google-cloud-location 0.1.2 → 0.3.beta.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e0a17d32c1b607a3c388555d73e6c6e867ee9026e60e0aaf661c96717a12701
4
- data.tar.gz: 4f60ac5e431874a42c6c38ecf95b19bde435b02fd669670c8f7ac0fd04ef0437
3
+ metadata.gz: d91f01afc5e162fb6acf5fbed86b645f1703832e51dab92a65cf56585ad96791
4
+ data.tar.gz: 2ea953918c7f1d8429bb906cc705327ec82f1975ba99a5afa0efd1c2416ab87a
5
5
  SHA512:
6
- metadata.gz: 832e8604924fded70d77cc93c927e2024e628ee5abcc1ce7f05c131c95e1edf491ab5defa442a18b1273f4a5be23edeb1dc65bee62337c9682bf99c18f009910
7
- data.tar.gz: b819f85495da8b9c3380adfbbdfb664e3b2fb6d084fea0ed16fdb64f262fb7922d805e4fb2b6970cf16044b1b5c296a7955b4b11c1ed57ed0fecbe3010f2ea39
6
+ metadata.gz: 4bdcf798ec2fe4299a48fdfda05e073323c8f4ecdda9037e9f85383a1005e2f300cb5f6e7a1900c8a9215db9bd57ac12d7b69bd8f76a85107bc6032fce7ac659
7
+ data.tar.gz: bfa91aea618ca13c9cf930ca356f368f32542c99b131d38aee920d8adc1d253b8cb0c9a88c4cdf730866c26d6bde73237ab7db9b98606af5a3ef196501d795bb
data/AUTHENTICATION.md CHANGED
@@ -112,7 +112,7 @@ credentials are discovered.
112
112
  To configure your system for this, simply:
113
113
 
114
114
  1. [Download and install the Cloud SDK](https://cloud.google.com/sdk)
115
- 2. Authenticate using OAuth 2.0 `$ gcloud auth login`
115
+ 2. Authenticate using OAuth 2.0 `$ gcloud auth application-default login`
116
116
  3. Write code as if already authenticated.
117
117
 
118
118
  **NOTE:** This is _not_ recommended for running in production. The Cloud SDK
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2021 Google LLC
3
+ # Copyright 2022 Google LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -0,0 +1,426 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2022 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/cloud/location/locations_pb"
21
+ require "google/cloud/location/locations/rest/service_stub"
22
+
23
+ module Google
24
+ module Cloud
25
+ module Location
26
+ module Locations
27
+ module Rest
28
+ ##
29
+ # REST client for the Locations service.
30
+ #
31
+ # An abstract interface that provides location-related information for
32
+ # a service. Service-specific metadata is provided through the
33
+ # {::Google::Cloud::Location::Location#metadata Location.metadata} field.
34
+ #
35
+ class Client
36
+ # @private
37
+ attr_reader :locations_stub
38
+
39
+ ##
40
+ # Configure the Locations Client class.
41
+ #
42
+ # See {::Google::Cloud::Location::Locations::Rest::Client::Configuration}
43
+ # for a description of the configuration fields.
44
+ #
45
+ # @example
46
+ #
47
+ # # Modify the configuration for all Locations clients
48
+ # ::Google::Cloud::Location::Locations::Rest::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", "Location"]
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 Locations 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::Location::Locations::Rest::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 Locations REST client object.
96
+ #
97
+ # @example
98
+ #
99
+ # # Create a client using the default configuration
100
+ # client = ::Google::Cloud::Location::Locations::Rest::Client.new
101
+ #
102
+ # # Create a client using a custom configuration
103
+ # client = ::Google::Cloud::Location::Locations::Rest::Client.new do |config|
104
+ # config.timeout = 10.0
105
+ # end
106
+ #
107
+ # @yield [config] Configure the Locations client.
108
+ # @yieldparam config [Client::Configuration]
109
+ #
110
+ def initialize
111
+ # Create the configuration object
112
+ @config = Configuration.new Client.configure
113
+
114
+ # Yield the configuration if needed
115
+ yield @config if block_given?
116
+
117
+ # Create credentials
118
+ credentials = @config.credentials
119
+ # Use self-signed JWT if the endpoint is unchanged from default,
120
+ # but only if the default endpoint does not have a region prefix.
121
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
122
+ !@config.endpoint.split(".").first.include?("-")
123
+ credentials ||= Credentials.default scope: @config.scope,
124
+ enable_self_signed_jwt: enable_self_signed_jwt
125
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
126
+ credentials = Credentials.new credentials, scope: @config.scope
127
+ end
128
+
129
+ @quota_project_id = @config.quota_project
130
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
131
+
132
+ @locations_stub = ::Google::Cloud::Location::Locations::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
133
+ end
134
+
135
+ # Service calls
136
+
137
+ ##
138
+ # Lists information about the supported locations for this service.
139
+ #
140
+ # @overload list_locations(request, options = nil)
141
+ # Pass arguments to `list_locations` via a request object, either of type
142
+ # {::Google::Cloud::Location::ListLocationsRequest} or an equivalent Hash.
143
+ #
144
+ # @param request [::Google::Cloud::Location::ListLocationsRequest, ::Hash]
145
+ # A request object representing the call parameters. Required. To specify no
146
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
147
+ # @param options [::Gapic::CallOptions, ::Hash]
148
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
149
+ #
150
+ # @overload list_locations(name: nil, filter: nil, page_size: nil, page_token: nil)
151
+ # Pass arguments to `list_locations` via keyword arguments. Note that at
152
+ # least one keyword argument is required. To specify no parameters, or to keep all
153
+ # the default parameter values, pass an empty Hash as a request object (see above).
154
+ #
155
+ # @param name [::String]
156
+ # The resource that owns the locations collection, if applicable.
157
+ # @param filter [::String]
158
+ # The standard list filter.
159
+ # @param page_size [::Integer]
160
+ # The standard list page size.
161
+ # @param page_token [::String]
162
+ # The standard list page token.
163
+ # @yield [result, response] Access the result along with the Faraday response object
164
+ # @yieldparam result [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Location::Location>]
165
+ # @yieldparam response [::Faraday::Response]
166
+ #
167
+ # @return [::Gapic::Rest::PagedEnumerable<::Google::Cloud::Location::Location>]
168
+ #
169
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
170
+ def list_locations request, options = nil
171
+ raise ::ArgumentError, "request must be provided" if request.nil?
172
+
173
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Location::ListLocationsRequest
174
+
175
+ # Converts hash and nil to an options object
176
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
177
+
178
+ # Customize the options with defaults
179
+ call_metadata = @config.rpcs.list_locations.metadata.to_h
180
+
181
+ # Set x-goog-api-client and x-goog-user-project headers
182
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
183
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
184
+ gapic_version: ::Google::Cloud::Location::VERSION,
185
+ transports_version_send: [:rest]
186
+
187
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
188
+
189
+ options.apply_defaults timeout: @config.rpcs.list_locations.timeout,
190
+ metadata: call_metadata,
191
+ retry_policy: @config.rpcs.list_locations.retry_policy
192
+
193
+ options.apply_defaults timeout: @config.timeout,
194
+ metadata: @config.metadata,
195
+ retry_policy: @config.retry_policy
196
+
197
+ @locations_stub.list_locations request, options do |result, response|
198
+ result = ::Gapic::Rest::PagedEnumerable.new @locations_stub, :list_locations, "locations", request, result, options
199
+ yield result, response if block_given?
200
+ return result
201
+ end
202
+ rescue ::Faraday::Error => e
203
+ begin
204
+ raise ::Gapic::Rest::Error.wrap_faraday_error e
205
+ rescue ::Gapic::Rest::Error => gapic_error
206
+ raise ::Google::Cloud::Error.from_error gapic_error
207
+ end
208
+ end
209
+
210
+ ##
211
+ # Gets information about a location.
212
+ #
213
+ # @overload get_location(request, options = nil)
214
+ # Pass arguments to `get_location` via a request object, either of type
215
+ # {::Google::Cloud::Location::GetLocationRequest} or an equivalent Hash.
216
+ #
217
+ # @param request [::Google::Cloud::Location::GetLocationRequest, ::Hash]
218
+ # A request object representing the call parameters. Required. To specify no
219
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
220
+ # @param options [::Gapic::CallOptions, ::Hash]
221
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
222
+ #
223
+ # @overload get_location(name: nil)
224
+ # Pass arguments to `get_location` via keyword arguments. Note that at
225
+ # least one keyword argument is required. To specify no parameters, or to keep all
226
+ # the default parameter values, pass an empty Hash as a request object (see above).
227
+ #
228
+ # @param name [::String]
229
+ # Resource name for the location.
230
+ # @yield [result, response] Access the result along with the Faraday response object
231
+ # @yieldparam result [::Google::Cloud::Location::Location]
232
+ # @yieldparam response [::Faraday::Response]
233
+ #
234
+ # @return [::Google::Cloud::Location::Location]
235
+ #
236
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
237
+ def get_location request, options = nil
238
+ raise ::ArgumentError, "request must be provided" if request.nil?
239
+
240
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Location::GetLocationRequest
241
+
242
+ # Converts hash and nil to an options object
243
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
244
+
245
+ # Customize the options with defaults
246
+ call_metadata = @config.rpcs.get_location.metadata.to_h
247
+
248
+ # Set x-goog-api-client and x-goog-user-project headers
249
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
250
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
251
+ gapic_version: ::Google::Cloud::Location::VERSION,
252
+ transports_version_send: [:rest]
253
+
254
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
255
+
256
+ options.apply_defaults timeout: @config.rpcs.get_location.timeout,
257
+ metadata: call_metadata,
258
+ retry_policy: @config.rpcs.get_location.retry_policy
259
+
260
+ options.apply_defaults timeout: @config.timeout,
261
+ metadata: @config.metadata,
262
+ retry_policy: @config.retry_policy
263
+
264
+ @locations_stub.get_location request, options do |result, response|
265
+ yield result, response if block_given?
266
+ return result
267
+ end
268
+ rescue ::Faraday::Error => e
269
+ begin
270
+ raise ::Gapic::Rest::Error.wrap_faraday_error e
271
+ rescue ::Gapic::Rest::Error => gapic_error
272
+ raise ::Google::Cloud::Error.from_error gapic_error
273
+ end
274
+ end
275
+
276
+ ##
277
+ # Configuration class for the Locations REST API.
278
+ #
279
+ # This class represents the configuration for Locations REST,
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::Location::Locations::Rest::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
+ # # list_locations to 20 seconds,
293
+ # # and all remaining timeouts to 10 seconds.
294
+ # ::Google::Cloud::Location::Locations::Rest::Client.configure do |config|
295
+ # config.timeout = 10.0
296
+ # config.rpcs.list_locations.timeout = 20.0
297
+ # end
298
+ #
299
+ # # Apply the above configuration only to a new client.
300
+ # client = ::Google::Cloud::Location::Locations::Rest::Client.new do |config|
301
+ # config.timeout = 10.0
302
+ # config.rpcs.list_locations.timeout = 20.0
303
+ # end
304
+ #
305
+ # @!attribute [rw] endpoint
306
+ # The hostname or hostname:port of the service endpoint.
307
+ # Defaults to `"cloud.googleapis.com"`.
308
+ # @return [::String]
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://googleapis.dev/ruby/googleauth/latest/index.html))
315
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
316
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
317
+ # * (`nil`) indicating no credentials
318
+ # @return [::Object]
319
+ # @!attribute [rw] scope
320
+ # The OAuth scopes
321
+ # @return [::Array<::String>]
322
+ # @!attribute [rw] lib_name
323
+ # The library name as recorded in instrumentation and logging
324
+ # @return [::String]
325
+ # @!attribute [rw] lib_version
326
+ # The library version as recorded in instrumentation and logging
327
+ # @return [::String]
328
+ # @!attribute [rw] timeout
329
+ # The call timeout in seconds.
330
+ # @return [::Numeric]
331
+ # @!attribute [rw] metadata
332
+ # Additional headers to be sent with the call.
333
+ # @return [::Hash{::Symbol=>::String}]
334
+ # @!attribute [rw] retry_policy
335
+ # The retry policy. The value is a hash with 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
+ # @return [::Hash]
342
+ # @!attribute [rw] quota_project
343
+ # A separate project against which to charge quota.
344
+ # @return [::String]
345
+ #
346
+ class Configuration
347
+ extend ::Gapic::Config
348
+
349
+ config_attr :endpoint, "cloud.googleapis.com", ::String
350
+ config_attr :credentials, nil do |value|
351
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
352
+ allowed.any? { |klass| klass === value }
353
+ end
354
+ config_attr :scope, nil, ::String, ::Array, nil
355
+ config_attr :lib_name, nil, ::String, nil
356
+ config_attr :lib_version, nil, ::String, nil
357
+ config_attr :timeout, nil, ::Numeric, nil
358
+ config_attr :metadata, nil, ::Hash, nil
359
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
360
+ config_attr :quota_project, nil, ::String, nil
361
+
362
+ # @private
363
+ def initialize parent_config = nil
364
+ @parent_config = parent_config unless parent_config.nil?
365
+
366
+ yield self if block_given?
367
+ end
368
+
369
+ ##
370
+ # Configurations for individual RPCs
371
+ # @return [Rpcs]
372
+ #
373
+ def rpcs
374
+ @rpcs ||= begin
375
+ parent_rpcs = nil
376
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
377
+ Rpcs.new parent_rpcs
378
+ end
379
+ end
380
+
381
+ ##
382
+ # Configuration RPC class for the Locations API.
383
+ #
384
+ # Includes fields providing the configuration for each RPC in this service.
385
+ # Each configuration object is of type `Gapic::Config::Method` and includes
386
+ # the following configuration fields:
387
+ #
388
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
389
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
390
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
391
+ # include the following keys:
392
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
393
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
394
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
395
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
396
+ # trigger a retry.
397
+ #
398
+ class Rpcs
399
+ ##
400
+ # RPC-specific configuration for `list_locations`
401
+ # @return [::Gapic::Config::Method]
402
+ #
403
+ attr_reader :list_locations
404
+ ##
405
+ # RPC-specific configuration for `get_location`
406
+ # @return [::Gapic::Config::Method]
407
+ #
408
+ attr_reader :get_location
409
+
410
+ # @private
411
+ def initialize parent_rpcs = nil
412
+ list_locations_config = parent_rpcs.list_locations if parent_rpcs.respond_to? :list_locations
413
+ @list_locations = ::Gapic::Config::Method.new list_locations_config
414
+ get_location_config = parent_rpcs.get_location if parent_rpcs.respond_to? :get_location
415
+ @get_location = ::Gapic::Config::Method.new get_location_config
416
+
417
+ yield self if block_given?
418
+ end
419
+ end
420
+ end
421
+ end
422
+ end
423
+ end
424
+ end
425
+ end
426
+ end
@@ -0,0 +1,174 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2022 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/location/locations_pb"
20
+
21
+ module Google
22
+ module Cloud
23
+ module Location
24
+ module Locations
25
+ module Rest
26
+ ##
27
+ # REST service stub for the Locations service.
28
+ # Service stub contains baseline method implementations
29
+ # including transcoding, making the REST call, and deserialing the response.
30
+ #
31
+ class ServiceStub
32
+ def initialize endpoint:, credentials:
33
+ # These require statements are intentionally placed here to initialize
34
+ # the REST modules only when it's required.
35
+ require "gapic/rest"
36
+
37
+ @client_stub = ::Gapic::Rest::ClientStub.new endpoint: endpoint, credentials: credentials, numeric_enums: true
38
+ end
39
+
40
+ ##
41
+ # Baseline implementation for the list_locations REST call
42
+ #
43
+ # @param request_pb [::Google::Cloud::Location::ListLocationsRequest]
44
+ # A request object representing the call parameters. Required.
45
+ # @param options [::Gapic::CallOptions]
46
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
47
+ #
48
+ # @yield [result, response] Access the result along with the Faraday response object
49
+ # @yieldparam result [::Google::Cloud::Location::ListLocationsResponse]
50
+ # @yieldparam response [::Faraday::Response]
51
+ #
52
+ # @return [::Google::Cloud::Location::ListLocationsResponse]
53
+ # A result object deserialized from the server's reply
54
+ def list_locations request_pb, options = nil
55
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
56
+
57
+ verb, uri, query_string_params, body = ServiceStub.transcode_list_locations_request request_pb
58
+ query_string_params = if query_string_params.any?
59
+ query_string_params.to_h { |p| p.split("=", 2) }
60
+ else
61
+ {}
62
+ end
63
+
64
+ response = @client_stub.make_http_request(
65
+ verb,
66
+ uri: uri,
67
+ body: body || "",
68
+ params: query_string_params,
69
+ options: options
70
+ )
71
+ result = ::Google::Cloud::Location::ListLocationsResponse.decode_json response.body, ignore_unknown_fields: true
72
+
73
+ yield result, response if block_given?
74
+ result
75
+ end
76
+
77
+ ##
78
+ # Baseline implementation for the get_location REST call
79
+ #
80
+ # @param request_pb [::Google::Cloud::Location::GetLocationRequest]
81
+ # A request object representing the call parameters. Required.
82
+ # @param options [::Gapic::CallOptions]
83
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
84
+ #
85
+ # @yield [result, response] Access the result along with the Faraday response object
86
+ # @yieldparam result [::Google::Cloud::Location::Location]
87
+ # @yieldparam response [::Faraday::Response]
88
+ #
89
+ # @return [::Google::Cloud::Location::Location]
90
+ # A result object deserialized from the server's reply
91
+ def get_location request_pb, options = nil
92
+ raise ::ArgumentError, "request must be provided" if request_pb.nil?
93
+
94
+ verb, uri, query_string_params, body = ServiceStub.transcode_get_location_request request_pb
95
+ query_string_params = if query_string_params.any?
96
+ query_string_params.to_h { |p| p.split("=", 2) }
97
+ else
98
+ {}
99
+ end
100
+
101
+ response = @client_stub.make_http_request(
102
+ verb,
103
+ uri: uri,
104
+ body: body || "",
105
+ params: query_string_params,
106
+ options: options
107
+ )
108
+ result = ::Google::Cloud::Location::Location.decode_json response.body, ignore_unknown_fields: true
109
+
110
+ yield result, response if block_given?
111
+ result
112
+ end
113
+
114
+ ##
115
+ # @private
116
+ #
117
+ # GRPC transcoding helper method for the list_locations REST call
118
+ #
119
+ # @param request_pb [::Google::Cloud::Location::ListLocationsRequest]
120
+ # A request object representing the call parameters. Required.
121
+ # @return [Array(String, [String, nil], Hash{String => String})]
122
+ # Uri, Body, Query string parameters
123
+ def self.transcode_list_locations_request request_pb
124
+ transcoder = Gapic::Rest::GrpcTranscoder.new
125
+ .with_bindings(
126
+ uri_method: :get,
127
+ uri_template: "/v1/{name}",
128
+ matches: [
129
+ ["name", %r{^locations/?$}, false]
130
+ ]
131
+ )
132
+ .with_bindings(
133
+ uri_method: :get,
134
+ uri_template: "/v1/{name}/locations",
135
+ matches: [
136
+ ["name", %r{^projects/[^/]+/?$}, false]
137
+ ]
138
+ )
139
+ transcoder.transcode request_pb
140
+ end
141
+
142
+ ##
143
+ # @private
144
+ #
145
+ # GRPC transcoding helper method for the get_location REST call
146
+ #
147
+ # @param request_pb [::Google::Cloud::Location::GetLocationRequest]
148
+ # A request object representing the call parameters. Required.
149
+ # @return [Array(String, [String, nil], Hash{String => String})]
150
+ # Uri, Body, Query string parameters
151
+ def self.transcode_get_location_request request_pb
152
+ transcoder = Gapic::Rest::GrpcTranscoder.new
153
+ .with_bindings(
154
+ uri_method: :get,
155
+ uri_template: "/v1/{name}",
156
+ matches: [
157
+ ["name", %r{^locations/[^/]+/?$}, false]
158
+ ]
159
+ )
160
+ .with_bindings(
161
+ uri_method: :get,
162
+ uri_template: "/v1/{name}",
163
+ matches: [
164
+ ["name", %r{^projects/[^/]+/locations/[^/]+/?$}, false]
165
+ ]
166
+ )
167
+ transcoder.transcode request_pb
168
+ end
169
+ end
170
+ end
171
+ end
172
+ end
173
+ end
174
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2022 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/rest"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/location/version"
24
+
25
+ require "google/cloud/location/locations/credentials"
26
+ require "google/cloud/location/locations/rest/client"
27
+
28
+ module Google
29
+ module Cloud
30
+ module Location
31
+ ##
32
+ # An abstract interface that provides location-related information for
33
+ # a service. Service-specific metadata is provided through the
34
+ # {::Google::Cloud::Location::Location#metadata Location.metadata} field.
35
+ #
36
+ # To load this service and instantiate a REST client:
37
+ #
38
+ # require "google/cloud/location/locations/rest"
39
+ # client = ::Google::Cloud::Location::Locations::Rest::Client.new
40
+ #
41
+ module Locations
42
+ # Client for the REST transport
43
+ module Rest
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ helper_path = ::File.join __dir__, "rest", "helpers.rb"
51
+ require "google/cloud/location/locations/rest/helpers" if ::File.file? helper_path