Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-generated pubsub: add kms key and remove BETA warnings #7936

Merged
merged 1 commit into from
May 13, 2019
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
39 changes: 26 additions & 13 deletions pubsub/google/cloud/pubsub_v1/gapic/publisher_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@ def from_service_account_file(cls, filename, *args, **kwargs):
from_service_account_json = from_service_account_file

@classmethod
def topic_path(cls, project, topic):
"""Return a fully-qualified topic string."""
def project_path(cls, project):
"""Return a fully-qualified project string."""
return google.api_core.path_template.expand(
"projects/{project}/topics/{topic}", project=project, topic=topic
"projects/{project}", project=project
)

@classmethod
def project_path(cls, project):
"""Return a fully-qualified project string."""
def topic_path(cls, project, topic):
"""Return a fully-qualified topic string."""
return google.api_core.path_template.expand(
"projects/{project}", project=project
"projects/{project}/topics/{topic}", project=project, topic=topic
)

def __init__(
Expand Down Expand Up @@ -200,6 +200,7 @@ def create_topic(
name,
labels=None,
message_storage_policy=None,
kms_key_name=None,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
Expand Down Expand Up @@ -235,6 +236,14 @@ def create_topic(

If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.pubsub_v1.types.MessageStoragePolicy`
kms_key_name (str): The resource name of the Cloud KMS CryptoKey to be used to protect
access to messages published on this topic.

The expected format is
``projects/*/locations/*/keyRings/*/cryptoKeys/*``. EXPERIMENTAL: This
feature is part of a closed alpha release. This API might be changed in
backward-incompatible ways and is not recommended for production use. It
is not subject to any SLA or deprecation policy.
retry (Optional[google.api_core.retry.Retry]): A retry object used
to retry requests. If ``None`` is specified, requests will not
be retried.
Expand Down Expand Up @@ -266,7 +275,10 @@ def create_topic(
)

request = pubsub_pb2.Topic(
name=name, labels=labels, message_storage_policy=message_storage_policy
name=name,
labels=labels,
message_storage_policy=message_storage_policy,
kms_key_name=kms_key_name,
)
if metadata is None:
metadata = []
Expand Down Expand Up @@ -825,8 +837,7 @@ def set_iam_policy(

Args:
resource (str): REQUIRED: The resource for which the policy is being specified.
``resource`` is usually specified as a path. For example, a Project
resource is specified as ``projects/{project}``.
See the operation documentation for the appropriate value for this field.
policy (Union[dict, ~google.cloud.pubsub_v1.types.Policy]): REQUIRED: The complete policy to be applied to the ``resource``. The
size of the policy is limited to a few 10s of KB. An empty policy is a
valid policy but certain Cloud Platform services (such as Projects)
Expand Down Expand Up @@ -905,8 +916,7 @@ def get_iam_policy(

Args:
resource (str): REQUIRED: The resource for which the policy is being requested.
``resource`` is usually specified as a path. For example, a Project
resource is specified as ``projects/{project}``.
See the operation documentation for the appropriate value for this field.
retry (Optional[google.api_core.retry.Retry]): A retry object used
to retry requests. If ``None`` is specified, requests will not
be retried.
Expand Down Expand Up @@ -968,6 +978,10 @@ def test_iam_permissions(
resource does not exist, this will return an empty set of permissions,
not a NOT\_FOUND error.

Note: This operation is designed to be used for building
permission-aware UIs and command-line tools, not for authorization
checking. This operation may "fail open" without warning.

Example:
>>> from google.cloud import pubsub_v1
>>>
Expand All @@ -982,8 +996,7 @@ def test_iam_permissions(

Args:
resource (str): REQUIRED: The resource for which the policy detail is being requested.
``resource`` is usually specified as a path. For example, a Project
resource is specified as ``projects/{project}``.
See the operation documentation for the appropriate value for this field.
permissions (list[str]): The set of permissions to check for the ``resource``. Permissions with
wildcards (such as '*' or 'storage.*') are not allowed. For more
information see `IAM
Expand Down
94 changes: 35 additions & 59 deletions pubsub/google/cloud/pubsub_v1/gapic/subscriber_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,6 @@ def from_service_account_file(cls, filename, *args, **kwargs):

from_service_account_json = from_service_account_file

@classmethod
def subscription_path(cls, project, subscription):
"""Return a fully-qualified subscription string."""
return google.api_core.path_template.expand(
"projects/{project}/subscriptions/{subscription}",
project=project,
subscription=subscription,
)

@classmethod
def topic_path(cls, project, topic):
"""Return a fully-qualified topic string."""
return google.api_core.path_template.expand(
"projects/{project}/topics/{topic}", project=project, topic=topic
)

@classmethod
def project_path(cls, project):
"""Return a fully-qualified project string."""
Expand All @@ -117,6 +101,22 @@ def snapshot_path(cls, project, snapshot):
snapshot=snapshot,
)

@classmethod
def subscription_path(cls, project, subscription):
"""Return a fully-qualified subscription string."""
return google.api_core.path_template.expand(
"projects/{project}/subscriptions/{subscription}",
project=project,
subscription=subscription,
)

@classmethod
def topic_path(cls, project, topic):
"""Return a fully-qualified topic string."""
return google.api_core.path_template.expand(
"projects/{project}/topics/{topic}", project=project, topic=topic
)

def __init__(
self,
transport=None,
Expand Down Expand Up @@ -293,19 +293,13 @@ def create_subscription(
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. BETA: This feature is part of a beta
release. This API might be changed in backward-incompatible ways and is
not recommended for production use. It is not subject to any SLA or
deprecation policy.
like to Seek to a timestamp.
message_retention_duration (Union[dict, ~google.cloud.pubsub_v1.types.Duration]): How long to retain unacknowledged messages in the subscription's
backlog, from the moment a message is published. If
``retain_acked_messages`` is true, then this also configures the
retention of acknowledged messages, and thus configures how far back in
time a ``Seek`` can be done. Defaults to 7 days. Cannot be more than 7
days or less than 10 minutes. BETA: This feature is part of a beta
release. This API might be changed in backward-incompatible ways and is
not recommended for production use. It is not subject to any SLA or
deprecation policy.
days or less than 10 minutes.

If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.pubsub_v1.types.Duration`
Expand All @@ -323,10 +317,7 @@ def create_subscription(
subscriber is successfully consuming messages from the subscription or
is issuing operations on the subscription. If ``expiration_policy`` is
not set, a *default policy* with ``ttl`` of 31 days will be used. The
minimum allowed value for ``expiration_policy.ttl`` is 1 day. BETA: This
feature is part of a beta release. This API might be changed in
backward-incompatible ways and is not recommended for production use. It
is not subject to any SLA or deprecation policy.
minimum allowed value for ``expiration_policy.ttl`` is 1 day.

If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.pubsub_v1.types.ExpirationPolicy`
Expand Down Expand Up @@ -1151,10 +1142,7 @@ def list_snapshots(
operations, which allow
you to manage message acknowledgments in bulk. That is, you can set the
acknowledgment state of messages in an existing subscription to the state
captured by a snapshot.<br><br>
<b>BETA:</b> This feature is part of a beta release. This API might be
changed in backward-incompatible ways and is not recommended for production
use. It is not subject to any SLA or deprecation policy.
captured by a snapshot.

Example:
>>> from google.cloud import pubsub_v1
Expand Down Expand Up @@ -1260,15 +1248,12 @@ def create_snapshot(
Creates a snapshot from the requested subscription. Snapshots are used
in Seek operations, which allow you to manage message acknowledgments in
bulk. That is, you can set the acknowledgment state of messages in an
existing subscription to the state captured by a snapshot. BETA: This
feature is part of a beta release. This API might be changed in
backward-incompatible ways and is not recommended for production use. It
is not subject to any SLA or deprecation policy. If the snapshot already
exists, returns ``ALREADY_EXISTS``. If the requested subscription
doesn't exist, returns ``NOT_FOUND``. If the backlog in the subscription
is too old -- and the resulting snapshot would expire in less than 1
hour -- then ``FAILED_PRECONDITION`` is returned. See also the
``Snapshot.expire_time`` field. If the name is not provided in the
existing subscription to the state captured by a snapshot. If the
snapshot already exists, returns ``ALREADY_EXISTS``. If the requested
subscription doesn't exist, returns ``NOT_FOUND``. If the backlog in the
subscription is too old -- and the resulting snapshot would expire in
less than 1 hour -- then ``FAILED_PRECONDITION`` is returned. See also
the ``Snapshot.expire_time`` field. If the name is not provided in the
request, the server will assign a random name for this snapshot on the
same project as the subscription, conforming to the `resource name
format <https://cloud.google.com/pubsub/docs/admin#resource_names>`__.
Expand Down Expand Up @@ -1365,11 +1350,7 @@ def update_snapshot(
operations, which allow
you to manage message acknowledgments in bulk. That is, you can set the
acknowledgment state of messages in an existing subscription to the state
captured by a snapshot.<br><br>
<b>BETA:</b> This feature is part of a beta release. This API might be
changed in backward-incompatible ways and is not recommended for production
use. It is not subject to any SLA or deprecation policy.
Note that certain properties of a snapshot are not modifiable.
captured by a snapshot.

Example:
>>> from google.cloud import pubsub_v1
Expand Down Expand Up @@ -1459,9 +1440,6 @@ def delete_snapshot(
you to manage message acknowledgments in bulk. That is, you can set the
acknowledgment state of messages in an existing subscription to the state
captured by a snapshot.<br><br>
<b>BETA:</b> This feature is part of a beta release. This API might be
changed in backward-incompatible ways and is not recommended for production
use. It is not subject to any SLA or deprecation policy.
When the snapshot is deleted, all messages retained in the snapshot
are immediately dropped. After a snapshot is deleted, a new one may be
created with the same name, but the new one has no association with the old
Expand Down Expand Up @@ -1541,10 +1519,7 @@ def seek(
you to manage message acknowledgments in bulk. That is, you can set the
acknowledgment state of messages in an existing subscription to the state
captured by a snapshot. Note that both the subscription and the snapshot
must be on the same topic.<br><br>
<b>BETA:</b> This feature is part of a beta release. This API might be
changed in backward-incompatible ways and is not recommended for production
use. It is not subject to any SLA or deprecation policy.
must be on the same topic.

Example:
>>> from google.cloud import pubsub_v1
Expand Down Expand Up @@ -1651,8 +1626,7 @@ def set_iam_policy(

Args:
resource (str): REQUIRED: The resource for which the policy is being specified.
``resource`` is usually specified as a path. For example, a Project
resource is specified as ``projects/{project}``.
See the operation documentation for the appropriate value for this field.
policy (Union[dict, ~google.cloud.pubsub_v1.types.Policy]): REQUIRED: The complete policy to be applied to the ``resource``. The
size of the policy is limited to a few 10s of KB. An empty policy is a
valid policy but certain Cloud Platform services (such as Projects)
Expand Down Expand Up @@ -1731,8 +1705,7 @@ def get_iam_policy(

Args:
resource (str): REQUIRED: The resource for which the policy is being requested.
``resource`` is usually specified as a path. For example, a Project
resource is specified as ``projects/{project}``.
See the operation documentation for the appropriate value for this field.
retry (Optional[google.api_core.retry.Retry]): A retry object used
to retry requests. If ``None`` is specified, requests will not
be retried.
Expand Down Expand Up @@ -1794,6 +1767,10 @@ def test_iam_permissions(
resource does not exist, this will return an empty set of permissions,
not a NOT\_FOUND error.

Note: This operation is designed to be used for building
permission-aware UIs and command-line tools, not for authorization
checking. This operation may "fail open" without warning.

Example:
>>> from google.cloud import pubsub_v1
>>>
Expand All @@ -1808,8 +1785,7 @@ def test_iam_permissions(

Args:
resource (str): REQUIRED: The resource for which the policy detail is being requested.
``resource`` is usually specified as a path. For example, a Project
resource is specified as ``projects/{project}``.
See the operation documentation for the appropriate value for this field.
permissions (list[str]): The set of permissions to check for the ``resource``. Permissions with
wildcards (such as '*' or 'storage.*') are not allowed. For more
information see `IAM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ def test_iam_permissions(self):
resource does not exist, this will return an empty set of permissions,
not a NOT\_FOUND error.

Note: This operation is designed to be used for building
permission-aware UIs and command-line tools, not for authorization
checking. This operation may "fail open" without warning.

Returns:
Callable: A callable which accepts the appropriate
deserialized request object and returns a
Expand Down
Loading