// Copyright 2022 Luca Casonato. All rights reserved. MIT license. /** * Cloud Location Finder API Client for Deno * ========================================= * * * * Docs: https://cloud.google.com/location-finder/docs * Source: https://googleapis.deno.dev/v1/cloudlocationfinder:v1.ts */ import { auth, CredentialsClient, GoogleAuth, request } from "/_/base@v1/mod.ts"; export { auth, GoogleAuth }; export type { CredentialsClient }; export class CloudLocationFinder { #client: CredentialsClient | undefined; #baseUrl: string; constructor(client?: CredentialsClient, baseUrl: string = "https://cloudlocationfinder.googleapis.com/") { this.#client = client; this.#baseUrl = baseUrl; } /** * Retrieves a resource containing information about a cloud location. * * @param name Required. Name of the resource. */ async projectsLocationsCloudLocationsGet(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 CloudLocation; } /** * Lists cloud locations under a given project and location. * * @param parent Required. The parent, which owns this collection of cloud locations. Format: projects/{project}/locations/{location} */ async projectsLocationsCloudLocationsList(parent: string, opts: ProjectsLocationsCloudLocationsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ parent }/cloudLocations`); if (opts.filter !== undefined) { url.searchParams.append("filter", String(opts.filter)); } 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 ListCloudLocationsResponse; } /** * Searches for cloud locations from a given source location. * * @param parent Required. The parent, which owns this collection of cloud locations. Format: projects/{project}/locations/{location} */ async projectsLocationsCloudLocationsSearch(parent: string, opts: ProjectsLocationsCloudLocationsSearchOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ parent }/cloudLocations:search`); if (opts.pageSize !== undefined) { url.searchParams.append("pageSize", String(opts.pageSize)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } if (opts.query !== undefined) { url.searchParams.append("query", String(opts.query)); } if (opts.sourceCloudLocation !== undefined) { url.searchParams.append("sourceCloudLocation", String(opts.sourceCloudLocation)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return data as SearchCloudLocationsResponse; } /** * Gets information about a location. * * @param name Resource name for the location. */ async projectsLocationsGet(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 Location; } /** * Lists information about the supported locations for this service. This * method can be called in two ways: * **List all public locations:** Use the * path `GET /v1/locations`. * **List project-visible locations:** Use the * path `GET /v1/projects/{project_id}/locations`. This may include public * locations as well as private or other locations specifically visible to the * project. * * @param name The resource that owns the locations collection, if applicable. */ async projectsLocationsList(name: string, opts: ProjectsLocationsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }/locations`); if (opts.extraLocationTypes !== undefined) { url.searchParams.append("extraLocationTypes", String(opts.extraLocationTypes)); } if (opts.filter !== undefined) { url.searchParams.append("filter", String(opts.filter)); } 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 ListLocationsResponse; } } /** * Represents resource cloud locations. */ export interface CloudLocation { /** * Optional. The carbon free energy percentage of the cloud location. This * represents the average percentage of time customers' application will be * running on carbon-free energy. See * https://cloud.google.com/sustainability/region-carbon for more details. * There is a difference between default value 0 and unset value. 0 means the * carbon free energy percentage is 0%, while unset value means the carbon * footprint data is not available. */ carbonFreeEnergyPercentage?: number; /** * Optional. The type of the cloud location. */ cloudLocationType?: | "CLOUD_LOCATION_TYPE_UNSPECIFIED" | "CLOUD_LOCATION_TYPE_REGION" | "CLOUD_LOCATION_TYPE_ZONE" | "CLOUD_LOCATION_TYPE_REGION_EXTENSION" | "CLOUD_LOCATION_TYPE_GDCC_ZONE"; /** * Optional. The provider of the cloud location. Values can be Google Cloud * or third-party providers, including AWS, Azure, or Oracle Cloud * Infrastructure. */ cloudProvider?: | "CLOUD_PROVIDER_UNSPECIFIED" | "CLOUD_PROVIDER_GCP" | "CLOUD_PROVIDER_AWS" | "CLOUD_PROVIDER_AZURE" | "CLOUD_PROVIDER_OCI"; /** * Output only. The containing cloud location in the strict nesting * hierarchy. For example, the containing cloud location of a zone is a * region. */ readonly containingCloudLocation?: string; /** * Optional. The human-readable name of the cloud location. Example: * us-east-2, us-east1. */ displayName?: string; /** * Identifier. Name of the cloud location. Unique name of the cloud location * including project and location using the form: * `projects/{project_id}/locations/{location}/cloudLocations/{cloud_location}` */ name?: string; /** * Optional. The two-letter ISO 3166-1 alpha-2 code of the cloud location. * Examples: US, JP, KR. */ territoryCode?: string; } /** * Message for response to listing cloud locations. */ export interface ListCloudLocationsResponse { /** * Output only. List of cloud locations. */ readonly cloudLocations?: CloudLocation[]; /** * Output only. The continuation token, used to page through large result * sets. Provide this value in a subsequent request as page_token in * subsequent requests to retrieve the next page. If this field is not * present, there are no subsequent results. */ readonly nextPageToken?: string; } /** * The response message for Locations.ListLocations. */ export interface ListLocationsResponse { /** * A list of locations that matches the specified filter in the request. */ locations?: Location[]; /** * The standard List next-page token. */ nextPageToken?: string; } /** * A resource that represents a Google Cloud location. */ export interface Location { /** * The friendly name for this location, typically a nearby city name. For * example, "Tokyo". */ displayName?: string; /** * Cross-service attributes for the location. For example * {"cloud.googleapis.com/region": "us-east1"} */ labels?: { [key: string]: string }; /** * The canonical id for this location. For example: `"us-east1"`. */ locationId?: string; /** * Service-specific metadata. For example the available capacity at the given * location. */ metadata?: { [key: string]: any }; /** * Resource name for the location, which may vary between implementations. * For example: `"projects/example-project/locations/us-east1"` */ name?: string; } /** * Additional options for * CloudLocationFinder#projectsLocationsCloudLocationsList. */ export interface ProjectsLocationsCloudLocationsListOptions { /** * Optional. A filter expression that filters resources listed in the * response. The expression is in the form of field=value. For example, * 'cloud_location_type=CLOUD_LOCATION_TYPE_REGION'. Multiple filter queries * are space-separated. For example, * 'cloud_location_type=CLOUD_LOCATION_TYPE_REGION territory_code="US"' By * default, each expression is an AND expression. However, you can include AND * and OR expressions explicitly. */ filter?: string; /** * Optional. The maximum number of cloud locations to return per page. The * service might return fewer cloud locations than this value. If unspecified, * server will pick an appropriate default. */ pageSize?: number; /** * Optional. A token identifying a page of results the server should return. * Provide page token returned by a previous 'ListCloudLocations' call to * retrieve the next page of results. When paginating, all other parameters * provided to 'ListCloudLocations' must match the call that provided the page * token. */ pageToken?: string; } /** * Additional options for * CloudLocationFinder#projectsLocationsCloudLocationsSearch. */ export interface ProjectsLocationsCloudLocationsSearchOptions { /** * Optional. The maximum number of cloud locations to return. The service * might return fewer cloud locations than this value. If unspecified, server * will pick an appropriate default. */ pageSize?: number; /** * Optional. A token identifying a page of results the server should return. * Provide Page token returned by a previous 'ListCloudLocations' call to * retrieve the next page of results. When paginating, all other parameters * provided to 'ListCloudLocations' must match the call that provided the page * token. */ pageToken?: string; /** * Optional. The query string in search query syntax. While filter is used to * filter the search results by attributes, query is used to specify the * search requirements. */ query?: string; /** * Required. The source cloud location to search from. Example search can be * searching nearby cloud locations from the source cloud location by latency. */ sourceCloudLocation?: string; } /** * Additional options for CloudLocationFinder#projectsLocationsList. */ export interface ProjectsLocationsListOptions { /** * Optional. Do not use this field. It is unsupported and is ignored unless * explicitly documented otherwise. This is primarily for internal usage. */ extraLocationTypes?: string; /** * A filter to narrow down results to a preferred subset. The filtering * language accepts strings like `"displayName=tokyo"`, and is documented in * more detail in [AIP-160](https://google.aip.dev/160). */ filter?: string; /** * The maximum number of results to return. If not set, the service selects a * default. */ pageSize?: number; /** * A page token received from the `next_page_token` field in the response. * Send that page token to receive the subsequent page. */ pageToken?: string; } /** * Message for response to searching cloud locations. */ export interface SearchCloudLocationsResponse { /** * Output only. List of cloud locations. */ readonly cloudLocations?: CloudLocation[]; /** * Output only. The continuation token, used to page through large result * sets. Provide this value in a subsequent request as page_token in * subsequent requests to retrieve the next page. If this field is not * present, there are no subsequent results. */ readonly nextPageToken?: string; }