# frozen_string_literal: true # Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Auto-generated by gapic-generator-ruby. DO NOT EDIT! require "google/cloud/errors" require "google/datastore/v1/datastore_pb" require "google/cloud/datastore/v1/datastore/rest/service_stub" module Google module Cloud module Datastore module V1 module Datastore module Rest ## # REST client for the Datastore service. # # Each RPC normalizes the partition IDs of the keys in its input entities, # and always returns entities with keys with normalized partition IDs. # This applies to all keys and entities, including those in values, except keys # with both an empty path and an empty or unset partition ID. Normalization of # input keys sets the project ID (if not already set) to the project ID from # the request. # class Client # @private attr_reader :datastore_stub ## # Configure the Datastore Client class. # # See {::Google::Cloud::Datastore::V1::Datastore::Rest::Client::Configuration} # for a description of the configuration fields. # # @example # # # Modify the configuration for all Datastore clients # ::Google::Cloud::Datastore::V1::Datastore::Rest::Client.configure do |config| # config.timeout = 10.0 # end # # @yield [config] Configure the Client client. # @yieldparam config [Client::Configuration] # # @return [Client::Configuration] # def self.configure @configure ||= begin namespace = ["Google", "Cloud", "Datastore", "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.lookup.timeout = 60.0 default_config.rpcs.lookup.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4] } default_config.rpcs.run_query.timeout = 60.0 default_config.rpcs.run_query.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4] } default_config.rpcs.run_aggregation_query.timeout = 60.0 default_config.rpcs.run_aggregation_query.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4] } default_config.rpcs.begin_transaction.timeout = 60.0 default_config.rpcs.commit.timeout = 60.0 default_config.rpcs.rollback.timeout = 60.0 default_config.rpcs.allocate_ids.timeout = 60.0 default_config.rpcs.reserve_ids.timeout = 60.0 default_config.rpcs.reserve_ids.retry_policy = { initial_delay: 0.1, max_delay: 60.0, multiplier: 1.3, retry_codes: [14, 4] } default_config end yield @configure if block_given? @configure end ## # Configure the Datastore 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::Datastore::V1::Datastore::Rest::Client::Configuration} # for a description of the configuration fields. # # @yield [config] Configure the Client client. # @yieldparam config [Client::Configuration] # # @return [Client::Configuration] # def configure yield @config if block_given? @config end ## # Create a new Datastore REST client object. # # @example # # # Create a client using the default configuration # client = ::Google::Cloud::Datastore::V1::Datastore::Rest::Client.new # # # Create a client using a custom configuration # client = ::Google::Cloud::Datastore::V1::Datastore::Rest::Client.new do |config| # config.timeout = 10.0 # end # # @yield [config] Configure the Datastore client. # @yieldparam config [Client::Configuration] # 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 == 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 @datastore_stub = ::Google::Cloud::Datastore::V1::Datastore::Rest::ServiceStub.new endpoint: @config.endpoint, credentials: credentials end # Service calls ## # Looks up entities by key. # # @overload lookup(request, options = nil) # Pass arguments to `lookup` via a request object, either of type # {::Google::Cloud::Datastore::V1::LookupRequest} or an equivalent Hash. # # @param request [::Google::Cloud::Datastore::V1::LookupRequest, ::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 lookup(project_id: nil, database_id: nil, read_options: nil, keys: nil) # Pass arguments to `lookup` 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 project_id [::String] # Required. The ID of the project against which to make the request. # @param database_id [::String] # The ID of the database against which to make the request. # # '(default)' is not allowed; please use empty string '' to refer the default # database. # @param read_options [::Google::Cloud::Datastore::V1::ReadOptions, ::Hash] # The options for this lookup request. # @param keys [::Array<::Google::Cloud::Datastore::V1::Key, ::Hash>] # Required. Keys of entities to look up. # @yield [result, operation] Access the result along with the TransportOperation object # @yieldparam result [::Google::Cloud::Datastore::V1::LookupResponse] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Datastore::V1::LookupResponse] # # @raise [::Google::Cloud::Error] if the REST call is aborted. def lookup request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Datastore::V1::LookupRequest # 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 call_metadata = @config.rpcs.lookup.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers call_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::Datastore::V1::VERSION, transports_version_send: [:rest] call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id options.apply_defaults timeout: @config.rpcs.lookup.timeout, metadata: call_metadata, retry_policy: @config.rpcs.lookup.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @datastore_stub.lookup request, options do |result, operation| yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end ## # Queries for entities. # # @overload run_query(request, options = nil) # Pass arguments to `run_query` via a request object, either of type # {::Google::Cloud::Datastore::V1::RunQueryRequest} or an equivalent Hash. # # @param request [::Google::Cloud::Datastore::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(project_id: nil, database_id: nil, partition_id: nil, read_options: nil, query: nil, gql_query: 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 project_id [::String] # Required. The ID of the project against which to make the request. # @param database_id [::String] # The ID of the database against which to make the request. # # '(default)' is not allowed; please use empty string '' to refer the default # database. # @param partition_id [::Google::Cloud::Datastore::V1::PartitionId, ::Hash] # Entities are partitioned into subsets, identified by a partition ID. # Queries are scoped to a single partition. # This partition ID is normalized with the standard default context # partition ID. # @param read_options [::Google::Cloud::Datastore::V1::ReadOptions, ::Hash] # The options for this query. # @param query [::Google::Cloud::Datastore::V1::Query, ::Hash] # The query to run. # @param gql_query [::Google::Cloud::Datastore::V1::GqlQuery, ::Hash] # The GQL query to run. This query must be a non-aggregation query. # @yield [result, operation] Access the result along with the TransportOperation object # @yieldparam result [::Google::Cloud::Datastore::V1::RunQueryResponse] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Datastore::V1::RunQueryResponse] # # @raise [::Google::Cloud::Error] if the REST call is aborted. def run_query request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Datastore::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 call_metadata = @config.rpcs.run_query.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers call_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::Datastore::V1::VERSION, transports_version_send: [:rest] call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id options.apply_defaults timeout: @config.rpcs.run_query.timeout, metadata: call_metadata, retry_policy: @config.rpcs.run_query.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @datastore_stub.run_query request, options do |result, operation| yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end ## # Runs an aggregation query. # # @overload run_aggregation_query(request, options = nil) # Pass arguments to `run_aggregation_query` via a request object, either of type # {::Google::Cloud::Datastore::V1::RunAggregationQueryRequest} or an equivalent Hash. # # @param request [::Google::Cloud::Datastore::V1::RunAggregationQueryRequest, ::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_aggregation_query(project_id: nil, database_id: nil, partition_id: nil, read_options: nil, aggregation_query: nil, gql_query: nil) # Pass arguments to `run_aggregation_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 project_id [::String] # Required. The ID of the project against which to make the request. # @param database_id [::String] # The ID of the database against which to make the request. # # '(default)' is not allowed; please use empty string '' to refer the default # database. # @param partition_id [::Google::Cloud::Datastore::V1::PartitionId, ::Hash] # Entities are partitioned into subsets, identified by a partition ID. # Queries are scoped to a single partition. # This partition ID is normalized with the standard default context # partition ID. # @param read_options [::Google::Cloud::Datastore::V1::ReadOptions, ::Hash] # The options for this query. # @param aggregation_query [::Google::Cloud::Datastore::V1::AggregationQuery, ::Hash] # The query to run. # @param gql_query [::Google::Cloud::Datastore::V1::GqlQuery, ::Hash] # The GQL query to run. This query must be an aggregation query. # @yield [result, operation] Access the result along with the TransportOperation object # @yieldparam result [::Google::Cloud::Datastore::V1::RunAggregationQueryResponse] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Datastore::V1::RunAggregationQueryResponse] # # @raise [::Google::Cloud::Error] if the REST call is aborted. def run_aggregation_query request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Datastore::V1::RunAggregationQueryRequest # 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 call_metadata = @config.rpcs.run_aggregation_query.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers call_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::Datastore::V1::VERSION, transports_version_send: [:rest] call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id options.apply_defaults timeout: @config.rpcs.run_aggregation_query.timeout, metadata: call_metadata, retry_policy: @config.rpcs.run_aggregation_query.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @datastore_stub.run_aggregation_query request, options do |result, operation| yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end ## # Begins a new transaction. # # @overload begin_transaction(request, options = nil) # Pass arguments to `begin_transaction` via a request object, either of type # {::Google::Cloud::Datastore::V1::BeginTransactionRequest} or an equivalent Hash. # # @param request [::Google::Cloud::Datastore::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(project_id: nil, database_id: nil, transaction_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 project_id [::String] # Required. The ID of the project against which to make the request. # @param database_id [::String] # The ID of the database against which to make the request. # # '(default)' is not allowed; please use empty string '' to refer the default # database. # @param transaction_options [::Google::Cloud::Datastore::V1::TransactionOptions, ::Hash] # Options for a new transaction. # @yield [result, operation] Access the result along with the TransportOperation object # @yieldparam result [::Google::Cloud::Datastore::V1::BeginTransactionResponse] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Datastore::V1::BeginTransactionResponse] # # @raise [::Google::Cloud::Error] if the REST call is aborted. def begin_transaction request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Datastore::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 call_metadata = @config.rpcs.begin_transaction.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers call_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::Datastore::V1::VERSION, transports_version_send: [:rest] call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id options.apply_defaults timeout: @config.rpcs.begin_transaction.timeout, metadata: call_metadata, retry_policy: @config.rpcs.begin_transaction.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @datastore_stub.begin_transaction request, options do |result, operation| yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end ## # Commits a transaction, optionally creating, deleting or modifying some # entities. # # @overload commit(request, options = nil) # Pass arguments to `commit` via a request object, either of type # {::Google::Cloud::Datastore::V1::CommitRequest} or an equivalent Hash. # # @param request [::Google::Cloud::Datastore::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(project_id: nil, database_id: nil, mode: nil, transaction: nil, single_use_transaction: nil, mutations: 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 project_id [::String] # Required. The ID of the project against which to make the request. # @param database_id [::String] # The ID of the database against which to make the request. # # '(default)' is not allowed; please use empty string '' to refer the default # database. # @param mode [::Google::Cloud::Datastore::V1::CommitRequest::Mode] # The type of commit to perform. Defaults to `TRANSACTIONAL`. # @param transaction [::String] # The identifier of the transaction associated with the commit. A # transaction identifier is returned by a call to # {::Google::Cloud::Datastore::V1::Datastore::Rest::Client#begin_transaction Datastore.BeginTransaction}. # @param single_use_transaction [::Google::Cloud::Datastore::V1::TransactionOptions, ::Hash] # Options for beginning a new transaction for this request. # The transaction is committed when the request completes. If specified, # {::Google::Cloud::Datastore::V1::TransactionOptions TransactionOptions.mode} must be # {::Google::Cloud::Datastore::V1::TransactionOptions::ReadWrite TransactionOptions.ReadWrite}. # @param mutations [::Array<::Google::Cloud::Datastore::V1::Mutation, ::Hash>] # The mutations to perform. # # When mode is `TRANSACTIONAL`, mutations affecting a single entity are # applied in order. The following sequences of mutations affecting a single # entity are not permitted in a single `Commit` request: # # - `insert` followed by `insert` # - `update` followed by `insert` # - `upsert` followed by `insert` # - `delete` followed by `update` # # When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single # entity. # @yield [result, operation] Access the result along with the TransportOperation object # @yieldparam result [::Google::Cloud::Datastore::V1::CommitResponse] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Datastore::V1::CommitResponse] # # @raise [::Google::Cloud::Error] if the REST call is aborted. def commit request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Datastore::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 call_metadata = @config.rpcs.commit.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers call_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::Datastore::V1::VERSION, transports_version_send: [:rest] call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id options.apply_defaults timeout: @config.rpcs.commit.timeout, metadata: call_metadata, retry_policy: @config.rpcs.commit.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @datastore_stub.commit request, options do |result, operation| yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => 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::Datastore::V1::RollbackRequest} or an equivalent Hash. # # @param request [::Google::Cloud::Datastore::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(project_id: nil, database_id: 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 project_id [::String] # Required. The ID of the project against which to make the request. # @param database_id [::String] # The ID of the database against which to make the request. # # '(default)' is not allowed; please use empty string '' to refer the default # database. # @param transaction [::String] # Required. The transaction identifier, returned by a call to # {::Google::Cloud::Datastore::V1::Datastore::Rest::Client#begin_transaction Datastore.BeginTransaction}. # @yield [result, operation] Access the result along with the TransportOperation object # @yieldparam result [::Google::Cloud::Datastore::V1::RollbackResponse] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Datastore::V1::RollbackResponse] # # @raise [::Google::Cloud::Error] if the REST call is aborted. def rollback request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Datastore::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 call_metadata = @config.rpcs.rollback.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers call_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::Datastore::V1::VERSION, transports_version_send: [:rest] call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id options.apply_defaults timeout: @config.rpcs.rollback.timeout, metadata: call_metadata, retry_policy: @config.rpcs.rollback.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @datastore_stub.rollback request, options do |result, operation| yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end ## # Allocates IDs for the given keys, which is useful for referencing an entity # before it is inserted. # # @overload allocate_ids(request, options = nil) # Pass arguments to `allocate_ids` via a request object, either of type # {::Google::Cloud::Datastore::V1::AllocateIdsRequest} or an equivalent Hash. # # @param request [::Google::Cloud::Datastore::V1::AllocateIdsRequest, ::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 allocate_ids(project_id: nil, database_id: nil, keys: nil) # Pass arguments to `allocate_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 project_id [::String] # Required. The ID of the project against which to make the request. # @param database_id [::String] # The ID of the database against which to make the request. # # '(default)' is not allowed; please use empty string '' to refer the default # database. # @param keys [::Array<::Google::Cloud::Datastore::V1::Key, ::Hash>] # Required. A list of keys with incomplete key paths for which to allocate # IDs. No key may be reserved/read-only. # @yield [result, operation] Access the result along with the TransportOperation object # @yieldparam result [::Google::Cloud::Datastore::V1::AllocateIdsResponse] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Datastore::V1::AllocateIdsResponse] # # @raise [::Google::Cloud::Error] if the REST call is aborted. def allocate_ids request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Datastore::V1::AllocateIdsRequest # 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 call_metadata = @config.rpcs.allocate_ids.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers call_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::Datastore::V1::VERSION, transports_version_send: [:rest] call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id options.apply_defaults timeout: @config.rpcs.allocate_ids.timeout, metadata: call_metadata, retry_policy: @config.rpcs.allocate_ids.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @datastore_stub.allocate_ids request, options do |result, operation| yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end ## # Prevents the supplied keys' IDs from being auto-allocated by Cloud # Datastore. # # @overload reserve_ids(request, options = nil) # Pass arguments to `reserve_ids` via a request object, either of type # {::Google::Cloud::Datastore::V1::ReserveIdsRequest} or an equivalent Hash. # # @param request [::Google::Cloud::Datastore::V1::ReserveIdsRequest, ::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 reserve_ids(project_id: nil, database_id: nil, keys: nil) # Pass arguments to `reserve_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 project_id [::String] # Required. The ID of the project against which to make the request. # @param database_id [::String] # The ID of the database against which to make the request. # # '(default)' is not allowed; please use empty string '' to refer the default # database. # @param keys [::Array<::Google::Cloud::Datastore::V1::Key, ::Hash>] # Required. A list of keys with complete key paths whose numeric IDs should # not be auto-allocated. # @yield [result, operation] Access the result along with the TransportOperation object # @yieldparam result [::Google::Cloud::Datastore::V1::ReserveIdsResponse] # @yieldparam operation [::Gapic::Rest::TransportOperation] # # @return [::Google::Cloud::Datastore::V1::ReserveIdsResponse] # # @raise [::Google::Cloud::Error] if the REST call is aborted. def reserve_ids request, options = nil raise ::ArgumentError, "request must be provided" if request.nil? request = ::Gapic::Protobuf.coerce request, to: ::Google::Cloud::Datastore::V1::ReserveIdsRequest # 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 call_metadata = @config.rpcs.reserve_ids.metadata.to_h # Set x-goog-api-client and x-goog-user-project headers call_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::Datastore::V1::VERSION, transports_version_send: [:rest] call_metadata[:"x-goog-user-project"] = @quota_project_id if @quota_project_id options.apply_defaults timeout: @config.rpcs.reserve_ids.timeout, metadata: call_metadata, retry_policy: @config.rpcs.reserve_ids.retry_policy options.apply_defaults timeout: @config.timeout, metadata: @config.metadata, retry_policy: @config.retry_policy @datastore_stub.reserve_ids request, options do |result, operation| yield result, operation if block_given? return result end rescue ::Gapic::Rest::Error => e raise ::Google::Cloud::Error.from_error(e) end ## # Configuration class for the Datastore REST API. # # This class represents the configuration for Datastore REST, # providing control over timeouts, retry behavior, logging, transport # parameters, and other low-level controls. Certain parameters can also be # applied individually to specific RPCs. See # {::Google::Cloud::Datastore::V1::Datastore::Rest::Client::Configuration::Rpcs} # for a list of RPCs that can be configured independently. # # Configuration can be applied globally to all clients, or to a single client # on construction. # # @example # # # Modify the global config, setting the timeout for # # lookup to 20 seconds, # # and all remaining timeouts to 10 seconds. # ::Google::Cloud::Datastore::V1::Datastore::Rest::Client.configure do |config| # config.timeout = 10.0 # config.rpcs.lookup.timeout = 20.0 # end # # # Apply the above configuration only to a new client. # client = ::Google::Cloud::Datastore::V1::Datastore::Rest::Client.new do |config| # config.timeout = 10.0 # config.rpcs.lookup.timeout = 20.0 # end # # @!attribute [rw] endpoint # The hostname or hostname:port of the service endpoint. # Defaults to `"datastore.googleapis.com"`. # @return [::String] # @!attribute [rw] credentials # Credentials to send with calls. You may provide any of the following types: # * (`String`) The path to a service account key file in JSON format # * (`Hash`) A service account key as a Hash # * (`Google::Auth::Credentials`) A googleauth credentials object # (see the [googleauth docs](https://googleapis.dev/ruby/googleauth/latest/index.html)) # * (`Signet::OAuth2::Client`) A signet oauth2 client object # (see the [signet docs](https://googleapis.dev/ruby/signet/latest/Signet/OAuth2/Client.html)) # * (`nil`) indicating no credentials # @return [::Object] # @!attribute [rw] scope # The OAuth scopes # @return [::Array<::String>] # @!attribute [rw] lib_name # The library name as recorded in instrumentation and logging # @return [::String] # @!attribute [rw] lib_version # The library version as recorded in instrumentation and logging # @return [::String] # @!attribute [rw] timeout # The call timeout in seconds. # @return [::Numeric] # @!attribute [rw] metadata # Additional headers to be sent with the call. # @return [::Hash{::Symbol=>::String}] # @!attribute [rw] retry_policy # The retry policy. The value is a hash with the following keys: # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. # * `:retry_codes` (*type:* `Array`) - The error codes that should # trigger a retry. # @return [::Hash] # @!attribute [rw] quota_project # A separate project against which to charge quota. # @return [::String] # class Configuration extend ::Gapic::Config config_attr :endpoint, "datastore.googleapis.com", ::String config_attr :credentials, nil do |value| allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil] allowed.any? { |klass| klass === value } end config_attr :scope, nil, ::String, ::Array, nil config_attr :lib_name, nil, ::String, nil config_attr :lib_version, nil, ::String, nil config_attr :timeout, nil, ::Numeric, nil config_attr :metadata, nil, ::Hash, nil config_attr :retry_policy, nil, ::Hash, ::Proc, nil config_attr :quota_project, nil, ::String, nil # @private def initialize parent_config = nil @parent_config = parent_config unless parent_config.nil? yield self if block_given? end ## # Configurations for individual RPCs # @return [Rpcs] # def rpcs @rpcs ||= begin parent_rpcs = nil parent_rpcs = @parent_config.rpcs if defined?(@parent_config) && @parent_config.respond_to?(:rpcs) Rpcs.new parent_rpcs end end ## # Configuration RPC class for the Datastore API. # # Includes fields providing the configuration for each RPC in this service. # Each configuration object is of type `Gapic::Config::Method` and includes # the following configuration fields: # # * `timeout` (*type:* `Numeric`) - The call timeout in seconds # * `metadata` (*type:* `Hash{Symbol=>String}`) - Additional headers # * `retry_policy (*type:* `Hash`) - The retry policy. The policy fields # include the following keys: # * `:initial_delay` (*type:* `Numeric`) - The initial delay in seconds. # * `:max_delay` (*type:* `Numeric`) - The max delay in seconds. # * `:multiplier` (*type:* `Numeric`) - The incremental backoff multiplier. # * `:retry_codes` (*type:* `Array`) - The error codes that should # trigger a retry. # class Rpcs ## # RPC-specific configuration for `lookup` # @return [::Gapic::Config::Method] # attr_reader :lookup ## # RPC-specific configuration for `run_query` # @return [::Gapic::Config::Method] # attr_reader :run_query ## # RPC-specific configuration for `run_aggregation_query` # @return [::Gapic::Config::Method] # attr_reader :run_aggregation_query ## # RPC-specific configuration for `begin_transaction` # @return [::Gapic::Config::Method] # attr_reader :begin_transaction ## # RPC-specific configuration for `commit` # @return [::Gapic::Config::Method] # attr_reader :commit ## # RPC-specific configuration for `rollback` # @return [::Gapic::Config::Method] # attr_reader :rollback ## # RPC-specific configuration for `allocate_ids` # @return [::Gapic::Config::Method] # attr_reader :allocate_ids ## # RPC-specific configuration for `reserve_ids` # @return [::Gapic::Config::Method] # attr_reader :reserve_ids # @private def initialize parent_rpcs = nil lookup_config = parent_rpcs.lookup if parent_rpcs.respond_to? :lookup @lookup = ::Gapic::Config::Method.new lookup_config run_query_config = parent_rpcs.run_query if parent_rpcs.respond_to? :run_query @run_query = ::Gapic::Config::Method.new run_query_config run_aggregation_query_config = parent_rpcs.run_aggregation_query if parent_rpcs.respond_to? :run_aggregation_query @run_aggregation_query = ::Gapic::Config::Method.new run_aggregation_query_config begin_transaction_config = parent_rpcs.begin_transaction if parent_rpcs.respond_to? :begin_transaction @begin_transaction = ::Gapic::Config::Method.new begin_transaction_config commit_config = parent_rpcs.commit if parent_rpcs.respond_to? :commit @commit = ::Gapic::Config::Method.new commit_config rollback_config = parent_rpcs.rollback if parent_rpcs.respond_to? :rollback @rollback = ::Gapic::Config::Method.new rollback_config allocate_ids_config = parent_rpcs.allocate_ids if parent_rpcs.respond_to? :allocate_ids @allocate_ids = ::Gapic::Config::Method.new allocate_ids_config reserve_ids_config = parent_rpcs.reserve_ids if parent_rpcs.respond_to? :reserve_ids @reserve_ids = ::Gapic::Config::Method.new reserve_ids_config yield self if block_given? end end end end end end end end end end