Access Approval V1 API - Class Google::Cloud::AccessApproval::V1::AccessApproval::Client (v0.7.0)

Reference documentation and code samples for the Access Approval V1 API class Google::Cloud::AccessApproval::V1::AccessApproval::Client.

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.

Inherits

  • Object

Methods

.configure

def self.configure() { |config| ... } -> Client::Configuration

Configure the AccessApproval Client class.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter
Example
# Modify the configuration for all AccessApproval clients
::Google::Cloud::AccessApproval::V1::AccessApproval::Client.configure do |config|
  config.timeout = 10.0
end

#approve_approval_request

def approve_approval_request(request, options = nil) -> ::Google::Cloud::AccessApproval::V1::ApprovalRequest
def 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.

Overloads
def approve_approval_request(request, options = nil) -> ::Google::Cloud::AccessApproval::V1::ApprovalRequest
Pass arguments to approve_approval_request via a request object, either of type Google::Cloud::AccessApproval::V1::ApproveApprovalRequestMessage or an equivalent Hash.
Parameters
  • request (::Google::Cloud::AccessApproval::V1::ApproveApprovalRequestMessage, ::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) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def approve_approval_request(name: nil, expire_time: nil) -> ::Google::Cloud::AccessApproval::V1::ApprovalRequest
Pass arguments to approve_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) — Name of the approval request to approve.
  • expire_time (::Google::Protobuf::Timestamp, ::Hash) — The expiration time of this approval.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

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

#configure

def 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 Client.configure.

See Configuration for a description of the configuration fields.

Yields
  • (config) — Configure the Client client.
Yield Parameter

#delete_access_approval_settings

def delete_access_approval_settings(request, options = nil) -> ::Google::Protobuf::Empty
def 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.

Overloads
def 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) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def 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).
Parameter
  • name (::String) — Name of the AccessApprovalSettings to delete.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

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

#dismiss_approval_request

def dismiss_approval_request(request, options = nil) -> ::Google::Cloud::AccessApproval::V1::ApprovalRequest
def 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.

Overloads
def 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) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def 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).
Parameter
  • name (::String) — Name of the ApprovalRequest to dismiss.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

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

#get_access_approval_service_account

def get_access_approval_service_account(request, options = nil) -> ::Google::Cloud::AccessApproval::V1::AccessApprovalServiceAccount
def 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.

Overloads
def get_access_approval_service_account(request, options = nil) -> ::Google::Cloud::AccessApproval::V1::AccessApprovalServiceAccount
Pass arguments to get_access_approval_service_account via a request object, either of type GetAccessApprovalServiceAccountMessage or an equivalent Hash.
Parameters
  • request (::Google::Cloud::AccessApproval::V1::GetAccessApprovalServiceAccountMessage, ::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) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def get_access_approval_service_account(name: nil) -> ::Google::Cloud::AccessApproval::V1::AccessApprovalServiceAccount
Pass arguments to get_access_approval_service_account 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).
Parameter
  • name (::String) — Name of the AccessApprovalServiceAccount to retrieve.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

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.get_access_approval_service_account request

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

#get_access_approval_settings

def get_access_approval_settings(request, options = nil) -> ::Google::Cloud::AccessApproval::V1::AccessApprovalSettings
def get_access_approval_settings(name: nil) -> ::Google::Cloud::AccessApproval::V1::AccessApprovalSettings

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

Overloads
def 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) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def 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).
Parameter
  • name (::String) — 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
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

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

#get_approval_request

def get_approval_request(request, options = nil) -> ::Google::Cloud::AccessApproval::V1::ApprovalRequest
def get_approval_request(name: nil) -> ::Google::Cloud::AccessApproval::V1::ApprovalRequest

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

Overloads
def 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) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def 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).
Parameter
  • name (::String) — 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
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

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

#initialize

def initialize() { |config| ... } -> Client

Create a new AccessApproval client object.

Yields
  • (config) — Configure the AccessApproval client.
Yield Parameter
Returns
  • (Client) — a new instance of Client
Example
# 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

#invalidate_approval_request

def invalidate_approval_request(request, options = nil) -> ::Google::Cloud::AccessApproval::V1::ApprovalRequest
def 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.

Overloads
def 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) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def 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).
Parameter
  • name (::String) — Name of the ApprovalRequest to invalidate.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

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

#list_approval_requests

def list_approval_requests(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::AccessApproval::V1::ApprovalRequest>
def 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.

Overloads
def 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) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def 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) — The parent resource. This may be "projects/{project}", "folders/{folder}", or "organizations/{organization}".
  • filter (::String) —

    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) — Requested page size.
  • page_token (::String) — 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.
Example

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 all elements by calling #each, and the enumerable
# will lazily make API calls to fetch subsequent pages. Other
# methods are also available for managing paging directly.
result.each do |response|
  # Each element is of type ::Google::Cloud::AccessApproval::V1::ApprovalRequest.
  p response
end

#update_access_approval_settings

def update_access_approval_settings(request, options = nil) -> ::Google::Cloud::AccessApproval::V1::AccessApprovalSettings
def 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.

Overloads
def update_access_approval_settings(request, options = nil) -> ::Google::Cloud::AccessApproval::V1::AccessApprovalSettings
Pass arguments to update_access_approval_settings via a request object, either of type UpdateAccessApprovalSettingsMessage or an equivalent Hash.
Parameters
  • request (::Google::Cloud::AccessApproval::V1::UpdateAccessApprovalSettingsMessage, ::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) — Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
def update_access_approval_settings(settings: nil, update_mask: nil) -> ::Google::Cloud::AccessApproval::V1::AccessApprovalSettings
Pass arguments to update_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
  • settings (::Google::Cloud::AccessApproval::V1::AccessApprovalSettings, ::Hash) — The new AccessApprovalSettings.
  • update_mask (::Google::Protobuf::FieldMask, ::Hash) — The update mask applies to the settings. Only the top level fields of AccessApprovalSettings (notification_emails & enrolled_services) are supported. For each field, if it is included, the currently stored value will be entirely overwritten with the value of the field passed in this request.

    For the FieldMask definition, see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask If this field is left unset, only the notification_emails field will be updated.

Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

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