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 b5a3c09d248..938e37e9198 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 @@ -53,6 +53,14 @@ option (google.api.resource_definition) = { type: "cloudkms.googleapis.com/CryptoKey" pattern: "projects/{project}/locations/{location}/keyRings/{keyring}/cryptoKeys/{key}" }; +option (google.api.resource_definition) = { + type: "pubsub.googleapis.com/Subscription" + pattern: "projects/{project}/subscriptions/{subscription}" +}; +option (google.api.resource_definition) = { + type: "pubsub.googleapis.com/Topic" + pattern: "projects/{project}/topics/{topic}" +}; // Creates and manages builds on Google Cloud Platform. // @@ -1021,6 +1029,10 @@ message BuildTrigger { // Mutually exclusive with `trigger_template`. GitHubEventsConfig github = 13; + // Optional. PubsubConfig describes the configuration of a trigger that + // creates a build whenever a Pub/Sub message is published. + PubsubConfig pubsub_config = 29 [(google.api.field_behavior) = OPTIONAL]; + // Template describing the Build request to make when the trigger is matched. oneof build_template { // Contents of the build template. @@ -1062,6 +1074,9 @@ message BuildTrigger { // least one of those files matches a included_files glob. If not, // then we do not trigger a build. repeated string included_files = 16; + + // Optional. A Common Expression Language string. + string filter = 30 [(google.api.field_behavior) = OPTIONAL]; } // GitHubEventsConfig describes the configuration of a trigger that creates a @@ -1092,6 +1107,53 @@ message GitHubEventsConfig { } } +// PubsubConfig describes the configuration of a trigger that +// creates a build whenever a Pub/Sub message is published. +message PubsubConfig { + // Enumerates potential issues with the underlying Pub/Sub subscription + // configuration. + enum State { + // The subscription configuration has not been checked. + STATE_UNSPECIFIED = 0; + + // The Pub/Sub subscription is properly configured. + OK = 1; + + // The subscription has been deleted. + SUBSCRIPTION_DELETED = 2; + + // The topic has been deleted. + TOPIC_DELETED = 3; + + // Some of the subscription's field are misconfigured. + SUBSCRIPTION_MISCONFIGURED = 4; + } + + // Output only. Name of the subscription. Format is + // `projects/{project}/subscriptions/{subscription}`. + string subscription = 1 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "pubsub.googleapis.com/Subscription" + } + ]; + + // The name of the topic from which this subscription is receiving messages. + // Format is `projects/{project}/topics/{topic}`. + string topic = 2 [ + (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" } + ]; + + // Service account that will make the push request. + string service_account_email = 3 [(google.api.resource_reference) = { + type: "iam.googleapis.com/ServiceAccount" + }]; + + // Potential issues with the underlying Pub/Sub subscription configuration. + // Only populated on get requests. + State state = 4; +} + // PullRequestFilter contains filter properties for matching GitHub Pull // Requests. message PullRequestFilter { diff --git a/packages/google-devtools-cloudbuild/protos/protos.d.ts b/packages/google-devtools-cloudbuild/protos/protos.d.ts index e03d94b01d8..d75196fa500 100644 --- a/packages/google-devtools-cloudbuild/protos/protos.d.ts +++ b/packages/google-devtools-cloudbuild/protos/protos.d.ts @@ -3385,6 +3385,9 @@ export namespace google { /** BuildTrigger github */ github?: (google.devtools.cloudbuild.v1.IGitHubEventsConfig|null); + /** BuildTrigger pubsubConfig */ + pubsubConfig?: (google.devtools.cloudbuild.v1.IPubsubConfig|null); + /** BuildTrigger build */ build?: (google.devtools.cloudbuild.v1.IBuild|null); @@ -3405,6 +3408,9 @@ export namespace google { /** BuildTrigger includedFiles */ includedFiles?: (string[]|null); + + /** BuildTrigger filter */ + filter?: (string|null); } /** Represents a BuildTrigger. */ @@ -3434,6 +3440,9 @@ export namespace google { /** BuildTrigger github. */ public github?: (google.devtools.cloudbuild.v1.IGitHubEventsConfig|null); + /** BuildTrigger pubsubConfig. */ + public pubsubConfig?: (google.devtools.cloudbuild.v1.IPubsubConfig|null); + /** BuildTrigger build. */ public build?: (google.devtools.cloudbuild.v1.IBuild|null); @@ -3455,6 +3464,9 @@ export namespace google { /** BuildTrigger includedFiles. */ public includedFiles: string[]; + /** BuildTrigger filter. */ + public filter: string; + /** BuildTrigger buildTemplate. */ public buildTemplate?: ("build"|"filename"); @@ -3646,6 +3658,126 @@ export namespace google { public toJSON(): { [k: string]: any }; } + /** Properties of a PubsubConfig. */ + interface IPubsubConfig { + + /** PubsubConfig subscription */ + subscription?: (string|null); + + /** PubsubConfig topic */ + topic?: (string|null); + + /** PubsubConfig serviceAccountEmail */ + serviceAccountEmail?: (string|null); + + /** PubsubConfig state */ + state?: (google.devtools.cloudbuild.v1.PubsubConfig.State|keyof typeof google.devtools.cloudbuild.v1.PubsubConfig.State|null); + } + + /** Represents a PubsubConfig. */ + class PubsubConfig implements IPubsubConfig { + + /** + * Constructs a new PubsubConfig. + * @param [properties] Properties to set + */ + constructor(properties?: google.devtools.cloudbuild.v1.IPubsubConfig); + + /** PubsubConfig subscription. */ + public subscription: string; + + /** PubsubConfig topic. */ + public topic: string; + + /** PubsubConfig serviceAccountEmail. */ + public serviceAccountEmail: string; + + /** PubsubConfig state. */ + public state: (google.devtools.cloudbuild.v1.PubsubConfig.State|keyof typeof google.devtools.cloudbuild.v1.PubsubConfig.State); + + /** + * Creates a new PubsubConfig instance using the specified properties. + * @param [properties] Properties to set + * @returns PubsubConfig instance + */ + public static create(properties?: google.devtools.cloudbuild.v1.IPubsubConfig): google.devtools.cloudbuild.v1.PubsubConfig; + + /** + * Encodes the specified PubsubConfig message. Does not implicitly {@link google.devtools.cloudbuild.v1.PubsubConfig.verify|verify} messages. + * @param message PubsubConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.devtools.cloudbuild.v1.IPubsubConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified PubsubConfig message, length delimited. Does not implicitly {@link google.devtools.cloudbuild.v1.PubsubConfig.verify|verify} messages. + * @param message PubsubConfig message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.devtools.cloudbuild.v1.IPubsubConfig, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a PubsubConfig message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns PubsubConfig + * @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.PubsubConfig; + + /** + * Decodes a PubsubConfig message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns PubsubConfig + * @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.PubsubConfig; + + /** + * Verifies a PubsubConfig 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 PubsubConfig message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns PubsubConfig + */ + public static fromObject(object: { [k: string]: any }): google.devtools.cloudbuild.v1.PubsubConfig; + + /** + * Creates a plain object from a PubsubConfig message. Also converts values to other types if specified. + * @param message PubsubConfig + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.devtools.cloudbuild.v1.PubsubConfig, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this PubsubConfig to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + } + + namespace PubsubConfig { + + /** State enum. */ + enum State { + STATE_UNSPECIFIED = 0, + OK = 1, + SUBSCRIPTION_DELETED = 2, + TOPIC_DELETED = 3, + SUBSCRIPTION_MISCONFIGURED = 4 + } + } + /** Properties of a PullRequestFilter. */ interface IPullRequestFilter { diff --git a/packages/google-devtools-cloudbuild/protos/protos.js b/packages/google-devtools-cloudbuild/protos/protos.js index 033032535d2..6d23fafc882 100644 --- a/packages/google-devtools-cloudbuild/protos/protos.js +++ b/packages/google-devtools-cloudbuild/protos/protos.js @@ -8530,6 +8530,7 @@ * @property {Array.|null} [tags] BuildTrigger tags * @property {google.devtools.cloudbuild.v1.IRepoSource|null} [triggerTemplate] BuildTrigger triggerTemplate * @property {google.devtools.cloudbuild.v1.IGitHubEventsConfig|null} [github] BuildTrigger github + * @property {google.devtools.cloudbuild.v1.IPubsubConfig|null} [pubsubConfig] BuildTrigger pubsubConfig * @property {google.devtools.cloudbuild.v1.IBuild|null} [build] BuildTrigger build * @property {string|null} [filename] BuildTrigger filename * @property {google.protobuf.ITimestamp|null} [createTime] BuildTrigger createTime @@ -8537,6 +8538,7 @@ * @property {Object.|null} [substitutions] BuildTrigger substitutions * @property {Array.|null} [ignoredFiles] BuildTrigger ignoredFiles * @property {Array.|null} [includedFiles] BuildTrigger includedFiles + * @property {string|null} [filter] BuildTrigger filter */ /** @@ -8606,6 +8608,14 @@ */ BuildTrigger.prototype.github = null; + /** + * BuildTrigger pubsubConfig. + * @member {google.devtools.cloudbuild.v1.IPubsubConfig|null|undefined} pubsubConfig + * @memberof google.devtools.cloudbuild.v1.BuildTrigger + * @instance + */ + BuildTrigger.prototype.pubsubConfig = null; + /** * BuildTrigger build. * @member {google.devtools.cloudbuild.v1.IBuild|null|undefined} build @@ -8662,6 +8672,14 @@ */ BuildTrigger.prototype.includedFiles = $util.emptyArray; + /** + * BuildTrigger filter. + * @member {string} filter + * @memberof google.devtools.cloudbuild.v1.BuildTrigger + * @instance + */ + BuildTrigger.prototype.filter = ""; + // OneOf field names bound to virtual getters and setters var $oneOfFields; @@ -8730,6 +8748,10 @@ writer.uint32(/* id 19, wireType 2 =*/154).string(message.tags[i]); if (message.name != null && Object.hasOwnProperty.call(message, "name")) writer.uint32(/* id 21, wireType 2 =*/170).string(message.name); + if (message.pubsubConfig != null && Object.hasOwnProperty.call(message, "pubsubConfig")) + $root.google.devtools.cloudbuild.v1.PubsubConfig.encode(message.pubsubConfig, writer.uint32(/* id 29, wireType 2 =*/234).fork()).ldelim(); + if (message.filter != null && Object.hasOwnProperty.call(message, "filter")) + writer.uint32(/* id 30, wireType 2 =*/242).string(message.filter); return writer; }; @@ -8784,6 +8806,9 @@ case 13: message.github = $root.google.devtools.cloudbuild.v1.GitHubEventsConfig.decode(reader, reader.uint32()); break; + case 29: + message.pubsubConfig = $root.google.devtools.cloudbuild.v1.PubsubConfig.decode(reader, reader.uint32()); + break; case 4: message.build = $root.google.devtools.cloudbuild.v1.Build.decode(reader, reader.uint32()); break; @@ -8828,6 +8853,9 @@ message.includedFiles = []; message.includedFiles.push(reader.string()); break; + case 30: + message.filter = reader.string(); + break; default: reader.skipType(tag & 7); break; @@ -8890,6 +8918,11 @@ if (error) return "github." + error; } + if (message.pubsubConfig != null && message.hasOwnProperty("pubsubConfig")) { + var error = $root.google.devtools.cloudbuild.v1.PubsubConfig.verify(message.pubsubConfig); + if (error) + return "pubsubConfig." + error; + } if (message.build != null && message.hasOwnProperty("build")) { properties.buildTemplate = 1; { @@ -8935,6 +8968,9 @@ if (!$util.isString(message.includedFiles[i])) return "includedFiles: string[] expected"; } + if (message.filter != null && message.hasOwnProperty("filter")) + if (!$util.isString(message.filter)) + return "filter: string expected"; return null; }; @@ -8973,6 +9009,11 @@ throw TypeError(".google.devtools.cloudbuild.v1.BuildTrigger.github: object expected"); message.github = $root.google.devtools.cloudbuild.v1.GitHubEventsConfig.fromObject(object.github); } + if (object.pubsubConfig != null) { + if (typeof object.pubsubConfig !== "object") + throw TypeError(".google.devtools.cloudbuild.v1.BuildTrigger.pubsubConfig: object expected"); + message.pubsubConfig = $root.google.devtools.cloudbuild.v1.PubsubConfig.fromObject(object.pubsubConfig); + } if (object.build != null) { if (typeof object.build !== "object") throw TypeError(".google.devtools.cloudbuild.v1.BuildTrigger.build: object expected"); @@ -9008,6 +9049,8 @@ for (var i = 0; i < object.includedFiles.length; ++i) message.includedFiles[i] = String(object.includedFiles[i]); } + if (object.filter != null) + message.filter = String(object.filter); return message; }; @@ -9039,6 +9082,8 @@ object.description = ""; object.github = null; object.name = ""; + object.pubsubConfig = null; + object.filter = ""; } if (message.id != null && message.hasOwnProperty("id")) object.id = message.id; @@ -9085,6 +9130,10 @@ } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; + if (message.pubsubConfig != null && message.hasOwnProperty("pubsubConfig")) + object.pubsubConfig = $root.google.devtools.cloudbuild.v1.PubsubConfig.toObject(message.pubsubConfig, options); + if (message.filter != null && message.hasOwnProperty("filter")) + object.filter = message.filter; return object; }; @@ -9429,6 +9478,308 @@ return GitHubEventsConfig; })(); + v1.PubsubConfig = (function() { + + /** + * Properties of a PubsubConfig. + * @memberof google.devtools.cloudbuild.v1 + * @interface IPubsubConfig + * @property {string|null} [subscription] PubsubConfig subscription + * @property {string|null} [topic] PubsubConfig topic + * @property {string|null} [serviceAccountEmail] PubsubConfig serviceAccountEmail + * @property {google.devtools.cloudbuild.v1.PubsubConfig.State|null} [state] PubsubConfig state + */ + + /** + * Constructs a new PubsubConfig. + * @memberof google.devtools.cloudbuild.v1 + * @classdesc Represents a PubsubConfig. + * @implements IPubsubConfig + * @constructor + * @param {google.devtools.cloudbuild.v1.IPubsubConfig=} [properties] Properties to set + */ + function PubsubConfig(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]]; + } + + /** + * PubsubConfig subscription. + * @member {string} subscription + * @memberof google.devtools.cloudbuild.v1.PubsubConfig + * @instance + */ + PubsubConfig.prototype.subscription = ""; + + /** + * PubsubConfig topic. + * @member {string} topic + * @memberof google.devtools.cloudbuild.v1.PubsubConfig + * @instance + */ + PubsubConfig.prototype.topic = ""; + + /** + * PubsubConfig serviceAccountEmail. + * @member {string} serviceAccountEmail + * @memberof google.devtools.cloudbuild.v1.PubsubConfig + * @instance + */ + PubsubConfig.prototype.serviceAccountEmail = ""; + + /** + * PubsubConfig state. + * @member {google.devtools.cloudbuild.v1.PubsubConfig.State} state + * @memberof google.devtools.cloudbuild.v1.PubsubConfig + * @instance + */ + PubsubConfig.prototype.state = 0; + + /** + * Creates a new PubsubConfig instance using the specified properties. + * @function create + * @memberof google.devtools.cloudbuild.v1.PubsubConfig + * @static + * @param {google.devtools.cloudbuild.v1.IPubsubConfig=} [properties] Properties to set + * @returns {google.devtools.cloudbuild.v1.PubsubConfig} PubsubConfig instance + */ + PubsubConfig.create = function create(properties) { + return new PubsubConfig(properties); + }; + + /** + * Encodes the specified PubsubConfig message. Does not implicitly {@link google.devtools.cloudbuild.v1.PubsubConfig.verify|verify} messages. + * @function encode + * @memberof google.devtools.cloudbuild.v1.PubsubConfig + * @static + * @param {google.devtools.cloudbuild.v1.IPubsubConfig} message PubsubConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PubsubConfig.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.subscription != null && Object.hasOwnProperty.call(message, "subscription")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.subscription); + if (message.topic != null && Object.hasOwnProperty.call(message, "topic")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.topic); + if (message.serviceAccountEmail != null && Object.hasOwnProperty.call(message, "serviceAccountEmail")) + writer.uint32(/* id 3, wireType 2 =*/26).string(message.serviceAccountEmail); + if (message.state != null && Object.hasOwnProperty.call(message, "state")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.state); + return writer; + }; + + /** + * Encodes the specified PubsubConfig message, length delimited. Does not implicitly {@link google.devtools.cloudbuild.v1.PubsubConfig.verify|verify} messages. + * @function encodeDelimited + * @memberof google.devtools.cloudbuild.v1.PubsubConfig + * @static + * @param {google.devtools.cloudbuild.v1.IPubsubConfig} message PubsubConfig message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + PubsubConfig.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a PubsubConfig message from the specified reader or buffer. + * @function decode + * @memberof google.devtools.cloudbuild.v1.PubsubConfig + * @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.PubsubConfig} PubsubConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PubsubConfig.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.PubsubConfig(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.subscription = reader.string(); + break; + case 2: + message.topic = reader.string(); + break; + case 3: + message.serviceAccountEmail = reader.string(); + break; + case 4: + message.state = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a PubsubConfig message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.devtools.cloudbuild.v1.PubsubConfig + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.devtools.cloudbuild.v1.PubsubConfig} PubsubConfig + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + PubsubConfig.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a PubsubConfig message. + * @function verify + * @memberof google.devtools.cloudbuild.v1.PubsubConfig + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + PubsubConfig.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.subscription != null && message.hasOwnProperty("subscription")) + if (!$util.isString(message.subscription)) + return "subscription: string expected"; + if (message.topic != null && message.hasOwnProperty("topic")) + if (!$util.isString(message.topic)) + return "topic: string expected"; + if (message.serviceAccountEmail != null && message.hasOwnProperty("serviceAccountEmail")) + if (!$util.isString(message.serviceAccountEmail)) + return "serviceAccountEmail: string 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 4: + break; + } + return null; + }; + + /** + * Creates a PubsubConfig message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.devtools.cloudbuild.v1.PubsubConfig + * @static + * @param {Object.} object Plain object + * @returns {google.devtools.cloudbuild.v1.PubsubConfig} PubsubConfig + */ + PubsubConfig.fromObject = function fromObject(object) { + if (object instanceof $root.google.devtools.cloudbuild.v1.PubsubConfig) + return object; + var message = new $root.google.devtools.cloudbuild.v1.PubsubConfig(); + if (object.subscription != null) + message.subscription = String(object.subscription); + if (object.topic != null) + message.topic = String(object.topic); + if (object.serviceAccountEmail != null) + message.serviceAccountEmail = String(object.serviceAccountEmail); + switch (object.state) { + case "STATE_UNSPECIFIED": + case 0: + message.state = 0; + break; + case "OK": + case 1: + message.state = 1; + break; + case "SUBSCRIPTION_DELETED": + case 2: + message.state = 2; + break; + case "TOPIC_DELETED": + case 3: + message.state = 3; + break; + case "SUBSCRIPTION_MISCONFIGURED": + case 4: + message.state = 4; + break; + } + return message; + }; + + /** + * Creates a plain object from a PubsubConfig message. Also converts values to other types if specified. + * @function toObject + * @memberof google.devtools.cloudbuild.v1.PubsubConfig + * @static + * @param {google.devtools.cloudbuild.v1.PubsubConfig} message PubsubConfig + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + PubsubConfig.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.subscription = ""; + object.topic = ""; + object.serviceAccountEmail = ""; + object.state = options.enums === String ? "STATE_UNSPECIFIED" : 0; + } + if (message.subscription != null && message.hasOwnProperty("subscription")) + object.subscription = message.subscription; + if (message.topic != null && message.hasOwnProperty("topic")) + object.topic = message.topic; + if (message.serviceAccountEmail != null && message.hasOwnProperty("serviceAccountEmail")) + object.serviceAccountEmail = message.serviceAccountEmail; + if (message.state != null && message.hasOwnProperty("state")) + object.state = options.enums === String ? $root.google.devtools.cloudbuild.v1.PubsubConfig.State[message.state] : message.state; + return object; + }; + + /** + * Converts this PubsubConfig to JSON. + * @function toJSON + * @memberof google.devtools.cloudbuild.v1.PubsubConfig + * @instance + * @returns {Object.} JSON object + */ + PubsubConfig.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * State enum. + * @name google.devtools.cloudbuild.v1.PubsubConfig.State + * @enum {number} + * @property {number} STATE_UNSPECIFIED=0 STATE_UNSPECIFIED value + * @property {number} OK=1 OK value + * @property {number} SUBSCRIPTION_DELETED=2 SUBSCRIPTION_DELETED value + * @property {number} TOPIC_DELETED=3 TOPIC_DELETED value + * @property {number} SUBSCRIPTION_MISCONFIGURED=4 SUBSCRIPTION_MISCONFIGURED value + */ + PubsubConfig.State = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "STATE_UNSPECIFIED"] = 0; + values[valuesById[1] = "OK"] = 1; + values[valuesById[2] = "SUBSCRIPTION_DELETED"] = 2; + values[valuesById[3] = "TOPIC_DELETED"] = 3; + values[valuesById[4] = "SUBSCRIPTION_MISCONFIGURED"] = 4; + return values; + })(); + + return PubsubConfig; + })(); + v1.PullRequestFilter = (function() { /** diff --git a/packages/google-devtools-cloudbuild/protos/protos.json b/packages/google-devtools-cloudbuild/protos/protos.json index c4e707b6b2c..1b532ad117c 100644 --- a/packages/google-devtools-cloudbuild/protos/protos.json +++ b/packages/google-devtools-cloudbuild/protos/protos.json @@ -14,8 +14,8 @@ "java_package": "com.google.cloudbuild.v1", "objc_class_prefix": "GCB", "ruby_package": "Google::Cloud::Build::V1", - "(google.api.resource_definition).type": "cloudkms.googleapis.com/CryptoKey", - "(google.api.resource_definition).pattern": "projects/{project}/locations/{location}/keyRings/{keyring}/cryptoKeys/{key}" + "(google.api.resource_definition).type": "pubsub.googleapis.com/Topic", + "(google.api.resource_definition).pattern": "projects/{project}/topics/{topic}" }, "nested": { "CloudBuild": { @@ -1094,6 +1094,13 @@ "type": "GitHubEventsConfig", "id": 13 }, + "pubsubConfig": { + "type": "PubsubConfig", + "id": 29, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } + }, "build": { "type": "Build", "id": 4 @@ -1127,6 +1134,13 @@ "rule": "repeated", "type": "string", "id": 16 + }, + "filter": { + "type": "string", + "id": 30, + "options": { + "(google.api.field_behavior)": "OPTIONAL" + } } } }, @@ -1165,6 +1179,47 @@ } } }, + "PubsubConfig": { + "fields": { + "subscription": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "OUTPUT_ONLY", + "(google.api.resource_reference).type": "pubsub.googleapis.com/Subscription" + } + }, + "topic": { + "type": "string", + "id": 2, + "options": { + "(google.api.resource_reference).type": "pubsub.googleapis.com/Topic" + } + }, + "serviceAccountEmail": { + "type": "string", + "id": 3, + "options": { + "(google.api.resource_reference).type": "iam.googleapis.com/ServiceAccount" + } + }, + "state": { + "type": "State", + "id": 4 + } + }, + "nested": { + "State": { + "values": { + "STATE_UNSPECIFIED": 0, + "OK": 1, + "SUBSCRIPTION_DELETED": 2, + "TOPIC_DELETED": 3, + "SUBSCRIPTION_MISCONFIGURED": 4 + } + } + } + }, "PullRequestFilter": { "oneofs": { "gitRef": { 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 be5d7ce4956..cef5d1ba011 100644 --- a/packages/google-devtools-cloudbuild/src/v1/cloud_build_client.ts +++ b/packages/google-devtools-cloudbuild/src/v1/cloud_build_client.ts @@ -196,6 +196,12 @@ export class CloudBuildClient { serviceAccountPathTemplate: new this._gaxModule.PathTemplate( 'projects/{project}/serviceAccounts/{service_account}' ), + subscriptionPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/subscriptions/{subscription}' + ), + topicPathTemplate: new this._gaxModule.PathTemplate( + 'projects/{project}/topics/{topic}' + ), }; // Some of the methods on this service return "paged" results, @@ -2786,6 +2792,80 @@ export class CloudBuildClient { ).service_account; } + /** + * Return a fully-qualified subscription resource name string. + * + * @param {string} project + * @param {string} subscription + * @returns {string} Resource name string. + */ + subscriptionPath(project: string, subscription: string) { + return this.pathTemplates.subscriptionPathTemplate.render({ + project: project, + subscription: subscription, + }); + } + + /** + * Parse the project from Subscription resource. + * + * @param {string} subscriptionName + * A fully-qualified path representing Subscription resource. + * @returns {string} A string representing the project. + */ + matchProjectFromSubscriptionName(subscriptionName: string) { + return this.pathTemplates.subscriptionPathTemplate.match(subscriptionName) + .project; + } + + /** + * Parse the subscription from Subscription resource. + * + * @param {string} subscriptionName + * A fully-qualified path representing Subscription resource. + * @returns {string} A string representing the subscription. + */ + matchSubscriptionFromSubscriptionName(subscriptionName: string) { + return this.pathTemplates.subscriptionPathTemplate.match(subscriptionName) + .subscription; + } + + /** + * Return a fully-qualified topic resource name string. + * + * @param {string} project + * @param {string} topic + * @returns {string} Resource name string. + */ + topicPath(project: string, topic: string) { + return this.pathTemplates.topicPathTemplate.render({ + project: project, + topic: topic, + }); + } + + /** + * Parse the project from Topic resource. + * + * @param {string} topicName + * A fully-qualified path representing Topic resource. + * @returns {string} A string representing the project. + */ + matchProjectFromTopicName(topicName: string) { + return this.pathTemplates.topicPathTemplate.match(topicName).project; + } + + /** + * Parse the topic from Topic resource. + * + * @param {string} topicName + * A fully-qualified path representing Topic resource. + * @returns {string} A string representing the topic. + */ + matchTopicFromTopicName(topicName: string) { + return this.pathTemplates.topicPathTemplate.match(topicName).topic; + } + /** * Terminate the gRPC channel and close the client. * 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 fb3f2e92bd9..387ecdd26ac 100644 --- a/packages/google-devtools-cloudbuild/test/gapic_cloud_build_v1.ts +++ b/packages/google-devtools-cloudbuild/test/gapic_cloud_build_v1.ts @@ -3061,5 +3061,106 @@ describe('v1.CloudBuildClient', () => { ); }); }); + + describe('subscription', () => { + const fakePath = '/rendered/path/subscription'; + const expectedParameters = { + project: 'projectValue', + subscription: 'subscriptionValue', + }; + const client = new cloudbuildModule.v1.CloudBuildClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.subscriptionPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.subscriptionPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('subscriptionPath', () => { + const result = client.subscriptionPath( + 'projectValue', + 'subscriptionValue' + ); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.subscriptionPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromSubscriptionName', () => { + const result = client.matchProjectFromSubscriptionName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.subscriptionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchSubscriptionFromSubscriptionName', () => { + const result = client.matchSubscriptionFromSubscriptionName(fakePath); + assert.strictEqual(result, 'subscriptionValue'); + assert( + (client.pathTemplates.subscriptionPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); + + describe('topic', () => { + const fakePath = '/rendered/path/topic'; + const expectedParameters = { + project: 'projectValue', + topic: 'topicValue', + }; + const client = new cloudbuildModule.v1.CloudBuildClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + client.pathTemplates.topicPathTemplate.render = sinon + .stub() + .returns(fakePath); + client.pathTemplates.topicPathTemplate.match = sinon + .stub() + .returns(expectedParameters); + + it('topicPath', () => { + const result = client.topicPath('projectValue', 'topicValue'); + assert.strictEqual(result, fakePath); + assert( + (client.pathTemplates.topicPathTemplate.render as SinonStub) + .getCall(-1) + .calledWith(expectedParameters) + ); + }); + + it('matchProjectFromTopicName', () => { + const result = client.matchProjectFromTopicName(fakePath); + assert.strictEqual(result, 'projectValue'); + assert( + (client.pathTemplates.topicPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + + it('matchTopicFromTopicName', () => { + const result = client.matchTopicFromTopicName(fakePath); + assert.strictEqual(result, 'topicValue'); + assert( + (client.pathTemplates.topicPathTemplate.match as SinonStub) + .getCall(-1) + .calledWith(fakePath) + ); + }); + }); }); });