// Copyright 2022 Luca Casonato. All rights reserved. MIT license. /** * Parameter Manager API Client for Deno * ===================================== * * Parameter Manager is a single source of truth to store, access and manage the lifecycle of your workload parameters. Parameter Manager aims to make management of sensitive application parameters effortless for customers without diminishing focus on security. * * Docs: https://cloud.google.com/secret-manager/parameter-manager/docs/overview * Source: https://googleapis.deno.dev/v1/parametermanager:v1.ts */ import { auth, CredentialsClient, GoogleAuth, request } from "/_/base@v1/mod.ts"; export { auth, GoogleAuth }; export type { CredentialsClient }; /** * Parameter Manager is a single source of truth to store, access and manage * the lifecycle of your workload parameters. Parameter Manager aims to make * management of sensitive application parameters effortless for customers * without diminishing focus on security. */ export class ParameterManager { #client: CredentialsClient | undefined; #baseUrl: string; constructor(client?: CredentialsClient, baseUrl: string = "https://parametermanager.googleapis.com/") { this.#client = client; this.#baseUrl = baseUrl; } /** * 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 lists locations based on the resource scope provided in the * ListLocationsRequest.name field: * **Global locations**: If `name` is * empty, the method lists the public locations available to all projects. * * **Project-specific locations**: If `name` follows the format * `projects/{project}`, the method lists locations visible to that specific * project. This includes public, private, or other project-specific locations * enabled for the project. For gRPC and client library implementations, the * resource name is passed as the `name` field. For direct service calls, the * resource name is incorporated into the request path based on the specific * service implementation and version. * * @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; } /** * Creates a new Parameter in a given project and location. * * @param parent Required. Value for parent in the format `projects/*/locations/*`. */ async projectsLocationsParametersCreate(parent: string, req: Parameter, opts: ProjectsLocationsParametersCreateOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ parent }/parameters`); if (opts.parameterId !== undefined) { url.searchParams.append("parameterId", String(opts.parameterId)); } if (opts.requestId !== undefined) { url.searchParams.append("requestId", String(opts.requestId)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as Parameter; } /** * Deletes a single Parameter. * * @param name Required. Name of the resource in the format `projects/*/locations/*/parameters/*`. */ async projectsLocationsParametersDelete(name: string, opts: ProjectsLocationsParametersDeleteOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }`); if (opts.requestId !== undefined) { url.searchParams.append("requestId", String(opts.requestId)); } const data = await request(url.href, { client: this.#client, method: "DELETE", }); return data as Empty; } /** * Gets details of a single Parameter. * * @param name Required. Name of the resource in the format `projects/*/locations/*/parameters/*`. */ async projectsLocationsParametersGet(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 Parameter; } /** * Lists Parameters in a given project and location. * * @param parent Required. Parent value for ListParametersRequest in the format `projects/*/locations/*`. */ async projectsLocationsParametersList(parent: string, opts: ProjectsLocationsParametersListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ parent }/parameters`); if (opts.filter !== undefined) { url.searchParams.append("filter", String(opts.filter)); } if (opts.orderBy !== undefined) { url.searchParams.append("orderBy", String(opts.orderBy)); } 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 ListParametersResponse; } /** * Updates a single Parameter. * * @param name Identifier. [Output only] The resource name of the Parameter in the format `projects/*/locations/*/parameters/*`. */ async projectsLocationsParametersPatch(name: string, req: Parameter, opts: ProjectsLocationsParametersPatchOptions = {}): Promise { opts = serializeProjectsLocationsParametersPatchOptions(opts); const url = new URL(`${this.#baseUrl}v1/${ name }`); if (opts.requestId !== undefined) { url.searchParams.append("requestId", String(opts.requestId)); } 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 Parameter; } /** * Creates a new ParameterVersion in a given project, location, and * parameter. * * @param parent Required. Value for parent in the format `projects/*/locations/*/parameters/*`. */ async projectsLocationsParametersVersionsCreate(parent: string, req: ParameterVersion, opts: ProjectsLocationsParametersVersionsCreateOptions = {}): Promise { req = serializeParameterVersion(req); const url = new URL(`${this.#baseUrl}v1/${ parent }/versions`); if (opts.parameterVersionId !== undefined) { url.searchParams.append("parameterVersionId", String(opts.parameterVersionId)); } if (opts.requestId !== undefined) { url.searchParams.append("requestId", String(opts.requestId)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return deserializeParameterVersion(data); } /** * Deletes a single ParameterVersion. * * @param name Required. Name of the resource in the format `projects/*/locations/*/parameters/*/versions/*`. */ async projectsLocationsParametersVersionsDelete(name: string, opts: ProjectsLocationsParametersVersionsDeleteOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }`); if (opts.requestId !== undefined) { url.searchParams.append("requestId", String(opts.requestId)); } const data = await request(url.href, { client: this.#client, method: "DELETE", }); return data as Empty; } /** * Gets details of a single ParameterVersion. * * @param name Required. Name of the resource in the format `projects/*/locations/*/parameters/*/versions/*`. */ async projectsLocationsParametersVersionsGet(name: string, opts: ProjectsLocationsParametersVersionsGetOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }`); if (opts.view !== undefined) { url.searchParams.append("view", String(opts.view)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeParameterVersion(data); } /** * Lists ParameterVersions in a given project, location, and parameter. * * @param parent Required. Parent value for ListParameterVersionsRequest in the format `projects/*/locations/*/parameters/*`. */ async projectsLocationsParametersVersionsList(parent: string, opts: ProjectsLocationsParametersVersionsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ parent }/versions`); if (opts.filter !== undefined) { url.searchParams.append("filter", String(opts.filter)); } if (opts.orderBy !== undefined) { url.searchParams.append("orderBy", String(opts.orderBy)); } 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 deserializeListParameterVersionsResponse(data); } /** * Updates a single ParameterVersion. * * @param name Identifier. [Output only] The resource name of the ParameterVersion in the format `projects/*/locations/*/parameters/*/versions/*`. */ async projectsLocationsParametersVersionsPatch(name: string, req: ParameterVersion, opts: ProjectsLocationsParametersVersionsPatchOptions = {}): Promise { req = serializeParameterVersion(req); opts = serializeProjectsLocationsParametersVersionsPatchOptions(opts); const url = new URL(`${this.#baseUrl}v1/${ name }`); if (opts.requestId !== undefined) { url.searchParams.append("requestId", String(opts.requestId)); } 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 deserializeParameterVersion(data); } /** * Gets rendered version of a ParameterVersion. * * @param name Required. Name of the resource */ async projectsLocationsParametersVersionsRender(name: string): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }:render`); const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeRenderParameterVersionResponse(data); } /** * Creates a new Template in a given project and location. * * @param parent Required. Value for parent in the format `projects/*/locations/*`. */ async projectsLocationsTemplatesCreate(parent: string, req: Template, opts: ProjectsLocationsTemplatesCreateOptions = {}): Promise