Policy Simulator V1 API - Class Google::Cloud::PolicySimulator::V1::Simulator::Rest::Client (v1.1.0)

Reference documentation and code samples for the Policy Simulator V1 API class Google::Cloud::PolicySimulator::V1::Simulator::Rest::Client.

REST client for the Simulator service.

Policy Simulator API service.

Policy Simulator is a collection of endpoints for creating, running, and viewing a Replay. A Replay is a type of simulation that lets you see how your principals' access to resources might change if you changed your IAM policy.

During a Replay, Policy Simulator re-evaluates, or replays, past access attempts under both the current policy and your proposed policy, and compares those results to determine how your principals' access might change under the proposed policy.

Inherits

  • Object

Methods

.configure

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

Configure the Simulator 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 Simulator clients
::Google::Cloud::PolicySimulator::V1::Simulator::Rest::Client.configure do |config|
  config.timeout = 10.0
end

#configure

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

Configure the Simulator 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

#create_replay

def create_replay(request, options = nil) -> ::Gapic::Operation
def create_replay(parent: nil, replay: nil) -> ::Gapic::Operation

Creates and starts a Replay using the given ReplayConfig.

Overloads
def create_replay(request, options = nil) -> ::Gapic::Operation
Pass arguments to create_replay via a request object, either of type CreateReplayRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::PolicySimulator::V1::CreateReplayRequest, ::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 create_replay(parent: nil, replay: nil) -> ::Gapic::Operation
Pass arguments to create_replay 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) — Required. The parent resource where this Replay will be created. This resource must be a project, folder, or organization with a location.

    Example: projects/my-example-project/locations/global

  • replay (::Google::Cloud::PolicySimulator::V1::Replay, ::Hash) — Required. The Replay to create. Set Replay.ReplayConfig to configure the replay.
Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
  • result (::Gapic::Operation)
  • operation (::Gapic::Rest::TransportOperation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/policy_simulator/v1"

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

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

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

# The returned object is of type Gapic::Operation. You can use it to
# check the status of an operation, cancel it, or wait for results.
# Here is how to wait for a response.
result.wait_until_done! timeout: 60
if result.response?
  p result.response
else
  puts "No response received."
end

#get_replay

def get_replay(request, options = nil) -> ::Google::Cloud::PolicySimulator::V1::Replay
def get_replay(name: nil) -> ::Google::Cloud::PolicySimulator::V1::Replay

Gets the specified Replay. Each Replay is available for at least 7 days.

Overloads
def get_replay(request, options = nil) -> ::Google::Cloud::PolicySimulator::V1::Replay
Pass arguments to get_replay via a request object, either of type GetReplayRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::PolicySimulator::V1::GetReplayRequest, ::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_replay(name: nil) -> ::Google::Cloud::PolicySimulator::V1::Replay
Pass arguments to get_replay 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) — Required. The name of the Replay to retrieve, in the following format:

    {projects|folders|organizations}/{resource-id}/locations/global/replays/{replay-id}, where {resource-id} is the ID of the project, folder, or organization that owns the Replay.

    Example: projects/my-example-project/locations/global/replays/506a5f7f-38ce-4d7d-8e03-479ce1833c36

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

Basic example

require "google/cloud/policy_simulator/v1"

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

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

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

# The returned object is of type Google::Cloud::PolicySimulator::V1::Replay.
p result

#initialize

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

Create a new Simulator REST client object.

Yields
  • (config) — Configure the Simulator client.
Yield Parameter
Returns
  • (Client) — a new instance of Client
Example
# Create a client using the default configuration
client = ::Google::Cloud::PolicySimulator::V1::Simulator::Rest::Client.new

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

#list_replay_results

def list_replay_results(request, options = nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::PolicySimulator::V1::ReplayResult>
def list_replay_results(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::PolicySimulator::V1::ReplayResult>

Lists the results of running a Replay.

Overloads
def list_replay_results(request, options = nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::PolicySimulator::V1::ReplayResult>
Pass arguments to list_replay_results via a request object, either of type ListReplayResultsRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::PolicySimulator::V1::ListReplayResultsRequest, ::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_replay_results(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::Rest::PagedEnumerable<::Google::Cloud::PolicySimulator::V1::ReplayResult>
Pass arguments to list_replay_results 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) — Required. The Replay whose results are listed, in the following format:

    {projects|folders|organizations}/{resource-id}/locations/global/replays/{replay-id}

    Example: projects/my-project/locations/global/replays/506a5f7f-38ce-4d7d-8e03-479ce1833c36

  • page_size (::Integer) — The maximum number of ReplayResult objects to return. Defaults to 5000.

    The maximum value is 5000; values above 5000 are rounded down to 5000.

  • page_token (::String) — A page token, received from a previous Simulator.ListReplayResults call. Provide this token to retrieve the next page of results.

    When paginating, all other parameters provided to [Simulator.ListReplayResults[] must match the call that provided the page token.

Yields
  • (result, operation) — Access the result along with the TransportOperation object
Yield Parameters
Returns
Raises
  • (::Google::Cloud::Error) — if the REST call is aborted.
Example

Basic example

require "google/cloud/policy_simulator/v1"

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

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

# Call the list_replay_results method.
result = client.list_replay_results 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::PolicySimulator::V1::ReplayResult.
  p item
end

#logger

def logger() -> Logger

The logger used for request/response debug logging.

Returns
  • (Logger)

#operations_client

def operations_client() -> ::Google::Cloud::PolicySimulator::V1::Simulator::Rest::Operations

Get the associated client for long-running operations.

#universe_domain

def universe_domain() -> String

The effective universe domain

Returns
  • (String)