class Google::Cloud::PubSub::V1::SchemaService::Client
Client
for the SchemaService
service.
Service
for doing schema-related operations.
Attributes
@private
Public Class Methods
Configure the SchemaService
Client
class.
See {::Google::Cloud::PubSub::V1::SchemaService::Client::Configuration} for a description of the configuration fields.
@example
# Modify the configuration for all SchemaService clients ::Google::Cloud::PubSub::V1::SchemaService::Client.configure do |config| config.timeout = 10.0 end
@yield [config] Configure the Client
client. @yieldparam config [Client::Configuration]
@return [Client::Configuration]
# File lib/google/cloud/pubsub/v1/schema_service/client.rb, line 56 def self.configure @configure ||= begin namespace = ["Google", "Cloud", "PubSub", "V1"] 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 end yield @configure if block_given? @configure end
Create a new SchemaService
client object.
@example
# Create a client using the default configuration client = ::Google::Cloud::PubSub::V1::SchemaService::Client.new # Create a client using a custom configuration client = ::Google::Cloud::PubSub::V1::SchemaService::Client.new do |config| config.timeout = 10.0 end
@yield [config] Configure the SchemaService
client. @yieldparam config [Client::Configuration]
# File lib/google/cloud/pubsub/v1/schema_service/client.rb, line 109 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/pubsub/v1/schema_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 == Client.configure.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 @schema_service_stub = ::Gapic::ServiceStub.new( ::Google::Cloud::PubSub::V1::SchemaService::Stub, credentials: credentials, endpoint: @config.endpoint, channel_args: @config.channel_args, interceptors: @config.interceptors ) end
Public Instance Methods
Configure the SchemaService
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 {::Google::Cloud::PubSub::V1::SchemaService::Client::Configuration} for a description of the configuration fields.
@yield [config] Configure the Client
client. @yieldparam config [Client::Configuration]
@return [Client::Configuration]
# File lib/google/cloud/pubsub/v1/schema_service/client.rb, line 88 def configure yield @config if block_given? @config end
Creates a schema.
@overload create_schema
(request, options = nil)
Pass arguments to `create_schema` via a request object, either of type {::Google::Cloud::PubSub::V1::CreateSchemaRequest} or an equivalent Hash. @param request [::Google::Cloud::PubSub::V1::CreateSchemaRequest, ::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 create_schema
(parent: nil, schema: nil, schema_id: nil)
Pass arguments to `create_schema` 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 parent [::String] Required. The name of the project in which to create the schema. Format is `projects/{project-id}`. @param schema [::Google::Cloud::PubSub::V1::Schema, ::Hash] Required. The schema object to create. This schema's `name` parameter is ignored. The schema object returned by CreateSchema will have a `name` made using the given `parent` and `schema_id`. @param schema_id [::String] The ID to use for the schema, which will become the final component of the schema's resource name. See https://cloud.google.com/pubsub/docs/admin#resource_names for resource name constraints.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::PubSub::V1::Schema] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::PubSub::V1::Schema]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/pubsub/v1/schema_service/client.rb, line 189 def create_schema request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::CreateSchemaRequest # 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.create_schema.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::PubSub::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "parent" => request.parent } 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.create_schema.timeout, metadata: metadata, retry_policy: @config.rpcs.create_schema.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @schema_service_stub.call_rpc :create_schema, 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
Deletes a schema.
@overload delete_schema
(request, options = nil)
Pass arguments to `delete_schema` via a request object, either of type {::Google::Cloud::PubSub::V1::DeleteSchemaRequest} or an equivalent Hash. @param request [::Google::Cloud::PubSub::V1::DeleteSchemaRequest, ::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 delete_schema
(name: nil)
Pass arguments to `delete_schema` 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. Name of the schema to delete. Format is `projects/{project}/schemas/{schema}`.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Protobuf::Empty] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Protobuf::Empty]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/pubsub/v1/schema_service/client.rb, line 411 def delete_schema request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::DeleteSchemaRequest # 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.delete_schema.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::PubSub::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } 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.delete_schema.timeout, metadata: metadata, retry_policy: @config.rpcs.delete_schema.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @schema_service_stub.call_rpc :delete_schema, 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
Gets a schema.
@overload get_schema
(request, options = nil)
Pass arguments to `get_schema` via a request object, either of type {::Google::Cloud::PubSub::V1::GetSchemaRequest} or an equivalent Hash. @param request [::Google::Cloud::PubSub::V1::GetSchemaRequest, ::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_schema
(name: nil, view: nil)
Pass arguments to `get_schema` 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 name of the schema to get. Format is `projects/{project}/schemas/{schema}`. @param view [::Google::Cloud::PubSub::V1::SchemaView] The set of fields to return in the response. If not set, returns a Schema with `name` and `type`, but not `definition`. Set to `FULL` to retrieve all fields.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::PubSub::V1::Schema] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::PubSub::V1::Schema]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/pubsub/v1/schema_service/client.rb, line 262 def get_schema request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::GetSchemaRequest # 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_schema.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::PubSub::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "name" => request.name } 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_schema.timeout, metadata: metadata, retry_policy: @config.rpcs.get_schema.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @schema_service_stub.call_rpc :get_schema, 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
Lists schemas in a project.
@overload list_schemas
(request, options = nil)
Pass arguments to `list_schemas` via a request object, either of type {::Google::Cloud::PubSub::V1::ListSchemasRequest} or an equivalent Hash. @param request [::Google::Cloud::PubSub::V1::ListSchemasRequest, ::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 list_schemas
(parent: nil, view: nil, page_size: nil, page_token: nil)
Pass arguments to `list_schemas` 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 parent [::String] Required. The name of the project in which to list schemas. Format is `projects/{project-id}`. @param view [::Google::Cloud::PubSub::V1::SchemaView] The set of Schema fields to return in the response. If not set, returns Schemas with `name` and `type`, but not `definition`. Set to `FULL` to retrieve all fields. @param page_size [::Integer] Maximum number of schemas to return. @param page_token [::String] The value returned by the last `ListSchemasResponse`; indicates that this is a continuation of a prior `ListSchemas` call, and that the system should return the next page of data.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Schema>] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Gapic::PagedEnumerable<::Google::Cloud::PubSub::V1::Schema>]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/pubsub/v1/schema_service/client.rb, line 341 def list_schemas request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ListSchemasRequest # 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.list_schemas.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::PubSub::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "parent" => request.parent } 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.list_schemas.timeout, metadata: metadata, retry_policy: @config.rpcs.list_schemas.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @schema_service_stub.call_rpc :list_schemas, request, options: options do |response, operation| response = ::Gapic::PagedEnumerable.new @schema_service_stub, :list_schemas, 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
Validates a message against a schema.
@overload validate_message
(request, options = nil)
Pass arguments to `validate_message` via a request object, either of type {::Google::Cloud::PubSub::V1::ValidateMessageRequest} or an equivalent Hash. @param request [::Google::Cloud::PubSub::V1::ValidateMessageRequest, ::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 validate_message
(parent: nil, name: nil, schema: nil, message: nil, encoding: nil)
Pass arguments to `validate_message` 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 parent [::String] Required. The name of the project in which to validate schemas. Format is `projects/{project-id}`. @param name [::String] Name of the schema against which to validate. Format is `projects/{project}/schemas/{schema}`. @param schema [::Google::Cloud::PubSub::V1::Schema, ::Hash] Ad-hoc schema against which to validate @param message [::String] Message to validate against the provided `schema_spec`. @param encoding [::Google::Cloud::PubSub::V1::Encoding] The encoding expected for messages
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::PubSub::V1::ValidateMessageResponse] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::PubSub::V1::ValidateMessageResponse]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/pubsub/v1/schema_service/client.rb, line 561 def validate_message request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ValidateMessageRequest # 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.validate_message.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::PubSub::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "parent" => request.parent } 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.validate_message.timeout, metadata: metadata, retry_policy: @config.rpcs.validate_message.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @schema_service_stub.call_rpc :validate_message, 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
Validates a schema.
@overload validate_schema
(request, options = nil)
Pass arguments to `validate_schema` via a request object, either of type {::Google::Cloud::PubSub::V1::ValidateSchemaRequest} or an equivalent Hash. @param request [::Google::Cloud::PubSub::V1::ValidateSchemaRequest, ::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 validate_schema
(parent: nil, schema: nil)
Pass arguments to `validate_schema` 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 parent [::String] Required. The name of the project in which to validate schemas. Format is `projects/{project-id}`. @param schema [::Google::Cloud::PubSub::V1::Schema, ::Hash] Required. The schema object to validate.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::PubSub::V1::ValidateSchemaResponse] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::PubSub::V1::ValidateSchemaResponse]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/pubsub/v1/schema_service/client.rb, line 482 def validate_schema request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::PubSub::V1::ValidateSchemaRequest # 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.validate_schema.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::PubSub::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "parent" => request.parent } 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.validate_schema.timeout, metadata: metadata, retry_policy: @config.rpcs.validate_schema.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @schema_service_stub.call_rpc :validate_schema, 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