lib/google/cloud/redis/v1beta1/cloud_redis/client.rb in google-cloud-redis-v1beta1-0.5.1 vs lib/google/cloud/redis/v1beta1/cloud_redis/client.rb in google-cloud-redis-v1beta1-0.6.0

- old
+ new

@@ -80,10 +80,12 @@ default_config.rpcs.list_instances.timeout = 600.0 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 default_config.rpcs.upgrade_instance.timeout = 600.0 @@ -227,12 +229,11 @@ # and a caller should only rely on response's # {::Google::Cloud::Redis::V1beta1::ListInstancesResponse#next_page_token `next_page_token`} # 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>] # @yieldparam operation [::GRPC::ActiveCall::Operation] # @@ -389,10 +390,99 @@ rescue ::GRPC::BadStatus => e 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. # # By default, the instance is accessible from the project's # [default network](https://cloud.google.com/vpc/docs/vpc). # @@ -1113,10 +1203,112 @@ rescue ::GRPC::BadStatus => e 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. # # This class represents the configuration for CloudRedis, # providing control over timeouts, retry behavior, logging, transport # parameters, and other low-level controls. Certain parameters can also be @@ -1258,10 +1450,15 @@ # RPC-specific configuration for `get_instance` # @return [::Gapic::Config::Method] # 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] # attr_reader :create_instance ## @@ -1292,17 +1489,24 @@ ## # RPC-specific configuration for `delete_instance` # @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 @update_instance = ::Gapic::Config::Method.new update_instance_config upgrade_instance_config = parent_rpcs.upgrade_instance if parent_rpcs.respond_to? :upgrade_instance @@ -1313,9 +1517,11 @@ @export_instance = ::Gapic::Config::Method.new export_instance_config failover_instance_config = parent_rpcs.failover_instance if parent_rpcs.respond_to? :failover_instance @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 end end