// Copyright 2022 Luca Casonato. All rights reserved. MIT license. /** * Developer Connect API Client for Deno * ===================================== * * Connect third-party source code management to Google * * Docs: http://cloud.google.com/developer-connect/docs/overview * Source: https://googleapis.deno.dev/v1/developerconnect:v1.ts */ import { auth, CredentialsClient, GoogleAuth, request } from "/_/base@v1/mod.ts"; export { auth, GoogleAuth }; export type { CredentialsClient }; /** * Connect third-party source code management to Google */ export class DeveloperConnect { #client: CredentialsClient | undefined; #baseUrl: string; constructor(client?: CredentialsClient, baseUrl: string = "https://developerconnect.googleapis.com/") { this.#client = client; this.#baseUrl = baseUrl; } /** * Creates a new Connection in a given project and location. * * @param parent Required. Value for parent. */ async projectsLocationsConnectionsCreate(parent: string, req: Connection, opts: ProjectsLocationsConnectionsCreateOptions = {}): Promise { req = serializeConnection(req); const url = new URL(`${this.#baseUrl}v1/${ parent }/connections`); if (opts.connectionId !== undefined) { url.searchParams.append("connectionId", String(opts.connectionId)); } if (opts.requestId !== undefined) { url.searchParams.append("requestId", String(opts.requestId)); } if (opts.validateOnly !== undefined) { url.searchParams.append("validateOnly", String(opts.validateOnly)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as Operation; } /** * Deletes a single Connection. * * @param name Required. Name of the resource */ async projectsLocationsConnectionsDelete(name: string, opts: ProjectsLocationsConnectionsDeleteOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }`); if (opts.etag !== undefined) { url.searchParams.append("etag", String(opts.etag)); } if (opts.requestId !== undefined) { url.searchParams.append("requestId", String(opts.requestId)); } if (opts.validateOnly !== undefined) { url.searchParams.append("validateOnly", String(opts.validateOnly)); } const data = await request(url.href, { client: this.#client, method: "DELETE", }); return data as Operation; } /** * FetchGitHubInstallations returns the list of GitHub Installations that are * available to be added to a Connection. For github.com, only installations * accessible to the authorizer token are returned. For GitHub Enterprise, all * installations are returned. * * @param connection Required. The resource name of the connection in the format `projects/*/locations/*/connections/*`. */ async projectsLocationsConnectionsFetchGitHubInstallations(connection: string): Promise { const url = new URL(`${this.#baseUrl}v1/${ connection }:fetchGitHubInstallations`); const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeFetchGitHubInstallationsResponse(data); } /** * FetchLinkableGitRepositories returns a list of git repositories from an * SCM that are available to be added to a Connection. * * @param connection Required. The name of the Connection. Format: `projects/*/locations/*/connections/*`. */ async projectsLocationsConnectionsFetchLinkableGitRepositories(connection: string, opts: ProjectsLocationsConnectionsFetchLinkableGitRepositoriesOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ connection }:fetchLinkableGitRepositories`); 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 FetchLinkableGitRepositoriesResponse; } /** * Gets details of a single Connection. * * @param name Required. Name of the resource */ async projectsLocationsConnectionsGet(name: string): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }`); const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeConnection(data); } /** * Creates a GitRepositoryLink. Upon linking a Git Repository, Developer * Connect will configure the Git Repository to send webhook events to * Developer Connect. Connections that use Firebase GitHub Application will * have events forwarded to the Firebase service. All other Connections will * have events forwarded to Cloud Build. * * @param parent Required. Value for parent. */ async projectsLocationsConnectionsGitRepositoryLinksCreate(parent: string, req: GitRepositoryLink, opts: ProjectsLocationsConnectionsGitRepositoryLinksCreateOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ parent }/gitRepositoryLinks`); if (opts.gitRepositoryLinkId !== undefined) { url.searchParams.append("gitRepositoryLinkId", String(opts.gitRepositoryLinkId)); } if (opts.requestId !== undefined) { url.searchParams.append("requestId", String(opts.requestId)); } if (opts.validateOnly !== undefined) { url.searchParams.append("validateOnly", String(opts.validateOnly)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as Operation; } /** * Deletes a single GitRepositoryLink. * * @param name Required. Name of the resource */ async projectsLocationsConnectionsGitRepositoryLinksDelete(name: string, opts: ProjectsLocationsConnectionsGitRepositoryLinksDeleteOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }`); if (opts.etag !== undefined) { url.searchParams.append("etag", String(opts.etag)); } if (opts.requestId !== undefined) { url.searchParams.append("requestId", String(opts.requestId)); } if (opts.validateOnly !== undefined) { url.searchParams.append("validateOnly", String(opts.validateOnly)); } const data = await request(url.href, { client: this.#client, method: "DELETE", }); return data as Operation; } /** * Fetch the list of branches or tags for a given repository. * * @param gitRepositoryLink Required. The resource name of GitRepositoryLink in the format `projects/*/locations/*/connections/*/gitRepositoryLinks/*`. */ async projectsLocationsConnectionsGitRepositoryLinksFetchGitRefs(gitRepositoryLink: string, opts: ProjectsLocationsConnectionsGitRepositoryLinksFetchGitRefsOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ gitRepositoryLink }:fetchGitRefs`); if (opts.pageSize !== undefined) { url.searchParams.append("pageSize", String(opts.pageSize)); } if (opts.pageToken !== undefined) { url.searchParams.append("pageToken", String(opts.pageToken)); } if (opts.refType !== undefined) { url.searchParams.append("refType", String(opts.refType)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return data as FetchGitRefsResponse; } /** * Fetches read token of a given gitRepositoryLink. * * @param gitRepositoryLink Required. The resource name of the gitRepositoryLink in the format `projects/*/locations/*/connections/*/gitRepositoryLinks/*`. */ async projectsLocationsConnectionsGitRepositoryLinksFetchReadToken(gitRepositoryLink: string, req: FetchReadTokenRequest): Promise { const url = new URL(`${this.#baseUrl}v1/${ gitRepositoryLink }:fetchReadToken`); const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return deserializeFetchReadTokenResponse(data); } /** * Fetches read/write token of a given gitRepositoryLink. * * @param gitRepositoryLink Required. The resource name of the gitRepositoryLink in the format `projects/*/locations/*/connections/*/gitRepositoryLinks/*`. */ async projectsLocationsConnectionsGitRepositoryLinksFetchReadWriteToken(gitRepositoryLink: string, req: FetchReadWriteTokenRequest): Promise { const url = new URL(`${this.#baseUrl}v1/${ gitRepositoryLink }:fetchReadWriteToken`); const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return deserializeFetchReadWriteTokenResponse(data); } /** * Gets details of a single GitRepositoryLink. * * @param name Required. Name of the resource */ async projectsLocationsConnectionsGitRepositoryLinksGet(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 GitRepositoryLink; } /** * Lists GitRepositoryLinks in a given project, location, and connection. * * @param parent Required. Parent value for ListGitRepositoryLinksRequest */ async projectsLocationsConnectionsGitRepositoryLinksList(parent: string, opts: ProjectsLocationsConnectionsGitRepositoryLinksListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ parent }/gitRepositoryLinks`); 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 ListGitRepositoryLinksResponse; } /** * ProcessGitLabEnterpriseWebhook is called by the external GitLab Enterprise * instances for notifying events. * * @param name Required. The GitRepositoryLink resource where the webhook will be received. Format: `projects/*/locations/*/connections/*/gitRepositoryLinks/*`. */ async projectsLocationsConnectionsGitRepositoryLinksProcessGitLabEnterpriseWebhook(name: string, req: ProcessGitLabEnterpriseWebhookRequest): Promise { req = serializeProcessGitLabEnterpriseWebhookRequest(req); const url = new URL(`${this.#baseUrl}v1/${ name }:processGitLabEnterpriseWebhook`); const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as Empty; } /** * ProcessGitLabWebhook is called by the GitLab.com for notifying events. * * @param name Required. The GitRepositoryLink resource where the webhook will be received. Format: `projects/*/locations/*/connections/*/gitRepositoryLinks/*`. */ async projectsLocationsConnectionsGitRepositoryLinksProcessGitLabWebhook(name: string, req: ProcessGitLabWebhookRequest): Promise { req = serializeProcessGitLabWebhookRequest(req); const url = new URL(`${this.#baseUrl}v1/${ name }:processGitLabWebhook`); const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as Empty; } /** * Lists Connections in a given project and location. * * @param parent Required. Parent value for ListConnectionsRequest */ async projectsLocationsConnectionsList(parent: string, opts: ProjectsLocationsConnectionsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ parent }/connections`); 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 deserializeListConnectionsResponse(data); } /** * Updates the parameters of a single Connection. * * @param name Identifier. The resource name of the connection, in the format `projects/{project}/locations/{location}/connections/{connection_id}`. */ async projectsLocationsConnectionsPatch(name: string, req: Connection, opts: ProjectsLocationsConnectionsPatchOptions = {}): Promise { req = serializeConnection(req); opts = serializeProjectsLocationsConnectionsPatchOptions(opts); const url = new URL(`${this.#baseUrl}v1/${ name }`); if (opts.allowMissing !== undefined) { url.searchParams.append("allowMissing", String(opts.allowMissing)); } if (opts.requestId !== undefined) { url.searchParams.append("requestId", String(opts.requestId)); } if (opts.updateMask !== undefined) { url.searchParams.append("updateMask", String(opts.updateMask)); } if (opts.validateOnly !== undefined) { url.searchParams.append("validateOnly", String(opts.validateOnly)); } const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "PATCH", body, }); return data as Operation; } /** * ProcessGitHubEnterpriseWebhook is called by the external GitHub Enterprise * instances for notifying events. * * @param parent Required. Project and location where the webhook will be received. Format: `projects/*/locations/*`. */ async projectsLocationsConnectionsProcessGitHubEnterpriseWebhook(parent: string, req: ProcessGitHubEnterpriseWebhookRequest): Promise { req = serializeProcessGitHubEnterpriseWebhookRequest(req); const url = new URL(`${this.#baseUrl}v1/${ parent }/connections:processGitHubEnterpriseWebhook`); const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as Empty; } /** * 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. * * @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.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; } /** * Starts asynchronous cancellation on a long-running operation. The server * makes a best effort to cancel the operation, but success is not guaranteed. * If the server doesn't support this method, it returns * `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or * other methods to check whether the cancellation succeeded or whether the * operation completed despite cancellation. On successful cancellation, the * operation is not deleted; instead, it becomes an operation with an * Operation.error value with a google.rpc.Status.code of 1, corresponding to * `Code.CANCELLED`. * * @param name The name of the operation resource to be cancelled. */ async projectsLocationsOperationsCancel(name: string, req: CancelOperationRequest): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }:cancel`); const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as Empty; } /** * Deletes a long-running operation. This method indicates that the client is * no longer interested in the operation result. It does not cancel the * operation. If the server doesn't support this method, it returns * `google.rpc.Code.UNIMPLEMENTED`. * * @param name The name of the operation resource to be deleted. */ async projectsLocationsOperationsDelete(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 Empty; } /** * Gets the latest state of a long-running operation. Clients can use this * method to poll the operation result at intervals as recommended by the API * service. * * @param name The name of the operation resource. */ async projectsLocationsOperationsGet(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 Operation; } /** * Lists operations that match the specified filter in the request. If the * server doesn't support this method, it returns `UNIMPLEMENTED`. * * @param name The name of the operation's parent resource. */ async projectsLocationsOperationsList(name: string, opts: ProjectsLocationsOperationsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v1/${ name }/operations`); 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 ListOperationsResponse; } } /** * The request message for Operations.CancelOperation. */ export interface CancelOperationRequest { } /** * Message describing Connection object */ export interface Connection { /** * Optional. Allows clients to store small amounts of arbitrary data. */ annotations?: { [key: string]: string }; /** * Output only. [Output only] Create timestamp */ readonly createTime?: Date; /** * Optional. The crypto key configuration. This field is used by the * Customer-Managed Encryption Keys (CMEK) feature. */ cryptoKeyConfig?: CryptoKeyConfig; /** * Output only. [Output only] Delete timestamp */ readonly deleteTime?: Date; /** * Optional. If disabled is set to true, functionality is disabled for this * connection. Repository based API methods and webhooks processing for * repositories in this connection will be disabled. */ disabled?: boolean; /** * Optional. This checksum is computed by the server based on the value of * other fields, and may be sent on update and delete requests to ensure the * client has an up-to-date value before proceeding. */ etag?: string; /** * Configuration for connections to github.com. */ githubConfig?: GitHubConfig; /** * Configuration for connections to an instance of GitHub Enterprise. */ githubEnterpriseConfig?: GitHubEnterpriseConfig; /** * Configuration for connections to gitlab.com. */ gitlabConfig?: GitLabConfig; /** * Configuration for connections to an instance of GitLab Enterprise. */ gitlabEnterpriseConfig?: GitLabEnterpriseConfig; /** * Output only. Installation state of the Connection. */ readonly installationState?: InstallationState; /** * Optional. Labels as key value pairs */ labels?: { [key: string]: string }; /** * Identifier. The resource name of the connection, in the format * `projects/{project}/locations/{location}/connections/{connection_id}`. */ name?: string; /** * Output only. Set to true when the connection is being set up or updated in * the background. */ readonly reconciling?: boolean; /** * Output only. A system-assigned unique identifier for a the * GitRepositoryLink. */ readonly uid?: string; /** * Output only. [Output only] Update timestamp */ readonly updateTime?: Date; } function serializeConnection(data: any): Connection { return { ...data, githubConfig: data["githubConfig"] !== undefined ? serializeGitHubConfig(data["githubConfig"]) : undefined, githubEnterpriseConfig: data["githubEnterpriseConfig"] !== undefined ? serializeGitHubEnterpriseConfig(data["githubEnterpriseConfig"]) : undefined, }; } function deserializeConnection(data: any): Connection { return { ...data, createTime: data["createTime"] !== undefined ? new Date(data["createTime"]) : undefined, deleteTime: data["deleteTime"] !== undefined ? new Date(data["deleteTime"]) : undefined, githubConfig: data["githubConfig"] !== undefined ? deserializeGitHubConfig(data["githubConfig"]) : undefined, githubEnterpriseConfig: data["githubEnterpriseConfig"] !== undefined ? deserializeGitHubEnterpriseConfig(data["githubEnterpriseConfig"]) : undefined, updateTime: data["updateTime"] !== undefined ? new Date(data["updateTime"]) : undefined, }; } /** * The crypto key configuration. This field is used by the Customer-managed * encryption keys (CMEK) feature. */ export interface CryptoKeyConfig { /** * Required. The name of the key which is used to encrypt/decrypt customer * data. For key in Cloud KMS, the key should be in the format of * `projects/*\/locations/*\/keyRings/*\/cryptoKeys/*`. */ keyReference?: string; } /** * A generic empty message that you can re-use to avoid defining duplicated * empty messages in your APIs. A typical example is to use it as the request or * the response type of an API method. For instance: service Foo { rpc * Bar(google.protobuf.Empty) returns (google.protobuf.Empty); } */ export interface Empty { } /** * Response of fetching github installations. */ export interface FetchGitHubInstallationsResponse { /** * List of installations available to the OAuth user (for github.com) or all * the installations (for GitHub enterprise). */ installations?: Installation[]; } function serializeFetchGitHubInstallationsResponse(data: any): FetchGitHubInstallationsResponse { return { ...data, installations: data["installations"] !== undefined ? data["installations"].map((item: any) => (serializeInstallation(item))) : undefined, }; } function deserializeFetchGitHubInstallationsResponse(data: any): FetchGitHubInstallationsResponse { return { ...data, installations: data["installations"] !== undefined ? data["installations"].map((item: any) => (deserializeInstallation(item))) : undefined, }; } /** * Response for fetching git refs. */ export interface FetchGitRefsResponse { /** * A token identifying a page of results the server should return. */ nextPageToken?: string; /** * Name of the refs fetched. */ refNames?: string[]; } /** * Response message for FetchLinkableGitRepositories. */ export interface FetchLinkableGitRepositoriesResponse { /** * The git repositories that can be linked to the connection. */ linkableGitRepositories?: LinkableGitRepository[]; /** * A token identifying a page of results the server should return. */ nextPageToken?: string; } /** * Message for fetching SCM read token. */ export interface FetchReadTokenRequest { } /** * Message for responding to get read token. */ export interface FetchReadTokenResponse { /** * Expiration timestamp. Can be empty if unknown or non-expiring. */ expirationTime?: Date; /** * The git_username to specify when making a git clone with the token. For * example, for GitHub GitRepositoryLinks, this would be "x-access-token" */ gitUsername?: string; /** * The token content. */ token?: string; } function serializeFetchReadTokenResponse(data: any): FetchReadTokenResponse { return { ...data, expirationTime: data["expirationTime"] !== undefined ? data["expirationTime"].toISOString() : undefined, }; } function deserializeFetchReadTokenResponse(data: any): FetchReadTokenResponse { return { ...data, expirationTime: data["expirationTime"] !== undefined ? new Date(data["expirationTime"]) : undefined, }; } /** * Message for fetching SCM read/write token. */ export interface FetchReadWriteTokenRequest { } /** * Message for responding to get read/write token. */ export interface FetchReadWriteTokenResponse { /** * Expiration timestamp. Can be empty if unknown or non-expiring. */ expirationTime?: Date; /** * The git_username to specify when making a git clone with the token. For * example, for GitHub GitRepositoryLinks, this would be "x-access-token" */ gitUsername?: string; /** * The token content. */ token?: string; } function serializeFetchReadWriteTokenResponse(data: any): FetchReadWriteTokenResponse { return { ...data, expirationTime: data["expirationTime"] !== undefined ? data["expirationTime"].toISOString() : undefined, }; } function deserializeFetchReadWriteTokenResponse(data: any): FetchReadWriteTokenResponse { return { ...data, expirationTime: data["expirationTime"] !== undefined ? new Date(data["expirationTime"]) : undefined, }; } /** * Configuration for connections to github.com. */ export interface GitHubConfig { /** * Optional. GitHub App installation id. */ appInstallationId?: bigint; /** * Optional. OAuth credential of the account that authorized the GitHub App. * It is recommended to use a robot account instead of a human user account. * The OAuth token must be tied to the GitHub App of this config. */ authorizerCredential?: OAuthCredential; /** * Required. Immutable. The GitHub Application that was installed to the * GitHub user or organization. */ githubApp?: | "GIT_HUB_APP_UNSPECIFIED" | "DEVELOPER_CONNECT" | "FIREBASE"; /** * Output only. The URI to navigate to in order to manage the installation * associated with this GitHubConfig. */ readonly installationUri?: string; } function serializeGitHubConfig(data: any): GitHubConfig { return { ...data, appInstallationId: data["appInstallationId"] !== undefined ? String(data["appInstallationId"]) : undefined, }; } function deserializeGitHubConfig(data: any): GitHubConfig { return { ...data, appInstallationId: data["appInstallationId"] !== undefined ? BigInt(data["appInstallationId"]) : undefined, }; } /** * Configuration for connections to an instance of GitHub Enterprise. */ export interface GitHubEnterpriseConfig { /** * Optional. ID of the GitHub App created from the manifest. */ appId?: bigint; /** * Optional. ID of the installation of the GitHub App. */ appInstallationId?: bigint; /** * Output only. The URL-friendly name of the GitHub App. */ readonly appSlug?: string; /** * Required. The URI of the GitHub Enterprise host this connection is for. */ hostUri?: string; /** * Output only. The URI to navigate to in order to manage the installation * associated with this GitHubEnterpriseConfig. */ readonly installationUri?: string; /** * Optional. SecretManager resource containing the private key of the GitHub * App, formatted as `projects/*\/secrets/*\/versions/*`. */ privateKeySecretVersion?: string; /** * Output only. GitHub Enterprise version installed at the host_uri. */ readonly serverVersion?: string; /** * Optional. Configuration for using Service Directory to privately connect * to a GitHub Enterprise server. This should only be set if the GitHub * Enterprise server is hosted on-premises and not reachable by public * internet. If this field is left empty, calls to the GitHub Enterprise * server will be made over the public internet. */ serviceDirectoryConfig?: ServiceDirectoryConfig; /** * Optional. SSL certificate to use for requests to GitHub Enterprise. */ sslCaCertificate?: string; /** * Optional. SecretManager resource containing the webhook secret of the * GitHub App, formatted as `projects/*\/secrets/*\/versions/*`. */ webhookSecretSecretVersion?: string; } function serializeGitHubEnterpriseConfig(data: any): GitHubEnterpriseConfig { return { ...data, appId: data["appId"] !== undefined ? String(data["appId"]) : undefined, appInstallationId: data["appInstallationId"] !== undefined ? String(data["appInstallationId"]) : undefined, }; } function deserializeGitHubEnterpriseConfig(data: any): GitHubEnterpriseConfig { return { ...data, appId: data["appId"] !== undefined ? BigInt(data["appId"]) : undefined, appInstallationId: data["appInstallationId"] !== undefined ? BigInt(data["appInstallationId"]) : undefined, }; } /** * Configuration for connections to gitlab.com. */ export interface GitLabConfig { /** * Required. A GitLab personal access token with the minimum `api` scope * access and a minimum role of `maintainer`. The GitLab Projects visible to * this Personal Access Token will control which Projects Developer Connect * has access to. */ authorizerCredential?: UserCredential; /** * Required. A GitLab personal access token with the minimum `read_api` scope * access and a minimum role of `reporter`. The GitLab Projects visible to * this Personal Access Token will control which Projects Developer Connect * has access to. */ readAuthorizerCredential?: UserCredential; /** * Required. Immutable. SecretManager resource containing the webhook secret * of a GitLab project, formatted as `projects/*\/secrets/*\/versions/*`. This * is used to validate webhooks. */ webhookSecretSecretVersion?: string; } /** * Configuration for connections to an instance of GitLab Enterprise. */ export interface GitLabEnterpriseConfig { /** * Required. A GitLab personal access token with the minimum `api` scope * access and a minimum role of `maintainer`. The GitLab Projects visible to * this Personal Access Token will control which Projects Developer Connect * has access to. */ authorizerCredential?: UserCredential; /** * Required. The URI of the GitLab Enterprise host this connection is for. */ hostUri?: string; /** * Required. A GitLab personal access token with the minimum `read_api` scope * access and a minimum role of `reporter`. The GitLab Projects visible to * this Personal Access Token will control which Projects Developer Connect * has access to. */ readAuthorizerCredential?: UserCredential; /** * Output only. Version of the GitLab Enterprise server running on the * `host_uri`. */ readonly serverVersion?: string; /** * Optional. Configuration for using Service Directory to privately connect * to a GitLab Enterprise instance. This should only be set if the GitLab * Enterprise server is hosted on-premises and not reachable by public * internet. If this field is left empty, calls to the GitLab Enterprise * server will be made over the public internet. */ serviceDirectoryConfig?: ServiceDirectoryConfig; /** * Optional. SSL Certificate Authority certificate to use for requests to * GitLab Enterprise instance. */ sslCaCertificate?: string; /** * Required. Immutable. SecretManager resource containing the webhook secret * of a GitLab project, formatted as `projects/*\/secrets/*\/versions/*`. This * is used to validate webhooks. */ webhookSecretSecretVersion?: string; } /** * Message describing the GitRepositoryLink object */ export interface GitRepositoryLink { /** * Optional. Allows clients to store small amounts of arbitrary data. */ annotations?: { [key: string]: string }; /** * Required. Git Clone URI. */ cloneUri?: string; /** * Output only. [Output only] Create timestamp */ readonly createTime?: Date; /** * Output only. [Output only] Delete timestamp */ readonly deleteTime?: Date; /** * Optional. This checksum is computed by the server based on the value of * other fields, and may be sent on update and delete requests to ensure the * client has an up-to-date value before proceeding. */ etag?: string; /** * Optional. Labels as key value pairs */ labels?: { [key: string]: string }; /** * Identifier. Resource name of the repository, in the format * `projects/*\/locations/*\/connections/*\/gitRepositoryLinks/*`. */ name?: string; /** * Output only. Set to true when the connection is being set up or updated in * the background. */ readonly reconciling?: boolean; /** * Output only. A system-assigned unique identifier for a the * GitRepositoryLink. */ readonly uid?: string; /** * Output only. [Output only] Update timestamp */ readonly updateTime?: Date; /** * Output only. External ID of the webhook created for the repository. */ readonly webhookId?: string; } /** * Message that represents an arbitrary HTTP body. It should only be used for * payload formats that can't be represented as JSON, such as raw binary or an * HTML page. This message can be used both in streaming and non-streaming API * methods in the request as well as the response. It can be used as a top-level * request field, which is convenient if one wants to extract parameters from * either the URL or HTTP template into the request fields and also want access * to the raw HTTP body. Example: message GetResourceRequest { // A unique * request id. string request_id = 1; // The raw HTTP body is bound to this * field. google.api.HttpBody http_body = 2; } service ResourceService { rpc * GetResource(GetResourceRequest) returns (google.api.HttpBody); rpc * UpdateResource(google.api.HttpBody) returns (google.protobuf.Empty); } * Example with streaming methods: service CaldavService { rpc * GetCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); * rpc UpdateCalendar(stream google.api.HttpBody) returns (stream * google.api.HttpBody); } Use of this type only changes how the request and * response bodies are handled, all other features will continue to work * unchanged. */ export interface HttpBody { /** * The HTTP Content-Type header value specifying the content type of the * body. */ contentType?: string; /** * The HTTP request/response body as raw binary. */ data?: Uint8Array; /** * Application specific response metadata. Must be set in the first response * for streaming APIs. */ extensions?: { [key: string]: any }[]; } function serializeHttpBody(data: any): HttpBody { return { ...data, data: data["data"] !== undefined ? encodeBase64(data["data"]) : undefined, }; } function deserializeHttpBody(data: any): HttpBody { return { ...data, data: data["data"] !== undefined ? decodeBase64(data["data"] as string) : undefined, }; } /** * Represents an installation of the GitHub App. */ export interface Installation { /** * ID of the installation in GitHub. */ id?: bigint; /** * Name of the GitHub user or organization that owns this installation. */ name?: string; /** * Either "user" or "organization". */ type?: string; } function serializeInstallation(data: any): Installation { return { ...data, id: data["id"] !== undefined ? String(data["id"]) : undefined, }; } function deserializeInstallation(data: any): Installation { return { ...data, id: data["id"] !== undefined ? BigInt(data["id"]) : undefined, }; } /** * Describes stage and necessary actions to be taken by the user to complete * the installation. Used for GitHub and GitHub Enterprise based connections. */ export interface InstallationState { /** * Output only. Link to follow for next action. Empty string if the * installation is already complete. */ readonly actionUri?: string; /** * Output only. Message of what the user should do next to continue the * installation. Empty string if the installation is already complete. */ readonly message?: string; /** * Output only. Current step of the installation process. */ readonly stage?: | "STAGE_UNSPECIFIED" | "PENDING_CREATE_APP" | "PENDING_USER_OAUTH" | "PENDING_INSTALL_APP" | "COMPLETE"; } /** * LinkableGitRepository represents a git repository that can be linked to a * connection. */ export interface LinkableGitRepository { /** * The clone uri of the repository. */ cloneUri?: string; } /** * Message for response to listing Connections */ export interface ListConnectionsResponse { /** * The list of Connection */ connections?: Connection[]; /** * A token identifying a page of results the server should return. */ nextPageToken?: string; /** * Locations that could not be reached. */ unreachable?: string[]; } function serializeListConnectionsResponse(data: any): ListConnectionsResponse { return { ...data, connections: data["connections"] !== undefined ? data["connections"].map((item: any) => (serializeConnection(item))) : undefined, }; } function deserializeListConnectionsResponse(data: any): ListConnectionsResponse { return { ...data, connections: data["connections"] !== undefined ? data["connections"].map((item: any) => (deserializeConnection(item))) : undefined, }; } /** * Message for response to listing GitRepositoryLinks */ export interface ListGitRepositoryLinksResponse { /** * The list of GitRepositoryLinks */ gitRepositoryLinks?: GitRepositoryLink[]; /** * A token identifying a page of results the server should return. */ nextPageToken?: string; /** * Locations that could not be reached. */ unreachable?: 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; } /** * The response message for Operations.ListOperations. */ export interface ListOperationsResponse { /** * The standard List next-page token. */ nextPageToken?: string; /** * A list of operations that matches the specified filter in the request. */ operations?: Operation[]; } /** * 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; } /** * Represents an OAuth token of the account that authorized the Connection, and * associated metadata. */ export interface OAuthCredential { /** * Required. A SecretManager resource containing the OAuth token that * authorizes the connection. Format: `projects/*\/secrets/*\/versions/*`. */ oauthTokenSecretVersion?: string; /** * Output only. The username associated with this token. */ readonly username?: string; } /** * This resource represents a long-running operation that is the result of a * network API call. */ export interface Operation { /** * If the value is `false`, it means the operation is still in progress. If * `true`, the operation is completed, and either `error` or `response` is * available. */ done?: boolean; /** * The error result of the operation in case of failure or cancellation. */ error?: Status; /** * Service-specific metadata associated with the operation. It typically * contains progress information and common metadata such as create time. Some * services might not provide such metadata. Any method that returns a * long-running operation should document the metadata type, if any. */ metadata?: { [key: string]: any }; /** * The server-assigned name, which is only unique within the same service * that originally returns it. If you use the default HTTP mapping, the `name` * should be a resource name ending with `operations/{unique_id}`. */ name?: string; /** * The normal, successful response of the operation. If the original method * returns no data on success, such as `Delete`, the response is * `google.protobuf.Empty`. If the original method is standard * `Get`/`Create`/`Update`, the response should be the resource. For other * methods, the response should have the type `XxxResponse`, where `Xxx` is * the original method name. For example, if the original method name is * `TakeSnapshot()`, the inferred response type is `TakeSnapshotResponse`. */ response?: { [key: string]: any }; } /** * Represents the metadata of the long-running operation. */ export interface OperationMetadata { /** * Output only. API version used to start the operation. */ readonly apiVersion?: string; /** * Output only. The time the operation was created. */ readonly createTime?: Date; /** * Output only. The time the operation finished running. */ readonly endTime?: Date; /** * Output only. Identifies whether the user has requested cancellation of the * operation. Operations that have been cancelled successfully have * google.longrunning.Operation.error value with a google.rpc.Status.code of * 1, corresponding to `Code.CANCELLED`. */ readonly requestedCancellation?: boolean; /** * Output only. Human-readable status of the operation, if any. */ readonly statusMessage?: string; /** * Output only. Server-defined resource path for the target of the operation. */ readonly target?: string; /** * Output only. Name of the verb executed by the operation. */ readonly verb?: string; } /** * RPC request object accepted by the ProcessGitHubEnterpriseWebhook RPC * method. */ export interface ProcessGitHubEnterpriseWebhookRequest { /** * Required. HTTP request body. */ body?: HttpBody; } function serializeProcessGitHubEnterpriseWebhookRequest(data: any): ProcessGitHubEnterpriseWebhookRequest { return { ...data, body: data["body"] !== undefined ? serializeHttpBody(data["body"]) : undefined, }; } function deserializeProcessGitHubEnterpriseWebhookRequest(data: any): ProcessGitHubEnterpriseWebhookRequest { return { ...data, body: data["body"] !== undefined ? deserializeHttpBody(data["body"]) : undefined, }; } /** * RPC request object accepted by the ProcessGitLabEnterpriseWebhook RPC * method. */ export interface ProcessGitLabEnterpriseWebhookRequest { /** * Required. HTTP request body. */ body?: HttpBody; } function serializeProcessGitLabEnterpriseWebhookRequest(data: any): ProcessGitLabEnterpriseWebhookRequest { return { ...data, body: data["body"] !== undefined ? serializeHttpBody(data["body"]) : undefined, }; } function deserializeProcessGitLabEnterpriseWebhookRequest(data: any): ProcessGitLabEnterpriseWebhookRequest { return { ...data, body: data["body"] !== undefined ? deserializeHttpBody(data["body"]) : undefined, }; } /** * RPC request object accepted by the ProcessGitLabWebhook RPC method. */ export interface ProcessGitLabWebhookRequest { /** * Required. HTTP request body. */ body?: HttpBody; } function serializeProcessGitLabWebhookRequest(data: any): ProcessGitLabWebhookRequest { return { ...data, body: data["body"] !== undefined ? serializeHttpBody(data["body"]) : undefined, }; } function deserializeProcessGitLabWebhookRequest(data: any): ProcessGitLabWebhookRequest { return { ...data, body: data["body"] !== undefined ? deserializeHttpBody(data["body"]) : undefined, }; } /** * Additional options for DeveloperConnect#projectsLocationsConnectionsCreate. */ export interface ProjectsLocationsConnectionsCreateOptions { /** * Required. Id of the requesting object If auto-generating Id server-side, * remove this field and connection_id from the method_signature of Create RPC */ connectionId?: string; /** * Optional. An optional request ID to identify requests. Specify a unique * request ID so that if you must retry your request, the server will know to * ignore the request if it has already been completed. The server will * guarantee that for at least 60 minutes since the first request. For * example, consider a situation where you make an initial request and the * request times out. If you make the request again with the same request ID, * the server can check if original operation with the same request ID was * received, and if so, will ignore the second request. This prevents clients * from accidentally creating duplicate commitments. The request ID must be a * valid UUID with the exception that zero UUID is not supported * (00000000-0000-0000-0000-000000000000). */ requestId?: string; /** * Optional. If set, validate the request, but do not actually post it. */ validateOnly?: boolean; } /** * Additional options for DeveloperConnect#projectsLocationsConnectionsDelete. */ export interface ProjectsLocationsConnectionsDeleteOptions { /** * Optional. The current etag of the Connection. If an etag is provided and * does not match the current etag of the Connection, deletion will be blocked * and an ABORTED error will be returned. */ etag?: string; /** * Optional. An optional request ID to identify requests. Specify a unique * request ID so that if you must retry your request, the server will know to * ignore the request if it has already been completed. The server will * guarantee that for at least 60 minutes after the first request. For * example, consider a situation where you make an initial request and the * request times out. If you make the request again with the same request ID, * the server can check if original operation with the same request ID was * received, and if so, will ignore the second request. This prevents clients * from accidentally creating duplicate commitments. The request ID must be a * valid UUID with the exception that zero UUID is not supported * (00000000-0000-0000-0000-000000000000). */ requestId?: string; /** * Optional. If set, validate the request, but do not actually post it. */ validateOnly?: boolean; } /** * Additional options for * DeveloperConnect#projectsLocationsConnectionsFetchLinkableGitRepositories. */ export interface ProjectsLocationsConnectionsFetchLinkableGitRepositoriesOptions { /** * Optional. Number of results to return in the list. Defaults to 20. */ pageSize?: number; /** * Optional. Page start. */ pageToken?: string; } /** * Additional options for * DeveloperConnect#projectsLocationsConnectionsGitRepositoryLinksCreate. */ export interface ProjectsLocationsConnectionsGitRepositoryLinksCreateOptions { /** * Required. The ID to use for the repository, which will become the final * component of the repository's resource name. This ID should be unique in * the connection. Allows alphanumeric characters and any of * -._~%!$&'()*+,;=@. */ gitRepositoryLinkId?: string; /** * Optional. An optional request ID to identify requests. Specify a unique * request ID so that if you must retry your request, the server will know to * ignore the request if it has already been completed. The server will * guarantee that for at least 60 minutes since the first request. For * example, consider a situation where you make an initial request and the * request times out. If you make the request again with the same request ID, * the server can check if original operation with the same request ID was * received, and if so, will ignore the second request. This prevents clients * from accidentally creating duplicate commitments. The request ID must be a * valid UUID with the exception that zero UUID is not supported * (00000000-0000-0000-0000-000000000000). */ requestId?: string; /** * Optional. If set, validate the request, but do not actually post it. */ validateOnly?: boolean; } /** * Additional options for * DeveloperConnect#projectsLocationsConnectionsGitRepositoryLinksDelete. */ export interface ProjectsLocationsConnectionsGitRepositoryLinksDeleteOptions { /** * Optional. This checksum is computed by the server based on the value of * other fields, and may be sent on update and delete requests to ensure the * client has an up-to-date value before proceeding. */ etag?: string; /** * Optional. An optional request ID to identify requests. Specify a unique * request ID so that if you must retry your request, the server will know to * ignore the request if it has already been completed. The server will * guarantee that for at least 60 minutes after the first request. For * example, consider a situation where you make an initial request and the * request times out. If you make the request again with the same request ID, * the server can check if original operation with the same request ID was * received, and if so, will ignore the second request. This prevents clients * from accidentally creating duplicate commitments. The request ID must be a * valid UUID with the exception that zero UUID is not supported * (00000000-0000-0000-0000-000000000000). */ requestId?: string; /** * Optional. If set, validate the request, but do not actually post it. */ validateOnly?: boolean; } /** * Additional options for * DeveloperConnect#projectsLocationsConnectionsGitRepositoryLinksFetchGitRefs. */ export interface ProjectsLocationsConnectionsGitRepositoryLinksFetchGitRefsOptions { /** * Optional. Number of results to return in the list. Default to 20. */ pageSize?: number; /** * Optional. Page start. */ pageToken?: string; /** * Required. Type of refs to fetch. */ refType?: | "REF_TYPE_UNSPECIFIED" | "TAG" | "BRANCH"; } /** * Additional options for * DeveloperConnect#projectsLocationsConnectionsGitRepositoryLinksList. */ export interface ProjectsLocationsConnectionsGitRepositoryLinksListOptions { /** * Optional. Filtering results */ filter?: string; /** * Optional. Hint for how to order the results */ orderBy?: string; /** * Optional. Requested page size. Server may return fewer items than * requested. If unspecified, server will pick an appropriate default. */ pageSize?: number; /** * Optional. A token identifying a page of results the server should return. */ pageToken?: string; } /** * Additional options for DeveloperConnect#projectsLocationsConnectionsList. */ export interface ProjectsLocationsConnectionsListOptions { /** * Optional. Filtering results */ filter?: string; /** * Optional. Hint for how to order the results */ orderBy?: string; /** * Optional. Requested page size. Server may return fewer items than * requested. If unspecified, server will pick an appropriate default. */ pageSize?: number; /** * Optional. A token identifying a page of results the server should return. */ pageToken?: string; } /** * Additional options for DeveloperConnect#projectsLocationsConnectionsPatch. */ export interface ProjectsLocationsConnectionsPatchOptions { /** * Optional. If set to true, and the connection is not found a new connection * will be created. In this situation `update_mask` is ignored. The creation * will succeed only if the input connection has all the necessary information * (e.g a github_config with both user_oauth_token and installation_id * properties). */ allowMissing?: boolean; /** * Optional. An optional request ID to identify requests. Specify a unique * request ID so that if you must retry your request, the server will know to * ignore the request if it has already been completed. The server will * guarantee that for at least 60 minutes since the first request. For * example, consider a situation where you make an initial request and the * request times out. If you make the request again with the same request ID, * the server can check if original operation with the same request ID was * received, and if so, will ignore the second request. This prevents clients * from accidentally creating duplicate commitments. The request ID must be a * valid UUID with the exception that zero UUID is not supported * (00000000-0000-0000-0000-000000000000). */ requestId?: string; /** * Required. Field mask is used to specify the fields to be overwritten in * the Connection resource by the update. The fields specified in the * update_mask are relative to the resource, not the full request. A field * will be overwritten if it is in the mask. If the user does not provide a * mask then all fields will be overwritten. */ updateMask?: string /* FieldMask */; /** * Optional. If set, validate the request, but do not actually post it. */ validateOnly?: boolean; } function serializeProjectsLocationsConnectionsPatchOptions(data: any): ProjectsLocationsConnectionsPatchOptions { return { ...data, updateMask: data["updateMask"] !== undefined ? data["updateMask"] : undefined, }; } function deserializeProjectsLocationsConnectionsPatchOptions(data: any): ProjectsLocationsConnectionsPatchOptions { return { ...data, updateMask: data["updateMask"] !== undefined ? data["updateMask"] : undefined, }; } /** * Additional options for DeveloperConnect#projectsLocationsList. */ export interface ProjectsLocationsListOptions { /** * 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; } /** * Additional options for DeveloperConnect#projectsLocationsOperationsList. */ export interface ProjectsLocationsOperationsListOptions { /** * The standard list filter. */ filter?: string; /** * The standard list page size. */ pageSize?: number; /** * The standard list page token. */ pageToken?: string; } /** * ServiceDirectoryConfig represents Service Directory configuration for a * connection. */ export interface ServiceDirectoryConfig { /** * Required. The Service Directory service name. Format: * projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}. */ service?: string; } /** * The `Status` type defines a logical error model that is suitable for * different programming environments, including REST APIs and RPC APIs. It is * used by [gRPC](https://github.com/grpc). Each `Status` message contains three * pieces of data: error code, error message, and error details. You can find * out more about this error model and how to work with it in the [API Design * Guide](https://cloud.google.com/apis/design/errors). */ export interface Status { /** * The status code, which should be an enum value of google.rpc.Code. */ code?: number; /** * A list of messages that carry the error details. There is a common set of * message types for APIs to use. */ details?: { [key: string]: any }[]; /** * A developer-facing error message, which should be in English. Any * user-facing error message should be localized and sent in the * google.rpc.Status.details field, or localized by the client. */ message?: string; } /** * Represents a personal access token that authorized the Connection, and * associated metadata. */ export interface UserCredential { /** * Output only. The username associated with this token. */ readonly username?: string; /** * Required. A SecretManager resource containing the user token that * authorizes the Developer Connect connection. Format: * `projects/*\/secrets/*\/versions/*`. */ userTokenSecretVersion?: string; } function decodeBase64(b64: string): Uint8Array { const binString = atob(b64); const size = binString.length; const bytes = new Uint8Array(size); for (let i = 0; i < size; i++) { bytes[i] = binString.charCodeAt(i); } return bytes; } const base64abc = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"]; /** * CREDIT: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727 * Encodes a given Uint8Array, ArrayBuffer or string into RFC4648 base64 representation * @param data */ function encodeBase64(uint8: Uint8Array): string { let result = "", i; const l = uint8.length; for (i = 2; i < l; i += 3) { result += base64abc[uint8[i - 2] >> 2]; result += base64abc[((uint8[i - 2] & 0x03) << 4) | (uint8[i - 1] >> 4)]; result += base64abc[((uint8[i - 1] & 0x0f) << 2) | (uint8[i] >> 6)]; result += base64abc[uint8[i] & 0x3f]; } if (i === l + 1) { // 1 octet yet to write result += base64abc[uint8[i - 2] >> 2]; result += base64abc[(uint8[i - 2] & 0x03) << 4]; result += "=="; } if (i === l) { // 2 octets yet to write result += base64abc[uint8[i - 2] >> 2]; result += base64abc[((uint8[i - 2] & 0x03) << 4) | (uint8[i - 1] >> 4)]; result += base64abc[(uint8[i - 1] & 0x0f) << 2]; result += "="; } return result; }