UNPKG

7.57 kBTypeScriptView Raw
1/*!
2 * Copyright 2014 Google Inc. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16/// <reference types="node" />
17import { DeleteCallback, Metadata, ServiceObject } from '@google-cloud/common';
18import { ResourceStream } from '@google-cloud/paginator';
19import { Duplex } from 'stream';
20import { BigQuery, PagedCallback, PagedRequest, PagedResponse, Query, QueryRowsResponse, ResourceCallback, SimpleQueryRowsCallback } from './bigquery';
21import { JobCallback, JobResponse, Table, TableMetadata, TableOptions } from './table';
22import { Model } from './model';
23import { Routine } from './routine';
24import bigquery from './types';
25export interface DatasetDeleteOptions {
26 force?: boolean;
27}
28export interface DatasetOptions {
29 location?: string;
30}
31export declare type CreateDatasetOptions = bigquery.IDataset;
32export declare type GetModelsOptions = PagedRequest<bigquery.models.IListParams>;
33export declare type GetModelsResponse = PagedResponse<Model, GetModelsOptions, bigquery.IListModelsResponse>;
34export declare type GetModelsCallback = PagedCallback<Model, GetModelsOptions, bigquery.IListModelsResponse>;
35export declare type GetRoutinesOptions = PagedRequest<bigquery.routines.IListParams>;
36export declare type GetRoutinesResponse = PagedResponse<Routine, GetRoutinesOptions, bigquery.IListRoutinesResponse>;
37export declare type GetRoutinesCallback = PagedCallback<Routine, GetRoutinesOptions, bigquery.IListRoutinesResponse>;
38export declare type GetTablesOptions = PagedRequest<bigquery.tables.IListParams>;
39export declare type GetTablesResponse = PagedResponse<Table, GetTablesOptions, bigquery.ITableList>;
40export declare type GetTablesCallback = PagedCallback<Table, GetTablesOptions, bigquery.ITableList>;
41export declare type RoutineMetadata = bigquery.IRoutine;
42export declare type RoutineResponse = [Routine, bigquery.IRoutine];
43export declare type RoutineCallback = ResourceCallback<Routine, bigquery.IRoutine>;
44export declare type TableResponse = [Table, bigquery.ITable];
45export declare type TableCallback = ResourceCallback<Table, bigquery.ITable>;
46/**
47 * Interact with your BigQuery dataset. Create a Dataset instance with
48 * {@link BigQuery#createDataset} or {@link BigQuery#dataset}.
49 *
50 * @class
51 * @param {BigQuery} bigQuery {@link BigQuery} instance.
52 * @param {string} id The ID of the Dataset.
53 * @param {object} [options] Dataset options.
54 * @param {string} [options.location] The geographic location of the dataset.
55 * Defaults to US.
56 *
57 * @example
58 * const {BigQuery} = require('@google-cloud/bigquery');
59 * const bigquery = new BigQuery();
60 * const dataset = bigquery.dataset('institutions');
61 */
62declare class Dataset extends ServiceObject {
63 bigQuery: BigQuery;
64 location?: string;
65 getModelsStream: (options?: GetModelsOptions) => ResourceStream<Model>;
66 getRoutinesStream: (options?: GetRoutinesOptions) => ResourceStream<Routine>;
67 getTablesStream: (options?: GetTablesOptions) => ResourceStream<Table>;
68 constructor(bigQuery: BigQuery, id: string, options?: DatasetOptions);
69 createQueryJob(options: string | Query): Promise<JobResponse>;
70 createQueryJob(options: string | Query, callback: JobCallback): void;
71 /**
72 * Run a query scoped to your dataset as a readable object stream.
73 *
74 * See {@link BigQuery#createQueryStream} for full documentation of this
75 * method.
76 *
77 * @param {object} options See {@link BigQuery#createQueryStream} for full
78 * documentation of this method.
79 * @returns {stream}
80 */
81 createQueryStream(options: Query | string): Duplex;
82 createRoutine(id: string, config: RoutineMetadata): Promise<RoutineResponse>;
83 createRoutine(id: string, config: RoutineMetadata, callback: RoutineCallback): void;
84 createTable(id: string, options: TableMetadata): Promise<TableResponse>;
85 createTable(id: string, options: TableMetadata, callback: TableCallback): void;
86 createTable(id: string, callback: TableCallback): void;
87 delete(options?: DatasetDeleteOptions): Promise<[Metadata]>;
88 delete(options: DatasetDeleteOptions, callback: DeleteCallback): void;
89 delete(callback: DeleteCallback): void;
90 getModels(options?: GetModelsOptions): Promise<GetModelsResponse>;
91 getModels(options: GetModelsOptions, callback: GetModelsCallback): void;
92 getModels(callback: GetModelsCallback): void;
93 getRoutines(options?: GetRoutinesOptions): Promise<GetRoutinesResponse>;
94 getRoutines(options: GetRoutinesOptions, callback: GetRoutinesCallback): void;
95 getRoutines(callback: GetRoutinesCallback): void;
96 getTables(options?: GetTablesOptions): Promise<GetTablesResponse>;
97 getTables(options: GetTablesOptions, callback: GetTablesCallback): void;
98 getTables(callback: GetTablesCallback): void;
99 /**
100 * Create a {@link Model} object.
101 *
102 * @throws {TypeError} if model ID is missing.
103 *
104 * @param {string} id The ID of the model.
105 * @return {Model}
106 *
107 * @example
108 * const {BigQuery} = require('@google-cloud/bigquery');
109 * const bigquery = new BigQuery();
110 * const dataset = bigquery.dataset('institutions');
111 *
112 * const model = dataset.model('my-model');
113 */
114 model(id: string): Model;
115 query(options: Query): Promise<QueryRowsResponse>;
116 query(options: string): Promise<QueryRowsResponse>;
117 query(options: Query, callback: SimpleQueryRowsCallback): void;
118 query(options: string, callback: SimpleQueryRowsCallback): void;
119 /**
120 * Create a {@link Routine} object.
121 *
122 * @throws {TypeError} if routine ID is missing.
123 *
124 * @param {string} id The ID of the routine.
125 * @returns {Routine}
126 *
127 * @example
128 * const {BigQuery} = require('@google-cloud/bigquery');
129 * const bigquery = new BigQuery();
130 * const dataset = bigquery.dataset('institutions');
131 *
132 * const routine = dataset.routine('my_routine');
133 */
134 routine(id: string): Routine;
135 /**
136 * Create a {@link Table} object.
137 *
138 * @throws {TypeError} if table ID is missing.
139 *
140 * @param {string} id The ID of the table.
141 * @param {object} [options] Table options.
142 * @param {string} [options.location] The geographic location of the table, by
143 * default this value is inherited from the dataset. This can be used to
144 * configure the location of all jobs created through a table instance.
145 * It cannot be used to set the actual location of the table. This value will
146 * be superseded by any API responses containing location data for the
147 * table.
148 * @return {Table}
149 *
150 * @example
151 * const {BigQuery} = require('@google-cloud/bigquery');
152 * const bigquery = new BigQuery();
153 * const dataset = bigquery.dataset('institutions');
154 *
155 * const institutions = dataset.table('institution_data');
156 */
157 table(id: string, options?: TableOptions): Table;
158}
159/**
160 * Reference to the {@link Dataset} class.
161 * @name module:@google-cloud/bigquery.Dataset
162 * @see Dataset
163 */
164export { Dataset };