Class: Google::Cloud::Firestore::V1::Firestore::Rest::Client
- Inherits:
-
Object
- Object
- Google::Cloud::Firestore::V1::Firestore::Rest::Client
- Defined in:
- lib/google/cloud/firestore/v1/firestore/rest/client.rb
Overview
REST client for the Firestore service.
The Cloud 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 accelerate building truly serverless apps.
Defined Under Namespace
Classes: Configuration
Instance Attribute Summary collapse
-
#location_client ⇒ Google::Cloud::Location::Locations::Rest::Client
readonly
Get the associated client for mix-in of the Locations.
Class Method Summary collapse
-
.configure {|config| ... } ⇒ Client::Configuration
Configure the Firestore Client class.
Instance Method Summary collapse
-
#batch_get_documents(request, options = nil) ⇒ ::Enumerable<::Google::Cloud::Firestore::V1::BatchGetDocumentsResponse>
Gets multiple documents.
-
#batch_write(request, options = nil) {|result, operation| ... } ⇒ ::Google::Cloud::Firestore::V1::BatchWriteResponse
Applies a batch of write operations.
-
#begin_transaction(request, options = nil) {|result, operation| ... } ⇒ ::Google::Cloud::Firestore::V1::BeginTransactionResponse
Starts a new transaction.
-
#commit(request, options = nil) {|result, operation| ... } ⇒ ::Google::Cloud::Firestore::V1::CommitResponse
Commits a transaction, while optionally updating documents.
-
#configure {|config| ... } ⇒ Client::Configuration
Configure the Firestore Client instance.
-
#create_document(request, options = nil) {|result, operation| ... } ⇒ ::Google::Cloud::Firestore::V1::Document
Creates a new document.
-
#delete_document(request, options = nil) {|result, operation| ... } ⇒ ::Google::Protobuf::Empty
Deletes a document.
-
#execute_pipeline(request, options = nil) ⇒ ::Enumerable<::Google::Cloud::Firestore::V1::ExecutePipelineResponse>
Executes a pipeline query.
-
#get_document(request, options = nil) {|result, operation| ... } ⇒ ::Google::Cloud::Firestore::V1::Document
Gets a single document.
-
#initialize {|config| ... } ⇒ Client
constructor
Create a new Firestore REST client object.
-
#list_collection_ids(request, options = nil) {|result, operation| ... } ⇒ ::Google::Cloud::Firestore::V1::ListCollectionIdsResponse
Lists all the collection IDs underneath a document.
-
#list_documents(request, options = nil) {|result, operation| ... } ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Firestore::V1::Document>
Lists documents.
-
#logger ⇒ Logger
The logger used for request/response debug logging.
-
#partition_query(request, options = nil) {|result, operation| ... } ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Firestore::V1::Cursor>
Partitions a query by returning partition cursors that can be used to run the query in parallel.
-
#rollback(request, options = nil) {|result, operation| ... } ⇒ ::Google::Protobuf::Empty
Rolls back a transaction.
-
#run_aggregation_query(request, options = nil) ⇒ ::Enumerable<::Google::Cloud::Firestore::V1::RunAggregationQueryResponse>
Runs an aggregation query.
-
#run_query(request, options = nil) ⇒ ::Enumerable<::Google::Cloud::Firestore::V1::RunQueryResponse>
Runs a query.
-
#universe_domain ⇒ String
The effective universe domain.
-
#update_document(request, options = nil) {|result, operation| ... } ⇒ ::Google::Cloud::Firestore::V1::Document
Updates or inserts a document.
Constructor Details
#initialize {|config| ... } ⇒ Client
Create a new Firestore REST client object.
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 207 def initialize # 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.nil? || (@config.endpoint == Configuration::DEFAULT_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 = ::Google::Cloud::Firestore::V1::Firestore::Rest::ServiceStub.new( endpoint: @config.endpoint, endpoint_template: DEFAULT_ENDPOINT_TEMPLATE, universe_domain: @config.universe_domain, credentials: credentials, logger: @config.logger ) @firestore_stub.logger(stub: true)&.info do |entry| entry.set_system_name entry.set_service entry. = "Created client for #{entry.service}" entry.set_credentials_fields credentials entry.set "customEndpoint", @config.endpoint if @config.endpoint entry.set "defaultTimeout", @config.timeout if @config.timeout entry.set "quotaProject", @quota_project_id if @quota_project_id end @location_client = Google::Cloud::Location::Locations::Rest::Client.new do |config| config.credentials = credentials config.quota_project = @quota_project_id config.endpoint = @firestore_stub.endpoint config.universe_domain = @firestore_stub.universe_domain config.logger = @firestore_stub.logger if config.respond_to? :logger= end end |
Instance Attribute Details
#location_client ⇒ Google::Cloud::Location::Locations::Rest::Client (readonly)
Get the associated client for mix-in of the Locations.
262 263 264 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 262 def location_client @location_client end |
Class Method Details
.configure {|config| ... } ⇒ Client::Configuration
Configure the Firestore Client class.
See Configuration for a description of the configuration fields.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 70 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: [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: [14, 13, 4] } default_config.rpcs.execute_pipeline.timeout = 300.0 default_config.rpcs.execute_pipeline.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 13] } default_config.rpcs.run_aggregation_query.timeout = 300.0 default_config.rpcs.run_aggregation_query.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [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: [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 |
Instance Method Details
#batch_get_documents(request, options = nil) ⇒ ::Enumerable<::Google::Cloud::Firestore::V1::BatchGetDocumentsResponse> #batch_get_documents(database: nil, documents: nil, mask: nil, transaction: nil, new_transaction: nil, read_time: nil) ⇒ ::Enumerable<::Google::Cloud::Firestore::V1::BatchGetDocumentsResponse>
Gets multiple documents.
Documents returned by this method are not guaranteed to be returned in the same order that they were requested.
765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 765 def batch_get_documents request, = 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 = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.batch_get_documents..to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers [:"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, transports_version_send: [:rest] [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.batch_get_documents.timeout, metadata: , retry_policy: @config.rpcs.batch_get_documents.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy ::Gapic::Rest::ServerStream.new( ::Google::Cloud::Firestore::V1::BatchGetDocumentsResponse, ::Gapic::Rest::ThreadedEnumerator.new do |in_q, out_q| @firestore_stub.batch_get_documents request, do |chunk| in_q.deq out_q.enq chunk end end ) rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#batch_write(request, options = nil) ⇒ ::Google::Cloud::Firestore::V1::BatchWriteResponse #batch_write(database: nil, writes: nil, labels: nil) ⇒ ::Google::Cloud::Firestore::V1::BatchWriteResponse
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 BatchWriteResponse for the success status of each write.
If you require an atomically applied set of writes, use Commit instead.
1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 1692 def batch_write request, = 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 = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.batch_write..to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers [:"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, transports_version_send: [:rest] [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.batch_write.timeout, metadata: , retry_policy: @config.rpcs.batch_write.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @firestore_stub.batch_write request, do |result, operation| yield result, operation if block_given? end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#begin_transaction(request, options = nil) ⇒ ::Google::Cloud::Firestore::V1::BeginTransactionResponse #begin_transaction(database: nil, options: nil) ⇒ ::Google::Cloud::Firestore::V1::BeginTransactionResponse
Starts a new transaction.
853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 853 def begin_transaction request, = 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 = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.begin_transaction..to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers [:"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, transports_version_send: [:rest] [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.begin_transaction.timeout, metadata: , retry_policy: @config.rpcs.begin_transaction.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @firestore_stub.begin_transaction request, do |result, operation| yield result, operation if block_given? end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#commit(request, options = nil) ⇒ ::Google::Cloud::Firestore::V1::CommitResponse #commit(database: nil, writes: nil, transaction: nil) ⇒ ::Google::Cloud::Firestore::V1::CommitResponse
Commits a transaction, while optionally updating documents.
938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 938 def commit request, = 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 = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.commit..to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers [:"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, transports_version_send: [:rest] [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.commit.timeout, metadata: , retry_policy: @config.rpcs.commit.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @firestore_stub.commit request, do |result, operation| yield result, operation if block_given? end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#configure {|config| ... } ⇒ Client::Configuration
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 configure.
See Configuration for a description of the configuration fields.
177 178 179 180 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 177 def configure yield @config if block_given? @config end |
#create_document(request, options = nil) ⇒ ::Google::Cloud::Firestore::V1::Document #create_document(parent: nil, collection_id: nil, document_id: nil, document: nil, mask: nil) ⇒ ::Google::Cloud::Firestore::V1::Document
Creates a new document.
1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 1786 def create_document request, = 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 = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.create_document..to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers [:"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, transports_version_send: [:rest] [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.create_document.timeout, metadata: , retry_policy: @config.rpcs.create_document.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @firestore_stub.create_document request, do |result, operation| yield result, operation if block_given? end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#delete_document(request, options = nil) ⇒ ::Google::Protobuf::Empty #delete_document(name: nil, current_document: nil) ⇒ ::Google::Protobuf::Empty
Deletes a document.
655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 655 def delete_document request, = 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 = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.delete_document..to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers [:"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, transports_version_send: [:rest] [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.delete_document.timeout, metadata: , retry_policy: @config.rpcs.delete_document.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @firestore_stub.delete_document request, do |result, operation| yield result, operation if block_given? end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#execute_pipeline(request, options = nil) ⇒ ::Enumerable<::Google::Cloud::Firestore::V1::ExecutePipelineResponse> #execute_pipeline(database: nil, structured_pipeline: nil, transaction: nil, new_transaction: nil, read_time: nil, auto_commit_transaction: nil) ⇒ ::Enumerable<::Google::Cloud::Firestore::V1::ExecutePipelineResponse>
Executes a pipeline query.
1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 1238 def execute_pipeline request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::ExecutePipelineRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.execute_pipeline..to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers [:"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, transports_version_send: [:rest] [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.execute_pipeline.timeout, metadata: , retry_policy: @config.rpcs.execute_pipeline.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy ::Gapic::Rest::ServerStream.new( ::Google::Cloud::Firestore::V1::ExecutePipelineResponse, ::Gapic::Rest::ThreadedEnumerator.new do |in_q, out_q| @firestore_stub.execute_pipeline request, do |chunk| in_q.deq out_q.enq chunk end end ) rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#get_document(request, options = nil) ⇒ ::Google::Cloud::Firestore::V1::Document #get_document(name: nil, mask: nil, transaction: nil, read_time: nil) ⇒ ::Google::Cloud::Firestore::V1::Document
Gets a single document.
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 336 def get_document request, = 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 = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.get_document..to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers [:"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, transports_version_send: [:rest] [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.get_document.timeout, metadata: , retry_policy: @config.rpcs.get_document.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @firestore_stub.get_document request, do |result, operation| yield result, operation if block_given? end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#list_collection_ids(request, options = nil) ⇒ ::Google::Cloud::Firestore::V1::ListCollectionIdsResponse #list_collection_ids(parent: nil, page_size: nil, page_token: nil, read_time: nil) ⇒ ::Google::Cloud::Firestore::V1::ListCollectionIdsResponse
Lists all the collection IDs underneath a document.
1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 1596 def list_collection_ids request, = 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 = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.list_collection_ids..to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers [:"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, transports_version_send: [:rest] [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.list_collection_ids.timeout, metadata: , retry_policy: @config.rpcs.list_collection_ids.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @firestore_stub.list_collection_ids request, do |result, operation| yield result, operation if block_given? end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#list_documents(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Firestore::V1::Document> #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) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Firestore::V1::Document>
Lists documents.
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 476 def list_documents request, = 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 = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.list_documents..to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers [:"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, transports_version_send: [:rest] [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.list_documents.timeout, metadata: , retry_policy: @config.rpcs.list_documents.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @firestore_stub.list_documents request, do |result, operation| result = ::Gapic::Rest::PagedEnumerable.new @firestore_stub, :list_documents, "documents", request, result, yield result, operation if block_given? throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#logger ⇒ Logger
The logger used for request/response debug logging.
269 270 271 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 269 def logger @firestore_stub.logger end |
#partition_query(request, options = nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Firestore::V1::Cursor> #partition_query(parent: nil, structured_query: nil, partition_count: nil, page_token: nil, page_size: nil, read_time: nil) ⇒ ::Gapic::Rest::PagedEnumerable<::Google::Cloud::Firestore::V1::Cursor>
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.
1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 1499 def partition_query request, = 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 = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.partition_query..to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers [:"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, transports_version_send: [:rest] [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.partition_query.timeout, metadata: , retry_policy: @config.rpcs.partition_query.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @firestore_stub.partition_query request, do |result, operation| result = ::Gapic::Rest::PagedEnumerable.new @firestore_stub, :partition_query, "partitions", request, result, yield result, operation if block_given? throw :response, result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#rollback(request, options = nil) ⇒ ::Google::Protobuf::Empty #rollback(database: nil, transaction: nil) ⇒ ::Google::Protobuf::Empty
Rolls back a transaction.
1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 1019 def rollback request, = 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 = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.rollback..to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers [:"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, transports_version_send: [:rest] [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.rollback.timeout, metadata: , retry_policy: @config.rpcs.rollback.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @firestore_stub.rollback request, do |result, operation| yield result, operation if block_given? end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#run_aggregation_query(request, options = nil) ⇒ ::Enumerable<::Google::Cloud::Firestore::V1::RunAggregationQueryResponse> #run_aggregation_query(parent: nil, structured_aggregation_query: nil, transaction: nil, new_transaction: nil, read_time: nil, explain_options: nil) ⇒ ::Enumerable<::Google::Cloud::Firestore::V1::RunAggregationQueryResponse>
Runs an aggregation query.
Rather than producing Document results like Firestore.RunQuery, this API allows running an aggregation to produce a series of AggregationResult server-side.
High-Level Example:
-- Return the number of documents in table given a filter.
SELECT COUNT(*) FROM ( SELECT * FROM k where a = true );
1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 1364 def run_aggregation_query request, = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Firestore::V1::RunAggregationQueryRequest # Converts hash and nil to an options object = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.run_aggregation_query..to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers [:"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, transports_version_send: [:rest] [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.run_aggregation_query.timeout, metadata: , retry_policy: @config.rpcs.run_aggregation_query.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy ::Gapic::Rest::ServerStream.new( ::Google::Cloud::Firestore::V1::RunAggregationQueryResponse, ::Gapic::Rest::ThreadedEnumerator.new do |in_q, out_q| @firestore_stub.run_aggregation_query request, do |chunk| in_q.deq out_q.enq chunk end end ) rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#run_query(request, options = nil) ⇒ ::Enumerable<::Google::Cloud::Firestore::V1::RunQueryResponse> #run_query(parent: nil, structured_query: nil, transaction: nil, new_transaction: nil, read_time: nil, explain_options: nil) ⇒ ::Enumerable<::Google::Cloud::Firestore::V1::RunQueryResponse>
Runs a query.
1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 1127 def run_query request, = 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 = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.run_query..to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers [:"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, transports_version_send: [:rest] [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.run_query.timeout, metadata: , retry_policy: @config.rpcs.run_query.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy ::Gapic::Rest::ServerStream.new( ::Google::Cloud::Firestore::V1::RunQueryResponse, ::Gapic::Rest::ThreadedEnumerator.new do |in_q, out_q| @firestore_stub.run_query request, do |chunk| in_q.deq out_q.enq chunk end end ) rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |
#universe_domain ⇒ String
The effective universe domain
187 188 189 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 187 def universe_domain @firestore_stub.universe_domain end |
#update_document(request, options = nil) ⇒ ::Google::Cloud::Firestore::V1::Document #update_document(document: nil, update_mask: nil, mask: nil, current_document: nil) ⇒ ::Google::Cloud::Firestore::V1::Document
Updates or inserts a document.
573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 |
# File 'lib/google/cloud/firestore/v1/firestore/rest/client.rb', line 573 def update_document request, = 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 = ::Gapic::CallOptions.new(**.to_h) if .respond_to? :to_h # Customize the options with defaults = @config.rpcs.update_document..to_h # Set x-goog-api-client, x-goog-user-project and x-goog-api-version headers [:"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, transports_version_send: [:rest] [:"x-goog-api-version"] = API_VERSION unless API_VERSION.empty? [:"x-goog-user-project"] = @quota_project_id if @quota_project_id .apply_defaults timeout: @config.rpcs.update_document.timeout, metadata: , retry_policy: @config.rpcs.update_document.retry_policy .apply_defaults timeout: @config.timeout, metadata: @config., retry_policy: @config.retry_policy @firestore_stub.update_document request, do |result, operation| yield result, operation if block_given? end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end |