diff --git a/protos/google/devtools/cloudbuild/v1/cloudbuild.proto b/protos/google/devtools/cloudbuild/v1/cloudbuild.proto index 0e2e44d..6a932ba 100644 --- a/protos/google/devtools/cloudbuild/v1/cloudbuild.proto +++ b/protos/google/devtools/cloudbuild/v1/cloudbuild.proto @@ -176,6 +176,28 @@ service CloudBuild { }; } + // Approves or rejects a pending build. + // + // If approved, the returned LRO will be analogous to the LRO returned from + // a CreateBuild call. + // + // If rejected, the returned LRO will be immediately done. + rpc ApproveBuild(ApproveBuildRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/builds/*}:approve" + body: "*" + additional_bindings { + post: "/v1/{name=projects/*/locations/*/builds/*}:approve" + body: "*" + } + }; + option (google.api.method_signature) = "name,approval_result"; + option (google.longrunning.operation_info) = { + response_type: "Build" + metadata_type: "BuildOperationMetadata" + }; + } + // Creates a new `BuildTrigger`. // // This API is experimental. @@ -720,6 +742,10 @@ message Build { // Status of the build is unknown. STATUS_UNKNOWN = 0; + // Build has been created and is pending execution and queuing. It has not + // been queued. + PENDING = 10; + // Build or step is queued; work has not yet begun. QUEUED = 1; @@ -863,6 +889,10 @@ message Build { // these keys will not be included. map timing = 33 [(google.api.field_behavior) = OUTPUT_ONLY]; + // Output only. Describes this build's approval configuration, status, + // and result. + BuildApproval approval = 44 [(google.api.field_behavior) = OUTPUT_ONLY]; + // IAM service account whose credentials will be used at build runtime. // Must be of the format `projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}`. // ACCOUNT can be email address or uniqueId of the service account. @@ -1145,6 +1175,92 @@ message CancelBuildRequest { string id = 2 [(google.api.field_behavior) = REQUIRED]; } +// Request to approve or reject a pending build. +message ApproveBuildRequest { + // Required. Name of the target build. + // For example: "projects/{$project_id}/builds/{$build_id}" + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Approval decision and metadata. + ApprovalResult approval_result = 2; +} + +// BuildApproval describes a build's approval configuration, state, and +// result. +message BuildApproval { + // Specifies the current state of a build's approval. + enum State { + // Default enum type. This should not be used. + STATE_UNSPECIFIED = 0; + + // Build approval is pending. + PENDING = 1; + + // Build approval has been approved. + APPROVED = 2; + + // Build approval has been rejected. + REJECTED = 3; + + // Build was cancelled while it was still pending approval. + CANCELLED = 5; + } + + // Output only. The state of this build's approval. + State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Configuration for manual approval of this build. + ApprovalConfig config = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Result of manual approval for this Build. + ApprovalResult result = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// ApprovalConfig describes configuration for manual approval of a build. +message ApprovalConfig { + // Whether or not approval is needed. If this is set on a build, it will + // become pending when created, and will need to be explicitly approved + // to start. + bool approval_required = 1; +} + +// ApprovalResult describes the decision and associated metadata of a manual +// approval of a build. +message ApprovalResult { + // Specifies whether or not this manual approval result is to approve + // or reject a build. + enum Decision { + // Default enum type. This should not be used. + DECISION_UNSPECIFIED = 0; + + // Build is approved. + APPROVED = 1; + + // Build is rejected. + REJECTED = 2; + } + + // Output only. Email of the user that called the ApproveBuild API to + // approve or reject a build at the time that the API was called. + string approver_account = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time when the approval decision was made. + google.protobuf.Timestamp approval_time = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. The decision of this manual approval. + Decision decision = 4 [(google.api.field_behavior) = REQUIRED]; + + // Optional. An optional comment for this manual approval result. + string comment = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. An optional URL tied to this manual approval result. This field + // is essentially the same as comment, except that it will be rendered by the + // UI differently. An example use case is a link to an external job that + // approved this Build. + string url = 6 [(google.api.field_behavior) = OPTIONAL]; +} + // Configuration for an automated build in response to source repository // changes. message BuildTrigger { diff --git a/protos/protos.d.ts b/protos/protos.d.ts index daf9b42..fd33ae2 100644 --- a/protos/protos.d.ts +++ b/protos/protos.d.ts @@ -116,6 +116,20 @@ export namespace google { */ public retryBuild(request: google.devtools.cloudbuild.v1.IRetryBuildRequest): Promise; + /** + * Calls ApproveBuild. + * @param request ApproveBuildRequest message or plain object + * @param callback Node-style callback called with the error, if any, and Operation + */ + public approveBuild(request: google.devtools.cloudbuild.v1.IApproveBuildRequest, callback: google.devtools.cloudbuild.v1.CloudBuild.ApproveBuildCallback): void; + + /** + * Calls ApproveBuild. + * @param request ApproveBuildRequest message or plain object + * @returns Promise + */ + public approveBuild(request: google.devtools.cloudbuild.v1.IApproveBuildRequest): Promise; + /** * Calls CreateBuildTrigger. * @param request CreateBuildTriggerRequest message or plain object @@ -322,6 +336,13 @@ export namespace google { */ type RetryBuildCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + /** + * Callback as used by {@link google.devtools.cloudbuild.v1.CloudBuild#approveBuild}. + * @param error Error, if any + * @param [response] Operation + */ + type ApproveBuildCallback = (error: (Error|null), response?: google.longrunning.Operation) => void; + /** * Callback as used by {@link google.devtools.cloudbuild.v1.CloudBuild#createBuildTrigger}. * @param error Error, if any @@ -1712,6 +1733,9 @@ export namespace google { /** Build timing */ timing?: ({ [k: string]: google.devtools.cloudbuild.v1.ITimeSpan }|null); + /** Build approval */ + approval?: (google.devtools.cloudbuild.v1.IBuildApproval|null); + /** Build serviceAccount */ serviceAccount?: (string|null); @@ -1806,6 +1830,9 @@ export namespace google { /** Build timing. */ public timing: { [k: string]: google.devtools.cloudbuild.v1.ITimeSpan }; + /** Build approval. */ + public approval?: (google.devtools.cloudbuild.v1.IBuildApproval|null); + /** Build serviceAccount. */ public serviceAccount: string; @@ -2111,6 +2138,7 @@ export namespace google { /** Status enum. */ enum Status { STATUS_UNKNOWN = 0, + PENDING = 10, QUEUED = 1, WORKING = 2, SUCCESS = 3, @@ -3713,6 +3741,430 @@ export namespace google { public toJSON(): { [k: string]: any }; } + /** Properties of an ApproveBuildRequest. */ + interface IApproveBuildRequest { + + /** ApproveBuildRequest name */ + name?: (string|null); + + /** ApproveBuildRequest approvalResult */ + approvalResult?: (google.devtools.cloudbuild.v1.IApprovalResult|null); + } + + /** Represents an ApproveBuildRequest. */ + class ApproveBuildRequest implements IApproveBuildRequest { + + /** + * Constructs a new ApproveBuildRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.devtools.cloudbuild.v1.IApproveBuildRequest); + + /** ApproveBuildRequest name. */ + public name: string; + + /** ApproveBuildRequest approvalResult. */ + public approvalResult?: (google.devtools.cloudbuild.v1.IApprovalResult|null); + + /** + * Creates a new ApproveBuildRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns ApproveBuildRequest instance + */ + public static create(properties?: google.devtools.cloudbuild.v1.IApproveBuildRequest): google.devtools.cloudbuild.v1.ApproveBuildRequest; + + /** + * Encodes the specified ApproveBuildRequest message. Does not implicitly {@link google.devtools.cloudbuild.v1.ApproveBuildRequest.verify|verify} messages. + * @param message ApproveBuildRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.devtools.cloudbuild.v1.IApproveBuildRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ApproveBuildRequest message, length delimited. Does not implicitly {@link google.devtools.cloudbuild.v1.ApproveBuildRequest.verify|verify} messages. + * @param message ApproveBuildRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.devtools.cloudbuild.v1.IApproveBuildRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ApproveBuildRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ApproveBuildRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.devtools.cloudbuild.v1.ApproveBuildRequest; + + /** + * Decodes an ApproveBuildRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ApproveBuildRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.devtools.cloudbuild.v1.ApproveBuildRequest; + + /** + * Verifies an ApproveBuildRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ApproveBuildRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ApproveBuildRequest + */ + public static fromObject(object: { [k: string]: any }): google.devtools.cloudbuild.v1.ApproveBuildRequest; + + /** + * Creates a plain object from an ApproveBuildRequest message. Also converts values to other types if specified. + * @param message ApproveBuildRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.devtools.cloudbuild.v1.ApproveBuildRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ApproveBuildRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of a BuildApproval. */ + interface IBuildApproval { + + /** BuildApproval state */ + state?: (google.devtools.cloudbuild.v1.BuildApproval.State|keyof typeof google.devtools.cloudbuild.v1.BuildApproval.State|null); + + /** BuildApproval config */ + config?: (google.devtools.cloudbuild.v1.IApprovalConfig|null); + + /** BuildApproval result */ + result?: (google.devtools.cloudbuild.v1.IApprovalResult|null); + } + + /** Represents a BuildApproval. */ + class BuildApproval implements IBuildApproval { + + /** + * Constructs a new BuildApproval. + * @param [properties] Properties to set + */ + constructor(properties?: google.devtools.cloudbuild.v1.IBuildApproval); + + /** BuildApproval state. */ + public state: (google.devtools.cloudbuild.v1.BuildApproval.State|keyof typeof google.devtools.cloudbuild.v1.BuildApproval.State); + + /** BuildApproval config. */ + public config?: (google.devtools.cloudbuild.v1.IApprovalConfig|null); + + /** BuildApproval result. */ + public result?: (google.devtools.cloudbuild.v1.IApprovalResult|null); + + /** + * Creates a new BuildApproval instance using the specified properties. + * @param [properties] Properties to set + * @returns BuildApproval instance + */ + public static create(properties?: google.devtools.cloudbuild.v1.IBuildApproval): google.devtools.cloudbuild.v1.BuildApproval; + + /** + * Encodes the specified BuildApproval message. Does not implicitly {@link google.devtools.cloudbuild.v1.BuildApproval.verify|verify} messages. + * @param message BuildApproval message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.devtools.cloudbuild.v1.IBuildApproval, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified BuildApproval message, length delimited. Does not implicitly {@link google.devtools.cloudbuild.v1.BuildApproval.verify|verify} messages. + * @param message BuildApproval message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.devtools.cloudbuild.v1.IBuildApproval, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a BuildApproval message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns BuildApproval + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.devtools.cloudbuild.v1.BuildApproval; + + /** + * Decodes a BuildApproval message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns BuildApproval + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.devtools.cloudbuild.v1.BuildApproval; + + /** + * Verifies a BuildApproval message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a BuildApproval message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns BuildApproval + */ + public static fromObject(object: { [k: string]: any }): google.devtools.cloudbuild.v1.BuildApproval; + + /** + * Creates a plain object from a BuildApproval message. Also converts values to other types if specified. + * @param message BuildApproval + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.devtools.cloudbuild.v1.BuildApproval, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this BuildApproval to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace BuildApproval { + + /** State enum. */ + enum State { + STATE_UNSPECIFIED = 0, + PENDING = 1, + APPROVED = 2, + REJECTED = 3, + CANCELLED = 5 + } + } + + /** Properties of an ApprovalConfig. */ + interface IApprovalConfig { + + /** ApprovalConfig approvalRequired */ + approvalRequired?: (boolean|null); + } + + /** Represents an ApprovalConfig. */ + class ApprovalConfig implements IApprovalConfig { + + /** + * Constructs a new ApprovalConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.devtools.cloudbuild.v1.IApprovalConfig); + + /** ApprovalConfig approvalRequired. */ + public approvalRequired: boolean; + + /** + * Creates a new ApprovalConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns ApprovalConfig instance + */ + public static create(properties?: google.devtools.cloudbuild.v1.IApprovalConfig): google.devtools.cloudbuild.v1.ApprovalConfig; + + /** + * Encodes the specified ApprovalConfig message. Does not implicitly {@link google.devtools.cloudbuild.v1.ApprovalConfig.verify|verify} messages. + * @param message ApprovalConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.devtools.cloudbuild.v1.IApprovalConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ApprovalConfig message, length delimited. Does not implicitly {@link google.devtools.cloudbuild.v1.ApprovalConfig.verify|verify} messages. + * @param message ApprovalConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.devtools.cloudbuild.v1.IApprovalConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ApprovalConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ApprovalConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.devtools.cloudbuild.v1.ApprovalConfig; + + /** + * Decodes an ApprovalConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ApprovalConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.devtools.cloudbuild.v1.ApprovalConfig; + + /** + * Verifies an ApprovalConfig message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ApprovalConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ApprovalConfig + */ + public static fromObject(object: { [k: string]: any }): google.devtools.cloudbuild.v1.ApprovalConfig; + + /** + * Creates a plain object from an ApprovalConfig message. Also converts values to other types if specified. + * @param message ApprovalConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.devtools.cloudbuild.v1.ApprovalConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ApprovalConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + /** Properties of an ApprovalResult. */ + interface IApprovalResult { + + /** ApprovalResult approverAccount */ + approverAccount?: (string|null); + + /** ApprovalResult approvalTime */ + approvalTime?: (google.protobuf.ITimestamp|null); + + /** ApprovalResult decision */ + decision?: (google.devtools.cloudbuild.v1.ApprovalResult.Decision|keyof typeof google.devtools.cloudbuild.v1.ApprovalResult.Decision|null); + + /** ApprovalResult comment */ + comment?: (string|null); + + /** ApprovalResult url */ + url?: (string|null); + } + + /** Represents an ApprovalResult. */ + class ApprovalResult implements IApprovalResult { + + /** + * Constructs a new ApprovalResult. + * @param [properties] Properties to set + */ + constructor(properties?: google.devtools.cloudbuild.v1.IApprovalResult); + + /** ApprovalResult approverAccount. */ + public approverAccount: string; + + /** ApprovalResult approvalTime. */ + public approvalTime?: (google.protobuf.ITimestamp|null); + + /** ApprovalResult decision. */ + public decision: (google.devtools.cloudbuild.v1.ApprovalResult.Decision|keyof typeof google.devtools.cloudbuild.v1.ApprovalResult.Decision); + + /** ApprovalResult comment. */ + public comment: string; + + /** ApprovalResult url. */ + public url: string; + + /** + * Creates a new ApprovalResult instance using the specified properties. + * @param [properties] Properties to set + * @returns ApprovalResult instance + */ + public static create(properties?: google.devtools.cloudbuild.v1.IApprovalResult): google.devtools.cloudbuild.v1.ApprovalResult; + + /** + * Encodes the specified ApprovalResult message. Does not implicitly {@link google.devtools.cloudbuild.v1.ApprovalResult.verify|verify} messages. + * @param message ApprovalResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.devtools.cloudbuild.v1.IApprovalResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ApprovalResult message, length delimited. Does not implicitly {@link google.devtools.cloudbuild.v1.ApprovalResult.verify|verify} messages. + * @param message ApprovalResult message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.devtools.cloudbuild.v1.IApprovalResult, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an ApprovalResult message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ApprovalResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.devtools.cloudbuild.v1.ApprovalResult; + + /** + * Decodes an ApprovalResult message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ApprovalResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.devtools.cloudbuild.v1.ApprovalResult; + + /** + * Verifies an ApprovalResult message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an ApprovalResult message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ApprovalResult + */ + public static fromObject(object: { [k: string]: any }): google.devtools.cloudbuild.v1.ApprovalResult; + + /** + * Creates a plain object from an ApprovalResult message. Also converts values to other types if specified. + * @param message ApprovalResult + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.devtools.cloudbuild.v1.ApprovalResult, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ApprovalResult to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace ApprovalResult { + + /** Decision enum. */ + enum Decision { + DECISION_UNSPECIFIED = 0, + APPROVED = 1, + REJECTED = 2 + } + } + /** Properties of a BuildTrigger. */ interface IBuildTrigger { diff --git a/protos/protos.js b/protos/protos.js index 5d25703..9435efc 100644 --- a/protos/protos.js +++ b/protos/protos.js @@ -263,6 +263,39 @@ * @variation 2 */ + /** + * Callback as used by {@link google.devtools.cloudbuild.v1.CloudBuild#approveBuild}. + * @memberof google.devtools.cloudbuild.v1.CloudBuild + * @typedef ApproveBuildCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.longrunning.Operation} [response] Operation + */ + + /** + * Calls ApproveBuild. + * @function approveBuild + * @memberof google.devtools.cloudbuild.v1.CloudBuild + * @instance + * @param {google.devtools.cloudbuild.v1.IApproveBuildRequest} request ApproveBuildRequest message or plain object + * @param {google.devtools.cloudbuild.v1.CloudBuild.ApproveBuildCallback} callback Node-style callback called with the error, if any, and Operation + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(CloudBuild.prototype.approveBuild = function approveBuild(request, callback) { + return this.rpcCall(approveBuild, $root.google.devtools.cloudbuild.v1.ApproveBuildRequest, $root.google.longrunning.Operation, request, callback); + }, "name", { value: "ApproveBuild" }); + + /** + * Calls ApproveBuild. + * @function approveBuild + * @memberof google.devtools.cloudbuild.v1.CloudBuild + * @instance + * @param {google.devtools.cloudbuild.v1.IApproveBuildRequest} request ApproveBuildRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + /** * Callback as used by {@link google.devtools.cloudbuild.v1.CloudBuild#createBuildTrigger}. * @memberof google.devtools.cloudbuild.v1.CloudBuild @@ -2957,6 +2990,7 @@ default: return "status: enum value expected"; case 0: + case 10: case 1: case 2: case 3: @@ -3048,6 +3082,10 @@ case 0: message.status = 0; break; + case "PENDING": + case 10: + message.status = 10; + break; case "QUEUED": case 1: message.status = 1; @@ -4018,6 +4056,7 @@ * @property {Array.|null} [tags] Build tags * @property {Array.|null} [secrets] Build secrets * @property {Object.|null} [timing] Build timing + * @property {google.devtools.cloudbuild.v1.IBuildApproval|null} [approval] Build approval * @property {string|null} [serviceAccount] Build serviceAccount * @property {google.devtools.cloudbuild.v1.ISecrets|null} [availableSecrets] Build availableSecrets * @property {Array.|null} [warnings] Build warnings @@ -4238,6 +4277,14 @@ */ Build.prototype.timing = $util.emptyObject; + /** + * Build approval. + * @member {google.devtools.cloudbuild.v1.IBuildApproval|null|undefined} approval + * @memberof google.devtools.cloudbuild.v1.Build + * @instance + */ + Build.prototype.approval = null; + /** * Build serviceAccount. * @member {string} serviceAccount @@ -4350,6 +4397,8 @@ $root.google.protobuf.Duration.encode(message.queueTtl, writer.uint32(/* id 40, wireType 2 =*/322).fork()).ldelim(); if (message.serviceAccount != null && Object.hasOwnProperty.call(message, "serviceAccount")) writer.uint32(/* id 42, wireType 2 =*/338).string(message.serviceAccount); + if (message.approval != null && Object.hasOwnProperty.call(message, "approval")) + $root.google.devtools.cloudbuild.v1.BuildApproval.encode(message.approval, writer.uint32(/* id 44, wireType 2 =*/354).fork()).ldelim(); if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 45, wireType 2 =*/362).string(message.name); if (message.availableSecrets != null && Object.hasOwnProperty.call(message, "availableSecrets")) @@ -4511,6 +4560,9 @@ } message.timing[key] = value; break; + case 44: + message.approval = $root.google.devtools.cloudbuild.v1.BuildApproval.decode(reader, reader.uint32()); + break; case 42: message.serviceAccount = reader.string(); break; @@ -4574,6 +4626,7 @@ default: return "status: enum value expected"; case 0: + case 10: case 1: case 2: case 3: @@ -4696,6 +4749,11 @@ return "timing." + error; } } + if (message.approval != null && message.hasOwnProperty("approval")) { + var error = $root.google.devtools.cloudbuild.v1.BuildApproval.verify(message.approval); + if (error) + return "approval." + error; + } if (message.serviceAccount != null && message.hasOwnProperty("serviceAccount")) if (!$util.isString(message.serviceAccount)) return "serviceAccount: string expected"; @@ -4744,6 +4802,10 @@ case 0: message.status = 0; break; + case "PENDING": + case 10: + message.status = 10; + break; case "QUEUED": case 1: message.status = 1; @@ -4886,6 +4948,11 @@ message.timing[keys[i]] = $root.google.devtools.cloudbuild.v1.TimeSpan.fromObject(object.timing[keys[i]]); } } + if (object.approval != null) { + if (typeof object.approval !== "object") + throw TypeError(".google.devtools.cloudbuild.v1.Build.approval: object expected"); + message.approval = $root.google.devtools.cloudbuild.v1.BuildApproval.fromObject(object.approval); + } if (object.serviceAccount != null) message.serviceAccount = String(object.serviceAccount); if (object.availableSecrets != null) { @@ -4954,6 +5021,7 @@ object.artifacts = null; object.queueTtl = null; object.serviceAccount = ""; + object.approval = null; object.name = ""; object.availableSecrets = null; object.failureInfo = null; @@ -5025,6 +5093,8 @@ object.queueTtl = $root.google.protobuf.Duration.toObject(message.queueTtl, options); if (message.serviceAccount != null && message.hasOwnProperty("serviceAccount")) object.serviceAccount = message.serviceAccount; + if (message.approval != null && message.hasOwnProperty("approval")) + object.approval = $root.google.devtools.cloudbuild.v1.BuildApproval.toObject(message.approval, options); if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; if (message.availableSecrets != null && message.hasOwnProperty("availableSecrets")) @@ -5578,6 +5648,7 @@ * @name google.devtools.cloudbuild.v1.Build.Status * @enum {number} * @property {number} STATUS_UNKNOWN=0 STATUS_UNKNOWN value + * @property {number} PENDING=10 PENDING value * @property {number} QUEUED=1 QUEUED value * @property {number} WORKING=2 WORKING value * @property {number} SUCCESS=3 SUCCESS value @@ -5590,6 +5661,7 @@ Build.Status = (function() { var valuesById = {}, values = Object.create(valuesById); values[valuesById[0] = "STATUS_UNKNOWN"] = 0; + values[valuesById[10] = "PENDING"] = 10; values[valuesById[1] = "QUEUED"] = 1; values[valuesById[2] = "WORKING"] = 2; values[valuesById[3] = "SUCCESS"] = 3; @@ -9440,6 +9512,1013 @@ return CancelBuildRequest; })(); + v1.ApproveBuildRequest = (function() { + + /** + * Properties of an ApproveBuildRequest. + * @memberof google.devtools.cloudbuild.v1 + * @interface IApproveBuildRequest + * @property {string|null} [name] ApproveBuildRequest name + * @property {google.devtools.cloudbuild.v1.IApprovalResult|null} [approvalResult] ApproveBuildRequest approvalResult + */ + + /** + * Constructs a new ApproveBuildRequest. + * @memberof google.devtools.cloudbuild.v1 + * @classdesc Represents an ApproveBuildRequest. + * @implements IApproveBuildRequest + * @constructor + * @param {google.devtools.cloudbuild.v1.IApproveBuildRequest=} [properties] Properties to set + */ + function ApproveBuildRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ApproveBuildRequest name. + * @member {string} name + * @memberof google.devtools.cloudbuild.v1.ApproveBuildRequest + * @instance + */ + ApproveBuildRequest.prototype.name = ""; + + /** + * ApproveBuildRequest approvalResult. + * @member {google.devtools.cloudbuild.v1.IApprovalResult|null|undefined} approvalResult + * @memberof google.devtools.cloudbuild.v1.ApproveBuildRequest + * @instance + */ + ApproveBuildRequest.prototype.approvalResult = null; + + /** + * Creates a new ApproveBuildRequest instance using the specified properties. + * @function create + * @memberof google.devtools.cloudbuild.v1.ApproveBuildRequest + * @static + * @param {google.devtools.cloudbuild.v1.IApproveBuildRequest=} [properties] Properties to set + * @returns {google.devtools.cloudbuild.v1.ApproveBuildRequest} ApproveBuildRequest instance + */ + ApproveBuildRequest.create = function create(properties) { + return new ApproveBuildRequest(properties); + }; + + /** + * Encodes the specified ApproveBuildRequest message. Does not implicitly {@link google.devtools.cloudbuild.v1.ApproveBuildRequest.verify|verify} messages. + * @function encode + * @memberof google.devtools.cloudbuild.v1.ApproveBuildRequest + * @static + * @param {google.devtools.cloudbuild.v1.IApproveBuildRequest} message ApproveBuildRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ApproveBuildRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.name != null && Object.hasOwnProperty.call(message, "name")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.name); + if (message.approvalResult != null && Object.hasOwnProperty.call(message, "approvalResult")) + $root.google.devtools.cloudbuild.v1.ApprovalResult.encode(message.approvalResult, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ApproveBuildRequest message, length delimited. Does not implicitly {@link google.devtools.cloudbuild.v1.ApproveBuildRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.devtools.cloudbuild.v1.ApproveBuildRequest + * @static + * @param {google.devtools.cloudbuild.v1.IApproveBuildRequest} message ApproveBuildRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ApproveBuildRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ApproveBuildRequest message from the specified reader or buffer. + * @function decode + * @memberof google.devtools.cloudbuild.v1.ApproveBuildRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.devtools.cloudbuild.v1.ApproveBuildRequest} ApproveBuildRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ApproveBuildRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.devtools.cloudbuild.v1.ApproveBuildRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.approvalResult = $root.google.devtools.cloudbuild.v1.ApprovalResult.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ApproveBuildRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.devtools.cloudbuild.v1.ApproveBuildRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.devtools.cloudbuild.v1.ApproveBuildRequest} ApproveBuildRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ApproveBuildRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ApproveBuildRequest message. + * @function verify + * @memberof google.devtools.cloudbuild.v1.ApproveBuildRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ApproveBuildRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.name != null && message.hasOwnProperty("name")) + if (!$util.isString(message.name)) + return "name: string expected"; + if (message.approvalResult != null && message.hasOwnProperty("approvalResult")) { + var error = $root.google.devtools.cloudbuild.v1.ApprovalResult.verify(message.approvalResult); + if (error) + return "approvalResult." + error; + } + return null; + }; + + /** + * Creates an ApproveBuildRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.devtools.cloudbuild.v1.ApproveBuildRequest + * @static + * @param {Object.} object Plain object + * @returns {google.devtools.cloudbuild.v1.ApproveBuildRequest} ApproveBuildRequest + */ + ApproveBuildRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.devtools.cloudbuild.v1.ApproveBuildRequest) + return object; + var message = new $root.google.devtools.cloudbuild.v1.ApproveBuildRequest(); + if (object.name != null) + message.name = String(object.name); + if (object.approvalResult != null) { + if (typeof object.approvalResult !== "object") + throw TypeError(".google.devtools.cloudbuild.v1.ApproveBuildRequest.approvalResult: object expected"); + message.approvalResult = $root.google.devtools.cloudbuild.v1.ApprovalResult.fromObject(object.approvalResult); + } + return message; + }; + + /** + * Creates a plain object from an ApproveBuildRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.devtools.cloudbuild.v1.ApproveBuildRequest + * @static + * @param {google.devtools.cloudbuild.v1.ApproveBuildRequest} message ApproveBuildRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ApproveBuildRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.name = ""; + object.approvalResult = null; + } + if (message.name != null && message.hasOwnProperty("name")) + object.name = message.name; + if (message.approvalResult != null && message.hasOwnProperty("approvalResult")) + object.approvalResult = $root.google.devtools.cloudbuild.v1.ApprovalResult.toObject(message.approvalResult, options); + return object; + }; + + /** + * Converts this ApproveBuildRequest to JSON. + * @function toJSON + * @memberof google.devtools.cloudbuild.v1.ApproveBuildRequest + * @instance + * @returns {Object.} JSON object + */ + ApproveBuildRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ApproveBuildRequest; + })(); + + v1.BuildApproval = (function() { + + /** + * Properties of a BuildApproval. + * @memberof google.devtools.cloudbuild.v1 + * @interface IBuildApproval + * @property {google.devtools.cloudbuild.v1.BuildApproval.State|null} [state] BuildApproval state + * @property {google.devtools.cloudbuild.v1.IApprovalConfig|null} [config] BuildApproval config + * @property {google.devtools.cloudbuild.v1.IApprovalResult|null} [result] BuildApproval result + */ + + /** + * Constructs a new BuildApproval. + * @memberof google.devtools.cloudbuild.v1 + * @classdesc Represents a BuildApproval. + * @implements IBuildApproval + * @constructor + * @param {google.devtools.cloudbuild.v1.IBuildApproval=} [properties] Properties to set + */ + function BuildApproval(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * BuildApproval state. + * @member {google.devtools.cloudbuild.v1.BuildApproval.State} state + * @memberof google.devtools.cloudbuild.v1.BuildApproval + * @instance + */ + BuildApproval.prototype.state = 0; + + /** + * BuildApproval config. + * @member {google.devtools.cloudbuild.v1.IApprovalConfig|null|undefined} config + * @memberof google.devtools.cloudbuild.v1.BuildApproval + * @instance + */ + BuildApproval.prototype.config = null; + + /** + * BuildApproval result. + * @member {google.devtools.cloudbuild.v1.IApprovalResult|null|undefined} result + * @memberof google.devtools.cloudbuild.v1.BuildApproval + * @instance + */ + BuildApproval.prototype.result = null; + + /** + * Creates a new BuildApproval instance using the specified properties. + * @function create + * @memberof google.devtools.cloudbuild.v1.BuildApproval + * @static + * @param {google.devtools.cloudbuild.v1.IBuildApproval=} [properties] Properties to set + * @returns {google.devtools.cloudbuild.v1.BuildApproval} BuildApproval instance + */ + BuildApproval.create = function create(properties) { + return new BuildApproval(properties); + }; + + /** + * Encodes the specified BuildApproval message. Does not implicitly {@link google.devtools.cloudbuild.v1.BuildApproval.verify|verify} messages. + * @function encode + * @memberof google.devtools.cloudbuild.v1.BuildApproval + * @static + * @param {google.devtools.cloudbuild.v1.IBuildApproval} message BuildApproval message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BuildApproval.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.state != null && Object.hasOwnProperty.call(message, "state")) + writer.uint32(/* id 1, wireType 0 =*/8).int32(message.state); + if (message.config != null && Object.hasOwnProperty.call(message, "config")) + $root.google.devtools.cloudbuild.v1.ApprovalConfig.encode(message.config, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + if (message.result != null && Object.hasOwnProperty.call(message, "result")) + $root.google.devtools.cloudbuild.v1.ApprovalResult.encode(message.result, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified BuildApproval message, length delimited. Does not implicitly {@link google.devtools.cloudbuild.v1.BuildApproval.verify|verify} messages. + * @function encodeDelimited + * @memberof google.devtools.cloudbuild.v1.BuildApproval + * @static + * @param {google.devtools.cloudbuild.v1.IBuildApproval} message BuildApproval message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + BuildApproval.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a BuildApproval message from the specified reader or buffer. + * @function decode + * @memberof google.devtools.cloudbuild.v1.BuildApproval + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.devtools.cloudbuild.v1.BuildApproval} BuildApproval + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BuildApproval.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.devtools.cloudbuild.v1.BuildApproval(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.state = reader.int32(); + break; + case 2: + message.config = $root.google.devtools.cloudbuild.v1.ApprovalConfig.decode(reader, reader.uint32()); + break; + case 3: + message.result = $root.google.devtools.cloudbuild.v1.ApprovalResult.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a BuildApproval message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.devtools.cloudbuild.v1.BuildApproval + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.devtools.cloudbuild.v1.BuildApproval} BuildApproval + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + BuildApproval.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a BuildApproval message. + * @function verify + * @memberof google.devtools.cloudbuild.v1.BuildApproval + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + BuildApproval.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.state != null && message.hasOwnProperty("state")) + switch (message.state) { + default: + return "state: enum value expected"; + case 0: + case 1: + case 2: + case 3: + case 5: + break; + } + if (message.config != null && message.hasOwnProperty("config")) { + var error = $root.google.devtools.cloudbuild.v1.ApprovalConfig.verify(message.config); + if (error) + return "config." + error; + } + if (message.result != null && message.hasOwnProperty("result")) { + var error = $root.google.devtools.cloudbuild.v1.ApprovalResult.verify(message.result); + if (error) + return "result." + error; + } + return null; + }; + + /** + * Creates a BuildApproval message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.devtools.cloudbuild.v1.BuildApproval + * @static + * @param {Object.} object Plain object + * @returns {google.devtools.cloudbuild.v1.BuildApproval} BuildApproval + */ + BuildApproval.fromObject = function fromObject(object) { + if (object instanceof $root.google.devtools.cloudbuild.v1.BuildApproval) + return object; + var message = new $root.google.devtools.cloudbuild.v1.BuildApproval(); + switch (object.state) { + case "STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "PENDING": + case 1: + message.state = 1; + break; + case "APPROVED": + case 2: + message.state = 2; + break; + case "REJECTED": + case 3: + message.state = 3; + break; + case "CANCELLED": + case 5: + message.state = 5; + break; + } + if (object.config != null) { + if (typeof object.config !== "object") + throw TypeError(".google.devtools.cloudbuild.v1.BuildApproval.config: object expected"); + message.config = $root.google.devtools.cloudbuild.v1.ApprovalConfig.fromObject(object.config); + } + if (object.result != null) { + if (typeof object.result !== "object") + throw TypeError(".google.devtools.cloudbuild.v1.BuildApproval.result: object expected"); + message.result = $root.google.devtools.cloudbuild.v1.ApprovalResult.fromObject(object.result); + } + return message; + }; + + /** + * Creates a plain object from a BuildApproval message. Also converts values to other types if specified. + * @function toObject + * @memberof google.devtools.cloudbuild.v1.BuildApproval + * @static + * @param {google.devtools.cloudbuild.v1.BuildApproval} message BuildApproval + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + BuildApproval.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; + object.config = null; + object.result = null; + } + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.devtools.cloudbuild.v1.BuildApproval.State[message.state] : message.state; + if (message.config != null && message.hasOwnProperty("config")) + object.config = $root.google.devtools.cloudbuild.v1.ApprovalConfig.toObject(message.config, options); + if (message.result != null && message.hasOwnProperty("result")) + object.result = $root.google.devtools.cloudbuild.v1.ApprovalResult.toObject(message.result, options); + return object; + }; + + /** + * Converts this BuildApproval to JSON. + * @function toJSON + * @memberof google.devtools.cloudbuild.v1.BuildApproval + * @instance + * @returns {Object.} JSON object + */ + BuildApproval.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * State enum. + * @name google.devtools.cloudbuild.v1.BuildApproval.State + * @enum {number} + * @property {number} STATE_UNSPECIFIED=0 STATE_UNSPECIFIED value + * @property {number} PENDING=1 PENDING value + * @property {number} APPROVED=2 APPROVED value + * @property {number} REJECTED=3 REJECTED value + * @property {number} CANCELLED=5 CANCELLED value + */ + BuildApproval.State = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "PENDING"] = 1; + values[valuesById[2] = "APPROVED"] = 2; + values[valuesById[3] = "REJECTED"] = 3; + values[valuesById[5] = "CANCELLED"] = 5; + return values; + })(); + + return BuildApproval; + })(); + + v1.ApprovalConfig = (function() { + + /** + * Properties of an ApprovalConfig. + * @memberof google.devtools.cloudbuild.v1 + * @interface IApprovalConfig + * @property {boolean|null} [approvalRequired] ApprovalConfig approvalRequired + */ + + /** + * Constructs a new ApprovalConfig. + * @memberof google.devtools.cloudbuild.v1 + * @classdesc Represents an ApprovalConfig. + * @implements IApprovalConfig + * @constructor + * @param {google.devtools.cloudbuild.v1.IApprovalConfig=} [properties] Properties to set + */ + function ApprovalConfig(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ApprovalConfig approvalRequired. + * @member {boolean} approvalRequired + * @memberof google.devtools.cloudbuild.v1.ApprovalConfig + * @instance + */ + ApprovalConfig.prototype.approvalRequired = false; + + /** + * Creates a new ApprovalConfig instance using the specified properties. + * @function create + * @memberof google.devtools.cloudbuild.v1.ApprovalConfig + * @static + * @param {google.devtools.cloudbuild.v1.IApprovalConfig=} [properties] Properties to set + * @returns {google.devtools.cloudbuild.v1.ApprovalConfig} ApprovalConfig instance + */ + ApprovalConfig.create = function create(properties) { + return new ApprovalConfig(properties); + }; + + /** + * Encodes the specified ApprovalConfig message. Does not implicitly {@link google.devtools.cloudbuild.v1.ApprovalConfig.verify|verify} messages. + * @function encode + * @memberof google.devtools.cloudbuild.v1.ApprovalConfig + * @static + * @param {google.devtools.cloudbuild.v1.IApprovalConfig} message ApprovalConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ApprovalConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.approvalRequired != null && Object.hasOwnProperty.call(message, "approvalRequired")) + writer.uint32(/* id 1, wireType 0 =*/8).bool(message.approvalRequired); + return writer; + }; + + /** + * Encodes the specified ApprovalConfig message, length delimited. Does not implicitly {@link google.devtools.cloudbuild.v1.ApprovalConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.devtools.cloudbuild.v1.ApprovalConfig + * @static + * @param {google.devtools.cloudbuild.v1.IApprovalConfig} message ApprovalConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ApprovalConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ApprovalConfig message from the specified reader or buffer. + * @function decode + * @memberof google.devtools.cloudbuild.v1.ApprovalConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.devtools.cloudbuild.v1.ApprovalConfig} ApprovalConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ApprovalConfig.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.devtools.cloudbuild.v1.ApprovalConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.approvalRequired = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ApprovalConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.devtools.cloudbuild.v1.ApprovalConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.devtools.cloudbuild.v1.ApprovalConfig} ApprovalConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ApprovalConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ApprovalConfig message. + * @function verify + * @memberof google.devtools.cloudbuild.v1.ApprovalConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ApprovalConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.approvalRequired != null && message.hasOwnProperty("approvalRequired")) + if (typeof message.approvalRequired !== "boolean") + return "approvalRequired: boolean expected"; + return null; + }; + + /** + * Creates an ApprovalConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.devtools.cloudbuild.v1.ApprovalConfig + * @static + * @param {Object.} object Plain object + * @returns {google.devtools.cloudbuild.v1.ApprovalConfig} ApprovalConfig + */ + ApprovalConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.devtools.cloudbuild.v1.ApprovalConfig) + return object; + var message = new $root.google.devtools.cloudbuild.v1.ApprovalConfig(); + if (object.approvalRequired != null) + message.approvalRequired = Boolean(object.approvalRequired); + return message; + }; + + /** + * Creates a plain object from an ApprovalConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.devtools.cloudbuild.v1.ApprovalConfig + * @static + * @param {google.devtools.cloudbuild.v1.ApprovalConfig} message ApprovalConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ApprovalConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.approvalRequired = false; + if (message.approvalRequired != null && message.hasOwnProperty("approvalRequired")) + object.approvalRequired = message.approvalRequired; + return object; + }; + + /** + * Converts this ApprovalConfig to JSON. + * @function toJSON + * @memberof google.devtools.cloudbuild.v1.ApprovalConfig + * @instance + * @returns {Object.} JSON object + */ + ApprovalConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + return ApprovalConfig; + })(); + + v1.ApprovalResult = (function() { + + /** + * Properties of an ApprovalResult. + * @memberof google.devtools.cloudbuild.v1 + * @interface IApprovalResult + * @property {string|null} [approverAccount] ApprovalResult approverAccount + * @property {google.protobuf.ITimestamp|null} [approvalTime] ApprovalResult approvalTime + * @property {google.devtools.cloudbuild.v1.ApprovalResult.Decision|null} [decision] ApprovalResult decision + * @property {string|null} [comment] ApprovalResult comment + * @property {string|null} [url] ApprovalResult url + */ + + /** + * Constructs a new ApprovalResult. + * @memberof google.devtools.cloudbuild.v1 + * @classdesc Represents an ApprovalResult. + * @implements IApprovalResult + * @constructor + * @param {google.devtools.cloudbuild.v1.IApprovalResult=} [properties] Properties to set + */ + function ApprovalResult(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ApprovalResult approverAccount. + * @member {string} approverAccount + * @memberof google.devtools.cloudbuild.v1.ApprovalResult + * @instance + */ + ApprovalResult.prototype.approverAccount = ""; + + /** + * ApprovalResult approvalTime. + * @member {google.protobuf.ITimestamp|null|undefined} approvalTime + * @memberof google.devtools.cloudbuild.v1.ApprovalResult + * @instance + */ + ApprovalResult.prototype.approvalTime = null; + + /** + * ApprovalResult decision. + * @member {google.devtools.cloudbuild.v1.ApprovalResult.Decision} decision + * @memberof google.devtools.cloudbuild.v1.ApprovalResult + * @instance + */ + ApprovalResult.prototype.decision = 0; + + /** + * ApprovalResult comment. + * @member {string} comment + * @memberof google.devtools.cloudbuild.v1.ApprovalResult + * @instance + */ + ApprovalResult.prototype.comment = ""; + + /** + * ApprovalResult url. + * @member {string} url + * @memberof google.devtools.cloudbuild.v1.ApprovalResult + * @instance + */ + ApprovalResult.prototype.url = ""; + + /** + * Creates a new ApprovalResult instance using the specified properties. + * @function create + * @memberof google.devtools.cloudbuild.v1.ApprovalResult + * @static + * @param {google.devtools.cloudbuild.v1.IApprovalResult=} [properties] Properties to set + * @returns {google.devtools.cloudbuild.v1.ApprovalResult} ApprovalResult instance + */ + ApprovalResult.create = function create(properties) { + return new ApprovalResult(properties); + }; + + /** + * Encodes the specified ApprovalResult message. Does not implicitly {@link google.devtools.cloudbuild.v1.ApprovalResult.verify|verify} messages. + * @function encode + * @memberof google.devtools.cloudbuild.v1.ApprovalResult + * @static + * @param {google.devtools.cloudbuild.v1.IApprovalResult} message ApprovalResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ApprovalResult.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.approverAccount != null && Object.hasOwnProperty.call(message, "approverAccount")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.approverAccount); + if (message.approvalTime != null && Object.hasOwnProperty.call(message, "approvalTime")) + $root.google.protobuf.Timestamp.encode(message.approvalTime, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.decision != null && Object.hasOwnProperty.call(message, "decision")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.decision); + if (message.comment != null && Object.hasOwnProperty.call(message, "comment")) + writer.uint32(/* id 5, wireType 2 =*/42).string(message.comment); + if (message.url != null && Object.hasOwnProperty.call(message, "url")) + writer.uint32(/* id 6, wireType 2 =*/50).string(message.url); + return writer; + }; + + /** + * Encodes the specified ApprovalResult message, length delimited. Does not implicitly {@link google.devtools.cloudbuild.v1.ApprovalResult.verify|verify} messages. + * @function encodeDelimited + * @memberof google.devtools.cloudbuild.v1.ApprovalResult + * @static + * @param {google.devtools.cloudbuild.v1.IApprovalResult} message ApprovalResult message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ApprovalResult.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an ApprovalResult message from the specified reader or buffer. + * @function decode + * @memberof google.devtools.cloudbuild.v1.ApprovalResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.devtools.cloudbuild.v1.ApprovalResult} ApprovalResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ApprovalResult.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.devtools.cloudbuild.v1.ApprovalResult(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.approverAccount = reader.string(); + break; + case 3: + message.approvalTime = $root.google.protobuf.Timestamp.decode(reader, reader.uint32()); + break; + case 4: + message.decision = reader.int32(); + break; + case 5: + message.comment = reader.string(); + break; + case 6: + message.url = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an ApprovalResult message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.devtools.cloudbuild.v1.ApprovalResult + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.devtools.cloudbuild.v1.ApprovalResult} ApprovalResult + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ApprovalResult.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an ApprovalResult message. + * @function verify + * @memberof google.devtools.cloudbuild.v1.ApprovalResult + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ApprovalResult.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.approverAccount != null && message.hasOwnProperty("approverAccount")) + if (!$util.isString(message.approverAccount)) + return "approverAccount: string expected"; + if (message.approvalTime != null && message.hasOwnProperty("approvalTime")) { + var error = $root.google.protobuf.Timestamp.verify(message.approvalTime); + if (error) + return "approvalTime." + error; + } + if (message.decision != null && message.hasOwnProperty("decision")) + switch (message.decision) { + default: + return "decision: enum value expected"; + case 0: + case 1: + case 2: + break; + } + if (message.comment != null && message.hasOwnProperty("comment")) + if (!$util.isString(message.comment)) + return "comment: string expected"; + if (message.url != null && message.hasOwnProperty("url")) + if (!$util.isString(message.url)) + return "url: string expected"; + return null; + }; + + /** + * Creates an ApprovalResult message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.devtools.cloudbuild.v1.ApprovalResult + * @static + * @param {Object.} object Plain object + * @returns {google.devtools.cloudbuild.v1.ApprovalResult} ApprovalResult + */ + ApprovalResult.fromObject = function fromObject(object) { + if (object instanceof $root.google.devtools.cloudbuild.v1.ApprovalResult) + return object; + var message = new $root.google.devtools.cloudbuild.v1.ApprovalResult(); + if (object.approverAccount != null) + message.approverAccount = String(object.approverAccount); + if (object.approvalTime != null) { + if (typeof object.approvalTime !== "object") + throw TypeError(".google.devtools.cloudbuild.v1.ApprovalResult.approvalTime: object expected"); + message.approvalTime = $root.google.protobuf.Timestamp.fromObject(object.approvalTime); + } + switch (object.decision) { + case "DECISION_UNSPECIFIED": + case 0: + message.decision = 0; + break; + case "APPROVED": + case 1: + message.decision = 1; + break; + case "REJECTED": + case 2: + message.decision = 2; + break; + } + if (object.comment != null) + message.comment = String(object.comment); + if (object.url != null) + message.url = String(object.url); + return message; + }; + + /** + * Creates a plain object from an ApprovalResult message. Also converts values to other types if specified. + * @function toObject + * @memberof google.devtools.cloudbuild.v1.ApprovalResult + * @static + * @param {google.devtools.cloudbuild.v1.ApprovalResult} message ApprovalResult + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ApprovalResult.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.approverAccount = ""; + object.approvalTime = null; + object.decision = options.enums === String ? "DECISION_UNSPECIFIED" : 0; + object.comment = ""; + object.url = ""; + } + if (message.approverAccount != null && message.hasOwnProperty("approverAccount")) + object.approverAccount = message.approverAccount; + if (message.approvalTime != null && message.hasOwnProperty("approvalTime")) + object.approvalTime = $root.google.protobuf.Timestamp.toObject(message.approvalTime, options); + if (message.decision != null && message.hasOwnProperty("decision")) + object.decision = options.enums === String ? $root.google.devtools.cloudbuild.v1.ApprovalResult.Decision[message.decision] : message.decision; + if (message.comment != null && message.hasOwnProperty("comment")) + object.comment = message.comment; + if (message.url != null && message.hasOwnProperty("url")) + object.url = message.url; + return object; + }; + + /** + * Converts this ApprovalResult to JSON. + * @function toJSON + * @memberof google.devtools.cloudbuild.v1.ApprovalResult + * @instance + * @returns {Object.} JSON object + */ + ApprovalResult.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Decision enum. + * @name google.devtools.cloudbuild.v1.ApprovalResult.Decision + * @enum {number} + * @property {number} DECISION_UNSPECIFIED=0 DECISION_UNSPECIFIED value + * @property {number} APPROVED=1 APPROVED value + * @property {number} REJECTED=2 REJECTED value + */ + ApprovalResult.Decision = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DECISION_UNSPECIFIED"] = 0; + values[valuesById[1] = "APPROVED"] = 1; + values[valuesById[2] = "REJECTED"] = 2; + return values; + })(); + + return ApprovalResult; + })(); + v1.BuildTrigger = (function() { /** diff --git a/protos/protos.json b/protos/protos.json index ffc8e0d..a2206d3 100644 --- a/protos/protos.json +++ b/protos/protos.json @@ -162,6 +162,40 @@ } ] }, + "ApproveBuild": { + "requestType": "ApproveBuildRequest", + "responseType": "google.longrunning.Operation", + "options": { + "(google.api.http).post": "/v1/{name=projects/*/builds/*}:approve", + "(google.api.http).body": "*", + "(google.api.http).additional_bindings.post": "/v1/{name=projects/*/locations/*/builds/*}:approve", + "(google.api.http).additional_bindings.body": "*", + "(google.api.method_signature)": "name,approval_result", + "(google.longrunning.operation_info).response_type": "Build", + "(google.longrunning.operation_info).metadata_type": "BuildOperationMetadata" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{name=projects/*/builds/*}:approve", + "body": "*", + "additional_bindings": { + "post": "/v1/{name=projects/*/locations/*/builds/*}:approve", + "body": "*" + } + } + }, + { + "(google.api.method_signature)": "name,approval_result" + }, + { + "(google.longrunning.operation_info)": { + "response_type": "Build", + "metadata_type": "BuildOperationMetadata" + } + } + ] + }, "CreateBuildTrigger": { "requestType": "CreateBuildTriggerRequest", "responseType": "BuildTrigger", @@ -905,6 +939,13 @@ "(google.api.field_behavior)": "OUTPUT_ONLY" } }, + "approval": { + "type": "BuildApproval", + "id": 44, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, "serviceAccount": { "type": "string", "id": 42, @@ -983,6 +1024,7 @@ "Status": { "values": { "STATUS_UNKNOWN": 0, + "PENDING": 10, "QUEUED": 1, "WORKING": 2, "SUCCESS": 3, @@ -1280,6 +1322,113 @@ } } }, + "ApproveBuildRequest": { + "fields": { + "name": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "approvalResult": { + "type": "ApprovalResult", + "id": 2 + } + } + }, + "BuildApproval": { + "fields": { + "state": { + "type": "State", + "id": 1, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "config": { + "type": "ApprovalConfig", + "id": 2, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "result": { + "type": "ApprovalResult", + "id": 3, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + } + }, + "nested": { + "State": { + "values": { + "STATE_UNSPECIFIED": 0, + "PENDING": 1, + "APPROVED": 2, + "REJECTED": 3, + "CANCELLED": 5 + } + } + } + }, + "ApprovalConfig": { + "fields": { + "approvalRequired": { + "type": "bool", + "id": 1 + } + } + }, + "ApprovalResult": { + "fields": { + "approverAccount": { + "type": "string", + "id": 2, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "approvalTime": { + "type": "google.protobuf.Timestamp", + "id": 3, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "decision": { + "type": "Decision", + "id": 4, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + }, + "comment": { + "type": "string", + "id": 5, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, + "url": { + "type": "string", + "id": 6, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + } + }, + "nested": { + "Decision": { + "values": { + "DECISION_UNSPECIFIED": 0, + "APPROVED": 1, + "REJECTED": 2 + } + } + } + }, "BuildTrigger": { "options": { "(google.api.resource).type": "cloudbuild.googleapis.com/BuildTrigger", diff --git a/src/v1/cloud_build_client.ts b/src/v1/cloud_build_client.ts index 099fc45..bc435fd 100644 --- a/src/v1/cloud_build_client.ts +++ b/src/v1/cloud_build_client.ts @@ -250,6 +250,12 @@ export class CloudBuildClient { const retryBuildMetadata = protoFilesRoot.lookup( '.google.devtools.cloudbuild.v1.BuildOperationMetadata' ) as gax.protobuf.Type; + const approveBuildResponse = protoFilesRoot.lookup( + '.google.devtools.cloudbuild.v1.Build' + ) as gax.protobuf.Type; + const approveBuildMetadata = protoFilesRoot.lookup( + '.google.devtools.cloudbuild.v1.BuildOperationMetadata' + ) as gax.protobuf.Type; const runBuildTriggerResponse = protoFilesRoot.lookup( '.google.devtools.cloudbuild.v1.Build' ) as gax.protobuf.Type; @@ -286,6 +292,11 @@ export class CloudBuildClient { retryBuildResponse.decode.bind(retryBuildResponse), retryBuildMetadata.decode.bind(retryBuildMetadata) ), + approveBuild: new this._gaxModule.LongrunningDescriptor( + this.operationsClient, + approveBuildResponse.decode.bind(approveBuildResponse), + approveBuildMetadata.decode.bind(approveBuildMetadata) + ), runBuildTrigger: new this._gaxModule.LongrunningDescriptor( this.operationsClient, runBuildTriggerResponse.decode.bind(runBuildTriggerResponse), @@ -363,6 +374,7 @@ export class CloudBuildClient { 'listBuilds', 'cancelBuild', 'retryBuild', + 'approveBuild', 'createBuildTrigger', 'getBuildTrigger', 'listBuildTriggers', @@ -1589,6 +1601,155 @@ export class CloudBuildClient { protos.google.devtools.cloudbuild.v1.BuildOperationMetadata >; } + approveBuild( + request?: protos.google.devtools.cloudbuild.v1.IApproveBuildRequest, + options?: CallOptions + ): Promise< + [ + LROperation< + protos.google.devtools.cloudbuild.v1.IBuild, + protos.google.devtools.cloudbuild.v1.IBuildOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + >; + approveBuild( + request: protos.google.devtools.cloudbuild.v1.IApproveBuildRequest, + options: CallOptions, + callback: Callback< + LROperation< + protos.google.devtools.cloudbuild.v1.IBuild, + protos.google.devtools.cloudbuild.v1.IBuildOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + approveBuild( + request: protos.google.devtools.cloudbuild.v1.IApproveBuildRequest, + callback: Callback< + LROperation< + protos.google.devtools.cloudbuild.v1.IBuild, + protos.google.devtools.cloudbuild.v1.IBuildOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): void; + /** + * Approves or rejects a pending build. + * + * If approved, the returned LRO will be analogous to the LRO returned from + * a CreateBuild call. + * + * If rejected, the returned LRO will be immediately done. + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.name + * Required. Name of the target build. + * For example: "projects/{$project_id}/builds/{$build_id}" + * @param {google.devtools.cloudbuild.v1.ApprovalResult} request.approvalResult + * Approval decision and metadata. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing + * a long running operation. Its `promise()` method returns a promise + * you can `await` for. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const [operation] = await client.approveBuild(request); + * const [response] = await operation.promise(); + */ + approveBuild( + request?: protos.google.devtools.cloudbuild.v1.IApproveBuildRequest, + optionsOrCallback?: + | CallOptions + | Callback< + LROperation< + protos.google.devtools.cloudbuild.v1.IBuild, + protos.google.devtools.cloudbuild.v1.IBuildOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + >, + callback?: Callback< + LROperation< + protos.google.devtools.cloudbuild.v1.IBuild, + protos.google.devtools.cloudbuild.v1.IBuildOperationMetadata + >, + protos.google.longrunning.IOperation | null | undefined, + {} | null | undefined + > + ): Promise< + [ + LROperation< + protos.google.devtools.cloudbuild.v1.IBuild, + protos.google.devtools.cloudbuild.v1.IBuildOperationMetadata + >, + protos.google.longrunning.IOperation | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + gax.routingHeader.fromParams({ + name: request.name || '', + }); + this.initialize(); + return this.innerApiCalls.approveBuild(request, options, callback); + } + /** + * Check the status of the long running operation returned by `approveBuild()`. + * @param {String} name + * The operation name that will be passed. + * @returns {Promise} - The promise which resolves to an object. + * The decoded operation object has result and metadata field to get information from. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#long-running-operations) + * for more details and examples. + * @example + * const decodedOperation = await checkApproveBuildProgress(name); + * console.log(decodedOperation.result); + * console.log(decodedOperation.done); + * console.log(decodedOperation.metadata); + */ + async checkApproveBuildProgress( + name: string + ): Promise< + LROperation< + protos.google.devtools.cloudbuild.v1.Build, + protos.google.devtools.cloudbuild.v1.BuildOperationMetadata + > + > { + const request = new operationsProtos.google.longrunning.GetOperationRequest( + {name} + ); + const [operation] = await this.operationsClient.getOperation(request); + const decodeOperation = new gax.Operation( + operation, + this.descriptors.longrunning.approveBuild, + gax.createDefaultBackoffSettings() + ); + return decodeOperation as LROperation< + protos.google.devtools.cloudbuild.v1.Build, + protos.google.devtools.cloudbuild.v1.BuildOperationMetadata + >; + } runBuildTrigger( request?: protos.google.devtools.cloudbuild.v1.IRunBuildTriggerRequest, options?: CallOptions diff --git a/src/v1/cloud_build_client_config.json b/src/v1/cloud_build_client_config.json index 59a36aa..c677cba 100644 --- a/src/v1/cloud_build_client_config.json +++ b/src/v1/cloud_build_client_config.json @@ -45,6 +45,10 @@ "retry_codes_name": "non_idempotent", "retry_params_name": "default" }, + "ApproveBuild": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, "CreateBuildTrigger": { "timeout_millis": 600000, "retry_codes_name": "non_idempotent", diff --git a/src/v1/gapic_metadata.json b/src/v1/gapic_metadata.json index 254f618..3322642 100644 --- a/src/v1/gapic_metadata.json +++ b/src/v1/gapic_metadata.json @@ -60,6 +60,11 @@ "retryBuild" ] }, + "ApproveBuild": { + "methods": [ + "approveBuild" + ] + }, "RunBuildTrigger": { "methods": [ "runBuildTrigger" @@ -156,6 +161,11 @@ "retryBuild" ] }, + "ApproveBuild": { + "methods": [ + "approveBuild" + ] + }, "RunBuildTrigger": { "methods": [ "runBuildTrigger" diff --git a/test/gapic_cloud_build_v1.ts b/test/gapic_cloud_build_v1.ts index 40c4d45..ec20373 100644 --- a/test/gapic_cloud_build_v1.ts +++ b/test/gapic_cloud_build_v1.ts @@ -1529,6 +1529,196 @@ describe('v1.CloudBuildClient', () => { }); }); + describe('approveBuild', () => { + it('invokes approveBuild without error', async () => { + const client = new cloudbuildModule.v1.CloudBuildClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.devtools.cloudbuild.v1.ApproveBuildRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.approveBuild = stubLongRunningCall(expectedResponse); + const [operation] = await client.approveBuild(request); + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.approveBuild as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes approveBuild without error using callback', async () => { + const client = new cloudbuildModule.v1.CloudBuildClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.devtools.cloudbuild.v1.ApproveBuildRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedResponse = generateSampleMessage( + new protos.google.longrunning.Operation() + ); + client.innerApiCalls.approveBuild = + stubLongRunningCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.approveBuild( + request, + ( + err?: Error | null, + result?: LROperation< + protos.google.devtools.cloudbuild.v1.IBuild, + protos.google.devtools.cloudbuild.v1.IBuildOperationMetadata + > | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const operation = (await promise) as LROperation< + protos.google.devtools.cloudbuild.v1.IBuild, + protos.google.devtools.cloudbuild.v1.IBuildOperationMetadata + >; + const [response] = await operation.promise(); + assert.deepStrictEqual(response, expectedResponse); + assert( + (client.innerApiCalls.approveBuild as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions /*, callback defined above */) + ); + }); + + it('invokes approveBuild with call error', async () => { + const client = new cloudbuildModule.v1.CloudBuildClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.devtools.cloudbuild.v1.ApproveBuildRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.approveBuild = stubLongRunningCall( + undefined, + expectedError + ); + await assert.rejects(client.approveBuild(request), expectedError); + assert( + (client.innerApiCalls.approveBuild as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes approveBuild with LRO error', async () => { + const client = new cloudbuildModule.v1.CloudBuildClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.devtools.cloudbuild.v1.ApproveBuildRequest() + ); + request.name = ''; + const expectedHeaderRequestParams = 'name='; + const expectedOptions = { + otherArgs: { + headers: { + 'x-goog-request-params': expectedHeaderRequestParams, + }, + }, + }; + const expectedError = new Error('expected'); + client.innerApiCalls.approveBuild = stubLongRunningCall( + undefined, + undefined, + expectedError + ); + const [operation] = await client.approveBuild(request); + await assert.rejects(operation.promise(), expectedError); + assert( + (client.innerApiCalls.approveBuild as SinonStub) + .getCall(0) + .calledWith(request, expectedOptions, undefined) + ); + }); + + it('invokes checkApproveBuildProgress without error', async () => { + const client = new cloudbuildModule.v1.CloudBuildClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedResponse = generateSampleMessage( + new operationsProtos.google.longrunning.Operation() + ); + expectedResponse.name = 'test'; + expectedResponse.response = {type_url: 'url', value: Buffer.from('')}; + expectedResponse.metadata = {type_url: 'url', value: Buffer.from('')}; + + client.operationsClient.getOperation = stubSimpleCall(expectedResponse); + const decodedOperation = await client.checkApproveBuildProgress( + expectedResponse.name + ); + assert.deepStrictEqual(decodedOperation.name, expectedResponse.name); + assert(decodedOperation.metadata); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + + it('invokes checkApproveBuildProgress with error', async () => { + const client = new cloudbuildModule.v1.CloudBuildClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const expectedError = new Error('expected'); + + client.operationsClient.getOperation = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.checkApproveBuildProgress(''), expectedError); + assert((client.operationsClient.getOperation as SinonStub).getCall(0)); + }); + }); + describe('runBuildTrigger', () => { it('invokes runBuildTrigger without error', async () => { const client = new cloudbuildModule.v1.CloudBuildClient({