UNPKG

19.7 kBTypeScriptView Raw
1import * as gax from 'google-gax';
2import { Callback, CallOptions, Descriptors, ClientOptions } from 'google-gax';
3import * as protos from '../../protos/protos';
4/**
5 * Each RPC normalizes the partition IDs of the keys in its input entities,
6 * and always returns entities with keys with normalized partition IDs.
7 * This applies to all keys and entities, including those in values, except keys
8 * with both an empty path and an empty or unset partition ID. Normalization of
9 * input keys sets the project ID (if not already set) to the project ID from
10 * the request.
11 *
12 * @class
13 * @memberof v1
14 */
15export declare class DatastoreClient {
16 private _terminated;
17 private _opts;
18 private _providedCustomServicePath;
19 private _gaxModule;
20 private _gaxGrpc;
21 private _protos;
22 private _defaults;
23 auth: gax.GoogleAuth;
24 descriptors: Descriptors;
25 warn: (code: string, message: string, warnType?: string) => void;
26 innerApiCalls: {
27 [name: string]: Function;
28 };
29 datastoreStub?: Promise<{
30 [name: string]: Function;
31 }>;
32 /**
33 * Construct an instance of DatastoreClient.
34 *
35 * @param {object} [options] - The configuration object.
36 * The options accepted by the constructor are described in detail
37 * in [this document](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#creating-the-client-instance).
38 * The common options are:
39 * @param {object} [options.credentials] - Credentials object.
40 * @param {string} [options.credentials.client_email]
41 * @param {string} [options.credentials.private_key]
42 * @param {string} [options.email] - Account email address. Required when
43 * using a .pem or .p12 keyFilename.
44 * @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
45 * .p12 key downloaded from the Google Developers Console. If you provide
46 * a path to a JSON file, the projectId option below is not necessary.
47 * NOTE: .pem and .p12 require you to specify options.email as well.
48 * @param {number} [options.port] - The port on which to connect to
49 * the remote host.
50 * @param {string} [options.projectId] - The project ID from the Google
51 * Developer's Console, e.g. 'grape-spaceship-123'. We will also check
52 * the environment variable GCLOUD_PROJECT for your project ID. If your
53 * app is running in an environment which supports
54 * {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
55 * your project ID will be detected automatically.
56 * @param {string} [options.apiEndpoint] - The domain name of the
57 * API remote host.
58 * @param {gax.ClientConfig} [options.clientConfig] - Client configuration override.
59 * Follows the structure of {@link gapicConfig}.
60 * @param {boolean} [options.fallback] - Use HTTP fallback mode.
61 * In fallback mode, a special browser-compatible transport implementation is used
62 * instead of gRPC transport. In browser context (if the `window` object is defined)
63 * the fallback mode is enabled automatically; set `options.fallback` to `false`
64 * if you need to override this behavior.
65 */
66 constructor(opts?: ClientOptions);
67 /**
68 * Initialize the client.
69 * Performs asynchronous operations (such as authentication) and prepares the client.
70 * This function will be called automatically when any class method is called for the
71 * first time, but if you need to initialize it before calling an actual method,
72 * feel free to call initialize() directly.
73 *
74 * You can await on this method if you want to make sure the client is initialized.
75 *
76 * @returns {Promise} A promise that resolves to an authenticated service stub.
77 */
78 initialize(): Promise<{
79 [name: string]: Function;
80 }>;
81 /**
82 * The DNS address for this API service.
83 * @returns {string} The DNS address for this service.
84 */
85 static get servicePath(): string;
86 /**
87 * The DNS address for this API service - same as servicePath(),
88 * exists for compatibility reasons.
89 * @returns {string} The DNS address for this service.
90 */
91 static get apiEndpoint(): string;
92 /**
93 * The port for this API service.
94 * @returns {number} The default port for this service.
95 */
96 static get port(): number;
97 /**
98 * The scopes needed to make gRPC calls for every method defined
99 * in this service.
100 * @returns {string[]} List of default scopes.
101 */
102 static get scopes(): string[];
103 getProjectId(): Promise<string>;
104 getProjectId(callback: Callback<string, undefined, undefined>): void;
105 /**
106 * Looks up entities by key.
107 *
108 * @param {Object} request
109 * The request object that will be sent.
110 * @param {string} request.projectId
111 * Required. The ID of the project against which to make the request.
112 * @param {google.datastore.v1.ReadOptions} request.readOptions
113 * The options for this lookup request.
114 * @param {number[]} request.keys
115 * Required. Keys of entities to look up.
116 * @param {object} [options]
117 * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
118 * @returns {Promise} - The promise which resolves to an array.
119 * The first element of the array is an object representing [LookupResponse]{@link google.datastore.v1.LookupResponse}.
120 * Please see the
121 * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
122 * for more details and examples.
123 * @example <caption>include:samples/generated/v1/datastore.lookup.js</caption>
124 * region_tag:datastore_v1_generated_Datastore_Lookup_async
125 */
126 lookup(request?: protos.google.datastore.v1.ILookupRequest, options?: CallOptions): Promise<[
127 protos.google.datastore.v1.ILookupResponse,
128 protos.google.datastore.v1.ILookupRequest | undefined,
129 {} | undefined
130 ]>;
131 lookup(request: protos.google.datastore.v1.ILookupRequest, options: CallOptions, callback: Callback<protos.google.datastore.v1.ILookupResponse, protos.google.datastore.v1.ILookupRequest | null | undefined, {} | null | undefined>): void;
132 lookup(request: protos.google.datastore.v1.ILookupRequest, callback: Callback<protos.google.datastore.v1.ILookupResponse, protos.google.datastore.v1.ILookupRequest | null | undefined, {} | null | undefined>): void;
133 /**
134 * Queries for entities.
135 *
136 * @param {Object} request
137 * The request object that will be sent.
138 * @param {string} request.projectId
139 * Required. The ID of the project against which to make the request.
140 * @param {google.datastore.v1.PartitionId} request.partitionId
141 * Entities are partitioned into subsets, identified by a partition ID.
142 * Queries are scoped to a single partition.
143 * This partition ID is normalized with the standard default context
144 * partition ID.
145 * @param {google.datastore.v1.ReadOptions} request.readOptions
146 * The options for this query.
147 * @param {google.datastore.v1.Query} request.query
148 * The query to run.
149 * @param {google.datastore.v1.GqlQuery} request.gqlQuery
150 * The GQL query to run.
151 * @param {object} [options]
152 * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
153 * @returns {Promise} - The promise which resolves to an array.
154 * The first element of the array is an object representing [RunQueryResponse]{@link google.datastore.v1.RunQueryResponse}.
155 * Please see the
156 * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
157 * for more details and examples.
158 * @example <caption>include:samples/generated/v1/datastore.run_query.js</caption>
159 * region_tag:datastore_v1_generated_Datastore_RunQuery_async
160 */
161 runQuery(request?: protos.google.datastore.v1.IRunQueryRequest, options?: CallOptions): Promise<[
162 protos.google.datastore.v1.IRunQueryResponse,
163 protos.google.datastore.v1.IRunQueryRequest | undefined,
164 {} | undefined
165 ]>;
166 runQuery(request: protos.google.datastore.v1.IRunQueryRequest, options: CallOptions, callback: Callback<protos.google.datastore.v1.IRunQueryResponse, protos.google.datastore.v1.IRunQueryRequest | null | undefined, {} | null | undefined>): void;
167 runQuery(request: protos.google.datastore.v1.IRunQueryRequest, callback: Callback<protos.google.datastore.v1.IRunQueryResponse, protos.google.datastore.v1.IRunQueryRequest | null | undefined, {} | null | undefined>): void;
168 /**
169 * Begins a new transaction.
170 *
171 * @param {Object} request
172 * The request object that will be sent.
173 * @param {string} request.projectId
174 * Required. The ID of the project against which to make the request.
175 * @param {google.datastore.v1.TransactionOptions} request.transactionOptions
176 * Options for a new transaction.
177 * @param {object} [options]
178 * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
179 * @returns {Promise} - The promise which resolves to an array.
180 * The first element of the array is an object representing [BeginTransactionResponse]{@link google.datastore.v1.BeginTransactionResponse}.
181 * Please see the
182 * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
183 * for more details and examples.
184 * @example <caption>include:samples/generated/v1/datastore.begin_transaction.js</caption>
185 * region_tag:datastore_v1_generated_Datastore_BeginTransaction_async
186 */
187 beginTransaction(request?: protos.google.datastore.v1.IBeginTransactionRequest, options?: CallOptions): Promise<[
188 protos.google.datastore.v1.IBeginTransactionResponse,
189 protos.google.datastore.v1.IBeginTransactionRequest | undefined,
190 {} | undefined
191 ]>;
192 beginTransaction(request: protos.google.datastore.v1.IBeginTransactionRequest, options: CallOptions, callback: Callback<protos.google.datastore.v1.IBeginTransactionResponse, protos.google.datastore.v1.IBeginTransactionRequest | null | undefined, {} | null | undefined>): void;
193 beginTransaction(request: protos.google.datastore.v1.IBeginTransactionRequest, callback: Callback<protos.google.datastore.v1.IBeginTransactionResponse, protos.google.datastore.v1.IBeginTransactionRequest | null | undefined, {} | null | undefined>): void;
194 /**
195 * Commits a transaction, optionally creating, deleting or modifying some
196 * entities.
197 *
198 * @param {Object} request
199 * The request object that will be sent.
200 * @param {string} request.projectId
201 * Required. The ID of the project against which to make the request.
202 * @param {google.datastore.v1.CommitRequest.Mode} request.mode
203 * The type of commit to perform. Defaults to `TRANSACTIONAL`.
204 * @param {Buffer} request.transaction
205 * The identifier of the transaction associated with the commit. A
206 * transaction identifier is returned by a call to
207 * {@link google.datastore.v1.Datastore.BeginTransaction|Datastore.BeginTransaction}.
208 * @param {number[]} request.mutations
209 * The mutations to perform.
210 *
211 * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
212 * applied in order. The following sequences of mutations affecting a single
213 * entity are not permitted in a single `Commit` request:
214 *
215 * - `insert` followed by `insert`
216 * - `update` followed by `insert`
217 * - `upsert` followed by `insert`
218 * - `delete` followed by `update`
219 *
220 * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
221 * entity.
222 * @param {object} [options]
223 * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
224 * @returns {Promise} - The promise which resolves to an array.
225 * The first element of the array is an object representing [CommitResponse]{@link google.datastore.v1.CommitResponse}.
226 * Please see the
227 * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
228 * for more details and examples.
229 * @example <caption>include:samples/generated/v1/datastore.commit.js</caption>
230 * region_tag:datastore_v1_generated_Datastore_Commit_async
231 */
232 commit(request?: protos.google.datastore.v1.ICommitRequest, options?: CallOptions): Promise<[
233 protos.google.datastore.v1.ICommitResponse,
234 protos.google.datastore.v1.ICommitRequest | undefined,
235 {} | undefined
236 ]>;
237 commit(request: protos.google.datastore.v1.ICommitRequest, options: CallOptions, callback: Callback<protos.google.datastore.v1.ICommitResponse, protos.google.datastore.v1.ICommitRequest | null | undefined, {} | null | undefined>): void;
238 commit(request: protos.google.datastore.v1.ICommitRequest, callback: Callback<protos.google.datastore.v1.ICommitResponse, protos.google.datastore.v1.ICommitRequest | null | undefined, {} | null | undefined>): void;
239 /**
240 * Rolls back a transaction.
241 *
242 * @param {Object} request
243 * The request object that will be sent.
244 * @param {string} request.projectId
245 * Required. The ID of the project against which to make the request.
246 * @param {Buffer} request.transaction
247 * Required. The transaction identifier, returned by a call to
248 * {@link google.datastore.v1.Datastore.BeginTransaction|Datastore.BeginTransaction}.
249 * @param {object} [options]
250 * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
251 * @returns {Promise} - The promise which resolves to an array.
252 * The first element of the array is an object representing [RollbackResponse]{@link google.datastore.v1.RollbackResponse}.
253 * Please see the
254 * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
255 * for more details and examples.
256 * @example <caption>include:samples/generated/v1/datastore.rollback.js</caption>
257 * region_tag:datastore_v1_generated_Datastore_Rollback_async
258 */
259 rollback(request?: protos.google.datastore.v1.IRollbackRequest, options?: CallOptions): Promise<[
260 protos.google.datastore.v1.IRollbackResponse,
261 protos.google.datastore.v1.IRollbackRequest | undefined,
262 {} | undefined
263 ]>;
264 rollback(request: protos.google.datastore.v1.IRollbackRequest, options: CallOptions, callback: Callback<protos.google.datastore.v1.IRollbackResponse, protos.google.datastore.v1.IRollbackRequest | null | undefined, {} | null | undefined>): void;
265 rollback(request: protos.google.datastore.v1.IRollbackRequest, callback: Callback<protos.google.datastore.v1.IRollbackResponse, protos.google.datastore.v1.IRollbackRequest | null | undefined, {} | null | undefined>): void;
266 /**
267 * Allocates IDs for the given keys, which is useful for referencing an entity
268 * before it is inserted.
269 *
270 * @param {Object} request
271 * The request object that will be sent.
272 * @param {string} request.projectId
273 * Required. The ID of the project against which to make the request.
274 * @param {number[]} request.keys
275 * Required. A list of keys with incomplete key paths for which to allocate IDs.
276 * No key may be reserved/read-only.
277 * @param {object} [options]
278 * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
279 * @returns {Promise} - The promise which resolves to an array.
280 * The first element of the array is an object representing [AllocateIdsResponse]{@link google.datastore.v1.AllocateIdsResponse}.
281 * Please see the
282 * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
283 * for more details and examples.
284 * @example <caption>include:samples/generated/v1/datastore.allocate_ids.js</caption>
285 * region_tag:datastore_v1_generated_Datastore_AllocateIds_async
286 */
287 allocateIds(request?: protos.google.datastore.v1.IAllocateIdsRequest, options?: CallOptions): Promise<[
288 protos.google.datastore.v1.IAllocateIdsResponse,
289 protos.google.datastore.v1.IAllocateIdsRequest | undefined,
290 {} | undefined
291 ]>;
292 allocateIds(request: protos.google.datastore.v1.IAllocateIdsRequest, options: CallOptions, callback: Callback<protos.google.datastore.v1.IAllocateIdsResponse, protos.google.datastore.v1.IAllocateIdsRequest | null | undefined, {} | null | undefined>): void;
293 allocateIds(request: protos.google.datastore.v1.IAllocateIdsRequest, callback: Callback<protos.google.datastore.v1.IAllocateIdsResponse, protos.google.datastore.v1.IAllocateIdsRequest | null | undefined, {} | null | undefined>): void;
294 /**
295 * Prevents the supplied keys' IDs from being auto-allocated by Cloud
296 * Datastore.
297 *
298 * @param {Object} request
299 * The request object that will be sent.
300 * @param {string} request.projectId
301 * Required. The ID of the project against which to make the request.
302 * @param {string} request.databaseId
303 * If not empty, the ID of the database against which to make the request.
304 * @param {number[]} request.keys
305 * Required. A list of keys with complete key paths whose numeric IDs should not be
306 * auto-allocated.
307 * @param {object} [options]
308 * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
309 * @returns {Promise} - The promise which resolves to an array.
310 * The first element of the array is an object representing [ReserveIdsResponse]{@link google.datastore.v1.ReserveIdsResponse}.
311 * Please see the
312 * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
313 * for more details and examples.
314 * @example <caption>include:samples/generated/v1/datastore.reserve_ids.js</caption>
315 * region_tag:datastore_v1_generated_Datastore_ReserveIds_async
316 */
317 reserveIds(request?: protos.google.datastore.v1.IReserveIdsRequest, options?: CallOptions): Promise<[
318 protos.google.datastore.v1.IReserveIdsResponse,
319 protos.google.datastore.v1.IReserveIdsRequest | undefined,
320 {} | undefined
321 ]>;
322 reserveIds(request: protos.google.datastore.v1.IReserveIdsRequest, options: CallOptions, callback: Callback<protos.google.datastore.v1.IReserveIdsResponse, protos.google.datastore.v1.IReserveIdsRequest | null | undefined, {} | null | undefined>): void;
323 reserveIds(request: protos.google.datastore.v1.IReserveIdsRequest, callback: Callback<protos.google.datastore.v1.IReserveIdsResponse, protos.google.datastore.v1.IReserveIdsRequest | null | undefined, {} | null | undefined>): void;
324 /**
325 * Terminate the gRPC channel and close the client.
326 *
327 * The client will no longer be usable and all future behavior is undefined.
328 * @returns {Promise} A promise that resolves when the client is closed.
329 */
330 close(): Promise<void>;
331}