google-cloud-functions-v2 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,972 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "google/cloud/errors"
20
+ require "google/cloud/functions/v2/functions_pb"
21
+ require "google/cloud/functions/v2/function_service/rest/service_stub"
22
+ require "google/cloud/location/rest"
23
+ require "google/iam/v1/rest"
24
+
25
+ module Google
26
+ module Cloud
27
+ module Functions
28
+ module V2
29
+ module FunctionService
30
+ module Rest
31
+ ##
32
+ # REST client for the FunctionService service.
33
+ #
34
+ # Google Cloud Functions is used to deploy functions that are executed by
35
+ # Google in response to various events. Data connected with that event is
36
+ # passed to a function as the input data.
37
+ #
38
+ # A **function** is a resource which describes a function that should be
39
+ # executed and how it is triggered.
40
+ #
41
+ class Client
42
+ include Paths
43
+
44
+ # @private
45
+ attr_reader :function_service_stub
46
+
47
+ ##
48
+ # Configure the FunctionService Client class.
49
+ #
50
+ # See {::Google::Cloud::Functions::V2::FunctionService::Rest::Client::Configuration}
51
+ # for a description of the configuration fields.
52
+ #
53
+ # @example
54
+ #
55
+ # # Modify the configuration for all FunctionService clients
56
+ # ::Google::Cloud::Functions::V2::FunctionService::Rest::Client.configure do |config|
57
+ # config.timeout = 10.0
58
+ # end
59
+ #
60
+ # @yield [config] Configure the Client client.
61
+ # @yieldparam config [Client::Configuration]
62
+ #
63
+ # @return [Client::Configuration]
64
+ #
65
+ def self.configure
66
+ @configure ||= begin
67
+ namespace = ["Google", "Cloud", "Functions", "V2"]
68
+ parent_config = while namespace.any?
69
+ parent_name = namespace.join "::"
70
+ parent_const = const_get parent_name
71
+ break parent_const.configure if parent_const.respond_to? :configure
72
+ namespace.pop
73
+ end
74
+ default_config = Client::Configuration.new parent_config
75
+
76
+ default_config
77
+ end
78
+ yield @configure if block_given?
79
+ @configure
80
+ end
81
+
82
+ ##
83
+ # Configure the FunctionService Client instance.
84
+ #
85
+ # The configuration is set to the derived mode, meaning that values can be changed,
86
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
87
+ # should be made on {Client.configure}.
88
+ #
89
+ # See {::Google::Cloud::Functions::V2::FunctionService::Rest::Client::Configuration}
90
+ # for a description of the configuration fields.
91
+ #
92
+ # @yield [config] Configure the Client client.
93
+ # @yieldparam config [Client::Configuration]
94
+ #
95
+ # @return [Client::Configuration]
96
+ #
97
+ def configure
98
+ yield @config if block_given?
99
+ @config
100
+ end
101
+
102
+ ##
103
+ # Create a new FunctionService REST client object.
104
+ #
105
+ # @example
106
+ #
107
+ # # Create a client using the default configuration
108
+ # client = ::Google::Cloud::Functions::V2::FunctionService::Rest::Client.new
109
+ #
110
+ # # Create a client using a custom configuration
111
+ # client = ::Google::Cloud::Functions::V2::FunctionService::Rest::Client.new do |config|
112
+ # config.timeout = 10.0
113
+ # end
114
+ #
115
+ # @yield [config] Configure the FunctionService client.
116
+ # @yieldparam config [Client::Configuration]
117
+ #
118
+ def initialize
119
+ # Create the configuration object
120
+ @config = Configuration.new Client.configure
121
+
122
+ # Yield the configuration if needed
123
+ yield @config if block_given?
124
+
125
+ # Create credentials
126
+ credentials = @config.credentials
127
+ # Use self-signed JWT if the endpoint is unchanged from default,
128
+ # but only if the default endpoint does not have a region prefix.
129
+ enable_self_signed_jwt = @config.endpoint == Client.configure.endpoint &&
130
+ !@config.endpoint.split(".").first.include?("-")
131
+ credentials ||= Credentials.default scope: @config.scope,
132
+ enable_self_signed_jwt: enable_self_signed_jwt
133
+ if credentials.is_a?(::String) || credentials.is_a?(::Hash)
134
+ credentials = Credentials.new credentials, scope: @config.scope
135
+ end
136
+
137
+ @quota_project_id = @config.quota_project
138
+ @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id
139
+
140
+ @operations_client = ::Google::Cloud::Functions::V2::FunctionService::Rest::Operations.new do |config|
141
+ config.credentials = credentials
142
+ config.quota_project = @quota_project_id
143
+ config.endpoint = @config.endpoint
144
+ end
145
+
146
+ @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config|
147
+ config.credentials = credentials
148
+ config.quota_project = @quota_project_id
149
+ config.endpoint = @config.endpoint
150
+ config.bindings_override = @config.bindings_override
151
+ end
152
+
153
+ @iam_policy_client = Google::Iam::V1::IAMPolicy::Rest::Client.new do |config|
154
+ config.credentials = credentials
155
+ config.quota_project = @quota_project_id
156
+ config.endpoint = @config.endpoint
157
+ config.bindings_override = @config.bindings_override
158
+ end
159
+
160
+ @function_service_stub = ::Google::Cloud::Functions::V2::FunctionService::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials
161
+ end
162
+
163
+ ##
164
+ # Get the associated client for long-running operations.
165
+ #
166
+ # @return [::Google::Cloud::Functions::V2::FunctionService::Rest::Operations]
167
+ #
168
+ attr_reader :operations_client
169
+
170
+ ##
171
+ # Get the associated client for mix-in of the Locations.
172
+ #
173
+ # @return [Google::Cloud::Location::Locations::Rest::Client]
174
+ #
175
+ attr_reader :location_client
176
+
177
+ ##
178
+ # Get the associated client for mix-in of the IAMPolicy.
179
+ #
180
+ # @return [Google::Iam::V1::IAMPolicy::Rest::Client]
181
+ #
182
+ attr_reader :iam_policy_client
183
+
184
+ # Service calls
185
+
186
+ ##
187
+ # Returns a function with the given name from the requested project.
188
+ #
189
+ # @overload get_function(request, options = nil)
190
+ # Pass arguments to `get_function` via a request object, either of type
191
+ # {::Google::Cloud::Functions::V2::GetFunctionRequest} or an equivalent Hash.
192
+ #
193
+ # @param request [::Google::Cloud::Functions::V2::GetFunctionRequest, ::Hash]
194
+ # A request object representing the call parameters. Required. To specify no
195
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
196
+ # @param options [::Gapic::CallOptions, ::Hash]
197
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
198
+ #
199
+ # @overload get_function(name: nil)
200
+ # Pass arguments to `get_function` via keyword arguments. Note that at
201
+ # least one keyword argument is required. To specify no parameters, or to keep all
202
+ # the default parameter values, pass an empty Hash as a request object (see above).
203
+ #
204
+ # @param name [::String]
205
+ # Required. The name of the function which details should be obtained.
206
+ # @yield [result, operation] Access the result along with the TransportOperation object
207
+ # @yieldparam result [::Google::Cloud::Functions::V2::Function]
208
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
209
+ #
210
+ # @return [::Google::Cloud::Functions::V2::Function]
211
+ #
212
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
213
+ def get_function request, options = nil
214
+ raise ::ArgumentError, "request must be provided" if request.nil?
215
+
216
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Functions::V2::GetFunctionRequest
217
+
218
+ # Converts hash and nil to an options object
219
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
220
+
221
+ # Customize the options with defaults
222
+ call_metadata = @config.rpcs.get_function.metadata.to_h
223
+
224
+ # Set x-goog-api-client and x-goog-user-project headers
225
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
226
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
227
+ gapic_version: ::Google::Cloud::Functions::V2::VERSION,
228
+ transports_version_send: [:rest]
229
+
230
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
231
+
232
+ options.apply_defaults timeout: @config.rpcs.get_function.timeout,
233
+ metadata: call_metadata,
234
+ retry_policy: @config.rpcs.get_function.retry_policy
235
+
236
+ options.apply_defaults timeout: @config.timeout,
237
+ metadata: @config.metadata,
238
+ retry_policy: @config.retry_policy
239
+
240
+ @function_service_stub.get_function request, options do |result, operation|
241
+ yield result, operation if block_given?
242
+ return result
243
+ end
244
+ rescue ::Gapic::Rest::Error => e
245
+ raise ::Google::Cloud::Error.from_error(e)
246
+ end
247
+
248
+ ##
249
+ # Returns a list of functions that belong to the requested project.
250
+ #
251
+ # @overload list_functions(request, options = nil)
252
+ # Pass arguments to `list_functions` via a request object, either of type
253
+ # {::Google::Cloud::Functions::V2::ListFunctionsRequest} or an equivalent Hash.
254
+ #
255
+ # @param request [::Google::Cloud::Functions::V2::ListFunctionsRequest, ::Hash]
256
+ # A request object representing the call parameters. Required. To specify no
257
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
258
+ # @param options [::Gapic::CallOptions, ::Hash]
259
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
260
+ #
261
+ # @overload list_functions(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil)
262
+ # Pass arguments to `list_functions` via keyword arguments. Note that at
263
+ # least one keyword argument is required. To specify no parameters, or to keep all
264
+ # the default parameter values, pass an empty Hash as a request object (see above).
265
+ #
266
+ # @param parent [::String]
267
+ # Required. The project and location from which the function should be
268
+ # listed, specified in the format `projects/*/locations/*` If you want to
269
+ # list functions in all locations, use "-" in place of a location. When
270
+ # listing functions in all locations, if one or more location(s) are
271
+ # unreachable, the response will contain functions from all reachable
272
+ # locations along with the names of any unreachable locations.
273
+ # @param page_size [::Integer]
274
+ # Maximum number of functions to return per call. The largest allowed
275
+ # page_size is 1,000, if the page_size is omitted or specified as greater
276
+ # than 1,000 then it will be replaced as 1,000. The size of the list
277
+ # response can be less than specified when used with filters.
278
+ # @param page_token [::String]
279
+ # The value returned by the last
280
+ # `ListFunctionsResponse`; indicates that
281
+ # this is a continuation of a prior `ListFunctions` call, and that the
282
+ # system should return the next page of data.
283
+ # @param filter [::String]
284
+ # The filter for Functions that match the filter expression,
285
+ # following the syntax outlined in https://google.aip.dev/160.
286
+ # @param order_by [::String]
287
+ # The sorting order of the resources returned. Value should be a comma
288
+ # separated list of fields. The default sorting oder is ascending.
289
+ # See https://google.aip.dev/132#ordering.
290
+ # @yield [result, operation] Access the result along with the TransportOperation object
291
+ # @yieldparam result [::Google::Cloud::Functions::V2::ListFunctionsResponse]
292
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
293
+ #
294
+ # @return [::Google::Cloud::Functions::V2::ListFunctionsResponse]
295
+ #
296
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
297
+ def list_functions request, options = nil
298
+ raise ::ArgumentError, "request must be provided" if request.nil?
299
+
300
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Functions::V2::ListFunctionsRequest
301
+
302
+ # Converts hash and nil to an options object
303
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
304
+
305
+ # Customize the options with defaults
306
+ call_metadata = @config.rpcs.list_functions.metadata.to_h
307
+
308
+ # Set x-goog-api-client and x-goog-user-project headers
309
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
310
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
311
+ gapic_version: ::Google::Cloud::Functions::V2::VERSION,
312
+ transports_version_send: [:rest]
313
+
314
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
315
+
316
+ options.apply_defaults timeout: @config.rpcs.list_functions.timeout,
317
+ metadata: call_metadata,
318
+ retry_policy: @config.rpcs.list_functions.retry_policy
319
+
320
+ options.apply_defaults timeout: @config.timeout,
321
+ metadata: @config.metadata,
322
+ retry_policy: @config.retry_policy
323
+
324
+ @function_service_stub.list_functions request, options do |result, operation|
325
+ yield result, operation if block_given?
326
+ return result
327
+ end
328
+ rescue ::Gapic::Rest::Error => e
329
+ raise ::Google::Cloud::Error.from_error(e)
330
+ end
331
+
332
+ ##
333
+ # Creates a new function. If a function with the given name already exists in
334
+ # the specified project, the long running operation will return
335
+ # `ALREADY_EXISTS` error.
336
+ #
337
+ # @overload create_function(request, options = nil)
338
+ # Pass arguments to `create_function` via a request object, either of type
339
+ # {::Google::Cloud::Functions::V2::CreateFunctionRequest} or an equivalent Hash.
340
+ #
341
+ # @param request [::Google::Cloud::Functions::V2::CreateFunctionRequest, ::Hash]
342
+ # A request object representing the call parameters. Required. To specify no
343
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
344
+ # @param options [::Gapic::CallOptions, ::Hash]
345
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
346
+ #
347
+ # @overload create_function(parent: nil, function: nil, function_id: nil)
348
+ # Pass arguments to `create_function` via keyword arguments. Note that at
349
+ # least one keyword argument is required. To specify no parameters, or to keep all
350
+ # the default parameter values, pass an empty Hash as a request object (see above).
351
+ #
352
+ # @param parent [::String]
353
+ # Required. The project and location in which the function should be created,
354
+ # specified in the format `projects/*/locations/*`
355
+ # @param function [::Google::Cloud::Functions::V2::Function, ::Hash]
356
+ # Required. Function to be created.
357
+ # @param function_id [::String]
358
+ # The ID to use for the function, which will become the final component of
359
+ # the function's resource name.
360
+ #
361
+ # This value should be 4-63 characters, and valid characters
362
+ # are /[a-z][0-9]-/.
363
+ # @yield [result, operation] Access the result along with the TransportOperation object
364
+ # @yieldparam result [::Gapic::Operation]
365
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
366
+ #
367
+ # @return [::Gapic::Operation]
368
+ #
369
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
370
+ def create_function request, options = nil
371
+ raise ::ArgumentError, "request must be provided" if request.nil?
372
+
373
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Functions::V2::CreateFunctionRequest
374
+
375
+ # Converts hash and nil to an options object
376
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
377
+
378
+ # Customize the options with defaults
379
+ call_metadata = @config.rpcs.create_function.metadata.to_h
380
+
381
+ # Set x-goog-api-client and x-goog-user-project headers
382
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
383
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
384
+ gapic_version: ::Google::Cloud::Functions::V2::VERSION,
385
+ transports_version_send: [:rest]
386
+
387
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
388
+
389
+ options.apply_defaults timeout: @config.rpcs.create_function.timeout,
390
+ metadata: call_metadata,
391
+ retry_policy: @config.rpcs.create_function.retry_policy
392
+
393
+ options.apply_defaults timeout: @config.timeout,
394
+ metadata: @config.metadata,
395
+ retry_policy: @config.retry_policy
396
+
397
+ @function_service_stub.create_function request, options do |result, operation|
398
+ result = ::Gapic::Operation.new result, @operations_client, options: options
399
+ yield result, operation if block_given?
400
+ return result
401
+ end
402
+ rescue ::Gapic::Rest::Error => e
403
+ raise ::Google::Cloud::Error.from_error(e)
404
+ end
405
+
406
+ ##
407
+ # Updates existing function.
408
+ #
409
+ # @overload update_function(request, options = nil)
410
+ # Pass arguments to `update_function` via a request object, either of type
411
+ # {::Google::Cloud::Functions::V2::UpdateFunctionRequest} or an equivalent Hash.
412
+ #
413
+ # @param request [::Google::Cloud::Functions::V2::UpdateFunctionRequest, ::Hash]
414
+ # A request object representing the call parameters. Required. To specify no
415
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
416
+ # @param options [::Gapic::CallOptions, ::Hash]
417
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
418
+ #
419
+ # @overload update_function(function: nil, update_mask: nil)
420
+ # Pass arguments to `update_function` via keyword arguments. Note that at
421
+ # least one keyword argument is required. To specify no parameters, or to keep all
422
+ # the default parameter values, pass an empty Hash as a request object (see above).
423
+ #
424
+ # @param function [::Google::Cloud::Functions::V2::Function, ::Hash]
425
+ # Required. New version of the function.
426
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
427
+ # The list of fields to be updated.
428
+ # If no field mask is provided, all provided fields in the request will be
429
+ # updated.
430
+ # @yield [result, operation] Access the result along with the TransportOperation object
431
+ # @yieldparam result [::Gapic::Operation]
432
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
433
+ #
434
+ # @return [::Gapic::Operation]
435
+ #
436
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
437
+ def update_function request, options = nil
438
+ raise ::ArgumentError, "request must be provided" if request.nil?
439
+
440
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Functions::V2::UpdateFunctionRequest
441
+
442
+ # Converts hash and nil to an options object
443
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
444
+
445
+ # Customize the options with defaults
446
+ call_metadata = @config.rpcs.update_function.metadata.to_h
447
+
448
+ # Set x-goog-api-client and x-goog-user-project headers
449
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
450
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
451
+ gapic_version: ::Google::Cloud::Functions::V2::VERSION,
452
+ transports_version_send: [:rest]
453
+
454
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
455
+
456
+ options.apply_defaults timeout: @config.rpcs.update_function.timeout,
457
+ metadata: call_metadata,
458
+ retry_policy: @config.rpcs.update_function.retry_policy
459
+
460
+ options.apply_defaults timeout: @config.timeout,
461
+ metadata: @config.metadata,
462
+ retry_policy: @config.retry_policy
463
+
464
+ @function_service_stub.update_function request, options do |result, operation|
465
+ result = ::Gapic::Operation.new result, @operations_client, options: options
466
+ yield result, operation if block_given?
467
+ return result
468
+ end
469
+ rescue ::Gapic::Rest::Error => e
470
+ raise ::Google::Cloud::Error.from_error(e)
471
+ end
472
+
473
+ ##
474
+ # Deletes a function with the given name from the specified project. If the
475
+ # given function is used by some trigger, the trigger will be updated to
476
+ # remove this function.
477
+ #
478
+ # @overload delete_function(request, options = nil)
479
+ # Pass arguments to `delete_function` via a request object, either of type
480
+ # {::Google::Cloud::Functions::V2::DeleteFunctionRequest} or an equivalent Hash.
481
+ #
482
+ # @param request [::Google::Cloud::Functions::V2::DeleteFunctionRequest, ::Hash]
483
+ # A request object representing the call parameters. Required. To specify no
484
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
485
+ # @param options [::Gapic::CallOptions, ::Hash]
486
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
487
+ #
488
+ # @overload delete_function(name: nil)
489
+ # Pass arguments to `delete_function` via keyword arguments. Note that at
490
+ # least one keyword argument is required. To specify no parameters, or to keep all
491
+ # the default parameter values, pass an empty Hash as a request object (see above).
492
+ #
493
+ # @param name [::String]
494
+ # Required. The name of the function which should be deleted.
495
+ # @yield [result, operation] Access the result along with the TransportOperation object
496
+ # @yieldparam result [::Gapic::Operation]
497
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
498
+ #
499
+ # @return [::Gapic::Operation]
500
+ #
501
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
502
+ def delete_function request, options = nil
503
+ raise ::ArgumentError, "request must be provided" if request.nil?
504
+
505
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Functions::V2::DeleteFunctionRequest
506
+
507
+ # Converts hash and nil to an options object
508
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
509
+
510
+ # Customize the options with defaults
511
+ call_metadata = @config.rpcs.delete_function.metadata.to_h
512
+
513
+ # Set x-goog-api-client and x-goog-user-project headers
514
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
515
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
516
+ gapic_version: ::Google::Cloud::Functions::V2::VERSION,
517
+ transports_version_send: [:rest]
518
+
519
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
520
+
521
+ options.apply_defaults timeout: @config.rpcs.delete_function.timeout,
522
+ metadata: call_metadata,
523
+ retry_policy: @config.rpcs.delete_function.retry_policy
524
+
525
+ options.apply_defaults timeout: @config.timeout,
526
+ metadata: @config.metadata,
527
+ retry_policy: @config.retry_policy
528
+
529
+ @function_service_stub.delete_function request, options do |result, operation|
530
+ result = ::Gapic::Operation.new result, @operations_client, options: options
531
+ yield result, operation if block_given?
532
+ return result
533
+ end
534
+ rescue ::Gapic::Rest::Error => e
535
+ raise ::Google::Cloud::Error.from_error(e)
536
+ end
537
+
538
+ ##
539
+ # Returns a signed URL for uploading a function source code.
540
+ # For more information about the signed URL usage see:
541
+ # https://cloud.google.com/storage/docs/access-control/signed-urls.
542
+ # Once the function source code upload is complete, the used signed
543
+ # URL should be provided in CreateFunction or UpdateFunction request
544
+ # as a reference to the function source code.
545
+ #
546
+ # When uploading source code to the generated signed URL, please follow
547
+ # these restrictions:
548
+ #
549
+ # * Source file type should be a zip file.
550
+ # * No credentials should be attached - the signed URLs provide access to the
551
+ # target bucket using internal service identity; if credentials were
552
+ # attached, the identity from the credentials would be used, but that
553
+ # identity does not have permissions to upload files to the URL.
554
+ #
555
+ # When making a HTTP PUT request, these two headers need to be specified:
556
+ #
557
+ # * `content-type: application/zip`
558
+ #
559
+ # And this header SHOULD NOT be specified:
560
+ #
561
+ # * `Authorization: Bearer YOUR_TOKEN`
562
+ #
563
+ # @overload generate_upload_url(request, options = nil)
564
+ # Pass arguments to `generate_upload_url` via a request object, either of type
565
+ # {::Google::Cloud::Functions::V2::GenerateUploadUrlRequest} or an equivalent Hash.
566
+ #
567
+ # @param request [::Google::Cloud::Functions::V2::GenerateUploadUrlRequest, ::Hash]
568
+ # A request object representing the call parameters. Required. To specify no
569
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
570
+ # @param options [::Gapic::CallOptions, ::Hash]
571
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
572
+ #
573
+ # @overload generate_upload_url(parent: nil, kms_key_name: nil)
574
+ # Pass arguments to `generate_upload_url` via keyword arguments. Note that at
575
+ # least one keyword argument is required. To specify no parameters, or to keep all
576
+ # the default parameter values, pass an empty Hash as a request object (see above).
577
+ #
578
+ # @param parent [::String]
579
+ # Required. The project and location in which the Google Cloud Storage signed
580
+ # URL should be generated, specified in the format `projects/*/locations/*`.
581
+ # @param kms_key_name [::String]
582
+ # Resource name of a KMS crypto key (managed by the user) used to
583
+ # encrypt/decrypt function source code objects in intermediate Cloud Storage
584
+ # buckets. When you generate an upload url and upload your source code, it
585
+ # gets copied to an intermediate Cloud Storage bucket. The source code is
586
+ # then copied to a versioned directory in the sources bucket in the consumer
587
+ # project during the function deployment.
588
+ #
589
+ # It must match the pattern
590
+ # `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
591
+ #
592
+ # The Google Cloud Functions service account
593
+ # (service-\\{project_number}@gcf-admin-robot.iam.gserviceaccount.com) must be
594
+ # granted the role 'Cloud KMS CryptoKey Encrypter/Decrypter
595
+ # (roles/cloudkms.cryptoKeyEncrypterDecrypter)' on the
596
+ # Key/KeyRing/Project/Organization (least access preferred).
597
+ # @yield [result, operation] Access the result along with the TransportOperation object
598
+ # @yieldparam result [::Google::Cloud::Functions::V2::GenerateUploadUrlResponse]
599
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
600
+ #
601
+ # @return [::Google::Cloud::Functions::V2::GenerateUploadUrlResponse]
602
+ #
603
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
604
+ def generate_upload_url request, options = nil
605
+ raise ::ArgumentError, "request must be provided" if request.nil?
606
+
607
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Functions::V2::GenerateUploadUrlRequest
608
+
609
+ # Converts hash and nil to an options object
610
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
611
+
612
+ # Customize the options with defaults
613
+ call_metadata = @config.rpcs.generate_upload_url.metadata.to_h
614
+
615
+ # Set x-goog-api-client and x-goog-user-project headers
616
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
617
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
618
+ gapic_version: ::Google::Cloud::Functions::V2::VERSION,
619
+ transports_version_send: [:rest]
620
+
621
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
622
+
623
+ options.apply_defaults timeout: @config.rpcs.generate_upload_url.timeout,
624
+ metadata: call_metadata,
625
+ retry_policy: @config.rpcs.generate_upload_url.retry_policy
626
+
627
+ options.apply_defaults timeout: @config.timeout,
628
+ metadata: @config.metadata,
629
+ retry_policy: @config.retry_policy
630
+
631
+ @function_service_stub.generate_upload_url request, options do |result, operation|
632
+ yield result, operation if block_given?
633
+ return result
634
+ end
635
+ rescue ::Gapic::Rest::Error => e
636
+ raise ::Google::Cloud::Error.from_error(e)
637
+ end
638
+
639
+ ##
640
+ # Returns a signed URL for downloading deployed function source code.
641
+ # The URL is only valid for a limited period and should be used within
642
+ # 30 minutes of generation.
643
+ # For more information about the signed URL usage see:
644
+ # https://cloud.google.com/storage/docs/access-control/signed-urls
645
+ #
646
+ # @overload generate_download_url(request, options = nil)
647
+ # Pass arguments to `generate_download_url` via a request object, either of type
648
+ # {::Google::Cloud::Functions::V2::GenerateDownloadUrlRequest} or an equivalent Hash.
649
+ #
650
+ # @param request [::Google::Cloud::Functions::V2::GenerateDownloadUrlRequest, ::Hash]
651
+ # A request object representing the call parameters. Required. To specify no
652
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
653
+ # @param options [::Gapic::CallOptions, ::Hash]
654
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
655
+ #
656
+ # @overload generate_download_url(name: nil)
657
+ # Pass arguments to `generate_download_url` via keyword arguments. Note that at
658
+ # least one keyword argument is required. To specify no parameters, or to keep all
659
+ # the default parameter values, pass an empty Hash as a request object (see above).
660
+ #
661
+ # @param name [::String]
662
+ # Required. The name of function for which source code Google Cloud Storage
663
+ # signed URL should be generated.
664
+ # @yield [result, operation] Access the result along with the TransportOperation object
665
+ # @yieldparam result [::Google::Cloud::Functions::V2::GenerateDownloadUrlResponse]
666
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
667
+ #
668
+ # @return [::Google::Cloud::Functions::V2::GenerateDownloadUrlResponse]
669
+ #
670
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
671
+ def generate_download_url request, options = nil
672
+ raise ::ArgumentError, "request must be provided" if request.nil?
673
+
674
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Functions::V2::GenerateDownloadUrlRequest
675
+
676
+ # Converts hash and nil to an options object
677
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
678
+
679
+ # Customize the options with defaults
680
+ call_metadata = @config.rpcs.generate_download_url.metadata.to_h
681
+
682
+ # Set x-goog-api-client and x-goog-user-project headers
683
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
684
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
685
+ gapic_version: ::Google::Cloud::Functions::V2::VERSION,
686
+ transports_version_send: [:rest]
687
+
688
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
689
+
690
+ options.apply_defaults timeout: @config.rpcs.generate_download_url.timeout,
691
+ metadata: call_metadata,
692
+ retry_policy: @config.rpcs.generate_download_url.retry_policy
693
+
694
+ options.apply_defaults timeout: @config.timeout,
695
+ metadata: @config.metadata,
696
+ retry_policy: @config.retry_policy
697
+
698
+ @function_service_stub.generate_download_url request, options do |result, operation|
699
+ yield result, operation if block_given?
700
+ return result
701
+ end
702
+ rescue ::Gapic::Rest::Error => e
703
+ raise ::Google::Cloud::Error.from_error(e)
704
+ end
705
+
706
+ ##
707
+ # Returns a list of runtimes that are supported for the requested project.
708
+ #
709
+ # @overload list_runtimes(request, options = nil)
710
+ # Pass arguments to `list_runtimes` via a request object, either of type
711
+ # {::Google::Cloud::Functions::V2::ListRuntimesRequest} or an equivalent Hash.
712
+ #
713
+ # @param request [::Google::Cloud::Functions::V2::ListRuntimesRequest, ::Hash]
714
+ # A request object representing the call parameters. Required. To specify no
715
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
716
+ # @param options [::Gapic::CallOptions, ::Hash]
717
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
718
+ #
719
+ # @overload list_runtimes(parent: nil, filter: nil)
720
+ # Pass arguments to `list_runtimes` via keyword arguments. Note that at
721
+ # least one keyword argument is required. To specify no parameters, or to keep all
722
+ # the default parameter values, pass an empty Hash as a request object (see above).
723
+ #
724
+ # @param parent [::String]
725
+ # Required. The project and location from which the runtimes should be
726
+ # listed, specified in the format `projects/*/locations/*`
727
+ # @param filter [::String]
728
+ # The filter for Runtimes that match the filter expression,
729
+ # following the syntax outlined in https://google.aip.dev/160.
730
+ # @yield [result, operation] Access the result along with the TransportOperation object
731
+ # @yieldparam result [::Google::Cloud::Functions::V2::ListRuntimesResponse]
732
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
733
+ #
734
+ # @return [::Google::Cloud::Functions::V2::ListRuntimesResponse]
735
+ #
736
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
737
+ def list_runtimes request, options = nil
738
+ raise ::ArgumentError, "request must be provided" if request.nil?
739
+
740
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Functions::V2::ListRuntimesRequest
741
+
742
+ # Converts hash and nil to an options object
743
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
744
+
745
+ # Customize the options with defaults
746
+ call_metadata = @config.rpcs.list_runtimes.metadata.to_h
747
+
748
+ # Set x-goog-api-client and x-goog-user-project headers
749
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
750
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
751
+ gapic_version: ::Google::Cloud::Functions::V2::VERSION,
752
+ transports_version_send: [:rest]
753
+
754
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
755
+
756
+ options.apply_defaults timeout: @config.rpcs.list_runtimes.timeout,
757
+ metadata: call_metadata,
758
+ retry_policy: @config.rpcs.list_runtimes.retry_policy
759
+
760
+ options.apply_defaults timeout: @config.timeout,
761
+ metadata: @config.metadata,
762
+ retry_policy: @config.retry_policy
763
+
764
+ @function_service_stub.list_runtimes request, options do |result, operation|
765
+ yield result, operation if block_given?
766
+ return result
767
+ end
768
+ rescue ::Gapic::Rest::Error => e
769
+ raise ::Google::Cloud::Error.from_error(e)
770
+ end
771
+
772
+ ##
773
+ # Configuration class for the FunctionService REST API.
774
+ #
775
+ # This class represents the configuration for FunctionService REST,
776
+ # providing control over timeouts, retry behavior, logging, transport
777
+ # parameters, and other low-level controls. Certain parameters can also be
778
+ # applied individually to specific RPCs. See
779
+ # {::Google::Cloud::Functions::V2::FunctionService::Rest::Client::Configuration::Rpcs}
780
+ # for a list of RPCs that can be configured independently.
781
+ #
782
+ # Configuration can be applied globally to all clients, or to a single client
783
+ # on construction.
784
+ #
785
+ # @example
786
+ #
787
+ # # Modify the global config, setting the timeout for
788
+ # # get_function to 20 seconds,
789
+ # # and all remaining timeouts to 10 seconds.
790
+ # ::Google::Cloud::Functions::V2::FunctionService::Rest::Client.configure do |config|
791
+ # config.timeout = 10.0
792
+ # config.rpcs.get_function.timeout = 20.0
793
+ # end
794
+ #
795
+ # # Apply the above configuration only to a new client.
796
+ # client = ::Google::Cloud::Functions::V2::FunctionService::Rest::Client.new do |config|
797
+ # config.timeout = 10.0
798
+ # config.rpcs.get_function.timeout = 20.0
799
+ # end
800
+ #
801
+ # @!attribute [rw] endpoint
802
+ # The hostname or hostname:port of the service endpoint.
803
+ # Defaults to `"cloudfunctions.googleapis.com"`.
804
+ # @return [::String]
805
+ # @!attribute [rw] credentials
806
+ # Credentials to send with calls. You may provide any of the following types:
807
+ # * (`String`) The path to a service account key file in JSON format
808
+ # * (`Hash`) A service account key as a Hash
809
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
810
+ # (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
811
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
812
+ # (see the [signet docs](https://rubydoc.info/gems/signet/Signet/OAuth2/Client))
813
+ # * (`nil`) indicating no credentials
814
+ # @return [::Object]
815
+ # @!attribute [rw] scope
816
+ # The OAuth scopes
817
+ # @return [::Array<::String>]
818
+ # @!attribute [rw] lib_name
819
+ # The library name as recorded in instrumentation and logging
820
+ # @return [::String]
821
+ # @!attribute [rw] lib_version
822
+ # The library version as recorded in instrumentation and logging
823
+ # @return [::String]
824
+ # @!attribute [rw] timeout
825
+ # The call timeout in seconds.
826
+ # @return [::Numeric]
827
+ # @!attribute [rw] metadata
828
+ # Additional headers to be sent with the call.
829
+ # @return [::Hash{::Symbol=>::String}]
830
+ # @!attribute [rw] retry_policy
831
+ # The retry policy. The value is a hash with the following keys:
832
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
833
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
834
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
835
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
836
+ # trigger a retry.
837
+ # @return [::Hash]
838
+ # @!attribute [rw] quota_project
839
+ # A separate project against which to charge quota.
840
+ # @return [::String]
841
+ #
842
+ class Configuration
843
+ extend ::Gapic::Config
844
+
845
+ config_attr :endpoint, "cloudfunctions.googleapis.com", ::String
846
+ config_attr :credentials, nil do |value|
847
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
848
+ allowed.any? { |klass| klass === value }
849
+ end
850
+ config_attr :scope, nil, ::String, ::Array, nil
851
+ config_attr :lib_name, nil, ::String, nil
852
+ config_attr :lib_version, nil, ::String, nil
853
+ config_attr :timeout, nil, ::Numeric, nil
854
+ config_attr :metadata, nil, ::Hash, nil
855
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
856
+ config_attr :quota_project, nil, ::String, nil
857
+
858
+ # @private
859
+ # Overrides for http bindings for the RPCs of this service
860
+ # are only used when this service is used as mixin, and only
861
+ # by the host service.
862
+ # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
863
+ config_attr :bindings_override, {}, ::Hash, nil
864
+
865
+ # @private
866
+ def initialize parent_config = nil
867
+ @parent_config = parent_config unless parent_config.nil?
868
+
869
+ yield self if block_given?
870
+ end
871
+
872
+ ##
873
+ # Configurations for individual RPCs
874
+ # @return [Rpcs]
875
+ #
876
+ def rpcs
877
+ @rpcs ||= begin
878
+ parent_rpcs = nil
879
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
880
+ Rpcs.new parent_rpcs
881
+ end
882
+ end
883
+
884
+ ##
885
+ # Configuration RPC class for the FunctionService API.
886
+ #
887
+ # Includes fields providing the configuration for each RPC in this service.
888
+ # Each configuration object is of type `Gapic::Config::Method` and includes
889
+ # the following configuration fields:
890
+ #
891
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
892
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
893
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
894
+ # include the following keys:
895
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
896
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
897
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
898
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
899
+ # trigger a retry.
900
+ #
901
+ class Rpcs
902
+ ##
903
+ # RPC-specific configuration for `get_function`
904
+ # @return [::Gapic::Config::Method]
905
+ #
906
+ attr_reader :get_function
907
+ ##
908
+ # RPC-specific configuration for `list_functions`
909
+ # @return [::Gapic::Config::Method]
910
+ #
911
+ attr_reader :list_functions
912
+ ##
913
+ # RPC-specific configuration for `create_function`
914
+ # @return [::Gapic::Config::Method]
915
+ #
916
+ attr_reader :create_function
917
+ ##
918
+ # RPC-specific configuration for `update_function`
919
+ # @return [::Gapic::Config::Method]
920
+ #
921
+ attr_reader :update_function
922
+ ##
923
+ # RPC-specific configuration for `delete_function`
924
+ # @return [::Gapic::Config::Method]
925
+ #
926
+ attr_reader :delete_function
927
+ ##
928
+ # RPC-specific configuration for `generate_upload_url`
929
+ # @return [::Gapic::Config::Method]
930
+ #
931
+ attr_reader :generate_upload_url
932
+ ##
933
+ # RPC-specific configuration for `generate_download_url`
934
+ # @return [::Gapic::Config::Method]
935
+ #
936
+ attr_reader :generate_download_url
937
+ ##
938
+ # RPC-specific configuration for `list_runtimes`
939
+ # @return [::Gapic::Config::Method]
940
+ #
941
+ attr_reader :list_runtimes
942
+
943
+ # @private
944
+ def initialize parent_rpcs = nil
945
+ get_function_config = parent_rpcs.get_function if parent_rpcs.respond_to? :get_function
946
+ @get_function = ::Gapic::Config::Method.new get_function_config
947
+ list_functions_config = parent_rpcs.list_functions if parent_rpcs.respond_to? :list_functions
948
+ @list_functions = ::Gapic::Config::Method.new list_functions_config
949
+ create_function_config = parent_rpcs.create_function if parent_rpcs.respond_to? :create_function
950
+ @create_function = ::Gapic::Config::Method.new create_function_config
951
+ update_function_config = parent_rpcs.update_function if parent_rpcs.respond_to? :update_function
952
+ @update_function = ::Gapic::Config::Method.new update_function_config
953
+ delete_function_config = parent_rpcs.delete_function if parent_rpcs.respond_to? :delete_function
954
+ @delete_function = ::Gapic::Config::Method.new delete_function_config
955
+ generate_upload_url_config = parent_rpcs.generate_upload_url if parent_rpcs.respond_to? :generate_upload_url
956
+ @generate_upload_url = ::Gapic::Config::Method.new generate_upload_url_config
957
+ generate_download_url_config = parent_rpcs.generate_download_url if parent_rpcs.respond_to? :generate_download_url
958
+ @generate_download_url = ::Gapic::Config::Method.new generate_download_url_config
959
+ list_runtimes_config = parent_rpcs.list_runtimes if parent_rpcs.respond_to? :list_runtimes
960
+ @list_runtimes = ::Gapic::Config::Method.new list_runtimes_config
961
+
962
+ yield self if block_given?
963
+ end
964
+ end
965
+ end
966
+ end
967
+ end
968
+ end
969
+ end
970
+ end
971
+ end
972
+ end