@google-cloud/bigtable
Version:
Cloud Bigtable Client Library for Node.js
130 lines (129 loc) • 4.62 kB
TypeScript
import { CallOptions } from 'google-gax';
import { ServiceError } from 'google-gax';
import { Bigtable } from './';
import { Table } from './table';
import { google } from '../protos/protos';
export type IColumnFamily = google.bigtable.admin.v2.IColumnFamily;
export type IGcRule = google.bigtable.admin.v2.IGcRule;
export type IModification = google.bigtable.admin.v2.ModifyColumnFamiliesRequest.IModification;
export type ITable = google.bigtable.admin.v2.ITable;
export interface RequestCallback<R> {
(err: null | ServiceError, response?: null | R): void;
}
export interface InstanceCallback<I, R> {
(err: null | ServiceError, instance?: null | I, response?: null | R): void;
}
export interface GcRule {
age?: google.protobuf.IDuration | number;
versions?: number;
rule?: GcRule;
union?: boolean;
}
export interface CreateFamilyOptions {
rule?: GcRule;
gaxOptions?: CallOptions;
}
export type CreateFamilyResponse = [Family, ITable];
export type CreateFamilyCallback = InstanceCallback<Family, ITable>;
export type DeleteFamilyResponse = [ITable];
export type DeleteFamilyCallback = RequestCallback<ITable>;
export type FamilyExistsResponse = [boolean];
export type FamilyExistsCallback = RequestCallback<boolean>;
export interface GetFamilyOptions {
autoCreate?: boolean;
gaxOptions?: CallOptions;
rule?: GcRule;
}
export type GetFamilyResponse = [Family, IColumnFamily | ITable];
export type GetFamilyCallback = InstanceCallback<Family, IColumnFamily | ITable>;
export type GetFamilyMetadataResponse = [IColumnFamily];
export type GetFamilyMetadataCallback = RequestCallback<IColumnFamily>;
export interface SetFamilyMetadataOptions {
rule?: GcRule;
}
export type SetFamilyMetadataResponse = [IColumnFamily, ITable];
export type SetFamilyMetadataCallback = InstanceCallback<IColumnFamily, ITable>;
/**
* @private
*/
export declare class FamilyError extends Error {
code: number;
constructor(name: string);
}
/**
* Create a Family object to interact with your table column families.
*
* @class
* @param {Table} table
* @param {string} id
*
* @example
* ```
* const {Bigtable} = require('@google-cloud/bigtable');
* const bigtable = new Bigtable();
* const instance = bigtable.instance('my-instance');
* const table = instance.table('prezzy');
* const family = table.family('follows');
* ```
*/
export declare class Family {
bigtable: Bigtable;
table: Table;
name: string;
id: string;
metadata?: IColumnFamily;
constructor(table: Table, id: string);
/**
* Formats Garbage Collection rule into proto format.
*
* @private
*
* @param {object} ruleObj The rule object.
* @returns {object}
*
* @example
* ```
* Family.formatRule({
* age: {
* seconds: 10000,
* nanos: 10000
* },
* versions: 2,
* union: true
* });
* // {
* // union: {
* // rules: [
* // {
* // maxAge: {
* // seconds: 10000,
* // nanos: 10000
* // }
* // }, {
* // maxNumVersions: 2
* // }
* // ]
* // }
* // }
* ```
*/
static formatRule_(ruleObj: GcRule): IGcRule;
create(options?: CreateFamilyOptions): Promise<CreateFamilyResponse>;
create(options: CreateFamilyOptions, callback: CreateFamilyCallback): void;
create(callback: CreateFamilyCallback): void;
delete(gaxOptions?: CallOptions): Promise<DeleteFamilyResponse>;
delete(gaxOptions: CallOptions, callback: DeleteFamilyCallback): void;
delete(callback: DeleteFamilyCallback): void;
exists(gaxOptions?: CallOptions): Promise<FamilyExistsResponse>;
exists(gaxOptions: CallOptions, callback: FamilyExistsCallback): void;
exists(callback: FamilyExistsCallback): void;
get(options?: GetFamilyOptions): Promise<GetFamilyResponse>;
get(options: GetFamilyOptions, callback: GetFamilyCallback): void;
get(callback: GetFamilyCallback): void;
getMetadata(gaxOptions?: CallOptions): Promise<GetFamilyMetadataResponse>;
getMetadata(gaxOptions: CallOptions, callback: GetFamilyMetadataCallback): void;
getMetadata(callback: GetFamilyMetadataCallback): void;
setMetadata(metadata: SetFamilyMetadataOptions, gaxOptions?: CallOptions): Promise<SetFamilyMetadataResponse>;
setMetadata(metadata: SetFamilyMetadataOptions, gaxOptions: CallOptions, callback: SetFamilyMetadataCallback): void;
setMetadata(metadata: SetFamilyMetadataOptions, callback: SetFamilyMetadataCallback): void;
}