google-cloud-apigee_connect-v1 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 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 ApigeeConnect
24
+ module V1
25
+ module ConnectionService
26
+ # Credentials for the ConnectionService API.
27
+ class Credentials < ::Google::Auth::Credentials
28
+ self.scope = [
29
+ "https://www.googleapis.com/auth/cloud-platform"
30
+ ]
31
+ self.env_vars = [
32
+ "APIGEE_CONNECT_CREDENTIALS",
33
+ "APIGEE_CONNECT_KEYFILE",
34
+ "GOOGLE_CLOUD_CREDENTIALS",
35
+ "GOOGLE_CLOUD_KEYFILE",
36
+ "GCLOUD_KEYFILE",
37
+ "APIGEE_CONNECT_CREDENTIALS_JSON",
38
+ "APIGEE_CONNECT_KEYFILE_JSON",
39
+ "GOOGLE_CLOUD_CREDENTIALS_JSON",
40
+ "GOOGLE_CLOUD_KEYFILE_JSON",
41
+ "GCLOUD_KEYFILE_JSON"
42
+ ]
43
+ self.paths = [
44
+ "~/.config/google_cloud/application_default_credentials.json"
45
+ ]
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 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
+
20
+ module Google
21
+ module Cloud
22
+ module ApigeeConnect
23
+ module V1
24
+ module ConnectionService
25
+ # Path helper methods for the ConnectionService API.
26
+ module Paths
27
+ ##
28
+ # Create a fully-qualified Endpoint resource string.
29
+ #
30
+ # The resource will be in the following format:
31
+ #
32
+ # `projects/{project}/endpoints/{endpoint}`
33
+ #
34
+ # @param project [String]
35
+ # @param endpoint [String]
36
+ #
37
+ # @return [::String]
38
+ def endpoint_path project:, endpoint:
39
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
40
+
41
+ "projects/#{project}/endpoints/#{endpoint}"
42
+ end
43
+
44
+ extend self
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 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/apigee_connect/v1/version"
24
+
25
+ require "google/cloud/apigee_connect/v1/tether/credentials"
26
+ require "google/cloud/apigee_connect/v1/tether/client"
27
+
28
+ module Google
29
+ module Cloud
30
+ module ApigeeConnect
31
+ module V1
32
+ ##
33
+ # Tether provides a way for the control plane to send HTTP API requests to
34
+ # services in data planes that runs in a remote datacenter without
35
+ # requiring customers to open firewalls on their runtime plane.
36
+ #
37
+ # To load this service and instantiate a client:
38
+ #
39
+ # require "google/cloud/apigee_connect/v1/tether"
40
+ # client = ::Google::Cloud::ApigeeConnect::V1::Tether::Client.new
41
+ #
42
+ module Tether
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ helper_path = ::File.join __dir__, "tether", "helpers.rb"
50
+ require "google/cloud/apigee_connect/v1/tether/helpers" if ::File.file? helper_path
@@ -0,0 +1,367 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 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/apigeeconnect/v1/tether_pb"
21
+
22
+ module Google
23
+ module Cloud
24
+ module ApigeeConnect
25
+ module V1
26
+ module Tether
27
+ ##
28
+ # Client for the Tether service.
29
+ #
30
+ # Tether provides a way for the control plane to send HTTP API requests to
31
+ # services in data planes that runs in a remote datacenter without
32
+ # requiring customers to open firewalls on their runtime plane.
33
+ #
34
+ class Client
35
+ # @private
36
+ attr_reader :tether_stub
37
+
38
+ ##
39
+ # Configure the Tether Client class.
40
+ #
41
+ # See {::Google::Cloud::ApigeeConnect::V1::Tether::Client::Configuration}
42
+ # for a description of the configuration fields.
43
+ #
44
+ # ## Example
45
+ #
46
+ # To modify the configuration for all Tether clients:
47
+ #
48
+ # ::Google::Cloud::ApigeeConnect::V1::Tether::Client.configure do |config|
49
+ # config.timeout = 10.0
50
+ # end
51
+ #
52
+ # @yield [config] Configure the Client client.
53
+ # @yieldparam config [Client::Configuration]
54
+ #
55
+ # @return [Client::Configuration]
56
+ #
57
+ def self.configure
58
+ @configure ||= begin
59
+ namespace = ["Google", "Cloud", "ApigeeConnect", "V1"]
60
+ parent_config = while namespace.any?
61
+ parent_name = namespace.join "::"
62
+ parent_const = const_get parent_name
63
+ break parent_const.configure if parent_const.respond_to? :configure
64
+ namespace.pop
65
+ end
66
+ default_config = Client::Configuration.new parent_config
67
+
68
+ default_config
69
+ end
70
+ yield @configure if block_given?
71
+ @configure
72
+ end
73
+
74
+ ##
75
+ # Configure the Tether Client instance.
76
+ #
77
+ # The configuration is set to the derived mode, meaning that values can be changed,
78
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
79
+ # should be made on {Client.configure}.
80
+ #
81
+ # See {::Google::Cloud::ApigeeConnect::V1::Tether::Client::Configuration}
82
+ # for a description of the configuration fields.
83
+ #
84
+ # @yield [config] Configure the Client client.
85
+ # @yieldparam config [Client::Configuration]
86
+ #
87
+ # @return [Client::Configuration]
88
+ #
89
+ def configure
90
+ yield @config if block_given?
91
+ @config
92
+ end
93
+
94
+ ##
95
+ # Create a new Tether client object.
96
+ #
97
+ # ## Examples
98
+ #
99
+ # To create a new Tether client with the default
100
+ # configuration:
101
+ #
102
+ # client = ::Google::Cloud::ApigeeConnect::V1::Tether::Client.new
103
+ #
104
+ # To create a new Tether client with a custom
105
+ # configuration:
106
+ #
107
+ # client = ::Google::Cloud::ApigeeConnect::V1::Tether::Client.new do |config|
108
+ # config.timeout = 10.0
109
+ # end
110
+ #
111
+ # @yield [config] Configure the Tether client.
112
+ # @yieldparam config [Client::Configuration]
113
+ #
114
+ def initialize
115
+ # These require statements are intentionally placed here to initialize
116
+ # the gRPC module only when it's required.
117
+ # See https://github.com/googleapis/toolkit/issues/446
118
+ require "gapic/grpc"
119
+ require "google/cloud/apigeeconnect/v1/tether_services_pb"
120
+
121
+ # Create the configuration object
122
+ @config = Configuration.new Client.configure
123
+
124
+ # Yield the configuration if needed
125
+ yield @config if block_given?
126
+
127
+ # Create credentials
128
+ credentials = @config.credentials
129
+ # Use self-signed JWT if the scope and endpoint are unchanged from default,
130
+ # but only if the default endpoint does not have a region prefix.
131
+ enable_self_signed_jwt = @config.scope == Client.configure.scope &&
132
+ @config.endpoint == Client.configure.endpoint &&
133
+ !@config.endpoint.split(".").first.include?("-")
134
+ credentials ||= Credentials.default scope: @config.scope,
135
+ enable_self_signed_jwt: enable_self_signed_jwt
136
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
137
+ credentials = Credentials.new credentials, scope: @config.scope
138
+ end
139
+ @quota_project_id = @config.quota_project
140
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
141
+
142
+ @tether_stub = ::Gapic::ServiceStub.new(
143
+ ::Google::Cloud::ApigeeConnect::V1::Tether::Stub,
144
+ credentials: credentials,
145
+ endpoint: @config.endpoint,
146
+ channel_args: @config.channel_args,
147
+ interceptors: @config.interceptors
148
+ )
149
+ end
150
+
151
+ # Service calls
152
+
153
+ ##
154
+ # Egress streams egress requests and responses. Logically, this is not
155
+ # actually a streaming request, but uses streaming as a mechanism to flip
156
+ # the client-server relationship of gRPC so that the server can act as a
157
+ # client.
158
+ # The listener, the RPC server, accepts connections from the dialer,
159
+ # the RPC client.
160
+ # The listener streams http requests and the dialer streams http responses.
161
+ #
162
+ # @param request [::Gapic::StreamInput, ::Enumerable<::Google::Cloud::ApigeeConnect::V1::EgressResponse, ::Hash>]
163
+ # An enumerable of {::Google::Cloud::ApigeeConnect::V1::EgressResponse} instances.
164
+ # @param options [::Gapic::CallOptions, ::Hash]
165
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
166
+ #
167
+ # @yield [response, operation] Access the result along with the RPC operation
168
+ # @yieldparam response [::Enumerable<::Google::Cloud::ApigeeConnect::V1::EgressRequest>]
169
+ # @yieldparam operation [::GRPC::ActiveCall::Operation]
170
+ #
171
+ # @return [::Enumerable<::Google::Cloud::ApigeeConnect::V1::EgressRequest>]
172
+ #
173
+ # @raise [::Google::Cloud::Error] if the RPC is aborted.
174
+ #
175
+ def egress request, options = nil
176
+ unless request.is_a? ::Enumerable
177
+ raise ::ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum
178
+ request = request.to_enum
179
+ end
180
+
181
+ request = request.lazy.map do |req|
182
+ ::Gapic::Protobuf.coerce req, to: ::Google::Cloud::ApigeeConnect::V1::EgressResponse
183
+ end
184
+
185
+ # Converts hash and nil to an options object
186
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
187
+
188
+ # Customize the options with defaults
189
+ metadata = @config.rpcs.egress.metadata.to_h
190
+
191
+ # Set x-goog-api-client and x-goog-user-project headers
192
+ metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
193
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
194
+ gapic_version: ::Google::Cloud::ApigeeConnect::V1::VERSION
195
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
196
+
197
+ options.apply_defaults timeout: @config.rpcs.egress.timeout,
198
+ metadata: metadata,
199
+ retry_policy: @config.rpcs.egress.retry_policy
200
+ options.apply_defaults metadata: @config.metadata,
201
+ retry_policy: @config.retry_policy
202
+
203
+ @tether_stub.call_rpc :egress, request, options: options do |response, operation|
204
+ yield response, operation if block_given?
205
+ return response
206
+ end
207
+ rescue ::GRPC::BadStatus => e
208
+ raise ::Google::Cloud::Error.from_error(e)
209
+ end
210
+
211
+ ##
212
+ # Configuration class for the Tether API.
213
+ #
214
+ # This class represents the configuration for Tether,
215
+ # providing control over timeouts, retry behavior, logging, transport
216
+ # parameters, and other low-level controls. Certain parameters can also be
217
+ # applied individually to specific RPCs. See
218
+ # {::Google::Cloud::ApigeeConnect::V1::Tether::Client::Configuration::Rpcs}
219
+ # for a list of RPCs that can be configured independently.
220
+ #
221
+ # Configuration can be applied globally to all clients, or to a single client
222
+ # on construction.
223
+ #
224
+ # # Examples
225
+ #
226
+ # To modify the global config, setting the timeout for egress
227
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
228
+ #
229
+ # ::Google::Cloud::ApigeeConnect::V1::Tether::Client.configure do |config|
230
+ # config.timeout = 10.0
231
+ # config.rpcs.egress.timeout = 20.0
232
+ # end
233
+ #
234
+ # To apply the above configuration only to a new client:
235
+ #
236
+ # client = ::Google::Cloud::ApigeeConnect::V1::Tether::Client.new do |config|
237
+ # config.timeout = 10.0
238
+ # config.rpcs.egress.timeout = 20.0
239
+ # end
240
+ #
241
+ # @!attribute [rw] endpoint
242
+ # The hostname or hostname:port of the service endpoint.
243
+ # Defaults to `"apigeeconnect.googleapis.com"`.
244
+ # @return [::String]
245
+ # @!attribute [rw] credentials
246
+ # Credentials to send with calls. You may provide any of the following types:
247
+ # * (`String`) The path to a service account key file in JSON format
248
+ # * (`Hash`) A service account key as a Hash
249
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
250
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
251
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
252
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
253
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
254
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
255
+ # * (`nil`) indicating no credentials
256
+ # @return [::Object]
257
+ # @!attribute [rw] scope
258
+ # The OAuth scopes
259
+ # @return [::Array<::String>]
260
+ # @!attribute [rw] lib_name
261
+ # The library name as recorded in instrumentation and logging
262
+ # @return [::String]
263
+ # @!attribute [rw] lib_version
264
+ # The library version as recorded in instrumentation and logging
265
+ # @return [::String]
266
+ # @!attribute [rw] channel_args
267
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
268
+ # `GRPC::Core::Channel` object is provided as the credential.
269
+ # @return [::Hash]
270
+ # @!attribute [rw] interceptors
271
+ # An array of interceptors that are run before calls are executed.
272
+ # @return [::Array<::GRPC::ClientInterceptor>]
273
+ # @!attribute [rw] timeout
274
+ # The call timeout in seconds.
275
+ # @return [::Numeric]
276
+ # @!attribute [rw] metadata
277
+ # Additional gRPC headers to be sent with the call.
278
+ # @return [::Hash{::Symbol=>::String}]
279
+ # @!attribute [rw] retry_policy
280
+ # The retry policy. The value is a hash with the following keys:
281
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
282
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
283
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
284
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
285
+ # trigger a retry.
286
+ # @return [::Hash]
287
+ # @!attribute [rw] quota_project
288
+ # A separate project against which to charge quota.
289
+ # @return [::String]
290
+ #
291
+ class Configuration
292
+ extend ::Gapic::Config
293
+
294
+ config_attr :endpoint, "apigeeconnect.googleapis.com", ::String
295
+ config_attr :credentials, nil do |value|
296
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
297
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
298
+ allowed.any? { |klass| klass === value }
299
+ end
300
+ config_attr :scope, nil, ::String, ::Array, nil
301
+ config_attr :lib_name, nil, ::String, nil
302
+ config_attr :lib_version, nil, ::String, nil
303
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution" => 1 }, ::Hash, nil)
304
+ config_attr :interceptors, nil, ::Array, nil
305
+ config_attr :timeout, nil, ::Numeric, nil
306
+ config_attr :metadata, nil, ::Hash, nil
307
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
308
+ config_attr :quota_project, nil, ::String, nil
309
+
310
+ # @private
311
+ def initialize parent_config = nil
312
+ @parent_config = parent_config unless parent_config.nil?
313
+
314
+ yield self if block_given?
315
+ end
316
+
317
+ ##
318
+ # Configurations for individual RPCs
319
+ # @return [Rpcs]
320
+ #
321
+ def rpcs
322
+ @rpcs ||= begin
323
+ parent_rpcs = nil
324
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
325
+ Rpcs.new parent_rpcs
326
+ end
327
+ end
328
+
329
+ ##
330
+ # Configuration RPC class for the Tether API.
331
+ #
332
+ # Includes fields providing the configuration for each RPC in this service.
333
+ # Each configuration object is of type `Gapic::Config::Method` and includes
334
+ # the following configuration fields:
335
+ #
336
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
337
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
338
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
339
+ # include the following keys:
340
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
341
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
342
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
343
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
344
+ # trigger a retry.
345
+ #
346
+ class Rpcs
347
+ ##
348
+ # RPC-specific configuration for `egress`
349
+ # @return [::Gapic::Config::Method]
350
+ #
351
+ attr_reader :egress
352
+
353
+ # @private
354
+ def initialize parent_rpcs = nil
355
+ egress_config = parent_rpcs.egress if parent_rpcs.respond_to? :egress
356
+ @egress = ::Gapic::Config::Method.new egress_config
357
+
358
+ yield self if block_given?
359
+ end
360
+ end
361
+ end
362
+ end
363
+ end
364
+ end
365
+ end
366
+ end
367
+ end