Skip to content

Commit de9f707

Browse files
feat(alloydb): Support for the AlloyDBCloudSQLAdmin service (#30351)
1 parent a0e1009 commit de9f707

5 files changed

Lines changed: 94 additions & 2 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
"requires_billing": true,
1414
"ruby-cloud-description": "AlloyDB for PostgreSQL is an open source-compatible database service that provides a powerful option for migrating, modernizing, or building commercial-grade applications. It offers full compatibility with standard PostgreSQL, and is more than 4x faster for transactional workloads and up to 100x faster for analytical queries than standard PostgreSQL in our performance tests. AlloyDB for PostgreSQL offers a 99.99 percent availability SLA inclusive of maintenance. AlloyDB is optimized for the most demanding use cases, allowing you to build new applications that require high transaction throughput, large database sizes, or multiple read resources; scale existing PostgreSQL workloads with no application changes; and modernize legacy proprietary databases.",
1515
"ruby-cloud-product-url": "https://cloud.google.com/alloydb/docs",
16+
"ruby-cloud-service-override": "AlloyDBCSQLAdmin=AlloyDBCloudSQLAdmin",
1617
"library_type": "GAPIC_MANUAL"
1718
}

google-cloud-alloy_db/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ruby Client for the AlloyDB API
22

3-
AlloyDB for PostgreSQL is an open source-compatible database service that provides a powerful option for migrating, modernizing, or building commercial-grade applications. It offers full compatibility with standard PostgreSQL, and is more than 4x faster for transactional workloads and up to 100x faster for analytical queries than standard PostgreSQL in our performance tests. AlloyDB for PostgreSQL offers a 99.99 percent availability SLA inclusive of maintenance. AlloyDB is optimized for the most demanding use cases, allowing you to build new applications that require high transaction throughput, large database sizes, or multiple read resources; scale existing PostgreSQL workloads with no application changes; and modernize legacy proprietary databases.
3+
AlloyDB for PostgreSQL is an open source-compatible database service that provides a powerful option for migrating, modernizing, or building commercial-grade applications. It offers full compatibility with standard PostgreSQL, and is more than 4x faster for transactional workloads and up to 100x faster for analytical queries than standard PostgreSQL in our performance tests. AlloyDB for PostgreSQL offers a 99.99 percent availability SLA inclusive of maintenance. AlloyDB is optimized for the most demanding use cases, allowing you to build new applications that require high transaction throughput, large database sizes, or multiple read resources; scale existing PostgreSQL workloads with no application changes; and modernize legacy proprietary databases.
44

55
AlloyDB for PostgreSQL is an open source-compatible database service that provides a powerful option for migrating, modernizing, or building commercial-grade applications. It offers full compatibility with standard PostgreSQL, and is more than 4x faster for transactional workloads and up to 100x faster for analytical queries than standard PostgreSQL in our performance tests. AlloyDB for PostgreSQL offers a 99.99 percent availability SLA inclusive of maintenance. AlloyDB is optimized for the most demanding use cases, allowing you to build new applications that require high transaction throughput, large database sizes, or multiple read resources; scale existing PostgreSQL workloads with no application changes; and modernize legacy proprietary databases.
66

google-cloud-alloy_db/google-cloud-alloy_db.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
1010
gem.authors = ["Google LLC"]
1111
gem.email = "googleapis-packages@google.com"
1212
gem.description = "AlloyDB for PostgreSQL is an open source-compatible database service that provides a powerful option for migrating, modernizing, or building commercial-grade applications. It offers full compatibility with standard PostgreSQL, and is more than 4x faster for transactional workloads and up to 100x faster for analytical queries than standard PostgreSQL in our performance tests. AlloyDB for PostgreSQL offers a 99.99 percent availability SLA inclusive of maintenance. AlloyDB is optimized for the most demanding use cases, allowing you to build new applications that require high transaction throughput, large database sizes, or multiple read resources; scale existing PostgreSQL workloads with no application changes; and modernize legacy proprietary databases."
13-
gem.summary = "AlloyDB for PostgreSQL is an open source-compatible database service that provides a powerful option for migrating, modernizing, or building commercial-grade applications. It offers full compatibility with standard PostgreSQL, and is more than 4x faster for transactional workloads and up to 100x faster for analytical queries than standard PostgreSQL in our performance tests. AlloyDB for PostgreSQL offers a 99.99 percent availability SLA inclusive of maintenance. AlloyDB is optimized for the most demanding use cases, allowing you to build new applications that require high transaction throughput, large database sizes, or multiple read resources; scale existing PostgreSQL workloads with no application changes; and modernize legacy proprietary databases."
13+
gem.summary = "AlloyDB for PostgreSQL is an open source-compatible database service that provides a powerful option for migrating, modernizing, or building commercial-grade applications. It offers full compatibility with standard PostgreSQL, and is more than 4x faster for transactional workloads and up to 100x faster for analytical queries than standard PostgreSQL in our performance tests. AlloyDB for PostgreSQL offers a 99.99 percent availability SLA inclusive of maintenance. AlloyDB is optimized for the most demanding use cases, allowing you to build new applications that require high transaction throughput, large database sizes, or multiple read resources; scale existing PostgreSQL workloads with no application changes; and modernize legacy proprietary databases."
1414
gem.homepage = "https://github.com/googleapis/google-cloud-ruby"
1515
gem.license = "Apache-2.0"
1616

google-cloud-alloy_db/lib/google/cloud/alloy_db.rb

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

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

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,25 @@ def test_alloy_db_admin_rest
6161
assert_kind_of Google::Cloud::AlloyDB::V1::AlloyDBAdmin::Rest::Client, client
6262
end
6363
end
64+
65+
def test_alloy_db_cloud_sql_admin_grpc
66+
skip unless Google::Cloud::AlloyDB.alloy_db_cloud_sql_admin_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::AlloyDB.alloy_db_cloud_sql_admin transport: :grpc do |config|
70+
config.credentials = grpc_channel
71+
end
72+
assert_kind_of Google::Cloud::AlloyDB::V1::AlloyDBCloudSQLAdmin::Client, client
73+
end
74+
end
75+
76+
def test_alloy_db_cloud_sql_admin_rest
77+
skip unless Google::Cloud::AlloyDB.alloy_db_cloud_sql_admin_available? transport: :rest
78+
Gapic::Rest::ClientStub.stub :new, DummyStub.new do
79+
client = Google::Cloud::AlloyDB.alloy_db_cloud_sql_admin transport: :rest do |config|
80+
config.credentials = :dummy_credentials
81+
end
82+
assert_kind_of Google::Cloud::AlloyDB::V1::AlloyDBCloudSQLAdmin::Rest::Client, client
83+
end
84+
end
6485
end

0 commit comments

Comments
 (0)