gapic-generator-cloud 0.10.1 → 0.45.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +330 -0
- data/README.md +82 -61
- data/bin/protoc-gen-bazel_ruby_cloud +2 -2
- data/bin/protoc-gen-ruby_cloud +2 -2
- data/lib/gapic/generator/cloud/version.rb +1 -1
- data/lib/gapic/generators/cloud_generator.rb +20 -21
- data/lib/gapic/generators/cloud_generator_parameters.rb +5 -1
- data/lib/gapic/presenters/cloud_gem_presenter.rb +60 -13
- data/lib/gapic/presenters/wrapper_gem_presenter.rb +31 -9
- data/lib/gapic/presenters/wrapper_service_presenter.rb +23 -1
- data/lib/gapic/presenters/wrapper_service_rest_presenter.rb +49 -0
- data/templates/cloud/gem/authentication.text.erb +125 -0
- data/templates/cloud/gem/{rakefile.erb → rakefile.text.erb} +0 -37
- data/templates/cloud/gem/{readme.erb → readme.text.erb} +48 -26
- data/templates/cloud/gem/{repo-metadata.erb → repo-metadata.text.erb} +3 -0
- data/templates/cloud/gem/{rubocop.erb → rubocop.text.erb} +3 -0
- data/templates/cloud/gem/{yardopts.erb → yardopts.text.erb} +1 -1
- data/templates/cloud/service/rest/client/method/def/_rescue.text.erb +3 -0
- data/templates/cloud/wrapper_gem/{_main.erb → _main.text.erb} +69 -9
- data/templates/cloud/wrapper_gem/client_test.text.erb +59 -0
- data/templates/cloud/wrapper_gem/gemfile.text.erb +29 -0
- data/templates/cloud/wrapper_gem/{gemspec.erb → gemspec.text.erb} +2 -11
- data/templates/cloud/wrapper_gem/{rakefile.erb → rakefile.text.erb} +2 -37
- data/templates/cloud/wrapper_gem/{readme.erb → readme.text.erb} +45 -35
- data/templates/cloud/wrapper_gem/{version_test.erb → version_test.text.erb} +1 -1
- data/templates/cloud/wrapper_gem/{yardopts.erb → yardopts.text.erb} +1 -1
- metadata +34 -151
- data/templates/cloud/gem/authentication.erb +0 -174
- data/templates/cloud/gem/yardopts-cloudrad.erb +0 -15
- data/templates/cloud/service/rest/client/method/def/_rescue.erb +0 -4
- data/templates/cloud/wrapper_gem/client_test.erb +0 -22
- data/templates/cloud/wrapper_gem/gemfile.erb +0 -8
- data/templates/cloud/wrapper_gem/yardopts-cloudrad.erb +0 -17
- /data/templates/cloud/gem/{gitignore.erb → gitignore.text.erb} +0 -0
- /data/templates/cloud/gem/{license.erb → license.text.erb} +0 -0
- /data/templates/cloud/service/client/{_credentials.erb → _credentials.text.erb} +0 -0
- /data/templates/cloud/service/client/{_requires.erb → _requires.text.erb} +0 -0
- /data/templates/cloud/service/client/{_self_configure.erb → _self_configure.text.erb} +0 -0
- /data/templates/cloud/service/client/method/def/{_rescue.erb → _rescue.text.erb} +0 -0
- /data/templates/cloud/service/client/method/docs/{_error.erb → _error.text.erb} +0 -0
- /data/templates/cloud/service/rest/client/method/docs/{_error.erb → _error.text.erb} +0 -0
- /data/templates/cloud/shared/{_license.erb → _license.text.erb} +0 -0
- /data/templates/cloud/wrapper_gem/{entrypoint.erb → entrypoint.text.erb} +0 -0
- /data/templates/cloud/wrapper_gem/{main.erb → main.text.erb} +0 -0
- /data/templates/cloud/wrapper_gem/{rubocop.erb → rubocop.text.erb} +0 -0
@@ -23,6 +23,19 @@ module Gapic
|
|
23
23
|
# A presenter subclass for cloud gems.
|
24
24
|
#
|
25
25
|
class CloudGemPresenter < GemPresenter
|
26
|
+
# @private
|
27
|
+
# A list of gem name patterns for gems that don't look like cloud but are
|
28
|
+
PSEUDO_CLOUD_GEMS = [
|
29
|
+
/^google-iam-credentials/,
|
30
|
+
/^google-identity-access_context_manager/,
|
31
|
+
/^grafeas/,
|
32
|
+
/^stackdriver/
|
33
|
+
].freeze
|
34
|
+
|
35
|
+
# @private
|
36
|
+
# A list of gem name patterns for gems that look like cloud but aren't
|
37
|
+
NON_CLOUD_GEMS = [].freeze
|
38
|
+
|
26
39
|
def license_name
|
27
40
|
"Apache-2.0"
|
28
41
|
end
|
@@ -56,23 +69,18 @@ module Gapic
|
|
56
69
|
minfo ? minfo[1] : nil
|
57
70
|
end
|
58
71
|
|
59
|
-
alias_method :readme_description, :description # rubocop:disable Style/Alias
|
60
|
-
|
61
72
|
##
|
62
|
-
#
|
63
|
-
# consider installing the wrapper instead
|
64
|
-
#
|
65
|
-
# Note: The method `readme_description` was aliased to the superclass
|
66
|
-
# method because the description without this note is used in the readme.
|
73
|
+
# Increments the original gemspec description for versioned gems, including a
|
74
|
+
# note that users should consider installing the wrapper gem instead.
|
67
75
|
#
|
68
76
|
# @return [String]
|
69
77
|
#
|
70
|
-
def
|
71
|
-
desc =
|
78
|
+
def gemspec_description
|
79
|
+
desc = super
|
72
80
|
if has_wrapper?
|
73
|
-
desc += " Note that #{name} is a version-specific client library." \
|
74
|
-
|
75
|
-
|
81
|
+
desc += " Note that #{name} is a version-specific client library. " \
|
82
|
+
"For most uses, we recommend installing the main client library " \
|
83
|
+
"#{wrapper_name} instead. See the readme for more details."
|
76
84
|
end
|
77
85
|
desc
|
78
86
|
end
|
@@ -87,7 +95,7 @@ module Gapic
|
|
87
95
|
#
|
88
96
|
def generator_args_for_metadata
|
89
97
|
result = {}
|
90
|
-
result["ruby-cloud-description"] =
|
98
|
+
result["ruby-cloud-description"] = gemspec_description
|
91
99
|
result["ruby-cloud-env-prefix"] = env_prefix if env_prefix
|
92
100
|
result["ruby-cloud-product-url"] = product_documentation_url if product_documentation_url
|
93
101
|
path_overrides = @api.overrides_of(:file_path).map { |k, v| "#{k}=#{v}" }.join ";"
|
@@ -98,6 +106,45 @@ module Gapic
|
|
98
106
|
result["ruby-cloud-service-override"] = service_overrides unless service_overrides.empty?
|
99
107
|
result
|
100
108
|
end
|
109
|
+
|
110
|
+
##
|
111
|
+
# Overrides the reference doc URL to point to either the cloud-rad page
|
112
|
+
# or the rubydoc.info page depending on whether it is a cloud product.
|
113
|
+
#
|
114
|
+
# @return [String]
|
115
|
+
#
|
116
|
+
def library_documentation_url
|
117
|
+
gem_config(:library_documentation_url) || begin
|
118
|
+
if cloud_product?
|
119
|
+
"https://cloud.google.com/ruby/docs/reference/#{name}/latest"
|
120
|
+
else
|
121
|
+
"https://rubydoc.info/gems/#{name}"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
##
|
127
|
+
# Whether this gem is for a cloud platform product. This controls, for
|
128
|
+
# example, whether the reference documentation appears under the
|
129
|
+
# cloud.google.com website.
|
130
|
+
#
|
131
|
+
# This first uses the `is_cloud_product` config. If that isn't set, it
|
132
|
+
# tries the overrides in the `PSEUDO_CLOUD_GEMS` and `NON_CLOUD_GEMS`
|
133
|
+
# constants. Finally, it looks for whether any services populate the
|
134
|
+
# `Google::Cloud` namespace.
|
135
|
+
#
|
136
|
+
# @return [boolean]
|
137
|
+
#
|
138
|
+
def cloud_product?
|
139
|
+
configured = gem_config :is_cloud_product
|
140
|
+
return configured unless configured.nil?
|
141
|
+
return @api.api_metadata.organization == "CLOUD" if @api.api_metadata.organization
|
142
|
+
return true if PSEUDO_CLOUD_GEMS.any? { |pattern| pattern === name }
|
143
|
+
return false if NON_CLOUD_GEMS.any? { |pattern| pattern === name }
|
144
|
+
services.any? do |service|
|
145
|
+
service.namespace =~ /^(::)?Google::Cloud::/
|
146
|
+
end
|
147
|
+
end
|
101
148
|
end
|
102
149
|
|
103
150
|
def self.cloud_gem_presenter api
|
@@ -14,6 +14,7 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
|
+
require "gapic/model/mixins"
|
17
18
|
require "gapic/presenters"
|
18
19
|
require "gapic/presenters/wrapper_service_presenter"
|
19
20
|
|
@@ -29,8 +30,11 @@ module Gapic
|
|
29
30
|
|
30
31
|
def services
|
31
32
|
@services ||= begin
|
32
|
-
|
33
|
-
|
33
|
+
@api.generate_files
|
34
|
+
.map(&:services)
|
35
|
+
.flatten
|
36
|
+
.map { |s| WrapperServicePresenter.new self, @api, s }
|
37
|
+
.find_all { |s| !s.is_hosted_mixin? }
|
34
38
|
end
|
35
39
|
end
|
36
40
|
|
@@ -62,6 +66,18 @@ module Gapic
|
|
62
66
|
gem_config :migration_version
|
63
67
|
end
|
64
68
|
|
69
|
+
##
|
70
|
+
# Generates a description text for README files, accounting for markdown
|
71
|
+
# rendering, properly escaping variables and disabling xrefs in the wrapper.
|
72
|
+
#
|
73
|
+
# @return [Array<String>] The description text as an array of lines.
|
74
|
+
#
|
75
|
+
def readme_description
|
76
|
+
has_markdown = description.strip.start_with? "#"
|
77
|
+
desc = has_markdown ? description.split("\n") : [description.gsub(/\s+/, " ").strip]
|
78
|
+
Gapic::FormattingUtils.format_doc_lines @api, desc, disable_xrefs: true
|
79
|
+
end
|
80
|
+
|
65
81
|
# A description of the versions prior to the migration version.
|
66
82
|
# Could be "a.x" if the migration version is 1.0 or later, otherwise
|
67
83
|
# falls back to "pre-a.b".
|
@@ -132,15 +148,21 @@ module Gapic
|
|
132
148
|
m[1].tr "-", "_"
|
133
149
|
end
|
134
150
|
|
135
|
-
def docs_link version: nil, class_name: nil, text: nil
|
136
|
-
gem_name
|
137
|
-
base_url =
|
151
|
+
def docs_link version: nil, class_name: nil, text: nil, gem_name: nil
|
152
|
+
gem_name ||= version ? "#{name}-#{version}" : name
|
153
|
+
base_url =
|
154
|
+
if cloud_product?
|
155
|
+
"https://cloud.google.com/ruby/docs/reference/#{gem_name}/latest"
|
156
|
+
else
|
157
|
+
"https://rubydoc.info/gems/#{gem_name}"
|
158
|
+
end
|
138
159
|
if class_name
|
139
|
-
|
140
|
-
path =
|
141
|
-
|
160
|
+
separator = cloud_product? ? "-" : "/"
|
161
|
+
path = namespace.gsub "::", separator
|
162
|
+
path = "#{path}#{separator}#{version.capitalize}" if version
|
163
|
+
class_path = class_name.gsub "::", separator
|
142
164
|
text ||= namespaced_class class_name, version: version
|
143
|
-
return "[#{text}](#{base_url}/#{path}
|
165
|
+
return "[#{text}](#{base_url}/#{path}#{separator}#{class_path})"
|
144
166
|
end
|
145
167
|
"[#{text || name}](#{base_url})"
|
146
168
|
end
|
@@ -15,6 +15,7 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
require "gapic/presenters"
|
18
|
+
require "gapic/presenters/wrapper_service_rest_presenter"
|
18
19
|
require "gapic/ruby_info"
|
19
20
|
|
20
21
|
module Gapic
|
@@ -23,13 +24,34 @@ module Gapic
|
|
23
24
|
# A presenter for wrapper services.
|
24
25
|
#
|
25
26
|
class WrapperServicePresenter < ServicePresenter
|
27
|
+
def initialize *args, **kwargs
|
28
|
+
super(*args, **kwargs)
|
29
|
+
@rest = WrapperServiceRestPresenter.new self, @api
|
30
|
+
end
|
31
|
+
|
26
32
|
def factory_method_name
|
27
33
|
@factory_method_name ||= begin
|
28
34
|
method_name = ActiveSupport::Inflector.underscore name
|
29
35
|
suffix = gem.factory_method_suffix
|
30
36
|
method_name = "#{method_name}#{suffix}" unless method_name.end_with? suffix
|
31
37
|
method_name = "#{method_name}_client" if Gapic::RubyInfo.excluded_method_names.include? method_name
|
32
|
-
method_name
|
38
|
+
@api.fix_file_path method_name
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
##
|
43
|
+
# Returns this service presenter if there is a grpc client. Otherwise,
|
44
|
+
# returns the corresponding rest service presenter if there isn't a grpc
|
45
|
+
# client but there is a rest client. Otherwise, returns nil if there is
|
46
|
+
# neither client.
|
47
|
+
#
|
48
|
+
# @return [WrapperServicePresenter,WrapperServiceRestPresenter,nil]
|
49
|
+
#
|
50
|
+
def usable_service_presenter
|
51
|
+
if generate_grpc_clients?
|
52
|
+
self
|
53
|
+
elsif generate_rest_clients?
|
54
|
+
rest
|
33
55
|
end
|
34
56
|
end
|
35
57
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2022 Google LLC
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require "gapic/presenters"
|
18
|
+
require "gapic/ruby_info"
|
19
|
+
|
20
|
+
module Gapic
|
21
|
+
module Presenters
|
22
|
+
##
|
23
|
+
# A presenter for wrapper services.
|
24
|
+
#
|
25
|
+
class WrapperServiceRestPresenter < ServiceRestPresenter
|
26
|
+
def factory_method_name
|
27
|
+
@factory_method_name ||= begin
|
28
|
+
method_name = ActiveSupport::Inflector.underscore main_service.name
|
29
|
+
suffix = main_service.gem.factory_method_suffix
|
30
|
+
method_name = "#{method_name}#{suffix}" unless method_name.end_with? suffix
|
31
|
+
method_name = "#{method_name}_client" if Gapic::RubyInfo.excluded_method_names.include? method_name
|
32
|
+
method_name
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def create_client_call
|
37
|
+
"#{main_service.gem.namespace}.#{factory_method_name}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def configure_client_call
|
41
|
+
"#{main_service.gem.namespace}.configure"
|
42
|
+
end
|
43
|
+
|
44
|
+
def credentials_class_xref
|
45
|
+
"`#{main_service.credentials_name_full}`"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
<%- assert_locals gem -%>
|
2
|
+
<%- service = gem.first_non_common_service.usable_service_presenter -%>
|
3
|
+
<%- assert_locals service -%>
|
4
|
+
# Authentication
|
5
|
+
|
6
|
+
The recommended way to authenticate to the <%= gem.name %> library is to use
|
7
|
+
[Application Default Credentials (ADC)](https://cloud.google.com/docs/authentication/application-default-credentials).
|
8
|
+
To review all of your authentication options, see [Credentials lookup](#credential-lookup).
|
9
|
+
|
10
|
+
## Quickstart
|
11
|
+
|
12
|
+
The following example shows how to set up authentication for a local development
|
13
|
+
environment with your user credentials.
|
14
|
+
|
15
|
+
**NOTE:** This method is _not_ recommended for running in production. User credentials
|
16
|
+
should be used only during development.
|
17
|
+
|
18
|
+
1. [Download and install the Google Cloud CLI](https://cloud.google.com/sdk).
|
19
|
+
2. Set up a local ADC file with your user credentials:
|
20
|
+
|
21
|
+
```sh
|
22
|
+
gcloud auth application-default login
|
23
|
+
```
|
24
|
+
|
25
|
+
3. Write code as if already authenticated.
|
26
|
+
|
27
|
+
For more information about setting up authentication for a local development environment, see
|
28
|
+
[Set up Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc#local-dev).
|
29
|
+
|
30
|
+
## Credential Lookup
|
31
|
+
|
32
|
+
The <%= gem.name %> library provides several mechanisms to configure your system.
|
33
|
+
Generally, using Application Default Credentials to facilitate automatic
|
34
|
+
credentials discovery is the easist method. But if you need to explicitly specify
|
35
|
+
credentials, there are several methods available to you.
|
36
|
+
|
37
|
+
Credentials are accepted in the following ways, in the following order or precedence:
|
38
|
+
|
39
|
+
1. Credentials specified in method arguments
|
40
|
+
2. Credentials specified in configuration
|
41
|
+
3. Credentials pointed to or included in environment variables
|
42
|
+
4. Credentials found in local ADC file
|
43
|
+
5. Credentials returned by the metadata server for the attached service account (GCP)
|
44
|
+
|
45
|
+
### Configuration
|
46
|
+
|
47
|
+
You can configure a path to a JSON credentials file, either for an individual client object or
|
48
|
+
globally, for all client objects. The JSON file can contain credentials created for
|
49
|
+
[workload identity federation](https://cloud.google.com/iam/docs/workload-identity-federation),
|
50
|
+
[workforce identity federation](https://cloud.google.com/iam/docs/workforce-identity-federation), or a
|
51
|
+
[service account key](https://cloud.google.com/docs/authentication/provide-credentials-adc#local-key).
|
52
|
+
|
53
|
+
Note: Service account keys are a security risk if not managed correctly. You should
|
54
|
+
[choose a more secure alternative to service account keys](https://cloud.google.com/docs/authentication#auth-decision-tree)
|
55
|
+
whenever possible.
|
56
|
+
|
57
|
+
To configure a credentials file for an individual client initialization:
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
require "<%= gem.entrypoint_require %>"
|
61
|
+
|
62
|
+
client = <%= service.create_client_call %> do |config|
|
63
|
+
config.credentials = "path/to/credentialfile.json"
|
64
|
+
end
|
65
|
+
```
|
66
|
+
|
67
|
+
To configure a credentials file globally for all clients:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
require "<%= gem.entrypoint_require %>"
|
71
|
+
|
72
|
+
<%= service.configure_client_call %> do |config|
|
73
|
+
config.credentials = "path/to/credentialfile.json"
|
74
|
+
end
|
75
|
+
|
76
|
+
client = <%= service.create_client_call %>
|
77
|
+
```
|
78
|
+
|
79
|
+
### Environment Variables
|
80
|
+
|
81
|
+
You can also use an environment variable to provide a JSON credentials file.
|
82
|
+
The environment variable can contain a path to the credentials file or, for
|
83
|
+
environments such as Docker containers where writing files is not encouraged,
|
84
|
+
you can include the credentials file itself.
|
85
|
+
|
86
|
+
The JSON file can contain credentials created for
|
87
|
+
[workload identity federation](https://cloud.google.com/iam/docs/workload-identity-federation),
|
88
|
+
[workforce identity federation](https://cloud.google.com/iam/docs/workforce-identity-federation), or a
|
89
|
+
[service account key](https://cloud.google.com/docs/authentication/provide-credentials-adc#local-key).
|
90
|
+
|
91
|
+
Note: Service account keys are a security risk if not managed correctly. You should
|
92
|
+
[choose a more secure alternative to service account keys](https://cloud.google.com/docs/authentication#auth-decision-tree)
|
93
|
+
whenever possible.
|
94
|
+
|
95
|
+
The environment variables that <%= gem.name %>
|
96
|
+
checks for credentials are:
|
97
|
+
|
98
|
+
* `GOOGLE_CLOUD_CREDENTIALS` - Path to JSON file, or JSON contents
|
99
|
+
* `GOOGLE_APPLICATION_CREDENTIALS` - Path to JSON file
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
require "<%= gem.entrypoint_require %>"
|
103
|
+
|
104
|
+
ENV["GOOGLE_APPLICATION_CREDENTIALS"] = "path/to/credentialfile.json"
|
105
|
+
|
106
|
+
client = <%= service.create_client_call %>
|
107
|
+
```
|
108
|
+
|
109
|
+
### Local ADC file
|
110
|
+
|
111
|
+
You can set up a local ADC file with your user credentials for authentication during
|
112
|
+
development. If credentials are not provided in code or in environment variables,
|
113
|
+
then the local ADC credentials are discovered.
|
114
|
+
|
115
|
+
Follow the steps in [Quickstart](#quickstart) to set up a local ADC file.
|
116
|
+
|
117
|
+
### Google Cloud Platform environments
|
118
|
+
|
119
|
+
When running on Google Cloud Platform (GCP), including Google Compute Engine
|
120
|
+
(GCE), Google Kubernetes Engine (GKE), Google App Engine (GAE), Google Cloud
|
121
|
+
Functions (GCF) and Cloud Run, credentials are retrieved from the attached
|
122
|
+
service account automatically. Code should be written as if already authenticated.
|
123
|
+
|
124
|
+
For more information, see
|
125
|
+
[Set up ADC for Google Cloud services](https://cloud.google.com/docs/authentication/provide-credentials-adc#attached-sa).
|
@@ -16,40 +16,12 @@ Rake::TestTask.new do |t|
|
|
16
16
|
t.warning = false
|
17
17
|
end
|
18
18
|
|
19
|
-
namespace :test do
|
20
|
-
desc "Runs tests with coverage."
|
21
|
-
task :coverage do
|
22
|
-
require "simplecov"
|
23
|
-
SimpleCov.start do
|
24
|
-
command_name "<%= gem.name %>"
|
25
|
-
track_files "lib/**/*.rb"
|
26
|
-
add_filter "test/"
|
27
|
-
end
|
28
|
-
|
29
|
-
Rake::Task[:test].invoke
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
19
|
desc "Runs the smoke tests."
|
34
20
|
Rake::TestTask.new :smoke_test do |t|
|
35
21
|
t.test_files = FileList["acceptance/**/*smoke_test.rb"]
|
36
22
|
t.warning = false
|
37
23
|
end
|
38
24
|
|
39
|
-
namespace :smoke_test do
|
40
|
-
desc "Runs smoke tests with coverage."
|
41
|
-
task :coverage do
|
42
|
-
require "simplecov"
|
43
|
-
SimpleCov.start do
|
44
|
-
command_name "<%= gem.name %>"
|
45
|
-
track_files "lib/**/*.rb"
|
46
|
-
add_filter "test/"
|
47
|
-
end
|
48
|
-
|
49
|
-
Rake::Task[:smoke_test].invoke
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
25
|
# Acceptance tests
|
54
26
|
desc "Run the <%= gem.name %> acceptance tests."
|
55
27
|
task :acceptance, :project, :keyfile do |t, args|
|
@@ -93,10 +65,6 @@ namespace :acceptance do
|
|
93
65
|
end
|
94
66
|
end
|
95
67
|
|
96
|
-
desc "Run acceptance tests with coverage."
|
97
|
-
task :coverage do
|
98
|
-
end
|
99
|
-
|
100
68
|
desc "Run acceptance cleanup."
|
101
69
|
task :cleanup do
|
102
70
|
end
|
@@ -149,11 +117,6 @@ task :doctest do
|
|
149
117
|
puts "The <%= gem.name %> gem does not have doctest tests."
|
150
118
|
end
|
151
119
|
|
152
|
-
task :cloudrad do
|
153
|
-
ENV["CLOUDRAD_GEM_NAME"] = "<%= gem.name %>"
|
154
|
-
sh "bundle exec yard doc --fail-on-warning --yardopts .yardopts-cloudrad"
|
155
|
-
end
|
156
|
-
|
157
120
|
desc "Run the CI build"
|
158
121
|
task :ci do
|
159
122
|
header "BUILDING <%= gem.name %>"
|
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
<%= gem.summary %>
|
4
4
|
|
5
|
-
|
5
|
+
<%- if gem.summary != gem.description %>
|
6
|
+
<% gem.readme_description.each do |line| %>
|
7
|
+
<%= line %>
|
8
|
+
<% end %>
|
9
|
+
<%- end %>
|
6
10
|
|
7
11
|
<%= gem.homepage %>
|
8
12
|
|
@@ -65,44 +69,62 @@ See also the [Product Documentation](<%= gem.product_documentation_url %>)
|
|
65
69
|
for general usage information.
|
66
70
|
|
67
71
|
<%- end -%>
|
68
|
-
<%- if gem.
|
69
|
-
##
|
72
|
+
<%- if gem.show_logging_docs? -%>
|
73
|
+
## Debug Logging
|
74
|
+
|
75
|
+
This library comes with opt-in Debug Logging that can help you troubleshoot
|
76
|
+
your application's integration with the API. When logging is activated, key
|
77
|
+
events such as requests and responses, along with data payloads and metadata
|
78
|
+
such as headers and client configuration, are logged to the standard error
|
79
|
+
stream.
|
80
|
+
|
81
|
+
**WARNING:** Client Library Debug Logging includes your data payloads in
|
82
|
+
plaintext, which could include sensitive data such as PII for yourself or your
|
83
|
+
customers, private keys, or other security data that could be compromising if
|
84
|
+
leaked. Always practice good data hygiene with your application logs, and follow
|
85
|
+
the principle of least access. Google also recommends that Client Library Debug
|
86
|
+
Logging be enabled only temporarily during active debugging, and not used
|
87
|
+
permanently in production.
|
88
|
+
|
89
|
+
To enable logging, set the environment variable `GOOGLE_SDK_RUBY_LOGGING_GEMS`
|
90
|
+
to the value `all`. Alternatively, you can set the value to a comma-delimited
|
91
|
+
list of client library gem names. This will select the default logging behavior,
|
92
|
+
which writes logs to the standard error stream. On a local workstation, this may
|
93
|
+
result in logs appearing on the console. When running on a Google Cloud hosting
|
94
|
+
service such as [Google Cloud Run](https://cloud.google.com/run), this generally
|
95
|
+
results in logs appearing alongside your application logs in the
|
96
|
+
[Google Cloud Logging](https://cloud.google.com/logging/) service.
|
70
97
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
|
76
|
-
|
77
|
-
Configuring a Ruby stdlib logger:
|
98
|
+
<%- service = gem.quick_start_service.usable_service_presenter -%>
|
99
|
+
<%- if service -%>
|
100
|
+
You can customize logging by modifying the `logger` configuration when
|
101
|
+
constructing a client object. For example:
|
78
102
|
|
79
103
|
```ruby
|
104
|
+
require "<%= gem.entrypoint_require %>"
|
80
105
|
require "logger"
|
81
106
|
|
82
|
-
|
83
|
-
|
84
|
-
def logger
|
85
|
-
LOGGER
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
# Define a gRPC module-level logger method before grpc/logconfig.rb loads.
|
90
|
-
module GRPC
|
91
|
-
extend MyLogger
|
107
|
+
client = <%= service.create_client_call %> do |config|
|
108
|
+
config.logger = Logger.new "my-app.log"
|
92
109
|
end
|
93
110
|
```
|
94
|
-
|
95
111
|
<%- end -%>
|
112
|
+
<%- end -%>
|
113
|
+
|
114
|
+
## Google Cloud Samples
|
115
|
+
|
116
|
+
To browse ready to use code samples check [Google Cloud Samples](https://cloud.google.com/docs/samples).
|
117
|
+
|
96
118
|
## Supported Ruby Versions
|
97
119
|
|
98
|
-
This library is supported on Ruby
|
120
|
+
This library is supported on Ruby 3.0+.
|
99
121
|
|
100
122
|
Google provides official support for Ruby versions that are actively supported
|
101
123
|
by Ruby Core—that is, Ruby versions that are either in normal maintenance or
|
102
|
-
in security maintenance, and not end of life.
|
103
|
-
|
104
|
-
|
105
|
-
|
124
|
+
in security maintenance, and not end of life. Older versions of Ruby _may_
|
125
|
+
still work, but are unsupported and not recommended. See
|
126
|
+
https://www.ruby-lang.org/en/downloads/branches/ for details about the Ruby
|
127
|
+
support schedule.
|
106
128
|
<%- if gem.wrapper_name -%>
|
107
129
|
|
108
130
|
## Which client should I use?
|
@@ -3,8 +3,10 @@
|
|
3
3
|
<%- if gem.api_id -%>
|
4
4
|
"api_id": "<%= gem.api_id %>",
|
5
5
|
<%- end -%>
|
6
|
+
"api_shortname": "<%= gem.api_shortname || 'unknown' %>",
|
6
7
|
"client_documentation": "<%= gem.library_documentation_url %>",
|
7
8
|
"distribution_name": "<%= gem.name %>",
|
9
|
+
"is_cloud": <%= gem.cloud_product? %>,
|
8
10
|
<%- if gem.issue_tracker_url -%>
|
9
11
|
"issue_tracker": "<%= gem.issue_tracker_url %>",
|
10
12
|
<%- end -%>
|
@@ -16,6 +18,7 @@
|
|
16
18
|
<%- if gem.product_documentation_url -%>
|
17
19
|
"product_documentation": "<%= gem.product_documentation_url %>",
|
18
20
|
<%- end -%>
|
21
|
+
"release_level": "unreleased",
|
19
22
|
"repo": "googleapis/google-cloud-ruby",
|
20
23
|
"requires_billing": <%= !gem.free_tier? %>,
|
21
24
|
<%- gem.generator_args_for_metadata.each do |key, val| -%>
|