Skip to content

Commit

Permalink
feat(redis-v1beta1): Add support for GetInstanceAuthString and Resche…
Browse files Browse the repository at this point in the history
…duleMaintenance
  • Loading branch information
gcf-owl-bot[bot] committed Jan 21, 2022
1 parent d027617 commit 9a976e7
Show file tree
Hide file tree
Showing 11 changed files with 773 additions and 29 deletions.
4 changes: 4 additions & 0 deletions google-cloud-redis-v1beta1/.owlbot-manifest.json
Expand Up @@ -33,14 +33,18 @@
"proto_docs/google/protobuf/field_mask.rb",
"proto_docs/google/protobuf/timestamp.rb",
"proto_docs/google/rpc/status.rb",
"proto_docs/google/type/dayofweek.rb",
"proto_docs/google/type/timeofday.rb",
"snippets/Gemfile",
"snippets/cloud_redis/create_instance.rb",
"snippets/cloud_redis/delete_instance.rb",
"snippets/cloud_redis/export_instance.rb",
"snippets/cloud_redis/failover_instance.rb",
"snippets/cloud_redis/get_instance.rb",
"snippets/cloud_redis/get_instance_auth_string.rb",
"snippets/cloud_redis/import_instance.rb",
"snippets/cloud_redis/list_instances.rb",
"snippets/cloud_redis/reschedule_maintenance.rb",
"snippets/cloud_redis/update_instance.rb",
"snippets/cloud_redis/upgrade_instance.rb",
"test/google/cloud/redis/v1beta1/cloud_redis_operations_test.rb",
Expand Down
10 changes: 10 additions & 0 deletions google-cloud-redis-v1beta1/gapic_metadata.json
Expand Up @@ -20,6 +20,11 @@
"get_instance"
]
},
"GetInstanceAuthString": {
"methods": [
"get_instance_auth_string"
]
},
"CreateInstance": {
"methods": [
"create_instance"
Expand Down Expand Up @@ -54,6 +59,11 @@
"methods": [
"delete_instance"
]
},
"RescheduleMaintenance": {
"methods": [
"reschedule_maintenance"
]
}
}
}
Expand Down
Expand Up @@ -82,6 +82,8 @@ def self.configure

default_config.rpcs.get_instance.timeout = 600.0

default_config.rpcs.get_instance_auth_string.timeout = 600.0

default_config.rpcs.create_instance.timeout = 600.0

default_config.rpcs.update_instance.timeout = 600.0
Expand Down Expand Up @@ -229,8 +231,7 @@ def initialize
# to determine if there are more instances left to be queried.
# @param page_token [::String]
# The `next_page_token` value returned from a previous
# {::Google::Cloud::Redis::V1beta1::CloudRedis::Client#list_instances ListInstances}
# request, if any.
# {::Google::Cloud::Redis::V1beta1::CloudRedis::Client#list_instances ListInstances} request, if any.
#
# @yield [response, operation] Access the result along with the RPC operation
# @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Redis::V1beta1::Instance>]
Expand Down Expand Up @@ -390,6 +391,95 @@ def get_instance request, options = nil
raise ::Google::Cloud::Error.from_error(e)
end

##
# Gets the AUTH string for a Redis instance. If AUTH is not enabled for the
# instance the response will be empty. This information is not included in
# the details returned to GetInstance.
#
# @overload get_instance_auth_string(request, options = nil)
# Pass arguments to `get_instance_auth_string` via a request object, either of type
# {::Google::Cloud::Redis::V1beta1::GetInstanceAuthStringRequest} or an equivalent Hash.
#
# @param request [::Google::Cloud::Redis::V1beta1::GetInstanceAuthStringRequest, ::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 get_instance_auth_string(name: nil)
# Pass arguments to `get_instance_auth_string` 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. Redis instance resource name using the form:
# `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
# where `location_id` refers to a GCP region.
#
# @yield [response, operation] Access the result along with the RPC operation
# @yieldparam response [::Google::Cloud::Redis::V1beta1::InstanceAuthString]
# @yieldparam operation [::GRPC::ActiveCall::Operation]
#
# @return [::Google::Cloud::Redis::V1beta1::InstanceAuthString]
#
# @raise [::Google::Cloud::Error] if the RPC is aborted.
#
# @example Basic example
# require "google/cloud/redis/v1beta1"
#
# # Create a client object. The client can be reused for multiple calls.
# client = Google::Cloud::Redis::V1beta1::CloudRedis::Client.new
#
# # Create a request. To set request fields, pass in keyword arguments.
# request = Google::Cloud::Redis::V1beta1::GetInstanceAuthStringRequest.new
#
# # Call the get_instance_auth_string method.
# result = client.get_instance_auth_string request
#
# # The returned object is of type Google::Cloud::Redis::V1beta1::InstanceAuthString.
# p result
#
def get_instance_auth_string request, options = nil
raise ::ArgumentError, "request must be provided" if request.nil?

request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Redis::V1beta1::GetInstanceAuthStringRequest

# 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.get_instance_auth_string.metadata.to_h

# Set x-goog-api-client and x-goog-user-project 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::Redis::V1beta1::VERSION
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.get_instance_auth_string.timeout,
metadata: metadata,
retry_policy: @config.rpcs.get_instance_auth_string.retry_policy

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

@cloud_redis_stub.call_rpc :get_instance_auth_string, 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

##
# Creates a Redis instance based on the specified tier and memory size.
#
Expand Down Expand Up @@ -1114,6 +1204,108 @@ def delete_instance request, options = nil
raise ::Google::Cloud::Error.from_error(e)
end

##
# Reschedule maintenance for a given instance in a given project and
# location.
#
# @overload reschedule_maintenance(request, options = nil)
# Pass arguments to `reschedule_maintenance` via a request object, either of type
# {::Google::Cloud::Redis::V1beta1::RescheduleMaintenanceRequest} or an equivalent Hash.
#
# @param request [::Google::Cloud::Redis::V1beta1::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.
# @param options [::Gapic::CallOptions, ::Hash]
# Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
#
# @overload reschedule_maintenance(name: nil, reschedule_type: nil, schedule_time: nil)
# 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).
#
# @param name [::String]
# Required. Redis instance resource name using the form:
# `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
# where `location_id` refers to a GCP region.
# @param reschedule_type [::Google::Cloud::Redis::V1beta1::RescheduleMaintenanceRequest::RescheduleType]
# Required. If reschedule type is SPECIFIC_TIME, must set up schedule_time as well.
# @param schedule_time [::Google::Protobuf::Timestamp, ::Hash]
# Optional. 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`.
#
# @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/redis/v1beta1"
#
# # Create a client object. The client can be reused for multiple calls.
# client = Google::Cloud::Redis::V1beta1::CloudRedis::Client.new
#
# # Create a request. To set request fields, pass in keyword arguments.
# request = Google::Cloud::Redis::V1beta1::RescheduleMaintenanceRequest.new
#
# # Call the reschedule_maintenance method.
# result = client.reschedule_maintenance 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
#
def reschedule_maintenance request, options = nil
raise ::ArgumentError, "request must be provided" if request.nil?

request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Redis::V1beta1::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
metadata = @config.rpcs.reschedule_maintenance.metadata.to_h

# Set x-goog-api-client and x-goog-user-project 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::Redis::V1beta1::VERSION
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.reschedule_maintenance.timeout,
metadata: metadata,
retry_policy: @config.rpcs.reschedule_maintenance.retry_policy

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

@cloud_redis_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

##
# Configuration class for the CloudRedis API.
#
Expand Down Expand Up @@ -1260,6 +1452,11 @@ class Rpcs
#
attr_reader :get_instance
##
# RPC-specific configuration for `get_instance_auth_string`
# @return [::Gapic::Config::Method]
#
attr_reader :get_instance_auth_string
##
# RPC-specific configuration for `create_instance`
# @return [::Gapic::Config::Method]
#
Expand Down Expand Up @@ -1294,13 +1491,20 @@ class Rpcs
# @return [::Gapic::Config::Method]
#
attr_reader :delete_instance
##
# RPC-specific configuration for `reschedule_maintenance`
# @return [::Gapic::Config::Method]
#
attr_reader :reschedule_maintenance

# @private
def initialize parent_rpcs = nil
list_instances_config = parent_rpcs.list_instances if parent_rpcs.respond_to? :list_instances
@list_instances = ::Gapic::Config::Method.new list_instances_config
get_instance_config = parent_rpcs.get_instance if parent_rpcs.respond_to? :get_instance
@get_instance = ::Gapic::Config::Method.new get_instance_config
get_instance_auth_string_config = parent_rpcs.get_instance_auth_string if parent_rpcs.respond_to? :get_instance_auth_string
@get_instance_auth_string = ::Gapic::Config::Method.new get_instance_auth_string_config
create_instance_config = parent_rpcs.create_instance if parent_rpcs.respond_to? :create_instance
@create_instance = ::Gapic::Config::Method.new create_instance_config
update_instance_config = parent_rpcs.update_instance if parent_rpcs.respond_to? :update_instance
Expand All @@ -1315,6 +1519,8 @@ def initialize parent_rpcs = nil
@failover_instance = ::Gapic::Config::Method.new failover_instance_config
delete_instance_config = parent_rpcs.delete_instance if parent_rpcs.respond_to? :delete_instance
@delete_instance = ::Gapic::Config::Method.new delete_instance_config
reschedule_maintenance_config = parent_rpcs.reschedule_maintenance if parent_rpcs.respond_to? :reschedule_maintenance
@reschedule_maintenance = ::Gapic::Config::Method.new reschedule_maintenance_config

yield self if block_given?
end
Expand Down

0 comments on commit 9a976e7

Please sign in to comment.