Skip to content

Commit

Permalink
chore: remove string replacement in owlbot.py (#469)
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 389879008

Source-Link: googleapis/googleapis@7b6a2ce

Source-Link: googleapis/googleapis-gen@3443eec
  • Loading branch information
gcf-owl-bot[bot] committed Aug 13, 2021
1 parent af8c126 commit 9e9d068
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 99 deletions.
1 change: 1 addition & 0 deletions google/pubsub_v1/services/publisher/async_client.py
Expand Up @@ -29,6 +29,7 @@

from google.iam.v1 import iam_policy_pb2 # type: ignore
from google.iam.v1 import policy_pb2 # type: ignore
from google.protobuf import duration_pb2 # type: ignore
from google.pubsub_v1.services.publisher import pagers
from google.pubsub_v1.types import pubsub
from google.pubsub_v1.types import TimeoutType
Expand Down
1 change: 1 addition & 0 deletions google/pubsub_v1/services/publisher/client.py
Expand Up @@ -34,6 +34,7 @@

from google.iam.v1 import iam_policy_pb2 # type: ignore
from google.iam.v1 import policy_pb2 # type: ignore
from google.protobuf import duration_pb2 # type: ignore
from google.pubsub_v1.services.publisher import pagers
from google.pubsub_v1.types import pubsub
from google.pubsub_v1.types import TimeoutType
Expand Down
4 changes: 4 additions & 0 deletions google/pubsub_v1/services/schema_service/async_client.py
Expand Up @@ -509,6 +509,8 @@ async def validate_schema(
Returns:
google.pubsub_v1.types.ValidateSchemaResponse:
Response for the ValidateSchema method.
Empty for now.
"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
Expand Down Expand Up @@ -572,6 +574,8 @@ async def validate_message(
Returns:
google.pubsub_v1.types.ValidateMessageResponse:
Response for the ValidateMessage method.
Empty for now.
"""
# Create or coerce a protobuf request object.
request = schema.ValidateMessageRequest(request)
Expand Down
4 changes: 4 additions & 0 deletions google/pubsub_v1/services/schema_service/client.py
Expand Up @@ -693,6 +693,8 @@ def validate_schema(
Returns:
google.pubsub_v1.types.ValidateSchemaResponse:
Response for the ValidateSchema method.
Empty for now.
"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
Expand Down Expand Up @@ -756,6 +758,8 @@ def validate_message(
Returns:
google.pubsub_v1.types.ValidateMessageResponse:
Response for the ValidateMessage method.
Empty for now.
"""
# Create or coerce a protobuf request object.
# Minor optimization to avoid making a copy if the user passes
Expand Down
5 changes: 3 additions & 2 deletions google/pubsub_v1/types/pubsub.py
Expand Up @@ -494,8 +494,9 @@ class Subscription(proto.Message):
then messages are not expunged from the subscription's
backlog, even if they are acknowledged, until they fall out
of the ``message_retention_duration`` window. This must be
true if you would like to [Seek to a timestamp]
(https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time).
true if you would like to [``Seek`` to a timestamp]
(https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time)
in the past to replay previously-acknowledged messages.
message_retention_duration (google.protobuf.duration_pb2.Duration):
How long to retain unacknowledged messages in the
subscription's backlog, from the moment a message is
Expand Down
4 changes: 2 additions & 2 deletions google/pubsub_v1/types/schema.py
Expand Up @@ -195,7 +195,7 @@ class ValidateSchemaRequest(proto.Message):


class ValidateSchemaResponse(proto.Message):
r"""Response for the ``ValidateSchema`` method. """
r"""Response for the ``ValidateSchema`` method. Empty for now. """


class ValidateMessageRequest(proto.Message):
Expand Down Expand Up @@ -227,7 +227,7 @@ class ValidateMessageRequest(proto.Message):


class ValidateMessageResponse(proto.Message):
r"""Response for the ``ValidateMessage`` method. """
r"""Response for the ``ValidateMessage`` method. Empty for now. """


__all__ = tuple(sorted(__protobuf__.manifest))
93 changes: 0 additions & 93 deletions owlbot.py
Expand Up @@ -299,99 +299,6 @@
),
)

# Add development feature `message_retention_duration` from pubsub_dev branch of googleapis
# See PR https://github.com/googleapis/python-pubsub/pull/456
count = s.replace(
library / f"google/pubsub_{library.name}/types/pubsub.py",
"""satisfies_pzs \(bool\):
Reserved for future use. This field is set
only in responses from the server; it is ignored
if it is set in any requests.""",
"""satisfies_pzs (bool):
Reserved for future use. This field is set
only in responses from the server; it is ignored
if it is set in any requests.
message_retention_duration (google.protobuf.duration_pb2.Duration):
Indicates the minimum duration to retain a message after it
is published to the topic. If this field is set, messages
published to the topic in the last
``message_retention_duration`` are always available to
subscribers. For instance, it allows any attached
subscription to `seek to a
timestamp <https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time>`__
that is up to ``message_retention_duration`` in the past. If
this field is not set, message retention is controlled by
settings on individual subscriptions. Cannot be more than 7
days or less than 10 minutes."""
)

# Add development feature `message_retention_duration` from pubsub_dev branch of googleapis
# See PR https://github.com/googleapis/python-pubsub/pull/456
count += s.replace(
library / f"google/pubsub_{library.name}/types/pubsub.py",
"""satisfies_pzs = proto.Field\(
proto.BOOL,
number=7,
\)""",
"""satisfies_pzs = proto.Field(
proto.BOOL,
number=7,
)
message_retention_duration = proto.Field(
proto.MESSAGE, number=8, message=duration_pb2.Duration,
)"""
)

# Add development feature `topic_message_retention_duration` from pubsub_dev branch of googleapis
# See PR https://github.com/googleapis/python-pubsub/pull/456
count += s.replace(
library / f"google/pubsub_{library.name}/types/pubsub.py",
"""detached \(bool\):
Indicates whether the subscription is detached from its
topic. Detached subscriptions don't receive messages from
their topic and don't retain any backlog. ``Pull`` and
``StreamingPull`` requests will return FAILED_PRECONDITION.
If the subscription is a push subscription, pushes to the
endpoint will not be made.""",
"""detached (bool):
Indicates whether the subscription is detached from its
topic. Detached subscriptions don't receive messages from
their topic and don't retain any backlog. ``Pull`` and
``StreamingPull`` requests will return FAILED_PRECONDITION.
If the subscription is a push subscription, pushes to the
endpoint will not be made.
topic_message_retention_duration (google.protobuf.duration_pb2.Duration):
Output only. Indicates the minimum duration for which a
message is retained after it is published to the
subscription's topic. If this field is set, messages
published to the subscription's topic in the last
``topic_message_retention_duration`` are always available to
subscribers. See the ``message_retention_duration`` field in
``Topic``. This field is set only in responses from the
server; it is ignored if it is set in any requests."""
)

# Add development feature `topic_message_retention_duration` from pubsub_dev branch of googleapis
# See PR https://github.com/googleapis/python-pubsub/pull/456
count += s.replace(
library / f"google/pubsub_{library.name}/types/pubsub.py",
"""detached = proto.Field\(
proto.BOOL,
number=15,
\)""",
"""detached = proto.Field(
proto.BOOL,
number=15,
)
topic_message_retention_duration = proto.Field(
proto.MESSAGE, number=17, message=duration_pb2.Duration,
)
"""
)

if count != 4:
raise Exception("Pub/Sub topic retention feature not added")

# The namespace package declaration in google/cloud/__init__.py should be excluded
# from coverage.
count = s.replace(
Expand Down
4 changes: 2 additions & 2 deletions scripts/fixup_pubsub_v1_keywords.py
Expand Up @@ -42,8 +42,8 @@ class pubsubCallTransformer(cst.CSTTransformer):
'acknowledge': ('subscription', 'ack_ids', ),
'create_schema': ('parent', 'schema', 'schema_id', ),
'create_snapshot': ('name', 'subscription', 'labels', ),
'create_subscription': ('name', 'topic', 'push_config', 'ack_deadline_seconds', 'retain_acked_messages', 'message_retention_duration', 'labels', 'enable_message_ordering', 'expiration_policy', 'filter', 'dead_letter_policy', 'retry_policy', 'detached', ),
'create_topic': ('name', 'labels', 'message_storage_policy', 'kms_key_name', 'schema_settings', 'satisfies_pzs', ),
'create_subscription': ('name', 'topic', 'push_config', 'ack_deadline_seconds', 'retain_acked_messages', 'message_retention_duration', 'labels', 'enable_message_ordering', 'expiration_policy', 'filter', 'dead_letter_policy', 'retry_policy', 'detached', 'topic_message_retention_duration', ),
'create_topic': ('name', 'labels', 'message_storage_policy', 'kms_key_name', 'schema_settings', 'satisfies_pzs', 'message_retention_duration', ),
'delete_schema': ('name', ),
'delete_snapshot': ('snapshot', ),
'delete_subscription': ('subscription', ),
Expand Down
1 change: 1 addition & 0 deletions tests/unit/gapic/pubsub_v1/test_publisher.py
Expand Up @@ -35,6 +35,7 @@
from google.iam.v1 import options_pb2 # type: ignore
from google.iam.v1 import policy_pb2 # type: ignore
from google.oauth2 import service_account
from google.protobuf import duration_pb2 # type: ignore
from google.protobuf import field_mask_pb2 # type: ignore
from google.protobuf import timestamp_pb2 # type: ignore
from google.pubsub_v1.services.publisher import PublisherAsyncClient
Expand Down

0 comments on commit 9e9d068

Please sign in to comment.