// Copyright 2022 Luca Casonato. All rights reserved. MIT license. /** * Google Cloud Support API Client for Deno * ======================================== * * Manages Google Cloud technical support cases for Customer Care support offerings. * * Docs: https://cloud.google.com/support/docs/apis * Source: https://googleapis.deno.dev/v1/cloudsupport:v2.ts */ import { auth, CredentialsClient, GoogleAuth, request } from "/_/base@v1/mod.ts"; export { auth, GoogleAuth }; export type { CredentialsClient }; /** * Manages Google Cloud technical support cases for Customer Care support * offerings. */ export class CloudSupport { #client: CredentialsClient | undefined; #baseUrl: string; constructor(client?: CredentialsClient, baseUrl: string = "https://cloudsupport.googleapis.com/") { this.#client = client; this.#baseUrl = baseUrl; } /** * Retrieve valid classifications to use when creating a support case. * Classifications are hierarchical. Each classification is a string * containing all levels of the hierarchy separated by `" > "`. For example, * `"Technical Issue > Compute > Compute Engine"`. Classification IDs returned * by this endpoint are valid for at least six months. When a classification * is deactivated, this endpoint immediately stops returning it. After six * months, `case.create` requests using the classification will fail. * EXAMPLES: cURL: ```shell curl \ --header "Authorization: Bearer $(gcloud * auth print-access-token)" \ * 'https://cloudsupport.googleapis.com/v2/caseClassifications:search?query=display_name:"*Compute%20Engine*"' * ``` Python: ```python import googleapiclient.discovery supportApiService = * googleapiclient.discovery.build( serviceName="cloudsupport", version="v2", * discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version=v2", * ) request = supportApiService.caseClassifications().search( * query='display_name:"*Compute Engine*"' ) print(request.execute()) ``` * */ async caseClassificationsSearch(opts: CaseClassificationsSearchOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v2/caseClassifications: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)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return data as SearchCaseClassificationsResponse; } /** * List all the attachments associated with a support case. EXAMPLES: cURL: * ```shell case="projects/some-project/cases/23598314" curl \ --header * "Authorization: Bearer $(gcloud auth print-access-token)" \ * "https://cloudsupport.googleapis.com/v2/$case/attachments" ``` Python: * ```python import googleapiclient.discovery api_version = "v2" * supportApiService = googleapiclient.discovery.build( * serviceName="cloudsupport", version=api_version, * discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", * ) request = ( supportApiService.cases() .attachments() * .list(parent="projects/some-project/cases/43595344") ) * print(request.execute()) ``` * * @param parent Required. The name of the case for which attachments should be listed. */ async casesAttachmentsList(parent: string, opts: CasesAttachmentsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v2/${ parent }/attachments`); 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 ListAttachmentsResponse; } /** * Close a case. EXAMPLES: cURL: ```shell * case="projects/some-project/cases/43595344" curl \ --request POST \ * --header "Authorization: Bearer $(gcloud auth print-access-token)" \ * "https://cloudsupport.googleapis.com/v2/$case:close" ``` Python: ```python * import googleapiclient.discovery api_version = "v2" supportApiService = * googleapiclient.discovery.build( serviceName="cloudsupport", * version=api_version, * discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", * ) request = supportApiService.cases().close( * name="projects/some-project/cases/43595344" ) print(request.execute()) ``` * * @param name Required. The name of the case to close. */ async casesClose(name: string, req: CloseCaseRequest): Promise { const url = new URL(`${this.#baseUrl}v2/${ name }:close`); const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as Case; } /** * Add a new comment to a case. The comment must have the following fields * set: `body`. EXAMPLES: cURL: ```shell * case="projects/some-project/cases/43591344" curl \ --request POST \ * --header "Authorization: Bearer $(gcloud auth print-access-token)" \ * --header 'Content-Type: application/json' \ --data '{ "body": "This is a * test comment." }' \ "https://cloudsupport.googleapis.com/v2/$case/comments" * ``` Python: ```python import googleapiclient.discovery api_version = "v2" * supportApiService = googleapiclient.discovery.build( * serviceName="cloudsupport", version=api_version, * discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", * ) request = ( supportApiService.cases() .comments() .create( * parent="projects/some-project/cases/43595344", body={"body": "This is a * test comment."}, ) ) print(request.execute()) ``` * * @param parent Required. The name of the case to which the comment should be added. */ async casesCommentsCreate(parent: string, req: Comment): Promise { const url = new URL(`${this.#baseUrl}v2/${ parent }/comments`); const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as Comment; } /** * List all the comments associated with a case. EXAMPLES: cURL: ```shell * case="projects/some-project/cases/43595344" curl \ --header "Authorization: * Bearer $(gcloud auth print-access-token)" \ * "https://cloudsupport.googleapis.com/v2/$case/comments" ``` Python: * ```python import googleapiclient.discovery api_version = "v2" * supportApiService = googleapiclient.discovery.build( * serviceName="cloudsupport", version=api_version, * discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", * ) request = ( supportApiService.cases() .comments() * .list(parent="projects/some-project/cases/43595344") ) * print(request.execute()) ``` * * @param parent Required. The name of the case for which to list comments. */ async casesCommentsList(parent: string, opts: CasesCommentsListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v2/${ parent }/comments`); 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 ListCommentsResponse; } /** * Create a new case and associate it with a parent. It must have the * following fields set: `display_name`, `description`, `classification`, and * `priority`. If you're just testing the API and don't want to route your * case to an agent, set `testCase=true`. EXAMPLES: cURL: ```shell * parent="projects/some-project" curl \ --request POST \ --header * "Authorization: Bearer $(gcloud auth print-access-token)" \ --header * 'Content-Type: application/json' \ --data '{ "display_name": "Test case * created by me.", "description": "a random test case, feel free to close", * "classification": { "id": * "100IK2AKCLHMGRJ9CDGMOCGP8DM6UTB4BT262T31BT1M2T31DHNMENPO6KS36CPJ786L2TBFEHGN6NPI64R3CDHN8880G08I1H3MURR7DHII0GRCDTQM8" * }, "time_zone": "-07:00", "subscriber_email_addresses": [ "foo@domain.com", * "bar@domain.com" ], "testCase": true, "priority": "P3" }' \ * "https://cloudsupport.googleapis.com/v2/$parent/cases" ``` Python: * ```python import googleapiclient.discovery api_version = "v2" * supportApiService = googleapiclient.discovery.build( * serviceName="cloudsupport", version=api_version, * discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", * ) request = supportApiService.cases().create( * parent="projects/some-project", body={ "displayName": "A Test Case", * "description": "This is a test case.", "testCase": True, "priority": "P2", * "classification": { "id": * "100IK2AKCLHMGRJ9CDGMOCGP8DM6UTB4BT262T31BT1M2T31DHNMENPO6KS36CPJ786L2TBFEHGN6NPI64R3CDHN8880G08I1H3MURR7DHII0GRCDTQM8" * }, }, ) print(request.execute()) ``` * * @param parent Required. The name of the parent under which the case should be created. */ async casesCreate(parent: string, req: Case): Promise { const url = new URL(`${this.#baseUrl}v2/${ parent }/cases`); const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as Case; } /** * Escalate a case, starting the Google Cloud Support escalation management * process. This operation is only available for some support services. Go to * https://cloud.google.com/support and look for 'Technical support * escalations' in the feature list to find out which ones let you do that. * EXAMPLES: cURL: ```shell case="projects/some-project/cases/43595344" curl \ * --request POST \ --header "Authorization: Bearer $(gcloud auth * print-access-token)" \ --header "Content-Type: application/json" \ --data * '{ "escalation": { "reason": "BUSINESS_IMPACT", "justification": "This is a * test escalation." } }' \ * "https://cloudsupport.googleapis.com/v2/$case:escalate" ``` Python: * ```python import googleapiclient.discovery api_version = "v2" * supportApiService = googleapiclient.discovery.build( * serviceName="cloudsupport", version=api_version, * discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", * ) request = supportApiService.cases().escalate( * name="projects/some-project/cases/43595344", body={ "escalation": { * "reason": "BUSINESS_IMPACT", "justification": "This is a test escalation.", * }, }, ) print(request.execute()) ``` * * @param name Required. The name of the case to be escalated. */ async casesEscalate(name: string, req: EscalateCaseRequest): Promise { const url = new URL(`${this.#baseUrl}v2/${ name }:escalate`); const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as Case; } /** * Retrieve a case. EXAMPLES: cURL: ```shell * case="projects/some-project/cases/16033687" curl \ --header "Authorization: * Bearer $(gcloud auth print-access-token)" \ * "https://cloudsupport.googleapis.com/v2/$case" ``` Python: ```python import * googleapiclient.discovery api_version = "v2" supportApiService = * googleapiclient.discovery.build( serviceName="cloudsupport", * version=api_version, * discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", * ) request = supportApiService.cases().get( * name="projects/some-project/cases/43595344", ) print(request.execute()) ``` * * @param name Required. The full name of a case to be retrieved. */ async casesGet(name: string): Promise { const url = new URL(`${this.#baseUrl}v2/${ name }`); const data = await request(url.href, { client: this.#client, method: "GET", }); return data as Case; } /** * Retrieve all cases under a parent, but not its children. For example, * listing cases under an organization only returns the cases that are * directly parented by that organization. To retrieve cases under an * organization and its projects, use `cases.search`. EXAMPLES: cURL: ```shell * parent="projects/some-project" curl \ --header "Authorization: Bearer * $(gcloud auth print-access-token)" \ * "https://cloudsupport.googleapis.com/v2/$parent/cases" ``` Python: * ```python import googleapiclient.discovery api_version = "v2" * supportApiService = googleapiclient.discovery.build( * serviceName="cloudsupport", version=api_version, * discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", * ) request = supportApiService.cases().list(parent="projects/some-project") * print(request.execute()) ``` * * @param parent Required. The name of a parent to list cases under. */ async casesList(parent: string, opts: CasesListOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v2/${ parent }/cases`); 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 ListCasesResponse; } /** * Update a case. Only some fields can be updated. EXAMPLES: cURL: ```shell * case="projects/some-project/cases/43595344" curl \ --request PATCH \ * --header "Authorization: Bearer $(gcloud auth print-access-token)" \ * --header "Content-Type: application/json" \ --data '{ "priority": "P1" }' \ * "https://cloudsupport.googleapis.com/v2/$case?updateMask=priority" ``` * Python: ```python import googleapiclient.discovery api_version = "v2" * supportApiService = googleapiclient.discovery.build( * serviceName="cloudsupport", version=api_version, * discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", * ) request = supportApiService.cases().patch( * name="projects/some-project/cases/43112854", body={ "displayName": "This is * Now a New Title", "priority": "P2", }, ) print(request.execute()) ``` * * @param name The resource name for the case. */ async casesPatch(name: string, req: Case, opts: CasesPatchOptions = {}): Promise { opts = serializeCasesPatchOptions(opts); const url = new URL(`${this.#baseUrl}v2/${ 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 Case; } /** * Search for cases using a query. EXAMPLES: cURL: ```shell * parent="projects/some-project" curl \ --header "Authorization: Bearer * $(gcloud auth print-access-token)" \ * "https://cloudsupport.googleapis.com/v2/$parent/cases:search" ``` Python: * ```python import googleapiclient.discovery api_version = "v2" * supportApiService = googleapiclient.discovery.build( * serviceName="cloudsupport", version=api_version, * discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", * ) request = supportApiService.cases().search( * parent="projects/some-project", query="state=OPEN" ) * print(request.execute()) ``` * * @param parent The name of the parent resource to search for cases under. */ async casesSearch(parent: string, opts: CasesSearchOptions = {}): Promise { const url = new URL(`${this.#baseUrl}v2/${ parent }/cases: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)); } const data = await request(url.href, { client: this.#client, method: "GET", }); return data as SearchCasesResponse; } /** * Download a file attached to a case. Note: HTTP requests must append * "?alt=media" to the URL. EXAMPLES: cURL: ```shell * name="projects/some-project/cases/43594844/attachments/0674M00000WijAnZAJ" * curl \ --header "Authorization: Bearer $(gcloud auth print-access-token)" \ * "https://cloudsupport.googleapis.com/v2/$name:download?alt=media" ``` * Python: ```python import googleapiclient.discovery api_version = "v2" * supportApiService = googleapiclient.discovery.build( * serviceName="cloudsupport", version=api_version, * discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", * ) request = supportApiService.media().download( * name="projects/some-project/cases/43595344/attachments/0684M00000Pw6pHQAR" * ) request.uri = request.uri.split("?")[0] + "?alt=media" * print(request.execute()) ``` * * @param name The name of the file attachment to download. */ async mediaDownload(name: string): Promise { const url = new URL(`${this.#baseUrl}v2/${ name }:download`); const data = await request(url.href, { client: this.#client, method: "GET", }); return deserializeMedia(data); } /** * Create a file attachment on a case or Cloud resource. The attachment must * have the following fields set: `filename`. EXAMPLES: cURL: ```shell echo * "This text is in a file I'm uploading using CSAPI." \ > * "./example_file.txt" case="projects/some-project/cases/43594844" curl \ * --header "Authorization: Bearer $(gcloud auth print-access-token)" \ * --data-binary @"./example_file.txt" \ * "https://cloudsupport.googleapis.com/upload/v2beta/$case/attachments?attachment.filename=uploaded_via_curl.txt" * ``` Python: ```python import googleapiclient.discovery api_version = "v2" * supportApiService = googleapiclient.discovery.build( * serviceName="cloudsupport", version=api_version, * discoveryServiceUrl=f"https://cloudsupport.googleapis.com/$discovery/rest?version={api_version}", * ) file_path = "./example_file.txt" with open(file_path, "w") as file: * file.write( "This text is inside a file I'm going to upload using the Cloud * Support API.", ) request = supportApiService.media().upload( * parent="projects/some-project/cases/43595344", media_body=file_path ) * request.uri = request.uri.split("?")[0] + * "?attachment.filename=uploaded_via_python.txt" print(request.execute()) ``` * * @param parent Required. The name of the case or Cloud resource to which the attachment should be attached. */ async mediaUpload(parent: string, req: CreateAttachmentRequest): Promise { const url = new URL(`${this.#baseUrl}v2/${ parent }/attachments`); const body = JSON.stringify(req); const data = await request(url.href, { client: this.#client, method: "POST", body, }); return data as Attachment; } } /** * An Actor represents an entity that performed an action. For example, an * actor could be a user who posted a comment on a support case, a user who * uploaded an attachment, or a service account that created a support case. */ export interface Actor { /** * The name to display for the actor. If not provided, it is inferred from * credentials supplied during case creation. When an email is provided, a * display name must also be provided. This will be obfuscated if the user is * a Google Support agent. */ displayName?: string; /** * The email address of the actor. If not provided, it is inferred from the * credentials supplied during case creation. When a name is provided, an * email must also be provided. If the user is a Google Support agent, this is * obfuscated. This field is deprecated. Use **username** field instead. */ email?: string; /** * Output only. Whether the actor is a Google support actor. */ readonly googleSupport?: boolean; /** * Output only. The username of the actor. It may look like an email or other * format provided by the identity provider. If not provided, it is inferred * from the credentials supplied. When a name is provided, a username must * also be provided. If the user is a Google Support agent, this will not be * set. */ readonly username?: string; } /** * An Attachment contains metadata about a file that was uploaded to a case - * it is NOT a file itself. That being said, the name of an Attachment object * can be used to download its accompanying file through the `media.download` * endpoint. While attachments can be uploaded in the console at the same time * as a comment, they're associated on a "case" level, not a "comment" level. */ export interface Attachment { /** * Output only. The time at which the attachment was created. */ readonly createTime?: Date; /** * Output only. The user who uploaded the attachment. Note, the name and * email will be obfuscated if the attachment was uploaded by Google support. */ readonly creator?: Actor; /** * The filename of the attachment (e.g. `"graph.jpg"`). */ filename?: string; /** * Output only. The MIME type of the attachment (e.g. text/plain). */ readonly mimeType?: string; /** * Output only. The resource name of the attachment. */ readonly name?: string; /** * Output only. The size of the attachment in bytes. */ readonly sizeBytes?: bigint; } /** * # gdata.* are outside protos with mising documentation */ export interface Blobstore2Info { /** * # gdata.* are outside protos with mising documentation */ blobGeneration?: bigint; /** * # gdata.* are outside protos with mising documentation */ blobId?: string; /** * # gdata.* are outside protos with mising documentation */ downloadReadHandle?: Uint8Array; /** * # gdata.* are outside protos with mising documentation */ readToken?: string; /** * # gdata.* are outside protos with mising documentation */ uploadMetadataContainer?: Uint8Array; } function serializeBlobstore2Info(data: any): Blobstore2Info { return { ...data, blobGeneration: data["blobGeneration"] !== undefined ? String(data["blobGeneration"]) : undefined, downloadReadHandle: data["downloadReadHandle"] !== undefined ? encodeBase64(data["downloadReadHandle"]) : undefined, uploadMetadataContainer: data["uploadMetadataContainer"] !== undefined ? encodeBase64(data["uploadMetadataContainer"]) : undefined, }; } function deserializeBlobstore2Info(data: any): Blobstore2Info { return { ...data, blobGeneration: data["blobGeneration"] !== undefined ? BigInt(data["blobGeneration"]) : undefined, downloadReadHandle: data["downloadReadHandle"] !== undefined ? decodeBase64(data["downloadReadHandle"] as string) : undefined, uploadMetadataContainer: data["uploadMetadataContainer"] !== undefined ? decodeBase64(data["uploadMetadataContainer"] as string) : undefined, }; } /** * A Case is an object that contains the details of a support case. It contains * fields for the time it was created, its priority, its classification, and * more. Cases can also have comments and attachments that get added over time. * A case is parented by a Google Cloud organization or project. Organizations * are identified by a number, so the name of a case parented by an organization * would look like this: ``` organizations/123/cases/456 ``` Projects have two * unique identifiers, an ID and a number, and they look like this: ``` * projects/abc/cases/456 ``` ``` projects/123/cases/456 ``` You can use either * of them when calling the API. To learn more about project identifiers, see * [AIP-2510](https://google.aip.dev/cloud/2510). */ export interface Case { /** * The issue classification applicable to this case. */ classification?: CaseClassification; /** * A user-supplied email address to send case update notifications for. This * should only be used in BYOID flows, where we cannot infer the user's email * address directly from their EUCs. */ contactEmail?: string; /** * Output only. The time this case was created. */ readonly createTime?: Date; /** * The user who created the case. Note: The name and email will be obfuscated * if the case was created by Google Support. */ creator?: Actor; /** * A broad description of the issue. */ description?: string; /** * The short summary of the issue reported in this case. */ displayName?: string; /** * Whether the case is currently escalated. */ escalated?: boolean; /** * The language the user has requested to receive support in. This should be * a BCP 47 language code (e.g., `"en"`, `"zh-CN"`, `"zh-TW"`, `"ja"`, * `"ko"`). If no language or an unsupported language is specified, this field * defaults to English (en). Language selection during case creation may * affect your available support options. For a list of supported languages * and their support working hours, see: * https://cloud.google.com/support/docs/language-working-hours */ languageCode?: string; /** * The resource name for the case. */ name?: string; /** * The priority of this case. */ priority?: | "PRIORITY_UNSPECIFIED" | "P0" | "P1" | "P2" | "P3" | "P4"; /** * Output only. The current status of the support case. */ readonly state?: | "STATE_UNSPECIFIED" | "NEW" | "IN_PROGRESS_GOOGLE_SUPPORT" | "ACTION_REQUIRED" | "SOLUTION_PROVIDED" | "CLOSED"; /** * The email addresses to receive updates on this case. */ subscriberEmailAddresses?: string[]; /** * Whether this case was created for internal API testing and should not be * acted on by the support team. */ testCase?: boolean; /** * The timezone of the user who created the support case. It should be in a * format IANA recognizes: https://www.iana.org/time-zones. There is no * additional validation done by the API. */ timeZone?: string; /** * Output only. The time this case was last updated. */ readonly updateTime?: Date; } /** * A Case Classification represents the topic that a case is about. It's very * important to use accurate classifications, because they're used to route your * cases to specialists who can help you. A classification always has an ID that * is its unique identifier. A valid ID is required when creating a case. */ export interface CaseClassification { /** * A display name for the classification. The display name is not static and * can change. To uniquely and consistently identify classifications, use the * `CaseClassification.id` field. */ displayName?: string; /** * The unique ID for a classification. Must be specified for case creation. * To retrieve valid classification IDs for case creation, use * `caseClassifications.search`. Classification IDs returned by * `caseClassifications.search` are guaranteed to be valid for at least 6 * months. If a given classification is deactiveated, it will immediately stop * being returned. After 6 months, `case.create` requests using the * classification ID will fail. */ id?: string; } /** * Additional options for CloudSupport#caseClassificationsSearch. */ export interface CaseClassificationsSearchOptions { /** * The maximum number of classifications fetched with each request. */ pageSize?: number; /** * A token identifying the page of results to return. If unspecified, the * first page is retrieved. */ pageToken?: string; /** * An expression used to filter case classifications. If it's an empty * string, then no filtering happens. Otherwise, case classifications will be * returned that match the filter. */ query?: string; } /** * Additional options for CloudSupport#casesAttachmentsList. */ export interface CasesAttachmentsListOptions { /** * The maximum number of attachments fetched with each request. If not * provided, the default is 10. The maximum page size that will be returned is * 100. */ pageSize?: number; /** * A token identifying the page of results to return. If unspecified, the * first page is retrieved. */ pageToken?: string; } /** * Additional options for CloudSupport#casesCommentsList. */ export interface CasesCommentsListOptions { /** * The maximum number of comments to fetch. Defaults to 10. */ pageSize?: number; /** * A token identifying the page of results to return. If unspecified, the * first page is returned. */ pageToken?: string; } /** * Additional options for CloudSupport#casesList. */ export interface CasesListOptions { /** * An expression used to filter cases. If it's an empty string, then no * filtering happens. Otherwise, the endpoint returns the cases that match the * filter. Expressions use the following fields separated by `AND` and * specified with `=`: - `state`: Can be `OPEN` or `CLOSED`. - `priority`: Can * be `P0`, `P1`, `P2`, `P3`, or `P4`. You can specify multiple values for * priority using the `OR` operator. For example, `priority=P1 OR * priority=P2`. - `creator.email`: The email address of the case creator. * EXAMPLES: - `state=CLOSED` - `state=OPEN AND * creator.email="tester@example.com"` - `state=OPEN AND (priority=P0 OR * priority=P1)` */ filter?: string; /** * The maximum number of cases fetched with each request. Defaults to 10. */ pageSize?: number; /** * A token identifying the page of results to return. If unspecified, the * first page is retrieved. */ pageToken?: string; } /** * Additional options for CloudSupport#casesPatch. */ export interface CasesPatchOptions { /** * A list of attributes of the case that should be updated. Supported values * are `priority`, `display_name`, and `subscriber_email_addresses`. If no * fields are specified, all supported fields are updated. Be careful - if you * do not provide a field mask, then you might accidentally clear some fields. * For example, if you leave the field mask empty and do not provide a value * for `subscriber_email_addresses`, then `subscriber_email_addresses` is * updated to empty. */ updateMask?: string /* FieldMask */; } function serializeCasesPatchOptions(data: any): CasesPatchOptions { return { ...data, updateMask: data["updateMask"] !== undefined ? data["updateMask"] : undefined, }; } function deserializeCasesPatchOptions(data: any): CasesPatchOptions { return { ...data, updateMask: data["updateMask"] !== undefined ? data["updateMask"] : undefined, }; } /** * Additional options for CloudSupport#casesSearch. */ export interface CasesSearchOptions { /** * The maximum number of cases fetched with each request. The default page * size is 10. */ pageSize?: number; /** * A token identifying the page of results to return. If unspecified, the * first page is retrieved. */ pageToken?: string; /** * An expression used to filter cases. Expressions use the following fields * separated by `AND` and specified with `=`: - `organization`: An * organization name in the form `organizations/`. - `project`: A project name * in the form `projects/`. - `state`: Can be `OPEN` or `CLOSED`. - * `priority`: Can be `P0`, `P1`, `P2`, `P3`, or `P4`. You can specify * multiple values for priority using the `OR` operator. For example, * `priority=P1 OR priority=P2`. - `creator.email`: The email address of the * case creator. You must specify either `organization` or `project`. To * search across `displayName`, `description`, and comments, use a global * restriction with no keyword or operator. For example, `"my search"`. To * search only cases updated after a certain date, use `update_time` * restricted with that particular date, time, and timezone in ISO datetime * format. For example, `update_time>"2020-01-01T00:00:00-05:00"`. * `update_time` only supports the greater than operator (`>`). Examples: - * `organization="organizations/123456789"` - * `project="projects/my-project-id"` - `project="projects/123456789"` - * `organization="organizations/123456789" AND state=CLOSED` - * `project="projects/my-project-id" AND creator.email="tester@example.com"` - * `project="projects/my-project-id" AND (priority=P0 OR priority=P1)` */ query?: string; } /** * The request message for the CloseCase endpoint. */ export interface CloseCaseRequest { } /** * A comment associated with a support case. Case comments are the primary way * for Google Support to communicate with a user who has opened a case. When a * user responds to Google Support, the user's responses also appear as * comments. */ export interface Comment { /** * The full comment body. Maximum of 12800 characters. */ body?: string; /** * Output only. The time when the comment was created. */ readonly createTime?: Date; /** * Output only. The user or Google Support agent who created the comment. */ readonly creator?: Actor; /** * Output only. Identifier. The resource name of the comment. */ readonly name?: string; /** * Output only. DEPRECATED. DO NOT USE. A duplicate of the `body` field. This * field is only present for legacy reasons. */ readonly plainTextBody?: string; } /** * # gdata.* are outside protos with mising documentation */ export interface CompositeMedia { /** * # gdata.* are outside protos with mising documentation */ blobRef?: Uint8Array; /** * # gdata.* are outside protos with mising documentation */ blobstore2Info?: Blobstore2Info; /** * # gdata.* are outside protos with mising documentation */ cosmoBinaryReference?: Uint8Array; /** * # gdata.* are outside protos with mising documentation */ crc32cHash?: number; /** * # gdata.* are outside protos with mising documentation */ inline?: Uint8Array; /** * # gdata.* are outside protos with mising documentation */ length?: bigint; /** * # gdata.* are outside protos with mising documentation */ md5Hash?: Uint8Array; /** * # gdata.* are outside protos with mising documentation */ objectId?: ObjectId; /** * # gdata.* are outside protos with mising documentation */ path?: string; /** * # gdata.* are outside protos with mising documentation */ referenceType?: | "PATH" | "BLOB_REF" | "INLINE" | "BIGSTORE_REF" | "COSMO_BINARY_REFERENCE"; /** * # gdata.* are outside protos with mising documentation */ sha1Hash?: Uint8Array; } function serializeCompositeMedia(data: any): CompositeMedia { return { ...data, blobRef: data["blobRef"] !== undefined ? encodeBase64(data["blobRef"]) : undefined, blobstore2Info: data["blobstore2Info"] !== undefined ? serializeBlobstore2Info(data["blobstore2Info"]) : undefined, cosmoBinaryReference: data["cosmoBinaryReference"] !== undefined ? encodeBase64(data["cosmoBinaryReference"]) : undefined, inline: data["inline"] !== undefined ? encodeBase64(data["inline"]) : undefined, length: data["length"] !== undefined ? String(data["length"]) : undefined, md5Hash: data["md5Hash"] !== undefined ? encodeBase64(data["md5Hash"]) : undefined, objectId: data["objectId"] !== undefined ? serializeObjectId(data["objectId"]) : undefined, sha1Hash: data["sha1Hash"] !== undefined ? encodeBase64(data["sha1Hash"]) : undefined, }; } function deserializeCompositeMedia(data: any): CompositeMedia { return { ...data, blobRef: data["blobRef"] !== undefined ? decodeBase64(data["blobRef"] as string) : undefined, blobstore2Info: data["blobstore2Info"] !== undefined ? deserializeBlobstore2Info(data["blobstore2Info"]) : undefined, cosmoBinaryReference: data["cosmoBinaryReference"] !== undefined ? decodeBase64(data["cosmoBinaryReference"] as string) : undefined, inline: data["inline"] !== undefined ? decodeBase64(data["inline"] as string) : undefined, length: data["length"] !== undefined ? BigInt(data["length"]) : undefined, md5Hash: data["md5Hash"] !== undefined ? decodeBase64(data["md5Hash"] as string) : undefined, objectId: data["objectId"] !== undefined ? deserializeObjectId(data["objectId"]) : undefined, sha1Hash: data["sha1Hash"] !== undefined ? decodeBase64(data["sha1Hash"] as string) : undefined, }; } /** * # gdata.* are outside protos with mising documentation */ export interface ContentTypeInfo { /** * # gdata.* are outside protos with mising documentation */ bestGuess?: string; /** * # gdata.* are outside protos with mising documentation */ fromBytes?: string; /** * # gdata.* are outside protos with mising documentation */ fromFileName?: string; /** * # gdata.* are outside protos with mising documentation */ fromHeader?: string; /** * # gdata.* are outside protos with mising documentation */ fromUrlPath?: string; } /** * The request message for the CreateAttachment endpoint. */ export interface CreateAttachmentRequest { /** * Required. The attachment to be created. */ attachment?: Attachment; } /** * # gdata.* are outside protos with mising documentation */ export interface DiffChecksumsResponse { /** * # gdata.* are outside protos with mising documentation */ checksumsLocation?: CompositeMedia; /** * # gdata.* are outside protos with mising documentation */ chunkSizeBytes?: bigint; /** * # gdata.* are outside protos with mising documentation */ objectLocation?: CompositeMedia; /** * # gdata.* are outside protos with mising documentation */ objectSizeBytes?: bigint; /** * # gdata.* are outside protos with mising documentation */ objectVersion?: string; } function serializeDiffChecksumsResponse(data: any): DiffChecksumsResponse { return { ...data, checksumsLocation: data["checksumsLocation"] !== undefined ? serializeCompositeMedia(data["checksumsLocation"]) : undefined, chunkSizeBytes: data["chunkSizeBytes"] !== undefined ? String(data["chunkSizeBytes"]) : undefined, objectLocation: data["objectLocation"] !== undefined ? serializeCompositeMedia(data["objectLocation"]) : undefined, objectSizeBytes: data["objectSizeBytes"] !== undefined ? String(data["objectSizeBytes"]) : undefined, }; } function deserializeDiffChecksumsResponse(data: any): DiffChecksumsResponse { return { ...data, checksumsLocation: data["checksumsLocation"] !== undefined ? deserializeCompositeMedia(data["checksumsLocation"]) : undefined, chunkSizeBytes: data["chunkSizeBytes"] !== undefined ? BigInt(data["chunkSizeBytes"]) : undefined, objectLocation: data["objectLocation"] !== undefined ? deserializeCompositeMedia(data["objectLocation"]) : undefined, objectSizeBytes: data["objectSizeBytes"] !== undefined ? BigInt(data["objectSizeBytes"]) : undefined, }; } /** * # gdata.* are outside protos with mising documentation */ export interface DiffDownloadResponse { /** * # gdata.* are outside protos with mising documentation */ objectLocation?: CompositeMedia; } function serializeDiffDownloadResponse(data: any): DiffDownloadResponse { return { ...data, objectLocation: data["objectLocation"] !== undefined ? serializeCompositeMedia(data["objectLocation"]) : undefined, }; } function deserializeDiffDownloadResponse(data: any): DiffDownloadResponse { return { ...data, objectLocation: data["objectLocation"] !== undefined ? deserializeCompositeMedia(data["objectLocation"]) : undefined, }; } /** * # gdata.* are outside protos with mising documentation */ export interface DiffUploadRequest { /** * # gdata.* are outside protos with mising documentation */ checksumsInfo?: CompositeMedia; /** * # gdata.* are outside protos with mising documentation */ objectInfo?: CompositeMedia; /** * # gdata.* are outside protos with mising documentation */ objectVersion?: string; } function serializeDiffUploadRequest(data: any): DiffUploadRequest { return { ...data, checksumsInfo: data["checksumsInfo"] !== undefined ? serializeCompositeMedia(data["checksumsInfo"]) : undefined, objectInfo: data["objectInfo"] !== undefined ? serializeCompositeMedia(data["objectInfo"]) : undefined, }; } function deserializeDiffUploadRequest(data: any): DiffUploadRequest { return { ...data, checksumsInfo: data["checksumsInfo"] !== undefined ? deserializeCompositeMedia(data["checksumsInfo"]) : undefined, objectInfo: data["objectInfo"] !== undefined ? deserializeCompositeMedia(data["objectInfo"]) : undefined, }; } /** * # gdata.* are outside protos with mising documentation */ export interface DiffUploadResponse { /** * # gdata.* are outside protos with mising documentation */ objectVersion?: string; /** * # gdata.* are outside protos with mising documentation */ originalObject?: CompositeMedia; } function serializeDiffUploadResponse(data: any): DiffUploadResponse { return { ...data, originalObject: data["originalObject"] !== undefined ? serializeCompositeMedia(data["originalObject"]) : undefined, }; } function deserializeDiffUploadResponse(data: any): DiffUploadResponse { return { ...data, originalObject: data["originalObject"] !== undefined ? deserializeCompositeMedia(data["originalObject"]) : undefined, }; } /** * # gdata.* are outside protos with mising documentation */ export interface DiffVersionResponse { /** * # gdata.* are outside protos with mising documentation */ objectSizeBytes?: bigint; /** * # gdata.* are outside protos with mising documentation */ objectVersion?: string; } function serializeDiffVersionResponse(data: any): DiffVersionResponse { return { ...data, objectSizeBytes: data["objectSizeBytes"] !== undefined ? String(data["objectSizeBytes"]) : undefined, }; } function deserializeDiffVersionResponse(data: any): DiffVersionResponse { return { ...data, objectSizeBytes: data["objectSizeBytes"] !== undefined ? BigInt(data["objectSizeBytes"]) : undefined, }; } /** * # gdata.* are outside protos with mising documentation */ export interface DownloadParameters { /** * # gdata.* are outside protos with mising documentation */ allowGzipCompression?: boolean; /** * # gdata.* are outside protos with mising documentation */ ignoreRange?: boolean; } /** * The request message for the EscalateCase endpoint. */ export interface EscalateCaseRequest { /** * The escalation information to be sent with the escalation request. */ escalation?: Escalation; } /** * An escalation of a support case. */ export interface Escalation { /** * Required. A free text description to accompany the `reason` field above. * Provides additional context on why the case is being escalated. */ justification?: string; /** * Required. The reason why the Case is being escalated. */ reason?: | "REASON_UNSPECIFIED" | "RESOLUTION_TIME" | "TECHNICAL_EXPERTISE" | "BUSINESS_IMPACT"; } /** * The response message for the ListAttachments endpoint. */ export interface ListAttachmentsResponse { /** * The list of attachments associated with a case. */ attachments?: Attachment[]; /** * A token to retrieve the next page of results. Set this in the `page_token` * field of subsequent `cases.attachments.list` requests. If unspecified, * there are no more results to retrieve. */ nextPageToken?: string; } /** * The response message for the ListCases endpoint. */ export interface ListCasesResponse { /** * The list of cases associated with the parent after any filters have been * applied. */ cases?: Case[]; /** * A token to retrieve the next page of results. Set this in the `page_token` * field of subsequent `cases.list` requests. If unspecified, there are no * more results to retrieve. */ nextPageToken?: string; } /** * The response message for the ListComments endpoint. */ export interface ListCommentsResponse { /** * List of the comments associated with the case. */ comments?: Comment[]; /** * A token to retrieve the next page of results. Set this in the `page_token` * field of subsequent `cases.comments.list` requests. If unspecified, there * are no more results to retrieve. */ nextPageToken?: string; } /** * # gdata.* are outside protos with mising documentation */ export interface Media { /** * # gdata.* are outside protos with mising documentation */ algorithm?: string; /** * # gdata.* are outside protos with mising documentation */ bigstoreObjectRef?: Uint8Array; /** * # gdata.* are outside protos with mising documentation */ blobRef?: Uint8Array; /** * # gdata.* are outside protos with mising documentation */ blobstore2Info?: Blobstore2Info; /** * # gdata.* are outside protos with mising documentation */ compositeMedia?: CompositeMedia[]; /** * # gdata.* are outside protos with mising documentation */ contentType?: string; /** * # gdata.* are outside protos with mising documentation */ contentTypeInfo?: ContentTypeInfo; /** * # gdata.* are outside protos with mising documentation */ cosmoBinaryReference?: Uint8Array; /** * # gdata.* are outside protos with mising documentation */ crc32cHash?: number; /** * # gdata.* are outside protos with mising documentation */ diffChecksumsResponse?: DiffChecksumsResponse; /** * # gdata.* are outside protos with mising documentation */ diffDownloadResponse?: DiffDownloadResponse; /** * # gdata.* are outside protos with mising documentation */ diffUploadRequest?: DiffUploadRequest; /** * # gdata.* are outside protos with mising documentation */ diffUploadResponse?: DiffUploadResponse; /** * # gdata.* are outside protos with mising documentation */ diffVersionResponse?: DiffVersionResponse; /** * # gdata.* are outside protos with mising documentation */ downloadParameters?: DownloadParameters; /** * # gdata.* are outside protos with mising documentation */ filename?: string; /** * # gdata.* are outside protos with mising documentation */ hash?: string; /** * # gdata.* are outside protos with mising documentation */ hashVerified?: boolean; /** * # gdata.* are outside protos with mising documentation */ inline?: Uint8Array; /** * # gdata.* are outside protos with mising documentation */ isPotentialRetry?: boolean; /** * # gdata.* are outside protos with mising documentation */ length?: bigint; /** * # gdata.* are outside protos with mising documentation */ md5Hash?: Uint8Array; /** * # gdata.* are outside protos with mising documentation */ mediaId?: Uint8Array; /** * # gdata.* are outside protos with mising documentation */ objectId?: ObjectId; /** * # gdata.* are outside protos with mising documentation */ path?: string; /** * # gdata.* are outside protos with mising documentation */ referenceType?: | "PATH" | "BLOB_REF" | "INLINE" | "GET_MEDIA" | "COMPOSITE_MEDIA" | "BIGSTORE_REF" | "DIFF_VERSION_RESPONSE" | "DIFF_CHECKSUMS_RESPONSE" | "DIFF_DOWNLOAD_RESPONSE" | "DIFF_UPLOAD_REQUEST" | "DIFF_UPLOAD_RESPONSE" | "COSMO_BINARY_REFERENCE" | "ARBITRARY_BYTES"; /** * # gdata.* are outside protos with mising documentation */ sha1Hash?: Uint8Array; /** * # gdata.* are outside protos with mising documentation */ sha256Hash?: Uint8Array; /** * # gdata.* are outside protos with mising documentation */ timestamp?: bigint; /** * # gdata.* are outside protos with mising documentation */ token?: string; } function serializeMedia(data: any): Media { return { ...data, bigstoreObjectRef: data["bigstoreObjectRef"] !== undefined ? encodeBase64(data["bigstoreObjectRef"]) : undefined, blobRef: data["blobRef"] !== undefined ? encodeBase64(data["blobRef"]) : undefined, blobstore2Info: data["blobstore2Info"] !== undefined ? serializeBlobstore2Info(data["blobstore2Info"]) : undefined, compositeMedia: data["compositeMedia"] !== undefined ? data["compositeMedia"].map((item: any) => (serializeCompositeMedia(item))) : undefined, cosmoBinaryReference: data["cosmoBinaryReference"] !== undefined ? encodeBase64(data["cosmoBinaryReference"]) : undefined, diffChecksumsResponse: data["diffChecksumsResponse"] !== undefined ? serializeDiffChecksumsResponse(data["diffChecksumsResponse"]) : undefined, diffDownloadResponse: data["diffDownloadResponse"] !== undefined ? serializeDiffDownloadResponse(data["diffDownloadResponse"]) : undefined, diffUploadRequest: data["diffUploadRequest"] !== undefined ? serializeDiffUploadRequest(data["diffUploadRequest"]) : undefined, diffUploadResponse: data["diffUploadResponse"] !== undefined ? serializeDiffUploadResponse(data["diffUploadResponse"]) : undefined, diffVersionResponse: data["diffVersionResponse"] !== undefined ? serializeDiffVersionResponse(data["diffVersionResponse"]) : undefined, inline: data["inline"] !== undefined ? encodeBase64(data["inline"]) : undefined, length: data["length"] !== undefined ? String(data["length"]) : undefined, md5Hash: data["md5Hash"] !== undefined ? encodeBase64(data["md5Hash"]) : undefined, mediaId: data["mediaId"] !== undefined ? encodeBase64(data["mediaId"]) : undefined, objectId: data["objectId"] !== undefined ? serializeObjectId(data["objectId"]) : undefined, sha1Hash: data["sha1Hash"] !== undefined ? encodeBase64(data["sha1Hash"]) : undefined, sha256Hash: data["sha256Hash"] !== undefined ? encodeBase64(data["sha256Hash"]) : undefined, timestamp: data["timestamp"] !== undefined ? String(data["timestamp"]) : undefined, }; } function deserializeMedia(data: any): Media { return { ...data, bigstoreObjectRef: data["bigstoreObjectRef"] !== undefined ? decodeBase64(data["bigstoreObjectRef"] as string) : undefined, blobRef: data["blobRef"] !== undefined ? decodeBase64(data["blobRef"] as string) : undefined, blobstore2Info: data["blobstore2Info"] !== undefined ? deserializeBlobstore2Info(data["blobstore2Info"]) : undefined, compositeMedia: data["compositeMedia"] !== undefined ? data["compositeMedia"].map((item: any) => (deserializeCompositeMedia(item))) : undefined, cosmoBinaryReference: data["cosmoBinaryReference"] !== undefined ? decodeBase64(data["cosmoBinaryReference"] as string) : undefined, diffChecksumsResponse: data["diffChecksumsResponse"] !== undefined ? deserializeDiffChecksumsResponse(data["diffChecksumsResponse"]) : undefined, diffDownloadResponse: data["diffDownloadResponse"] !== undefined ? deserializeDiffDownloadResponse(data["diffDownloadResponse"]) : undefined, diffUploadRequest: data["diffUploadRequest"] !== undefined ? deserializeDiffUploadRequest(data["diffUploadRequest"]) : undefined, diffUploadResponse: data["diffUploadResponse"] !== undefined ? deserializeDiffUploadResponse(data["diffUploadResponse"]) : undefined, diffVersionResponse: data["diffVersionResponse"] !== undefined ? deserializeDiffVersionResponse(data["diffVersionResponse"]) : undefined, inline: data["inline"] !== undefined ? decodeBase64(data["inline"] as string) : undefined, length: data["length"] !== undefined ? BigInt(data["length"]) : undefined, md5Hash: data["md5Hash"] !== undefined ? decodeBase64(data["md5Hash"] as string) : undefined, mediaId: data["mediaId"] !== undefined ? decodeBase64(data["mediaId"] as string) : undefined, objectId: data["objectId"] !== undefined ? deserializeObjectId(data["objectId"]) : undefined, sha1Hash: data["sha1Hash"] !== undefined ? decodeBase64(data["sha1Hash"] as string) : undefined, sha256Hash: data["sha256Hash"] !== undefined ? decodeBase64(data["sha256Hash"] as string) : undefined, timestamp: data["timestamp"] !== undefined ? BigInt(data["timestamp"]) : undefined, }; } /** * # gdata.* are outside protos with mising documentation */ export interface ObjectId { /** * # gdata.* are outside protos with mising documentation */ bucketName?: string; /** * # gdata.* are outside protos with mising documentation */ generation?: bigint; /** * # gdata.* are outside protos with mising documentation */ objectName?: string; } function serializeObjectId(data: any): ObjectId { return { ...data, generation: data["generation"] !== undefined ? String(data["generation"]) : undefined, }; } function deserializeObjectId(data: any): ObjectId { return { ...data, generation: data["generation"] !== undefined ? BigInt(data["generation"]) : undefined, }; } /** * The response message for SearchCaseClassifications endpoint. */ export interface SearchCaseClassificationsResponse { /** * The classifications retrieved. */ caseClassifications?: CaseClassification[]; /** * A token to retrieve the next page of results. Set this in the `page_token` * field of subsequent `caseClassifications.list` requests. If unspecified, * there are no more results to retrieve. */ nextPageToken?: string; } /** * The response message for the SearchCases endpoint. */ export interface SearchCasesResponse { /** * The list of cases associated with the parent after any filters have been * applied. */ cases?: Case[]; /** * A token to retrieve the next page of results. Set this in the `page_token` * field of subsequent `cases.search` requests. If unspecified, there are no * more results to retrieve. */ nextPageToken?: string; } /** * Metadata about the operation. Used to lookup the current status. */ export interface WorkflowOperationMetadata { /** * The namespace that the job was scheduled in. Must be included in the * workflow metadata so the workflow status can be retrieved. */ namespace?: string; /** * The type of action the operation is classified as. */ operationAction?: | "OPERATION_ACTION_UNSPECIFIED" | "CREATE_SUPPORT_ACCOUNT" | "UPDATE_SUPPORT_ACCOUNT" | "PURCHASE_SUPPORT_ACCOUNT"; /** * Which version of the workflow service this operation came from. */ workflowOperationType?: | "UNKNOWN_OPERATION_TYPE" | "WORKFLOWS_V1" | "WORKFLOWS_V2"; } 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; }