class Google::Cloud::Firestore::V1::Firestore::Client
Client
for the Firestore
service.
Cloud
Firestore
is a fast, fully managed, serverless, cloud-native NoSQL document database that simplifies storing, syncing, and querying data for your mobile, web, and IoT apps at global scale. Its client libraries provide live synchronization and offline support, while its security features and integrations with Firebase and Google
Cloud
Platform (GCP) accelerate building truly serverless apps.
Attributes
@private
Public Class Methods
Configure the Firestore
Client
class.
See {::Google::Cloud::Firestore::V1::Firestore::Client::Configuration} for a description of the configuration fields.
@example
# Modify the configuration for all Firestore clients ::Google::Cloud::Firestore::V1::Firestore::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/firestore/v1/firestore/client.rb, line 61 def self.configure @configure ||= begin namespace = ["Google", "Cloud", "Firestore", "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.rpcs.get_document.timeout = 60.0 default_config.rpcs.get_document.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4] } default_config.rpcs.list_documents.timeout = 60.0 default_config.rpcs.list_documents.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4] } default_config.rpcs.update_document.timeout = 60.0 default_config.rpcs.update_document.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14] } default_config.rpcs.delete_document.timeout = 60.0 default_config.rpcs.delete_document.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4] } default_config.rpcs.batch_get_documents.timeout = 300.0 default_config.rpcs.batch_get_documents.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4] } default_config.rpcs.begin_transaction.timeout = 60.0 default_config.rpcs.begin_transaction.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4] } default_config.rpcs.commit.timeout = 60.0 default_config.rpcs.commit.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14] } default_config.rpcs.rollback.timeout = 60.0 default_config.rpcs.rollback.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4] } default_config.rpcs.run_query.timeout = 300.0 default_config.rpcs.run_query.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4] } default_config.rpcs.partition_query.timeout = 300.0 default_config.rpcs.partition_query.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4] } default_config.rpcs.write.timeout = 86_400.0 default_config.rpcs.listen.timeout = 86_400.0 default_config.rpcs.listen.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4] } default_config.rpcs.list_collection_ids.timeout = 60.0 default_config.rpcs.list_collection_ids.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 13, 4] } default_config.rpcs.batch_write.timeout = 60.0 default_config.rpcs.batch_write.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14, 10] } default_config.rpcs.create_document.timeout = 60.0 default_config.rpcs.create_document.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [8, 14] } default_config end yield @configure if block_given? @configure end
Create a new Firestore
client object.
@example
# Create a client using the default configuration client = ::Google::Cloud::Firestore::V1::Firestore::Client.new # Create a client using a custom configuration client = ::Google::Cloud::Firestore::V1::Firestore::Client.new do |config| config.timeout = 10.0 end
@yield [config] Configure the Firestore
client. @yieldparam config [Client::Configuration]
# File lib/google/cloud/firestore/v1/firestore/client.rb, line 186 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/firestore/v1/firestore_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 @firestore_stub = ::Gapic::ServiceStub.new( ::Google::Cloud::Firestore::V1::Firestore::Stub, credentials: credentials, endpoint: @config.endpoint, channel_args: @config.channel_args, interceptors: @config.interceptors ) end
Public Instance Methods
Gets multiple documents.
Documents returned by this method are not guaranteed to be returned in the same order that they were requested.
@overload batch_get_documents
(request, options = nil)
Pass arguments to `batch_get_documents` via a request object, either of type {::Google::Cloud::Firestore::V1::BatchGetDocumentsRequest} or an equivalent Hash. @param request [::Google::Cloud::Firestore::V1::BatchGetDocumentsRequest, ::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 batch_get_documents
(database: nil, documents: nil, mask: nil, transaction: nil, new_transaction: nil, read_time: nil)
Pass arguments to `batch_get_documents` 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 database [::String] Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. @param documents [::Array<::String>] The names of the documents to retrieve. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`. The request will fail if any of the document is not a child resource of the given `database`. Duplicate names will be elided. @param mask [::Google::Cloud::Firestore::V1::DocumentMask, ::Hash] The fields to return. If not set, returns all fields. If a document has a field that is not present in this mask, that field will not be returned in the response. @param transaction [::String] Reads documents in a transaction. @param new_transaction [::Google::Cloud::Firestore::V1::TransactionOptions, ::Hash] Starts a new transaction and reads the documents. Defaults to a read-only transaction. The new transaction ID will be returned as the first response in the stream. @param read_time [::Google::Protobuf::Timestamp, ::Hash] Reads documents as they were at the given time. This may not be older than 270 seconds.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Enumerable<::Google::Cloud::Firestore::V1::BatchGetDocumentsResponse>] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Enumerable<::Google::Cloud::Firestore::V1::BatchGetDocumentsResponse>]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/firestore/v1/firestore/client.rb, line 615 def batch_get_documents request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::BatchGetDocumentsRequest # 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.batch_get_documents.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::Firestore::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "database" => request.database } 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.batch_get_documents.timeout, metadata: metadata, retry_policy: @config.rpcs.batch_get_documents.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @firestore_stub.call_rpc :batch_get_documents, 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
Applies a batch of write operations.
The BatchWrite method does not apply the write operations atomically and can apply them out of order. Method does not allow more than one write per document. Each write succeeds or fails independently. See the {::Google::Cloud::Firestore::V1::BatchWriteResponse BatchWriteResponse} for the success status of each write.
If you require an atomically applied set of writes, use {::Google::Cloud::Firestore::V1::Firestore::Client#commit Commit} instead.
@overload batch_write
(request, options = nil)
Pass arguments to `batch_write` via a request object, either of type {::Google::Cloud::Firestore::V1::BatchWriteRequest} or an equivalent Hash. @param request [::Google::Cloud::Firestore::V1::BatchWriteRequest, ::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 batch_write
(database: nil, writes: nil, labels: nil)
Pass arguments to `batch_write` 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 database [::String] Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. @param writes [::Array<::Google::Cloud::Firestore::V1::Write, ::Hash>] The writes to apply. Method does not apply writes atomically and does not guarantee ordering. Each write succeeds or fails independently. You cannot write to the same document more than once per request. @param labels [::Hash{::String => ::String}] Labels associated with this batch write.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Firestore::V1::BatchWriteResponse] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Firestore::V1::BatchWriteResponse]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/firestore/v1/firestore/client.rb, line 1297 def batch_write request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::BatchWriteRequest # 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.batch_write.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::Firestore::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "database" => request.database } 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.batch_write.timeout, metadata: metadata, retry_policy: @config.rpcs.batch_write.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @firestore_stub.call_rpc :batch_write, 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
Starts a new transaction.
@overload begin_transaction
(request, options = nil)
Pass arguments to `begin_transaction` via a request object, either of type {::Google::Cloud::Firestore::V1::BeginTransactionRequest} or an equivalent Hash. @param request [::Google::Cloud::Firestore::V1::BeginTransactionRequest, ::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 begin_transaction
(database: nil, options: nil)
Pass arguments to `begin_transaction` 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 database [::String] Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. @param options [::Google::Cloud::Firestore::V1::TransactionOptions, ::Hash] The options for the transaction. Defaults to a read-write transaction.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Firestore::V1::BeginTransactionResponse] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Firestore::V1::BeginTransactionResponse]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/firestore/v1/firestore/client.rb, line 687 def begin_transaction request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::BeginTransactionRequest # 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.begin_transaction.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::Firestore::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "database" => request.database } 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.begin_transaction.timeout, metadata: metadata, retry_policy: @config.rpcs.begin_transaction.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @firestore_stub.call_rpc :begin_transaction, 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
Commits a transaction, while optionally updating documents.
@overload commit(request, options = nil)
Pass arguments to `commit` via a request object, either of type {::Google::Cloud::Firestore::V1::CommitRequest} or an equivalent Hash. @param request [::Google::Cloud::Firestore::V1::CommitRequest, ::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 commit(database: nil, writes: nil, transaction: nil)
Pass arguments to `commit` 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 database [::String] Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. @param writes [::Array<::Google::Cloud::Firestore::V1::Write, ::Hash>] The writes to apply. Always executed atomically and in order. @param transaction [::String] If set, applies all writes in this transaction, and commits it.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Firestore::V1::CommitResponse] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Firestore::V1::CommitResponse]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/firestore/v1/firestore/client.rb, line 762 def commit request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::CommitRequest # 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.commit.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::Firestore::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "database" => request.database } 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.commit.timeout, metadata: metadata, retry_policy: @config.rpcs.commit.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @firestore_stub.call_rpc :commit, 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
Configure the Firestore
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::Firestore::V1::Firestore::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/firestore/v1/firestore/client.rb, line 165 def configure yield @config if block_given? @config end
Creates a new document.
@overload create_document
(request, options = nil)
Pass arguments to `create_document` via a request object, either of type {::Google::Cloud::Firestore::V1::CreateDocumentRequest} or an equivalent Hash. @param request [::Google::Cloud::Firestore::V1::CreateDocumentRequest, ::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_document
(parent: nil, collection_id: nil, document_id: nil, document: nil, mask: nil)
Pass arguments to `create_document` 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 parent resource. For example: `projects/{project_id}/databases/{database_id}/documents` or `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` @param collection_id [::String] Required. The collection ID, relative to `parent`, to list. For example: `chatrooms`. @param document_id [::String] The client-assigned document ID to use for this document. Optional. If not specified, an ID will be assigned by the service. @param document [::Google::Cloud::Firestore::V1::Document, ::Hash] Required. The document to create. `name` must not be set. @param mask [::Google::Cloud::Firestore::V1::DocumentMask, ::Hash] The fields to return. If not set, returns all fields. If the document has a field that is not present in this mask, that field will not be returned in the response.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Firestore::V1::Document] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Firestore::V1::Document]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/firestore/v1/firestore/client.rb, line 1380 def create_document request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::CreateDocumentRequest # 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_document.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::Firestore::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "parent" => request.parent, "collection_id" => request.collection_id } 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_document.timeout, metadata: metadata, retry_policy: @config.rpcs.create_document.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @firestore_stub.call_rpc :create_document, 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 document.
@overload delete_document
(request, options = nil)
Pass arguments to `delete_document` via a request object, either of type {::Google::Cloud::Firestore::V1::DeleteDocumentRequest} or an equivalent Hash. @param request [::Google::Cloud::Firestore::V1::DeleteDocumentRequest, ::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_document
(name: nil, current_document: nil)
Pass arguments to `delete_document` 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 Document to delete. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`. @param current_document [::Google::Cloud::Firestore::V1::Precondition, ::Hash] An optional precondition on the document. The request will fail if this is set and not met by the target document.
@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/firestore/v1/firestore/client.rb, line 523 def delete_document request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::DeleteDocumentRequest # 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_document.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::Firestore::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_document.timeout, metadata: metadata, retry_policy: @config.rpcs.delete_document.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @firestore_stub.call_rpc :delete_document, 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 single document.
@overload get_document
(request, options = nil)
Pass arguments to `get_document` via a request object, either of type {::Google::Cloud::Firestore::V1::GetDocumentRequest} or an equivalent Hash. @param request [::Google::Cloud::Firestore::V1::GetDocumentRequest, ::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_document
(name: nil, mask: nil, transaction: nil, read_time: nil)
Pass arguments to `get_document` 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 Document to get. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`. @param mask [::Google::Cloud::Firestore::V1::DocumentMask, ::Hash] The fields to return. If not set, returns all fields. If the document has a field that is not present in this mask, that field will not be returned in the response. @param transaction [::String] Reads the document in a transaction. @param read_time [::Google::Protobuf::Timestamp, ::Hash] Reads the version of the document at the given time. This may not be older than 270 seconds.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Firestore::V1::Document] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Firestore::V1::Document]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/firestore/v1/firestore/client.rb, line 264 def get_document request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::GetDocumentRequest # 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_document.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::Firestore::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_document.timeout, metadata: metadata, retry_policy: @config.rpcs.get_document.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @firestore_stub.call_rpc :get_document, 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 all the collection IDs underneath a document.
@overload list_collection_ids
(request, options = nil)
Pass arguments to `list_collection_ids` via a request object, either of type {::Google::Cloud::Firestore::V1::ListCollectionIdsRequest} or an equivalent Hash. @param request [::Google::Cloud::Firestore::V1::ListCollectionIdsRequest, ::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_collection_ids
(parent: nil, page_size: nil, page_token: nil)
Pass arguments to `list_collection_ids` 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 parent document. In the format: `projects/{project_id}/databases/{database_id}/documents/{document_path}`. For example: `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` @param page_size [::Integer] The maximum number of results to return. @param page_token [::String] A page token. Must be a value from {::Google::Cloud::Firestore::V1::ListCollectionIdsResponse ListCollectionIdsResponse}.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Firestore::V1::ListCollectionIdsResponse] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Firestore::V1::ListCollectionIdsResponse]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/firestore/v1/firestore/client.rb, line 1212 def list_collection_ids request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::ListCollectionIdsRequest # 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_collection_ids.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::Firestore::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_collection_ids.timeout, metadata: metadata, retry_policy: @config.rpcs.list_collection_ids.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @firestore_stub.call_rpc :list_collection_ids, 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 documents.
@overload list_documents
(request, options = nil)
Pass arguments to `list_documents` via a request object, either of type {::Google::Cloud::Firestore::V1::ListDocumentsRequest} or an equivalent Hash. @param request [::Google::Cloud::Firestore::V1::ListDocumentsRequest, ::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_documents
(parent: nil, collection_id: nil, page_size: nil, page_token: nil, order_by: nil, mask: nil, transaction: nil, read_time: nil, show_missing: nil)
Pass arguments to `list_documents` 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 parent resource name. In the format: `projects/{project_id}/databases/{database_id}/documents` or `projects/{project_id}/databases/{database_id}/documents/{document_path}`. For example: `projects/my-project/databases/my-database/documents` or `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` @param collection_id [::String] Required. The collection ID, relative to `parent`, to list. For example: `chatrooms` or `messages`. @param page_size [::Integer] The maximum number of documents to return. @param page_token [::String] The `next_page_token` value returned from a previous List request, if any. @param order_by [::String] The order to sort results by. For example: `priority desc, name`. @param mask [::Google::Cloud::Firestore::V1::DocumentMask, ::Hash] The fields to return. If not set, returns all fields. If a document has a field that is not present in this mask, that field will not be returned in the response. @param transaction [::String] Reads documents in a transaction. @param read_time [::Google::Protobuf::Timestamp, ::Hash] Reads documents as they were at the given time. This may not be older than 270 seconds. @param show_missing [::Boolean] If the list should show missing documents. A missing document is a document that does not exist but has sub-documents. These documents will be returned with a key but will not have fields, {::Google::Cloud::Firestore::V1::Document#create_time Document.create_time}, or {::Google::Cloud::Firestore::V1::Document#update_time Document.update_time} set. Requests with `show_missing` may not specify `where` or `order_by`.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Firestore::V1::Document>] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Gapic::PagedEnumerable<::Google::Cloud::Firestore::V1::Document>]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/firestore/v1/firestore/client.rb, line 364 def list_documents request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::ListDocumentsRequest # 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_documents.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::Firestore::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "parent" => request.parent, "collection_id" => request.collection_id } 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_documents.timeout, metadata: metadata, retry_policy: @config.rpcs.list_documents.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @firestore_stub.call_rpc :list_documents, request, options: options do |response, operation| response = ::Gapic::PagedEnumerable.new @firestore_stub, :list_documents, 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
Listens to changes.
@param request [::Gapic::StreamInput, ::Enumerable<::Google::Cloud::Firestore::V1::ListenRequest, ::Hash>]
An enumerable of {::Google::Cloud::Firestore::V1::ListenRequest} instances.
@param options [::Gapic::CallOptions, ::Hash]
Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Enumerable<::Google::Cloud::Firestore::V1::ListenResponse>] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Enumerable<::Google::Cloud::Firestore::V1::ListenResponse>]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/firestore/v1/firestore/client.rb, line 1137 def listen request, options = nil unless request.is_a? ::Enumerable raise ::ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum request = request.to_enum end request = request.lazy.map do |req| ::Gapic::Protobuf.coerce req, to: ::Google::Cloud::Firestore::V1::ListenRequest end # 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.listen.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::Firestore::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id options.apply_defaults timeout: @config.rpcs.listen.timeout, metadata: metadata, retry_policy: @config.rpcs.listen.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @firestore_stub.call_rpc :listen, 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
Partitions a query by returning partition cursors that can be used to run the query in parallel. The returned partition cursors are split points that can be used by RunQuery as starting/end points for the query results.
@overload partition_query
(request, options = nil)
Pass arguments to `partition_query` via a request object, either of type {::Google::Cloud::Firestore::V1::PartitionQueryRequest} or an equivalent Hash. @param request [::Google::Cloud::Firestore::V1::PartitionQueryRequest, ::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 partition_query
(parent: nil, structured_query: nil, partition_count: nil, page_token: nil, page_size: nil)
Pass arguments to `partition_query` 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 parent resource name. In the format: `projects/{project_id}/databases/{database_id}/documents`. Document resource names are not supported; only database resource names can be specified. @param structured_query [::Google::Cloud::Firestore::V1::StructuredQuery, ::Hash] A structured query. Query must specify collection with all descendants and be ordered by name ascending. Other filters, order bys, limits, offsets, and start/end cursors are not supported. @param partition_count [::Integer] The desired maximum number of partition points. The partitions may be returned across multiple pages of results. The number must be positive. The actual number of partitions returned may be fewer. For example, this may be set to one fewer than the number of parallel queries to be run, or in running a data pipeline job, one fewer than the number of workers or compute instances available. @param page_token [::String] The `next_page_token` value returned from a previous call to PartitionQuery that may be used to get an additional set of results. There are no ordering guarantees between sets of results. Thus, using multiple sets of results will require merging the different result sets. For example, two subsequent calls using a page_token may return: * cursor B, cursor M, cursor Q * cursor A, cursor U, cursor W To obtain a complete result set ordered with respect to the results of the query supplied to PartitionQuery, the results sets should be merged: cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W @param page_size [::Integer] The maximum number of partitions to return in this call, subject to `partition_count`. For example, if `partition_count` = 10 and `page_size` = 8, the first call to PartitionQuery will return up to 8 partitions and a `next_page_token` if more results exist. A second call to PartitionQuery will return up to 2 partitions, to complete the total of 10 specified in `partition_count`.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Gapic::PagedEnumerable<::Google::Cloud::Firestore::V1::Cursor>] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Gapic::PagedEnumerable<::Google::Cloud::Firestore::V1::Cursor>]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/firestore/v1/firestore/client.rb, line 1027 def partition_query request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::PartitionQueryRequest # 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.partition_query.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::Firestore::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.partition_query.timeout, metadata: metadata, retry_policy: @config.rpcs.partition_query.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @firestore_stub.call_rpc :partition_query, request, options: options do |response, operation| response = ::Gapic::PagedEnumerable.new @firestore_stub, :partition_query, 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
Rolls back a transaction.
@overload rollback(request, options = nil)
Pass arguments to `rollback` via a request object, either of type {::Google::Cloud::Firestore::V1::RollbackRequest} or an equivalent Hash. @param request [::Google::Cloud::Firestore::V1::RollbackRequest, ::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 rollback(database: nil, transaction: nil)
Pass arguments to `rollback` 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 database [::String] Required. The database name. In the format: `projects/{project_id}/databases/{database_id}`. @param transaction [::String] Required. The transaction to roll back.
@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/firestore/v1/firestore/client.rb, line 833 def rollback request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::RollbackRequest # 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.rollback.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::Firestore::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "database" => request.database } 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.rollback.timeout, metadata: metadata, retry_policy: @config.rpcs.rollback.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @firestore_stub.call_rpc :rollback, 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
Runs a query.
@overload run_query
(request, options = nil)
Pass arguments to `run_query` via a request object, either of type {::Google::Cloud::Firestore::V1::RunQueryRequest} or an equivalent Hash. @param request [::Google::Cloud::Firestore::V1::RunQueryRequest, ::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 run_query
(parent: nil, structured_query: nil, transaction: nil, new_transaction: nil, read_time: nil)
Pass arguments to `run_query` 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 parent resource name. In the format: `projects/{project_id}/databases/{database_id}/documents` or `projects/{project_id}/databases/{database_id}/documents/{document_path}`. For example: `projects/my-project/databases/my-database/documents` or `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` @param structured_query [::Google::Cloud::Firestore::V1::StructuredQuery, ::Hash] A structured query. @param transaction [::String] Reads documents in a transaction. @param new_transaction [::Google::Cloud::Firestore::V1::TransactionOptions, ::Hash] Starts a new transaction and reads the documents. Defaults to a read-only transaction. The new transaction ID will be returned as the first response in the stream. @param read_time [::Google::Protobuf::Timestamp, ::Hash] Reads documents as they were at the given time. This may not be older than 270 seconds.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Enumerable<::Google::Cloud::Firestore::V1::RunQueryResponse>] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Enumerable<::Google::Cloud::Firestore::V1::RunQueryResponse>]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/firestore/v1/firestore/client.rb, line 918 def run_query request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::RunQueryRequest # 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.run_query.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::Firestore::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.run_query.timeout, metadata: metadata, retry_policy: @config.rpcs.run_query.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @firestore_stub.call_rpc :run_query, 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
Updates or inserts a document.
@overload update_document
(request, options = nil)
Pass arguments to `update_document` via a request object, either of type {::Google::Cloud::Firestore::V1::UpdateDocumentRequest} or an equivalent Hash. @param request [::Google::Cloud::Firestore::V1::UpdateDocumentRequest, ::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 update_document
(document: nil, update_mask: nil, mask: nil, current_document: nil)
Pass arguments to `update_document` 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 document [::Google::Cloud::Firestore::V1::Document, ::Hash] Required. The updated document. Creates the document if it does not already exist. @param update_mask [::Google::Cloud::Firestore::V1::DocumentMask, ::Hash] The fields to update. None of the field paths in the mask may contain a reserved name. If the document exists on the server and has fields not referenced in the mask, they are left unchanged. Fields referenced in the mask, but not present in the input document, are deleted from the document on the server. @param mask [::Google::Cloud::Firestore::V1::DocumentMask, ::Hash] The fields to return. If not set, returns all fields. If the document has a field that is not present in this mask, that field will not be returned in the response. @param current_document [::Google::Cloud::Firestore::V1::Precondition, ::Hash] An optional precondition on the document. The request will fail if this is set and not met by the target document.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Google::Cloud::Firestore::V1::Document] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Google::Cloud::Firestore::V1::Document]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/firestore/v1/firestore/client.rb, line 451 def update_document request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::UpdateDocumentRequest # 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.update_document.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::Firestore::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id header_params = { "document.name" => request.document.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.update_document.timeout, metadata: metadata, retry_policy: @config.rpcs.update_document.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @firestore_stub.call_rpc :update_document, 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
Streams batches of document updates and deletes, in order.
@param request [::Gapic::StreamInput, ::Enumerable<::Google::Cloud::Firestore::V1::WriteRequest, ::Hash>]
An enumerable of {::Google::Cloud::Firestore::V1::WriteRequest} instances.
@param options [::Gapic::CallOptions, ::Hash]
Overrides the default settings for this call, e.g, timeout, retries, etc. Optional.
@yield [response, operation] Access the result along with the RPC operation @yieldparam response [::Enumerable<::Google::Cloud::Firestore::V1::WriteResponse>] @yieldparam operation [::GRPC::ActiveCall::Operation]
@return [::Enumerable<::Google::Cloud::Firestore::V1::WriteResponse>]
@raise [::Google::Cloud::Error] if the RPC is aborted.
# File lib/google/cloud/firestore/v1/firestore/client.rb, line 1083 def write request, options = nil unless request.is_a? ::Enumerable raise ::ArgumentError, "request must be an Enumerable" unless request.respond_to? :to_enum request = request.to_enum end request = request.lazy.map do |req| ::Gapic::Protobuf.coerce req, to: ::Google::Cloud::Firestore::V1::WriteRequest end # 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.write.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::Firestore::V1::VERSION metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id options.apply_defaults timeout: @config.rpcs.write.timeout, metadata: metadata, retry_policy: @config.rpcs.write.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @firestore_stub.call_rpc :write, 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