google-cloud-gke_connect-gateway-v1 0.a → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,450 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2024 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/cloud/gkeconnect/gateway/v1/control_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module GkeConnect
25
+ module Gateway
26
+ module V1
27
+ module GatewayControl
28
+ ##
29
+ # Client for the GatewayControl service.
30
+ #
31
+ # GatewayControl is the control plane API for Connect Gateway.
32
+ #
33
+ class Client
34
+ # @private
35
+ API_VERSION = ""
36
+
37
+ # @private
38
+ DEFAULT_ENDPOINT_TEMPLATE = "connectgateway.$UNIVERSE_DOMAIN$"
39
+
40
+ # @private
41
+ attr_reader :gateway_control_stub
42
+
43
+ ##
44
+ # Configure the GatewayControl Client class.
45
+ #
46
+ # See {::Google::Cloud::GkeConnect::Gateway::V1::GatewayControl::Client::Configuration}
47
+ # for a description of the configuration fields.
48
+ #
49
+ # @example
50
+ #
51
+ # # Modify the configuration for all GatewayControl clients
52
+ # ::Google::Cloud::GkeConnect::Gateway::V1::GatewayControl::Client.configure do |config|
53
+ # config.timeout = 10.0
54
+ # end
55
+ #
56
+ # @yield [config] Configure the Client client.
57
+ # @yieldparam config [Client::Configuration]
58
+ #
59
+ # @return [Client::Configuration]
60
+ #
61
+ def self.configure
62
+ @configure ||= begin
63
+ namespace = ["Google", "Cloud", "GkeConnect", "Gateway", "V1"]
64
+ parent_config = while namespace.any?
65
+ parent_name = namespace.join "::"
66
+ parent_const = const_get parent_name
67
+ break parent_const.configure if parent_const.respond_to? :configure
68
+ namespace.pop
69
+ end
70
+ default_config = Client::Configuration.new parent_config
71
+
72
+ default_config.rpcs.generate_credentials.timeout = 60.0
73
+ default_config.rpcs.generate_credentials.retry_policy = {
74
+ initial_delay: 1.0, max_delay: 10.0, multiplier: 1.3, retry_codes: [14]
75
+ }
76
+
77
+ default_config
78
+ end
79
+ yield @configure if block_given?
80
+ @configure
81
+ end
82
+
83
+ ##
84
+ # Configure the GatewayControl Client instance.
85
+ #
86
+ # The configuration is set to the derived mode, meaning that values can be changed,
87
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
88
+ # should be made on {Client.configure}.
89
+ #
90
+ # See {::Google::Cloud::GkeConnect::Gateway::V1::GatewayControl::Client::Configuration}
91
+ # for a description of the configuration fields.
92
+ #
93
+ # @yield [config] Configure the Client client.
94
+ # @yieldparam config [Client::Configuration]
95
+ #
96
+ # @return [Client::Configuration]
97
+ #
98
+ def configure
99
+ yield @config if block_given?
100
+ @config
101
+ end
102
+
103
+ ##
104
+ # The effective universe domain
105
+ #
106
+ # @return [String]
107
+ #
108
+ def universe_domain
109
+ @gateway_control_stub.universe_domain
110
+ end
111
+
112
+ ##
113
+ # Create a new GatewayControl client object.
114
+ #
115
+ # @example
116
+ #
117
+ # # Create a client using the default configuration
118
+ # client = ::Google::Cloud::GkeConnect::Gateway::V1::GatewayControl::Client.new
119
+ #
120
+ # # Create a client using a custom configuration
121
+ # client = ::Google::Cloud::GkeConnect::Gateway::V1::GatewayControl::Client.new do |config|
122
+ # config.timeout = 10.0
123
+ # end
124
+ #
125
+ # @yield [config] Configure the GatewayControl client.
126
+ # @yieldparam config [Client::Configuration]
127
+ #
128
+ def initialize
129
+ # These require statements are intentionally placed here to initialize
130
+ # the gRPC module only when it's required.
131
+ # See https://github.com/googleapis/toolkit/issues/446
132
+ require "gapic/grpc"
133
+ require "google/cloud/gkeconnect/gateway/v1/control_services_pb"
134
+
135
+ # Create the configuration object
136
+ @config = Configuration.new Client.configure
137
+
138
+ # Yield the configuration if needed
139
+ yield @config if block_given?
140
+
141
+ # Create credentials
142
+ credentials = @config.credentials
143
+ # Use self-signed JWT if the endpoint is unchanged from default,
144
+ # but only if the default endpoint does not have a region prefix.
145
+ enable_self_signed_jwt = @config.endpoint.nil? ||
146
+ (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
147
+ !@config.endpoint.split(".").first.include?("-"))
148
+ credentials ||= Credentials.default scope: @config.scope,
149
+ enable_self_signed_jwt: enable_self_signed_jwt
150
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
151
+ credentials = Credentials.new credentials, scope: @config.scope
152
+ end
153
+ @quota_project_id = @config.quota_project
154
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
155
+
156
+ @gateway_control_stub = ::Gapic::ServiceStub.new(
157
+ ::Google::Cloud::GkeConnect::Gateway::V1::GatewayControl::Stub,
158
+ credentials: credentials,
159
+ endpoint: @config.endpoint,
160
+ endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
161
+ universe_domain: @config.universe_domain,
162
+ channel_args: @config.channel_args,
163
+ interceptors: @config.interceptors,
164
+ channel_pool_config: @config.channel_pool
165
+ )
166
+ end
167
+
168
+ # Service calls
169
+
170
+ ##
171
+ # GenerateCredentials provides connection information that allows a user to
172
+ # access the specified membership using Connect Gateway.
173
+ #
174
+ # @overload generate_credentials(request, options = nil)
175
+ # Pass arguments to `generate_credentials` via a request object, either of type
176
+ # {::Google::Cloud::GkeConnect::Gateway::V1::GenerateCredentialsRequest} or an equivalent Hash.
177
+ #
178
+ # @param request [::Google::Cloud::GkeConnect::Gateway::V1::GenerateCredentialsRequest, ::Hash]
179
+ # A request object representing the call parameters. Required. To specify no
180
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
181
+ # @param options [::Gapic::CallOptions, ::Hash]
182
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
183
+ #
184
+ # @overload generate_credentials(name: nil, force_use_agent: nil, version: nil, kubernetes_namespace: nil, operating_system: nil)
185
+ # Pass arguments to `generate_credentials` via keyword arguments. Note that at
186
+ # least one keyword argument is required. To specify no parameters, or to keep all
187
+ # the default parameter values, pass an empty Hash as a request object (see above).
188
+ #
189
+ # @param name [::String]
190
+ # Required. The Fleet membership resource.
191
+ # @param force_use_agent [::Boolean]
192
+ # Optional. Whether to force the use of Connect Agent-based transport.
193
+ #
194
+ # This will return a configuration that uses Connect Agent as the underlying
195
+ # transport mechanism for cluster types that would otherwise have used a
196
+ # different transport. Requires that Connect Agent be installed on the
197
+ # cluster. Setting this field to false is equivalent to not setting it.
198
+ # @param version [::String]
199
+ # Optional. The Connect Gateway version to be used in the resulting
200
+ # configuration.
201
+ #
202
+ # Leave this field blank to let the server choose the version (recommended).
203
+ # @param kubernetes_namespace [::String]
204
+ # Optional. The namespace to use in the kubeconfig context.
205
+ #
206
+ # If this field is specified, the server will set the `namespace` field in
207
+ # kubeconfig context. If not specified, the `namespace` field is omitted.
208
+ # @param operating_system [::Google::Cloud::GkeConnect::Gateway::V1::GenerateCredentialsRequest::OperatingSystem]
209
+ # Optional. The operating system where the kubeconfig will be used.
210
+ #
211
+ # @yield [response, operation] Access the result along with the RPC operation
212
+ # @yieldparam response [::Google::Cloud::GkeConnect::Gateway::V1::GenerateCredentialsResponse]
213
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
214
+ #
215
+ # @return [::Google::Cloud::GkeConnect::Gateway::V1::GenerateCredentialsResponse]
216
+ #
217
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
218
+ #
219
+ # @example Basic example
220
+ # require "google/cloud/gke_connect/gateway/v1"
221
+ #
222
+ # # Create a client object. The client can be reused for multiple calls.
223
+ # client = Google::Cloud::GkeConnect::Gateway::V1::GatewayControl::Client.new
224
+ #
225
+ # # Create a request. To set request fields, pass in keyword arguments.
226
+ # request = Google::Cloud::GkeConnect::Gateway::V1::GenerateCredentialsRequest.new
227
+ #
228
+ # # Call the generate_credentials method.
229
+ # result = client.generate_credentials request
230
+ #
231
+ # # The returned object is of type Google::Cloud::GkeConnect::Gateway::V1::GenerateCredentialsResponse.
232
+ # p result
233
+ #
234
+ def generate_credentials request, options = nil
235
+ raise ::ArgumentError, "request must be provided" if request.nil?
236
+
237
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::GkeConnect::Gateway::V1::GenerateCredentialsRequest
238
+
239
+ # Converts hash and nil to an options object
240
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
241
+
242
+ # Customize the options with defaults
243
+ metadata = @config.rpcs.generate_credentials.metadata.to_h
244
+
245
+ # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
246
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
247
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
248
+ gapic_version: ::Google::Cloud::GkeConnect::Gateway::V1::VERSION
249
+ metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
250
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
251
+
252
+ header_params = {}
253
+ if request.name
254
+ header_params["name"] = request.name
255
+ end
256
+
257
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
258
+ metadata[:"x-goog-request-params"] ||= request_params_header
259
+
260
+ options.apply_defaults timeout: @config.rpcs.generate_credentials.timeout,
261
+ metadata: metadata,
262
+ retry_policy: @config.rpcs.generate_credentials.retry_policy
263
+
264
+ options.apply_defaults timeout: @config.timeout,
265
+ metadata: @config.metadata,
266
+ retry_policy: @config.retry_policy
267
+
268
+ @gateway_control_stub.call_rpc :generate_credentials, request, options: options do |response, operation|
269
+ yield response, operation if block_given?
270
+ return response
271
+ end
272
+ rescue ::GRPC::BadStatus => e
273
+ raise ::Google::Cloud::Error.from_error(e)
274
+ end
275
+
276
+ ##
277
+ # Configuration class for the GatewayControl API.
278
+ #
279
+ # This class represents the configuration for GatewayControl,
280
+ # providing control over timeouts, retry behavior, logging, transport
281
+ # parameters, and other low-level controls. Certain parameters can also be
282
+ # applied individually to specific RPCs. See
283
+ # {::Google::Cloud::GkeConnect::Gateway::V1::GatewayControl::Client::Configuration::Rpcs}
284
+ # for a list of RPCs that can be configured independently.
285
+ #
286
+ # Configuration can be applied globally to all clients, or to a single client
287
+ # on construction.
288
+ #
289
+ # @example
290
+ #
291
+ # # Modify the global config, setting the timeout for
292
+ # # generate_credentials to 20 seconds,
293
+ # # and all remaining timeouts to 10 seconds.
294
+ # ::Google::Cloud::GkeConnect::Gateway::V1::GatewayControl::Client.configure do |config|
295
+ # config.timeout = 10.0
296
+ # config.rpcs.generate_credentials.timeout = 20.0
297
+ # end
298
+ #
299
+ # # Apply the above configuration only to a new client.
300
+ # client = ::Google::Cloud::GkeConnect::Gateway::V1::GatewayControl::Client.new do |config|
301
+ # config.timeout = 10.0
302
+ # config.rpcs.generate_credentials.timeout = 20.0
303
+ # end
304
+ #
305
+ # @!attribute [rw] endpoint
306
+ # A custom service endpoint, as a hostname or hostname:port. The default is
307
+ # nil, indicating to use the default endpoint in the current universe domain.
308
+ # @return [::String,nil]
309
+ # @!attribute [rw] credentials
310
+ # Credentials to send with calls. You may provide any of the following types:
311
+ # * (`String`) The path to a service account key file in JSON format
312
+ # * (`Hash`) A service account key as a Hash
313
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
314
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
315
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
316
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
317
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
318
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
319
+ # * (`nil`) indicating no credentials
320
+ # @return [::Object]
321
+ # @!attribute [rw] scope
322
+ # The OAuth scopes
323
+ # @return [::Array<::String>]
324
+ # @!attribute [rw] lib_name
325
+ # The library name as recorded in instrumentation and logging
326
+ # @return [::String]
327
+ # @!attribute [rw] lib_version
328
+ # The library version as recorded in instrumentation and logging
329
+ # @return [::String]
330
+ # @!attribute [rw] channel_args
331
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
332
+ # `GRPC::Core::Channel` object is provided as the credential.
333
+ # @return [::Hash]
334
+ # @!attribute [rw] interceptors
335
+ # An array of interceptors that are run before calls are executed.
336
+ # @return [::Array<::GRPC::ClientInterceptor>]
337
+ # @!attribute [rw] timeout
338
+ # The call timeout in seconds.
339
+ # @return [::Numeric]
340
+ # @!attribute [rw] metadata
341
+ # Additional gRPC headers to be sent with the call.
342
+ # @return [::Hash{::Symbol=>::String}]
343
+ # @!attribute [rw] retry_policy
344
+ # The retry policy. The value is a hash with the following keys:
345
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
346
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
347
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
348
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
349
+ # trigger a retry.
350
+ # @return [::Hash]
351
+ # @!attribute [rw] quota_project
352
+ # A separate project against which to charge quota.
353
+ # @return [::String]
354
+ # @!attribute [rw] universe_domain
355
+ # The universe domain within which to make requests. This determines the
356
+ # default endpoint URL. The default value of nil uses the environment
357
+ # universe (usually the default "googleapis.com" universe).
358
+ # @return [::String,nil]
359
+ #
360
+ class Configuration
361
+ extend ::Gapic::Config
362
+
363
+ # @private
364
+ # The endpoint specific to the default "googleapis.com" universe. Deprecated.
365
+ DEFAULT_ENDPOINT = "connectgateway.googleapis.com"
366
+
367
+ config_attr :endpoint, nil, ::String, nil
368
+ config_attr :credentials, nil do |value|
369
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
370
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
371
+ allowed.any? { |klass| klass === value }
372
+ end
373
+ config_attr :scope, nil, ::String, ::Array, nil
374
+ config_attr :lib_name, nil, ::String, nil
375
+ config_attr :lib_version, nil, ::String, nil
376
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
377
+ config_attr :interceptors, nil, ::Array, nil
378
+ config_attr :timeout, nil, ::Numeric, nil
379
+ config_attr :metadata, nil, ::Hash, nil
380
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
381
+ config_attr :quota_project, nil, ::String, nil
382
+ config_attr :universe_domain, nil, ::String, nil
383
+
384
+ # @private
385
+ def initialize parent_config = nil
386
+ @parent_config = parent_config unless parent_config.nil?
387
+
388
+ yield self if block_given?
389
+ end
390
+
391
+ ##
392
+ # Configurations for individual RPCs
393
+ # @return [Rpcs]
394
+ #
395
+ def rpcs
396
+ @rpcs ||= begin
397
+ parent_rpcs = nil
398
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
399
+ Rpcs.new parent_rpcs
400
+ end
401
+ end
402
+
403
+ ##
404
+ # Configuration for the channel pool
405
+ # @return [::Gapic::ServiceStub::ChannelPool::Configuration]
406
+ #
407
+ def channel_pool
408
+ @channel_pool ||= ::Gapic::ServiceStub::ChannelPool::Configuration.new
409
+ end
410
+
411
+ ##
412
+ # Configuration RPC class for the GatewayControl API.
413
+ #
414
+ # Includes fields providing the configuration for each RPC in this service.
415
+ # Each configuration object is of type `Gapic::Config::Method` and includes
416
+ # the following configuration fields:
417
+ #
418
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
419
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
420
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
421
+ # include the following keys:
422
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
423
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
424
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
425
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
426
+ # trigger a retry.
427
+ #
428
+ class Rpcs
429
+ ##
430
+ # RPC-specific configuration for `generate_credentials`
431
+ # @return [::Gapic::Config::Method]
432
+ #
433
+ attr_reader :generate_credentials
434
+
435
+ # @private
436
+ def initialize parent_rpcs = nil
437
+ generate_credentials_config = parent_rpcs.generate_credentials if parent_rpcs.respond_to? :generate_credentials
438
+ @generate_credentials = ::Gapic::Config::Method.new generate_credentials_config
439
+
440
+ yield self if block_given?
441
+ end
442
+ end
443
+ end
444
+ end
445
+ end
446
+ end
447
+ end
448
+ end
449
+ end
450
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2024 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 "googleauth"
20
+
21
+ module Google
22
+ module Cloud
23
+ module GkeConnect
24
+ module Gateway
25
+ module V1
26
+ module GatewayControl
27
+ # Credentials for the GatewayControl API.
28
+ class Credentials < ::Google::Auth::Credentials
29
+ self.scope = [
30
+ "https://www.googleapis.com/auth/cloud-platform"
31
+ ]
32
+ self.env_vars = [
33
+ "GOOGLE_CLOUD_CREDENTIALS",
34
+ "GOOGLE_CLOUD_KEYFILE",
35
+ "GCLOUD_KEYFILE",
36
+ "GOOGLE_CLOUD_CREDENTIALS_JSON",
37
+ "GOOGLE_CLOUD_KEYFILE_JSON",
38
+ "GCLOUD_KEYFILE_JSON"
39
+ ]
40
+ self.paths = [
41
+ "~/.config/google_cloud/application_default_credentials.json"
42
+ ]
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end