UNPKG

1.92 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 * const {Datastore} = require('@google-cloud/datastore');
28 * const datastore = new Datastore();
29 * const index = datastore.index('my-index');
30 */
31export declare class Index {
32 datastore: Datastore;
33 id: string;
34 metadata?: IIndex;
35 constructor(datastore: Datastore, id: string);
36 get(gaxOptions?: CallOptions): Promise<GetIndexResponse>;
37 get(callback: GetIndexCallback): void;
38 get(gaxOptions: CallOptions, callback: GetIndexCallback): void;
39 getMetadata(gaxOptions?: CallOptions): Promise<IndexGetMetadataResponse>;
40 getMetadata(callback: IndexGetMetadataCallback): void;
41 getMetadata(gaxOptions: CallOptions, callback: IndexGetMetadataCallback): void;
42}