google-cloud-service_control-v1 0.4.6 → 0.6.0

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.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +1 -1
  3. data/README.md +13 -8
  4. data/lib/google/api/servicecontrol/v1/check_error_pb.rb +2 -1
  5. data/lib/google/api/servicecontrol/v1/distribution_pb.rb +2 -1
  6. data/lib/google/api/servicecontrol/v1/http_request_pb.rb +2 -1
  7. data/lib/google/api/servicecontrol/v1/log_entry_pb.rb +2 -1
  8. data/lib/google/api/servicecontrol/v1/metric_value_pb.rb +2 -1
  9. data/lib/google/api/servicecontrol/v1/operation_pb.rb +2 -1
  10. data/lib/google/api/servicecontrol/v1/quota_controller_pb.rb +2 -1
  11. data/lib/google/api/servicecontrol/v1/service_controller_pb.rb +2 -2
  12. data/lib/google/cloud/service_control/v1/quota_controller/rest/client.rb +364 -0
  13. data/lib/google/cloud/service_control/v1/quota_controller/rest/service_stub.rb +108 -0
  14. data/lib/google/cloud/service_control/v1/quota_controller/rest.rb +54 -0
  15. data/lib/google/cloud/service_control/v1/quota_controller.rb +7 -1
  16. data/lib/google/cloud/service_control/v1/rest.rb +38 -0
  17. data/lib/google/cloud/service_control/v1/service_controller/rest/client.rb +487 -0
  18. data/lib/google/cloud/service_control/v1/service_controller/rest/service_stub.rb +168 -0
  19. data/lib/google/cloud/service_control/v1/service_controller/rest.rb +54 -0
  20. data/lib/google/cloud/service_control/v1/service_controller.rb +7 -1
  21. data/lib/google/cloud/service_control/v1/version.rb +1 -1
  22. data/lib/google/cloud/service_control/v1.rb +8 -1
  23. data/proto_docs/google/api/client.rb +318 -0
  24. data/proto_docs/google/api/launch_stage.rb +71 -0
  25. data/proto_docs/google/protobuf/any.rb +3 -3
  26. data/proto_docs/google/protobuf/struct.rb +2 -2
  27. data/proto_docs/google/rpc/status.rb +4 -2
  28. metadata +23 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5074a3881bb241ce39220947d9d86c02dd7ff09f962448b2bc7a8496279a968
4
- data.tar.gz: 2cd6631626c4d34c84bc78bb7555131f66b45ab1b4f0fea26c960c444707613d
3
+ metadata.gz: d10b5e76a6253a53882a5c1193125ee8afd00b6010c97f8c6178fca0a7a6db88
4
+ data.tar.gz: 697797d8e15cc07f1064c0410f921936223f428457ccfaa79da17f10e0ed4583
5
5
  SHA512:
6
- metadata.gz: 0c2efadf07306fc57f2346eaec5781ddc9c7217113c146b408510aad5c3a72c8996ab12eba9059c2b26b8963a189507c9a4046cfb7e9758bf5b68bd5c3911a17
7
- data.tar.gz: b8cada7954e725fbed14c4a75414e2671d700adfb85f8848801b28e5c09f3b0bcb30252a003c587a299fedee961e245ab47fe133c4082adcccce14bf932c5bc1
6
+ metadata.gz: 30f1ebc6fc8f9d2c5730e555f0d73de25dfa50c1d077c90b5943c20082965938df97148a697961a97e1d86ad461943d8d1020e9f2c1cbe4e01c2d991fc335184
7
+ data.tar.gz: 92b92added443877011dbf1868a65ab7a195dbc7e6075a368741be663a3c21b8a6eeef9a4bb859f5a27abf2bba0741136436f50c77af1027e9d66bad8f83ccd4
data/AUTHENTICATION.md CHANGED
@@ -114,7 +114,7 @@ credentials are discovered.
114
114
  To configure your system for this, simply:
115
115
 
116
116
  1. [Download and install the Cloud SDK](https://cloud.google.com/sdk)
117
- 2. Authenticate using OAuth 2.0 `$ gcloud auth login`
117
+ 2. Authenticate using OAuth 2.0 `$ gcloud auth application-default login`
118
118
  3. Write code as if already authenticated.
119
119
 
120
120
  **NOTE:** This is _not_ recommended for running in production. The Cloud SDK
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Ruby Client for the Service Control API V1 API
2
2
 
3
- API Client library for the Service Control API V1 API
3
+ Provides admission control and telemetry reporting for services integrated with Service Infrastructure.
4
4
 
5
5
  The Service Control API provides control plane functionality to managed services, such as logging, monitoring, and status checks.
6
6
 
@@ -37,7 +37,7 @@ request = ::Google::Cloud::ServiceControl::V1::AllocateQuotaRequest.new # (reque
37
37
  response = client.allocate_quota request
38
38
  ```
39
39
 
40
- View the [Client Library Documentation](https://googleapis.dev/ruby/google-cloud-service_control-v1/latest)
40
+ View the [Client Library Documentation](https://cloud.google.com/ruby/docs/reference/google-cloud-service_control-v1/latest)
41
41
  for class and method documentation.
42
42
 
43
43
  See also the [Product Documentation](https://cloud.google.com/service-infrastructure/docs/overview/)
@@ -46,7 +46,7 @@ for general usage information.
46
46
  ## Enabling Logging
47
47
 
48
48
  To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
49
- The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html) as shown below,
49
+ The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/current/stdlibs/logger/Logger.html) as shown below,
50
50
  or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
51
51
  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)
52
52
  and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
@@ -69,16 +69,21 @@ module GRPC
69
69
  end
70
70
  ```
71
71
 
72
+
73
+ ## Google Cloud Samples
74
+
75
+ To browse ready to use code samples check [Google Cloud Samples](https://cloud.google.com/docs/samples).
76
+
72
77
  ## Supported Ruby Versions
73
78
 
74
- This library is supported on Ruby 2.5+.
79
+ This library is supported on Ruby 2.6+.
75
80
 
76
81
  Google provides official support for Ruby versions that are actively supported
77
82
  by Ruby Core—that is, Ruby versions that are either in normal maintenance or
78
- in security maintenance, and not end of life. Currently, this means Ruby 2.5
79
- and later. Older versions of Ruby _may_ still work, but are unsupported and not
80
- recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
81
- about the Ruby support schedule.
83
+ in security maintenance, and not end of life. Older versions of Ruby _may_
84
+ still work, but are unsupported and not recommended. See
85
+ https://www.ruby-lang.org/en/downloads/branches/ for details about the Ruby
86
+ support schedule.
82
87
 
83
88
  ## Which client should I use?
84
89
 
@@ -1,9 +1,10 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/api/servicecontrol/v1/check_error.proto
3
3
 
4
- require 'google/rpc/status_pb'
5
4
  require 'google/protobuf'
6
5
 
6
+ require 'google/rpc/status_pb'
7
+
7
8
  Google::Protobuf::DescriptorPool.generated_pool.build do
8
9
  add_file("google/api/servicecontrol/v1/check_error.proto", :syntax => :proto3) do
9
10
  add_message "google.api.servicecontrol.v1.CheckError" do
@@ -1,9 +1,10 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/api/servicecontrol/v1/distribution.proto
3
3
 
4
- require 'google/api/distribution_pb'
5
4
  require 'google/protobuf'
6
5
 
6
+ require 'google/api/distribution_pb'
7
+
7
8
  Google::Protobuf::DescriptorPool.generated_pool.build do
8
9
  add_file("google/api/servicecontrol/v1/distribution.proto", :syntax => :proto3) do
9
10
  add_message "google.api.servicecontrol.v1.Distribution" do
@@ -1,9 +1,10 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/api/servicecontrol/v1/http_request.proto
3
3
 
4
- require 'google/protobuf/duration_pb'
5
4
  require 'google/protobuf'
6
5
 
6
+ require 'google/protobuf/duration_pb'
7
+
7
8
  Google::Protobuf::DescriptorPool.generated_pool.build do
8
9
  add_file("google/api/servicecontrol/v1/http_request.proto", :syntax => :proto3) do
9
10
  add_message "google.api.servicecontrol.v1.HttpRequest" do
@@ -1,12 +1,13 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/api/servicecontrol/v1/log_entry.proto
3
3
 
4
+ require 'google/protobuf'
5
+
4
6
  require 'google/api/servicecontrol/v1/http_request_pb'
5
7
  require 'google/logging/type/log_severity_pb'
6
8
  require 'google/protobuf/any_pb'
7
9
  require 'google/protobuf/struct_pb'
8
10
  require 'google/protobuf/timestamp_pb'
9
- require 'google/protobuf'
10
11
 
11
12
  Google::Protobuf::DescriptorPool.generated_pool.build do
12
13
  add_file("google/api/servicecontrol/v1/log_entry.proto", :syntax => :proto3) do
@@ -1,9 +1,10 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/api/servicecontrol/v1/metric_value.proto
3
3
 
4
+ require 'google/protobuf'
5
+
4
6
  require 'google/api/servicecontrol/v1/distribution_pb'
5
7
  require 'google/protobuf/timestamp_pb'
6
- require 'google/protobuf'
7
8
 
8
9
  Google::Protobuf::DescriptorPool.generated_pool.build do
9
10
  add_file("google/api/servicecontrol/v1/metric_value.proto", :syntax => :proto3) do
@@ -1,11 +1,12 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/api/servicecontrol/v1/operation.proto
3
3
 
4
+ require 'google/protobuf'
5
+
4
6
  require 'google/api/servicecontrol/v1/log_entry_pb'
5
7
  require 'google/api/servicecontrol/v1/metric_value_pb'
6
8
  require 'google/protobuf/any_pb'
7
9
  require 'google/protobuf/timestamp_pb'
8
- require 'google/protobuf'
9
10
 
10
11
  Google::Protobuf::DescriptorPool.generated_pool.build do
11
12
  add_file("google/api/servicecontrol/v1/operation.proto", :syntax => :proto3) do
@@ -1,11 +1,12 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/api/servicecontrol/v1/quota_controller.proto
3
3
 
4
+ require 'google/protobuf'
5
+
4
6
  require 'google/api/annotations_pb'
5
7
  require 'google/api/servicecontrol/v1/metric_value_pb'
6
8
  require 'google/rpc/status_pb'
7
9
  require 'google/api/client_pb'
8
- require 'google/protobuf'
9
10
 
10
11
  Google::Protobuf::DescriptorPool.generated_pool.build do
11
12
  add_file("google/api/servicecontrol/v1/quota_controller.proto", :syntax => :proto3) do
@@ -1,13 +1,13 @@
1
1
  # Generated by the protocol buffer compiler. DO NOT EDIT!
2
2
  # source: google/api/servicecontrol/v1/service_controller.proto
3
3
 
4
+ require 'google/protobuf'
5
+
4
6
  require 'google/api/annotations_pb'
5
7
  require 'google/api/client_pb'
6
8
  require 'google/api/servicecontrol/v1/check_error_pb'
7
9
  require 'google/api/servicecontrol/v1/operation_pb'
8
- require 'google/protobuf/timestamp_pb'
9
10
  require 'google/rpc/status_pb'
10
- require 'google/protobuf'
11
11
 
12
12
  Google::Protobuf::DescriptorPool.generated_pool.build do
13
13
  add_file("google/api/servicecontrol/v1/service_controller.proto", :syntax => :proto3) do
@@ -0,0 +1,364 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 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
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/api/servicecontrol/v1/quota_controller_pb"
21
+ require "google/cloud/service_control/v1/quota_controller/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module ServiceControl
26
+ module V1
27
+ module QuotaController
28
+ module Rest
29
+ ##
30
+ # REST client for the QuotaController service.
31
+ #
32
+ # [Google Quota Control API](/service-control/overview)
33
+ #
34
+ # Allows clients to allocate and release quota against a [managed
35
+ # service](https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService).
36
+ #
37
+ class Client
38
+ # @private
39
+ attr_reader :quota_controller_stub
40
+
41
+ ##
42
+ # Configure the QuotaController Client class.
43
+ #
44
+ # See {::Google::Cloud::ServiceControl::V1::QuotaController::Rest::Client::Configuration}
45
+ # for a description of the configuration fields.
46
+ #
47
+ # @example
48
+ #
49
+ # # Modify the configuration for all QuotaController clients
50
+ # ::Google::Cloud::ServiceControl::V1::QuotaController::Rest::Client.configure do |config|
51
+ # config.timeout = 10.0
52
+ # end
53
+ #
54
+ # @yield [config] Configure the Client client.
55
+ # @yieldparam config [Client::Configuration]
56
+ #
57
+ # @return [Client::Configuration]
58
+ #
59
+ def self.configure
60
+ @configure ||= begin
61
+ namespace = ["Google", "Cloud", "ServiceControl", "V1"]
62
+ parent_config = while namespace.any?
63
+ parent_name = namespace.join "::"
64
+ parent_const = const_get parent_name
65
+ break parent_const.configure if parent_const.respond_to? :configure
66
+ namespace.pop
67
+ end
68
+ default_config = Client::Configuration.new parent_config
69
+
70
+ default_config
71
+ end
72
+ yield @configure if block_given?
73
+ @configure
74
+ end
75
+
76
+ ##
77
+ # Configure the QuotaController Client instance.
78
+ #
79
+ # The configuration is set to the derived mode, meaning that values can be changed,
80
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
81
+ # should be made on {Client.configure}.
82
+ #
83
+ # See {::Google::Cloud::ServiceControl::V1::QuotaController::Rest::Client::Configuration}
84
+ # for a description of the configuration fields.
85
+ #
86
+ # @yield [config] Configure the Client client.
87
+ # @yieldparam config [Client::Configuration]
88
+ #
89
+ # @return [Client::Configuration]
90
+ #
91
+ def configure
92
+ yield @config if block_given?
93
+ @config
94
+ end
95
+
96
+ ##
97
+ # Create a new QuotaController REST client object.
98
+ #
99
+ # @example
100
+ #
101
+ # # Create a client using the default configuration
102
+ # client = ::Google::Cloud::ServiceControl::V1::QuotaController::Rest::Client.new
103
+ #
104
+ # # Create a client using a custom configuration
105
+ # client = ::Google::Cloud::ServiceControl::V1::QuotaController::Rest::Client.new do |config|
106
+ # config.timeout = 10.0
107
+ # end
108
+ #
109
+ # @yield [config] Configure the QuotaController client.
110
+ # @yieldparam config [Client::Configuration]
111
+ #
112
+ def initialize
113
+ # Create the configuration object
114
+ @config = Configuration.new Client.configure
115
+
116
+ # Yield the configuration if needed
117
+ yield @config if block_given?
118
+
119
+ # Create credentials
120
+ credentials = @config.credentials
121
+ # Use self-signed JWT if the endpoint is unchanged from default,
122
+ # but only if the default endpoint does not have a region prefix.
123
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
124
+ !@config.endpoint.split(".").first.include?("-")
125
+ credentials ||= Credentials.default scope: @config.scope,
126
+ enable_self_signed_jwt: enable_self_signed_jwt
127
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
128
+ credentials = Credentials.new credentials, scope: @config.scope
129
+ end
130
+
131
+ @quota_project_id = @config.quota_project
132
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
133
+
134
+ @quota_controller_stub = ::Google::Cloud::ServiceControl::V1::QuotaController::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
135
+ end
136
+
137
+ # Service calls
138
+
139
+ ##
140
+ # Attempts to allocate quota for the specified consumer. It should be called
141
+ # before the operation is executed.
142
+ #
143
+ # This method requires the `servicemanagement.services.quota`
144
+ # permission on the specified service. For more information, see
145
+ # [Cloud IAM](https://cloud.google.com/iam).
146
+ #
147
+ # **NOTE:** The client **must** fail-open on server errors `INTERNAL`,
148
+ # `UNKNOWN`, `DEADLINE_EXCEEDED`, and `UNAVAILABLE`. To ensure system
149
+ # reliability, the server may inject these errors to prohibit any hard
150
+ # dependency on the quota functionality.
151
+ #
152
+ # @overload allocate_quota(request, options = nil)
153
+ # Pass arguments to `allocate_quota` via a request object, either of type
154
+ # {::Google::Cloud::ServiceControl::V1::AllocateQuotaRequest} or an equivalent Hash.
155
+ #
156
+ # @param request [::Google::Cloud::ServiceControl::V1::AllocateQuotaRequest, ::Hash]
157
+ # A request object representing the call parameters. Required. To specify no
158
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
159
+ # @param options [::Gapic::CallOptions, ::Hash]
160
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
161
+ #
162
+ # @overload allocate_quota(service_name: nil, allocate_operation: nil, service_config_id: nil)
163
+ # Pass arguments to `allocate_quota` via keyword arguments. Note that at
164
+ # least one keyword argument is required. To specify no parameters, or to keep all
165
+ # the default parameter values, pass an empty Hash as a request object (see above).
166
+ #
167
+ # @param service_name [::String]
168
+ # Name of the service as specified in the service configuration. For example,
169
+ # `"pubsub.googleapis.com"`.
170
+ #
171
+ # See [google.api.Service][google.api.Service] for the definition of a service name.
172
+ # @param allocate_operation [::Google::Cloud::ServiceControl::V1::QuotaOperation, ::Hash]
173
+ # Operation that describes the quota allocation.
174
+ # @param service_config_id [::String]
175
+ # Specifies which version of service configuration should be used to process
176
+ # the request. If unspecified or no matching version can be found, the latest
177
+ # one will be used.
178
+ # @yield [result, operation] Access the result along with the TransportOperation object
179
+ # @yieldparam result [::Google::Cloud::ServiceControl::V1::AllocateQuotaResponse]
180
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
181
+ #
182
+ # @return [::Google::Cloud::ServiceControl::V1::AllocateQuotaResponse]
183
+ #
184
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
185
+ def allocate_quota request, options = nil
186
+ raise ::ArgumentError, "request must be provided" if request.nil?
187
+
188
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ServiceControl::V1::AllocateQuotaRequest
189
+
190
+ # Converts hash and nil to an options object
191
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
192
+
193
+ # Customize the options with defaults
194
+ call_metadata = @config.rpcs.allocate_quota.metadata.to_h
195
+
196
+ # Set x-goog-api-client and x-goog-user-project headers
197
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
198
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
199
+ gapic_version: ::Google::Cloud::ServiceControl::V1::VERSION,
200
+ transports_version_send: [:rest]
201
+
202
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
203
+
204
+ options.apply_defaults timeout: @config.rpcs.allocate_quota.timeout,
205
+ metadata: call_metadata,
206
+ retry_policy: @config.rpcs.allocate_quota.retry_policy
207
+
208
+ options.apply_defaults timeout: @config.timeout,
209
+ metadata: @config.metadata,
210
+ retry_policy: @config.retry_policy
211
+
212
+ @quota_controller_stub.allocate_quota request, options do |result, operation|
213
+ yield result, operation if block_given?
214
+ return result
215
+ end
216
+ rescue ::Gapic::Rest::Error => e
217
+ raise ::Google::Cloud::Error.from_error(e)
218
+ end
219
+
220
+ ##
221
+ # Configuration class for the QuotaController REST API.
222
+ #
223
+ # This class represents the configuration for QuotaController REST,
224
+ # providing control over timeouts, retry behavior, logging, transport
225
+ # parameters, and other low-level controls. Certain parameters can also be
226
+ # applied individually to specific RPCs. See
227
+ # {::Google::Cloud::ServiceControl::V1::QuotaController::Rest::Client::Configuration::Rpcs}
228
+ # for a list of RPCs that can be configured independently.
229
+ #
230
+ # Configuration can be applied globally to all clients, or to a single client
231
+ # on construction.
232
+ #
233
+ # @example
234
+ #
235
+ # # Modify the global config, setting the timeout for
236
+ # # allocate_quota to 20 seconds,
237
+ # # and all remaining timeouts to 10 seconds.
238
+ # ::Google::Cloud::ServiceControl::V1::QuotaController::Rest::Client.configure do |config|
239
+ # config.timeout = 10.0
240
+ # config.rpcs.allocate_quota.timeout = 20.0
241
+ # end
242
+ #
243
+ # # Apply the above configuration only to a new client.
244
+ # client = ::Google::Cloud::ServiceControl::V1::QuotaController::Rest::Client.new do |config|
245
+ # config.timeout = 10.0
246
+ # config.rpcs.allocate_quota.timeout = 20.0
247
+ # end
248
+ #
249
+ # @!attribute [rw] endpoint
250
+ # The hostname or hostname:port of the service endpoint.
251
+ # Defaults to `"servicecontrol.googleapis.com"`.
252
+ # @return [::String]
253
+ # @!attribute [rw] credentials
254
+ # Credentials to send with calls. You may provide any of the following types:
255
+ # * (`String`) The path to a service account key file in JSON format
256
+ # * (`Hash`) A service account key as a Hash
257
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
258
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
259
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
260
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
261
+ # * (`nil`) indicating no credentials
262
+ # @return [::Object]
263
+ # @!attribute [rw] scope
264
+ # The OAuth scopes
265
+ # @return [::Array<::String>]
266
+ # @!attribute [rw] lib_name
267
+ # The library name as recorded in instrumentation and logging
268
+ # @return [::String]
269
+ # @!attribute [rw] lib_version
270
+ # The library version as recorded in instrumentation and logging
271
+ # @return [::String]
272
+ # @!attribute [rw] timeout
273
+ # The call timeout in seconds.
274
+ # @return [::Numeric]
275
+ # @!attribute [rw] metadata
276
+ # Additional headers to be sent with the call.
277
+ # @return [::Hash{::Symbol=>::String}]
278
+ # @!attribute [rw] retry_policy
279
+ # The retry policy. The value is a hash with the following keys:
280
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
281
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
282
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
283
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
284
+ # trigger a retry.
285
+ # @return [::Hash]
286
+ # @!attribute [rw] quota_project
287
+ # A separate project against which to charge quota.
288
+ # @return [::String]
289
+ #
290
+ class Configuration
291
+ extend ::Gapic::Config
292
+
293
+ config_attr :endpoint, "servicecontrol.googleapis.com", ::String
294
+ config_attr :credentials, nil do |value|
295
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
296
+ allowed.any? { |klass| klass === value }
297
+ end
298
+ config_attr :scope, nil, ::String, ::Array, nil
299
+ config_attr :lib_name, nil, ::String, nil
300
+ config_attr :lib_version, nil, ::String, nil
301
+ config_attr :timeout, nil, ::Numeric, nil
302
+ config_attr :metadata, nil, ::Hash, nil
303
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
304
+ config_attr :quota_project, nil, ::String, nil
305
+
306
+ # @private
307
+ def initialize parent_config = nil
308
+ @parent_config = parent_config unless parent_config.nil?
309
+
310
+ yield self if block_given?
311
+ end
312
+
313
+ ##
314
+ # Configurations for individual RPCs
315
+ # @return [Rpcs]
316
+ #
317
+ def rpcs
318
+ @rpcs ||= begin
319
+ parent_rpcs = nil
320
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
321
+ Rpcs.new parent_rpcs
322
+ end
323
+ end
324
+
325
+ ##
326
+ # Configuration RPC class for the QuotaController API.
327
+ #
328
+ # Includes fields providing the configuration for each RPC in this service.
329
+ # Each configuration object is of type `Gapic::Config::Method` and includes
330
+ # the following configuration fields:
331
+ #
332
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
333
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
334
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
335
+ # include the following keys:
336
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
337
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
338
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
339
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
340
+ # trigger a retry.
341
+ #
342
+ class Rpcs
343
+ ##
344
+ # RPC-specific configuration for `allocate_quota`
345
+ # @return [::Gapic::Config::Method]
346
+ #
347
+ attr_reader :allocate_quota
348
+
349
+ # @private
350
+ def initialize parent_rpcs = nil
351
+ allocate_quota_config = parent_rpcs.allocate_quota if parent_rpcs.respond_to? :allocate_quota
352
+ @allocate_quota = ::Gapic::Config::Method.new allocate_quota_config
353
+
354
+ yield self if block_given?
355
+ end
356
+ end
357
+ end
358
+ end
359
+ end
360
+ end
361
+ end
362
+ end
363
+ end
364
+ end
@@ -0,0 +1,108 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 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
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/api/servicecontrol/v1/quota_controller_pb"
20
+
21
+ module Google
22
+ module Cloud
23
+ module ServiceControl
24
+ module V1
25
+ module QuotaController
26
+ module Rest
27
+ ##
28
+ # REST service stub for the QuotaController service.
29
+ # Service stub contains baseline method implementations
30
+ # including transcoding, making the REST call, and deserialing the response.
31
+ #
32
+ class ServiceStub
33
+ def initialize endpoint:, credentials:
34
+ # These require statements are intentionally placed here to initialize
35
+ # the REST modules only when it's required.
36
+ require "gapic/rest"
37
+
38
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials,
39
+ numeric_enums: true,
40
+ raise_faraday_errors: false
41
+ end
42
+
43
+ ##
44
+ # Baseline implementation for the allocate_quota REST call
45
+ #
46
+ # @param request_pb [::Google::Cloud::ServiceControl::V1::AllocateQuotaRequest]
47
+ # A request object representing the call parameters. Required.
48
+ # @param options [::Gapic::CallOptions]
49
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
50
+ #
51
+ # @yield [result, operation] Access the result along with the TransportOperation object
52
+ # @yieldparam result [::Google::Cloud::ServiceControl::V1::AllocateQuotaResponse]
53
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
54
+ #
55
+ # @return [::Google::Cloud::ServiceControl::V1::AllocateQuotaResponse]
56
+ # A result object deserialized from the server's reply
57
+ def allocate_quota request_pb, options = nil
58
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
59
+
60
+ verb, uri, query_string_params, body = ServiceStub.transcode_allocate_quota_request request_pb
61
+ query_string_params = if query_string_params.any?
62
+ query_string_params.to_h { |p| p.split("=", 2) }
63
+ else
64
+ {}
65
+ end
66
+
67
+ response = @client_stub.make_http_request(
68
+ verb,
69
+ uri: uri,
70
+ body: body || "",
71
+ params: query_string_params,
72
+ options: options
73
+ )
74
+ operation = ::Gapic::Rest::TransportOperation.new response
75
+ result = ::Google::Cloud::ServiceControl::V1::AllocateQuotaResponse.decode_json response.body, ignore_unknown_fields: true
76
+
77
+ yield result, operation if block_given?
78
+ result
79
+ end
80
+
81
+ ##
82
+ # @private
83
+ #
84
+ # GRPC transcoding helper method for the allocate_quota REST call
85
+ #
86
+ # @param request_pb [::Google::Cloud::ServiceControl::V1::AllocateQuotaRequest]
87
+ # A request object representing the call parameters. Required.
88
+ # @return [Array(String, [String, nil], Hash{String => String})]
89
+ # Uri, Body, Query string parameters
90
+ def self.transcode_allocate_quota_request request_pb
91
+ transcoder = Gapic::Rest::GrpcTranscoder.new
92
+ .with_bindings(
93
+ uri_method: :post,
94
+ uri_template: "/v1/services/{service_name}:allocateQuota",
95
+ body: "*",
96
+ matches: [
97
+ ["service_name", %r{^[^/]+/?$}, false]
98
+ ]
99
+ )
100
+ transcoder.transcode request_pb
101
+ end
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end