UNPKG

2.82 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 = [
19 Index[],
20 GetIndexesOptions,
21 google.datastore.admin.v1.IListIndexesResponse
22];
23export declare type GetIndexesCallback = (err?: ServiceError | null, indexes?: Index[], nextQuery?: GetIndexesOptions, apiResponse?: google.datastore.admin.v1.IListIndexesResponse) => void;
24export declare type IIndex = google.datastore.admin.v1.IIndex;
25/**
26 * @class
27 * @param {Datastore} datastore The parent instance of this index.
28 * @param {string} id The index name or id.
29 *
30 * @example
31 * ```
32 * const {Datastore} = require('@google-cloud/datastore');
33 * const datastore = new Datastore();
34 * const index = datastore.index('my-index');
35 * ```
36 */
37export declare class Index {
38 datastore: Datastore;
39 id: string;
40 metadata?: IIndex;
41 constructor(datastore: Datastore, id: string);
42 /**
43 * Get an index if it exists.
44 *
45 * @param {object} [gaxOptions] Request configuration options, outlined here:
46 * https://googleapis.github.io/gax-nodejs/CallSettings.html.
47 * @param {function} callback The callback function.
48 * @param {?error} callback.err An error returned while making this request.
49 * @param {Index} callback.index The Index instance.
50 * @param {object} callback.apiResponse The full API response.
51 */
52 get(gaxOptions?: CallOptions): Promise<GetIndexResponse>;
53 get(callback: GetIndexCallback): void;
54 get(gaxOptions: CallOptions, callback: GetIndexCallback): void;
55 /**
56 * Get the metadata of this index.
57 *
58 * @param {object} [gaxOptions] Request configuration options, outlined here:
59 * https://googleapis.github.io/gax-nodejs/CallSettings.html.
60 * @param {function} callback The callback function.
61 * @param {?error} callback.err An error returned while making this request.
62 * @param {object} callback.metadata The metadata.
63 */
64 getMetadata(gaxOptions?: CallOptions): Promise<IndexGetMetadataResponse>;
65 getMetadata(callback: IndexGetMetadataCallback): void;
66 getMetadata(gaxOptions: CallOptions, callback: IndexGetMetadataCallback): void;
67}