google-cloud-access_approval-v1 0.1.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,868 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2020 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "gapic/common"
20
+ require "gapic/config"
21
+ require "gapic/config/method"
22
+
23
+ require "google/cloud/errors"
24
+ require "google/cloud/access_approval/v1/version"
25
+ require "google/cloud/accessapproval/v1/accessapproval_pb"
26
+ require "google/cloud/access_approval/v1/access_approval/credentials"
27
+
28
+ module Google
29
+ module Cloud
30
+ module AccessApproval
31
+ module V1
32
+ module AccessApproval
33
+ ##
34
+ # Client for the AccessApproval service.
35
+ #
36
+ # This API allows a customer to manage accesses to cloud resources by
37
+ # Google personnel. It defines the following resource model:
38
+ #
39
+ # - The API has a collection of
40
+ # {Google::Cloud::AccessApproval::V1::ApprovalRequest ApprovalRequest}
41
+ # resources, named `approvalRequests/{approval_request_id}`
42
+ # - The API has top-level settings per Project/Folder/Organization, named
43
+ # `accessApprovalSettings`
44
+ #
45
+ # The service also periodically emails a list of recipients, defined at the
46
+ # Project/Folder/Organization level in the accessApprovalSettings, when there
47
+ # is a pending ApprovalRequest for them to act on. The ApprovalRequests can
48
+ # also optionally be published to a Cloud Pub/Sub topic owned by the customer
49
+ # (for Beta, the Pub/Sub setup is managed manually).
50
+ #
51
+ # ApprovalRequests can be approved or dismissed. Google personel can only
52
+ # access the indicated resource or resources if the request is approved
53
+ # (subject to some exclusions:
54
+ # https://cloud.google.com/access-approval/docs/overview#exclusions).
55
+ #
56
+ # Note: Using Access Approval functionality will mean that Google may not be
57
+ # able to meet the SLAs for your chosen products, as any support response times
58
+ # may be dramatically increased. As such the SLAs do not apply to any service
59
+ # disruption to the extent impacted by Customer's use of Access Approval. Do
60
+ # not enable Access Approval for projects where you may require high service
61
+ # availability and rapid response by Google Cloud Support.
62
+ #
63
+ # After a request is approved or dismissed, no further action may be taken on
64
+ # it. Requests with the requested_expiration in the past or with no activity
65
+ # for 14 days are considered dismissed. When an approval expires, the request
66
+ # is considered dismissed.
67
+ #
68
+ # If a request is not approved or dismissed, we call it pending.
69
+ #
70
+ class Client
71
+ # @private
72
+ attr_reader :access_approval_stub
73
+
74
+ ##
75
+ # Configure the AccessApproval Client class.
76
+ #
77
+ # See {Google::Cloud::AccessApproval::V1::AccessApproval::Client::Configuration}
78
+ # for a description of the configuration fields.
79
+ #
80
+ # ## Example
81
+ #
82
+ # To modify the configuration for all AccessApproval clients:
83
+ #
84
+ # Google::Cloud::AccessApproval::V1::AccessApproval::Client.configure do |config|
85
+ # config.timeout = 10_000
86
+ # end
87
+ #
88
+ # @yield [config] Configure the Client client.
89
+ # @yieldparam config [Client::Configuration]
90
+ #
91
+ # @return [Client::Configuration]
92
+ #
93
+ def self.configure
94
+ @configure ||= begin
95
+ namespace = ["Google", "Cloud", "AccessApproval", "V1"]
96
+ parent_config = while namespace.any?
97
+ parent_name = namespace.join "::"
98
+ parent_const = const_get parent_name
99
+ break parent_const.configure if parent_const&.respond_to? :configure
100
+ namespace.pop
101
+ end
102
+ default_config = Client::Configuration.new parent_config
103
+
104
+ default_config
105
+ end
106
+ yield @configure if block_given?
107
+ @configure
108
+ end
109
+
110
+ ##
111
+ # Configure the AccessApproval Client instance.
112
+ #
113
+ # The configuration is set to the derived mode, meaning that values can be changed,
114
+ # but structural changes (adding new fields, etc.) are not allowed. Structural changes
115
+ # should be made on {Client.configure}.
116
+ #
117
+ # See {Google::Cloud::AccessApproval::V1::AccessApproval::Client::Configuration}
118
+ # for a description of the configuration fields.
119
+ #
120
+ # @yield [config] Configure the Client client.
121
+ # @yieldparam config [Client::Configuration]
122
+ #
123
+ # @return [Client::Configuration]
124
+ #
125
+ def configure
126
+ yield @config if block_given?
127
+ @config
128
+ end
129
+
130
+ ##
131
+ # Create a new AccessApproval client object.
132
+ #
133
+ # ## Examples
134
+ #
135
+ # To create a new AccessApproval client with the default
136
+ # configuration:
137
+ #
138
+ # client = Google::Cloud::AccessApproval::V1::AccessApproval::Client.new
139
+ #
140
+ # To create a new AccessApproval client with a custom
141
+ # configuration:
142
+ #
143
+ # client = Google::Cloud::AccessApproval::V1::AccessApproval::Client.new do |config|
144
+ # config.timeout = 10_000
145
+ # end
146
+ #
147
+ # @yield [config] Configure the AccessApproval client.
148
+ # @yieldparam config [Client::Configuration]
149
+ #
150
+ def initialize
151
+ # These require statements are intentionally placed here to initialize
152
+ # the gRPC module only when it's required.
153
+ # See https://github.com/googleapis/toolkit/issues/446
154
+ require "gapic/grpc"
155
+ require "google/cloud/accessapproval/v1/accessapproval_services_pb"
156
+
157
+ # Create the configuration object
158
+ @config = Configuration.new Client.configure
159
+
160
+ # Yield the configuration if needed
161
+ yield @config if block_given?
162
+
163
+ # Create credentials
164
+ credentials = @config.credentials
165
+ credentials ||= Credentials.default scope: @config.scope
166
+ if credentials.is_a?(String) || credentials.is_a?(Hash)
167
+ credentials = Credentials.new credentials, scope: @config.scope
168
+ end
169
+ @quota_project_id = credentials.respond_to?(:quota_project_id) ? credentials.quota_project_id : nil
170
+
171
+ @access_approval_stub = Gapic::ServiceStub.new(
172
+ Google::Cloud::AccessApproval::V1::AccessApproval::Stub,
173
+ credentials: credentials,
174
+ endpoint: @config.endpoint,
175
+ channel_args: @config.channel_args,
176
+ interceptors: @config.interceptors
177
+ )
178
+ end
179
+
180
+ # Service calls
181
+
182
+ ##
183
+ # Lists approval requests associated with a project, folder, or organization.
184
+ # Approval requests can be filtered by state (pending, active, dismissed).
185
+ # The order is reverse chronological.
186
+ #
187
+ # @overload list_approval_requests(request, options = nil)
188
+ # @param request [Google::Cloud::AccessApproval::V1::ListApprovalRequestsMessage | Hash]
189
+ # Lists approval requests associated with a project, folder, or organization.
190
+ # Approval requests can be filtered by state (pending, active, dismissed).
191
+ # The order is reverse chronological.
192
+ # @param options [Gapic::CallOptions, Hash]
193
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
194
+ #
195
+ # @overload list_approval_requests(parent: nil, filter: nil, page_size: nil, page_token: nil)
196
+ # @param parent [String]
197
+ # The parent resource. This may be "projects/\\{project_id}",
198
+ # "folders/\\{folder_id}", or "organizations/\\{organization_id}".
199
+ # @param filter [String]
200
+ # A filter on the type of approval requests to retrieve. Must be one of the
201
+ # following values:
202
+ # <ol>
203
+ # <li>[not set]: Requests that are pending or have active approvals.</li>
204
+ # <li>ALL: All requests.</li>
205
+ # <li>PENDING: Only pending requests.</li>
206
+ # <li>ACTIVE: Only active (i.e. currently approved) requests.</li>
207
+ # <li>DISMISSED: Only dismissed (including expired) requests.</li>
208
+ # </ol>
209
+ # @param page_size [Integer]
210
+ # Requested page size.
211
+ # @param page_token [String]
212
+ # A token identifying the page of results to return.
213
+ #
214
+ #
215
+ # @yield [response, operation] Access the result along with the RPC operation
216
+ # @yieldparam response [Gapic::PagedEnumerable<Google::Cloud::AccessApproval::V1::ApprovalRequest>]
217
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
218
+ #
219
+ # @return [Gapic::PagedEnumerable<Google::Cloud::AccessApproval::V1::ApprovalRequest>]
220
+ #
221
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
222
+ #
223
+ def list_approval_requests request, options = nil
224
+ raise ArgumentError, "request must be provided" if request.nil?
225
+
226
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::AccessApproval::V1::ListApprovalRequestsMessage
227
+
228
+ # Converts hash and nil to an options object
229
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
230
+
231
+ # Customize the options with defaults
232
+ metadata = @config.rpcs.list_approval_requests.metadata.to_h
233
+
234
+ # Set x-goog-api-client and x-goog-user-project headers
235
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
236
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
237
+ gapic_version: ::Google::Cloud::AccessApproval::V1::VERSION
238
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
239
+
240
+ header_params = {
241
+ "parent" => request.parent
242
+ }
243
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
244
+ metadata[:"x-goog-request-params"] ||= request_params_header
245
+
246
+ options.apply_defaults timeout: @config.rpcs.list_approval_requests.timeout,
247
+ metadata: metadata,
248
+ retry_policy: @config.rpcs.list_approval_requests.retry_policy
249
+ options.apply_defaults metadata: @config.metadata,
250
+ retry_policy: @config.retry_policy
251
+
252
+ @access_approval_stub.call_rpc :list_approval_requests, request, options: options do |response, operation|
253
+ response = Gapic::PagedEnumerable.new @access_approval_stub, :list_approval_requests, request, response, operation, options
254
+ yield response, operation if block_given?
255
+ return response
256
+ end
257
+ rescue GRPC::BadStatus => e
258
+ raise Google::Cloud::Error.from_error(e)
259
+ end
260
+
261
+ ##
262
+ # Gets an approval request. Returns NOT_FOUND if the request does not exist.
263
+ #
264
+ # @overload get_approval_request(request, options = nil)
265
+ # @param request [Google::Cloud::AccessApproval::V1::GetApprovalRequestMessage | Hash]
266
+ # Gets an approval request. Returns NOT_FOUND if the request does not exist.
267
+ # @param options [Gapic::CallOptions, Hash]
268
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
269
+ #
270
+ # @overload get_approval_request(name: nil)
271
+ # @param name [String]
272
+ # Name of the approval request to retrieve.
273
+ #
274
+ #
275
+ # @yield [response, operation] Access the result along with the RPC operation
276
+ # @yieldparam response [Google::Cloud::AccessApproval::V1::ApprovalRequest]
277
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
278
+ #
279
+ # @return [Google::Cloud::AccessApproval::V1::ApprovalRequest]
280
+ #
281
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
282
+ #
283
+ def get_approval_request request, options = nil
284
+ raise ArgumentError, "request must be provided" if request.nil?
285
+
286
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::AccessApproval::V1::GetApprovalRequestMessage
287
+
288
+ # Converts hash and nil to an options object
289
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
290
+
291
+ # Customize the options with defaults
292
+ metadata = @config.rpcs.get_approval_request.metadata.to_h
293
+
294
+ # Set x-goog-api-client and x-goog-user-project headers
295
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
296
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
297
+ gapic_version: ::Google::Cloud::AccessApproval::V1::VERSION
298
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
299
+
300
+ header_params = {
301
+ "name" => request.name
302
+ }
303
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
304
+ metadata[:"x-goog-request-params"] ||= request_params_header
305
+
306
+ options.apply_defaults timeout: @config.rpcs.get_approval_request.timeout,
307
+ metadata: metadata,
308
+ retry_policy: @config.rpcs.get_approval_request.retry_policy
309
+ options.apply_defaults metadata: @config.metadata,
310
+ retry_policy: @config.retry_policy
311
+
312
+ @access_approval_stub.call_rpc :get_approval_request, request, options: options do |response, operation|
313
+ yield response, operation if block_given?
314
+ return response
315
+ end
316
+ rescue GRPC::BadStatus => e
317
+ raise Google::Cloud::Error.from_error(e)
318
+ end
319
+
320
+ ##
321
+ # Approves a request and returns the updated ApprovalRequest.
322
+ #
323
+ # Returns NOT_FOUND if the request does not exist. Returns
324
+ # FAILED_PRECONDITION if the request exists but is not in a pending state.
325
+ #
326
+ # @overload approve_approval_request(request, options = nil)
327
+ # @param request [Google::Cloud::AccessApproval::V1::ApproveApprovalRequestMessage | Hash]
328
+ # Approves a request and returns the updated ApprovalRequest.
329
+ #
330
+ # Returns NOT_FOUND if the request does not exist. Returns
331
+ # FAILED_PRECONDITION if the request exists but is not in a pending state.
332
+ # @param options [Gapic::CallOptions, Hash]
333
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
334
+ #
335
+ # @overload approve_approval_request(name: nil, expire_time: nil)
336
+ # @param name [String]
337
+ # Name of the approval request to approve.
338
+ # @param expire_time [Google::Protobuf::Timestamp | Hash]
339
+ # The expiration time of this approval.
340
+ #
341
+ #
342
+ # @yield [response, operation] Access the result along with the RPC operation
343
+ # @yieldparam response [Google::Cloud::AccessApproval::V1::ApprovalRequest]
344
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
345
+ #
346
+ # @return [Google::Cloud::AccessApproval::V1::ApprovalRequest]
347
+ #
348
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
349
+ #
350
+ def approve_approval_request request, options = nil
351
+ raise ArgumentError, "request must be provided" if request.nil?
352
+
353
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::AccessApproval::V1::ApproveApprovalRequestMessage
354
+
355
+ # Converts hash and nil to an options object
356
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
357
+
358
+ # Customize the options with defaults
359
+ metadata = @config.rpcs.approve_approval_request.metadata.to_h
360
+
361
+ # Set x-goog-api-client and x-goog-user-project headers
362
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
363
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
364
+ gapic_version: ::Google::Cloud::AccessApproval::V1::VERSION
365
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
366
+
367
+ header_params = {
368
+ "name" => request.name
369
+ }
370
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
371
+ metadata[:"x-goog-request-params"] ||= request_params_header
372
+
373
+ options.apply_defaults timeout: @config.rpcs.approve_approval_request.timeout,
374
+ metadata: metadata,
375
+ retry_policy: @config.rpcs.approve_approval_request.retry_policy
376
+ options.apply_defaults metadata: @config.metadata,
377
+ retry_policy: @config.retry_policy
378
+
379
+ @access_approval_stub.call_rpc :approve_approval_request, request, options: options do |response, operation|
380
+ yield response, operation if block_given?
381
+ return response
382
+ end
383
+ rescue GRPC::BadStatus => e
384
+ raise Google::Cloud::Error.from_error(e)
385
+ end
386
+
387
+ ##
388
+ # Dismisses a request. Returns the updated ApprovalRequest.
389
+ #
390
+ # NOTE: This does not deny access to the resource if another request has been
391
+ # made and approved. It is equivalent in effect to ignoring the request
392
+ # altogether.
393
+ #
394
+ # Returns NOT_FOUND if the request does not exist.
395
+ #
396
+ # Returns FAILED_PRECONDITION if the request exists but is not in a pending
397
+ # state.
398
+ #
399
+ # @overload dismiss_approval_request(request, options = nil)
400
+ # @param request [Google::Cloud::AccessApproval::V1::DismissApprovalRequestMessage | Hash]
401
+ # Dismisses a request. Returns the updated ApprovalRequest.
402
+ #
403
+ # NOTE: This does not deny access to the resource if another request has been
404
+ # made and approved. It is equivalent in effect to ignoring the request
405
+ # altogether.
406
+ #
407
+ # Returns NOT_FOUND if the request does not exist.
408
+ #
409
+ # Returns FAILED_PRECONDITION if the request exists but is not in a pending
410
+ # state.
411
+ # @param options [Gapic::CallOptions, Hash]
412
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
413
+ #
414
+ # @overload dismiss_approval_request(name: nil)
415
+ # @param name [String]
416
+ # Name of the ApprovalRequest to dismiss.
417
+ #
418
+ #
419
+ # @yield [response, operation] Access the result along with the RPC operation
420
+ # @yieldparam response [Google::Cloud::AccessApproval::V1::ApprovalRequest]
421
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
422
+ #
423
+ # @return [Google::Cloud::AccessApproval::V1::ApprovalRequest]
424
+ #
425
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
426
+ #
427
+ def dismiss_approval_request request, options = nil
428
+ raise ArgumentError, "request must be provided" if request.nil?
429
+
430
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::AccessApproval::V1::DismissApprovalRequestMessage
431
+
432
+ # Converts hash and nil to an options object
433
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
434
+
435
+ # Customize the options with defaults
436
+ metadata = @config.rpcs.dismiss_approval_request.metadata.to_h
437
+
438
+ # Set x-goog-api-client and x-goog-user-project headers
439
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
440
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
441
+ gapic_version: ::Google::Cloud::AccessApproval::V1::VERSION
442
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
443
+
444
+ header_params = {
445
+ "name" => request.name
446
+ }
447
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
448
+ metadata[:"x-goog-request-params"] ||= request_params_header
449
+
450
+ options.apply_defaults timeout: @config.rpcs.dismiss_approval_request.timeout,
451
+ metadata: metadata,
452
+ retry_policy: @config.rpcs.dismiss_approval_request.retry_policy
453
+ options.apply_defaults metadata: @config.metadata,
454
+ retry_policy: @config.retry_policy
455
+
456
+ @access_approval_stub.call_rpc :dismiss_approval_request, request, options: options do |response, operation|
457
+ yield response, operation if block_given?
458
+ return response
459
+ end
460
+ rescue GRPC::BadStatus => e
461
+ raise Google::Cloud::Error.from_error(e)
462
+ end
463
+
464
+ ##
465
+ # Gets the settings associated with a project, folder, or organization.
466
+ #
467
+ # @overload get_access_approval_settings(request, options = nil)
468
+ # @param request [Google::Cloud::AccessApproval::V1::GetAccessApprovalSettingsMessage | Hash]
469
+ # Gets the settings associated with a project, folder, or organization.
470
+ # @param options [Gapic::CallOptions, Hash]
471
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
472
+ #
473
+ # @overload get_access_approval_settings(name: nil)
474
+ # @param name [String]
475
+ # Name of the AccessApprovalSettings to retrieve.
476
+ #
477
+ #
478
+ # @yield [response, operation] Access the result along with the RPC operation
479
+ # @yieldparam response [Google::Cloud::AccessApproval::V1::AccessApprovalSettings]
480
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
481
+ #
482
+ # @return [Google::Cloud::AccessApproval::V1::AccessApprovalSettings]
483
+ #
484
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
485
+ #
486
+ def get_access_approval_settings request, options = nil
487
+ raise ArgumentError, "request must be provided" if request.nil?
488
+
489
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::AccessApproval::V1::GetAccessApprovalSettingsMessage
490
+
491
+ # Converts hash and nil to an options object
492
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
493
+
494
+ # Customize the options with defaults
495
+ metadata = @config.rpcs.get_access_approval_settings.metadata.to_h
496
+
497
+ # Set x-goog-api-client and x-goog-user-project headers
498
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
499
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
500
+ gapic_version: ::Google::Cloud::AccessApproval::V1::VERSION
501
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
502
+
503
+ header_params = {
504
+ "name" => request.name
505
+ }
506
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
507
+ metadata[:"x-goog-request-params"] ||= request_params_header
508
+
509
+ options.apply_defaults timeout: @config.rpcs.get_access_approval_settings.timeout,
510
+ metadata: metadata,
511
+ retry_policy: @config.rpcs.get_access_approval_settings.retry_policy
512
+ options.apply_defaults metadata: @config.metadata,
513
+ retry_policy: @config.retry_policy
514
+
515
+ @access_approval_stub.call_rpc :get_access_approval_settings, request, options: options do |response, operation|
516
+ yield response, operation if block_given?
517
+ return response
518
+ end
519
+ rescue GRPC::BadStatus => e
520
+ raise Google::Cloud::Error.from_error(e)
521
+ end
522
+
523
+ ##
524
+ # Updates the settings associated with a project, folder, or organization.
525
+ # Settings to update are determined by the value of field_mask.
526
+ #
527
+ # @overload update_access_approval_settings(request, options = nil)
528
+ # @param request [Google::Cloud::AccessApproval::V1::UpdateAccessApprovalSettingsMessage | Hash]
529
+ # Updates the settings associated with a project, folder, or organization.
530
+ # Settings to update are determined by the value of field_mask.
531
+ # @param options [Gapic::CallOptions, Hash]
532
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
533
+ #
534
+ # @overload update_access_approval_settings(settings: nil, update_mask: nil)
535
+ # @param settings [Google::Cloud::AccessApproval::V1::AccessApprovalSettings | Hash]
536
+ # The new AccessApprovalSettings.
537
+ # @param update_mask [Google::Protobuf::FieldMask | Hash]
538
+ # The update mask applies to the settings. Only the top level fields of
539
+ # AccessApprovalSettings (notification_emails & enrolled_services) are
540
+ # supported. For each field, if it is included, the currently stored value
541
+ # will be entirely overwritten with the value of the field passed in this
542
+ # request.
543
+ #
544
+ # For the `FieldMask` definition, see
545
+ # https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask
546
+ # If this field is left unset, only the notification_emails field will be
547
+ # updated.
548
+ #
549
+ #
550
+ # @yield [response, operation] Access the result along with the RPC operation
551
+ # @yieldparam response [Google::Cloud::AccessApproval::V1::AccessApprovalSettings]
552
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
553
+ #
554
+ # @return [Google::Cloud::AccessApproval::V1::AccessApprovalSettings]
555
+ #
556
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
557
+ #
558
+ def update_access_approval_settings request, options = nil
559
+ raise ArgumentError, "request must be provided" if request.nil?
560
+
561
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::AccessApproval::V1::UpdateAccessApprovalSettingsMessage
562
+
563
+ # Converts hash and nil to an options object
564
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
565
+
566
+ # Customize the options with defaults
567
+ metadata = @config.rpcs.update_access_approval_settings.metadata.to_h
568
+
569
+ # Set x-goog-api-client and x-goog-user-project headers
570
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
571
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
572
+ gapic_version: ::Google::Cloud::AccessApproval::V1::VERSION
573
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
574
+
575
+ header_params = {
576
+ "settings.name" => request.settings.name
577
+ }
578
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
579
+ metadata[:"x-goog-request-params"] ||= request_params_header
580
+
581
+ options.apply_defaults timeout: @config.rpcs.update_access_approval_settings.timeout,
582
+ metadata: metadata,
583
+ retry_policy: @config.rpcs.update_access_approval_settings.retry_policy
584
+ options.apply_defaults metadata: @config.metadata,
585
+ retry_policy: @config.retry_policy
586
+
587
+ @access_approval_stub.call_rpc :update_access_approval_settings, request, options: options do |response, operation|
588
+ yield response, operation if block_given?
589
+ return response
590
+ end
591
+ rescue GRPC::BadStatus => e
592
+ raise Google::Cloud::Error.from_error(e)
593
+ end
594
+
595
+ ##
596
+ # Deletes the settings associated with a project, folder, or organization.
597
+ # This will have the effect of disabling Access Approval for the project,
598
+ # folder, or organization, but only if all ancestors also have Access
599
+ # Approval disabled. If Access Approval is enabled at a higher level of the
600
+ # hierarchy, then Access Approval will still be enabled at this level as
601
+ # the settings are inherited.
602
+ #
603
+ # @overload delete_access_approval_settings(request, options = nil)
604
+ # @param request [Google::Cloud::AccessApproval::V1::DeleteAccessApprovalSettingsMessage | Hash]
605
+ # Deletes the settings associated with a project, folder, or organization.
606
+ # This will have the effect of disabling Access Approval for the project,
607
+ # folder, or organization, but only if all ancestors also have Access
608
+ # Approval disabled. If Access Approval is enabled at a higher level of the
609
+ # hierarchy, then Access Approval will still be enabled at this level as
610
+ # the settings are inherited.
611
+ # @param options [Gapic::CallOptions, Hash]
612
+ # Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
613
+ #
614
+ # @overload delete_access_approval_settings(name: nil)
615
+ # @param name [String]
616
+ # Name of the AccessApprovalSettings to delete.
617
+ #
618
+ #
619
+ # @yield [response, operation] Access the result along with the RPC operation
620
+ # @yieldparam response [Google::Protobuf::Empty]
621
+ # @yieldparam operation [GRPC::ActiveCall::Operation]
622
+ #
623
+ # @return [Google::Protobuf::Empty]
624
+ #
625
+ # @raise [Google::Cloud::Error] if the RPC is aborted.
626
+ #
627
+ def delete_access_approval_settings request, options = nil
628
+ raise ArgumentError, "request must be provided" if request.nil?
629
+
630
+ request = Gapic::Protobuf.coerce request, to: Google::Cloud::AccessApproval::V1::DeleteAccessApprovalSettingsMessage
631
+
632
+ # Converts hash and nil to an options object
633
+ options = Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h
634
+
635
+ # Customize the options with defaults
636
+ metadata = @config.rpcs.delete_access_approval_settings.metadata.to_h
637
+
638
+ # Set x-goog-api-client and x-goog-user-project headers
639
+ metadata[:"x-goog-api-client"] ||= Gapic::Headers.x_goog_api_client \
640
+ lib_name: @config.lib_name, lib_version: @config.lib_version,
641
+ gapic_version: ::Google::Cloud::AccessApproval::V1::VERSION
642
+ metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id
643
+
644
+ header_params = {
645
+ "name" => request.name
646
+ }
647
+ request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
648
+ metadata[:"x-goog-request-params"] ||= request_params_header
649
+
650
+ options.apply_defaults timeout: @config.rpcs.delete_access_approval_settings.timeout,
651
+ metadata: metadata,
652
+ retry_policy: @config.rpcs.delete_access_approval_settings.retry_policy
653
+ options.apply_defaults metadata: @config.metadata,
654
+ retry_policy: @config.retry_policy
655
+
656
+ @access_approval_stub.call_rpc :delete_access_approval_settings, request, options: options do |response, operation|
657
+ yield response, operation if block_given?
658
+ return response
659
+ end
660
+ rescue GRPC::BadStatus => e
661
+ raise Google::Cloud::Error.from_error(e)
662
+ end
663
+
664
+ ##
665
+ # Configuration class for the AccessApproval API.
666
+ #
667
+ # This class represents the configuration for AccessApproval,
668
+ # providing control over timeouts, retry behavior, logging, transport
669
+ # parameters, and other low-level controls. Certain parameters can also be
670
+ # applied individually to specific RPCs. See
671
+ # {Google::Cloud::AccessApproval::V1::AccessApproval::Client::Configuration::Rpcs}
672
+ # for a list of RPCs that can be configured independently.
673
+ #
674
+ # Configuration can be applied globally to all clients, or to a single client
675
+ # on construction.
676
+ #
677
+ # # Examples
678
+ #
679
+ # To modify the global config, setting the timeout for list_approval_requests
680
+ # to 20 seconds, and all remaining timeouts to 10 seconds:
681
+ #
682
+ # Google::Cloud::AccessApproval::V1::AccessApproval::Client.configure do |config|
683
+ # config.timeout = 10_000
684
+ # config.rpcs.list_approval_requests.timeout = 20_000
685
+ # end
686
+ #
687
+ # To apply the above configuration only to a new client:
688
+ #
689
+ # client = Google::Cloud::AccessApproval::V1::AccessApproval::Client.new do |config|
690
+ # config.timeout = 10_000
691
+ # config.rpcs.list_approval_requests.timeout = 20_000
692
+ # end
693
+ #
694
+ # @!attribute [rw] endpoint
695
+ # The hostname or hostname:port of the service endpoint.
696
+ # Defaults to `"accessapproval.googleapis.com"`.
697
+ # @return [String]
698
+ # @!attribute [rw] credentials
699
+ # Credentials to send with calls. You may provide any of the following types:
700
+ # * (`String`) The path to a service account key file in JSON format
701
+ # * (`Hash`) A service account key as a Hash
702
+ # * (`Google::Auth::Credentials`) A googleauth credentials object
703
+ # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html))
704
+ # * (`Signet::OAuth2::Client`) A signet oauth2 client object
705
+ # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html))
706
+ # * (`GRPC::Core::Channel`) a gRPC channel with included credentials
707
+ # * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
708
+ # * (`nil`) indicating no credentials
709
+ # @return [Object]
710
+ # @!attribute [rw] scope
711
+ # The OAuth scopes
712
+ # @return [Array<String>]
713
+ # @!attribute [rw] lib_name
714
+ # The library name as recorded in instrumentation and logging
715
+ # @return [String]
716
+ # @!attribute [rw] lib_version
717
+ # The library version as recorded in instrumentation and logging
718
+ # @return [String]
719
+ # @!attribute [rw] channel_args
720
+ # Extra parameters passed to the gRPC channel. Note: this is ignored if a
721
+ # `GRPC::Core::Channel` object is provided as the credential.
722
+ # @return [Hash]
723
+ # @!attribute [rw] interceptors
724
+ # An array of interceptors that are run before calls are executed.
725
+ # @return [Array<GRPC::ClientInterceptor>]
726
+ # @!attribute [rw] timeout
727
+ # The call timeout in milliseconds.
728
+ # @return [Numeric]
729
+ # @!attribute [rw] metadata
730
+ # Additional gRPC headers to be sent with the call.
731
+ # @return [Hash{Symbol=>String}]
732
+ # @!attribute [rw] retry_policy
733
+ # The retry policy. The value is a hash with the following keys:
734
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
735
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
736
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
737
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
738
+ # trigger a retry.
739
+ # @return [Hash]
740
+ #
741
+ class Configuration
742
+ extend Gapic::Config
743
+
744
+ config_attr :endpoint, "accessapproval.googleapis.com", String
745
+ config_attr :credentials, nil do |value|
746
+ allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
747
+ allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
748
+ allowed.any? { |klass| klass === value }
749
+ end
750
+ config_attr :scope, nil, String, Array, nil
751
+ config_attr :lib_name, nil, String, nil
752
+ config_attr :lib_version, nil, String, nil
753
+ config_attr(:channel_args, { "grpc.service_config_disable_resolution"=>1 }, Hash, nil)
754
+ config_attr :interceptors, nil, Array, nil
755
+ config_attr :timeout, nil, Numeric, nil
756
+ config_attr :metadata, nil, Hash, nil
757
+ config_attr :retry_policy, nil, Hash, Proc, nil
758
+
759
+ # @private
760
+ def initialize parent_config = nil
761
+ @parent_config = parent_config unless parent_config.nil?
762
+
763
+ yield self if block_given?
764
+ end
765
+
766
+ ##
767
+ # Configurations for individual RPCs
768
+ # @return [Rpcs]
769
+ #
770
+ def rpcs
771
+ @rpcs ||= begin
772
+ parent_rpcs = nil
773
+ parent_rpcs = @parent_config.rpcs if @parent_config&.respond_to? :rpcs
774
+ Rpcs.new parent_rpcs
775
+ end
776
+ end
777
+
778
+ ##
779
+ # Configuration RPC class for the AccessApproval API.
780
+ #
781
+ # Includes fields providing the configuration for each RPC in this service.
782
+ # Each configuration object is of type `Gapic::Config::Method` and includes
783
+ # the following configuration fields:
784
+ #
785
+ # * `timeout` (*type:* `Numeric`) - The call timeout in milliseconds
786
+ # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional gRPC headers
787
+ # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields
788
+ # include the following keys:
789
+ # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds.
790
+ # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds.
791
+ # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier.
792
+ # * `:retry_codes` (*type:* `Array<String>`) - The error codes that should
793
+ # trigger a retry.
794
+ #
795
+ class Rpcs
796
+ ##
797
+ # RPC-specific configuration for `list_approval_requests`
798
+ # @return [Gapic::Config::Method]
799
+ #
800
+ attr_reader :list_approval_requests
801
+ ##
802
+ # RPC-specific configuration for `get_approval_request`
803
+ # @return [Gapic::Config::Method]
804
+ #
805
+ attr_reader :get_approval_request
806
+ ##
807
+ # RPC-specific configuration for `approve_approval_request`
808
+ # @return [Gapic::Config::Method]
809
+ #
810
+ attr_reader :approve_approval_request
811
+ ##
812
+ # RPC-specific configuration for `dismiss_approval_request`
813
+ # @return [Gapic::Config::Method]
814
+ #
815
+ attr_reader :dismiss_approval_request
816
+ ##
817
+ # RPC-specific configuration for `get_access_approval_settings`
818
+ # @return [Gapic::Config::Method]
819
+ #
820
+ attr_reader :get_access_approval_settings
821
+ ##
822
+ # RPC-specific configuration for `update_access_approval_settings`
823
+ # @return [Gapic::Config::Method]
824
+ #
825
+ attr_reader :update_access_approval_settings
826
+ ##
827
+ # RPC-specific configuration for `delete_access_approval_settings`
828
+ # @return [Gapic::Config::Method]
829
+ #
830
+ attr_reader :delete_access_approval_settings
831
+
832
+ # @private
833
+ def initialize parent_rpcs = nil
834
+ list_approval_requests_config = parent_rpcs&.list_approval_requests if parent_rpcs&.respond_to? :list_approval_requests
835
+ @list_approval_requests = Gapic::Config::Method.new list_approval_requests_config
836
+ get_approval_request_config = parent_rpcs&.get_approval_request if parent_rpcs&.respond_to? :get_approval_request
837
+ @get_approval_request = Gapic::Config::Method.new get_approval_request_config
838
+ approve_approval_request_config = parent_rpcs&.approve_approval_request if parent_rpcs&.respond_to? :approve_approval_request
839
+ @approve_approval_request = Gapic::Config::Method.new approve_approval_request_config
840
+ dismiss_approval_request_config = parent_rpcs&.dismiss_approval_request if parent_rpcs&.respond_to? :dismiss_approval_request
841
+ @dismiss_approval_request = Gapic::Config::Method.new dismiss_approval_request_config
842
+ get_access_approval_settings_config = parent_rpcs&.get_access_approval_settings if parent_rpcs&.respond_to? :get_access_approval_settings
843
+ @get_access_approval_settings = Gapic::Config::Method.new get_access_approval_settings_config
844
+ update_access_approval_settings_config = parent_rpcs&.update_access_approval_settings if parent_rpcs&.respond_to? :update_access_approval_settings
845
+ @update_access_approval_settings = Gapic::Config::Method.new update_access_approval_settings_config
846
+ delete_access_approval_settings_config = parent_rpcs&.delete_access_approval_settings if parent_rpcs&.respond_to? :delete_access_approval_settings
847
+ @delete_access_approval_settings = Gapic::Config::Method.new delete_access_approval_settings_config
848
+
849
+ yield self if block_given?
850
+ end
851
+ end
852
+ end
853
+ end
854
+ end
855
+ end
856
+ end
857
+ end
858
+ end
859
+
860
+ # rubocop:disable Lint/HandleExceptions
861
+
862
+ # Once client is loaded, load helpers.rb if it exists.
863
+ begin
864
+ require "google/cloud/access_approval/v1/access_approval/helpers"
865
+ rescue LoadError
866
+ end
867
+
868
+ # rubocop:enable Lint/HandleExceptions