UNPKG

2.81 kBTypeScriptView Raw
1import { CallOptions, ServiceError } from 'google-gax';
2import { Datastore } from './';
3import { google } from '../protos/protos';
4export interface GenericIndexCallback<T> {
5 (err?: ServiceError | null, index?: Index | null, apiResponse?: T | null): void;
6}
7export declare type GetIndexCallback = GenericIndexCallback<IIndex>;
8export declare type GetIndexResponse = [Index, IIndex];
9export declare type IndexGetMetadataCallback = (err?: ServiceError | null, metadata?: IIndex | null) => void;
10export declare type IndexGetMetadataResponse = [IIndex];
11export interface GetIndexesOptions {
12 filter?: string;
13 gaxOptions?: CallOptions;
14 pageSize?: number;
15 pageToken?: string;
16 autoPaginate?: boolean;
17}
18export declare type GetIndexesResponse = [Index[], GetIndexesOptions, google.datastore.admin.v1.IListIndexesResponse];
19export declare type GetIndexesCallback = (err?: ServiceError | null, indexes?: Index[], nextQuery?: GetIndexesOptions, apiResponse?: google.datastore.admin.v1.IListIndexesResponse) => void;
20export declare type IIndex = google.datastore.admin.v1.IIndex;
21/**
22 * @class
23 * @param {Datastore} datastore The parent instance of this index.
24 * @param {string} id The index name or id.
25 *
26 * @example
27 * ```
28 * const {Datastore} = require('@google-cloud/datastore');
29 * const datastore = new Datastore();
30 * const index = datastore.index('my-index');
31 * ```
32 */
33export declare class Index {
34 datastore: Datastore;
35 id: string;
36 metadata?: IIndex;
37 constructor(datastore: Datastore, id: string);
38 /**
39 * Get an index if it exists.
40 *
41 * @param {object} [gaxOptions] Request configuration options, outlined here:
42 * https://googleapis.github.io/gax-nodejs/CallSettings.html.
43 * @param {function} callback The callback function.
44 * @param {?error} callback.err An error returned while making this request.
45 * @param {Index} callback.index The Index instance.
46 * @param {object} callback.apiResponse The full API response.
47 */
48 get(gaxOptions?: CallOptions): Promise<GetIndexResponse>;
49 get(callback: GetIndexCallback): void;
50 get(gaxOptions: CallOptions, callback: GetIndexCallback): void;
51 /**
52 * Get the metadata of this index.
53 *
54 * @param {object} [gaxOptions] Request configuration options, outlined here:
55 * https://googleapis.github.io/gax-nodejs/CallSettings.html.
56 * @param {function} callback The callback function.
57 * @param {?error} callback.err An error returned while making this request.
58 * @param {object} callback.metadata The metadata.
59 */
60 getMetadata(gaxOptions?: CallOptions): Promise<IndexGetMetadataResponse>;
61 getMetadata(callback: IndexGetMetadataCallback): void;
62 getMetadata(gaxOptions: CallOptions, callback: IndexGetMetadataCallback): void;
63}