Google Cloud Memorystore for Memcached API - Class Google::Cloud::Memcache::V1beta2::CloudMemcache::Client (v0.7.0)

Reference documentation and code samples for the Google Cloud Memorystore for Memcached API class Google::Cloud::Memcache::V1beta2::CloudMemcache::Client.

Client for the CloudMemcache service.

Configures and manages Cloud Memorystore for Memcached instances.

The memcache.googleapis.com service implements the Google Cloud Memorystore for Memcached API and defines the following resource model for managing Memorystore Memcached (also called Memcached below) instances:

  • The service works with a collection of cloud projects, named: /projects/
  • Each project has a collection of available locations, named: /locations/
  • Each location has a collection of Memcached instances, named: /instances/*
  • As such, Memcached instances are resources of the form: /projects/{project_id}/locations/{location_id}/instances/{instance_id}

Note that location_id must be a GCP region; for example:

  • projects/my-memcached-project/locations/us-central1/instances/my-memcached

Inherits

  • Object

Methods

.configure

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

Configure the CloudMemcache 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 CloudMemcache clients
::Google::Cloud::Memcache::V1beta2::CloudMemcache::Client.configure do |config|
  config.timeout = 10.0
end

#apply_parameters

def apply_parameters(request, options = nil) -> ::Gapic::Operation
def apply_parameters(name: nil, node_ids: nil, apply_all: nil) -> ::Gapic::Operation

ApplyParameters restarts the set of specified nodes in order to update them to the current set of parameters for the Memcached Instance.

Overloads
def apply_parameters(request, options = nil) -> ::Gapic::Operation
Pass arguments to apply_parameters via a request object, either of type ApplyParametersRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Memcache::V1beta2::ApplyParametersRequest, ::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 apply_parameters(name: nil, node_ids: nil, apply_all: nil) -> ::Gapic::Operation
Pass arguments to apply_parameters 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. Resource name of the Memcached instance for which parameter group updates should be applied.
  • node_ids (::Array<::String>) — Nodes to which the instance-level parameter group is applied.
  • apply_all (::Boolean) — Whether to apply instance-level parameter group to all nodes. If set to true, users are restricted from specifying individual nodes, and ApplyParameters updates all nodes within the instance.
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/memcache/v1beta2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Memcache::V1beta2::CloudMemcache::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Memcache::V1beta2::ApplyParametersRequest.new

# Call the apply_parameters method.
result = client.apply_parameters 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

#apply_software_update

def apply_software_update(request, options = nil) -> ::Gapic::Operation
def apply_software_update(instance: nil, node_ids: nil, apply_all: nil) -> ::Gapic::Operation

Updates software on the selected nodes of the Instance.

Overloads
def apply_software_update(request, options = nil) -> ::Gapic::Operation
Pass arguments to apply_software_update via a request object, either of type ApplySoftwareUpdateRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Memcache::V1beta2::ApplySoftwareUpdateRequest, ::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 apply_software_update(instance: nil, node_ids: nil, apply_all: nil) -> ::Gapic::Operation
Pass arguments to apply_software_update 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 (::String) — Required. Resource name of the Memcached instance for which software update should be applied.
  • node_ids (::Array<::String>) — Nodes to which we should apply the update to. Note all the selected nodes are updated in parallel.
  • apply_all (::Boolean) — Whether to apply the update to all nodes. If set to true, will explicitly restrict users from specifying any nodes, and apply software update to all nodes (where applicable) within the instance.
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/memcache/v1beta2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Memcache::V1beta2::CloudMemcache::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Memcache::V1beta2::ApplySoftwareUpdateRequest.new

# Call the apply_software_update method.
result = client.apply_software_update 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

#configure

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

Configure the CloudMemcache 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, resource: nil) -> ::Gapic::Operation

Creates a new Instance in a given location.

Overloads
def create_instance(request, options = nil) -> ::Gapic::Operation
Pass arguments to create_instance via a request object, either of type Google::Cloud::Memcache::V1beta2::CreateInstanceRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Memcache::V1beta2::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, resource: 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 resource name of the instance location using the form: projects/{project_id}/locations/{location_id} where location_id refers to a GCP region
  • instance_id (::String) — Required. The logical name of the Memcached instance in the user project with the following restrictions:

    • Must contain only lowercase letters, numbers, and hyphens.
    • Must start with a letter.
    • Must be between 1-40 characters.
    • Must end with a number or a letter.
    • Must be unique within the user project / location.

    If any of the above are not met, the API raises an invalid argument error.

  • resource (::Google::Cloud::Memcache::V1beta2::Instance, ::Hash) — Required. A Memcached [Instance] resource
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/memcache/v1beta2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Memcache::V1beta2::CloudMemcache::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Memcache::V1beta2::CreateInstanceRequest.new

# Call the create_instance method.
result = client.create_instance 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

#delete_instance

def delete_instance(request, options = nil) -> ::Gapic::Operation
def delete_instance(name: nil) -> ::Gapic::Operation

Deletes a single Instance.

Overloads
def delete_instance(request, options = nil) -> ::Gapic::Operation
Pass arguments to delete_instance via a request object, either of type DeleteInstanceRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Memcache::V1beta2::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) -> ::Gapic::Operation
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. Memcached instance resource name in the format: projects/{project_id}/locations/{location_id}/instances/{instance_id} where location_id refers to a GCP region
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/memcache/v1beta2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Memcache::V1beta2::CloudMemcache::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Memcache::V1beta2::DeleteInstanceRequest.new

# Call the delete_instance method.
result = client.delete_instance 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_instance

def get_instance(request, options = nil) -> ::Google::Cloud::Memcache::V1beta2::Instance
def get_instance(name: nil) -> ::Google::Cloud::Memcache::V1beta2::Instance

Gets details of a single Instance.

Overloads
def get_instance(request, options = nil) -> ::Google::Cloud::Memcache::V1beta2::Instance
Pass arguments to get_instance via a request object, either of type GetInstanceRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Memcache::V1beta2::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) -> ::Google::Cloud::Memcache::V1beta2::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).
Parameter
  • name (::String) — Required. Memcached instance resource name in the format: projects/{project_id}/locations/{location_id}/instances/{instance_id} where location_id refers to a GCP region
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/memcache/v1beta2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Memcache::V1beta2::CloudMemcache::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Memcache::V1beta2::GetInstanceRequest.new

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

# The returned object is of type Google::Cloud::Memcache::V1beta2::Instance.
p result

#initialize

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

Create a new CloudMemcache client object.

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

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

#list_instances

def list_instances(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Memcache::V1beta2::Instance>
def list_instances(parent: nil, page_size: nil, page_token: nil, filter: nil, order_by: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Memcache::V1beta2::Instance>

Lists Instances in a given location.

Overloads
def list_instances(request, options = nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Memcache::V1beta2::Instance>
Pass arguments to list_instances via a request object, either of type ListInstancesRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Memcache::V1beta2::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, order_by: nil) -> ::Gapic::PagedEnumerable<::Google::Cloud::Memcache::V1beta2::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 resource name of the instance location using the form: projects/{project_id}/locations/{location_id} where location_id refers to a GCP region
  • page_size (::Integer) — The maximum number of items to return.

    If not specified, a default value of 1000 will be used by the service. Regardless of the page_size value, the response may include a partial list and a caller should only rely on response's next_page_token to determine if there are more instances left to be queried.

  • page_token (::String) — The next_page_token value returned from a previous List request, if any.
  • filter (::String) — List filter. For example, exclude all Memcached instances with name as my-instance by specifying "name != my-instance".
  • order_by (::String) — Sort results. Supported values are "name", "name desc" or "" (unsorted).
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/memcache/v1beta2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Memcache::V1beta2::CloudMemcache::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Memcache::V1beta2::ListInstancesRequest.new

# Call the list_instances method.
result = client.list_instances 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::Memcache::V1beta2::Instance.
  p item
end

#location_client

def location_client() -> Google::Cloud::Location::Locations::Client

Get the associated client for mix-in of the Locations.

Returns
  • (Google::Cloud::Location::Locations::Client)

#operations_client

def operations_client() -> ::Google::Cloud::Memcache::V1beta2::CloudMemcache::Operations

Get the associated client for long-running operations.

#reschedule_maintenance

def reschedule_maintenance(request, options = nil) -> ::Gapic::Operation
def reschedule_maintenance(instance: nil, reschedule_type: nil, schedule_time: nil) -> ::Gapic::Operation

Performs the apply phase of the RescheduleMaintenance verb.

Overloads
def reschedule_maintenance(request, options = nil) -> ::Gapic::Operation
Pass arguments to reschedule_maintenance via a request object, either of type RescheduleMaintenanceRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Memcache::V1beta2::RescheduleMaintenanceRequest, ::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 reschedule_maintenance(instance: nil, reschedule_type: nil, schedule_time: nil) -> ::Gapic::Operation
Pass arguments to reschedule_maintenance 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 (::String) — Required. Memcache instance resource name using the form: projects/{project_id}/locations/{location_id}/instances/{instance_id} where location_id refers to a GCP region.
  • reschedule_type (::Google::Cloud::Memcache::V1beta2::RescheduleMaintenanceRequest::RescheduleType) — Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well.
  • schedule_time (::Google::Protobuf::Timestamp, ::Hash) — Timestamp when the maintenance shall be rescheduled to if reschedule_type=SPECIFIC_TIME, in RFC 3339 format, for example 2012-11-15T16:19:00.094Z.
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/memcache/v1beta2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Memcache::V1beta2::CloudMemcache::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Memcache::V1beta2::RescheduleMaintenanceRequest.new

# Call the reschedule_maintenance method.
result = client.reschedule_maintenance 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

#update_instance

def update_instance(request, options = nil) -> ::Gapic::Operation
def update_instance(update_mask: nil, resource: nil) -> ::Gapic::Operation

Updates an existing Instance in a given project and location.

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::Memcache::V1beta2::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(update_mask: nil, resource: 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/memcache/v1beta2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Memcache::V1beta2::CloudMemcache::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Memcache::V1beta2::UpdateInstanceRequest.new

# Call the update_instance method.
result = client.update_instance 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

#update_parameters

def update_parameters(request, options = nil) -> ::Gapic::Operation
def update_parameters(name: nil, update_mask: nil, parameters: nil) -> ::Gapic::Operation

Updates the defined Memcached parameters for an existing instance. This method only stages the parameters, it must be followed by ApplyParameters to apply the parameters to nodes of the Memcached instance.

Overloads
def update_parameters(request, options = nil) -> ::Gapic::Operation
Pass arguments to update_parameters via a request object, either of type UpdateParametersRequest or an equivalent Hash.
Parameters
  • request (::Google::Cloud::Memcache::V1beta2::UpdateParametersRequest, ::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_parameters(name: nil, update_mask: nil, parameters: nil) -> ::Gapic::Operation
Pass arguments to update_parameters 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/memcache/v1beta2"

# Create a client object. The client can be reused for multiple calls.
client = Google::Cloud::Memcache::V1beta2::CloudMemcache::Client.new

# Create a request. To set request fields, pass in keyword arguments.
request = Google::Cloud::Memcache::V1beta2::UpdateParametersRequest.new

# Call the update_parameters method.
result = client.update_parameters 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