import type * as gax from 'google-gax'; import type { Callback, CallOptions, Descriptors, ClientOptions } from 'google-gax'; import * as protos from '../../protos/protos'; /** * 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 * @memberof v1 */ export declare class DatastoreClient { private _terminated; private _opts; private _providedCustomServicePath; private _gaxModule; private _gaxGrpc; private _protos; private _defaults; private _universeDomain; private _servicePath; auth: gax.GoogleAuth; descriptors: Descriptors; warn: (code: string, message: string, warnType?: string) => void; innerApiCalls: { [name: string]: Function; }; operationsClient: gax.OperationsClient; datastoreStub?: Promise<{ [name: string]: Function; }>; /** * Construct an instance of DatastoreClient. * * @param {object} [options] - The configuration object. * The options accepted by the constructor are described in detail * in [this document](https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#creating-the-client-instance). * The common options are: * @param {object} [options.credentials] - Credentials object. * @param {string} [options.credentials.client_email] * @param {string} [options.credentials.private_key] * @param {string} [options.email] - Account email address. Required when * using a .pem or .p12 keyFilename. * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or * .p12 key downloaded from the Google Developers Console. If you provide * a path to a JSON file, the projectId option below is not necessary. * NOTE: .pem and .p12 require you to specify options.email as well. * @param {number} [options.port] - The port on which to connect to * the remote host. * @param {string} [options.projectId] - The project ID from the Google * Developer's Console, e.g. 'grape-spaceship-123'. We will also check * the environment variable GCLOUD_PROJECT for your project ID. If your * app is running in an environment which supports * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials}, * your project ID will be detected automatically. * @param {string} [options.apiEndpoint] - The domain name of the * API remote host. * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override. * Follows the structure of {@link gapicConfig}. * @param {boolean} [options.fallback] - Use HTTP/1.1 REST mode. * For more information, please check the * {@link https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md#http11-rest-api-mode documentation}. * @param {gax} [gaxInstance]: loaded instance of `google-gax`. Useful if you * need to avoid loading the default gRPC version and want to use the fallback * HTTP implementation. Load only fallback version and pass it to the constructor: * ``` * const gax = require('google-gax/build/src/fallback'); // avoids loading google-gax with gRPC * const client = new DatastoreClient({fallback: true}, gax); * ``` */ constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback); /** * Initialize the client. * Performs asynchronous operations (such as authentication) and prepares the client. * This function will be called automatically when any class method is called for the * first time, but if you need to initialize it before calling an actual method, * feel free to call initialize() directly. * * You can await on this method if you want to make sure the client is initialized. * * @returns {Promise} A promise that resolves to an authenticated service stub. */ initialize(): Promise<{ [name: string]: Function; }>; /** * The DNS address for this API service. * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get servicePath(): string; /** * The DNS address for this API service - same as servicePath. * @deprecated Use the apiEndpoint method of the client instance. * @returns {string} The DNS address for this service. */ static get apiEndpoint(): string; /** * The DNS address for this API service. * @returns {string} The DNS address for this service. */ get apiEndpoint(): string; get universeDomain(): string; /** * The port for this API service. * @returns {number} The default port for this service. */ static get port(): number; /** * The scopes needed to make gRPC calls for every method defined * in this service. * @returns {string[]} List of default scopes. */ static get scopes(): string[]; getProjectId(): Promise; getProjectId(callback: Callback): void; /** * Looks up entities by key. * * @param {Object} request * The request object that will be sent. * @param {string} request.projectId * Required. The ID of the project against which to make the request. * @param {string} request.databaseId * 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 {google.datastore.v1.ReadOptions} request.readOptions * The options for this lookup request. * @param {number[]} request.keys * Required. Keys of entities to look up. * @param {google.datastore.v1.PropertyMask} request.propertyMask * The properties to return. Defaults to returning all properties. * * If this field is set and an entity has a property not referenced in the * mask, it will be absent from {@link protos.|LookupResponse.found.entity.properties}. * * The entity's key is always returned. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. * The first element of the array is an object representing {@link protos.google.datastore.v1.LookupResponse|LookupResponse}. * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } * for more details and examples. * @example include:samples/generated/v1/datastore.lookup.js * region_tag:datastore_v1_generated_Datastore_Lookup_async */ lookup(request?: protos.google.datastore.v1.ILookupRequest, options?: CallOptions): Promise<[ protos.google.datastore.v1.ILookupResponse, protos.google.datastore.v1.ILookupRequest | undefined, {} | undefined ]>; lookup(request: protos.google.datastore.v1.ILookupRequest, options: CallOptions, callback: Callback): void; lookup(request: protos.google.datastore.v1.ILookupRequest, callback: Callback): void; /** * Queries for entities. * * @param {Object} request * The request object that will be sent. * @param {string} request.projectId * Required. The ID of the project against which to make the request. * @param {string} request.databaseId * 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 {google.datastore.v1.PartitionId} request.partitionId * 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 {google.datastore.v1.ReadOptions} request.readOptions * The options for this query. * @param {google.datastore.v1.Query} request.query * The query to run. * @param {google.datastore.v1.GqlQuery} request.gqlQuery * The GQL query to run. This query must be a non-aggregation query. * @param {google.datastore.v1.PropertyMask} request.propertyMask * The properties to return. * This field must not be set for a projection query. * * See * {@link protos.google.datastore.v1.LookupRequest.property_mask|LookupRequest.property_mask}. * @param {google.datastore.v1.ExplainOptions} [request.explainOptions] * Optional. Explain options for the query. If set, additional query * statistics will be returned. If not, only query results will be returned. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. * The first element of the array is an object representing {@link protos.google.datastore.v1.RunQueryResponse|RunQueryResponse}. * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } * for more details and examples. * @example include:samples/generated/v1/datastore.run_query.js * region_tag:datastore_v1_generated_Datastore_RunQuery_async */ runQuery(request?: protos.google.datastore.v1.IRunQueryRequest, options?: CallOptions): Promise<[ protos.google.datastore.v1.IRunQueryResponse, protos.google.datastore.v1.IRunQueryRequest | undefined, {} | undefined ]>; runQuery(request: protos.google.datastore.v1.IRunQueryRequest, options: CallOptions, callback: Callback): void; runQuery(request: protos.google.datastore.v1.IRunQueryRequest, callback: Callback): void; /** * Runs an aggregation query. * * @param {Object} request * The request object that will be sent. * @param {string} request.projectId * Required. The ID of the project against which to make the request. * @param {string} request.databaseId * 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 {google.datastore.v1.PartitionId} request.partitionId * 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 {google.datastore.v1.ReadOptions} request.readOptions * The options for this query. * @param {google.datastore.v1.AggregationQuery} request.aggregationQuery * The query to run. * @param {google.datastore.v1.GqlQuery} request.gqlQuery * The GQL query to run. This query must be an aggregation query. * @param {google.datastore.v1.ExplainOptions} [request.explainOptions] * Optional. Explain options for the query. If set, additional query * statistics will be returned. If not, only query results will be returned. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. * The first element of the array is an object representing {@link protos.google.datastore.v1.RunAggregationQueryResponse|RunAggregationQueryResponse}. * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } * for more details and examples. * @example include:samples/generated/v1/datastore.run_aggregation_query.js * region_tag:datastore_v1_generated_Datastore_RunAggregationQuery_async */ runAggregationQuery(request?: protos.google.datastore.v1.IRunAggregationQueryRequest, options?: CallOptions): Promise<[ protos.google.datastore.v1.IRunAggregationQueryResponse, protos.google.datastore.v1.IRunAggregationQueryRequest | undefined, {} | undefined ]>; runAggregationQuery(request: protos.google.datastore.v1.IRunAggregationQueryRequest, options: CallOptions, callback: Callback): void; runAggregationQuery(request: protos.google.datastore.v1.IRunAggregationQueryRequest, callback: Callback): void; /** * Begins a new transaction. * * @param {Object} request * The request object that will be sent. * @param {string} request.projectId * Required. The ID of the project against which to make the request. * @param {string} request.databaseId * 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 {google.datastore.v1.TransactionOptions} request.transactionOptions * Options for a new transaction. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. * The first element of the array is an object representing {@link protos.google.datastore.v1.BeginTransactionResponse|BeginTransactionResponse}. * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } * for more details and examples. * @example include:samples/generated/v1/datastore.begin_transaction.js * region_tag:datastore_v1_generated_Datastore_BeginTransaction_async */ beginTransaction(request?: protos.google.datastore.v1.IBeginTransactionRequest, options?: CallOptions): Promise<[ protos.google.datastore.v1.IBeginTransactionResponse, protos.google.datastore.v1.IBeginTransactionRequest | undefined, {} | undefined ]>; beginTransaction(request: protos.google.datastore.v1.IBeginTransactionRequest, options: CallOptions, callback: Callback): void; beginTransaction(request: protos.google.datastore.v1.IBeginTransactionRequest, callback: Callback): void; /** * Commits a transaction, optionally creating, deleting or modifying some * entities. * * @param {Object} request * The request object that will be sent. * @param {string} request.projectId * Required. The ID of the project against which to make the request. * @param {string} request.databaseId * 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 {google.datastore.v1.CommitRequest.Mode} request.mode * The type of commit to perform. Defaults to `TRANSACTIONAL`. * @param {Buffer} request.transaction * The identifier of the transaction associated with the commit. A * transaction identifier is returned by a call to * {@link protos.google.datastore.v1.Datastore.BeginTransaction|Datastore.BeginTransaction}. * @param {google.datastore.v1.TransactionOptions} request.singleUseTransaction * Options for beginning a new transaction for this request. * The transaction is committed when the request completes. If specified, * {@link protos.google.datastore.v1.TransactionOptions|TransactionOptions.mode} must be * {@link protos.google.datastore.v1.TransactionOptions.ReadWrite|TransactionOptions.ReadWrite}. * @param {number[]} request.mutations * 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. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. * The first element of the array is an object representing {@link protos.google.datastore.v1.CommitResponse|CommitResponse}. * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } * for more details and examples. * @example include:samples/generated/v1/datastore.commit.js * region_tag:datastore_v1_generated_Datastore_Commit_async */ commit(request?: protos.google.datastore.v1.ICommitRequest, options?: CallOptions): Promise<[ protos.google.datastore.v1.ICommitResponse, protos.google.datastore.v1.ICommitRequest | undefined, {} | undefined ]>; commit(request: protos.google.datastore.v1.ICommitRequest, options: CallOptions, callback: Callback): void; commit(request: protos.google.datastore.v1.ICommitRequest, callback: Callback): void; /** * Rolls back a transaction. * * @param {Object} request * The request object that will be sent. * @param {string} request.projectId * Required. The ID of the project against which to make the request. * @param {string} request.databaseId * 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 {Buffer} request.transaction * Required. The transaction identifier, returned by a call to * {@link protos.google.datastore.v1.Datastore.BeginTransaction|Datastore.BeginTransaction}. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. * The first element of the array is an object representing {@link protos.google.datastore.v1.RollbackResponse|RollbackResponse}. * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } * for more details and examples. * @example include:samples/generated/v1/datastore.rollback.js * region_tag:datastore_v1_generated_Datastore_Rollback_async */ rollback(request?: protos.google.datastore.v1.IRollbackRequest, options?: CallOptions): Promise<[ protos.google.datastore.v1.IRollbackResponse, protos.google.datastore.v1.IRollbackRequest | undefined, {} | undefined ]>; rollback(request: protos.google.datastore.v1.IRollbackRequest, options: CallOptions, callback: Callback): void; rollback(request: protos.google.datastore.v1.IRollbackRequest, callback: Callback): void; /** * Allocates IDs for the given keys, which is useful for referencing an entity * before it is inserted. * * @param {Object} request * The request object that will be sent. * @param {string} request.projectId * Required. The ID of the project against which to make the request. * @param {string} request.databaseId * 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 {number[]} request.keys * Required. A list of keys with incomplete key paths for which to allocate * IDs. No key may be reserved/read-only. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. * The first element of the array is an object representing {@link protos.google.datastore.v1.AllocateIdsResponse|AllocateIdsResponse}. * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } * for more details and examples. * @example include:samples/generated/v1/datastore.allocate_ids.js * region_tag:datastore_v1_generated_Datastore_AllocateIds_async */ allocateIds(request?: protos.google.datastore.v1.IAllocateIdsRequest, options?: CallOptions): Promise<[ protos.google.datastore.v1.IAllocateIdsResponse, protos.google.datastore.v1.IAllocateIdsRequest | undefined, {} | undefined ]>; allocateIds(request: protos.google.datastore.v1.IAllocateIdsRequest, options: CallOptions, callback: Callback): void; allocateIds(request: protos.google.datastore.v1.IAllocateIdsRequest, callback: Callback): void; /** * Prevents the supplied keys' IDs from being auto-allocated by Cloud * Datastore. * * @param {Object} request * The request object that will be sent. * @param {string} request.projectId * Required. The ID of the project against which to make the request. * @param {string} request.databaseId * 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 {number[]} request.keys * Required. A list of keys with complete key paths whose numeric IDs should * not be auto-allocated. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. * The first element of the array is an object representing {@link protos.google.datastore.v1.ReserveIdsResponse|ReserveIdsResponse}. * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation } * for more details and examples. * @example include:samples/generated/v1/datastore.reserve_ids.js * region_tag:datastore_v1_generated_Datastore_ReserveIds_async */ reserveIds(request?: protos.google.datastore.v1.IReserveIdsRequest, options?: CallOptions): Promise<[ protos.google.datastore.v1.IReserveIdsResponse, protos.google.datastore.v1.IReserveIdsRequest | undefined, {} | undefined ]>; reserveIds(request: protos.google.datastore.v1.IReserveIdsRequest, options: CallOptions, callback: Callback): void; reserveIds(request: protos.google.datastore.v1.IReserveIdsRequest, callback: Callback): void; /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. * * @param {Object} request - The request object that will be sent. * @param {string} request.name - The name of the operation resource. * @param {Object=} options * Optional parameters. You can override the default settings for this call, * e.g, timeout, retries, paginations, etc. See {@link * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} * for the details. * @param {function(?Error, ?Object)=} callback * The function which will be called with the result of the API call. * * The second parameter to the callback is an object representing * {@link google.longrunning.Operation | google.longrunning.Operation}. * @return {Promise} - The promise which resolves to an array. * The first element of the array is an object representing * {@link google.longrunning.Operation | google.longrunning.Operation}. * The promise has a method named "cancel" which cancels the ongoing API call. * * @example * ``` * const client = longrunning.operationsClient(); * const name = ''; * const [response] = await client.getOperation({name}); * // doThingsWith(response) * ``` */ getOperation(request: protos.google.longrunning.GetOperationRequest, options?: gax.CallOptions | Callback, callback?: Callback): Promise<[protos.google.longrunning.Operation]>; /** * Lists operations that match the specified filter in the request. If the * server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object. * * For-await-of syntax is used with the iterable to recursively get response element on-demand. * * @param {Object} request - The request object that will be sent. * @param {string} request.name - The name of the operation collection. * @param {string} request.filter - The standard list filter. * @param {number=} request.pageSize - * The maximum number of resources contained in the underlying API * response. If page streaming is performed per-resource, this * parameter does not affect the return value. If page streaming is * performed per-page, this determines the maximum number of * resources in a page. * @param {Object=} options * Optional parameters. You can override the default settings for this call, * e.g, timeout, retries, paginations, etc. See {@link * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the * details. * @returns {Object} * An iterable Object that conforms to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols | iteration protocols}. * * @example * ``` * const client = longrunning.operationsClient(); * for await (const response of client.listOperationsAsync(request)); * // doThingsWith(response) * ``` */ listOperationsAsync(request: protos.google.longrunning.ListOperationsRequest, options?: gax.CallOptions): AsyncIterable; /** * Starts asynchronous cancellation on a long-running operation. The server * makes a best effort to cancel the operation, but success is not * guaranteed. If the server doesn't support this method, it returns * `google.rpc.Code.UNIMPLEMENTED`. Clients can use * {@link Operations.GetOperation} or * other methods to check whether the cancellation succeeded or whether the * operation completed despite cancellation. On successful cancellation, * the operation is not deleted; instead, it becomes an operation with * an {@link Operation.error} value with a {@link google.rpc.Status.code} of * 1, corresponding to `Code.CANCELLED`. * * @param {Object} request - The request object that will be sent. * @param {string} request.name - The name of the operation resource to be cancelled. * @param {Object=} options * Optional parameters. You can override the default settings for this call, * e.g, timeout, retries, paginations, etc. See {@link * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} for the * details. * @param {function(?Error)=} callback * The function which will be called with the result of the API call. * @return {Promise} - The promise which resolves when API call finishes. * The promise has a method named "cancel" which cancels the ongoing API * call. * * @example * ``` * const client = longrunning.operationsClient(); * await client.cancelOperation({name: ''}); * ``` */ cancelOperation(request: protos.google.longrunning.CancelOperationRequest, options?: gax.CallOptions | Callback, callback?: Callback): Promise; /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the * operation. If the server doesn't support this method, it returns * `google.rpc.Code.UNIMPLEMENTED`. * * @param {Object} request - The request object that will be sent. * @param {string} request.name - The name of the operation resource to be deleted. * @param {Object=} options * Optional parameters. You can override the default settings for this call, * e.g, timeout, retries, paginations, etc. See {@link * https://googleapis.github.io/gax-nodejs/global.html#CallOptions | gax.CallOptions} * for the details. * @param {function(?Error)=} callback * The function which will be called with the result of the API call. * @return {Promise} - The promise which resolves when API call finishes. * The promise has a method named "cancel" which cancels the ongoing API * call. * * @example * ``` * const client = longrunning.operationsClient(); * await client.deleteOperation({name: ''}); * ``` */ deleteOperation(request: protos.google.longrunning.DeleteOperationRequest, options?: gax.CallOptions | Callback, callback?: Callback): Promise; /** * Terminate the gRPC channel and close the client. * * The client will no longer be usable and all future behavior is undefined. * @returns {Promise} A promise that resolves when the client is closed. */ close(): Promise; }