// Copyright 2022 Luca Casonato. All rights reserved. MIT license. /** * BigLake API Client for Deno * =========================== * * The BigLake API provides access to BigLake Metastore, a serverless, fully managed, and highly available metastore for open-source data that can be used for querying Apache Iceberg tables in BigQuery. * * Docs: https://cloud.google.com/bigquery/ * Source: https://googleapis.deno.dev/v1/biglake:v1.ts */ import { auth, CredentialsClient, GoogleAuth, request } from "/_/base@v1/mod.ts"; export { auth, GoogleAuth }; export type { CredentialsClient }; /** * The BigLake API provides access to BigLake Metastore, a serverless, fully * managed, and highly available metastore for open-source data that can be used * for querying Apache Iceberg tables in BigQuery. */ export class BigLake { #client: CredentialsClient | undefined; #baseUrl: string; constructor(client?: CredentialsClient, baseUrl: string = "https://biglake.googleapis.com/") { this.#client = client; this.#baseUrl = baseUrl; } /** * Creates a new catalog. * * @param parent Required. The parent resource where this catalog will be created. Format: projects/{project_id_or_number}/locations/{location_id} */ async projectsLocationsCatalogsCreate(parent: string, req: Catalog, opts: ProjectsLocationsCatalogsCreateOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ parent }/catalogs`); if (opts.catalogId !== undefined) { url.searchParams.append("catalogId", String(opts.catalogId)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as Catalog; } /** * Creates a new database. * * @param parent Required. The parent resource where this database will be created. Format: projects/{project_id_or_number}/locations/{location_id}/catalogs/{catalog_id} */ async projectsLocationsCatalogsDatabasesCreate(parent: string, req: Database, opts: ProjectsLocationsCatalogsDatabasesCreateOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ parent }/databases`); if (opts.databaseId !== undefined) { url.searchParams.append("databaseId", String(opts.databaseId)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as Database; } /** * Deletes an existing database specified by the database ID. * * @param name Required. The name of the database to delete. Format: projects/{project_id_or_number}/locations/{location_id}/catalogs/{catalog_id}/databases/{database_id} */ async projectsLocationsCatalogsDatabasesDelete(name: string): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }`); const data = await request(url.href, { client: this.#client, method: "DELETE", }); return data as Database; } /** * Gets the database specified by the resource name. * * @param name Required. The name of the database to retrieve. Format: projects/{project_id_or_number}/locations/{location_id}/catalogs/{catalog_id}/databases/{database_id} */ async projectsLocationsCatalogsDatabasesGet(name: string): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }`); const data = await request(url.href, { client: this.#client, method: "GET", }); return data as Database; } /** * List all databases in a specified catalog. * * @param parent Required. The parent, which owns this collection of databases. Format: projects/{project_id_or_number}/locations/{location_id}/catalogs/{catalog_id} */ async projectsLocationsCatalogsDatabasesList(parent: string, opts: ProjectsLocationsCatalogsDatabasesListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ parent }/databases`); if (opts.pageSize !== undefined) { url.searchParams.append("pageSize", String(opts.pageSize)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return data as ListDatabasesResponse; } /** * Updates an existing database specified by the database ID. * * @param name Output only. The resource name. Format: projects/{project_id_or_number}/locations/{location_id}/catalogs/{catalog_id}/databases/{database_id} */ async projectsLocationsCatalogsDatabasesPatch(name: string, req: Database, opts: ProjectsLocationsCatalogsDatabasesPatchOptions = {}): Promise { opts = serializeProjectsLocationsCatalogsDatabasesPatchOptions(opts); const url = new URL(`${this.#baseUrl}v1/${ name }`); if (opts.updateMask !== undefined) { url.searchParams.append("updateMask", String(opts.updateMask)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "PATCH", body, }); return data as Database; } /** * Creates a new table. * * @param parent Required. The parent resource where this table will be created. Format: projects/{project_id_or_number}/locations/{location_id}/catalogs/{catalog_id}/databases/{database_id} */ async projectsLocationsCatalogsDatabasesTablesCreate(parent: string, req: Table, opts: ProjectsLocationsCatalogsDatabasesTablesCreateOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ parent }/tables`); if (opts.tableId !== undefined) { url.searchParams.append("tableId", String(opts.tableId)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as Table; } /** * Deletes an existing table specified by the table ID. * * @param name Required. The name of the table to delete. Format: projects/{project_id_or_number}/locations/{location_id}/catalogs/{catalog_id}/databases/{database_id}/tables/{table_id} */ async projectsLocationsCatalogsDatabasesTablesDelete(name: string): Promise
{ const url = new URL(`${this.#baseUrl}v1/${ name }`); const data = await request(url.href, { client: this.#client, method: "DELETE", }); return data as Table; } /** * Gets the table specified by the resource name. * * @param name Required. The name of the table to retrieve. Format: projects/{project_id_or_number}/locations/{location_id}/catalogs/{catalog_id}/databases/{database_id}/tables/{table_id} */ async projectsLocationsCatalogsDatabasesTablesGet(name: string): Promise
{ const url = new URL(`${this.#baseUrl}v1/${ name }`); const data = await request(url.href, { client: this.#client, method: "GET", }); return data as Table; } /** * List all tables in a specified database. * * @param parent Required. The parent, which owns this collection of tables. Format: projects/{project_id_or_number}/locations/{location_id}/catalogs/{catalog_id}/databases/{database_id} */ async projectsLocationsCatalogsDatabasesTablesList(parent: string, opts: ProjectsLocationsCatalogsDatabasesTablesListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ parent }/tables`); if (opts.pageSize !== undefined) { url.searchParams.append("pageSize", String(opts.pageSize)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } if (opts.view !== undefined) { url.searchParams.append("view", String(opts.view)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return data as ListTablesResponse; } /** * Updates an existing table specified by the table ID. * * @param name Output only. The resource name. Format: projects/{project_id_or_number}/locations/{location_id}/catalogs/{catalog_id}/databases/{database_id}/tables/{table_id} */ async projectsLocationsCatalogsDatabasesTablesPatch(name: string, req: Table, opts: ProjectsLocationsCatalogsDatabasesTablesPatchOptions = {}): Promise
{ opts = serializeProjectsLocationsCatalogsDatabasesTablesPatchOptions(opts); const url = new URL(`${this.#baseUrl}v1/${ name }`); if (opts.updateMask !== undefined) { url.searchParams.append("updateMask", String(opts.updateMask)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "PATCH", body, }); return data as Table; } /** * Renames an existing table specified by the table ID. * * @param name Required. The table's `name` field is used to identify the table to rename. Format: projects/{project_id_or_number}/locations/{location_id}/catalogs/{catalog_id}/databases/{database_id}/tables/{table_id} */ async projectsLocationsCatalogsDatabasesTablesRename(name: string, req: RenameTableRequest): Promise
{ const url = new URL(`${this.#baseUrl}v1/${ name }:rename`); const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as Table; } /** * Deletes an existing catalog specified by the catalog ID. * * @param name Required. The name of the catalog to delete. Format: projects/{project_id_or_number}/locations/{location_id}/catalogs/{catalog_id} */ async projectsLocationsCatalogsDelete(name: string): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }`); const data = await request(url.href, { client: this.#client, method: "DELETE", }); return data as Catalog; } /** * Gets the catalog specified by the resource name. * * @param name Required. The name of the catalog to retrieve. Format: projects/{project_id_or_number}/locations/{location_id}/catalogs/{catalog_id} */ async projectsLocationsCatalogsGet(name: string): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }`); const data = await request(url.href, { client: this.#client, method: "GET", }); return data as Catalog; } /** * List all catalogs in a specified project. * * @param parent Required. The parent, which owns this collection of catalogs. Format: projects/{project_id_or_number}/locations/{location_id} */ async projectsLocationsCatalogsList(parent: string, opts: ProjectsLocationsCatalogsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ parent }/catalogs`); if (opts.pageSize !== undefined) { url.searchParams.append("pageSize", String(opts.pageSize)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return data as ListCatalogsResponse; } } /** * Catalog is the container of databases. */ export interface Catalog { /** * Output only. The creation time of the catalog. */ readonly createTime?: Date; /** * Output only. The deletion time of the catalog. Only set after the catalog * is deleted. */ readonly deleteTime?: Date; /** * Output only. The time when this catalog is considered expired. Only set * after the catalog is deleted. */ readonly expireTime?: Date; /** * Output only. The resource name. Format: * projects/{project_id_or_number}/locations/{location_id}/catalogs/{catalog_id} */ readonly name?: string; /** * Output only. The last modification time of the catalog. */ readonly updateTime?: Date; } /** * Database is the container of tables. */ export interface Database { /** * Output only. The creation time of the database. */ readonly createTime?: Date; /** * Output only. The deletion time of the database. Only set after the * database is deleted. */ readonly deleteTime?: Date; /** * Output only. The time when this database is considered expired. Only set * after the database is deleted. */ readonly expireTime?: Date; /** * Options of a Hive database. */ hiveOptions?: HiveDatabaseOptions; /** * Output only. The resource name. Format: * projects/{project_id_or_number}/locations/{location_id}/catalogs/{catalog_id}/databases/{database_id} */ readonly name?: string; /** * The database type. */ type?: | "TYPE_UNSPECIFIED" | "HIVE"; /** * Output only. The last modification time of the database. */ readonly updateTime?: Date; } /** * Options of a Hive database. */ export interface HiveDatabaseOptions { /** * Cloud Storage folder URI where the database data is stored, starting with * "gs://". */ locationUri?: string; /** * Stores user supplied Hive database parameters. */ parameters?: { [key: string]: string }; } /** * Options of a Hive table. */ export interface HiveTableOptions { /** * Stores user supplied Hive table parameters. */ parameters?: { [key: string]: string }; /** * Stores physical storage information of the data. */ storageDescriptor?: StorageDescriptor; /** * Hive table type. For example, MANAGED_TABLE, EXTERNAL_TABLE. */ tableType?: string; } /** * Response message for the ListCatalogs method. */ export interface ListCatalogsResponse { /** * The catalogs from the specified project. */ catalogs?: Catalog[]; /** * A token, which can be sent as `page_token` to retrieve the next page. If * this field is omitted, there are no subsequent pages. */ nextPageToken?: string; } /** * Response message for the ListDatabases method. */ export interface ListDatabasesResponse { /** * The databases from the specified catalog. */ databases?: Database[]; /** * A token, which can be sent as `page_token` to retrieve the next page. If * this field is omitted, there are no subsequent pages. */ nextPageToken?: string; } /** * Response message for the ListTables method. */ export interface ListTablesResponse { /** * A token, which can be sent as `page_token` to retrieve the next page. If * this field is omitted, there are no subsequent pages. */ nextPageToken?: string; /** * The tables from the specified database. */ tables?: Table[]; } /** * Additional options for BigLake#projectsLocationsCatalogsCreate. */ export interface ProjectsLocationsCatalogsCreateOptions { /** * Required. The ID to use for the catalog, which will become the final * component of the catalog's resource name. */ catalogId?: string; } /** * Additional options for BigLake#projectsLocationsCatalogsDatabasesCreate. */ export interface ProjectsLocationsCatalogsDatabasesCreateOptions { /** * Required. The ID to use for the database, which will become the final * component of the database's resource name. */ databaseId?: string; } /** * Additional options for BigLake#projectsLocationsCatalogsDatabasesList. */ export interface ProjectsLocationsCatalogsDatabasesListOptions { /** * The maximum number of databases to return. The service may return fewer * than this value. If unspecified, at most 50 databases will be returned. The * maximum value is 1000; values above 1000 will be coerced to 1000. */ pageSize?: number; /** * A page token, received from a previous `ListDatabases` call. Provide this * to retrieve the subsequent page. When paginating, all other parameters * provided to `ListDatabases` must match the call that provided the page * token. */ pageToken?: string; } /** * Additional options for BigLake#projectsLocationsCatalogsDatabasesPatch. */ export interface ProjectsLocationsCatalogsDatabasesPatchOptions { /** * The list of fields to update. For the `FieldMask` definition, see * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask * If not set, defaults to all of the fields that are allowed to update. */ updateMask?: string /* FieldMask */; } function serializeProjectsLocationsCatalogsDatabasesPatchOptions(data: any): ProjectsLocationsCatalogsDatabasesPatchOptions { return { ...data, updateMask: data["updateMask"] !== undefined ? data["updateMask"] : undefined, }; } function deserializeProjectsLocationsCatalogsDatabasesPatchOptions(data: any): ProjectsLocationsCatalogsDatabasesPatchOptions { return { ...data, updateMask: data["updateMask"] !== undefined ? data["updateMask"] : undefined, }; } /** * Additional options for * BigLake#projectsLocationsCatalogsDatabasesTablesCreate. */ export interface ProjectsLocationsCatalogsDatabasesTablesCreateOptions { /** * Required. The ID to use for the table, which will become the final * component of the table's resource name. */ tableId?: string; } /** * Additional options for BigLake#projectsLocationsCatalogsDatabasesTablesList. */ export interface ProjectsLocationsCatalogsDatabasesTablesListOptions { /** * The maximum number of tables to return. The service may return fewer than * this value. If unspecified, at most 50 tables will be returned. The maximum * value is 1000; values above 1000 will be coerced to 1000. */ pageSize?: number; /** * A page token, received from a previous `ListTables` call. Provide this to * retrieve the subsequent page. When paginating, all other parameters * provided to `ListTables` must match the call that provided the page token. */ pageToken?: string; /** * The view for the returned tables. */ view?: | "TABLE_VIEW_UNSPECIFIED" | "BASIC" | "FULL"; } /** * Additional options for * BigLake#projectsLocationsCatalogsDatabasesTablesPatch. */ export interface ProjectsLocationsCatalogsDatabasesTablesPatchOptions { /** * The list of fields to update. For the `FieldMask` definition, see * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask * If not set, defaults to all of the fields that are allowed to update. */ updateMask?: string /* FieldMask */; } function serializeProjectsLocationsCatalogsDatabasesTablesPatchOptions(data: any): ProjectsLocationsCatalogsDatabasesTablesPatchOptions { return { ...data, updateMask: data["updateMask"] !== undefined ? data["updateMask"] : undefined, }; } function deserializeProjectsLocationsCatalogsDatabasesTablesPatchOptions(data: any): ProjectsLocationsCatalogsDatabasesTablesPatchOptions { return { ...data, updateMask: data["updateMask"] !== undefined ? data["updateMask"] : undefined, }; } /** * Additional options for BigLake#projectsLocationsCatalogsList. */ export interface ProjectsLocationsCatalogsListOptions { /** * The maximum number of catalogs to return. The service may return fewer * than this value. If unspecified, at most 50 catalogs will be returned. The * maximum value is 1000; values above 1000 will be coerced to 1000. */ pageSize?: number; /** * A page token, received from a previous `ListCatalogs` call. Provide this * to retrieve the subsequent page. When paginating, all other parameters * provided to `ListCatalogs` must match the call that provided the page * token. */ pageToken?: string; } /** * Request message for the RenameTable method in MetastoreService */ export interface RenameTableRequest { /** * Required. The new `name` for the specified table, must be in the same * database. Format: * projects/{project_id_or_number}/locations/{location_id}/catalogs/{catalog_id}/databases/{database_id}/tables/{table_id} */ newName?: string; } /** * Serializer and deserializer information. */ export interface SerDeInfo { /** * The fully qualified Java class name of the serialization library. */ serializationLib?: string; } /** * Stores physical storage information of the data. */ export interface StorageDescriptor { /** * The fully qualified Java class name of the input format. */ inputFormat?: string; /** * Cloud Storage folder URI where the table data is stored, starting with * "gs://". */ locationUri?: string; /** * The fully qualified Java class name of the output format. */ outputFormat?: string; /** * Serializer and deserializer information. */ serdeInfo?: SerDeInfo; } /** * Represents a table. */ export interface Table { /** * Output only. The creation time of the table. */ readonly createTime?: Date; /** * Output only. The deletion time of the table. Only set after the table is * deleted. */ readonly deleteTime?: Date; /** * The checksum of a table object computed by the server based on the value * of other fields. It may be sent on update requests to ensure the client has * an up-to-date value before proceeding. It is only checked for update table * operations. */ etag?: string; /** * Output only. The time when this table is considered expired. Only set * after the table is deleted. */ readonly expireTime?: Date; /** * Options of a Hive table. */ hiveOptions?: HiveTableOptions; /** * Output only. The resource name. Format: * projects/{project_id_or_number}/locations/{location_id}/catalogs/{catalog_id}/databases/{database_id}/tables/{table_id} */ readonly name?: string; /** * The table type. */ type?: | "TYPE_UNSPECIFIED" | "HIVE"; /** * Output only. The last modification time of the table. */ readonly updateTime?: Date; }