Skip to content

Commit 194fc9b

Browse files
1 parent 9bd22b4 commit 194fc9b

23 files changed

Lines changed: 99 additions & 2048 deletions

File tree

β€Žgoogle-cloud-chronicle/AUTHENTICATION.mdβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ To configure a credentials file for an individual client initialization:
5656
```ruby
5757
require "google/cloud/chronicle"
5858

59-
client = Google::Cloud::Chronicle.dashboard_query_service do |config|
59+
client = Google::Cloud::Chronicle.big_query_export_service do |config|
6060
config.credentials = "path/to/credentialfile.json"
6161
end
6262
```
@@ -70,7 +70,7 @@ Google::Cloud::Chronicle.configure do |config|
7070
config.credentials = "path/to/credentialfile.json"
7171
end
7272

73-
client = Google::Cloud::Chronicle.dashboard_query_service
73+
client = Google::Cloud::Chronicle.big_query_export_service
7474
```
7575

7676
### Environment Variables
@@ -100,7 +100,7 @@ require "google/cloud/chronicle"
100100

101101
ENV["GOOGLE_APPLICATION_CREDENTIALS"] = "path/to/credentialfile.json"
102102

103-
client = Google::Cloud::Chronicle.dashboard_query_service
103+
client = Google::Cloud::Chronicle.big_query_export_service
104104
```
105105

106106
### Local ADC file

β€Žgoogle-cloud-chronicle/README.mdβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ In order to use this library, you first need to go through the following steps:
3737
```ruby
3838
require "google/cloud/chronicle"
3939

40-
client = Google::Cloud::Chronicle.dashboard_query_service
41-
request = ::Google::Cloud::Chronicle::V1::GetDashboardQueryRequest.new # (request fields as keyword arguments...)
42-
response = client.get_dashboard_query request
40+
client = Google::Cloud::Chronicle.big_query_export_service
41+
request = ::Google::Cloud::Chronicle::V1::GetBigQueryExportRequest.new # (request fields as keyword arguments...)
42+
response = client.get_big_query_export request
4343
```
4444

4545
## Debug Logging

β€Žgoogle-cloud-chronicle/Rakefileβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ task :acceptance, :project, :keyfile do |t, args|
5757
if project.nil? || keyfile.nil?
5858
fail "You must provide a project and keyfile. e.g. rake acceptance[test123, /path/to/keyfile.json] or GOOGLE_CLOUD_TEST_PROJECT=test123 GOOGLE_CLOUD_TEST_KEYFILE=/path/to/keyfile.json rake acceptance"
5959
end
60-
require "google/cloud/chronicle/v1/dashboard_query_service/credentials"
61-
::Google::Cloud::Chronicle::V1::DashboardQueryService::Credentials.env_vars.each do |path|
60+
require "google/cloud/chronicle/v1/big_query_export_service/credentials"
61+
::Google::Cloud::Chronicle::V1::BigQueryExportService::Credentials.env_vars.each do |path|
6262
ENV[path] = nil
6363
end
6464
ENV["GOOGLE_CLOUD_PROJECT"] = project

β€Žgoogle-cloud-chronicle/lib/google/cloud/chronicle.rbβ€Ž

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,76 @@
4545
module Google
4646
module Cloud
4747
module Chronicle
48+
##
49+
# Create a new client object for BigQueryExportService.
50+
#
51+
# By default, this returns an instance of
52+
# [Google::Cloud::Chronicle::V1::BigQueryExportService::Client](https://cloud.google.com/ruby/docs/reference/google-cloud-chronicle-v1/latest/Google-Cloud-Chronicle-V1-BigQueryExportService-Client)
53+
# for a gRPC client for version V1 of the API.
54+
# However, you can specify a different API version by passing it in the
55+
# `version` parameter. If the BigQueryExportService service is
56+
# supported by that API version, and the corresponding gem is available, the
57+
# appropriate versioned client will be returned.
58+
# You can also specify a different transport by passing `:rest` or `:grpc` in
59+
# the `transport` parameter.
60+
#
61+
# Raises an exception if the currently installed versioned client gem for the
62+
# given API version does not support the given transport of the BigQueryExportService service.
63+
# You can determine whether the method will succeed by calling
64+
# {Google::Cloud::Chronicle.big_query_export_service_available?}.
65+
#
66+
# ## About BigQueryExportService
67+
#
68+
# Service for managing BigQuery export configurations for Chronicle instances.
69+
#
70+
# @param version [::String, ::Symbol] The API version to connect to. Optional.
71+
# Defaults to `:v1`.
72+
# @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`.
73+
# @return [::Object] A client object for the specified version.
74+
#
75+
def self.big_query_export_service version: :v1, transport: :grpc, &block
76+
require "google/cloud/chronicle/#{version.to_s.downcase}"
77+
78+
package_name = Google::Cloud::Chronicle
79+
.constants
80+
.select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
81+
.first
82+
service_module = Google::Cloud::Chronicle.const_get(package_name).const_get(:BigQueryExportService)
83+
service_module = service_module.const_get(:Rest) if transport == :rest
84+
service_module.const_get(:Client).new(&block)
85+
end
86+
87+
##
88+
# Determines whether the BigQueryExportService service is supported by the current client.
89+
# If true, you can retrieve a client object by calling {Google::Cloud::Chronicle.big_query_export_service}.
90+
# If false, that method will raise an exception. This could happen if the given
91+
# API version does not exist or does not support the BigQueryExportService service,
92+
# or if the versioned client gem needs an update to support the BigQueryExportService service.
93+
#
94+
# @param version [::String, ::Symbol] The API version to connect to. Optional.
95+
# Defaults to `:v1`.
96+
# @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`.
97+
# @return [boolean] Whether the service is available.
98+
#
99+
def self.big_query_export_service_available? version: :v1, transport: :grpc
100+
require "google/cloud/chronicle/#{version.to_s.downcase}"
101+
package_name = Google::Cloud::Chronicle
102+
.constants
103+
.select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
104+
.first
105+
return false unless package_name
106+
service_module = Google::Cloud::Chronicle.const_get package_name
107+
return false unless service_module.const_defined? :BigQueryExportService
108+
service_module = service_module.const_get :BigQueryExportService
109+
if transport == :rest
110+
return false unless service_module.const_defined? :Rest
111+
service_module = service_module.const_get :Rest
112+
end
113+
service_module.const_defined? :Client
114+
rescue ::LoadError
115+
false
116+
end
117+
48118
##
49119
# Create a new client object for DashboardQueryService.
50120
#

β€Žgoogle-cloud-chronicle/test/google/cloud/chronicle/client_test.rbβ€Ž

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,27 @@ def logger
4141
end
4242
end
4343

44+
def test_big_query_export_service_grpc
45+
skip unless Google::Cloud::Chronicle.big_query_export_service_available? transport: :grpc
46+
Gapic::ServiceStub.stub :new, DummyStub.new do
47+
grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure
48+
client = Google::Cloud::Chronicle.big_query_export_service transport: :grpc do |config|
49+
config.credentials = grpc_channel
50+
end
51+
assert_kind_of Google::Cloud::Chronicle::V1::BigQueryExportService::Client, client
52+
end
53+
end
54+
55+
def test_big_query_export_service_rest
56+
skip unless Google::Cloud::Chronicle.big_query_export_service_available? transport: :rest
57+
Gapic::Rest::ClientStub.stub :new, DummyStub.new do
58+
client = Google::Cloud::Chronicle.big_query_export_service transport: :rest do |config|
59+
config.credentials = :dummy_credentials
60+
end
61+
assert_kind_of Google::Cloud::Chronicle::V1::BigQueryExportService::Rest::Client, client
62+
end
63+
end
64+
4465
def test_dashboard_query_service_grpc
4566
skip unless Google::Cloud::Chronicle.dashboard_query_service_available? transport: :grpc
4667
Gapic::ServiceStub.stub :new, DummyStub.new do

β€Žowl-bot-staging/google-cloud-chronicle/.gitignoreβ€Ž

Lines changed: 0 additions & 22 deletions
This file was deleted.

β€Žowl-bot-staging/google-cloud-chronicle/.repo-metadata.jsonβ€Ž

Lines changed: 0 additions & 17 deletions
This file was deleted.

β€Žowl-bot-staging/google-cloud-chronicle/.rubocop.ymlβ€Ž

Lines changed: 0 additions & 39 deletions
This file was deleted.

β€Žowl-bot-staging/google-cloud-chronicle/.toys.rbβ€Ž

Lines changed: 0 additions & 28 deletions
This file was deleted.

β€Žowl-bot-staging/google-cloud-chronicle/.yardoptsβ€Ž

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
Β (0)