Skip to content

Commit e497fef

Browse files
feat: Support REST transport (googleapis#20765)
1 parent dfaeca8 commit e497fef

File tree

80 files changed

+480
-603
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+480
-603
lines changed

google-analytics-admin/README.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,6 @@ In order to use this library, you first need to go through the following steps:
3131
1. [Enable the API.](https://console.cloud.google.com/apis/library/analyticsadmin.googleapis.com)
3232
1. {file:AUTHENTICATION.md Set up authentication.}
3333

34-
## Enabling Logging
35-
36-
To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
37-
The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/current/stdlibs/logger/Logger.html) as shown below,
38-
or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
39-
that will write logs to [Cloud Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
40-
and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
41-
42-
Configuring a Ruby stdlib logger:
43-
44-
```ruby
45-
require "logger"
46-
47-
module MyLogger
48-
LOGGER = Logger.new $stderr, level: Logger::WARN
49-
def logger
50-
LOGGER
51-
end
52-
end
53-
54-
# Define a gRPC module-level logger method before grpc/logconfig.rb loads.
55-
module GRPC
56-
extend MyLogger
57-
end
58-
```
59-
6034
## Supported Ruby Versions
6135

6236
This library is supported on Ruby 2.6+.

google-analytics-admin/google-analytics-admin.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Gem::Specification.new do |gem|
2222

2323
gem.required_ruby_version = ">= 2.6"
2424

25-
gem.add_dependency "google-analytics-admin-v1alpha", ">= 0.0", "< 2.a"
25+
gem.add_dependency "google-analytics-admin-v1alpha", ">= 0.16", "< 2.a"
2626
gem.add_dependency "google-cloud-core", "~> 1.6"
2727

2828
gem.add_development_dependency "google-style", "~> 1.26.1"

google-analytics-admin/lib/google/analytics/admin.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,27 @@ module Admin
3737
# `version` parameter. If the AnalyticsAdminService service is
3838
# supported by that API version, and the corresponding gem is available, the
3939
# appropriate versioned client will be returned.
40+
# You can also specify a different transport by passing `:rest` or `:grpc` in
41+
# the `transport` parameter.
4042
#
4143
# ## About AnalyticsAdminService
4244
#
4345
# Service Interface for the Analytics Admin API (GA4).
4446
#
4547
# @param version [::String, ::Symbol] The API version to connect to. Optional.
4648
# Defaults to `:v1alpha`.
49+
# @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`.
4750
# @return [::Object] A client object for the specified version.
4851
#
49-
def self.analytics_admin_service version: :v1alpha, &block
52+
def self.analytics_admin_service version: :v1alpha, transport: :grpc, &block
5053
require "google/analytics/admin/#{version.to_s.downcase}"
5154

5255
package_name = Google::Analytics::Admin
5356
.constants
5457
.select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
5558
.first
5659
service_module = Google::Analytics::Admin.const_get(package_name).const_get(:AnalyticsAdminService)
60+
service_module = service_module.const_get(:Rest) if transport == :rest
5761
service_module.const_get(:Client).new(&block)
5862
end
5963
end

google-analytics-admin/test/google/analytics/admin/client_test.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,25 @@
2020
require "google/analytics/admin"
2121
require "gapic/common"
2222
require "gapic/grpc"
23+
require "gapic/rest"
2324

2425
class Google::Analytics::Admin::ClientConstructionMinitest < Minitest::Test
2526
def test_analytics_admin_service_grpc
2627
Gapic::ServiceStub.stub :new, :stub do
2728
grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure
28-
client = Google::Analytics::Admin.analytics_admin_service do |config|
29+
client = Google::Analytics::Admin.analytics_admin_service transport: :grpc do |config|
2930
config.credentials = grpc_channel
3031
end
3132
assert_kind_of Google::Analytics::Admin::V1alpha::AnalyticsAdminService::Client, client
3233
end
3334
end
35+
36+
def test_analytics_admin_service_rest
37+
Gapic::Rest::ClientStub.stub :new, :stub do
38+
client = Google::Analytics::Admin.analytics_admin_service transport: :rest do |config|
39+
config.credentials = :dummy_credentials
40+
end
41+
assert_kind_of Google::Analytics::Admin::V1alpha::AnalyticsAdminService::Rest::Client, client
42+
end
43+
end
3444
end

google-analytics-data/README.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,6 @@ In order to use this library, you first need to go through the following steps:
3434
1. [Enable the API.](https://console.cloud.google.com/apis/library/analyticsdata.googleapis.com)
3535
1. {file:AUTHENTICATION.md Set up authentication.}
3636

37-
## Enabling Logging
38-
39-
To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
40-
The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/current/stdlibs/logger/Logger.html) as shown below,
41-
or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
42-
that will write logs to [Cloud Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
43-
and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
44-
45-
Configuring a Ruby stdlib logger:
46-
47-
```ruby
48-
require "logger"
49-
50-
module MyLogger
51-
LOGGER = Logger.new $stderr, level: Logger::WARN
52-
def logger
53-
LOGGER
54-
end
55-
end
56-
57-
# Define a gRPC module-level logger method before grpc/logconfig.rb loads.
58-
module GRPC
59-
extend MyLogger
60-
end
61-
```
62-
6337
## Supported Ruby Versions
6438

6539
This library is supported on Ruby 2.6+.

google-analytics-data/google-analytics-data.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Gem::Specification.new do |gem|
2222

2323
gem.required_ruby_version = ">= 2.6"
2424

25-
gem.add_dependency "google-analytics-data-v1beta", ">= 0.0", "< 2.a"
25+
gem.add_dependency "google-analytics-data-v1beta", ">= 0.7", "< 2.a"
2626
gem.add_dependency "google-cloud-core", "~> 1.6"
2727

2828
gem.add_development_dependency "google-style", "~> 1.26.1"

google-analytics-data/lib/google/analytics/data.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,27 @@ module Data
3737
# `version` parameter. If the AnalyticsData service is
3838
# supported by that API version, and the corresponding gem is available, the
3939
# appropriate versioned client will be returned.
40+
# You can also specify a different transport by passing `:rest` or `:grpc` in
41+
# the `transport` parameter.
4042
#
4143
# ## About AnalyticsData
4244
#
4345
# Google Analytics reporting data service.
4446
#
4547
# @param version [::String, ::Symbol] The API version to connect to. Optional.
4648
# Defaults to `:v1beta`.
49+
# @param transport [:grpc, :rest] The transport to use. Defaults to `:grpc`.
4750
# @return [::Object] A client object for the specified version.
4851
#
49-
def self.analytics_data version: :v1beta, &block
52+
def self.analytics_data version: :v1beta, transport: :grpc, &block
5053
require "google/analytics/data/#{version.to_s.downcase}"
5154

5255
package_name = Google::Analytics::Data
5356
.constants
5457
.select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
5558
.first
5659
service_module = Google::Analytics::Data.const_get(package_name).const_get(:AnalyticsData)
60+
service_module = service_module.const_get(:Rest) if transport == :rest
5761
service_module.const_get(:Client).new(&block)
5862
end
5963
end

google-analytics-data/test/google/analytics/data/client_test.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,25 @@
2020
require "google/analytics/data"
2121
require "gapic/common"
2222
require "gapic/grpc"
23+
require "gapic/rest"
2324

2425
class Google::Analytics::Data::ClientConstructionMinitest < Minitest::Test
2526
def test_analytics_data_grpc
2627
Gapic::ServiceStub.stub :new, :stub do
2728
grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure
28-
client = Google::Analytics::Data.analytics_data do |config|
29+
client = Google::Analytics::Data.analytics_data transport: :grpc do |config|
2930
config.credentials = grpc_channel
3031
end
3132
assert_kind_of Google::Analytics::Data::V1beta::AnalyticsData::Client, client
3233
end
3334
end
35+
36+
def test_analytics_data_rest
37+
Gapic::Rest::ClientStub.stub :new, :stub do
38+
client = Google::Analytics::Data.analytics_data transport: :rest do |config|
39+
config.credentials = :dummy_credentials
40+
end
41+
assert_kind_of Google::Analytics::Data::V1beta::AnalyticsData::Rest::Client, client
42+
end
43+
end
3444
end

google-area120-tables/README.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,32 +34,6 @@ In order to use this library, you first need to go through the following steps:
3434
1. [Enable the API.](https://console.cloud.google.com/apis/library/area120tables.googleapis.com)
3535
1. {file:AUTHENTICATION.md Set up authentication.}
3636

37-
## Enabling Logging
38-
39-
To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
40-
The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/current/stdlibs/logger/Logger.html) as shown below,
41-
or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
42-
that will write logs to [Cloud Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
43-
and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
44-
45-
Configuring a Ruby stdlib logger:
46-
47-
```ruby
48-
require "logger"
49-
50-
module MyLogger
51-
LOGGER = Logger.new $stderr, level: Logger::WARN
52-
def logger
53-
LOGGER
54-
end
55-
end
56-
57-
# Define a gRPC module-level logger method before grpc/logconfig.rb loads.
58-
module GRPC
59-
extend MyLogger
60-
end
61-
```
62-
6337
## Supported Ruby Versions
6438

6539
This library is supported on Ruby 2.6+.

google-area120-tables/google-area120-tables.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Gem::Specification.new do |gem|
2222

2323
gem.required_ruby_version = ">= 2.6"
2424

25-
gem.add_dependency "google-area120-tables-v1alpha1", ">= 0.0", "< 2.a"
25+
gem.add_dependency "google-area120-tables-v1alpha1", ">= 0.4", "< 2.a"
2626
gem.add_dependency "google-cloud-core", "~> 1.6"
2727

2828
gem.add_development_dependency "google-style", "~> 1.26.1"

0 commit comments

Comments
 (0)