google-cloud-functions-v2 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,953 @@
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 listed,
268
+ # specified in the format `projects/*/locations/*`
269
+ # If you want to list functions in all locations, use "-" in place of a
270
+ # location. When listing functions in all locations, if one or more
271
+ # location(s) are unreachable, the response will contain functions from all
272
+ # reachable locations along with the names of any unreachable locations.
273
+ # @param page_size [::Integer]
274
+ # Maximum number of functions to return per call.
275
+ # @param page_token [::String]
276
+ # The value returned by the last
277
+ # `ListFunctionsResponse`; indicates that
278
+ # this is a continuation of a prior `ListFunctions` call, and that the
279
+ # system should return the next page of data.
280
+ # @param filter [::String]
281
+ # The filter for Functions that match the filter expression,
282
+ # following the syntax outlined in https://google.aip.dev/160.
283
+ # @param order_by [::String]
284
+ # The sorting order of the resources returned. Value should be a comma
285
+ # separated list of fields. The default sorting oder is ascending.
286
+ # See https://google.aip.dev/132#ordering.
287
+ # @yield [result, operation] Access the result along with the TransportOperation object
288
+ # @yieldparam result [::Google::Cloud::Functions::V2::ListFunctionsResponse]
289
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
290
+ #
291
+ # @return [::Google::Cloud::Functions::V2::ListFunctionsResponse]
292
+ #
293
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
294
+ def list_functions request, options = nil
295
+ raise ::ArgumentError, "request must be provided" if request.nil?
296
+
297
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Functions::V2::ListFunctionsRequest
298
+
299
+ # Converts hash and nil to an options object
300
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
301
+
302
+ # Customize the options with defaults
303
+ call_metadata = @config.rpcs.list_functions.metadata.to_h
304
+
305
+ # Set x-goog-api-client and x-goog-user-project headers
306
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
307
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
308
+ gapic_version: ::Google::Cloud::Functions::V2::VERSION,
309
+ transports_version_send: [:rest]
310
+
311
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
312
+
313
+ options.apply_defaults timeout: @config.rpcs.list_functions.timeout,
314
+ metadata: call_metadata,
315
+ retry_policy: @config.rpcs.list_functions.retry_policy
316
+
317
+ options.apply_defaults timeout: @config.timeout,
318
+ metadata: @config.metadata,
319
+ retry_policy: @config.retry_policy
320
+
321
+ @function_service_stub.list_functions request, options do |result, operation|
322
+ yield result, operation if block_given?
323
+ return result
324
+ end
325
+ rescue ::Gapic::Rest::Error => e
326
+ raise ::Google::Cloud::Error.from_error(e)
327
+ end
328
+
329
+ ##
330
+ # Creates a new function. If a function with the given name already exists in
331
+ # the specified project, the long running operation will return
332
+ # `ALREADY_EXISTS` error.
333
+ #
334
+ # @overload create_function(request, options = nil)
335
+ # Pass arguments to `create_function` via a request object, either of type
336
+ # {::Google::Cloud::Functions::V2::CreateFunctionRequest} or an equivalent Hash.
337
+ #
338
+ # @param request [::Google::Cloud::Functions::V2::CreateFunctionRequest, ::Hash]
339
+ # A request object representing the call parameters. Required. To specify no
340
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
341
+ # @param options [::Gapic::CallOptions, ::Hash]
342
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
343
+ #
344
+ # @overload create_function(parent: nil, function: nil, function_id: nil)
345
+ # Pass arguments to `create_function` via keyword arguments. Note that at
346
+ # least one keyword argument is required. To specify no parameters, or to keep all
347
+ # the default parameter values, pass an empty Hash as a request object (see above).
348
+ #
349
+ # @param parent [::String]
350
+ # Required. The project and location in which the function should be created, specified
351
+ # in the format `projects/*/locations/*`
352
+ # @param function [::Google::Cloud::Functions::V2::Function, ::Hash]
353
+ # Required. Function to be created.
354
+ # @param function_id [::String]
355
+ # The ID to use for the function, which will become the final component of
356
+ # the function's resource name.
357
+ #
358
+ # This value should be 4-63 characters, and valid characters
359
+ # are /[a-z][0-9]-/.
360
+ # @yield [result, operation] Access the result along with the TransportOperation object
361
+ # @yieldparam result [::Gapic::Operation]
362
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
363
+ #
364
+ # @return [::Gapic::Operation]
365
+ #
366
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
367
+ def create_function request, options = nil
368
+ raise ::ArgumentError, "request must be provided" if request.nil?
369
+
370
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Functions::V2::CreateFunctionRequest
371
+
372
+ # Converts hash and nil to an options object
373
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
374
+
375
+ # Customize the options with defaults
376
+ call_metadata = @config.rpcs.create_function.metadata.to_h
377
+
378
+ # Set x-goog-api-client and x-goog-user-project headers
379
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
380
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
381
+ gapic_version: ::Google::Cloud::Functions::V2::VERSION,
382
+ transports_version_send: [:rest]
383
+
384
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
385
+
386
+ options.apply_defaults timeout: @config.rpcs.create_function.timeout,
387
+ metadata: call_metadata,
388
+ retry_policy: @config.rpcs.create_function.retry_policy
389
+
390
+ options.apply_defaults timeout: @config.timeout,
391
+ metadata: @config.metadata,
392
+ retry_policy: @config.retry_policy
393
+
394
+ @function_service_stub.create_function request, options do |result, operation|
395
+ result = ::Gapic::Operation.new result, @operations_client, options: options
396
+ yield result, operation if block_given?
397
+ return result
398
+ end
399
+ rescue ::Gapic::Rest::Error => e
400
+ raise ::Google::Cloud::Error.from_error(e)
401
+ end
402
+
403
+ ##
404
+ # Updates existing function.
405
+ #
406
+ # @overload update_function(request, options = nil)
407
+ # Pass arguments to `update_function` via a request object, either of type
408
+ # {::Google::Cloud::Functions::V2::UpdateFunctionRequest} or an equivalent Hash.
409
+ #
410
+ # @param request [::Google::Cloud::Functions::V2::UpdateFunctionRequest, ::Hash]
411
+ # A request object representing the call parameters. Required. To specify no
412
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
413
+ # @param options [::Gapic::CallOptions, ::Hash]
414
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
415
+ #
416
+ # @overload update_function(function: nil, update_mask: nil)
417
+ # Pass arguments to `update_function` via keyword arguments. Note that at
418
+ # least one keyword argument is required. To specify no parameters, or to keep all
419
+ # the default parameter values, pass an empty Hash as a request object (see above).
420
+ #
421
+ # @param function [::Google::Cloud::Functions::V2::Function, ::Hash]
422
+ # Required. New version of the function.
423
+ # @param update_mask [::Google::Protobuf::FieldMask, ::Hash]
424
+ # The list of fields to be updated.
425
+ # If no field mask is provided, all provided fields in the request will be
426
+ # updated.
427
+ # @yield [result, operation] Access the result along with the TransportOperation object
428
+ # @yieldparam result [::Gapic::Operation]
429
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
430
+ #
431
+ # @return [::Gapic::Operation]
432
+ #
433
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
434
+ def update_function request, options = nil
435
+ raise ::ArgumentError, "request must be provided" if request.nil?
436
+
437
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Functions::V2::UpdateFunctionRequest
438
+
439
+ # Converts hash and nil to an options object
440
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
441
+
442
+ # Customize the options with defaults
443
+ call_metadata = @config.rpcs.update_function.metadata.to_h
444
+
445
+ # Set x-goog-api-client and x-goog-user-project headers
446
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
447
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
448
+ gapic_version: ::Google::Cloud::Functions::V2::VERSION,
449
+ transports_version_send: [:rest]
450
+
451
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
452
+
453
+ options.apply_defaults timeout: @config.rpcs.update_function.timeout,
454
+ metadata: call_metadata,
455
+ retry_policy: @config.rpcs.update_function.retry_policy
456
+
457
+ options.apply_defaults timeout: @config.timeout,
458
+ metadata: @config.metadata,
459
+ retry_policy: @config.retry_policy
460
+
461
+ @function_service_stub.update_function request, options do |result, operation|
462
+ result = ::Gapic::Operation.new result, @operations_client, options: options
463
+ yield result, operation if block_given?
464
+ return result
465
+ end
466
+ rescue ::Gapic::Rest::Error => e
467
+ raise ::Google::Cloud::Error.from_error(e)
468
+ end
469
+
470
+ ##
471
+ # Deletes a function with the given name from the specified project. If the
472
+ # given function is used by some trigger, the trigger will be updated to
473
+ # remove this function.
474
+ #
475
+ # @overload delete_function(request, options = nil)
476
+ # Pass arguments to `delete_function` via a request object, either of type
477
+ # {::Google::Cloud::Functions::V2::DeleteFunctionRequest} or an equivalent Hash.
478
+ #
479
+ # @param request [::Google::Cloud::Functions::V2::DeleteFunctionRequest, ::Hash]
480
+ # A request object representing the call parameters. Required. To specify no
481
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
482
+ # @param options [::Gapic::CallOptions, ::Hash]
483
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
484
+ #
485
+ # @overload delete_function(name: nil)
486
+ # Pass arguments to `delete_function` via keyword arguments. Note that at
487
+ # least one keyword argument is required. To specify no parameters, or to keep all
488
+ # the default parameter values, pass an empty Hash as a request object (see above).
489
+ #
490
+ # @param name [::String]
491
+ # Required. The name of the function which should be deleted.
492
+ # @yield [result, operation] Access the result along with the TransportOperation object
493
+ # @yieldparam result [::Gapic::Operation]
494
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
495
+ #
496
+ # @return [::Gapic::Operation]
497
+ #
498
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
499
+ def delete_function request, options = nil
500
+ raise ::ArgumentError, "request must be provided" if request.nil?
501
+
502
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Functions::V2::DeleteFunctionRequest
503
+
504
+ # Converts hash and nil to an options object
505
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
506
+
507
+ # Customize the options with defaults
508
+ call_metadata = @config.rpcs.delete_function.metadata.to_h
509
+
510
+ # Set x-goog-api-client and x-goog-user-project headers
511
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
512
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
513
+ gapic_version: ::Google::Cloud::Functions::V2::VERSION,
514
+ transports_version_send: [:rest]
515
+
516
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
517
+
518
+ options.apply_defaults timeout: @config.rpcs.delete_function.timeout,
519
+ metadata: call_metadata,
520
+ retry_policy: @config.rpcs.delete_function.retry_policy
521
+
522
+ options.apply_defaults timeout: @config.timeout,
523
+ metadata: @config.metadata,
524
+ retry_policy: @config.retry_policy
525
+
526
+ @function_service_stub.delete_function request, options do |result, operation|
527
+ result = ::Gapic::Operation.new result, @operations_client, options: options
528
+ yield result, operation if block_given?
529
+ return result
530
+ end
531
+ rescue ::Gapic::Rest::Error => e
532
+ raise ::Google::Cloud::Error.from_error(e)
533
+ end
534
+
535
+ ##
536
+ # Returns a signed URL for uploading a function source code.
537
+ # For more information about the signed URL usage see:
538
+ # https://cloud.google.com/storage/docs/access-control/signed-urls.
539
+ # Once the function source code upload is complete, the used signed
540
+ # URL should be provided in CreateFunction or UpdateFunction request
541
+ # as a reference to the function source code.
542
+ #
543
+ # When uploading source code to the generated signed URL, please follow
544
+ # these restrictions:
545
+ #
546
+ # * Source file type should be a zip file.
547
+ # * No credentials should be attached - the signed URLs provide access to the
548
+ # target bucket using internal service identity; if credentials were
549
+ # attached, the identity from the credentials would be used, but that
550
+ # identity does not have permissions to upload files to the URL.
551
+ #
552
+ # When making a HTTP PUT request, these two headers need to be specified:
553
+ #
554
+ # * `content-type: application/zip`
555
+ #
556
+ # And this header SHOULD NOT be specified:
557
+ #
558
+ # * `Authorization: Bearer YOUR_TOKEN`
559
+ #
560
+ # @overload generate_upload_url(request, options = nil)
561
+ # Pass arguments to `generate_upload_url` via a request object, either of type
562
+ # {::Google::Cloud::Functions::V2::GenerateUploadUrlRequest} or an equivalent Hash.
563
+ #
564
+ # @param request [::Google::Cloud::Functions::V2::GenerateUploadUrlRequest, ::Hash]
565
+ # A request object representing the call parameters. Required. To specify no
566
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
567
+ # @param options [::Gapic::CallOptions, ::Hash]
568
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
569
+ #
570
+ # @overload generate_upload_url(parent: nil)
571
+ # Pass arguments to `generate_upload_url` via keyword arguments. Note that at
572
+ # least one keyword argument is required. To specify no parameters, or to keep all
573
+ # the default parameter values, pass an empty Hash as a request object (see above).
574
+ #
575
+ # @param parent [::String]
576
+ # Required. The project and location in which the Google Cloud Storage signed URL
577
+ # should be generated, specified in the format `projects/*/locations/*`.
578
+ # @yield [result, operation] Access the result along with the TransportOperation object
579
+ # @yieldparam result [::Google::Cloud::Functions::V2::GenerateUploadUrlResponse]
580
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
581
+ #
582
+ # @return [::Google::Cloud::Functions::V2::GenerateUploadUrlResponse]
583
+ #
584
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
585
+ def generate_upload_url request, options = nil
586
+ raise ::ArgumentError, "request must be provided" if request.nil?
587
+
588
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Functions::V2::GenerateUploadUrlRequest
589
+
590
+ # Converts hash and nil to an options object
591
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
592
+
593
+ # Customize the options with defaults
594
+ call_metadata = @config.rpcs.generate_upload_url.metadata.to_h
595
+
596
+ # Set x-goog-api-client and x-goog-user-project headers
597
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
598
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
599
+ gapic_version: ::Google::Cloud::Functions::V2::VERSION,
600
+ transports_version_send: [:rest]
601
+
602
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
603
+
604
+ options.apply_defaults timeout: @config.rpcs.generate_upload_url.timeout,
605
+ metadata: call_metadata,
606
+ retry_policy: @config.rpcs.generate_upload_url.retry_policy
607
+
608
+ options.apply_defaults timeout: @config.timeout,
609
+ metadata: @config.metadata,
610
+ retry_policy: @config.retry_policy
611
+
612
+ @function_service_stub.generate_upload_url request, options do |result, operation|
613
+ yield result, operation if block_given?
614
+ return result
615
+ end
616
+ rescue ::Gapic::Rest::Error => e
617
+ raise ::Google::Cloud::Error.from_error(e)
618
+ end
619
+
620
+ ##
621
+ # Returns a signed URL for downloading deployed function source code.
622
+ # The URL is only valid for a limited period and should be used within
623
+ # 30 minutes of generation.
624
+ # For more information about the signed URL usage see:
625
+ # https://cloud.google.com/storage/docs/access-control/signed-urls
626
+ #
627
+ # @overload generate_download_url(request, options = nil)
628
+ # Pass arguments to `generate_download_url` via a request object, either of type
629
+ # {::Google::Cloud::Functions::V2::GenerateDownloadUrlRequest} or an equivalent Hash.
630
+ #
631
+ # @param request [::Google::Cloud::Functions::V2::GenerateDownloadUrlRequest, ::Hash]
632
+ # A request object representing the call parameters. Required. To specify no
633
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
634
+ # @param options [::Gapic::CallOptions, ::Hash]
635
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
636
+ #
637
+ # @overload generate_download_url(name: nil)
638
+ # Pass arguments to `generate_download_url` via keyword arguments. Note that at
639
+ # least one keyword argument is required. To specify no parameters, or to keep all
640
+ # the default parameter values, pass an empty Hash as a request object (see above).
641
+ #
642
+ # @param name [::String]
643
+ # Required. The name of function for which source code Google Cloud Storage signed
644
+ # URL should be generated.
645
+ # @yield [result, operation] Access the result along with the TransportOperation object
646
+ # @yieldparam result [::Google::Cloud::Functions::V2::GenerateDownloadUrlResponse]
647
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
648
+ #
649
+ # @return [::Google::Cloud::Functions::V2::GenerateDownloadUrlResponse]
650
+ #
651
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
652
+ def generate_download_url request, options = nil
653
+ raise ::ArgumentError, "request must be provided" if request.nil?
654
+
655
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Functions::V2::GenerateDownloadUrlRequest
656
+
657
+ # Converts hash and nil to an options object
658
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
659
+
660
+ # Customize the options with defaults
661
+ call_metadata = @config.rpcs.generate_download_url.metadata.to_h
662
+
663
+ # Set x-goog-api-client and x-goog-user-project headers
664
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
665
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
666
+ gapic_version: ::Google::Cloud::Functions::V2::VERSION,
667
+ transports_version_send: [:rest]
668
+
669
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
670
+
671
+ options.apply_defaults timeout: @config.rpcs.generate_download_url.timeout,
672
+ metadata: call_metadata,
673
+ retry_policy: @config.rpcs.generate_download_url.retry_policy
674
+
675
+ options.apply_defaults timeout: @config.timeout,
676
+ metadata: @config.metadata,
677
+ retry_policy: @config.retry_policy
678
+
679
+ @function_service_stub.generate_download_url request, options do |result, operation|
680
+ yield result, operation if block_given?
681
+ return result
682
+ end
683
+ rescue ::Gapic::Rest::Error => e
684
+ raise ::Google::Cloud::Error.from_error(e)
685
+ end
686
+
687
+ ##
688
+ # Returns a list of runtimes that are supported for the requested project.
689
+ #
690
+ # @overload list_runtimes(request, options = nil)
691
+ # Pass arguments to `list_runtimes` via a request object, either of type
692
+ # {::Google::Cloud::Functions::V2::ListRuntimesRequest} or an equivalent Hash.
693
+ #
694
+ # @param request [::Google::Cloud::Functions::V2::ListRuntimesRequest, ::Hash]
695
+ # A request object representing the call parameters. Required. To specify no
696
+ # parameters, or to keep all the default parameter values, pass an empty Hash.
697
+ # @param options [::Gapic::CallOptions, ::Hash]
698
+ # Overrides the default settings for this call, e.g, timeout, retries etc. Optional.
699
+ #
700
+ # @overload list_runtimes(parent: nil, filter: nil)
701
+ # Pass arguments to `list_runtimes` via keyword arguments. Note that at
702
+ # least one keyword argument is required. To specify no parameters, or to keep all
703
+ # the default parameter values, pass an empty Hash as a request object (see above).
704
+ #
705
+ # @param parent [::String]
706
+ # Required. The project and location from which the runtimes should be listed,
707
+ # specified in the format `projects/*/locations/*`
708
+ # @param filter [::String]
709
+ # The filter for Runtimes that match the filter expression,
710
+ # following the syntax outlined in https://google.aip.dev/160.
711
+ # @yield [result, operation] Access the result along with the TransportOperation object
712
+ # @yieldparam result [::Google::Cloud::Functions::V2::ListRuntimesResponse]
713
+ # @yieldparam operation [::Gapic::Rest::TransportOperation]
714
+ #
715
+ # @return [::Google::Cloud::Functions::V2::ListRuntimesResponse]
716
+ #
717
+ # @raise [::Google::Cloud::Error] if the REST call is aborted.
718
+ def list_runtimes request, options = nil
719
+ raise ::ArgumentError, "request must be provided" if request.nil?
720
+
721
+ request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Functions::V2::ListRuntimesRequest
722
+
723
+ # Converts hash and nil to an options object
724
+ options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
725
+
726
+ # Customize the options with defaults
727
+ call_metadata = @config.rpcs.list_runtimes.metadata.to_h
728
+
729
+ # Set x-goog-api-client and x-goog-user-project headers
730
+ call_metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
731
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
732
+ gapic_version: ::Google::Cloud::Functions::V2::VERSION,
733
+ transports_version_send: [:rest]
734
+
735
+ call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
736
+
737
+ options.apply_defaults timeout: @config.rpcs.list_runtimes.timeout,
738
+ metadata: call_metadata,
739
+ retry_policy: @config.rpcs.list_runtimes.retry_policy
740
+
741
+ options.apply_defaults timeout: @config.timeout,
742
+ metadata: @config.metadata,
743
+ retry_policy: @config.retry_policy
744
+
745
+ @function_service_stub.list_runtimes request, options do |result, operation|
746
+ yield result, operation if block_given?
747
+ return result
748
+ end
749
+ rescue ::Gapic::Rest::Error => e
750
+ raise ::Google::Cloud::Error.from_error(e)
751
+ end
752
+
753
+ ##
754
+ # Configuration class for the FunctionService REST API.
755
+ #
756
+ # This class represents the configuration for FunctionService REST,
757
+ # providing control over timeouts, retry behavior, logging, transport
758
+ # parameters, and other low-level controls. Certain parameters can also be
759
+ # applied individually to specific RPCs. See
760
+ # {::Google::Cloud::Functions::V2::FunctionService::Rest::Client::Configuration::Rpcs}
761
+ # for a list of RPCs that can be configured independently.
762
+ #
763
+ # Configuration can be applied globally to all clients, or to a single client
764
+ # on construction.
765
+ #
766
+ # @example
767
+ #
768
+ # # Modify the global config, setting the timeout for
769
+ # # get_function to 20 seconds,
770
+ # # and all remaining timeouts to 10 seconds.
771
+ # ::Google::Cloud::Functions::V2::FunctionService::Rest::Client.configure do |config|
772
+ # config.timeout = 10.0
773
+ # config.rpcs.get_function.timeout = 20.0
774
+ # end
775
+ #
776
+ # # Apply the above configuration only to a new client.
777
+ # client = ::Google::Cloud::Functions::V2::FunctionService::Rest::Client.new do |config|
778
+ # config.timeout = 10.0
779
+ # config.rpcs.get_function.timeout = 20.0
780
+ # end
781
+ #
782
+ # @!attribute [rw] endpoint
783
+ # The hostname or hostname:port of the service endpoint.
784
+ # Defaults to `"cloudfunctions.googleapis.com"`.
785
+ # @return [::String]
786
+ # @!attribute [rw] credentials
787
+ # Credentials to send with calls. You may provide any of the following types:
788
+ # * (`String`) The path to a service account key file in JSON format
789
+ # * (`Hash`) A service account key as a Hash
790
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
791
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
792
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
793
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
794
+ # * (`nil`) indicating no credentials
795
+ # @return [::Object]
796
+ # @!attribute [rw] scope
797
+ # The OAuth scopes
798
+ # @return [::Array<::String>]
799
+ # @!attribute [rw] lib_name
800
+ # The library name as recorded in instrumentation and logging
801
+ # @return [::String]
802
+ # @!attribute [rw] lib_version
803
+ # The library version as recorded in instrumentation and logging
804
+ # @return [::String]
805
+ # @!attribute [rw] timeout
806
+ # The call timeout in seconds.
807
+ # @return [::Numeric]
808
+ # @!attribute [rw] metadata
809
+ # Additional headers to be sent with the call.
810
+ # @return [::Hash{::Symbol=>::String}]
811
+ # @!attribute [rw] retry_policy
812
+ # The retry policy. The value is a hash with the following keys:
813
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
814
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
815
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
816
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
817
+ # trigger a retry.
818
+ # @return [::Hash]
819
+ # @!attribute [rw] quota_project
820
+ # A separate project against which to charge quota.
821
+ # @return [::String]
822
+ #
823
+ class Configuration
824
+ extend ::Gapic::Config
825
+
826
+ config_attr :endpoint, "cloudfunctions.googleapis.com", ::String
827
+ config_attr :credentials, nil do |value|
828
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
829
+ allowed.any? { |klass| klass === value }
830
+ end
831
+ config_attr :scope, nil, ::String, ::Array, nil
832
+ config_attr :lib_name, nil, ::String, nil
833
+ config_attr :lib_version, nil, ::String, nil
834
+ config_attr :timeout, nil, ::Numeric, nil
835
+ config_attr :metadata, nil, ::Hash, nil
836
+ config_attr :retry_policy, nil, ::Hash, ::Proc, nil
837
+ config_attr :quota_project, nil, ::String, nil
838
+
839
+ # @private
840
+ # Overrides for http bindings for the RPCs of this service
841
+ # are only used when this service is used as mixin, and only
842
+ # by the host service.
843
+ # @return [::Hash{::Symbol=>::Array<::Gapic::Rest::GrpcTranscoder::HttpBinding>}]
844
+ config_attr :bindings_override, {}, ::Hash, nil
845
+
846
+ # @private
847
+ def initialize parent_config = nil
848
+ @parent_config = parent_config unless parent_config.nil?
849
+
850
+ yield self if block_given?
851
+ end
852
+
853
+ ##
854
+ # Configurations for individual RPCs
855
+ # @return [Rpcs]
856
+ #
857
+ def rpcs
858
+ @rpcs ||= begin
859
+ parent_rpcs = nil
860
+ parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs)
861
+ Rpcs.new parent_rpcs
862
+ end
863
+ end
864
+
865
+ ##
866
+ # Configuration RPC class for the FunctionService API.
867
+ #
868
+ # Includes fields providing the configuration for each RPC in this service.
869
+ # Each configuration object is of type `Gapic::Config::Method` and includes
870
+ # the following configuration fields:
871
+ #
872
+ # * `timeout` (*type:* `Numeric`) - The call timeout in seconds
873
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers
874
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
875
+ # include the following keys:
876
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
877
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
878
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
879
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
880
+ # trigger a retry.
881
+ #
882
+ class Rpcs
883
+ ##
884
+ # RPC-specific configuration for `get_function`
885
+ # @return [::Gapic::Config::Method]
886
+ #
887
+ attr_reader :get_function
888
+ ##
889
+ # RPC-specific configuration for `list_functions`
890
+ # @return [::Gapic::Config::Method]
891
+ #
892
+ attr_reader :list_functions
893
+ ##
894
+ # RPC-specific configuration for `create_function`
895
+ # @return [::Gapic::Config::Method]
896
+ #
897
+ attr_reader :create_function
898
+ ##
899
+ # RPC-specific configuration for `update_function`
900
+ # @return [::Gapic::Config::Method]
901
+ #
902
+ attr_reader :update_function
903
+ ##
904
+ # RPC-specific configuration for `delete_function`
905
+ # @return [::Gapic::Config::Method]
906
+ #
907
+ attr_reader :delete_function
908
+ ##
909
+ # RPC-specific configuration for `generate_upload_url`
910
+ # @return [::Gapic::Config::Method]
911
+ #
912
+ attr_reader :generate_upload_url
913
+ ##
914
+ # RPC-specific configuration for `generate_download_url`
915
+ # @return [::Gapic::Config::Method]
916
+ #
917
+ attr_reader :generate_download_url
918
+ ##
919
+ # RPC-specific configuration for `list_runtimes`
920
+ # @return [::Gapic::Config::Method]
921
+ #
922
+ attr_reader :list_runtimes
923
+
924
+ # @private
925
+ def initialize parent_rpcs = nil
926
+ get_function_config = parent_rpcs.get_function if parent_rpcs.respond_to? :get_function
927
+ @get_function = ::Gapic::Config::Method.new get_function_config
928
+ list_functions_config = parent_rpcs.list_functions if parent_rpcs.respond_to? :list_functions
929
+ @list_functions = ::Gapic::Config::Method.new list_functions_config
930
+ create_function_config = parent_rpcs.create_function if parent_rpcs.respond_to? :create_function
931
+ @create_function = ::Gapic::Config::Method.new create_function_config
932
+ update_function_config = parent_rpcs.update_function if parent_rpcs.respond_to? :update_function
933
+ @update_function = ::Gapic::Config::Method.new update_function_config
934
+ delete_function_config = parent_rpcs.delete_function if parent_rpcs.respond_to? :delete_function
935
+ @delete_function = ::Gapic::Config::Method.new delete_function_config
936
+ generate_upload_url_config = parent_rpcs.generate_upload_url if parent_rpcs.respond_to? :generate_upload_url
937
+ @generate_upload_url = ::Gapic::Config::Method.new generate_upload_url_config
938
+ generate_download_url_config = parent_rpcs.generate_download_url if parent_rpcs.respond_to? :generate_download_url
939
+ @generate_download_url = ::Gapic::Config::Method.new generate_download_url_config
940
+ list_runtimes_config = parent_rpcs.list_runtimes if parent_rpcs.respond_to? :list_runtimes
941
+ @list_runtimes = ::Gapic::Config::Method.new list_runtimes_config
942
+
943
+ yield self if block_given?
944
+ end
945
+ end
946
+ end
947
+ end
948
+ end
949
+ end
950
+ end
951
+ end
952
+ end
953
+ end