Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions google-cloud-memorystore-v1/.owlbot-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"snippets/memorystore/delete_backup.rb",
"snippets/memorystore/delete_instance.rb",
"snippets/memorystore/export_backup.rb",
"snippets/memorystore/finish_migration.rb",
"snippets/memorystore/get_backup.rb",
"snippets/memorystore/get_backup_collection.rb",
"snippets/memorystore/get_certificate_authority.rb",
Expand All @@ -60,6 +61,7 @@
"snippets/memorystore/list_backups.rb",
"snippets/memorystore/list_instances.rb",
"snippets/memorystore/reschedule_maintenance.rb",
"snippets/memorystore/start_migration.rb",
"snippets/memorystore/update_instance.rb",
"snippets/snippet_metadata_google.cloud.memorystore.v1.json",
"test/google/cloud/memorystore/v1/memorystore_operations_test.rb",
Expand Down
10 changes: 10 additions & 0 deletions google-cloud-memorystore-v1/gapic_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@
"methods": [
"backup_instance"
]
},
"StartMigration": {
"methods": [
"start_migration"
]
},
"FinishMigration": {
"methods": [
"finish_migration"
]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1073,11 +1073,11 @@ def reschedule_maintenance request, options = nil
# 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
# {::Google::Cloud::Memorystore::V1::ListBackupCollectionsResponse#next_page_token `next_page_token`}
# `next_page_token`
# to determine if there are more clusters left to be queried.
# @param page_token [::String]
# Optional. The `next_page_token` value returned from a previous
# [ListBackupCollections] request, if any.
# `ListBackupCollections` request, if any.
#
# @yield [response, operation] Access the result along with the RPC operation
# @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Memorystore::V1::BackupCollection>]
Expand Down Expand Up @@ -1263,11 +1263,11 @@ def get_backup_collection request, options = nil
# 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
# {::Google::Cloud::Memorystore::V1::ListBackupsResponse#next_page_token `next_page_token`}
# `next_page_token`
# to determine if there are more clusters left to be queried.
# @param page_token [::String]
# Optional. The `next_page_token` value returned from a previous
# [ListBackupCollections] request, if any.
# `ListBackupCollections` request, if any.
#
# @yield [response, operation] Access the result along with the RPC operation
# @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Memorystore::V1::Backup>]
Expand Down Expand Up @@ -1732,6 +1732,215 @@ def backup_instance request, options = nil
raise ::Google::Cloud::Error.from_error(e)
end

##
# Initiates the migration of a source instance to the target Memorystore
# instance.
#
# After the successful completion of this operation, the target instance
# will:
# 1. Set up replication with the source instance and replicate any writes to
# the source instance.
# 2. Only allow reads.
#
# @overload start_migration(request, options = nil)
# Pass arguments to `start_migration` via a request object, either of type
# {::Google::Cloud::Memorystore::V1::StartMigrationRequest} or an equivalent Hash.
#
# @param request [::Google::Cloud::Memorystore::V1::StartMigrationRequest, ::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.
# @param options [::Gapic::CallOptions, ::Hash]
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
#
# @overload start_migration(self_managed_source: nil, name: nil)
# Pass arguments to `start_migration` 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).
#
# @param self_managed_source [::Google::Cloud::Memorystore::V1::SelfManagedSource, ::Hash]
# Required. Configuration for migrating from a self-managed Valkey/Redis
# instance
# @param name [::String]
# Required. The resource name of the instance to start migration on.
# Format: projects/\\{project}/locations/\\{location}/instances/\\{instance}
#
# @yield [response, operation] Access the result along with the RPC operation
# @yieldparam response [::Gapic::Operation]
# @yieldparam operation [::GRPC::ActiveCall::Operation]
#
# @return [::Gapic::Operation]
#
# @raise [::Google::Cloud::Error] if the RPC is aborted.
#
# @example Basic example
# require "google/cloud/memorystore/v1"
#
# # Create a client object. The client can be reused for multiple calls.
# client = Google::Cloud::Memorystore::V1::Memorystore::Client.new
#
# # Create a request. To set request fields, pass in keyword arguments.
# request = Google::Cloud::Memorystore::V1::StartMigrationRequest.new
#
# # Call the start_migration method.
# result = client.start_migration 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
#
def start_migration request, options = nil
raise ::ArgumentError, "request must be provided" if request.nil?

request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Memorystore::V1::StartMigrationRequest

# 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
metadata = @config.rpcs.start_migration.metadata.to_h

# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
lib_name: @config.lib_name, lib_version: @config.lib_version,
gapic_version: ::Google::Cloud::Memorystore::V1::VERSION
metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
metadata[:"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("&")
metadata[:"x-goog-request-params"] ||= request_params_header

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

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

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

##
# Finalizes the migration process.
#
# After the successful completion of this operation, the target instance
# will:
# 1. Stop replicating from the source instance.
# 2. Allow both reads and writes.
#
# @overload finish_migration(request, options = nil)
# Pass arguments to `finish_migration` via a request object, either of type
# {::Google::Cloud::Memorystore::V1::FinishMigrationRequest} or an equivalent Hash.
#
# @param request [::Google::Cloud::Memorystore::V1::FinishMigrationRequest, ::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.
# @param options [::Gapic::CallOptions, ::Hash]
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
#
# @overload finish_migration(name: nil, force: nil)
# Pass arguments to `finish_migration` 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).
#
# @param name [::String]
# Required. The resource name of the instance to finalize migration on.
# Format: projects/\\{project}/locations/\\{location}/instances/\\{instance}
# @param force [::Boolean]
# Optional. By default, the `FinishMigration` operation ensures the target
# replication offset to catch up to the source offset as of the time of the
# call. Set this field to `true` to bypass this offset verification check.
#
# @yield [response, operation] Access the result along with the RPC operation
# @yieldparam response [::Gapic::Operation]
# @yieldparam operation [::GRPC::ActiveCall::Operation]
#
# @return [::Gapic::Operation]
#
# @raise [::Google::Cloud::Error] if the RPC is aborted.
#
# @example Basic example
# require "google/cloud/memorystore/v1"
#
# # Create a client object. The client can be reused for multiple calls.
# client = Google::Cloud::Memorystore::V1::Memorystore::Client.new
#
# # Create a request. To set request fields, pass in keyword arguments.
# request = Google::Cloud::Memorystore::V1::FinishMigrationRequest.new
#
# # Call the finish_migration method.
# result = client.finish_migration 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
#
def finish_migration request, options = nil
raise ::ArgumentError, "request must be provided" if request.nil?

request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Memorystore::V1::FinishMigrationRequest

# 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
metadata = @config.rpcs.finish_migration.metadata.to_h

# Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers
metadata[:"x-goog-api-client"] ||= ::Gapic::Headers.x_goog_api_client \
lib_name: @config.lib_name, lib_version: @config.lib_version,
gapic_version: ::Google::Cloud::Memorystore::V1::VERSION
metadata[:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty?
metadata[:"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("&")
metadata[:"x-goog-request-params"] ||= request_params_header

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

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

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

##
# Configuration class for the Memorystore API.
#
Expand Down Expand Up @@ -1992,6 +2201,16 @@ class Rpcs
# @return [::Gapic::Config::Method]
#
attr_reader :backup_instance
##
# RPC-specific configuration for `start_migration`
# @return [::Gapic::Config::Method]
#
attr_reader :start_migration
##
# RPC-specific configuration for `finish_migration`
# @return [::Gapic::Config::Method]
#
attr_reader :finish_migration

# @private
def initialize parent_rpcs = nil
Expand Down Expand Up @@ -2025,6 +2244,10 @@ def initialize parent_rpcs = nil
@export_backup = ::Gapic::Config::Method.new export_backup_config
backup_instance_config = parent_rpcs.backup_instance if parent_rpcs.respond_to? :backup_instance
@backup_instance = ::Gapic::Config::Method.new backup_instance_config
start_migration_config = parent_rpcs.start_migration if parent_rpcs.respond_to? :start_migration
@start_migration = ::Gapic::Config::Method.new start_migration_config
finish_migration_config = parent_rpcs.finish_migration if parent_rpcs.respond_to? :finish_migration
@finish_migration = ::Gapic::Config::Method.new finish_migration_config

yield self if block_given?
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ module Memorystore
# Credentials for the Memorystore API.
class Credentials < ::Google::Auth::Credentials
self.scope = [
"https://www.googleapis.com/auth/cloud-platform"
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/memorystore.read-only",
"https://www.googleapis.com/auth/memorystore.read-write"
]
self.env_vars = [
"GOOGLE_CLOUD_CREDENTIALS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,25 @@ def network_path project:, network:
"projects/#{project}/global/networks/#{network}"
end

##
# Create a fully-qualified NetworkAttachment resource string.
#
# The resource will be in the following format:
#
# `projects/{project}/regions/{region}/networkAttachments/{network_attachment}`
#
# @param project [String]
# @param region [String]
# @param network_attachment [String]
#
# @return [::String]
def network_attachment_path project:, region:, network_attachment:
raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
raise ::ArgumentError, "region cannot contain /" if region.to_s.include? "/"

"projects/#{project}/regions/#{region}/networkAttachments/#{network_attachment}"
end

##
# Create a fully-qualified ServiceAttachment resource string.
#
Expand Down
Loading
Loading