Client( subscriber_options: typing.Union[ google.cloud.pubsub_v1.types.SubscriberOptions, typing.Sequence ] = (), **kwargs: typing.Any )A subscriber client for Google Cloud Pub/Sub.
This creates an object that is capable of subscribing to messages. Generally, you can instantiate this client with no arguments, and you get sensible defaults.
Properties
api
The underlying gapic API client.
.. versionchanged:: 2.10.0 Instead of a GAPIC SubscriberClient client instance, this property is a proxy object to it with the same interface.
api_endpoint
Return the API endpoint used by the client instance.
| Returns | |
|---|---|
| Type | Description |
str | The API endpoint used by the client instance. |
closed
Return whether the client has been closed and cannot be used anymore.
.. versionadded:: 2.8.0
open_telemetry_enabled
Returns True if Open Telemetry is enabled. False otherwise.
target
Return the target (where the API is).
transport
Returns the transport used by the client instance.
| Returns | |
|---|---|
| Type | Description |
SubscriberTransport | The transport used by the client instance. |
universe_domain
Return the universe domain used by the client instance.
| Returns | |
|---|---|
| Type | Description |
str | The universe domain used by the client instance. |
Methods
Client
Client( subscriber_options: typing.Union[ google.cloud.pubsub_v1.types.SubscriberOptions, typing.Sequence ] = (), **kwargs: typing.Any )Instantiates the subscriber client.
| Parameters | |
|---|---|
| Name | Description |
credentials | Optional[google.auth.credentials.Credentials] The authorization credentials to attach to requests. These credentials identify the application to the service; if none are specified, the client will attempt to ascertain the credentials from the environment. |
transport | Optional[Union[str,SubscriberTransport,Callable[..., SubscriberTransport]]] The transport to use, or a Callable that constructs and returns a new transport. If a Callable is given, it will be called with the same set of initialization arguments as used in the SubscriberTransport constructor. If set to None, a transport is chosen automatically. |
client_options | Optional[Union[google.api_core.client_options.ClientOptions, dict]] Custom options for the client. 1. The |
client_info | google.api_core.gapic_v1.client_info.ClientInfo The client info used to send a user-agent string along with API requests. If |
| Exceptions | |
|---|---|
| Type | Description |
google.auth.exceptions.MutualTLSChannelError | If mutual TLS transport creation failed for any reason. |
acknowledge
acknowledge( request: typing.Optional[ typing.Union[google.cloud.pubsub_v1.types.AcknowledgeRequest, dict] ] = None, *, subscription: typing.Optional[str] = None, ack_ids: typing.Optional[typing.MutableSequence[str]] = None, retry: typing.Optional[ typing.Union[ google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault, ] ] = _MethodDefault._DEFAULT_VALUE, timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = () ) -> NoneAcknowledges the messages associated with the ack_ids in the AcknowledgeRequest. The Pub/Sub system can remove the relevant messages from the subscription.
Acknowledging a message whose ack deadline has expired may succeed, but such a message may be redelivered later. Acknowledging a message more than once will not result in an error.
# 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 import pubsub_v1 def sample_acknowledge(): # Create a client client = pubsub_v1.SubscriberClient() # Initialize request argument(s) request = pubsub_v1.AcknowledgeRequest( subscription="subscription_value", ack_ids=['ack_ids_value1', 'ack_ids_value2'], ) # Make the request client.acknowledge(request=request) | Parameters | |
|---|---|
| Name | Description |
request | Union[google.pubsub_v1.types.AcknowledgeRequest, dict] The request object. Request for the Acknowledge method. |
subscription | str Required. The subscription whose message is being acknowledged. Format is |
ack_ids | MutableSequence[str] Required. The acknowledgment ID for the messages being acknowledged that was returned by the Pub/Sub system in the |
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, Union[str, bytes]]] Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type |
close
close() -> NoneClose the underlying channel to release socket resources.
After a channel has been closed, the client instance cannot be used anymore.
This method is idempotent.
common_billing_account_path
common_billing_account_path(billing_account: str) -> strReturns a fully-qualified billing_account string.
common_folder_path
common_folder_path(folder: str) -> strReturns a fully-qualified folder string.
common_location_path
common_location_path(project: str, location: str) -> strReturns a fully-qualified location string.
common_organization_path
common_organization_path(organization: str) -> strReturns a fully-qualified organization string.
common_project_path
common_project_path(project: str) -> strReturns a fully-qualified project string.
create_snapshot
create_snapshot( request: typing.Optional[ typing.Union[google.cloud.pubsub_v1.types.CreateSnapshotRequest, dict] ] = None, *, name: typing.Optional[str] = None, subscription: typing.Optional[str] = None, retry: typing.Optional[ typing.Union[ google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault, ] ] = _MethodDefault._DEFAULT_VALUE, timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = () ) -> google.cloud.pubsub_v1.types.SnapshotCreates a snapshot from the requested subscription. Snapshots are used in Seek <https://cloud.google.com/pubsub/docs/replay-overview>__ 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. 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. The generated name is populated in the returned Snapshot object. Note that for REST API requests, you must specify a name in the request.
# 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 import pubsub_v1 def sample_create_snapshot(): # Create a client client = pubsub_v1.SubscriberClient() # Initialize request argument(s) request = pubsub_v1.CreateSnapshotRequest( name="name_value", subscription="subscription_value", ) # Make the request response = client.create_snapshot(request=request) # Handle the response print(response) | Parameters | |
|---|---|
| Name | Description |
request | Union[google.pubsub_v1.types.CreateSnapshotRequest, dict] The request object. Request for the |
name | str Required. User-provided name for this snapshot. 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. Note that for REST API requests, you must specify a name. See the |
subscription | str Required. The subscription whose backlog the snapshot retains. Specifically, the created snapshot is guaranteed to retain: (a) The existing backlog on the subscription. More precisely, this is defined as the messages in the subscription's backlog that are unacknowledged upon the successful completion of the |
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, Union[str, bytes]]] Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type |
| Returns | |
|---|---|
| Type | Description |
google.pubsub_v1.types.Snapshot | A snapshot resource. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) 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. |
create_subscription
create_subscription( request: typing.Optional[ typing.Union[google.cloud.pubsub_v1.types.Subscription, dict] ] = None, *, name: typing.Optional[str] = None, topic: typing.Optional[str] = None, push_config: typing.Optional[google.cloud.pubsub_v1.types.PushConfig] = None, ack_deadline_seconds: typing.Optional[int] = None, retry: typing.Optional[ typing.Union[ google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault, ] ] = _MethodDefault._DEFAULT_VALUE, timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = () ) -> google.cloud.pubsub_v1.types.SubscriptionCreates a subscription to a given topic. See the resource name rules. If the subscription already exists, returns ALREADY_EXISTS. If the corresponding topic doesn't exist, returns NOT_FOUND.
If the name is not provided in the request, the server will assign a random name for this subscription on the same project as the topic, conforming to the resource name format. The generated name is populated in the returned Subscription object. Note that for REST API requests, you must specify a name in the request.
# 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 import pubsub_v1 def sample_create_subscription(): # Create a client client = pubsub_v1.SubscriberClient() # Initialize request argument(s) request = pubsub_v1.Subscription( name="name_value", topic="topic_value", ) # Make the request response = client.create_subscription(request=request) # Handle the response print(response) | Parameters | |
|---|---|
| Name | Description |
request | Union[google.pubsub_v1.types.Subscription, dict] The request object. A subscription resource. If none of |
name | str Required. The name of the subscription. It must have the format <code>+</code><code>) or percent signs (</code><code>%</code><code>). It must be between 3 and 255 characters in length, and it must not start with </code>"goog"<code>. This corresponds to the </code>name<code> field on the </code>request<code> instance; if </code>request is provided, this should not be set. |
topic | str Required. The name of the topic from which this subscription is receiving messages. Format is |
push_config | google.pubsub_v1.types.PushConfig Optional. If push delivery is used with this subscription, this field is used to configure it. This corresponds to the |
ack_deadline_seconds | int Optional. The approximate amount of time (on a best-effort basis) Pub/Sub waits for the subscriber to acknowledge receipt before resending the message. In the interval after the message is delivered and before it is acknowledged, it is considered to be outstanding. During that time period, the message will not be redelivered (on a best-effort basis). For pull subscriptions, this value is used as the initial value for the ack deadline. To override this value for a given message, call |
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, Union[str, bytes]]] Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type |
| Returns | |
|---|---|
| Type | Description |
google.pubsub_v1.types.Subscription | A subscription resource. If none of push_config, bigquery_config, or cloud_storage_config is set, then the subscriber will pull and ack messages using API methods. At most one of these fields may be set. |
delete_snapshot
delete_snapshot( request: typing.Optional[ typing.Union[google.cloud.pubsub_v1.types.DeleteSnapshotRequest, dict] ] = None, *, snapshot: typing.Optional[str] = None, retry: typing.Optional[ typing.Union[ google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault, ] ] = _MethodDefault._DEFAULT_VALUE, timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = () ) -> NoneRemoves an existing snapshot. 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. 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 snapshot or its subscription, unless the same subscription is specified.
# 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 import pubsub_v1 def sample_delete_snapshot(): # Create a client client = pubsub_v1.SubscriberClient() # Initialize request argument(s) request = pubsub_v1.DeleteSnapshotRequest( snapshot="snapshot_value", ) # Make the request client.delete_snapshot(request=request) | Parameters | |
|---|---|
| Name | Description |
request | Union[google.pubsub_v1.types.DeleteSnapshotRequest, dict] The request object. Request for the |
snapshot | str Required. The name of the snapshot to delete. Format is |
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, Union[str, bytes]]] Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type |
delete_subscription
delete_subscription( request: typing.Optional[ typing.Union[google.cloud.pubsub_v1.types.DeleteSubscriptionRequest, dict] ] = None, *, subscription: typing.Optional[str] = None, retry: typing.Optional[ typing.Union[ google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault, ] ] = _MethodDefault._DEFAULT_VALUE, timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = () ) -> NoneDeletes an existing subscription. All messages retained in the subscription are immediately dropped. Calls to Pull after deletion will return NOT_FOUND. After a subscription is deleted, a new one may be created with the same name, but the new one has no association with the old subscription or its topic unless the same topic is specified.
# 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 import pubsub_v1 def sample_delete_subscription(): # Create a client client = pubsub_v1.SubscriberClient() # Initialize request argument(s) request = pubsub_v1.DeleteSubscriptionRequest( subscription="subscription_value", ) # Make the request client.delete_subscription(request=request) | Parameters | |
|---|---|
| Name | Description |
request | Union[google.pubsub_v1.types.DeleteSubscriptionRequest, dict] The request object. Request for the DeleteSubscription method. |
subscription | str Required. The subscription to delete. Format is |
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, Union[str, bytes]]] Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type |
from_service_account_file
from_service_account_file( filename: str, **kwargs: typing.Any ) -> google.cloud.pubsub_v1.subscriber.client.ClientCreates an instance of this client using the provided credentials file.
from_service_account_info
from_service_account_info(info: dict, *args, **kwargs)Creates an instance of this client using the provided credentials info.
| Parameter | |
|---|---|
| Name | Description |
info | dict The service account private key info. |
| Returns | |
|---|---|
| Type | Description |
SubscriberClient | The constructed client. |
from_service_account_json
from_service_account_json( filename: str, **kwargs: typing.Any ) -> google.cloud.pubsub_v1.subscriber.client.ClientCreates an instance of this client using the provided credentials file.
get_iam_policy
get_iam_policy( request: typing.Optional[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest] = None, *, retry: typing.Optional[ typing.Union[ google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault, ] ] = _MethodDefault._DEFAULT_VALUE, timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = () ) -> google.iam.v1.policy_pb2.PolicyGets the IAM access control policy for a function.
Returns an empty policy if the function exists and does not have a policy set.
| Parameters | |
|---|---|
| Name | Description |
request | The request object. Request message for |
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, Union[str, bytes]]] Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type |
| Returns | |
|---|---|
| Type | Description |
| Defines an Identity and Access Management (IAM) policy. It is used to specify access control policies for Cloud Platform resources. A Policy is a collection of bindings. A binding binds one or more members to a single role. Members can be user accounts, service accounts, Google groups, and domains (such as G Suite). A role is a named list of permissions (defined by IAM or configured by users). A binding can optionally specify a condition, which is a logic expression that further constrains the role binding based on attributes about the request and/or target resource. **JSON Example** :: { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:[email protected]", "group:[email protected]", "domain:google.com", "serviceAccount:[email protected]" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": ["user:[email protected]"], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01t00:00:00.000z')",="" }="" }="" ]="" }="" **yaml="" example**="" ::="" bindings:="" -="" members:="" -="" user:[email protected]="" -="" group:[email protected]="" -="" domain:google.com="" -="" serviceaccount:[email protected]="" role:="" roles/resourcemanager.organizationadmin="" -="" members:="" -="" user:[email protected]="" role:="" roles/resourcemanager.organizationviewer="" condition:="" title:="" expirable="" access="" description:="" does="" not="" grant="" access="" after="" sep="" 2020="" expression:="" request.time="">< timestamp('2020-10-01t00:00:00.000z')="" for="" a="" description="" of="" iam="" and="" its="" features,="" see="" the="">IAM developer's guide __. |
get_mtls_endpoint_and_cert_source
get_mtls_endpoint_and_cert_source( client_options: typing.Optional[ google.api_core.client_options.ClientOptions ] = None, )Deprecated. Return the API endpoint and client cert source for mutual TLS.
The client cert source is determined in the following order: (1) if GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is not "true", the client cert source is None. (2) if client_options.client_cert_source is provided, use the provided one; if the default client cert source exists, use the default one; otherwise the client cert source is None.
The API endpoint is determined in the following order: (1) if client_options.api_endpoint if provided, use the provided one. (2) if GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable is "always", use the default mTLS endpoint; if the environment variable is "never", use the default API endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise use the default API endpoint.
More details can be found at https://google.aip.dev/auth/4114.
| Parameter | |
|---|---|
| Name | Description |
client_options | google.api_core.client_options.ClientOptions Custom options for the client. Only the |
| Exceptions | |
|---|---|
| Type | Description |
google.auth.exceptions.MutualTLSChannelError | If any errors happen. |
| Returns | |
|---|---|
| Type | Description |
Tuple[str, Callable[[], Tuple[bytes, bytes]]] | returns the API endpoint and the client cert source to use. |
get_snapshot
get_snapshot( request: typing.Optional[ typing.Union[google.cloud.pubsub_v1.types.GetSnapshotRequest, dict] ] = None, *, snapshot: typing.Optional[str] = None, retry: typing.Optional[ typing.Union[ google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault, ] ] = _MethodDefault._DEFAULT_VALUE, timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = () ) -> google.cloud.pubsub_v1.types.SnapshotGets the configuration details of a snapshot. Snapshots are used in Seek <https://cloud.google.com/pubsub/docs/replay-overview>__ 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.
# 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 import pubsub_v1 def sample_get_snapshot(): # Create a client client = pubsub_v1.SubscriberClient() # Initialize request argument(s) request = pubsub_v1.GetSnapshotRequest( snapshot="snapshot_value", ) # Make the request response = client.get_snapshot(request=request) # Handle the response print(response) | Parameters | |
|---|---|
| Name | Description |
request | Union[google.pubsub_v1.types.GetSnapshotRequest, dict] The request object. Request for the GetSnapshot method. |
snapshot | str Required. The name of the snapshot to get. Format is |
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, Union[str, bytes]]] Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type |
| Returns | |
|---|---|
| Type | Description |
google.pubsub_v1.types.Snapshot | A snapshot resource. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) 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. |
get_subscription
get_subscription( request: typing.Optional[ typing.Union[google.cloud.pubsub_v1.types.GetSubscriptionRequest, dict] ] = None, *, subscription: typing.Optional[str] = None, retry: typing.Optional[ typing.Union[ google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault, ] ] = _MethodDefault._DEFAULT_VALUE, timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = () ) -> google.cloud.pubsub_v1.types.SubscriptionGets the configuration details of a subscription.
# 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 import pubsub_v1 def sample_get_subscription(): # Create a client client = pubsub_v1.SubscriberClient() # Initialize request argument(s) request = pubsub_v1.GetSubscriptionRequest( subscription="subscription_value", ) # Make the request response = client.get_subscription(request=request) # Handle the response print(response) | Parameters | |
|---|---|
| Name | Description |
request | Union[google.pubsub_v1.types.GetSubscriptionRequest, dict] The request object. Request for the GetSubscription method. |
subscription | str Required. The name of the subscription to get. Format is |
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, Union[str, bytes]]] Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type |
| Returns | |
|---|---|
| Type | Description |
google.pubsub_v1.types.Subscription | A subscription resource. If none of push_config, bigquery_config, or cloud_storage_config is set, then the subscriber will pull and ack messages using API methods. At most one of these fields may be set. |
list_snapshots
list_snapshots( request: typing.Optional[ typing.Union[google.cloud.pubsub_v1.types.ListSnapshotsRequest, dict] ] = None, *, project: typing.Optional[str] = None, retry: typing.Optional[ typing.Union[ google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault, ] ] = _MethodDefault._DEFAULT_VALUE, timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = () ) -> google.pubsub_v1.services.subscriber.pagers.ListSnapshotsPagerLists the existing snapshots. Snapshots are used in Seek <https://cloud.google.com/pubsub/docs/replay-overview>__ 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.
# 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 import pubsub_v1 def sample_list_snapshots(): # Create a client client = pubsub_v1.SubscriberClient() # Initialize request argument(s) request = pubsub_v1.ListSnapshotsRequest( project="project_value", ) # Make the request page_result = client.list_snapshots(request=request) # Handle the response for response in page_result: print(response) | Parameters | |
|---|---|
| Name | Description |
request | Union[google.pubsub_v1.types.ListSnapshotsRequest, dict] The request object. Request for the |
project | str Required. The name of the project in which to list snapshots. Format is |
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, Union[str, bytes]]] Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type |
| Returns | |
|---|---|
| Type | Description |
google.pubsub_v1.services.subscriber.pagers.ListSnapshotsPager | Response for the ListSnapshots method. Iterating over this object will yield results and resolve additional pages automatically. |
list_subscriptions
list_subscriptions( request: typing.Optional[ typing.Union[google.cloud.pubsub_v1.types.ListSubscriptionsRequest, dict] ] = None, *, project: typing.Optional[str] = None, retry: typing.Optional[ typing.Union[ google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault, ] ] = _MethodDefault._DEFAULT_VALUE, timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = () ) -> google.pubsub_v1.services.subscriber.pagers.ListSubscriptionsPagerLists matching subscriptions.
# 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 import pubsub_v1 def sample_list_subscriptions(): # Create a client client = pubsub_v1.SubscriberClient() # Initialize request argument(s) request = pubsub_v1.ListSubscriptionsRequest( project="project_value", ) # Make the request page_result = client.list_subscriptions(request=request) # Handle the response for response in page_result: print(response) | Parameters | |
|---|---|
| Name | Description |
request | Union[google.pubsub_v1.types.ListSubscriptionsRequest, dict] The request object. Request for the |
project | str Required. The name of the project in which to list subscriptions. Format is |
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, Union[str, bytes]]] Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type |
| Returns | |
|---|---|
| Type | Description |
google.pubsub_v1.services.subscriber.pagers.ListSubscriptionsPager | Response for the ListSubscriptions method. Iterating over this object will yield results and resolve additional pages automatically. |
listing_path
listing_path(project: str, location: str, data_exchange: str, listing: str) -> strReturns a fully-qualified listing string.
modify_ack_deadline
modify_ack_deadline( request: typing.Optional[ typing.Union[google.cloud.pubsub_v1.types.ModifyAckDeadlineRequest, dict] ] = None, *, subscription: typing.Optional[str] = None, ack_ids: typing.Optional[typing.MutableSequence[str]] = None, ack_deadline_seconds: typing.Optional[int] = None, retry: typing.Optional[ typing.Union[ google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault, ] ] = _MethodDefault._DEFAULT_VALUE, timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = () ) -> NoneModifies the ack deadline for a specific message. This method is useful to indicate that more time is needed to process a message by the subscriber, or to make the message available for redelivery if the processing was interrupted. Note that this does not modify the subscription-level ackDeadlineSeconds used for subsequent messages.
# 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 import pubsub_v1 def sample_modify_ack_deadline(): # Create a client client = pubsub_v1.SubscriberClient() # Initialize request argument(s) request = pubsub_v1.ModifyAckDeadlineRequest( subscription="subscription_value", ack_ids=['ack_ids_value1', 'ack_ids_value2'], ack_deadline_seconds=2066, ) # Make the request client.modify_ack_deadline(request=request) | Parameters | |
|---|---|
| Name | Description |
request | Union[google.pubsub_v1.types.ModifyAckDeadlineRequest, dict] The request object. Request for the ModifyAckDeadline method. |
subscription | str Required. The name of the subscription. Format is |
ack_ids | MutableSequence[str] Required. List of acknowledgment IDs. This corresponds to the |
ack_deadline_seconds | int Required. The new ack deadline with respect to the time this request was sent to the Pub/Sub system. For example, if the value is 10, the new ack deadline will expire 10 seconds after the |
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, Union[str, bytes]]] Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type |
modify_push_config
modify_push_config( request: typing.Optional[ typing.Union[google.cloud.pubsub_v1.types.ModifyPushConfigRequest, dict] ] = None, *, subscription: typing.Optional[str] = None, push_config: typing.Optional[google.cloud.pubsub_v1.types.PushConfig] = None, retry: typing.Optional[ typing.Union[ google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault, ] ] = _MethodDefault._DEFAULT_VALUE, timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = () ) -> NoneModifies the PushConfig for a specified subscription.
This may be used to change a push subscription to a pull one (signified by an empty PushConfig) or vice versa, or change the endpoint URL and other attributes of a push subscription. Messages will accumulate for delivery continuously through the call regardless of changes to the PushConfig.
# 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 import pubsub_v1 def sample_modify_push_config(): # Create a client client = pubsub_v1.SubscriberClient() # Initialize request argument(s) request = pubsub_v1.ModifyPushConfigRequest( subscription="subscription_value", ) # Make the request client.modify_push_config(request=request) | Parameters | |
|---|---|
| Name | Description |
request | Union[google.pubsub_v1.types.ModifyPushConfigRequest, dict] The request object. Request for the ModifyPushConfig method. |
subscription | str Required. The name of the subscription. Format is |
push_config | google.pubsub_v1.types.PushConfig Required. The push configuration for future deliveries. An empty |
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, Union[str, bytes]]] Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type |
parse_common_billing_account_path
parse_common_billing_account_path(path: str) -> typing.Dict[str, str]Parse a billing_account path into its component segments.
parse_common_folder_path
parse_common_folder_path(path: str) -> typing.Dict[str, str]Parse a folder path into its component segments.
parse_common_location_path
parse_common_location_path(path: str) -> typing.Dict[str, str]Parse a location path into its component segments.
parse_common_organization_path
parse_common_organization_path(path: str) -> typing.Dict[str, str]Parse a organization path into its component segments.
parse_common_project_path
parse_common_project_path(path: str) -> typing.Dict[str, str]Parse a project path into its component segments.
parse_listing_path
parse_listing_path(path: str) -> typing.Dict[str, str]Parses a listing path into its component segments.
parse_snapshot_path
parse_snapshot_path(path: str) -> typing.Dict[str, str]Parses a snapshot path into its component segments.
parse_subscription_path
parse_subscription_path(path: str) -> typing.Dict[str, str]Parses a subscription path into its component segments.
parse_topic_path
parse_topic_path(path: str) -> typing.Dict[str, str]Parses a topic path into its component segments.
pull
pull( request: typing.Optional[ typing.Union[google.cloud.pubsub_v1.types.PullRequest, dict] ] = None, *, subscription: typing.Optional[str] = None, return_immediately: typing.Optional[bool] = None, max_messages: typing.Optional[int] = None, retry: typing.Optional[ typing.Union[ google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault, ] ] = _MethodDefault._DEFAULT_VALUE, timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = () ) -> google.cloud.pubsub_v1.types.PullResponsePulls messages from the server.
# 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 import pubsub_v1 def sample_pull(): # Create a client client = pubsub_v1.SubscriberClient() # Initialize request argument(s) request = pubsub_v1.PullRequest( subscription="subscription_value", max_messages=1277, ) # Make the request response = client.pull(request=request) # Handle the response print(response) | Parameters | |
|---|---|
| Name | Description |
request | Union[google.pubsub_v1.types.PullRequest, dict] The request object. Request for the |
subscription | str Required. The subscription from which messages should be pulled. Format is |
return_immediately | bool Optional. If this field set to true, the system will respond immediately even if it there are no messages available to return in the |
max_messages | int Required. The maximum number of messages to return for this request. Must be a positive integer. The Pub/Sub system may return fewer than the number specified. This corresponds to the |
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, Union[str, bytes]]] Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type |
| Returns | |
|---|---|
| Type | Description |
google.pubsub_v1.types.PullResponse | Response for the Pull method. |
seek
seek( request: typing.Optional[ typing.Union[google.cloud.pubsub_v1.types.SeekRequest, dict] ] = None, *, retry: typing.Optional[ typing.Union[ google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault, ] ] = _MethodDefault._DEFAULT_VALUE, timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = () ) -> google.cloud.pubsub_v1.types.SeekResponseSeeks an existing subscription to a point in time or to a given snapshot, whichever is provided in the request. 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. Note that both the subscription and the snapshot must be on the same topic.
# 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 import pubsub_v1 def sample_seek(): # Create a client client = pubsub_v1.SubscriberClient() # Initialize request argument(s) request = pubsub_v1.SeekRequest( subscription="subscription_value", ) # Make the request response = client.seek(request=request) # Handle the response print(response) | Parameters | |
|---|---|
| Name | Description |
request | Union[google.pubsub_v1.types.SeekRequest, dict] The request object. Request for the |
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, Union[str, bytes]]] Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type |
| Returns | |
|---|---|
| Type | Description |
google.pubsub_v1.types.SeekResponse | Response for the Seek method (this response is empty). |
set_iam_policy
set_iam_policy( request: typing.Optional[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest] = None, *, retry: typing.Optional[ typing.Union[ google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault, ] ] = _MethodDefault._DEFAULT_VALUE, timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = () ) -> google.iam.v1.policy_pb2.PolicySets the IAM access control policy on the specified function.
Replaces any existing policy.
| Parameters | |
|---|---|
| Name | Description |
request | The request object. Request message for |
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, Union[str, bytes]]] Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type |
| Returns | |
|---|---|
| Type | Description |
| Defines an Identity and Access Management (IAM) policy. It is used to specify access control policies for Cloud Platform resources. A Policy is a collection of bindings. A binding binds one or more members to a single role. Members can be user accounts, service accounts, Google groups, and domains (such as G Suite). A role is a named list of permissions (defined by IAM or configured by users). A binding can optionally specify a condition, which is a logic expression that further constrains the role binding based on attributes about the request and/or target resource. **JSON Example** :: { "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:[email protected]", "group:[email protected]", "domain:google.com", "serviceAccount:[email protected]" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": ["user:[email protected]"], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01t00:00:00.000z')",="" }="" }="" ]="" }="" **yaml="" example**="" ::="" bindings:="" -="" members:="" -="" user:[email protected]="" -="" group:[email protected]="" -="" domain:google.com="" -="" serviceaccount:[email protected]="" role:="" roles/resourcemanager.organizationadmin="" -="" members:="" -="" user:[email protected]="" role:="" roles/resourcemanager.organizationviewer="" condition:="" title:="" expirable="" access="" description:="" does="" not="" grant="" access="" after="" sep="" 2020="" expression:="" request.time="">< timestamp('2020-10-01t00:00:00.000z')="" for="" a="" description="" of="" iam="" and="" its="" features,="" see="" the="">IAM developer's guide __. |
snapshot_path
snapshot_path(project: str, snapshot: str) -> strReturns a fully-qualified snapshot string.
streaming_pull
streaming_pull( requests: typing.Optional[ typing.Iterator[google.cloud.pubsub_v1.types.StreamingPullRequest] ] = None, *, retry: typing.Optional[ typing.Union[ google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault, ] ] = _MethodDefault._DEFAULT_VALUE, timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = () ) -> typing.Iterable[google.cloud.pubsub_v1.types.StreamingPullResponse]Establishes a stream with the server, which sends messages down to the client. The client streams acknowledgments and ack deadline modifications back to the server. The server will close the stream and return the status on any error. The server may close the stream with status UNAVAILABLE to reassign server-side resources, in which case, the client should re-establish the stream. Flow control can be achieved by configuring the underlying RPC channel.
# 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 import pubsub_v1 def sample_streaming_pull(): # Create a client client = pubsub_v1.SubscriberClient() # Initialize request argument(s) request = pubsub_v1.StreamingPullRequest( subscription="subscription_value", stream_ack_deadline_seconds=2813, ) # This method expects an iterator which contains # 'pubsub_v1.StreamingPullRequest' objects # Here we create a generator that yields a single `request` for # demonstrative purposes. requests = [request] def request_generator(): for request in requests: yield request # Make the request stream = client.streaming_pull(requests=request_generator()) # Handle the response for response in stream: print(response) | Parameters | |
|---|---|
| Name | Description |
requests | Iterator[google.pubsub_v1.types.StreamingPullRequest] The request object iterator. Request for the |
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, Union[str, bytes]]] Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type |
| Returns | |
|---|---|
| Type | Description |
Iterable[google.pubsub_v1.types.StreamingPullResponse] | Response for the StreamingPull method. This response is used to stream messages from the server to the client. |
subscribe
subscribe( subscription: str, callback: typing.Callable[[subscriber.message.Message], typing.Any], flow_control: typing.Union[ google.cloud.pubsub_v1.types.FlowControl, typing.Sequence ] = (), scheduler: typing.Optional[subscriber.scheduler.ThreadScheduler] = None, use_legacy_flow_control: bool = False, await_callbacks_on_shutdown: bool = False, ) -> google.cloud.pubsub_v1.subscriber.futures.StreamingPullFutureAsynchronously start receiving messages on a given subscription.
This method starts a background thread to begin pulling messages from a Pub/Sub subscription and scheduling them to be processed using the provided callback.
The callback will be called with an individual xref_Message. It is the responsibility of the callback to either call ack() or nack() on the message when it finished processing. If an exception occurs in the callback during processing, the exception is logged and the message is nack() ed.
The flow_control argument can be used to control the rate of at which messages are pulled. The settings are relatively conservative by default to prevent "message hoarding" - a situation where the client pulls a large number of messages but can not process them fast enough leading it to "starve" other clients of messages. Increasing these settings may lead to faster throughput for messages that do not take a long time to process.
The use_legacy_flow_control argument disables enforcing flow control settings at the Cloud Pub/Sub server, and only the client side flow control will be enforced.
This method starts the receiver in the background and returns a Future representing its execution. Waiting on the future (calling result()) will block forever or until a non-recoverable error is encountered (such as loss of network connectivity). Cancelling the future will signal the process to shutdown gracefully and exit.
from google.cloud import pubsub_v1 subscriber_client = pubsub_v1.SubscriberClient() # existing subscription subscription = subscriber_client.subscription_path( 'my-project-id', 'my-subscription') def callback(message): print(message) message.ack() future = subscriber_client.subscribe( subscription, callback) try: future.result() except KeyboardInterrupt: future.cancel() # Trigger the shutdown. future.result() # Block until the shutdown is complete. | Parameter | |
|---|---|
| Name | Description |
use_legacy_flow_control | bool If set to |
subscription_path
subscription_path(project: str, subscription: str) -> strReturns a fully-qualified subscription string.
test_iam_permissions
test_iam_permissions( request: typing.Optional[ google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest ] = None, *, retry: typing.Optional[ typing.Union[ google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault, ] ] = _MethodDefault._DEFAULT_VALUE, timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = () ) -> google.iam.v1.iam_policy_pb2.TestIamPermissionsResponseTests the specified IAM permissions against the IAM access control policy for a function.
If the function does not exist, this will return an empty set of permissions, not a NOT_FOUND error.
| Parameters | |
|---|---|
| Name | Description |
request | The request object. Request message for |
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, Union[str, bytes]]] Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type |
| Returns | |
|---|---|
| Type | Description |
| Response message for TestIamPermissions method. |
topic_path
topic_path(project: str, topic: str) -> strReturns a fully-qualified topic string.
update_snapshot
update_snapshot( request: typing.Optional[ typing.Union[google.cloud.pubsub_v1.types.UpdateSnapshotRequest, dict] ] = None, *, snapshot: typing.Optional[google.cloud.pubsub_v1.types.Snapshot] = None, update_mask: typing.Optional[google.protobuf.field_mask_pb2.FieldMask] = None, retry: typing.Optional[ typing.Union[ google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault, ] ] = _MethodDefault._DEFAULT_VALUE, timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = () ) -> google.cloud.pubsub_v1.types.SnapshotUpdates an existing snapshot by updating the fields specified in the update mask. Snapshots are used in Seek <https://cloud.google.com/pubsub/docs/replay-overview>__ 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.
# 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 import pubsub_v1 def sample_update_snapshot(): # Create a client client = pubsub_v1.SubscriberClient() # Initialize request argument(s) request = pubsub_v1.UpdateSnapshotRequest( ) # Make the request response = client.update_snapshot(request=request) # Handle the response print(response) | Parameters | |
|---|---|
| Name | Description |
request | Union[google.pubsub_v1.types.UpdateSnapshotRequest, dict] The request object. Request for the UpdateSnapshot method. |
snapshot | google.pubsub_v1.types.Snapshot Required. The updated snapshot object. This corresponds to the |
update_mask | google.protobuf.field_mask_pb2.FieldMask Required. Indicates which fields in the provided snapshot to update. Must be specified and non-empty. This corresponds to the |
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, Union[str, bytes]]] Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type |
| Returns | |
|---|---|
| Type | Description |
google.pubsub_v1.types.Snapshot | A snapshot resource. Snapshots are used in [Seek](https://cloud.google.com/pubsub/docs/replay-overview) 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. |
update_subscription
update_subscription( request: typing.Optional[ typing.Union[google.cloud.pubsub_v1.types.UpdateSubscriptionRequest, dict] ] = None, *, subscription: typing.Optional[google.cloud.pubsub_v1.types.Subscription] = None, update_mask: typing.Optional[google.protobuf.field_mask_pb2.FieldMask] = None, retry: typing.Optional[ typing.Union[ google.api_core.retry.retry_unary.Retry, google.api_core.gapic_v1.method._MethodDefault, ] ] = _MethodDefault._DEFAULT_VALUE, timeout: typing.Union[float, object] = _MethodDefault._DEFAULT_VALUE, metadata: typing.Sequence[typing.Tuple[str, typing.Union[str, bytes]]] = () ) -> google.cloud.pubsub_v1.types.SubscriptionUpdates an existing subscription by updating the fields specified in the update mask. Note that certain properties of a subscription, such as its topic, are not modifiable.
# 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 import pubsub_v1 def sample_update_subscription(): # Create a client client = pubsub_v1.SubscriberClient() # Initialize request argument(s) subscription = pubsub_v1.Subscription() subscription.name = "name_value" subscription.topic = "topic_value" request = pubsub_v1.UpdateSubscriptionRequest( subscription=subscription, ) # Make the request response = client.update_subscription(request=request) # Handle the response print(response) | Parameters | |
|---|---|
| Name | Description |
request | Union[google.pubsub_v1.types.UpdateSubscriptionRequest, dict] The request object. Request for the UpdateSubscription method. |
subscription | google.pubsub_v1.types.Subscription Required. The updated subscription object. This corresponds to the |
update_mask | google.protobuf.field_mask_pb2.FieldMask Required. Indicates which fields in the provided subscription to update. Must be specified and non-empty. This corresponds to the |
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, Union[str, bytes]]] Key/value pairs which should be sent along with the request as metadata. Normally, each value must be of type |
| Returns | |
|---|---|
| Type | Description |
google.pubsub_v1.types.Subscription | A subscription resource. If none of push_config, bigquery_config, or cloud_storage_config is set, then the subscriber will pull and ack messages using API methods. At most one of these fields may be set. |