google-cloud-service_control-v1 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +12 -0
- data/AUTHENTICATION.md +169 -0
- data/LICENSE.md +203 -0
- data/README.md +75 -0
- data/lib/google-cloud-service_control-v1.rb +21 -0
- data/lib/google/api/servicecontrol/v1/check_error_pb.rb +50 -0
- data/lib/google/api/servicecontrol/v1/distribution_pb.rb +48 -0
- data/lib/google/api/servicecontrol/v1/http_request_pb.rb +37 -0
- data/lib/google/api/servicecontrol/v1/log_entry_pb.rb +53 -0
- data/lib/google/api/servicecontrol/v1/metric_value_pb.rb +38 -0
- data/lib/google/api/servicecontrol/v1/operation_pb.rb +40 -0
- data/lib/google/api/servicecontrol/v1/quota_controller_pb.rb +67 -0
- data/lib/google/api/servicecontrol/v1/quota_controller_services_pb.rb +58 -0
- data/lib/google/api/servicecontrol/v1/service_controller_pb.rb +74 -0
- data/lib/google/api/servicecontrol/v1/service_controller_services_pb.rb +79 -0
- data/lib/google/cloud/service_control/v1.rb +36 -0
- data/lib/google/cloud/service_control/v1/quota_controller.rb +51 -0
- data/lib/google/cloud/service_control/v1/quota_controller/client.rb +389 -0
- data/lib/google/cloud/service_control/v1/quota_controller/credentials.rb +52 -0
- data/lib/google/cloud/service_control/v1/service_controller.rb +51 -0
- data/lib/google/cloud/service_control/v1/service_controller/client.rb +507 -0
- data/lib/google/cloud/service_control/v1/service_controller/credentials.rb +52 -0
- data/lib/google/cloud/service_control/v1/version.rb +28 -0
- data/proto_docs/README.md +4 -0
- data/proto_docs/google/api/resource.rb +283 -0
- data/proto_docs/google/api/servicecontrol/v1/check_error.rb +125 -0
- data/proto_docs/google/api/servicecontrol/v1/distribution.rb +148 -0
- data/proto_docs/google/api/servicecontrol/v1/http_request.rb +95 -0
- data/proto_docs/google/api/servicecontrol/v1/log_entry.rb +136 -0
- data/proto_docs/google/api/servicecontrol/v1/metric_value.rb +86 -0
- data/proto_docs/google/api/servicecontrol/v1/operation.rb +128 -0
- data/proto_docs/google/api/servicecontrol/v1/quota_controller.rb +227 -0
- data/proto_docs/google/api/servicecontrol/v1/service_controller.rb +206 -0
- data/proto_docs/google/logging/type/log_severity.rb +69 -0
- data/proto_docs/google/protobuf/any.rb +138 -0
- data/proto_docs/google/protobuf/duration.rb +98 -0
- data/proto_docs/google/protobuf/struct.rb +96 -0
- data/proto_docs/google/protobuf/timestamp.rb +120 -0
- data/proto_docs/google/rpc/status.rb +46 -0
- metadata +222 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# Source: google/api/servicecontrol/v1/service_controller.proto for package 'Google.Cloud.ServiceControl.V1'
|
3
|
+
# Original file comments:
|
4
|
+
# Copyright 2020 Google LLC
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'grpc'
|
20
|
+
require 'google/api/servicecontrol/v1/service_controller_pb'
|
21
|
+
|
22
|
+
module Google
|
23
|
+
module Cloud
|
24
|
+
module ServiceControl
|
25
|
+
module V1
|
26
|
+
module ServiceController
|
27
|
+
# [Google Service Control API](/service-control/overview)
|
28
|
+
#
|
29
|
+
# Lets clients check and report operations against a [managed
|
30
|
+
# service](https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService).
|
31
|
+
class Service
|
32
|
+
|
33
|
+
include GRPC::GenericService
|
34
|
+
|
35
|
+
self.marshal_class_method = :encode
|
36
|
+
self.unmarshal_class_method = :decode
|
37
|
+
self.service_name = 'google.api.servicecontrol.v1.ServiceController'
|
38
|
+
|
39
|
+
# Checks whether an operation on a service should be allowed to proceed
|
40
|
+
# based on the configuration of the service and related policies. It must be
|
41
|
+
# called before the operation is executed.
|
42
|
+
#
|
43
|
+
# If feasible, the client should cache the check results and reuse them for
|
44
|
+
# 60 seconds. In case of any server errors, the client should rely on the
|
45
|
+
# cached results for much longer time to avoid outage.
|
46
|
+
# WARNING: There is general 60s delay for the configuration and policy
|
47
|
+
# propagation, therefore callers MUST NOT depend on the `Check` method having
|
48
|
+
# the latest policy information.
|
49
|
+
#
|
50
|
+
# NOTE: the [CheckRequest][google.api.servicecontrol.v1.CheckRequest] has the size limit of 64KB.
|
51
|
+
#
|
52
|
+
# This method requires the `servicemanagement.services.check` permission
|
53
|
+
# on the specified service. For more information, see
|
54
|
+
# [Cloud IAM](https://cloud.google.com/iam).
|
55
|
+
rpc :Check, ::Google::Cloud::ServiceControl::V1::CheckRequest, ::Google::Cloud::ServiceControl::V1::CheckResponse
|
56
|
+
# Reports operation results to Google Service Control, such as logs and
|
57
|
+
# metrics. It should be called after an operation is completed.
|
58
|
+
#
|
59
|
+
# If feasible, the client should aggregate reporting data for up to 5
|
60
|
+
# seconds to reduce API traffic. Limiting aggregation to 5 seconds is to
|
61
|
+
# reduce data loss during client crashes. Clients should carefully choose
|
62
|
+
# the aggregation time window to avoid data loss risk more than 0.01%
|
63
|
+
# for business and compliance reasons.
|
64
|
+
#
|
65
|
+
# NOTE: the [ReportRequest][google.api.servicecontrol.v1.ReportRequest] has the size limit (wire-format byte size) of
|
66
|
+
# 1MB.
|
67
|
+
#
|
68
|
+
# This method requires the `servicemanagement.services.report` permission
|
69
|
+
# on the specified service. For more information, see
|
70
|
+
# [Google Cloud IAM](https://cloud.google.com/iam).
|
71
|
+
rpc :Report, ::Google::Cloud::ServiceControl::V1::ReportRequest, ::Google::Cloud::ServiceControl::V1::ReportResponse
|
72
|
+
end
|
73
|
+
|
74
|
+
Stub = Service.rpc_stub_class
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 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/service_control/v1/quota_controller"
|
20
|
+
require "google/cloud/service_control/v1/service_controller"
|
21
|
+
require "google/cloud/service_control/v1/version"
|
22
|
+
|
23
|
+
module Google
|
24
|
+
module Cloud
|
25
|
+
module ServiceControl
|
26
|
+
##
|
27
|
+
# To load this package, including all its services, and instantiate a client:
|
28
|
+
#
|
29
|
+
# require "google/cloud/service_control/v1"
|
30
|
+
# client = ::Google::Cloud::ServiceControl::V1::QuotaController::Client.new
|
31
|
+
#
|
32
|
+
module V1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 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 "gapic/common"
|
20
|
+
require "gapic/config"
|
21
|
+
require "gapic/config/method"
|
22
|
+
|
23
|
+
require "google/cloud/service_control/v1/version"
|
24
|
+
|
25
|
+
require "google/cloud/service_control/v1/quota_controller/credentials"
|
26
|
+
require "google/cloud/service_control/v1/quota_controller/client"
|
27
|
+
|
28
|
+
module Google
|
29
|
+
module Cloud
|
30
|
+
module ServiceControl
|
31
|
+
module V1
|
32
|
+
##
|
33
|
+
# [Google Quota Control API](/service-control/overview)
|
34
|
+
#
|
35
|
+
# Allows clients to allocate and release quota against a [managed
|
36
|
+
# service](https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService).
|
37
|
+
#
|
38
|
+
# To load this service and instantiate a client:
|
39
|
+
#
|
40
|
+
# require "google/cloud/service_control/v1/quota_controller"
|
41
|
+
# client = ::Google::Cloud::ServiceControl::V1::QuotaController::Client.new
|
42
|
+
#
|
43
|
+
module QuotaController
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
helper_path = ::File.join __dir__, "quota_controller", "helpers.rb"
|
51
|
+
require "google/cloud/service_control/v1/quota_controller/helpers" if ::File.file? helper_path
|
@@ -0,0 +1,389 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2020 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
|
+
|
22
|
+
module Google
|
23
|
+
module Cloud
|
24
|
+
module ServiceControl
|
25
|
+
module V1
|
26
|
+
module QuotaController
|
27
|
+
##
|
28
|
+
# Client for the QuotaController service.
|
29
|
+
#
|
30
|
+
# [Google Quota Control API](/service-control/overview)
|
31
|
+
#
|
32
|
+
# Allows clients to allocate and release quota against a [managed
|
33
|
+
# service](https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService).
|
34
|
+
#
|
35
|
+
class Client
|
36
|
+
# @private
|
37
|
+
attr_reader :quota_controller_stub
|
38
|
+
|
39
|
+
##
|
40
|
+
# Configure the QuotaController Client class.
|
41
|
+
#
|
42
|
+
# See {::Google::Cloud::ServiceControl::V1::QuotaController::Client::Configuration}
|
43
|
+
# for a description of the configuration fields.
|
44
|
+
#
|
45
|
+
# ## Example
|
46
|
+
#
|
47
|
+
# To modify the configuration for all QuotaController clients:
|
48
|
+
#
|
49
|
+
# ::Google::Cloud::ServiceControl::V1::QuotaController::Client.configure do |config|
|
50
|
+
# config.timeout = 10.0
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# @yield [config] Configure the Client client.
|
54
|
+
# @yieldparam config [Client::Configuration]
|
55
|
+
#
|
56
|
+
# @return [Client::Configuration]
|
57
|
+
#
|
58
|
+
def self.configure
|
59
|
+
@configure ||= begin
|
60
|
+
namespace = ["Google", "Cloud", "ServiceControl", "V1"]
|
61
|
+
parent_config = while namespace.any?
|
62
|
+
parent_name = namespace.join "::"
|
63
|
+
parent_const = const_get parent_name
|
64
|
+
break parent_const.configure if parent_const&.respond_to? :configure
|
65
|
+
namespace.pop
|
66
|
+
end
|
67
|
+
default_config = Client::Configuration.new parent_config
|
68
|
+
|
69
|
+
default_config
|
70
|
+
end
|
71
|
+
yield @configure if block_given?
|
72
|
+
@configure
|
73
|
+
end
|
74
|
+
|
75
|
+
##
|
76
|
+
# Configure the QuotaController Client instance.
|
77
|
+
#
|
78
|
+
# The configuration is set to the derived mode, meaning that values can be changed,
|
79
|
+
# but structural changes (adding new fields, etc.) are not allowed. Structural changes
|
80
|
+
# should be made on {Client.configure}.
|
81
|
+
#
|
82
|
+
# See {::Google::Cloud::ServiceControl::V1::QuotaController::Client::Configuration}
|
83
|
+
# for a description of the configuration fields.
|
84
|
+
#
|
85
|
+
# @yield [config] Configure the Client client.
|
86
|
+
# @yieldparam config [Client::Configuration]
|
87
|
+
#
|
88
|
+
# @return [Client::Configuration]
|
89
|
+
#
|
90
|
+
def configure
|
91
|
+
yield @config if block_given?
|
92
|
+
@config
|
93
|
+
end
|
94
|
+
|
95
|
+
##
|
96
|
+
# Create a new QuotaController client object.
|
97
|
+
#
|
98
|
+
# ## Examples
|
99
|
+
#
|
100
|
+
# To create a new QuotaController client with the default
|
101
|
+
# configuration:
|
102
|
+
#
|
103
|
+
# client = ::Google::Cloud::ServiceControl::V1::QuotaController::Client.new
|
104
|
+
#
|
105
|
+
# To create a new QuotaController client with a custom
|
106
|
+
# configuration:
|
107
|
+
#
|
108
|
+
# client = ::Google::Cloud::ServiceControl::V1::QuotaController::Client.new do |config|
|
109
|
+
# config.timeout = 10.0
|
110
|
+
# end
|
111
|
+
#
|
112
|
+
# @yield [config] Configure the QuotaController client.
|
113
|
+
# @yieldparam config [Client::Configuration]
|
114
|
+
#
|
115
|
+
def initialize
|
116
|
+
# These require statements are intentionally placed here to initialize
|
117
|
+
# the gRPC module only when it's required.
|
118
|
+
# See https://github.com/googleapis/toolkit/issues/446
|
119
|
+
require "gapic/grpc"
|
120
|
+
require "google/api/servicecontrol/v1/quota_controller_services_pb"
|
121
|
+
|
122
|
+
# Create the configuration object
|
123
|
+
@config = Configuration.new Client.configure
|
124
|
+
|
125
|
+
# Yield the configuration if needed
|
126
|
+
yield @config if block_given?
|
127
|
+
|
128
|
+
# Create credentials
|
129
|
+
credentials = @config.credentials
|
130
|
+
credentials ||= Credentials.default scope: @config.scope
|
131
|
+
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
132
|
+
credentials = Credentials.new credentials, scope: @config.scope
|
133
|
+
end
|
134
|
+
@quota_project_id = @config.quota_project
|
135
|
+
@quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
|
136
|
+
|
137
|
+
@quota_controller_stub = ::Gapic::ServiceStub.new(
|
138
|
+
::Google::Cloud::ServiceControl::V1::QuotaController::Stub,
|
139
|
+
credentials: credentials,
|
140
|
+
endpoint: @config.endpoint,
|
141
|
+
channel_args: @config.channel_args,
|
142
|
+
interceptors: @config.interceptors
|
143
|
+
)
|
144
|
+
end
|
145
|
+
|
146
|
+
# Service calls
|
147
|
+
|
148
|
+
##
|
149
|
+
# Attempts to allocate quota for the specified consumer. It should be called
|
150
|
+
# before the operation is executed.
|
151
|
+
#
|
152
|
+
# This method requires the `servicemanagement.services.quota`
|
153
|
+
# permission on the specified service. For more information, see
|
154
|
+
# [Cloud IAM](https://cloud.google.com/iam).
|
155
|
+
#
|
156
|
+
# **NOTE:** The client **must** fail-open on server errors `INTERNAL`,
|
157
|
+
# `UNKNOWN`, `DEADLINE_EXCEEDED`, and `UNAVAILABLE`. To ensure system
|
158
|
+
# reliability, the server may inject these errors to prohibit any hard
|
159
|
+
# dependency on the quota functionality.
|
160
|
+
#
|
161
|
+
# @overload allocate_quota(request, options = nil)
|
162
|
+
# Pass arguments to `allocate_quota` via a request object, either of type
|
163
|
+
# {::Google::Cloud::ServiceControl::V1::AllocateQuotaRequest} or an equivalent Hash.
|
164
|
+
#
|
165
|
+
# @param request [::Google::Cloud::ServiceControl::V1::AllocateQuotaRequest, ::Hash]
|
166
|
+
# A request object representing the call parameters. Required. To specify no
|
167
|
+
# parameters, or to keep all the default parameter values, pass an empty Hash.
|
168
|
+
# @param options [::Gapic::CallOptions, ::Hash]
|
169
|
+
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
|
170
|
+
#
|
171
|
+
# @overload allocate_quota(service_name: nil, allocate_operation: nil, service_config_id: nil)
|
172
|
+
# Pass arguments to `allocate_quota` via keyword arguments. Note that at
|
173
|
+
# least one keyword argument is required. To specify no parameters, or to keep all
|
174
|
+
# the default parameter values, pass an empty Hash as a request object (see above).
|
175
|
+
#
|
176
|
+
# @param service_name [::String]
|
177
|
+
# Name of the service as specified in the service configuration. For example,
|
178
|
+
# `"pubsub.googleapis.com"`.
|
179
|
+
#
|
180
|
+
# See [google.api.Service][google.api.Service] for the definition of a service name.
|
181
|
+
# @param allocate_operation [::Google::Cloud::ServiceControl::V1::QuotaOperation, ::Hash]
|
182
|
+
# Operation that describes the quota allocation.
|
183
|
+
# @param service_config_id [::String]
|
184
|
+
# Specifies which version of service configuration should be used to process
|
185
|
+
# the request. If unspecified or no matching version can be found, the latest
|
186
|
+
# one will be used.
|
187
|
+
#
|
188
|
+
# @yield [response, operation] Access the result along with the RPC operation
|
189
|
+
# @yieldparam response [::Google::Cloud::ServiceControl::V1::AllocateQuotaResponse]
|
190
|
+
# @yieldparam operation [::GRPC::ActiveCall::Operation]
|
191
|
+
#
|
192
|
+
# @return [::Google::Cloud::ServiceControl::V1::AllocateQuotaResponse]
|
193
|
+
#
|
194
|
+
# @raise [::Google::Cloud::Error] if the RPC is aborted.
|
195
|
+
#
|
196
|
+
def allocate_quota request, options = nil
|
197
|
+
raise ::ArgumentError, "request must be provided" if request.nil?
|
198
|
+
|
199
|
+
request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::ServiceControl::V1::AllocateQuotaRequest
|
200
|
+
|
201
|
+
# Converts hash and nil to an options object
|
202
|
+
options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
|
203
|
+
|
204
|
+
# Customize the options with defaults
|
205
|
+
metadata = @config.rpcs.allocate_quota.metadata.to_h
|
206
|
+
|
207
|
+
# Set x-goog-api-client and x-goog-user-project headers
|
208
|
+
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
|
209
|
+
lib_name: @config.lib_name, lib_version: @config.lib_version,
|
210
|
+
gapic_version: ::Google::Cloud::ServiceControl::V1::VERSION
|
211
|
+
metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
|
212
|
+
|
213
|
+
header_params = {
|
214
|
+
"service_name" => request.service_name
|
215
|
+
}
|
216
|
+
request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
|
217
|
+
metadata[:"x-goog-request-params"] ||= request_params_header
|
218
|
+
|
219
|
+
options.apply_defaults timeout: @config.rpcs.allocate_quota.timeout,
|
220
|
+
metadata: metadata,
|
221
|
+
retry_policy: @config.rpcs.allocate_quota.retry_policy
|
222
|
+
options.apply_defaults metadata: @config.metadata,
|
223
|
+
retry_policy: @config.retry_policy
|
224
|
+
|
225
|
+
@quota_controller_stub.call_rpc :allocate_quota, request, options: options do |response, operation|
|
226
|
+
yield response, operation if block_given?
|
227
|
+
return response
|
228
|
+
end
|
229
|
+
rescue ::GRPC::BadStatus => e
|
230
|
+
raise ::Google::Cloud::Error.from_error(e)
|
231
|
+
end
|
232
|
+
|
233
|
+
##
|
234
|
+
# Configuration class for the QuotaController API.
|
235
|
+
#
|
236
|
+
# This class represents the configuration for QuotaController,
|
237
|
+
# providing control over timeouts, retry behavior, logging, transport
|
238
|
+
# parameters, and other low-level controls. Certain parameters can also be
|
239
|
+
# applied individually to specific RPCs. See
|
240
|
+
# {::Google::Cloud::ServiceControl::V1::QuotaController::Client::Configuration::Rpcs}
|
241
|
+
# for a list of RPCs that can be configured independently.
|
242
|
+
#
|
243
|
+
# Configuration can be applied globally to all clients, or to a single client
|
244
|
+
# on construction.
|
245
|
+
#
|
246
|
+
# # Examples
|
247
|
+
#
|
248
|
+
# To modify the global config, setting the timeout for allocate_quota
|
249
|
+
# to 20 seconds, and all remaining timeouts to 10 seconds:
|
250
|
+
#
|
251
|
+
# ::Google::Cloud::ServiceControl::V1::QuotaController::Client.configure do |config|
|
252
|
+
# config.timeout = 10.0
|
253
|
+
# config.rpcs.allocate_quota.timeout = 20.0
|
254
|
+
# end
|
255
|
+
#
|
256
|
+
# To apply the above configuration only to a new client:
|
257
|
+
#
|
258
|
+
# client = ::Google::Cloud::ServiceControl::V1::QuotaController::Client.new do |config|
|
259
|
+
# config.timeout = 10.0
|
260
|
+
# config.rpcs.allocate_quota.timeout = 20.0
|
261
|
+
# end
|
262
|
+
#
|
263
|
+
# @!attribute [rw] endpoint
|
264
|
+
# The hostname or hostname:port of the service endpoint.
|
265
|
+
# Defaults to `"servicecontrol.googleapis.com"`.
|
266
|
+
# @return [::String]
|
267
|
+
# @!attribute [rw] credentials
|
268
|
+
# Credentials to send with calls. You may provide any of the following types:
|
269
|
+
# * (`String`) The path to a service account key file in JSON format
|
270
|
+
# * (`Hash`) A service account key as a Hash
|
271
|
+
# * (`Google::Auth::Credentials`) A googleauth credentials object
|
272
|
+
# (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
|
273
|
+
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
|
274
|
+
# (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
|
275
|
+
# * (`GRPC::Core::Channel`) a gRPC channel with included credentials
|
276
|
+
# * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
|
277
|
+
# * (`nil`) indicating no credentials
|
278
|
+
# @return [::Object]
|
279
|
+
# @!attribute [rw] scope
|
280
|
+
# The OAuth scopes
|
281
|
+
# @return [::Array<::String>]
|
282
|
+
# @!attribute [rw] lib_name
|
283
|
+
# The library name as recorded in instrumentation and logging
|
284
|
+
# @return [::String]
|
285
|
+
# @!attribute [rw] lib_version
|
286
|
+
# The library version as recorded in instrumentation and logging
|
287
|
+
# @return [::String]
|
288
|
+
# @!attribute [rw] channel_args
|
289
|
+
# Extra parameters passed to the gRPC channel. Note: this is ignored if a
|
290
|
+
# `GRPC::Core::Channel` object is provided as the credential.
|
291
|
+
# @return [::Hash]
|
292
|
+
# @!attribute [rw] interceptors
|
293
|
+
# An array of interceptors that are run before calls are executed.
|
294
|
+
# @return [::Array<::GRPC::ClientInterceptor>]
|
295
|
+
# @!attribute [rw] timeout
|
296
|
+
# The call timeout in seconds.
|
297
|
+
# @return [::Numeric]
|
298
|
+
# @!attribute [rw] metadata
|
299
|
+
# Additional gRPC headers to be sent with the call.
|
300
|
+
# @return [::Hash{::Symbol=>::String}]
|
301
|
+
# @!attribute [rw] retry_policy
|
302
|
+
# The retry policy. The value is a hash with the following keys:
|
303
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
304
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
305
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
306
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
307
|
+
# trigger a retry.
|
308
|
+
# @return [::Hash]
|
309
|
+
# @!attribute [rw] quota_project
|
310
|
+
# A separate project against which to charge quota.
|
311
|
+
# @return [::String]
|
312
|
+
#
|
313
|
+
class Configuration
|
314
|
+
extend ::Gapic::Config
|
315
|
+
|
316
|
+
config_attr :endpoint, "servicecontrol.googleapis.com", ::String
|
317
|
+
config_attr :credentials, nil do |value|
|
318
|
+
allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
|
319
|
+
allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
|
320
|
+
allowed.any? { |klass| klass === value }
|
321
|
+
end
|
322
|
+
config_attr :scope, nil, ::String, ::Array, nil
|
323
|
+
config_attr :lib_name, nil, ::String, nil
|
324
|
+
config_attr :lib_version, nil, ::String, nil
|
325
|
+
config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, ::Hash, nil)
|
326
|
+
config_attr :interceptors, nil, ::Array, nil
|
327
|
+
config_attr :timeout, nil, ::Numeric, nil
|
328
|
+
config_attr :metadata, nil, ::Hash, nil
|
329
|
+
config_attr :retry_policy, nil, ::Hash, ::Proc, nil
|
330
|
+
config_attr :quota_project, nil, ::String, nil
|
331
|
+
|
332
|
+
# @private
|
333
|
+
def initialize parent_config = nil
|
334
|
+
@parent_config = parent_config unless parent_config.nil?
|
335
|
+
|
336
|
+
yield self if block_given?
|
337
|
+
end
|
338
|
+
|
339
|
+
##
|
340
|
+
# Configurations for individual RPCs
|
341
|
+
# @return [Rpcs]
|
342
|
+
#
|
343
|
+
def rpcs
|
344
|
+
@rpcs ||= begin
|
345
|
+
parent_rpcs = nil
|
346
|
+
parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config&.respond_to?(:rpcs)
|
347
|
+
Rpcs.new parent_rpcs
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
##
|
352
|
+
# Configuration RPC class for the QuotaController API.
|
353
|
+
#
|
354
|
+
# Includes fields providing the configuration for each RPC in this service.
|
355
|
+
# Each configuration object is of type `Gapic::Config::Method` and includes
|
356
|
+
# the following configuration fields:
|
357
|
+
#
|
358
|
+
# * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
|
359
|
+
# * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
|
360
|
+
# * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
|
361
|
+
# include the following keys:
|
362
|
+
# * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
|
363
|
+
# * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
|
364
|
+
# * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
|
365
|
+
# * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
|
366
|
+
# trigger a retry.
|
367
|
+
#
|
368
|
+
class Rpcs
|
369
|
+
##
|
370
|
+
# RPC-specific configuration for `allocate_quota`
|
371
|
+
# @return [::Gapic::Config::Method]
|
372
|
+
#
|
373
|
+
attr_reader :allocate_quota
|
374
|
+
|
375
|
+
# @private
|
376
|
+
def initialize parent_rpcs = nil
|
377
|
+
allocate_quota_config = parent_rpcs&.allocate_quota if parent_rpcs&.respond_to? :allocate_quota
|
378
|
+
@allocate_quota = ::Gapic::Config::Method.new allocate_quota_config
|
379
|
+
|
380
|
+
yield self if block_given?
|
381
|
+
end
|
382
|
+
end
|
383
|
+
end
|
384
|
+
end
|
385
|
+
end
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|
389
|
+
end
|