diff --git a/packages/google-devtools-cloudbuild/protos/google/devtools/cloudbuild/v1/cloudbuild.proto b/packages/google-devtools-cloudbuild/protos/google/devtools/cloudbuild/v1/cloudbuild.proto index cc2b1dd56a2..bcefce6b603 100644 --- a/packages/google-devtools-cloudbuild/protos/google/devtools/cloudbuild/v1/cloudbuild.proto +++ b/packages/google-devtools-cloudbuild/protos/google/devtools/cloudbuild/v1/cloudbuild.proto @@ -62,6 +62,10 @@ option (google.api.resource_definition) = { type: "pubsub.googleapis.com/Topic" pattern: "projects/{project}/topics/{topic}" }; +option (google.api.resource_definition) = { + type: "cloudbuild.googleapis.com/Repository" + pattern: "projects/{project}/locations/{location}/connections/{connection}/repositories/{repository}" +}; // Creates and manages builds on Google Cloud Platform. // @@ -1575,6 +1579,47 @@ message BuildTrigger { string service_account = 33 [(google.api.resource_reference) = { type: "iam.googleapis.com/ServiceAccount" }]; + + // The configuration of a trigger that creates a build whenever an event from + // Repo API is received. + RepositoryEventConfig repository_event_config = 39; +} + +// The configuration of a trigger that creates a build whenever an event from +// Repo API is received. +message RepositoryEventConfig { + // All possible SCM repo types from Repo API. + enum RepositoryType { + // If unspecified, RepositoryType defaults to GITHUB. + REPOSITORY_TYPE_UNSPECIFIED = 0; + + // The SCM repo is GITHUB. + GITHUB = 1; + + // The SCM repo is GITHUB Enterprise. + GITHUB_ENTERPRISE = 2; + + // The SCM repo is GITLAB Enterprise. + GITLAB_ENTERPRISE = 3; + } + + // The resource name of the Repo API resource. + string repository = 1 [(google.api.resource_reference) = { + type: "cloudbuild.googleapis.com/Repository" + }]; + + // Output only. The type of the SCM vendor the repository points to. + RepositoryType repository_type = 2 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The types of filter to trigger a build. + oneof filter { + // Filter to match changes in pull requests. + PullRequestFilter pull_request = 3; + + // Filter to match changes in refs like branches, tags. + PushFilter push = 4; + } } // GitHubEventsConfig describes the configuration of a trigger that creates a diff --git a/packages/google-devtools-cloudbuild/protos/protos.d.ts b/packages/google-devtools-cloudbuild/protos/protos.d.ts index 6e49890d60a..0e0b31b4e56 100644 --- a/packages/google-devtools-cloudbuild/protos/protos.d.ts +++ b/packages/google-devtools-cloudbuild/protos/protos.d.ts @@ -5292,6 +5292,9 @@ export namespace google { /** BuildTrigger serviceAccount */ serviceAccount?: (string|null); + + /** BuildTrigger repositoryEventConfig */ + repositoryEventConfig?: (google.devtools.cloudbuild.v1.IRepositoryEventConfig|null); } /** Represents a BuildTrigger. */ @@ -5360,6 +5363,9 @@ export namespace google { /** BuildTrigger serviceAccount. */ public serviceAccount: string; + /** BuildTrigger repositoryEventConfig. */ + public repositoryEventConfig?: (google.devtools.cloudbuild.v1.IRepositoryEventConfig|null); + /** BuildTrigger buildTemplate. */ public buildTemplate?: ("autodetect"|"build"|"filename"); @@ -5441,6 +5447,135 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a RepositoryEventConfig. */ + interface IRepositoryEventConfig { + + /** RepositoryEventConfig repository */ + repository?: (string|null); + + /** RepositoryEventConfig repositoryType */ + repositoryType?: (google.devtools.cloudbuild.v1.RepositoryEventConfig.RepositoryType|keyof typeof google.devtools.cloudbuild.v1.RepositoryEventConfig.RepositoryType|null); + + /** RepositoryEventConfig pullRequest */ + pullRequest?: (google.devtools.cloudbuild.v1.IPullRequestFilter|null); + + /** RepositoryEventConfig push */ + push?: (google.devtools.cloudbuild.v1.IPushFilter|null); + } + + /** Represents a RepositoryEventConfig. */ + class RepositoryEventConfig implements IRepositoryEventConfig { + + /** + * Constructs a new RepositoryEventConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.devtools.cloudbuild.v1.IRepositoryEventConfig); + + /** RepositoryEventConfig repository. */ + public repository: string; + + /** RepositoryEventConfig repositoryType. */ + public repositoryType: (google.devtools.cloudbuild.v1.RepositoryEventConfig.RepositoryType|keyof typeof google.devtools.cloudbuild.v1.RepositoryEventConfig.RepositoryType); + + /** RepositoryEventConfig pullRequest. */ + public pullRequest?: (google.devtools.cloudbuild.v1.IPullRequestFilter|null); + + /** RepositoryEventConfig push. */ + public push?: (google.devtools.cloudbuild.v1.IPushFilter|null); + + /** RepositoryEventConfig filter. */ + public filter?: ("pullRequest"|"push"); + + /** + * Creates a new RepositoryEventConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns RepositoryEventConfig instance + */ + public static create(properties?: google.devtools.cloudbuild.v1.IRepositoryEventConfig): google.devtools.cloudbuild.v1.RepositoryEventConfig; + + /** + * Encodes the specified RepositoryEventConfig message. Does not implicitly {@link google.devtools.cloudbuild.v1.RepositoryEventConfig.verify|verify} messages. + * @param message RepositoryEventConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.devtools.cloudbuild.v1.IRepositoryEventConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified RepositoryEventConfig message, length delimited. Does not implicitly {@link google.devtools.cloudbuild.v1.RepositoryEventConfig.verify|verify} messages. + * @param message RepositoryEventConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.devtools.cloudbuild.v1.IRepositoryEventConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a RepositoryEventConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns RepositoryEventConfig + * @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.RepositoryEventConfig; + + /** + * Decodes a RepositoryEventConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns RepositoryEventConfig + * @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.RepositoryEventConfig; + + /** + * Verifies a RepositoryEventConfig 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 RepositoryEventConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns RepositoryEventConfig + */ + public static fromObject(object: { [k: string]: any }): google.devtools.cloudbuild.v1.RepositoryEventConfig; + + /** + * Creates a plain object from a RepositoryEventConfig message. Also converts values to other types if specified. + * @param message RepositoryEventConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.devtools.cloudbuild.v1.RepositoryEventConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this RepositoryEventConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for RepositoryEventConfig + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + namespace RepositoryEventConfig { + + /** RepositoryType enum. */ + enum RepositoryType { + REPOSITORY_TYPE_UNSPECIFIED = 0, + GITHUB = 1, + GITHUB_ENTERPRISE = 2, + GITLAB_ENTERPRISE = 3 + } + } + /** Properties of a GitHubEventsConfig. */ interface IGitHubEventsConfig { diff --git a/packages/google-devtools-cloudbuild/protos/protos.js b/packages/google-devtools-cloudbuild/protos/protos.js index ae9dd2f4819..10c47196c86 100644 --- a/packages/google-devtools-cloudbuild/protos/protos.js +++ b/packages/google-devtools-cloudbuild/protos/protos.js @@ -13448,6 +13448,7 @@ * @property {Array.|null} [includedFiles] BuildTrigger includedFiles * @property {string|null} [filter] BuildTrigger filter * @property {string|null} [serviceAccount] BuildTrigger serviceAccount + * @property {google.devtools.cloudbuild.v1.IRepositoryEventConfig|null} [repositoryEventConfig] BuildTrigger repositoryEventConfig */ /** @@ -13621,6 +13622,14 @@ */ BuildTrigger.prototype.serviceAccount = ""; + /** + * BuildTrigger repositoryEventConfig. + * @member {google.devtools.cloudbuild.v1.IRepositoryEventConfig|null|undefined} repositoryEventConfig + * @memberof google.devtools.cloudbuild.v1.BuildTrigger + * @instance + */ + BuildTrigger.prototype.repositoryEventConfig = null; + // OneOf field names bound to virtual getters and setters var $oneOfFields; @@ -13701,6 +13710,8 @@ writer.uint32(/* id 33, wireType 2 =*/266).string(message.serviceAccount); if (message.resourceName != null && Object.hasOwnProperty.call(message, "resourceName")) writer.uint32(/* id 34, wireType 2 =*/274).string(message.resourceName); + if (message.repositoryEventConfig != null && Object.hasOwnProperty.call(message, "repositoryEventConfig")) + $root.google.devtools.cloudbuild.v1.RepositoryEventConfig.encode(message.repositoryEventConfig, writer.uint32(/* id 39, wireType 2 =*/314).fork()).ldelim(); return writer; }; @@ -13836,6 +13847,10 @@ message.serviceAccount = reader.string(); break; } + case 39: { + message.repositoryEventConfig = $root.google.devtools.cloudbuild.v1.RepositoryEventConfig.decode(reader, reader.uint32()); + break; + } default: reader.skipType(tag & 7); break; @@ -13969,6 +13984,11 @@ if (message.serviceAccount != null && message.hasOwnProperty("serviceAccount")) if (!$util.isString(message.serviceAccount)) return "serviceAccount: string expected"; + if (message.repositoryEventConfig != null && message.hasOwnProperty("repositoryEventConfig")) { + var error = $root.google.devtools.cloudbuild.v1.RepositoryEventConfig.verify(message.repositoryEventConfig); + if (error) + return "repositoryEventConfig." + error; + } return null; }; @@ -14060,6 +14080,11 @@ message.filter = String(object.filter); if (object.serviceAccount != null) message.serviceAccount = String(object.serviceAccount); + if (object.repositoryEventConfig != null) { + if (typeof object.repositoryEventConfig !== "object") + throw TypeError(".google.devtools.cloudbuild.v1.BuildTrigger.repositoryEventConfig: object expected"); + message.repositoryEventConfig = $root.google.devtools.cloudbuild.v1.RepositoryEventConfig.fromObject(object.repositoryEventConfig); + } return message; }; @@ -14096,6 +14121,7 @@ object.webhookConfig = null; object.serviceAccount = ""; object.resourceName = ""; + object.repositoryEventConfig = null; } if (message.id != null && message.hasOwnProperty("id")) object.id = message.id; @@ -14157,6 +14183,8 @@ object.serviceAccount = message.serviceAccount; if (message.resourceName != null && message.hasOwnProperty("resourceName")) object.resourceName = message.resourceName; + if (message.repositoryEventConfig != null && message.hasOwnProperty("repositoryEventConfig")) + object.repositoryEventConfig = $root.google.devtools.cloudbuild.v1.RepositoryEventConfig.toObject(message.repositoryEventConfig, options); return object; }; @@ -14189,6 +14217,363 @@ return BuildTrigger; })(); + v1.RepositoryEventConfig = (function() { + + /** + * Properties of a RepositoryEventConfig. + * @memberof google.devtools.cloudbuild.v1 + * @interface IRepositoryEventConfig + * @property {string|null} [repository] RepositoryEventConfig repository + * @property {google.devtools.cloudbuild.v1.RepositoryEventConfig.RepositoryType|null} [repositoryType] RepositoryEventConfig repositoryType + * @property {google.devtools.cloudbuild.v1.IPullRequestFilter|null} [pullRequest] RepositoryEventConfig pullRequest + * @property {google.devtools.cloudbuild.v1.IPushFilter|null} [push] RepositoryEventConfig push + */ + + /** + * Constructs a new RepositoryEventConfig. + * @memberof google.devtools.cloudbuild.v1 + * @classdesc Represents a RepositoryEventConfig. + * @implements IRepositoryEventConfig + * @constructor + * @param {google.devtools.cloudbuild.v1.IRepositoryEventConfig=} [properties] Properties to set + */ + function RepositoryEventConfig(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]]; + } + + /** + * RepositoryEventConfig repository. + * @member {string} repository + * @memberof google.devtools.cloudbuild.v1.RepositoryEventConfig + * @instance + */ + RepositoryEventConfig.prototype.repository = ""; + + /** + * RepositoryEventConfig repositoryType. + * @member {google.devtools.cloudbuild.v1.RepositoryEventConfig.RepositoryType} repositoryType + * @memberof google.devtools.cloudbuild.v1.RepositoryEventConfig + * @instance + */ + RepositoryEventConfig.prototype.repositoryType = 0; + + /** + * RepositoryEventConfig pullRequest. + * @member {google.devtools.cloudbuild.v1.IPullRequestFilter|null|undefined} pullRequest + * @memberof google.devtools.cloudbuild.v1.RepositoryEventConfig + * @instance + */ + RepositoryEventConfig.prototype.pullRequest = null; + + /** + * RepositoryEventConfig push. + * @member {google.devtools.cloudbuild.v1.IPushFilter|null|undefined} push + * @memberof google.devtools.cloudbuild.v1.RepositoryEventConfig + * @instance + */ + RepositoryEventConfig.prototype.push = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * RepositoryEventConfig filter. + * @member {"pullRequest"|"push"|undefined} filter + * @memberof google.devtools.cloudbuild.v1.RepositoryEventConfig + * @instance + */ + Object.defineProperty(RepositoryEventConfig.prototype, "filter", { + get: $util.oneOfGetter($oneOfFields = ["pullRequest", "push"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new RepositoryEventConfig instance using the specified properties. + * @function create + * @memberof google.devtools.cloudbuild.v1.RepositoryEventConfig + * @static + * @param {google.devtools.cloudbuild.v1.IRepositoryEventConfig=} [properties] Properties to set + * @returns {google.devtools.cloudbuild.v1.RepositoryEventConfig} RepositoryEventConfig instance + */ + RepositoryEventConfig.create = function create(properties) { + return new RepositoryEventConfig(properties); + }; + + /** + * Encodes the specified RepositoryEventConfig message. Does not implicitly {@link google.devtools.cloudbuild.v1.RepositoryEventConfig.verify|verify} messages. + * @function encode + * @memberof google.devtools.cloudbuild.v1.RepositoryEventConfig + * @static + * @param {google.devtools.cloudbuild.v1.IRepositoryEventConfig} message RepositoryEventConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RepositoryEventConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.repository != null && Object.hasOwnProperty.call(message, "repository")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.repository); + if (message.repositoryType != null && Object.hasOwnProperty.call(message, "repositoryType")) + writer.uint32(/* id 2, wireType 0 =*/16).int32(message.repositoryType); + if (message.pullRequest != null && Object.hasOwnProperty.call(message, "pullRequest")) + $root.google.devtools.cloudbuild.v1.PullRequestFilter.encode(message.pullRequest, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.push != null && Object.hasOwnProperty.call(message, "push")) + $root.google.devtools.cloudbuild.v1.PushFilter.encode(message.push, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified RepositoryEventConfig message, length delimited. Does not implicitly {@link google.devtools.cloudbuild.v1.RepositoryEventConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.devtools.cloudbuild.v1.RepositoryEventConfig + * @static + * @param {google.devtools.cloudbuild.v1.IRepositoryEventConfig} message RepositoryEventConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + RepositoryEventConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a RepositoryEventConfig message from the specified reader or buffer. + * @function decode + * @memberof google.devtools.cloudbuild.v1.RepositoryEventConfig + * @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.RepositoryEventConfig} RepositoryEventConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RepositoryEventConfig.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.RepositoryEventConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.repository = reader.string(); + break; + } + case 2: { + message.repositoryType = reader.int32(); + break; + } + case 3: { + message.pullRequest = $root.google.devtools.cloudbuild.v1.PullRequestFilter.decode(reader, reader.uint32()); + break; + } + case 4: { + message.push = $root.google.devtools.cloudbuild.v1.PushFilter.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a RepositoryEventConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.devtools.cloudbuild.v1.RepositoryEventConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.devtools.cloudbuild.v1.RepositoryEventConfig} RepositoryEventConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + RepositoryEventConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a RepositoryEventConfig message. + * @function verify + * @memberof google.devtools.cloudbuild.v1.RepositoryEventConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + RepositoryEventConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.repository != null && message.hasOwnProperty("repository")) + if (!$util.isString(message.repository)) + return "repository: string expected"; + if (message.repositoryType != null && message.hasOwnProperty("repositoryType")) + switch (message.repositoryType) { + default: + return "repositoryType: enum value expected"; + case 0: + case 1: + case 2: + case 3: + break; + } + if (message.pullRequest != null && message.hasOwnProperty("pullRequest")) { + properties.filter = 1; + { + var error = $root.google.devtools.cloudbuild.v1.PullRequestFilter.verify(message.pullRequest); + if (error) + return "pullRequest." + error; + } + } + if (message.push != null && message.hasOwnProperty("push")) { + if (properties.filter === 1) + return "filter: multiple values"; + properties.filter = 1; + { + var error = $root.google.devtools.cloudbuild.v1.PushFilter.verify(message.push); + if (error) + return "push." + error; + } + } + return null; + }; + + /** + * Creates a RepositoryEventConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.devtools.cloudbuild.v1.RepositoryEventConfig + * @static + * @param {Object.} object Plain object + * @returns {google.devtools.cloudbuild.v1.RepositoryEventConfig} RepositoryEventConfig + */ + RepositoryEventConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.devtools.cloudbuild.v1.RepositoryEventConfig) + return object; + var message = new $root.google.devtools.cloudbuild.v1.RepositoryEventConfig(); + if (object.repository != null) + message.repository = String(object.repository); + switch (object.repositoryType) { + default: + if (typeof object.repositoryType === "number") { + message.repositoryType = object.repositoryType; + break; + } + break; + case "REPOSITORY_TYPE_UNSPECIFIED": + case 0: + message.repositoryType = 0; + break; + case "GITHUB": + case 1: + message.repositoryType = 1; + break; + case "GITHUB_ENTERPRISE": + case 2: + message.repositoryType = 2; + break; + case "GITLAB_ENTERPRISE": + case 3: + message.repositoryType = 3; + break; + } + if (object.pullRequest != null) { + if (typeof object.pullRequest !== "object") + throw TypeError(".google.devtools.cloudbuild.v1.RepositoryEventConfig.pullRequest: object expected"); + message.pullRequest = $root.google.devtools.cloudbuild.v1.PullRequestFilter.fromObject(object.pullRequest); + } + if (object.push != null) { + if (typeof object.push !== "object") + throw TypeError(".google.devtools.cloudbuild.v1.RepositoryEventConfig.push: object expected"); + message.push = $root.google.devtools.cloudbuild.v1.PushFilter.fromObject(object.push); + } + return message; + }; + + /** + * Creates a plain object from a RepositoryEventConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.devtools.cloudbuild.v1.RepositoryEventConfig + * @static + * @param {google.devtools.cloudbuild.v1.RepositoryEventConfig} message RepositoryEventConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + RepositoryEventConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.repository = ""; + object.repositoryType = options.enums === String ? "REPOSITORY_TYPE_UNSPECIFIED" : 0; + } + if (message.repository != null && message.hasOwnProperty("repository")) + object.repository = message.repository; + if (message.repositoryType != null && message.hasOwnProperty("repositoryType")) + object.repositoryType = options.enums === String ? $root.google.devtools.cloudbuild.v1.RepositoryEventConfig.RepositoryType[message.repositoryType] === undefined ? message.repositoryType : $root.google.devtools.cloudbuild.v1.RepositoryEventConfig.RepositoryType[message.repositoryType] : message.repositoryType; + if (message.pullRequest != null && message.hasOwnProperty("pullRequest")) { + object.pullRequest = $root.google.devtools.cloudbuild.v1.PullRequestFilter.toObject(message.pullRequest, options); + if (options.oneofs) + object.filter = "pullRequest"; + } + if (message.push != null && message.hasOwnProperty("push")) { + object.push = $root.google.devtools.cloudbuild.v1.PushFilter.toObject(message.push, options); + if (options.oneofs) + object.filter = "push"; + } + return object; + }; + + /** + * Converts this RepositoryEventConfig to JSON. + * @function toJSON + * @memberof google.devtools.cloudbuild.v1.RepositoryEventConfig + * @instance + * @returns {Object.} JSON object + */ + RepositoryEventConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for RepositoryEventConfig + * @function getTypeUrl + * @memberof google.devtools.cloudbuild.v1.RepositoryEventConfig + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + RepositoryEventConfig.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.devtools.cloudbuild.v1.RepositoryEventConfig"; + }; + + /** + * RepositoryType enum. + * @name google.devtools.cloudbuild.v1.RepositoryEventConfig.RepositoryType + * @enum {number} + * @property {number} REPOSITORY_TYPE_UNSPECIFIED=0 REPOSITORY_TYPE_UNSPECIFIED value + * @property {number} GITHUB=1 GITHUB value + * @property {number} GITHUB_ENTERPRISE=2 GITHUB_ENTERPRISE value + * @property {number} GITLAB_ENTERPRISE=3 GITLAB_ENTERPRISE value + */ + RepositoryEventConfig.RepositoryType = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "REPOSITORY_TYPE_UNSPECIFIED"] = 0; + values[valuesById[1] = "GITHUB"] = 1; + values[valuesById[2] = "GITHUB_ENTERPRISE"] = 2; + values[valuesById[3] = "GITLAB_ENTERPRISE"] = 3; + return values; + })(); + + return RepositoryEventConfig; + })(); + v1.GitHubEventsConfig = (function() { /** diff --git a/packages/google-devtools-cloudbuild/protos/protos.json b/packages/google-devtools-cloudbuild/protos/protos.json index 882b0894c55..1f9c416c0ce 100644 --- a/packages/google-devtools-cloudbuild/protos/protos.json +++ b/packages/google-devtools-cloudbuild/protos/protos.json @@ -15,8 +15,8 @@ "objc_class_prefix": "GCB", "php_namespace": "Google\\Cloud\\Build\\V1", "ruby_package": "Google::Cloud::Build::V1", - "(google.api.resource_definition).type": "pubsub.googleapis.com/Topic", - "(google.api.resource_definition).pattern": "projects/{project}/topics/{topic}" + "(google.api.resource_definition).type": "cloudbuild.googleapis.com/Repository", + "(google.api.resource_definition).pattern": "projects/{project}/locations/{location}/connections/{connection}/repositories/{repository}" }, "nested": { "CloudBuild": { @@ -1716,6 +1716,54 @@ "options": { "(google.api.resource_reference).type": "iam.googleapis.com/ServiceAccount" } + }, + "repositoryEventConfig": { + "type": "RepositoryEventConfig", + "id": 39 + } + } + }, + "RepositoryEventConfig": { + "oneofs": { + "filter": { + "oneof": [ + "pullRequest", + "push" + ] + } + }, + "fields": { + "repository": { + "type": "string", + "id": 1, + "options": { + "(google.api.resource_reference).type": "cloudbuild.googleapis.com/Repository" + } + }, + "repositoryType": { + "type": "RepositoryType", + "id": 2, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY" + } + }, + "pullRequest": { + "type": "PullRequestFilter", + "id": 3 + }, + "push": { + "type": "PushFilter", + "id": 4 + } + }, + "nested": { + "RepositoryType": { + "values": { + "REPOSITORY_TYPE_UNSPECIFIED": 0, + "GITHUB": 1, + "GITHUB_ENTERPRISE": 2, + "GITLAB_ENTERPRISE": 3 + } } } }, diff --git a/packages/google-devtools-cloudbuild/src/v1/cloud_build_client.ts b/packages/google-devtools-cloudbuild/src/v1/cloud_build_client.ts index 69483b1b259..89d357e6870 100644 --- a/packages/google-devtools-cloudbuild/src/v1/cloud_build_client.ts +++ b/packages/google-devtools-cloudbuild/src/v1/cloud_build_client.ts @@ -209,6 +209,9 @@ export class CloudBuildClient { projectTriggerPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/triggers/{trigger}' ), + repositoryPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/locations/{location}/connections/{connection}/repositories/{repository}' + ), secretVersionPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/secrets/{secret}/versions/{version}' ), @@ -3350,6 +3353,77 @@ export class CloudBuildClient { ).trigger; } + /** + * Return a fully-qualified repository resource name string. + * + * @param {string} project + * @param {string} location + * @param {string} connection + * @param {string} repository + * @returns {string} Resource name string. + */ + repositoryPath( + project: string, + location: string, + connection: string, + repository: string + ) { + return this.pathTemplates.repositoryPathTemplate.render({ + project: project, + location: location, + connection: connection, + repository: repository, + }); + } + + /** + * Parse the project from Repository resource. + * + * @param {string} repositoryName + * A fully-qualified path representing Repository resource. + * @returns {string} A string representing the project. + */ + matchProjectFromRepositoryName(repositoryName: string) { + return this.pathTemplates.repositoryPathTemplate.match(repositoryName) + .project; + } + + /** + * Parse the location from Repository resource. + * + * @param {string} repositoryName + * A fully-qualified path representing Repository resource. + * @returns {string} A string representing the location. + */ + matchLocationFromRepositoryName(repositoryName: string) { + return this.pathTemplates.repositoryPathTemplate.match(repositoryName) + .location; + } + + /** + * Parse the connection from Repository resource. + * + * @param {string} repositoryName + * A fully-qualified path representing Repository resource. + * @returns {string} A string representing the connection. + */ + matchConnectionFromRepositoryName(repositoryName: string) { + return this.pathTemplates.repositoryPathTemplate.match(repositoryName) + .connection; + } + + /** + * Parse the repository from Repository resource. + * + * @param {string} repositoryName + * A fully-qualified path representing Repository resource. + * @returns {string} A string representing the repository. + */ + matchRepositoryFromRepositoryName(repositoryName: string) { + return this.pathTemplates.repositoryPathTemplate.match(repositoryName) + .repository; + } + /** * Return a fully-qualified secretVersion resource name string. * diff --git a/packages/google-devtools-cloudbuild/test/gapic_cloud_build_v1.ts b/packages/google-devtools-cloudbuild/test/gapic_cloud_build_v1.ts index cd0369a7946..e2e8369f5d9 100644 --- a/packages/google-devtools-cloudbuild/test/gapic_cloud_build_v1.ts +++ b/packages/google-devtools-cloudbuild/test/gapic_cloud_build_v1.ts @@ -4470,6 +4470,82 @@ describe('v1.CloudBuildClient', () => { }); }); + describe('repository', () => { + const fakePath = '/rendered/path/repository'; + const expectedParameters = { + project: 'projectValue', + location: 'locationValue', + connection: 'connectionValue', + repository: 'repositoryValue', + }; + const client = new cloudbuildModule.v1.CloudBuildClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.repositoryPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.repositoryPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('repositoryPath', () => { + const result = client.repositoryPath( + 'projectValue', + 'locationValue', + 'connectionValue', + 'repositoryValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.repositoryPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromRepositoryName', () => { + const result = client.matchProjectFromRepositoryName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.repositoryPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchLocationFromRepositoryName', () => { + const result = client.matchLocationFromRepositoryName(fakePath); + assert.strictEqual(result, 'locationValue'); + assert( + (client.pathTemplates.repositoryPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchConnectionFromRepositoryName', () => { + const result = client.matchConnectionFromRepositoryName(fakePath); + assert.strictEqual(result, 'connectionValue'); + assert( + (client.pathTemplates.repositoryPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchRepositoryFromRepositoryName', () => { + const result = client.matchRepositoryFromRepositoryName(fakePath); + assert.strictEqual(result, 'repositoryValue'); + assert( + (client.pathTemplates.repositoryPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + describe('secretVersion', () => { const fakePath = '/rendered/path/secretVersion'; const expectedParameters = {