Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,24 @@
from google.cloud.eventarc_publishing_v1.services.publisher.client import (
PublisherClient,
)
from google.cloud.eventarc_publishing_v1.types.cloud_event import CloudEvent
from google.cloud.eventarc_publishing_v1.types.publisher import (
PublishChannelConnectionEventsRequest,
PublishChannelConnectionEventsResponse,
PublishEventsRequest,
PublishEventsResponse,
PublishRequest,
PublishResponse,
)

__all__ = (
"PublisherClient",
"PublisherAsyncClient",
"CloudEvent",
"PublishChannelConnectionEventsRequest",
"PublishChannelConnectionEventsResponse",
"PublishEventsRequest",
"PublishEventsResponse",
"PublishRequest",
"PublishResponse",
)
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.6.12" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,24 @@


from .services.publisher import PublisherAsyncClient, PublisherClient
from .types.cloud_event import CloudEvent
from .types.publisher import (
PublishChannelConnectionEventsRequest,
PublishChannelConnectionEventsResponse,
PublishEventsRequest,
PublishEventsResponse,
PublishRequest,
PublishResponse,
)

__all__ = (
"PublisherAsyncClient",
"CloudEvent",
"PublishChannelConnectionEventsRequest",
"PublishChannelConnectionEventsResponse",
"PublishEventsRequest",
"PublishEventsResponse",
"PublishRequest",
"PublishResponse",
"PublisherClient",
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
"grpc": {
"libraryClient": "PublisherClient",
"rpcs": {
"Publish": {
"methods": [
"publish"
]
},
"PublishChannelConnectionEvents": {
"methods": [
"publish_channel_connection_events"
Expand All @@ -25,6 +30,11 @@
"grpc-async": {
"libraryClient": "PublisherAsyncClient",
"rpcs": {
"Publish": {
"methods": [
"publish"
]
},
"PublishChannelConnectionEvents": {
"methods": [
"publish_channel_connection_events"
Expand All @@ -40,6 +50,11 @@
"rest": {
"libraryClient": "PublisherClient",
"rpcs": {
"Publish": {
"methods": [
"publish"
]
},
"PublishChannelConnectionEvents": {
"methods": [
"publish_channel_connection_events"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.6.12" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,98 @@ async def sample_publish_events():
# Done; return the response.
return response

async def publish(
self,
request: Optional[Union[publisher.PublishRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> publisher.PublishResponse:
r"""Publish events to a message bus.

.. code-block:: python

# This snippet 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 as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import eventarc_publishing_v1

async def sample_publish():
# Create a client
client = eventarc_publishing_v1.PublisherAsyncClient()

# Initialize request argument(s)
proto_message = eventarc_publishing_v1.CloudEvent()
proto_message.binary_data = b'binary_data_blob'
proto_message.id = "id_value"
proto_message.source = "source_value"
proto_message.spec_version = "spec_version_value"
proto_message.type_ = "type__value"

request = eventarc_publishing_v1.PublishRequest(
proto_message=proto_message,
message_bus="message_bus_value",
)

# Make the request
response = await client.publish(request=request)

# Handle the response
print(response)

Args:
request (Optional[Union[google.cloud.eventarc_publishing_v1.types.PublishRequest, dict]]):
The request object. The request message for the Publish
method.
retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.

Returns:
google.cloud.eventarc_publishing_v1.types.PublishResponse:
The response message for the Publish
method.

"""
# Create or coerce a protobuf request object.
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, publisher.PublishRequest):
request = publisher.PublishRequest(request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._client._transport._wrapped_methods[self._client._transport.publish]

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("message_bus", request.message_bus),)
),
)

# Validate the universe domain.
self._client._validate_universe_domain()

# Send the request.
response = await rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

async def __aenter__(self) -> "PublisherAsyncClient":
return self

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,98 @@ def sample_publish_events():
# Done; return the response.
return response

def publish(
self,
request: Optional[Union[publisher.PublishRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> publisher.PublishResponse:
r"""Publish events to a message bus.

.. code-block:: python

# This snippet 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 as shown in:
# https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import eventarc_publishing_v1

def sample_publish():
# Create a client
client = eventarc_publishing_v1.PublisherClient()

# Initialize request argument(s)
proto_message = eventarc_publishing_v1.CloudEvent()
proto_message.binary_data = b'binary_data_blob'
proto_message.id = "id_value"
proto_message.source = "source_value"
proto_message.spec_version = "spec_version_value"
proto_message.type_ = "type__value"

request = eventarc_publishing_v1.PublishRequest(
proto_message=proto_message,
message_bus="message_bus_value",
)

# Make the request
response = client.publish(request=request)

# Handle the response
print(response)

Args:
request (Union[google.cloud.eventarc_publishing_v1.types.PublishRequest, dict]):
The request object. The request message for the Publish
method.
retry (google.api_core.retry.Retry): Designation of what errors, if any,
should be retried.
timeout (float): The timeout for this request.
metadata (Sequence[Tuple[str, str]]): Strings which should be
sent along with the request as metadata.

Returns:
google.cloud.eventarc_publishing_v1.types.PublishResponse:
The response message for the Publish
method.

"""
# Create or coerce a protobuf request object.
# - Use the request object if provided (there's no risk of modifying the input as
# there are no flattened fields), or create one.
if not isinstance(request, publisher.PublishRequest):
request = publisher.PublishRequest(request)

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
rpc = self._transport._wrapped_methods[self._transport.publish]

# Certain fields should be provided within the metadata header;
# add these here.
metadata = tuple(metadata) + (
gapic_v1.routing_header.to_grpc_metadata(
(("message_bus", request.message_bus),)
),
)

# Validate the universe domain.
self._validate_universe_domain()

# Send the request.
response = rpc(
request,
retry=retry,
timeout=timeout,
metadata=metadata,
)

# Done; return the response.
return response

def __enter__(self) -> "PublisherClient":
return self

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ def _prep_wrapped_messages(self, client_info):
default_timeout=None,
client_info=client_info,
),
self.publish: gapic_v1.method.wrap_method(
self.publish,
default_timeout=60.0,
client_info=client_info,
),
}

def close(self):
Expand Down Expand Up @@ -172,6 +177,15 @@ def publish_events(
]:
raise NotImplementedError()

@property
def publish(
self,
) -> Callable[
[publisher.PublishRequest],
Union[publisher.PublishResponse, Awaitable[publisher.PublishResponse]],
]:
raise NotImplementedError()

@property
def kind(self) -> str:
raise NotImplementedError()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,32 @@ def publish_events(
)
return self._stubs["publish_events"]

@property
def publish(
self,
) -> Callable[[publisher.PublishRequest], publisher.PublishResponse]:
r"""Return a callable for the publish method over gRPC.

Publish events to a message bus.

Returns:
Callable[[~.PublishRequest],
~.PublishResponse]:
A function that, when called, will call the underlying RPC
on the server.
"""
# Generate a "stub function" on-the-fly which will actually make
# the request.
# gRPC handles serialization and deserialization, so we just need
# to pass in the functions for each.
if "publish" not in self._stubs:
self._stubs["publish"] = self.grpc_channel.unary_unary(
"/google.cloud.eventarc.publishing.v1.Publisher/Publish",
request_serializer=publisher.PublishRequest.serialize,
response_deserializer=publisher.PublishResponse.deserialize,
)
return self._stubs["publish"]

def close(self):
self.grpc_channel.close()

Expand Down
Loading