Cloud Spanner Instance Admin V1 API - Class Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdmin::Client (v0.8.0)

Stay organized with collections Save and categorize content based on your preferences.

Reference documentation and code samples for the Cloud Spanner Instance Admin V1 API class Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdmin::Client.

Client for the InstanceAdmin service.

Cloud Spanner Instance Admin API

The Cloud Spanner Instance Admin API can be used to create, delete, modify and list instances. Instances are dedicated Cloud Spanner serving and storage resources to be used by Cloud Spanner databases.

Each instance has a "configuration", which dictates where the serving resources for the Cloud Spanner instance are located (e.g., US-central, Europe). Configurations are created by Google based on resource availability.

Cloud Spanner billing is based on the instances that exist and their sizes. After an instance exists, there are no additional per-database or per-operation charges for use of the instance (though there may be additional network bandwidth charges). Instances offer isolation: problems with databases in one instance will not affect other instances. However, within an instance databases can affect each other. For example, if one database in an instance receives a lot of requests and consumes most of the instance resources, fewer resources are available for other databases in that instance, and their performance may suffer.

Inherits

  • Object

Methods

.configure

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

Configure the InstanceAdmin 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 InstanceAdmin clients
::Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdmin::Client.configure do |config|
  config.timeout = 10.0
end

#configure

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

Configure the InstanceAdmin 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_instance

def create_instance(request, options = nil) -> ::Gapic::Operation
def create_instance(parent: nil, instance_id: nil, instance: nil) -> ::Gapic::Operation

Creates an instance and begins preparing it to begin serving. The returned long-running operation can be used to track the progress of preparing the new instance. The instance name is assigned by the caller. If the named instance already exists, CreateInstance returns ALREADY_EXISTS.

Immediately upon completion of this request:

  • The instance is readable via the API, with all requested attributes but no allocated resources. Its state is CREATING.

Until completion of the returned operation:

  • Cancelling the operation renders the instance immediately unreadable via the API.
  • The instance can be deleted.
  • All other attempts to modify the instance are rejected.

Upon completion of the returned operation:

  • Billing for all successfully-allocated resources begins (some types may have lower than the requested levels).
  • Databases can be created in the instance.
  • The instance's allocated resource levels are readable via the API.
  • The instance's state becomes READY.

The returned long-running operation will have a name of the format <instance_name>/operations/<operation_id> and can be used to track creation of the instance. The metadata field type is CreateInstanceMetadata. The response field type is Instance, if successful.

Overloads
def create_instance(request, options = nil) -> ::Gapic::Operation
Pass arguments to create_instance via a request object, either of type CreateInstanceRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Spanner::Admin::Instance::V1::CreateInstanceRequest, ::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_instance(parent: nil, instance_id: nil, instance: nil) -> ::Gapic::Operation
Pass arguments to create_instance 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 name of the project in which to create the instance. Values are of the form projects/<project>.
  • instance_id (::String) — Required. The ID of the instance to create. Valid identifiers are of the form [a-z][-a-z0-9]*[a-z0-9] and must be between 2 and 64 characters in length.
  • instance (::Google::Cloud::Spanner::Admin::Instance::V1::Instance, ::Hash) — Required. The instance to create. The name may be omitted, but if specified must be <parent>/instances/<instance_id>.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/spanner/admin/instance/v1"

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

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Instance::V1::CreateInstanceRequest.new

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

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

#create_instance_config

def create_instance_config(request, options = nil) -> ::Gapic::Operation
def create_instance_config(parent: nil, instance_config_id: nil, instance_config: nil, validate_only: nil) -> ::Gapic::Operation

Creates an instance config and begins preparing it to be used. The returned long-running operation can be used to track the progress of preparing the new instance config. The instance config name is assigned by the caller. If the named instance config already exists, CreateInstanceConfig returns ALREADY_EXISTS.

Immediately after the request returns:

  • The instance config is readable via the API, with all requested attributes. The instance config's reconciling field is set to true. Its state is CREATING.

While the operation is pending:

  • Cancelling the operation renders the instance config immediately unreadable via the API.
  • Except for deleting the creating resource, all other attempts to modify the instance config are rejected.

Upon completion of the returned operation:

  • Instances can be created using the instance configuration.
  • The instance config's reconciling field becomes false. Its state becomes READY.

The returned long-running operation will have a name of the format <instance_config_name>/operations/<operation_id> and can be used to track creation of the instance config. The metadata field type is CreateInstanceConfigMetadata. The response field type is InstanceConfig, if successful.

Authorization requires spanner.instanceConfigs.create permission on the resource parent.

Overloads
def create_instance_config(request, options = nil) -> ::Gapic::Operation
Pass arguments to create_instance_config via a request object, either of type CreateInstanceConfigRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Spanner::Admin::Instance::V1::CreateInstanceConfigRequest, ::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_instance_config(parent: nil, instance_config_id: nil, instance_config: nil, validate_only: nil) -> ::Gapic::Operation
Pass arguments to create_instance_config 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 name of the project in which to create the instance config. Values are of the form projects/<project>.
  • instance_config_id (::String) — Required. The ID of the instance config to create. Valid identifiers are of the form custom-[-a-z0-9]*[a-z0-9] and must be between 2 and 64 characters in length. The custom- prefix is required to avoid name conflicts with Google managed configurations.
  • instance_config (::Google::Cloud::Spanner::Admin::Instance::V1::InstanceConfig, ::Hash) — Required. The InstanceConfig proto of the configuration to create. instance_config.name must be <parent>/instanceConfigs/<instance_config_id>. instance_config.base_config must be a Google managed configuration name, e.g.
  • validate_only (::Boolean) — An option to validate, but not actually execute, a request, and provide the same response.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/spanner/admin/instance/v1"

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

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Instance::V1::CreateInstanceConfigRequest.new

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

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

#delete_instance

def delete_instance(request, options = nil) -> ::Google::Protobuf::Empty
def delete_instance(name: nil) -> ::Google::Protobuf::Empty

Deletes an instance.

Immediately upon completion of the request:

  • Billing ceases for all of the instance's reserved resources.

Soon afterward:

  • The instance and all of its databases immediately and irrevocably disappear from the API. All data in the databases is permanently deleted.
Overloads
def delete_instance(request, options = nil) -> ::Google::Protobuf::Empty
Pass arguments to delete_instance via a request object, either of type DeleteInstanceRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Spanner::Admin::Instance::V1::DeleteInstanceRequest, ::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_instance(name: nil) -> ::Google::Protobuf::Empty
Pass arguments to delete_instance 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 instance to be deleted. Values are of the form projects/<project>/instances/<instance>
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/spanner/admin/instance/v1"

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

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Instance::V1::DeleteInstanceRequest.new

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

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

#delete_instance_config

def delete_instance_config(request, options = nil) -> ::Google::Protobuf::Empty
def delete_instance_config(name: nil, etag: nil, validate_only: nil) -> ::Google::Protobuf::Empty

Deletes the instance config. Deletion is only allowed when no instances are using the configuration. If any instances are using the config, returns FAILED_PRECONDITION.

Only user managed configurations can be deleted.

Authorization requires spanner.instanceConfigs.delete permission on the resource name.

Overloads
def delete_instance_config(request, options = nil) -> ::Google::Protobuf::Empty
Pass arguments to delete_instance_config via a request object, either of type DeleteInstanceConfigRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Spanner::Admin::Instance::V1::DeleteInstanceConfigRequest, ::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_instance_config(name: nil, etag: nil, validate_only: nil) -> ::Google::Protobuf::Empty
Pass arguments to delete_instance_config 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) — Required. The name of the instance configuration to be deleted. Values are of the form projects/<project>/instanceConfigs/<instance_config>
  • etag (::String) — Used for optimistic concurrency control as a way to help prevent simultaneous deletes of an instance config from overwriting each other. If not empty, the API only deletes the instance config when the etag provided matches the current status of the requested instance config. Otherwise, deletes the instance config without checking the current status of the requested instance config.
  • validate_only (::Boolean) — An option to validate, but not actually execute, a request, and provide the same response.
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/spanner/admin/instance/v1"

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

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Instance::V1::DeleteInstanceConfigRequest.new

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

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

#get_iam_policy

def get_iam_policy(request, options = nil) -> ::Google::Iam::V1::Policy
def get_iam_policy(resource: nil, options: nil) -> ::Google::Iam::V1::Policy

Gets the access control policy for an instance resource. Returns an empty policy if an instance exists but does not have a policy set.

Authorization requires spanner.instances.getIamPolicy on resource.

Overloads
def get_iam_policy(request, options = nil) -> ::Google::Iam::V1::Policy
Pass arguments to get_iam_policy via a request object, either of type Iam::V1::GetIamPolicyRequest or an equivalent Hash.
Parameters
  • request (::Google::Iam::V1::GetIamPolicyRequest, ::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_iam_policy(resource: nil, options: nil) -> ::Google::Iam::V1::Policy
Pass arguments to get_iam_policy 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
  • resource (::String) — REQUIRED: The resource for which the policy is being requested. See the operation documentation for the appropriate value for this field.
  • options (::Google::Iam::V1::GetPolicyOptions, ::Hash) — OPTIONAL: A GetPolicyOptions object for specifying options to GetIamPolicy.
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/spanner/admin/instance/v1"

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

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Iam::V1::GetIamPolicyRequest.new

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

# The returned object is of type Google::Iam::V1::Policy.
p result

#get_instance

def get_instance(request, options = nil) -> ::Google::Cloud::Spanner::Admin::Instance::V1::Instance
def get_instance(name: nil, field_mask: nil) -> ::Google::Cloud::Spanner::Admin::Instance::V1::Instance

Gets information about a particular instance.

Overloads
def get_instance(request, options = nil) -> ::Google::Cloud::Spanner::Admin::Instance::V1::Instance
Pass arguments to get_instance via a request object, either of type GetInstanceRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Spanner::Admin::Instance::V1::GetInstanceRequest, ::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_instance(name: nil, field_mask: nil) -> ::Google::Cloud::Spanner::Admin::Instance::V1::Instance
Pass arguments to get_instance 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) — Required. The name of the requested instance. Values are of the form projects/<project>/instances/<instance>.
  • field_mask (::Google::Protobuf::FieldMask, ::Hash) — If field_mask is present, specifies the subset of Instance fields that should be returned. If absent, all Instance fields are returned.
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/spanner/admin/instance/v1"

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

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Instance::V1::GetInstanceRequest.new

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

# The returned object is of type Google::Cloud::Spanner::Admin::Instance::V1::Instance.
p result

#get_instance_config

def get_instance_config(request, options = nil) -> ::Google::Cloud::Spanner::Admin::Instance::V1::InstanceConfig
def get_instance_config(name: nil) -> ::Google::Cloud::Spanner::Admin::Instance::V1::InstanceConfig

Gets information about a particular instance configuration.

Overloads
def get_instance_config(request, options = nil) -> ::Google::Cloud::Spanner::Admin::Instance::V1::InstanceConfig
Pass arguments to get_instance_config via a request object, either of type GetInstanceConfigRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Spanner::Admin::Instance::V1::GetInstanceConfigRequest, ::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_instance_config(name: nil) -> ::Google::Cloud::Spanner::Admin::Instance::V1::InstanceConfig
Pass arguments to get_instance_config 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 requested instance configuration. Values are of the form projects/<project>/instanceConfigs/<config>.
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/spanner/admin/instance/v1"

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

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Instance::V1::GetInstanceConfigRequest.new

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

# The returned object is of type Google::Cloud::Spanner::Admin::Instance::V1::InstanceConfig.
p result

#initialize

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

Create a new InstanceAdmin client object.

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

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

#list_instance_config_operations

def list_instance_config_operations(request, options = nil) -> ::Gapic::PagedEnumerable<::Gapic::Operation>
def list_instance_config_operations(parent: nil, filter: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Gapic::Operation>

Lists the user-managed instance config [long-running operations][google.longrunning.Operation] in the given project. An instance config operation has a name of the form projects/<project>/instanceConfigs/<instance_config>/operations/<operation>. The long-running operation metadata field type metadata.type_url describes the type of the metadata. Operations returned include those that have completed/failed/canceled within the last 7 days, and pending operations. Operations returned are ordered by operation.metadata.value.start_time in descending order starting from the most recently started operation.

Overloads
def list_instance_config_operations(request, options = nil) -> ::Gapic::PagedEnumerable<::Gapic::Operation>
Pass arguments to list_instance_config_operations via a request object, either of type ListInstanceConfigOperationsRequest or an equivalent Hash.
Parameters
def list_instance_config_operations(parent: nil, filter: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Gapic::Operation>
Pass arguments to list_instance_config_operations 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 project of the instance config operations. Values are of the form projects/<project>.
  • filter (::String) —

    An expression that filters the list of returned operations.

    A filter expression consists of a field name, a comparison operator, and a value for filtering. The value must be a string, a number, or a boolean. The comparison operator must be one of: <, >, <=, >=, !=, =, or :. Colon : is the contains operator. Filter rules are not case sensitive.

    The following fields in the Operation are eligible for filtering:

    • name - The name of the long-running operation
    • done - False if the operation is in progress, else true.
    • metadata.@type - the type of metadata. For example, the type string for CreateInstanceConfigMetadata is type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata.
    • metadata.<field_name> - any field in metadata.value. metadata.@type must be specified first, if filtering on metadata fields.
    • error - Error associated with the long-running operation.
    • response.@type - the type of response.
    • response.<field_name> - any field in response.value.

    You can combine multiple expressions by enclosing each expression in parentheses. By default, expressions are combined with AND logic. However, you can specify AND, OR, and NOT logic explicitly.

    Here are a few examples:

    • done:true - The operation is complete.
    • (metadata.@type= \ type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceConfigMetadata) AND \ (metadata.instance_config.name:custom-config) AND \ (metadata.progress.start_time < \"2021-03-28T14:50:00Z\") AND \ (error:*) - Return operations where:
      • The operation's metadata type is CreateInstanceConfigMetadata.
      • The instance config name contains "custom-config".
      • The operation started before 2021-03-28T14:50:00Z.
      • The operation resulted in an error.
  • page_size (::Integer) — Number of operations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
  • page_token (::String) — If non-empty, page_token should contain a next_page_token from a previous ListInstanceConfigOperationsResponse to the same parent and with the same filter.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::PagedEnumerable<::Gapic::Operation>)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::PagedEnumerable<::Gapic::Operation>)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/spanner/admin/instance/v1"

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

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Instance::V1::ListInstanceConfigOperationsRequest.new

# Call the list_instance_config_operations method.
result = client.list_instance_config_operations 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::Longrunning::Operation.
  p response
end

#list_instance_configs

def list_instance_configs(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Instance::V1::InstanceConfig>
def list_instance_configs(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Instance::V1::InstanceConfig>

Lists the supported instance configurations for a given project.

Overloads
def list_instance_configs(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Instance::V1::InstanceConfig>
Pass arguments to list_instance_configs via a request object, either of type ListInstanceConfigsRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Spanner::Admin::Instance::V1::ListInstanceConfigsRequest, ::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_instance_configs(parent: nil, page_size: nil, page_token: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Instance::V1::InstanceConfig>
Pass arguments to list_instance_configs 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 name of the project for which a list of supported instance configurations is requested. Values are of the form projects/<project>.
  • page_size (::Integer) — Number of instance configurations to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
  • page_token (::String) — If non-empty, page_token should contain a next_page_token from a previous ListInstanceConfigsResponse.
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/spanner/admin/instance/v1"

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

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Instance::V1::ListInstanceConfigsRequest.new

# Call the list_instance_configs method.
result = client.list_instance_configs 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::Spanner::Admin::Instance::V1::InstanceConfig.
  p response
end

#list_instances

def list_instances(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Instance::V1::Instance>
def list_instances(parent: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Instance::V1::Instance>

Lists all instances in the given project.

Overloads
def list_instances(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Instance::V1::Instance>
Pass arguments to list_instances via a request object, either of type ListInstancesRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Spanner::Admin::Instance::V1::ListInstancesRequest, ::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_instances(parent: nil, page_size: nil, page_token: nil, filter: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Spanner::Admin::Instance::V1::Instance>
Pass arguments to list_instances 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 name of the project for which a list of instances is requested. Values are of the form projects/<project>.
  • page_size (::Integer) — Number of instances to be returned in the response. If 0 or less, defaults to the server's maximum allowed page size.
  • page_token (::String) — If non-empty, page_token should contain a next_page_token from a previous ListInstancesResponse.
  • filter (::String) —

    An expression for filtering the results of the request. Filter rules are case insensitive. The fields eligible for filtering are:

    • name
    • display_name
    • labels.key where key is the name of a label

    Some examples of using filters are:

    • name:* --> The instance has a name.
    • name:Howl --> The instance's name contains the string "howl".
    • name:HOWL --> Equivalent to above.
    • NAME:howl --> Equivalent to above.
    • labels.env:* --> The instance has the label "env".
    • labels.env:dev --> The instance has the label "env" and the value of the label contains the string "dev".
    • name:howl labels.env:dev --> The instance's name contains "howl" and it has the label "env" with its value containing "dev".
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/spanner/admin/instance/v1"

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

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Instance::V1::ListInstancesRequest.new

# Call the list_instances method.
result = client.list_instances 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::Spanner::Admin::Instance::V1::Instance.
  p response
end

#operations_client

def operations_client() -> ::Google::Cloud::Spanner::Admin::Instance::V1::InstanceAdmin::Operations

Get the associated client for long-running operations.

#set_iam_policy

def set_iam_policy(request, options = nil) -> ::Google::Iam::V1::Policy
def set_iam_policy(resource: nil, policy: nil, update_mask: nil) -> ::Google::Iam::V1::Policy

Sets the access control policy on an instance resource. Replaces any existing policy.

Authorization requires spanner.instances.setIamPolicy on resource.

Overloads
def set_iam_policy(request, options = nil) -> ::Google::Iam::V1::Policy
Pass arguments to set_iam_policy via a request object, either of type Iam::V1::SetIamPolicyRequest or an equivalent Hash.
Parameters
  • request (::Google::Iam::V1::SetIamPolicyRequest, ::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 set_iam_policy(resource: nil, policy: nil, update_mask: nil) -> ::Google::Iam::V1::Policy
Pass arguments to set_iam_policy 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
  • resource (::String) — REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.
  • policy (::Google::Iam::V1::Policy, ::Hash) — REQUIRED: The complete policy to be applied to the resource. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Cloud Platform services (such as Projects) might reject them.
  • update_mask (::Google::Protobuf::FieldMask, ::Hash) — OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only the fields in the mask will be modified. If no mask is provided, the following default mask is used:

    paths: "bindings, etag"

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/spanner/admin/instance/v1"

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

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Iam::V1::SetIamPolicyRequest.new

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

# The returned object is of type Google::Iam::V1::Policy.
p result

#test_iam_permissions

def test_iam_permissions(request, options = nil) -> ::Google::Iam::V1::TestIamPermissionsResponse
def test_iam_permissions(resource: nil, permissions: nil) -> ::Google::Iam::V1::TestIamPermissionsResponse

Returns permissions that the caller has on the specified instance resource.

Attempting this RPC on a non-existent Cloud Spanner instance resource will result in a NOT_FOUND error if the user has spanner.instances.list permission on the containing Google Cloud Project. Otherwise returns an empty set of permissions.

Overloads
def test_iam_permissions(request, options = nil) -> ::Google::Iam::V1::TestIamPermissionsResponse
Pass arguments to test_iam_permissions via a request object, either of type Iam::V1::TestIamPermissionsRequest or an equivalent Hash.
Parameters
  • request (::Google::Iam::V1::TestIamPermissionsRequest, ::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 test_iam_permissions(resource: nil, permissions: nil) -> ::Google::Iam::V1::TestIamPermissionsResponse
Pass arguments to test_iam_permissions 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
  • resource (::String) — REQUIRED: The resource for which the policy detail is being requested. See the operation documentation for the appropriate value for this field.
  • permissions (::Array<::String>) — The set of permissions to check for the resource. Permissions with wildcards (such as '' or 'storage.') are not allowed. For more information see IAM Overview.
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/spanner/admin/instance/v1"

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

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Iam::V1::TestIamPermissionsRequest.new

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

# The returned object is of type Google::Iam::V1::TestIamPermissionsResponse.
p result

#update_instance

def update_instance(request, options = nil) -> ::Gapic::Operation
def update_instance(instance: nil, field_mask: nil) -> ::Gapic::Operation

Updates an instance, and begins allocating or releasing resources as requested. The returned [long-running operation][google.longrunning.Operation] can be used to track the progress of updating the instance. If the named instance does not exist, returns NOT_FOUND.

Immediately upon completion of this request:

  • For resource types for which a decrease in the instance's allocation has been requested, billing is based on the newly-requested level.

Until completion of the returned operation:

  • Cancelling the operation sets its metadata's cancel_time, and begins restoring resources to their pre-request values. The operation is guaranteed to succeed at undoing all resource changes, after which point it terminates with a CANCELLED status.
  • All other attempts to modify the instance are rejected.
  • Reading the instance via the API continues to give the pre-request resource levels.

Upon completion of the returned operation:

  • Billing begins for all successfully-allocated resources (some types may have lower than the requested levels).
  • All newly-reserved resources are available for serving the instance's tables.
  • The instance's new resource levels are readable via the API.

The returned long-running operation will have a name of the format <instance_name>/operations/<operation_id> and can be used to track the instance modification. The metadata field type is UpdateInstanceMetadata. The response field type is Instance, if successful.

Authorization requires spanner.instances.update permission on the resource name.

Overloads
def update_instance(request, options = nil) -> ::Gapic::Operation
Pass arguments to update_instance via a request object, either of type UpdateInstanceRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Spanner::Admin::Instance::V1::UpdateInstanceRequest, ::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_instance(instance: nil, field_mask: nil) -> ::Gapic::Operation
Pass arguments to update_instance 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
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/spanner/admin/instance/v1"

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

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Instance::V1::UpdateInstanceRequest.new

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

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

#update_instance_config

def update_instance_config(request, options = nil) -> ::Gapic::Operation
def update_instance_config(instance_config: nil, update_mask: nil, validate_only: nil) -> ::Gapic::Operation

Updates an instance config. The returned long-running operation can be used to track the progress of updating the instance. If the named instance config does not exist, returns NOT_FOUND.

Only user managed configurations can be updated.

Immediately after the request returns:

  • The instance config's reconciling field is set to true.

While the operation is pending:

  • Cancelling the operation sets its metadata's cancel_time. The operation is guaranteed to succeed at undoing all changes, after which point it terminates with a CANCELLED status.
  • All other attempts to modify the instance config are rejected.
  • Reading the instance config via the API continues to give the pre-request values.

Upon completion of the returned operation:

  • Creating instances using the instance configuration uses the new values.
  • The instance config's new values are readable via the API.
  • The instance config's reconciling field becomes false.

The returned long-running operation will have a name of the format <instance_config_name>/operations/<operation_id> and can be used to track the instance config modification. The metadata field type is UpdateInstanceConfigMetadata. The response field type is InstanceConfig, if successful.

Authorization requires spanner.instanceConfigs.update permission on the resource name.

Overloads
def update_instance_config(request, options = nil) -> ::Gapic::Operation
Pass arguments to update_instance_config via a request object, either of type UpdateInstanceConfigRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Spanner::Admin::Instance::V1::UpdateInstanceConfigRequest, ::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_instance_config(instance_config: nil, update_mask: nil, validate_only: nil) -> ::Gapic::Operation
Pass arguments to update_instance_config 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
  • instance_config (::Google::Cloud::Spanner::Admin::Instance::V1::InstanceConfig, ::Hash) — Required. The user instance config to update, which must always include the instance config name. Otherwise, only fields mentioned in update_mask need be included. To prevent conflicts of concurrent updates, etag can be used.
  • update_mask (::Google::Protobuf::FieldMask, ::Hash) — Required. A mask specifying which fields in InstanceConfig should be updated. The field mask must always be specified; this prevents any future fields in InstanceConfig from being erased accidentally by clients that do not know about them. Only display_name and labels can be updated.
  • validate_only (::Boolean) — An option to validate, but not actually execute, a request, and provide the same response.
Yields
  • (response, operation) — Access the result along with the RPC operation
Yield Parameters
  • response (::Gapic::Operation)
  • operation (::GRPC::ActiveCall::Operation)
Returns
  • (::Gapic::Operation)
Raises
  • (::Google::Cloud::Error) — if the RPC is aborted.
Example

Basic example

require "google/cloud/spanner/admin/instance/v1"

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

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Spanner::Admin::Instance::V1::UpdateInstanceConfigRequest.new

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

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