Class: Google::Cloud::AccessApproval::V1::AccessApproval::Client

Inherits:
Object
  • Object
show all
Includes:
Paths
Defined in:
lib/google/cloud/access_approval/v1/access_approval/client.rb

Overview

Client for the AccessApproval service.

This API allows a customer to manage accesses to cloud resources by Google personnel. It defines the following resource model:

  • The API has a collection of ApprovalRequest resources, named approvalRequests/{approval_request}
  • The API has top-level settings per Project/Folder/Organization, named accessApprovalSettings

The service also periodically emails a list of recipients, defined at the Project/Folder/Organization level in the accessApprovalSettings, when there is a pending ApprovalRequest for them to act on. The ApprovalRequests can also optionally be published to a Pub/Sub topic owned by the customer (contact support if you would like to enable Pub/Sub notifications).

ApprovalRequests can be approved or dismissed. Google personnel can only access the indicated resource or resources if the request is approved (subject to some exclusions: https://cloud.google.com/access-approval/docs/overview#exclusions).

Note: Using Access Approval functionality will mean that Google may not be able to meet the SLAs for your chosen products, as any support response times may be dramatically increased. As such the SLAs do not apply to any service disruption to the extent impacted by Customer's use of Access Approval. Do not enable Access Approval for projects where you may require high service availability and rapid response by Google Cloud Support.

After a request is approved or dismissed, no further action may be taken on it. Requests with the requested_expiration in the past or with no activity for 14 days are considered dismissed. When an approval expires, the request is considered dismissed.

If a request is not approved or dismissed, we call it pending.

Defined Under Namespace

Classes: Configuration

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Paths

#access_approval_settings_path, #approval_request_path, #folder_path, #organization_path, #project_path

Constructor Details

#initialize {|config| ... } ⇒ Client

Create a new AccessApproval client object.

Examples:


# Create a client using the default configuration
client = ::Google::Cloud::AccessApproval::V1::AccessApproval::Client.new

# Create a client using a custom configuration
client = ::Google::Cloud::AccessApproval::V1::AccessApproval::Client.new do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the AccessApproval client.

Yield Parameters:



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/google/cloud/access_approval/v1/access_approval/client.rb', line 181

def initialize
  # These require statements are intentionally placed here to initialize
  # the gRPC module only when it's required.
  # See https://github.com/googleapis/toolkit/issues/446
  require "gapic/grpc"
  require "google/cloud/accessapproval/v1/accessapproval_services_pb"

  # Create the configuration object
  @config = Configuration.new Client.configure

  # Yield the configuration if needed
  yield @config if block_given?

  # Create credentials
  credentials = @config.credentials
  # Use self-signed JWT if the endpoint is unchanged from default,
  # but only if the default endpoint does not have a region prefix.
  enable_self_signed_jwt = @config.endpoint.nil? ||
                           (@config.endpoint == Configuration::DEFAULT_ENDPOINT &&
                           !@config.endpoint.split(".").first.include?("-"))
  credentials ||= Credentials.default scope: @config.scope,
                                      enable_self_signed_jwt: enable_self_signed_jwt
  if credentials.is_a?(::String) || credentials.is_a?(::Hash)
    credentials = Credentials.new credentials, scope: @config.scope
  end
  @quota_project_id = @config.quota_project
  @quota_project_id ||= credentials.quota_project_id if credentials.respond_to? :quota_project_id

  @access_approval_stub = ::Gapic::ServiceStub.new(
    ::Google::Cloud::AccessApproval::V1::AccessApproval::Stub,
    credentials: credentials,
    endpoint: @config.endpoint,
    endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
    universe_domain: @config.universe_domain,
    channel_args: @config.channel_args,
    interceptors: @config.interceptors,
    channel_pool_config: @config.channel_pool
  )
end

Class Method Details

.configure {|config| ... } ⇒ Client::Configuration

Configure the AccessApproval Client class.

See Configuration for a description of the configuration fields.

Examples:


# Modify the configuration for all AccessApproval clients
::Google::Cloud::AccessApproval::V1::AccessApproval::Client.configure do |config|
  config.timeout = 10.0
end

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/google/cloud/access_approval/v1/access_approval/client.rb', line 94

def self.configure
  @configure ||= begin
    namespace = ["Google", "Cloud", "AccessApproval", "V1"]
    parent_config = while namespace.any?
                      parent_name = namespace.join "::"
                      parent_const = const_get parent_name
                      break parent_const.configure if parent_const.respond_to? :configure
                      namespace.pop
                    end
    default_config = Client::Configuration.new parent_config

    default_config.rpcs.list_approval_requests.timeout = 600.0
    default_config.rpcs.list_approval_requests.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14]
    }

    default_config.rpcs.get_approval_request.timeout = 600.0
    default_config.rpcs.get_approval_request.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14]
    }

    default_config.rpcs.approve_approval_request.timeout = 600.0

    default_config.rpcs.dismiss_approval_request.timeout = 600.0

    default_config.rpcs.invalidate_approval_request.timeout = 600.0

    default_config.rpcs.get_access_approval_settings.timeout = 600.0
    default_config.rpcs.get_access_approval_settings.retry_policy = {
      initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14]
    }

    default_config.rpcs.update_access_approval_settings.timeout = 600.0

    default_config.rpcs.delete_access_approval_settings.timeout = 600.0

    default_config
  end
  yield @configure if block_given?
  @configure
end

Instance Method Details

#approve_approval_request(request, options = nil) ⇒ ::Google::Cloud::AccessApproval::V1::ApprovalRequest #approve_approval_request(name: nil, expire_time: nil) ⇒ ::Google::Cloud::AccessApproval::V1::ApprovalRequest

Approves a request and returns the updated ApprovalRequest.

Returns NOT_FOUND if the request does not exist. Returns FAILED_PRECONDITION if the request exists but is not in a pending state.

Examples:

Basic example

require "google/cloud/access_approval/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::AccessApproval::V1::AccessApproval::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::AccessApproval::V1::ApproveApprovalRequestMessage.new

# Call the approve_approval_request method.
result = client.approve_approval_request request

# The returned object is of type Google::Cloud::AccessApproval::V1::ApprovalRequest.
p result

Overloads:

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
# File 'lib/google/cloud/access_approval/v1/access_approval/client.rb', line 471

def approve_approval_request request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AccessApproval::V1::ApproveApprovalRequestMessage

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.approve_approval_request..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::AccessApproval::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.approve_approval_request.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.approve_approval_request.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @access_approval_stub.call_rpc :approve_approval_request, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#configure {|config| ... } ⇒ Client::Configuration

Configure the AccessApproval Client instance.

The configuration is set to the derived mode, meaning that values can be changed, but structural changes (adding new fields, etc.) are not allowed. Structural changes should be made on configure.

See Configuration for a description of the configuration fields.

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



151
152
153
154
# File 'lib/google/cloud/access_approval/v1/access_approval/client.rb', line 151

def configure
  yield @config if block_given?
  @config
end

#delete_access_approval_settings(request, options = nil) ⇒ ::Google::Protobuf::Empty #delete_access_approval_settings(name: nil) ⇒ ::Google::Protobuf::Empty

Deletes the settings associated with a project, folder, or organization. This will have the effect of disabling Access Approval for the project, folder, or organization, but only if all ancestors also have Access Approval disabled. If Access Approval is enabled at a higher level of the hierarchy, then Access Approval will still be enabled at this level as the settings are inherited.

Examples:

Basic example

require "google/cloud/access_approval/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::AccessApproval::V1::AccessApproval::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::AccessApproval::V1::DeleteAccessApprovalSettingsMessage.new

# Call the delete_access_approval_settings method.
result = client.delete_access_approval_settings request

# The returned object is of type Google::Protobuf::Empty.
p result

Overloads:

  • #delete_access_approval_settings(request, options = nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_access_approval_settings via a request object, either of type DeleteAccessApprovalSettingsMessage or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::AccessApproval::V1::DeleteAccessApprovalSettingsMessage, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #delete_access_approval_settings(name: nil) ⇒ ::Google::Protobuf::Empty

    Pass arguments to delete_access_approval_settings via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Name of the AccessApprovalSettings to delete.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
# File 'lib/google/cloud/access_approval/v1/access_approval/client.rb', line 935

def delete_access_approval_settings request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AccessApproval::V1::DeleteAccessApprovalSettingsMessage

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.delete_access_approval_settings..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::AccessApproval::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.delete_access_approval_settings.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.delete_access_approval_settings.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @access_approval_stub.call_rpc :delete_access_approval_settings, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#dismiss_approval_request(request, options = nil) ⇒ ::Google::Cloud::AccessApproval::V1::ApprovalRequest #dismiss_approval_request(name: nil) ⇒ ::Google::Cloud::AccessApproval::V1::ApprovalRequest

Dismisses a request. Returns the updated ApprovalRequest.

NOTE: This does not deny access to the resource if another request has been made and approved. It is equivalent in effect to ignoring the request altogether.

Returns NOT_FOUND if the request does not exist.

Returns FAILED_PRECONDITION if the request exists but is not in a pending state.

Examples:

Basic example

require "google/cloud/access_approval/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::AccessApproval::V1::AccessApproval::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::AccessApproval::V1::DismissApprovalRequestMessage.new

# Call the dismiss_approval_request method.
result = client.dismiss_approval_request request

# The returned object is of type Google::Cloud::AccessApproval::V1::ApprovalRequest.
p result

Overloads:

  • #dismiss_approval_request(request, options = nil) ⇒ ::Google::Cloud::AccessApproval::V1::ApprovalRequest

    Pass arguments to dismiss_approval_request via a request object, either of type DismissApprovalRequestMessage or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::AccessApproval::V1::DismissApprovalRequestMessage, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #dismiss_approval_request(name: nil) ⇒ ::Google::Cloud::AccessApproval::V1::ApprovalRequest

    Pass arguments to dismiss_approval_request via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Name of the ApprovalRequest to dismiss.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
# File 'lib/google/cloud/access_approval/v1/access_approval/client.rb', line 566

def dismiss_approval_request request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AccessApproval::V1::DismissApprovalRequestMessage

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.dismiss_approval_request..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::AccessApproval::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.dismiss_approval_request.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.dismiss_approval_request.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @access_approval_stub.call_rpc :dismiss_approval_request, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_access_approval_service_account(request, options = nil) ⇒ ::Google::Cloud::AccessApproval::V1::AccessApprovalServiceAccount #get_access_approval_service_account(name: nil) ⇒ ::Google::Cloud::AccessApproval::V1::AccessApprovalServiceAccount

Retrieves the service account that is used by Access Approval to access KMS keys for signing approved approval requests.

Examples:

Basic example

require "google/cloud/access_approval/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::AccessApproval::V1::AccessApproval::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::AccessApproval::V1::GetAccessApprovalServiceAccountMessage.new

# Call the get_access_approval_service_account method.
result = client. request

# The returned object is of type Google::Cloud::AccessApproval::V1::AccessApprovalServiceAccount.
p result

Overloads:

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
# File 'lib/google/cloud/access_approval/v1/access_approval/client.rb', line 1022

def  request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AccessApproval::V1::GetAccessApprovalServiceAccountMessage

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs...to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::AccessApproval::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs..timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs..retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @access_approval_stub.call_rpc :get_access_approval_service_account, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_access_approval_settings(request, options = nil) ⇒ ::Google::Cloud::AccessApproval::V1::AccessApprovalSettings #get_access_approval_settings(name: nil) ⇒ ::Google::Cloud::AccessApproval::V1::AccessApprovalSettings

Gets the settings associated with a project, folder, or organization.

Examples:

Basic example

require "google/cloud/access_approval/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::AccessApproval::V1::AccessApproval::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::AccessApproval::V1::GetAccessApprovalSettingsMessage.new

# Call the get_access_approval_settings method.
result = client.get_access_approval_settings request

# The returned object is of type Google::Cloud::AccessApproval::V1::AccessApprovalSettings.
p result

Overloads:

  • #get_access_approval_settings(request, options = nil) ⇒ ::Google::Cloud::AccessApproval::V1::AccessApprovalSettings

    Pass arguments to get_access_approval_settings via a request object, either of type GetAccessApprovalSettingsMessage or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::AccessApproval::V1::GetAccessApprovalSettingsMessage, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_access_approval_settings(name: nil) ⇒ ::Google::Cloud::AccessApproval::V1::AccessApprovalSettings

    Pass arguments to get_access_approval_settings via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      The name of the AccessApprovalSettings to retrieve. Format: "{projects|folders|organizations}/{id}/accessApprovalSettings"

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
# File 'lib/google/cloud/access_approval/v1/access_approval/client.rb', line 746

def get_access_approval_settings request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AccessApproval::V1::GetAccessApprovalSettingsMessage

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_access_approval_settings..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::AccessApproval::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_access_approval_settings.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_access_approval_settings.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @access_approval_stub.call_rpc :get_access_approval_settings, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#get_approval_request(request, options = nil) ⇒ ::Google::Cloud::AccessApproval::V1::ApprovalRequest #get_approval_request(name: nil) ⇒ ::Google::Cloud::AccessApproval::V1::ApprovalRequest

Gets an approval request. Returns NOT_FOUND if the request does not exist.

Examples:

Basic example

require "google/cloud/access_approval/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::AccessApproval::V1::AccessApproval::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::AccessApproval::V1::GetApprovalRequestMessage.new

# Call the get_approval_request method.
result = client.get_approval_request request

# The returned object is of type Google::Cloud::AccessApproval::V1::ApprovalRequest.
p result

Overloads:

  • #get_approval_request(request, options = nil) ⇒ ::Google::Cloud::AccessApproval::V1::ApprovalRequest

    Pass arguments to get_approval_request via a request object, either of type GetApprovalRequestMessage or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::AccessApproval::V1::GetApprovalRequestMessage, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #get_approval_request(name: nil) ⇒ ::Google::Cloud::AccessApproval::V1::ApprovalRequest

    Pass arguments to get_approval_request via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      The name of the approval request to retrieve. Format: "{projects|folders|organizations}/{id}/approvalRequests/{approval_request}"

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/google/cloud/access_approval/v1/access_approval/client.rb', line 380

def get_approval_request request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AccessApproval::V1::GetApprovalRequestMessage

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.get_approval_request..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::AccessApproval::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.get_approval_request.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.get_approval_request.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @access_approval_stub.call_rpc :get_approval_request, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#invalidate_approval_request(request, options = nil) ⇒ ::Google::Cloud::AccessApproval::V1::ApprovalRequest #invalidate_approval_request(name: nil) ⇒ ::Google::Cloud::AccessApproval::V1::ApprovalRequest

Invalidates an existing ApprovalRequest. Returns the updated ApprovalRequest.

NOTE: This does not deny access to the resource if another request has been made and approved. It only invalidates a single approval.

Returns FAILED_PRECONDITION if the request exists but is not in an approved state.

Examples:

Basic example

require "google/cloud/access_approval/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::AccessApproval::V1::AccessApproval::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::AccessApproval::V1::InvalidateApprovalRequestMessage.new

# Call the invalidate_approval_request method.
result = client.invalidate_approval_request request

# The returned object is of type Google::Cloud::AccessApproval::V1::ApprovalRequest.
p result

Overloads:

  • #invalidate_approval_request(request, options = nil) ⇒ ::Google::Cloud::AccessApproval::V1::ApprovalRequest

    Pass arguments to invalidate_approval_request via a request object, either of type InvalidateApprovalRequestMessage or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::AccessApproval::V1::InvalidateApprovalRequestMessage, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #invalidate_approval_request(name: nil) ⇒ ::Google::Cloud::AccessApproval::V1::ApprovalRequest

    Pass arguments to invalidate_approval_request via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • name (::String) (defaults to: nil)

      Name of the ApprovalRequest to invalidate.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
# File 'lib/google/cloud/access_approval/v1/access_approval/client.rb', line 659

def invalidate_approval_request request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AccessApproval::V1::InvalidateApprovalRequestMessage

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.invalidate_approval_request..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::AccessApproval::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.name
    header_params["name"] = request.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.invalidate_approval_request.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.invalidate_approval_request.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @access_approval_stub.call_rpc :invalidate_approval_request, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#list_approval_requests(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::AccessApproval::V1::ApprovalRequest> #list_approval_requests(parent: nil, filter: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::AccessApproval::V1::ApprovalRequest>

Lists approval requests associated with a project, folder, or organization. Approval requests can be filtered by state (pending, active, dismissed). The order is reverse chronological.

Examples:

Basic example

require "google/cloud/access_approval/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::AccessApproval::V1::AccessApproval::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::AccessApproval::V1::ListApprovalRequestsMessage.new

# Call the list_approval_requests method.
result = client.list_approval_requests request

# The returned object is of type Gapic::PagedEnumerable. You can iterate
# over elements, and API calls will be issued to fetch pages as needed.
result.each do |item|
  # Each element is of type ::Google::Cloud::AccessApproval::V1::ApprovalRequest.
  p item
end

Overloads:

  • #list_approval_requests(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::AccessApproval::V1::ApprovalRequest>

    Pass arguments to list_approval_requests via a request object, either of type ListApprovalRequestsMessage or an equivalent Hash.

    Parameters:

    • request (::Google::Cloud::AccessApproval::V1::ListApprovalRequestsMessage, ::Hash)

      A request object representing the call parameters. Required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash.

    • options (::Gapic::CallOptions, ::Hash) (defaults to: nil)

      Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.

  • #list_approval_requests(parent: nil, filter: nil, page_size: nil, page_token: nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::AccessApproval::V1::ApprovalRequest>

    Pass arguments to list_approval_requests via keyword arguments. Note that at least one keyword argument is required. To specify no parameters, or to keep all the default parameter values, pass an empty Hash as a request object (see above).

    Parameters:

    • parent (::String) (defaults to: nil)

      The parent resource. This may be "projects/{project}", "folders/{folder}", or "organizations/{organization}".

    • filter (::String) (defaults to: nil)

      A filter on the type of approval requests to retrieve. Must be one of the following values:

      • [not set]: Requests that are pending or have active approvals.
      • ALL: All requests.
      • PENDING: Only pending requests.
      • ACTIVE: Only active (i.e. currently approved) requests.
      • DISMISSED: Only requests that have been dismissed, or requests that are not approved and past expiration.
      • EXPIRED: Only requests that have been approved, and the approval has expired.
      • HISTORY: Active, dismissed and expired requests.
    • page_size (::Integer) (defaults to: nil)

      Requested page size.

    • page_token (::String) (defaults to: nil)

      A token identifying the page of results to return.

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/google/cloud/access_approval/v1/access_approval/client.rb', line 291

def list_approval_requests request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AccessApproval::V1::ListApprovalRequestsMessage

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.list_approval_requests..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::AccessApproval::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.parent
    header_params["parent"] = request.parent
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.list_approval_requests.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.list_approval_requests.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @access_approval_stub.call_rpc :list_approval_requests, request, options: options do |response, operation|
    response = ::Gapic::PagedEnumerable.new @access_approval_stub, :list_approval_requests, request, response, operation, options
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end

#universe_domainString

The effective universe domain

Returns:

  • (String)


161
162
163
# File 'lib/google/cloud/access_approval/v1/access_approval/client.rb', line 161

def universe_domain
  @access_approval_stub.universe_domain
end

#update_access_approval_settings(request, options = nil) ⇒ ::Google::Cloud::AccessApproval::V1::AccessApprovalSettings #update_access_approval_settings(settings: nil, update_mask: nil) ⇒ ::Google::Cloud::AccessApproval::V1::AccessApprovalSettings

Updates the settings associated with a project, folder, or organization. Settings to update are determined by the value of field_mask.

Examples:

Basic example

require "google/cloud/access_approval/v1"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::AccessApproval::V1::AccessApproval::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::AccessApproval::V1::UpdateAccessApprovalSettingsMessage.new

# Call the update_access_approval_settings method.
result = client.update_access_approval_settings request

# The returned object is of type Google::Cloud::AccessApproval::V1::AccessApprovalSettings.
p result

Overloads:

Yields:

  • (response, operation)

    Access the result along with the RPC operation

Yield Parameters:

Returns:

Raises:

  • (::Google::Cloud::Error)

    if the RPC is aborted.



844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
# File 'lib/google/cloud/access_approval/v1/access_approval/client.rb', line 844

def update_access_approval_settings request, options = nil
  raise ::ArgumentError, "request must be provided" if request.nil?

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::AccessApproval::V1::UpdateAccessApprovalSettingsMessage

  # Converts hash and nil to an options object
  options = ::Gapic::CallOptions.new(**options.to_h) if options.respond_to? :to_h

  # Customize the options with defaults
   = @config.rpcs.update_access_approval_settings..to_h

  # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
  [:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
    lib_name: @config.lib_name, lib_version: @config.lib_version,
    gapic_version: ::Google::Cloud::AccessApproval::V1::VERSION
  [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
  [:"x-goog-user-project"] = @quota_project_id if @quota_project_id

  header_params = {}
  if request.settings&.name
    header_params["settings.name"] = request.settings.name
  end

  request_params_header = header_params.map { |k, v| "#{k}=#{v}" }.join("&")
  [:"x-goog-request-params"] ||= request_params_header

  options.apply_defaults timeout:      @config.rpcs.update_access_approval_settings.timeout,
                         metadata:     ,
                         retry_policy: @config.rpcs.update_access_approval_settings.retry_policy

  options.apply_defaults timeout:      @config.timeout,
                         metadata:     @config.,
                         retry_policy: @config.retry_policy

  @access_approval_stub.call_rpc :update_access_approval_settings, request, options: options do |response, operation|
    yield response, operation if block_given?
    return response
  end
rescue ::GRPC::BadStatus => e
  raise ::Google::Cloud::Error.from_error(e)
end