Class: Google::Cloud::Memcache::V1beta2::CloudMemcache::Client

Inherits:
Object
  • Object
show all
Includes:
Paths
Defined in:
lib/google/cloud/memcache/v1beta2/cloud_memcache/client.rb

Overview

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

Defined Under Namespace

Classes: Configuration

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Paths

#instance_path, #location_path

Constructor Details

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

Create a new CloudMemcache client object.

Examples:


# 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

Yields:

  • (config)

    Configure the CloudMemcache client.

Yield Parameters:



157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/google/cloud/memcache/v1beta2/cloud_memcache/client.rb', line 157

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

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

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

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

  @operations_client = Operations.new do |config|
    config.credentials = credentials
    config.quota_project = @quota_project_id
    config.endpoint = @config.endpoint
    config.universe_domain = @config.universe_domain
  end

  @cloud_memcache_stub = ::Gapic::ServiceStub.new(
    ::Google::Cloud::Memcache::V1beta2::CloudMemcache::Stub,
    credentials: credentials,
    endpoint: @config.endpoint,
    endpoint_template: DEFAULT_ENDPOINT_TEMPLATE,
    universe_domain: @config.universe_domain,
    channel_args: @config.channel_args,
    interceptors: @config.interceptors,
    channel_pool_config: @config.channel_pool
  )

  @location_client = Google::Cloud::Location::Locations::Client.new do |config|
    config.credentials = credentials
    config.quota_project = @quota_project_id
    config.endpoint = @cloud_memcache_stub.endpoint
    config.universe_domain = @cloud_memcache_stub.universe_domain
  end
end

Instance Attribute Details

#location_clientGoogle::Cloud::Location::Locations::Client (readonly)

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

Returns:

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


223
224
225
# File 'lib/google/cloud/memcache/v1beta2/cloud_memcache/client.rb', line 223

def location_client
  @location_client
end

#operations_client::Google::Cloud::Memcache::V1beta2::CloudMemcache::Operations (readonly)

Get the associated client for long-running operations.



216
217
218
# File 'lib/google/cloud/memcache/v1beta2/cloud_memcache/client.rb', line 216

def operations_client
  @operations_client
end

Class Method Details

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

Configure the CloudMemcache Client class.

See Configuration for a description of the configuration fields.

Examples:


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

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/google/cloud/memcache/v1beta2/cloud_memcache/client.rb', line 77

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

    default_config.rpcs.list_instances.timeout = 1200.0

    default_config.rpcs.get_instance.timeout = 1200.0

    default_config.rpcs.create_instance.timeout = 1200.0

    default_config.rpcs.update_instance.timeout = 1200.0

    default_config.rpcs.update_parameters.timeout = 1200.0

    default_config.rpcs.delete_instance.timeout = 1200.0

    default_config.rpcs.apply_parameters.timeout = 1200.0

    default_config.rpcs.apply_software_update.timeout = 1200.0

    default_config.rpcs.reschedule_maintenance.timeout = 1200.0

    default_config
  end
  yield @configure if block_given?
  @configure
end

Instance Method Details

#apply_parameters(request, options = nil) ⇒ ::Gapic::Operation #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.

Examples:

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

Overloads:

  • #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) (defaults to: nil)

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

  • #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) (defaults to: nil)

      Required. Resource name of the Memcached instance for which parameter group updates should be applied.

    • node_ids (::Array<::String>) (defaults to: nil)

      Nodes to which the instance-level parameter group is applied.

    • apply_all (::Boolean) (defaults to: nil)

      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.



888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
# File 'lib/google/cloud/memcache/v1beta2/cloud_memcache/client.rb', line 888

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

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Memcache::V1beta2::ApplyParametersRequest

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

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

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

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

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

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

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

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

#apply_software_update(request, options = nil) ⇒ ::Gapic::Operation #apply_software_update(instance: nil, node_ids: nil, apply_all: nil) ⇒ ::Gapic::Operation

Updates software on the selected nodes of the Instance.

Examples:

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

Overloads:

  • #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) (defaults to: nil)

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

  • #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) (defaults to: nil)

      Required. Resource name of the Memcached instance for which software update should be applied.

    • node_ids (::Array<::String>) (defaults to: nil)

      Nodes to which we should apply the update to. Note all the selected nodes are updated in parallel.

    • apply_all (::Boolean) (defaults to: nil)

      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.



990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
# File 'lib/google/cloud/memcache/v1beta2/cloud_memcache/client.rb', line 990

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

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Memcache::V1beta2::ApplySoftwareUpdateRequest

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

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

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

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

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

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

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

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

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

Configure the 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 configure.

See Configuration for a description of the configuration fields.

Yields:

  • (config)

    Configure the Client client.

Yield Parameters:

Returns:



127
128
129
130
# File 'lib/google/cloud/memcache/v1beta2/cloud_memcache/client.rb', line 127

def configure
  yield @config if block_given?
  @config
end

#create_instance(request, options = nil) ⇒ ::Gapic::Operation #create_instance(parent: nil, instance_id: nil, resource: nil) ⇒ ::Gapic::Operation

Creates a new Instance in a given location.

Examples:

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

Overloads:

  • #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) (defaults to: nil)

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

  • #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) (defaults to: nil)

      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) (defaults to: nil)

      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) (defaults to: nil)

      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.



489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
# File 'lib/google/cloud/memcache/v1beta2/cloud_memcache/client.rb', line 489

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

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Memcache::V1beta2::CreateInstanceRequest

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

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

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

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

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

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

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

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

#delete_instance(request, options = nil) ⇒ ::Gapic::Operation #delete_instance(name: nil) ⇒ ::Gapic::Operation

Deletes a single Instance.

Examples:

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

Overloads:

  • #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) (defaults to: nil)

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

  • #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).

    Parameters:

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

      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.



786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
# File 'lib/google/cloud/memcache/v1beta2/cloud_memcache/client.rb', line 786

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

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Memcache::V1beta2::DeleteInstanceRequest

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

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

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

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

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

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

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

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

#get_instance(request, options = nil) ⇒ ::Google::Cloud::Memcache::V1beta2::Instance #get_instance(name: nil) ⇒ ::Google::Cloud::Memcache::V1beta2::Instance

Gets details of a single Instance.

Examples:

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

Overloads:

  • #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) (defaults to: nil)

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

  • #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).

    Parameters:

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

      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:

Returns:

Raises:

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

    if the RPC is aborted.



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

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

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Memcache::V1beta2::GetInstanceRequest

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

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

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

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

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

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

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

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

#list_instances(request, options = nil) ⇒ ::Gapic::PagedEnumerable<::Google::Cloud::Memcache::V1beta2::Instance> #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.

Examples:

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

Overloads:

  • #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) (defaults to: nil)

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

  • #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) (defaults to: nil)

      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) (defaults to: nil)

      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) (defaults to: nil)

      The next_page_token value returned from a previous List request, if any.

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

      List filter. For example, exclude all Memcached instances with name as my-instance by specifying "name != my-instance".

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

      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.



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

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

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Memcache::V1beta2::ListInstancesRequest

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

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

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

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

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

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

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

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

#reschedule_maintenance(request, options = nil) ⇒ ::Gapic::Operation #reschedule_maintenance(instance: nil, reschedule_type: nil, schedule_time: nil) ⇒ ::Gapic::Operation

Performs the apply phase of the RescheduleMaintenance verb.

Examples:

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

Overloads:

  • #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) (defaults to: nil)

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

  • #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) (defaults to: nil)

      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) (defaults to: nil)

      Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well.

    • schedule_time (::Google::Protobuf::Timestamp, ::Hash) (defaults to: nil)

      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.



1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
# File 'lib/google/cloud/memcache/v1beta2/cloud_memcache/client.rb', line 1092

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

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Memcache::V1beta2::RescheduleMaintenanceRequest

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

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

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

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

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

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

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

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

#universe_domainString

The effective universe domain

Returns:

  • (String)


137
138
139
# File 'lib/google/cloud/memcache/v1beta2/cloud_memcache/client.rb', line 137

def universe_domain
  @cloud_memcache_stub.universe_domain
end

#update_instance(request, options = nil) ⇒ ::Gapic::Operation #update_instance(update_mask: nil, resource: nil) ⇒ ::Gapic::Operation

Updates an existing Instance in a given project and location.

Examples:

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

Overloads:

  • #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) (defaults to: nil)

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

  • #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.



588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
# File 'lib/google/cloud/memcache/v1beta2/cloud_memcache/client.rb', line 588

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

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Memcache::V1beta2::UpdateInstanceRequest

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

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

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

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

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

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

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

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

#update_parameters(request, options = nil) ⇒ ::Gapic::Operation #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.

Examples:

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

Overloads:

  • #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) (defaults to: nil)

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

  • #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.



690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
# File 'lib/google/cloud/memcache/v1beta2/cloud_memcache/client.rb', line 690

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

  request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Memcache::V1beta2::UpdateParametersRequest

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

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

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

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

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

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

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

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