diff --git a/EventarcPublishing/metadata/V1/CloudEvent.php b/EventarcPublishing/metadata/V1/CloudEvent.php
new file mode 100644
index 00000000000..406503720ae
Binary files /dev/null and b/EventarcPublishing/metadata/V1/CloudEvent.php differ
diff --git a/EventarcPublishing/metadata/V1/Publisher.php b/EventarcPublishing/metadata/V1/Publisher.php
index 026594dd2e3..e9952863ea7 100644
Binary files a/EventarcPublishing/metadata/V1/Publisher.php and b/EventarcPublishing/metadata/V1/Publisher.php differ
diff --git a/EventarcPublishing/samples/V1/PublisherClient/publish.php b/EventarcPublishing/samples/V1/PublisherClient/publish.php
new file mode 100644
index 00000000000..80fce160f98
--- /dev/null
+++ b/EventarcPublishing/samples/V1/PublisherClient/publish.php
@@ -0,0 +1,71 @@
+setMessageBus($messageBus);
+
+ // Call the API and handle any network failures.
+ try {
+ /** @var PublishResponse $response */
+ $response = $publisherClient->publish($request);
+ printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
+ } catch (ApiException $ex) {
+ printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
+ }
+}
+
+/**
+ * Helper to execute the sample.
+ *
+ * This sample has been automatically generated and should be regarded as a code
+ * template only. It will require modifications to work:
+ * - It may require correct/in-range values for request initialization.
+ * - It may require specifying regional endpoints when creating the service client,
+ * please see the apiEndpoint client configuration option for more details.
+ */
+function callSample(): void
+{
+ $messageBus = '[MESSAGE_BUS]';
+
+ publish_sample($messageBus);
+}
+// [END eventarcpublishing_v1_generated_Publisher_Publish_sync]
diff --git a/EventarcPublishing/src/V1/Client/PublisherClient.php b/EventarcPublishing/src/V1/Client/PublisherClient.php
index de480d4d2f4..5598ecb5fb6 100644
--- a/EventarcPublishing/src/V1/Client/PublisherClient.php
+++ b/EventarcPublishing/src/V1/Client/PublisherClient.php
@@ -35,6 +35,8 @@
use Google\Cloud\Eventarc\Publishing\V1\PublishChannelConnectionEventsResponse;
use Google\Cloud\Eventarc\Publishing\V1\PublishEventsRequest;
use Google\Cloud\Eventarc\Publishing\V1\PublishEventsResponse;
+use Google\Cloud\Eventarc\Publishing\V1\PublishRequest;
+use Google\Cloud\Eventarc\Publishing\V1\PublishResponse;
use Google\Protobuf\Any;
use GuzzleHttp\Promise\PromiseInterface;
@@ -67,6 +69,7 @@
* This class provides the ability to make remote calls to the backing service through method
* calls that map to API methods.
*
+ * @method PromiseInterface publishAsync(PublishRequest $request, array $optionalArgs = [])
* @method PromiseInterface publishChannelConnectionEventsAsync(PublishChannelConnectionEventsRequest $request, array $optionalArgs = [])
* @method PromiseInterface publishEventsAsync(PublishEventsRequest $request, array $optionalArgs = [])
*/
@@ -186,6 +189,32 @@ public function __call($method, $args)
return call_user_func_array([$this, 'startAsyncCall'], $args);
}
+ /**
+ * Publish events to a message bus.
+ *
+ * The async variant is {@see PublisherClient::publishAsync()} .
+ *
+ * @example samples/V1/PublisherClient/publish.php
+ *
+ * @param PublishRequest $request A request to house fields associated with the call.
+ * @param array $callOptions {
+ * Optional.
+ *
+ * @type RetrySettings|array $retrySettings
+ * Retry settings to use for this call. Can be a {@see RetrySettings} object, or an
+ * associative array of retry settings parameters. See the documentation on
+ * {@see RetrySettings} for example usage.
+ * }
+ *
+ * @return PublishResponse
+ *
+ * @throws ApiException Thrown if the API call fails.
+ */
+ public function publish(PublishRequest $request, array $callOptions = []): PublishResponse
+ {
+ return $this->startApiCall('Publish', $request, $callOptions)->wait();
+ }
+
/**
* Publish events to a ChannelConnection in a partner's project.
*
diff --git a/EventarcPublishing/src/V1/CloudEvent.php b/EventarcPublishing/src/V1/CloudEvent.php
new file mode 100644
index 00000000000..59178671d8c
--- /dev/null
+++ b/EventarcPublishing/src/V1/CloudEvent.php
@@ -0,0 +1,328 @@
+google.cloud.eventarc.publishing.v1.CloudEvent
+ */
+class CloudEvent extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * Required. Identifies the event. Producers MUST ensure that source + id is
+ * unique for each distinct event.
+ *
+ * Generated from protobuf field string id = 1 [(.google.api.field_behavior) = REQUIRED];
+ */
+ protected $id = '';
+ /**
+ * Required. Identifies the context in which an event happened.
+ * URI-reference
+ *
+ * Generated from protobuf field string source = 2 [(.google.api.field_behavior) = REQUIRED];
+ */
+ protected $source = '';
+ /**
+ * Required. The version of the CloudEvents specification which the event
+ * uses.
+ *
+ * Generated from protobuf field string spec_version = 3 [(.google.api.field_behavior) = REQUIRED];
+ */
+ protected $spec_version = '';
+ /**
+ * Required. This attribute contains a value describing the type of event
+ * related to the originating occurrence.
+ *
+ * Generated from protobuf field string type = 4 [(.google.api.field_behavior) = REQUIRED];
+ */
+ protected $type = '';
+ /**
+ * Optional. Used for Optional & Extension Attributes
+ *
+ * Generated from protobuf field map attributes = 5 [(.google.api.field_behavior) = OPTIONAL];
+ */
+ private $attributes;
+ protected $data;
+
+ /**
+ * Constructor.
+ *
+ * @param array $data {
+ * Optional. Data for populating the Message object.
+ *
+ * @type string $id
+ * Required. Identifies the event. Producers MUST ensure that source + id is
+ * unique for each distinct event.
+ * @type string $source
+ * Required. Identifies the context in which an event happened.
+ * URI-reference
+ * @type string $spec_version
+ * Required. The version of the CloudEvents specification which the event
+ * uses.
+ * @type string $type
+ * Required. This attribute contains a value describing the type of event
+ * related to the originating occurrence.
+ * @type array|\Google\Protobuf\Internal\MapField $attributes
+ * Optional. Used for Optional & Extension Attributes
+ * @type string $binary_data
+ * Optional. Binary data.
+ * @type string $text_data
+ * Optional. Text data.
+ * @type \Google\Protobuf\Any $proto_data
+ * Optional. Proto data.
+ * }
+ */
+ public function __construct($data = NULL) {
+ \GPBMetadata\Google\Cloud\Eventarc\Publishing\V1\CloudEvent::initOnce();
+ parent::__construct($data);
+ }
+
+ /**
+ * Required. Identifies the event. Producers MUST ensure that source + id is
+ * unique for each distinct event.
+ *
+ * Generated from protobuf field string id = 1 [(.google.api.field_behavior) = REQUIRED];
+ * @return string
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Required. Identifies the event. Producers MUST ensure that source + id is
+ * unique for each distinct event.
+ *
+ * Generated from protobuf field string id = 1 [(.google.api.field_behavior) = REQUIRED];
+ * @param string $var
+ * @return $this
+ */
+ public function setId($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->id = $var;
+
+ return $this;
+ }
+
+ /**
+ * Required. Identifies the context in which an event happened.
+ * URI-reference
+ *
+ * Generated from protobuf field string source = 2 [(.google.api.field_behavior) = REQUIRED];
+ * @return string
+ */
+ public function getSource()
+ {
+ return $this->source;
+ }
+
+ /**
+ * Required. Identifies the context in which an event happened.
+ * URI-reference
+ *
+ * Generated from protobuf field string source = 2 [(.google.api.field_behavior) = REQUIRED];
+ * @param string $var
+ * @return $this
+ */
+ public function setSource($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->source = $var;
+
+ return $this;
+ }
+
+ /**
+ * Required. The version of the CloudEvents specification which the event
+ * uses.
+ *
+ * Generated from protobuf field string spec_version = 3 [(.google.api.field_behavior) = REQUIRED];
+ * @return string
+ */
+ public function getSpecVersion()
+ {
+ return $this->spec_version;
+ }
+
+ /**
+ * Required. The version of the CloudEvents specification which the event
+ * uses.
+ *
+ * Generated from protobuf field string spec_version = 3 [(.google.api.field_behavior) = REQUIRED];
+ * @param string $var
+ * @return $this
+ */
+ public function setSpecVersion($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->spec_version = $var;
+
+ return $this;
+ }
+
+ /**
+ * Required. This attribute contains a value describing the type of event
+ * related to the originating occurrence.
+ *
+ * Generated from protobuf field string type = 4 [(.google.api.field_behavior) = REQUIRED];
+ * @return string
+ */
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ /**
+ * Required. This attribute contains a value describing the type of event
+ * related to the originating occurrence.
+ *
+ * Generated from protobuf field string type = 4 [(.google.api.field_behavior) = REQUIRED];
+ * @param string $var
+ * @return $this
+ */
+ public function setType($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->type = $var;
+
+ return $this;
+ }
+
+ /**
+ * Optional. Used for Optional & Extension Attributes
+ *
+ * Generated from protobuf field map attributes = 5 [(.google.api.field_behavior) = OPTIONAL];
+ * @return \Google\Protobuf\Internal\MapField
+ */
+ public function getAttributes()
+ {
+ return $this->attributes;
+ }
+
+ /**
+ * Optional. Used for Optional & Extension Attributes
+ *
+ * Generated from protobuf field map attributes = 5 [(.google.api.field_behavior) = OPTIONAL];
+ * @param array|\Google\Protobuf\Internal\MapField $var
+ * @return $this
+ */
+ public function setAttributes($var)
+ {
+ $arr = GPBUtil::checkMapField($var, \Google\Protobuf\Internal\GPBType::STRING, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Eventarc\Publishing\V1\CloudEvent\CloudEventAttributeValue::class);
+ $this->attributes = $arr;
+
+ return $this;
+ }
+
+ /**
+ * Optional. Binary data.
+ *
+ * Generated from protobuf field bytes binary_data = 6 [(.google.api.field_behavior) = OPTIONAL];
+ * @return string
+ */
+ public function getBinaryData()
+ {
+ return $this->readOneof(6);
+ }
+
+ public function hasBinaryData()
+ {
+ return $this->hasOneof(6);
+ }
+
+ /**
+ * Optional. Binary data.
+ *
+ * Generated from protobuf field bytes binary_data = 6 [(.google.api.field_behavior) = OPTIONAL];
+ * @param string $var
+ * @return $this
+ */
+ public function setBinaryData($var)
+ {
+ GPBUtil::checkString($var, False);
+ $this->writeOneof(6, $var);
+
+ return $this;
+ }
+
+ /**
+ * Optional. Text data.
+ *
+ * Generated from protobuf field string text_data = 7 [(.google.api.field_behavior) = OPTIONAL];
+ * @return string
+ */
+ public function getTextData()
+ {
+ return $this->readOneof(7);
+ }
+
+ public function hasTextData()
+ {
+ return $this->hasOneof(7);
+ }
+
+ /**
+ * Optional. Text data.
+ *
+ * Generated from protobuf field string text_data = 7 [(.google.api.field_behavior) = OPTIONAL];
+ * @param string $var
+ * @return $this
+ */
+ public function setTextData($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->writeOneof(7, $var);
+
+ return $this;
+ }
+
+ /**
+ * Optional. Proto data.
+ *
+ * Generated from protobuf field .google.protobuf.Any proto_data = 8 [(.google.api.field_behavior) = OPTIONAL];
+ * @return \Google\Protobuf\Any|null
+ */
+ public function getProtoData()
+ {
+ return $this->readOneof(8);
+ }
+
+ public function hasProtoData()
+ {
+ return $this->hasOneof(8);
+ }
+
+ /**
+ * Optional. Proto data.
+ *
+ * Generated from protobuf field .google.protobuf.Any proto_data = 8 [(.google.api.field_behavior) = OPTIONAL];
+ * @param \Google\Protobuf\Any $var
+ * @return $this
+ */
+ public function setProtoData($var)
+ {
+ GPBUtil::checkMessage($var, \Google\Protobuf\Any::class);
+ $this->writeOneof(8, $var);
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getData()
+ {
+ return $this->whichOneof("data");
+ }
+
+}
+
diff --git a/EventarcPublishing/src/V1/CloudEvent/CloudEventAttributeValue.php b/EventarcPublishing/src/V1/CloudEvent/CloudEventAttributeValue.php
new file mode 100644
index 00000000000..226c118df6f
--- /dev/null
+++ b/EventarcPublishing/src/V1/CloudEvent/CloudEventAttributeValue.php
@@ -0,0 +1,274 @@
+google.cloud.eventarc.publishing.v1.CloudEvent.CloudEventAttributeValue
+ */
+class CloudEventAttributeValue extends \Google\Protobuf\Internal\Message
+{
+ protected $attr;
+
+ /**
+ * Constructor.
+ *
+ * @param array $data {
+ * Optional. Data for populating the Message object.
+ *
+ * @type bool $ce_boolean
+ * Boolean value.
+ * @type int $ce_integer
+ * Integer value.
+ * @type string $ce_string
+ * String value.
+ * @type string $ce_bytes
+ * Bytes value.
+ * @type string $ce_uri
+ * URI value.
+ * @type string $ce_uri_ref
+ * URI-reference value.
+ * @type \Google\Protobuf\Timestamp $ce_timestamp
+ * Timestamp value.
+ * }
+ */
+ public function __construct($data = NULL) {
+ \GPBMetadata\Google\Cloud\Eventarc\Publishing\V1\CloudEvent::initOnce();
+ parent::__construct($data);
+ }
+
+ /**
+ * Boolean value.
+ *
+ * Generated from protobuf field bool ce_boolean = 1;
+ * @return bool
+ */
+ public function getCeBoolean()
+ {
+ return $this->readOneof(1);
+ }
+
+ public function hasCeBoolean()
+ {
+ return $this->hasOneof(1);
+ }
+
+ /**
+ * Boolean value.
+ *
+ * Generated from protobuf field bool ce_boolean = 1;
+ * @param bool $var
+ * @return $this
+ */
+ public function setCeBoolean($var)
+ {
+ GPBUtil::checkBool($var);
+ $this->writeOneof(1, $var);
+
+ return $this;
+ }
+
+ /**
+ * Integer value.
+ *
+ * Generated from protobuf field int32 ce_integer = 2;
+ * @return int
+ */
+ public function getCeInteger()
+ {
+ return $this->readOneof(2);
+ }
+
+ public function hasCeInteger()
+ {
+ return $this->hasOneof(2);
+ }
+
+ /**
+ * Integer value.
+ *
+ * Generated from protobuf field int32 ce_integer = 2;
+ * @param int $var
+ * @return $this
+ */
+ public function setCeInteger($var)
+ {
+ GPBUtil::checkInt32($var);
+ $this->writeOneof(2, $var);
+
+ return $this;
+ }
+
+ /**
+ * String value.
+ *
+ * Generated from protobuf field string ce_string = 3;
+ * @return string
+ */
+ public function getCeString()
+ {
+ return $this->readOneof(3);
+ }
+
+ public function hasCeString()
+ {
+ return $this->hasOneof(3);
+ }
+
+ /**
+ * String value.
+ *
+ * Generated from protobuf field string ce_string = 3;
+ * @param string $var
+ * @return $this
+ */
+ public function setCeString($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->writeOneof(3, $var);
+
+ return $this;
+ }
+
+ /**
+ * Bytes value.
+ *
+ * Generated from protobuf field bytes ce_bytes = 4;
+ * @return string
+ */
+ public function getCeBytes()
+ {
+ return $this->readOneof(4);
+ }
+
+ public function hasCeBytes()
+ {
+ return $this->hasOneof(4);
+ }
+
+ /**
+ * Bytes value.
+ *
+ * Generated from protobuf field bytes ce_bytes = 4;
+ * @param string $var
+ * @return $this
+ */
+ public function setCeBytes($var)
+ {
+ GPBUtil::checkString($var, False);
+ $this->writeOneof(4, $var);
+
+ return $this;
+ }
+
+ /**
+ * URI value.
+ *
+ * Generated from protobuf field string ce_uri = 5;
+ * @return string
+ */
+ public function getCeUri()
+ {
+ return $this->readOneof(5);
+ }
+
+ public function hasCeUri()
+ {
+ return $this->hasOneof(5);
+ }
+
+ /**
+ * URI value.
+ *
+ * Generated from protobuf field string ce_uri = 5;
+ * @param string $var
+ * @return $this
+ */
+ public function setCeUri($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->writeOneof(5, $var);
+
+ return $this;
+ }
+
+ /**
+ * URI-reference value.
+ *
+ * Generated from protobuf field string ce_uri_ref = 6;
+ * @return string
+ */
+ public function getCeUriRef()
+ {
+ return $this->readOneof(6);
+ }
+
+ public function hasCeUriRef()
+ {
+ return $this->hasOneof(6);
+ }
+
+ /**
+ * URI-reference value.
+ *
+ * Generated from protobuf field string ce_uri_ref = 6;
+ * @param string $var
+ * @return $this
+ */
+ public function setCeUriRef($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->writeOneof(6, $var);
+
+ return $this;
+ }
+
+ /**
+ * Timestamp value.
+ *
+ * Generated from protobuf field .google.protobuf.Timestamp ce_timestamp = 7;
+ * @return \Google\Protobuf\Timestamp|null
+ */
+ public function getCeTimestamp()
+ {
+ return $this->readOneof(7);
+ }
+
+ public function hasCeTimestamp()
+ {
+ return $this->hasOneof(7);
+ }
+
+ /**
+ * Timestamp value.
+ *
+ * Generated from protobuf field .google.protobuf.Timestamp ce_timestamp = 7;
+ * @param \Google\Protobuf\Timestamp $var
+ * @return $this
+ */
+ public function setCeTimestamp($var)
+ {
+ GPBUtil::checkMessage($var, \Google\Protobuf\Timestamp::class);
+ $this->writeOneof(7, $var);
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getAttr()
+ {
+ return $this->whichOneof("attr");
+ }
+
+}
+
+
diff --git a/EventarcPublishing/src/V1/PublishRequest.php b/EventarcPublishing/src/V1/PublishRequest.php
new file mode 100644
index 00000000000..ce20979caf1
--- /dev/null
+++ b/EventarcPublishing/src/V1/PublishRequest.php
@@ -0,0 +1,197 @@
+google.cloud.eventarc.publishing.v1.PublishRequest
+ */
+class PublishRequest extends \Google\Protobuf\Internal\Message
+{
+ /**
+ * Required. The full name of the message bus to publish events to. Format:
+ * `projects/{project}/locations/{location}/messageBuses/{messageBus}`.
+ *
+ * Generated from protobuf field string message_bus = 1 [(.google.api.field_behavior) = REQUIRED];
+ */
+ protected $message_bus = '';
+ protected $format;
+
+ /**
+ * Constructor.
+ *
+ * @param array $data {
+ * Optional. Data for populating the Message object.
+ *
+ * @type string $message_bus
+ * Required. The full name of the message bus to publish events to. Format:
+ * `projects/{project}/locations/{location}/messageBuses/{messageBus}`.
+ * @type \Google\Cloud\Eventarc\Publishing\V1\CloudEvent $proto_message
+ * The Protobuf format of the CloudEvent being published. Specification can
+ * be found here:
+ * https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/formats/protobuf-format.md
+ * @type string $json_message
+ * The JSON format of the CloudEvent being published. Specification can be
+ * found here:
+ * https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/formats/json-format.md
+ * @type string $avro_message
+ * The Avro format of the CloudEvent being published. Specification can
+ * be found here:
+ * https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/formats/avro-format.md
+ * }
+ */
+ public function __construct($data = NULL) {
+ \GPBMetadata\Google\Cloud\Eventarc\Publishing\V1\Publisher::initOnce();
+ parent::__construct($data);
+ }
+
+ /**
+ * Required. The full name of the message bus to publish events to. Format:
+ * `projects/{project}/locations/{location}/messageBuses/{messageBus}`.
+ *
+ * Generated from protobuf field string message_bus = 1 [(.google.api.field_behavior) = REQUIRED];
+ * @return string
+ */
+ public function getMessageBus()
+ {
+ return $this->message_bus;
+ }
+
+ /**
+ * Required. The full name of the message bus to publish events to. Format:
+ * `projects/{project}/locations/{location}/messageBuses/{messageBus}`.
+ *
+ * Generated from protobuf field string message_bus = 1 [(.google.api.field_behavior) = REQUIRED];
+ * @param string $var
+ * @return $this
+ */
+ public function setMessageBus($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->message_bus = $var;
+
+ return $this;
+ }
+
+ /**
+ * The Protobuf format of the CloudEvent being published. Specification can
+ * be found here:
+ * https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/formats/protobuf-format.md
+ *
+ * Generated from protobuf field .google.cloud.eventarc.publishing.v1.CloudEvent proto_message = 2;
+ * @return \Google\Cloud\Eventarc\Publishing\V1\CloudEvent|null
+ */
+ public function getProtoMessage()
+ {
+ return $this->readOneof(2);
+ }
+
+ public function hasProtoMessage()
+ {
+ return $this->hasOneof(2);
+ }
+
+ /**
+ * The Protobuf format of the CloudEvent being published. Specification can
+ * be found here:
+ * https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/formats/protobuf-format.md
+ *
+ * Generated from protobuf field .google.cloud.eventarc.publishing.v1.CloudEvent proto_message = 2;
+ * @param \Google\Cloud\Eventarc\Publishing\V1\CloudEvent $var
+ * @return $this
+ */
+ public function setProtoMessage($var)
+ {
+ GPBUtil::checkMessage($var, \Google\Cloud\Eventarc\Publishing\V1\CloudEvent::class);
+ $this->writeOneof(2, $var);
+
+ return $this;
+ }
+
+ /**
+ * The JSON format of the CloudEvent being published. Specification can be
+ * found here:
+ * https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/formats/json-format.md
+ *
+ * Generated from protobuf field string json_message = 3;
+ * @return string
+ */
+ public function getJsonMessage()
+ {
+ return $this->readOneof(3);
+ }
+
+ public function hasJsonMessage()
+ {
+ return $this->hasOneof(3);
+ }
+
+ /**
+ * The JSON format of the CloudEvent being published. Specification can be
+ * found here:
+ * https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/formats/json-format.md
+ *
+ * Generated from protobuf field string json_message = 3;
+ * @param string $var
+ * @return $this
+ */
+ public function setJsonMessage($var)
+ {
+ GPBUtil::checkString($var, True);
+ $this->writeOneof(3, $var);
+
+ return $this;
+ }
+
+ /**
+ * The Avro format of the CloudEvent being published. Specification can
+ * be found here:
+ * https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/formats/avro-format.md
+ *
+ * Generated from protobuf field bytes avro_message = 4;
+ * @return string
+ */
+ public function getAvroMessage()
+ {
+ return $this->readOneof(4);
+ }
+
+ public function hasAvroMessage()
+ {
+ return $this->hasOneof(4);
+ }
+
+ /**
+ * The Avro format of the CloudEvent being published. Specification can
+ * be found here:
+ * https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/formats/avro-format.md
+ *
+ * Generated from protobuf field bytes avro_message = 4;
+ * @param string $var
+ * @return $this
+ */
+ public function setAvroMessage($var)
+ {
+ GPBUtil::checkString($var, False);
+ $this->writeOneof(4, $var);
+
+ return $this;
+ }
+
+ /**
+ * @return string
+ */
+ public function getFormat()
+ {
+ return $this->whichOneof("format");
+ }
+
+}
+
diff --git a/EventarcPublishing/src/V1/PublishResponse.php b/EventarcPublishing/src/V1/PublishResponse.php
new file mode 100644
index 00000000000..76e083aea44
--- /dev/null
+++ b/EventarcPublishing/src/V1/PublishResponse.php
@@ -0,0 +1,33 @@
+google.cloud.eventarc.publishing.v1.PublishResponse
+ */
+class PublishResponse extends \Google\Protobuf\Internal\Message
+{
+
+ /**
+ * Constructor.
+ *
+ * @param array $data {
+ * Optional. Data for populating the Message object.
+ *
+ * }
+ */
+ public function __construct($data = NULL) {
+ \GPBMetadata\Google\Cloud\Eventarc\Publishing\V1\Publisher::initOnce();
+ parent::__construct($data);
+ }
+
+}
+
diff --git a/EventarcPublishing/src/V1/gapic_metadata.json b/EventarcPublishing/src/V1/gapic_metadata.json
index ea1b74edc86..8c15efbe6be 100644
--- a/EventarcPublishing/src/V1/gapic_metadata.json
+++ b/EventarcPublishing/src/V1/gapic_metadata.json
@@ -10,6 +10,11 @@
"grpc": {
"libraryClient": "PublisherGapicClient",
"rpcs": {
+ "Publish": {
+ "methods": [
+ "publish"
+ ]
+ },
"PublishChannelConnectionEvents": {
"methods": [
"publishChannelConnectionEvents"
diff --git a/EventarcPublishing/src/V1/resources/publisher_client_config.json b/EventarcPublishing/src/V1/resources/publisher_client_config.json
index 4eca798f5b1..8e360d5b887 100644
--- a/EventarcPublishing/src/V1/resources/publisher_client_config.json
+++ b/EventarcPublishing/src/V1/resources/publisher_client_config.json
@@ -26,6 +26,11 @@
}
},
"methods": {
+ "Publish": {
+ "timeout_millis": 60000,
+ "retry_codes_name": "no_retry_1_codes",
+ "retry_params_name": "no_retry_1_params"
+ },
"PublishChannelConnectionEvents": {
"timeout_millis": 60000,
"retry_codes_name": "no_retry_1_codes",
diff --git a/EventarcPublishing/src/V1/resources/publisher_descriptor_config.php b/EventarcPublishing/src/V1/resources/publisher_descriptor_config.php
index ebce97ea4ab..bff99c08e67 100644
--- a/EventarcPublishing/src/V1/resources/publisher_descriptor_config.php
+++ b/EventarcPublishing/src/V1/resources/publisher_descriptor_config.php
@@ -23,6 +23,18 @@
return [
'interfaces' => [
'google.cloud.eventarc.publishing.v1.Publisher' => [
+ 'Publish' => [
+ 'callType' => \Google\ApiCore\Call::UNARY_CALL,
+ 'responseType' => 'Google\Cloud\Eventarc\Publishing\V1\PublishResponse',
+ 'headerParams' => [
+ [
+ 'keyName' => 'message_bus',
+ 'fieldAccessors' => [
+ 'getMessageBus',
+ ],
+ ],
+ ],
+ ],
'PublishChannelConnectionEvents' => [
'callType' => \Google\ApiCore\Call::UNARY_CALL,
'responseType' => 'Google\Cloud\Eventarc\Publishing\V1\PublishChannelConnectionEventsResponse',
diff --git a/EventarcPublishing/src/V1/resources/publisher_rest_client_config.php b/EventarcPublishing/src/V1/resources/publisher_rest_client_config.php
index 8922a23ca60..5730c0aa7b5 100644
--- a/EventarcPublishing/src/V1/resources/publisher_rest_client_config.php
+++ b/EventarcPublishing/src/V1/resources/publisher_rest_client_config.php
@@ -23,6 +23,18 @@
return [
'interfaces' => [
'google.cloud.eventarc.publishing.v1.Publisher' => [
+ 'Publish' => [
+ 'method' => 'post',
+ 'uriTemplate' => '/v1/{message_bus=projects/*/locations/*/messageBuses/*}:publish',
+ 'body' => '*',
+ 'placeholders' => [
+ 'message_bus' => [
+ 'getters' => [
+ 'getMessageBus',
+ ],
+ ],
+ ],
+ ],
'PublishChannelConnectionEvents' => [
'method' => 'post',
'uriTemplate' => '/v1/{channel_connection=projects/*/locations/*/channelConnections/*}:publishEvents',
diff --git a/EventarcPublishing/tests/Unit/V1/Client/PublisherClientTest.php b/EventarcPublishing/tests/Unit/V1/Client/PublisherClientTest.php
index e65da6bd505..49c8165ab0d 100644
--- a/EventarcPublishing/tests/Unit/V1/Client/PublisherClientTest.php
+++ b/EventarcPublishing/tests/Unit/V1/Client/PublisherClientTest.php
@@ -31,6 +31,8 @@
use Google\Cloud\Eventarc\Publishing\V1\PublishChannelConnectionEventsResponse;
use Google\Cloud\Eventarc\Publishing\V1\PublishEventsRequest;
use Google\Cloud\Eventarc\Publishing\V1\PublishEventsResponse;
+use Google\Cloud\Eventarc\Publishing\V1\PublishRequest;
+use Google\Cloud\Eventarc\Publishing\V1\PublishResponse;
use Google\Rpc\Code;
use stdClass;
@@ -64,6 +66,69 @@ private function createClient(array $options = [])
return new PublisherClient($options);
}
+ /** @test */
+ public function publishTest()
+ {
+ $transport = $this->createTransport();
+ $gapicClient = $this->createClient([
+ 'transport' => $transport,
+ ]);
+ $this->assertTrue($transport->isExhausted());
+ // Mock response
+ $expectedResponse = new PublishResponse();
+ $transport->addResponse($expectedResponse);
+ // Mock request
+ $messageBus = 'messageBus-872787384';
+ $request = (new PublishRequest())->setMessageBus($messageBus);
+ $response = $gapicClient->publish($request);
+ $this->assertEquals($expectedResponse, $response);
+ $actualRequests = $transport->popReceivedCalls();
+ $this->assertSame(1, count($actualRequests));
+ $actualFuncCall = $actualRequests[0]->getFuncCall();
+ $actualRequestObject = $actualRequests[0]->getRequestObject();
+ $this->assertSame('/google.cloud.eventarc.publishing.v1.Publisher/Publish', $actualFuncCall);
+ $actualValue = $actualRequestObject->getMessageBus();
+ $this->assertProtobufEquals($messageBus, $actualValue);
+ $this->assertTrue($transport->isExhausted());
+ }
+
+ /** @test */
+ public function publishExceptionTest()
+ {
+ $transport = $this->createTransport();
+ $gapicClient = $this->createClient([
+ 'transport' => $transport,
+ ]);
+ $this->assertTrue($transport->isExhausted());
+ $status = new stdClass();
+ $status->code = Code::DATA_LOSS;
+ $status->details = 'internal error';
+ $expectedExceptionMessage = json_encode(
+ [
+ 'message' => 'internal error',
+ 'code' => Code::DATA_LOSS,
+ 'status' => 'DATA_LOSS',
+ 'details' => [],
+ ],
+ JSON_PRETTY_PRINT
+ );
+ $transport->addResponse(null, $status);
+ // Mock request
+ $messageBus = 'messageBus-872787384';
+ $request = (new PublishRequest())->setMessageBus($messageBus);
+ try {
+ $gapicClient->publish($request);
+ // If the $gapicClient method call did not throw, fail the test
+ $this->fail('Expected an ApiException, but no exception was thrown.');
+ } catch (ApiException $ex) {
+ $this->assertEquals($status->code, $ex->getCode());
+ $this->assertEquals($expectedExceptionMessage, $ex->getMessage());
+ }
+ // Call popReceivedCalls to ensure the stub is exhausted
+ $transport->popReceivedCalls();
+ $this->assertTrue($transport->isExhausted());
+ }
+
/** @test */
public function publishChannelConnectionEventsTest()
{
@@ -182,7 +247,7 @@ public function publishEventsExceptionTest()
}
/** @test */
- public function publishChannelConnectionEventsAsyncTest()
+ public function publishAsyncTest()
{
$transport = $this->createTransport();
$gapicClient = $this->createClient([
@@ -190,19 +255,20 @@ public function publishChannelConnectionEventsAsyncTest()
]);
$this->assertTrue($transport->isExhausted());
// Mock response
- $expectedResponse = new PublishChannelConnectionEventsResponse();
+ $expectedResponse = new PublishResponse();
$transport->addResponse($expectedResponse);
- $request = new PublishChannelConnectionEventsRequest();
- $response = $gapicClient->publishChannelConnectionEventsAsync($request)->wait();
+ // Mock request
+ $messageBus = 'messageBus-872787384';
+ $request = (new PublishRequest())->setMessageBus($messageBus);
+ $response = $gapicClient->publishAsync($request)->wait();
$this->assertEquals($expectedResponse, $response);
$actualRequests = $transport->popReceivedCalls();
$this->assertSame(1, count($actualRequests));
$actualFuncCall = $actualRequests[0]->getFuncCall();
$actualRequestObject = $actualRequests[0]->getRequestObject();
- $this->assertSame(
- '/google.cloud.eventarc.publishing.v1.Publisher/PublishChannelConnectionEvents',
- $actualFuncCall
- );
+ $this->assertSame('/google.cloud.eventarc.publishing.v1.Publisher/Publish', $actualFuncCall);
+ $actualValue = $actualRequestObject->getMessageBus();
+ $this->assertProtobufEquals($messageBus, $actualValue);
$this->assertTrue($transport->isExhausted());
}
}