Skip to content

Commit b8e9fb7

Browse files
feat: Add DataTableService to Chronicle v1 Client Libraries (#33830)
* feat: Add DataTableService to Chronicle v1 Client Libraries PiperOrigin-RevId: 898791366 Source-Link: googleapis/googleapis@e182cf5 Source-Link: googleapis/googleapis-gen@dab413d Copy-Tag: eyJwIjoiZ29vZ2xlLWNsb3VkLWNocm9uaWNsZS8uT3dsQm90LnlhbWwiLCJoIjoiZGFiNDEzZDQzYmQ0NzUzODZiMzc1ZDdkY2EzMTY5Y2IwNjNkY2Q4ZCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent af083bd commit b8e9fb7

5 files changed

Lines changed: 96 additions & 5 deletions

File tree

google-cloud-chronicle/.repo-metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"release_level": "preview",
1212
"repo": "googleapis/google-cloud-ruby",
1313
"requires_billing": true,
14-
"ruby-cloud-description": "The Google Cloud Security Operations API, popularly known as the Chronicle API, serves endpoints that enable security analysts to analyze and mitigate a security threat throughout its lifecycle.",
14+
"ruby-cloud-description": "The Google Cloud Security Operations API (Chronicle API) provides endpoints that help analysts investigate and mitigate security threats throughout their lifecycle.",
1515
"ruby-cloud-product-url": "https://cloud.google.com/chronicle/docs/secops/secops-overview",
1616
"library_type": "GAPIC_MANUAL"
1717
}

google-cloud-chronicle/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Ruby Client for the Chronicle API
22

3-
The Google Cloud Security Operations API, popularly known as the Chronicle API, serves endpoints that enable security analysts to analyze and mitigate a security threat throughout its lifecycle.
3+
The Google Cloud Security Operations API (Chronicle API) provides endpoints that help analysts investigate and mitigate security threats throughout their lifecycle.
44

5-
The Google Cloud Security Operations API, popularly known as the Chronicle API, serves endpoints that enable security analysts to analyze and mitigate a security threat throughout its lifecycle.
5+
The Google Cloud Security Operations API (Chronicle API) provides endpoints that help analysts investigate and mitigate security threats throughout their lifecycle.
66

77
Actual client classes for the various versions of this API are defined in
88
_versioned_ client gems, with names of the form `google-cloud-chronicle-v*`.

google-cloud-chronicle/google-cloud-chronicle.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Gem::Specification.new do |gem|
99

1010
gem.authors = ["Google LLC"]
1111
gem.email = "googleapis-packages@google.com"
12-
gem.description = "The Google Cloud Security Operations API, popularly known as the Chronicle API, serves endpoints that enable security analysts to analyze and mitigate a security threat throughout its lifecycle."
13-
gem.summary = "The Google Cloud Security Operations API, popularly known as the Chronicle API, serves endpoints that enable security analysts to analyze and mitigate a security threat throughout its lifecycle."
12+
gem.description = "The Google Cloud Security Operations API (Chronicle API) provides endpoints that help analysts investigate and mitigate security threats throughout their lifecycle."
13+
gem.summary = "The Google Cloud Security Operations API (Chronicle API) provides endpoints that help analysts investigate and mitigate security threats throughout their lifecycle."
1414
gem.homepage = "https://github.com/googleapis/google-cloud-ruby"
1515
gem.license = "Apache-2.0"
1616

google-cloud-chronicle/lib/google/cloud/chronicle.rb

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,76 @@ def self.data_access_control_service_available? version: :v1, transport: :grpc
116116
false
117117
end
118118

119+
##
120+
# Create a new client object for DataTableService.
121+
#
122+
# By default, this returns an instance of
123+
# [Google::Cloud::Chronicle::V1::DataTableService::Client](https://cloud.google.com/ruby/docs/reference/google-cloud-chronicle-v1/latest/Google-Cloud-Chronicle-V1-DataTableService-Client)
124+
# for a gRPC client for version V1 of the API.
125+
# However, you can specify a different API version by passing it in the
126+
# `version` parameter. If the DataTableService service is
127+
# supported by that API version, and the corresponding gem is available, the
128+
# appropriate versioned client will be returned.
129+
# You can also specify a different transport by passing `:rest` or `:grpc` in
130+
# the `transport` parameter.
131+
#
132+
# Raises an exception if the currently installed versioned client gem for the
133+
# given API version does not support the given transport of the DataTableService service.
134+
# You can determine whether the method will succeed by calling
135+
# {Google::Cloud::Chronicle.data_table_service_available?}.
136+
#
137+
# ## About DataTableService
138+
#
139+
# DataTableManager provides an interface for managing data tables.
140+
#
141+
# @param version [::String, ::Symbol] The API version to connect to. Optional.
142+
# Defaults to `:v1`.
143+
# @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`.
144+
# @return [::Object] A client object for the specified version.
145+
#
146+
def self.data_table_service version: :v1, transport: :grpc, &block
147+
require "google/cloud/chronicle/#{version.to_s.downcase}"
148+
149+
package_name = Google::Cloud::Chronicle
150+
.constants
151+
.select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
152+
.first
153+
service_module = Google::Cloud::Chronicle.const_get(package_name).const_get(:DataTableService)
154+
service_module = service_module.const_get(:Rest) if transport == :rest
155+
service_module.const_get(:Client).new(&block)
156+
end
157+
158+
##
159+
# Determines whether the DataTableService service is supported by the current client.
160+
# If true, you can retrieve a client object by calling {Google::Cloud::Chronicle.data_table_service}.
161+
# If false, that method will raise an exception. This could happen if the given
162+
# API version does not exist or does not support the DataTableService service,
163+
# or if the versioned client gem needs an update to support the DataTableService service.
164+
#
165+
# @param version [::String, ::Symbol] The API version to connect to. Optional.
166+
# Defaults to `:v1`.
167+
# @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`.
168+
# @return [boolean] Whether the service is available.
169+
#
170+
def self.data_table_service_available? version: :v1, transport: :grpc
171+
require "google/cloud/chronicle/#{version.to_s.downcase}"
172+
package_name = Google::Cloud::Chronicle
173+
.constants
174+
.select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
175+
.first
176+
return false unless package_name
177+
service_module = Google::Cloud::Chronicle.const_get package_name
178+
return false unless service_module.const_defined? :DataTableService
179+
service_module = service_module.const_get :DataTableService
180+
if transport == :rest
181+
return false unless service_module.const_defined? :Rest
182+
service_module = service_module.const_get :Rest
183+
end
184+
service_module.const_defined? :Client
185+
rescue ::LoadError
186+
false
187+
end
188+
119189
##
120190
# Create a new client object for EntityService.
121191
#

google-cloud-chronicle/test/google/cloud/chronicle/client_test.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,27 @@ def test_data_access_control_service_rest
6262
end
6363
end
6464

65+
def test_data_table_service_grpc
66+
skip unless Google::Cloud::Chronicle.data_table_service_available? transport: :grpc
67+
Gapic::ServiceStub.stub :new, DummyStub.new do
68+
grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure
69+
client = Google::Cloud::Chronicle.data_table_service transport: :grpc do |config|
70+
config.credentials = grpc_channel
71+
end
72+
assert_kind_of Google::Cloud::Chronicle::V1::DataTableService::Client, client
73+
end
74+
end
75+
76+
def test_data_table_service_rest
77+
skip unless Google::Cloud::Chronicle.data_table_service_available? transport: :rest
78+
Gapic::Rest::ClientStub.stub :new, DummyStub.new do
79+
client = Google::Cloud::Chronicle.data_table_service transport: :rest do |config|
80+
config.credentials = :dummy_credentials
81+
end
82+
assert_kind_of Google::Cloud::Chronicle::V1::DataTableService::Rest::Client, client
83+
end
84+
end
85+
6586
def test_entity_service_grpc
6687
skip unless Google::Cloud::Chronicle.entity_service_available? transport: :grpc
6788
Gapic::ServiceStub.stub :new, DummyStub.new do

0 commit comments

Comments
 (0)