google-cloud-pubsub 2.30.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. google/cloud/pubsub/__init__.py +31 -0
  2. google/cloud/pubsub_v1/__init__.py +35 -0
  3. google/cloud/pubsub_v1/exceptions.py +20 -0
  4. google/cloud/pubsub_v1/futures.py +56 -0
  5. google/cloud/pubsub_v1/open_telemetry/__init__.py +13 -0
  6. google/cloud/pubsub_v1/open_telemetry/context_propagation.py +55 -0
  7. google/cloud/pubsub_v1/open_telemetry/publish_message_wrapper.py +142 -0
  8. google/cloud/pubsub_v1/open_telemetry/subscribe_opentelemetry.py +280 -0
  9. google/cloud/pubsub_v1/proto/pubsub.proto +1344 -0
  10. google/cloud/pubsub_v1/proto/schema.proto +286 -0
  11. google/cloud/pubsub_v1/publisher/__init__.py +20 -0
  12. google/cloud/pubsub_v1/publisher/_batch/__init__.py +0 -0
  13. google/cloud/pubsub_v1/publisher/_batch/base.py +174 -0
  14. google/cloud/pubsub_v1/publisher/_batch/thread.py +492 -0
  15. google/cloud/pubsub_v1/publisher/_sequencer/__init__.py +0 -0
  16. google/cloud/pubsub_v1/publisher/_sequencer/base.py +82 -0
  17. google/cloud/pubsub_v1/publisher/_sequencer/ordered_sequencer.py +340 -0
  18. google/cloud/pubsub_v1/publisher/_sequencer/unordered_sequencer.py +167 -0
  19. google/cloud/pubsub_v1/publisher/client.py +614 -0
  20. google/cloud/pubsub_v1/publisher/exceptions.py +51 -0
  21. google/cloud/pubsub_v1/publisher/flow_controller.py +313 -0
  22. google/cloud/pubsub_v1/publisher/futures.py +83 -0
  23. google/cloud/pubsub_v1/subscriber/__init__.py +20 -0
  24. google/cloud/pubsub_v1/subscriber/_protocol/__init__.py +0 -0
  25. google/cloud/pubsub_v1/subscriber/_protocol/dispatcher.py +658 -0
  26. google/cloud/pubsub_v1/subscriber/_protocol/heartbeater.py +77 -0
  27. google/cloud/pubsub_v1/subscriber/_protocol/helper_threads.py +122 -0
  28. google/cloud/pubsub_v1/subscriber/_protocol/histogram.py +159 -0
  29. google/cloud/pubsub_v1/subscriber/_protocol/leaser.py +292 -0
  30. google/cloud/pubsub_v1/subscriber/_protocol/messages_on_hold.py +182 -0
  31. google/cloud/pubsub_v1/subscriber/_protocol/requests.py +62 -0
  32. google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py +1309 -0
  33. google/cloud/pubsub_v1/subscriber/client.py +323 -0
  34. google/cloud/pubsub_v1/subscriber/exceptions.py +44 -0
  35. google/cloud/pubsub_v1/subscriber/futures.py +125 -0
  36. google/cloud/pubsub_v1/subscriber/message.py +532 -0
  37. google/cloud/pubsub_v1/subscriber/scheduler.py +170 -0
  38. google/cloud/pubsub_v1/types.py +336 -0
  39. google/pubsub/__init__.py +174 -0
  40. google/pubsub/gapic_version.py +16 -0
  41. google/pubsub/py.typed +2 -0
  42. google/pubsub_v1/__init__.py +172 -0
  43. google/pubsub_v1/gapic_metadata.json +591 -0
  44. google/pubsub_v1/gapic_version.py +16 -0
  45. google/pubsub_v1/py.typed +2 -0
  46. google/pubsub_v1/services/__init__.py +15 -0
  47. google/pubsub_v1/services/publisher/__init__.py +22 -0
  48. google/pubsub_v1/services/publisher/async_client.py +1670 -0
  49. google/pubsub_v1/services/publisher/client.py +2136 -0
  50. google/pubsub_v1/services/publisher/pagers.py +508 -0
  51. google/pubsub_v1/services/publisher/transports/__init__.py +38 -0
  52. google/pubsub_v1/services/publisher/transports/base.py +427 -0
  53. google/pubsub_v1/services/publisher/transports/grpc.py +667 -0
  54. google/pubsub_v1/services/publisher/transports/grpc_asyncio.py +847 -0
  55. google/pubsub_v1/services/publisher/transports/rest.py +2511 -0
  56. google/pubsub_v1/services/publisher/transports/rest_base.py +678 -0
  57. google/pubsub_v1/services/schema_service/__init__.py +22 -0
  58. google/pubsub_v1/services/schema_service/async_client.py +1783 -0
  59. google/pubsub_v1/services/schema_service/client.py +2197 -0
  60. google/pubsub_v1/services/schema_service/pagers.py +352 -0
  61. google/pubsub_v1/services/schema_service/transports/__init__.py +38 -0
  62. google/pubsub_v1/services/schema_service/transports/base.py +439 -0
  63. google/pubsub_v1/services/schema_service/transports/grpc.py +676 -0
  64. google/pubsub_v1/services/schema_service/transports/grpc_asyncio.py +858 -0
  65. google/pubsub_v1/services/schema_service/transports/rest.py +2718 -0
  66. google/pubsub_v1/services/schema_service/transports/rest_base.py +746 -0
  67. google/pubsub_v1/services/subscriber/__init__.py +22 -0
  68. google/pubsub_v1/services/subscriber/async_client.py +2643 -0
  69. google/pubsub_v1/services/subscriber/client.py +3094 -0
  70. google/pubsub_v1/services/subscriber/pagers.py +352 -0
  71. google/pubsub_v1/services/subscriber/transports/__init__.py +38 -0
  72. google/pubsub_v1/services/subscriber/transports/base.py +589 -0
  73. google/pubsub_v1/services/subscriber/transports/grpc.py +921 -0
  74. google/pubsub_v1/services/subscriber/transports/grpc_asyncio.py +1207 -0
  75. google/pubsub_v1/services/subscriber/transports/rest.py +3561 -0
  76. google/pubsub_v1/services/subscriber/transports/rest_base.py +1024 -0
  77. google/pubsub_v1/types/__init__.py +169 -0
  78. google/pubsub_v1/types/pubsub.py +3478 -0
  79. google/pubsub_v1/types/schema.py +511 -0
  80. google_cloud_pubsub-2.30.0.data/scripts/fixup_pubsub_v1_keywords.py +210 -0
  81. google_cloud_pubsub-2.30.0.dist-info/METADATA +283 -0
  82. google_cloud_pubsub-2.30.0.dist-info/RECORD +85 -0
  83. google_cloud_pubsub-2.30.0.dist-info/WHEEL +5 -0
  84. google_cloud_pubsub-2.30.0.dist-info/licenses/LICENSE +202 -0
  85. google_cloud_pubsub-2.30.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,210 @@
1
+ #!python
2
+ # -*- coding: utf-8 -*-
3
+ # Copyright 2025 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ import argparse
18
+ import os
19
+ import libcst as cst
20
+ import pathlib
21
+ import sys
22
+ from typing import (Any, Callable, Dict, List, Sequence, Tuple)
23
+
24
+
25
+ def partition(
26
+ predicate: Callable[[Any], bool],
27
+ iterator: Sequence[Any]
28
+ ) -> Tuple[List[Any], List[Any]]:
29
+ """A stable, out-of-place partition."""
30
+ results = ([], [])
31
+
32
+ for i in iterator:
33
+ results[int(predicate(i))].append(i)
34
+
35
+ # Returns trueList, falseList
36
+ return results[1], results[0]
37
+
38
+
39
+ class pubsubCallTransformer(cst.CSTTransformer):
40
+ CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata')
41
+ METHOD_TO_PARAMS: Dict[str, Tuple[str]] = {
42
+ 'acknowledge': ('subscription', 'ack_ids', ),
43
+ 'commit_schema': ('name', 'schema', ),
44
+ 'create_schema': ('parent', 'schema', 'schema_id', ),
45
+ 'create_snapshot': ('name', 'subscription', 'labels', ),
46
+ 'create_subscription': ('name', 'topic', 'push_config', 'bigquery_config', 'cloud_storage_config', 'ack_deadline_seconds', 'retain_acked_messages', 'message_retention_duration', 'labels', 'enable_message_ordering', 'expiration_policy', 'filter', 'dead_letter_policy', 'retry_policy', 'detached', 'enable_exactly_once_delivery', 'topic_message_retention_duration', 'state', 'analytics_hub_subscription_info', 'message_transforms', ),
47
+ 'create_topic': ('name', 'labels', 'message_storage_policy', 'kms_key_name', 'schema_settings', 'satisfies_pzs', 'message_retention_duration', 'state', 'ingestion_data_source_settings', 'message_transforms', ),
48
+ 'delete_schema': ('name', ),
49
+ 'delete_schema_revision': ('name', 'revision_id', ),
50
+ 'delete_snapshot': ('snapshot', ),
51
+ 'delete_subscription': ('subscription', ),
52
+ 'delete_topic': ('topic', ),
53
+ 'detach_subscription': ('subscription', ),
54
+ 'get_schema': ('name', 'view', ),
55
+ 'get_snapshot': ('snapshot', ),
56
+ 'get_subscription': ('subscription', ),
57
+ 'get_topic': ('topic', ),
58
+ 'list_schema_revisions': ('name', 'view', 'page_size', 'page_token', ),
59
+ 'list_schemas': ('parent', 'view', 'page_size', 'page_token', ),
60
+ 'list_snapshots': ('project', 'page_size', 'page_token', ),
61
+ 'list_subscriptions': ('project', 'page_size', 'page_token', ),
62
+ 'list_topics': ('project', 'page_size', 'page_token', ),
63
+ 'list_topic_snapshots': ('topic', 'page_size', 'page_token', ),
64
+ 'list_topic_subscriptions': ('topic', 'page_size', 'page_token', ),
65
+ 'modify_ack_deadline': ('subscription', 'ack_ids', 'ack_deadline_seconds', ),
66
+ 'modify_push_config': ('subscription', 'push_config', ),
67
+ 'publish': ('topic', 'messages', ),
68
+ 'pull': ('subscription', 'max_messages', 'return_immediately', ),
69
+ 'rollback_schema': ('name', 'revision_id', ),
70
+ 'seek': ('subscription', 'time', 'snapshot', ),
71
+ 'streaming_pull': ('subscription', 'stream_ack_deadline_seconds', 'ack_ids', 'modify_deadline_seconds', 'modify_deadline_ack_ids', 'client_id', 'max_outstanding_messages', 'max_outstanding_bytes', ),
72
+ 'update_snapshot': ('snapshot', 'update_mask', ),
73
+ 'update_subscription': ('subscription', 'update_mask', ),
74
+ 'update_topic': ('topic', 'update_mask', ),
75
+ 'validate_message': ('parent', 'name', 'schema', 'message', 'encoding', ),
76
+ 'validate_schema': ('parent', 'schema', ),
77
+ }
78
+
79
+ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode:
80
+ try:
81
+ key = original.func.attr.value
82
+ kword_params = self.METHOD_TO_PARAMS[key]
83
+ except (AttributeError, KeyError):
84
+ # Either not a method from the API or too convoluted to be sure.
85
+ return updated
86
+
87
+ # If the existing code is valid, keyword args come after positional args.
88
+ # Therefore, all positional args must map to the first parameters.
89
+ args, kwargs = partition(lambda a: not bool(a.keyword), updated.args)
90
+ if any(k.keyword.value == "request" for k in kwargs):
91
+ # We've already fixed this file, don't fix it again.
92
+ return updated
93
+
94
+ kwargs, ctrl_kwargs = partition(
95
+ lambda a: a.keyword.value not in self.CTRL_PARAMS,
96
+ kwargs
97
+ )
98
+
99
+ args, ctrl_args = args[:len(kword_params)], args[len(kword_params):]
100
+ ctrl_kwargs.extend(cst.Arg(value=a.value, keyword=cst.Name(value=ctrl))
101
+ for a, ctrl in zip(ctrl_args, self.CTRL_PARAMS))
102
+
103
+ request_arg = cst.Arg(
104
+ value=cst.Dict([
105
+ cst.DictElement(
106
+ cst.SimpleString("'{}'".format(name)),
107
+ cst.Element(value=arg.value)
108
+ )
109
+ # Note: the args + kwargs looks silly, but keep in mind that
110
+ # the control parameters had to be stripped out, and that
111
+ # those could have been passed positionally or by keyword.
112
+ for name, arg in zip(kword_params, args + kwargs)]),
113
+ keyword=cst.Name("request")
114
+ )
115
+
116
+ return updated.with_changes(
117
+ args=[request_arg] + ctrl_kwargs
118
+ )
119
+
120
+
121
+ def fix_files(
122
+ in_dir: pathlib.Path,
123
+ out_dir: pathlib.Path,
124
+ *,
125
+ transformer=pubsubCallTransformer(),
126
+ ):
127
+ """Duplicate the input dir to the output dir, fixing file method calls.
128
+
129
+ Preconditions:
130
+ * in_dir is a real directory
131
+ * out_dir is a real, empty directory
132
+ """
133
+ pyfile_gen = (
134
+ pathlib.Path(os.path.join(root, f))
135
+ for root, _, files in os.walk(in_dir)
136
+ for f in files if os.path.splitext(f)[1] == ".py"
137
+ )
138
+
139
+ for fpath in pyfile_gen:
140
+ with open(fpath, 'r') as f:
141
+ src = f.read()
142
+
143
+ # Parse the code and insert method call fixes.
144
+ tree = cst.parse_module(src)
145
+ updated = tree.visit(transformer)
146
+
147
+ # Create the path and directory structure for the new file.
148
+ updated_path = out_dir.joinpath(fpath.relative_to(in_dir))
149
+ updated_path.parent.mkdir(parents=True, exist_ok=True)
150
+
151
+ # Generate the updated source file at the corresponding path.
152
+ with open(updated_path, 'w') as f:
153
+ f.write(updated.code)
154
+
155
+
156
+ if __name__ == '__main__':
157
+ parser = argparse.ArgumentParser(
158
+ description="""Fix up source that uses the pubsub client library.
159
+
160
+ The existing sources are NOT overwritten but are copied to output_dir with changes made.
161
+
162
+ Note: This tool operates at a best-effort level at converting positional
163
+ parameters in client method calls to keyword based parameters.
164
+ Cases where it WILL FAIL include
165
+ A) * or ** expansion in a method call.
166
+ B) Calls via function or method alias (includes free function calls)
167
+ C) Indirect or dispatched calls (e.g. the method is looked up dynamically)
168
+
169
+ These all constitute false negatives. The tool will also detect false
170
+ positives when an API method shares a name with another method.
171
+ """)
172
+ parser.add_argument(
173
+ '-d',
174
+ '--input-directory',
175
+ required=True,
176
+ dest='input_dir',
177
+ help='the input directory to walk for python files to fix up',
178
+ )
179
+ parser.add_argument(
180
+ '-o',
181
+ '--output-directory',
182
+ required=True,
183
+ dest='output_dir',
184
+ help='the directory to output files fixed via un-flattening',
185
+ )
186
+ args = parser.parse_args()
187
+ input_dir = pathlib.Path(args.input_dir)
188
+ output_dir = pathlib.Path(args.output_dir)
189
+ if not input_dir.is_dir():
190
+ print(
191
+ f"input directory '{input_dir}' does not exist or is not a directory",
192
+ file=sys.stderr,
193
+ )
194
+ sys.exit(-1)
195
+
196
+ if not output_dir.is_dir():
197
+ print(
198
+ f"output directory '{output_dir}' does not exist or is not a directory",
199
+ file=sys.stderr,
200
+ )
201
+ sys.exit(-1)
202
+
203
+ if os.listdir(output_dir):
204
+ print(
205
+ f"output directory '{output_dir}' is not empty",
206
+ file=sys.stderr,
207
+ )
208
+ sys.exit(-1)
209
+
210
+ fix_files(input_dir, output_dir)
@@ -0,0 +1,283 @@
1
+ Metadata-Version: 2.4
2
+ Name: google-cloud-pubsub
3
+ Version: 2.30.0
4
+ Summary: Google Cloud Pub/Sub API client library
5
+ Home-page: https://github.com/googleapis/python-pubsub
6
+ Author: Google LLC
7
+ Author-email: googleapis-packages@google.com
8
+ License: Apache 2.0
9
+ Platform: Posix; MacOS X; Windows
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.7
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Operating System :: OS Independent
23
+ Classifier: Topic :: Internet
24
+ Requires-Python: >=3.7
25
+ License-File: LICENSE
26
+ Requires-Dist: grpcio<2.0.0,>=1.51.3
27
+ Requires-Dist: google-auth<3.0.0,>=2.14.1
28
+ Requires-Dist: google-api-core[grpc]!=2.0.*,!=2.1.*,!=2.10.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,<3.0.0,>=1.34.0
29
+ Requires-Dist: proto-plus<2.0.0,>=1.22.0
30
+ Requires-Dist: proto-plus<2.0.0,>=1.22.2; python_version >= "3.11"
31
+ Requires-Dist: proto-plus<2.0.0,>=1.25.0; python_version >= "3.13"
32
+ Requires-Dist: protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<7.0.0,>=3.20.2
33
+ Requires-Dist: grpc-google-iam-v1<1.0.0,>=0.12.4
34
+ Requires-Dist: grpcio-status>=1.33.2
35
+ Requires-Dist: opentelemetry-api<=1.22.0; python_version <= "3.7"
36
+ Requires-Dist: opentelemetry-api>=1.27.0; python_version >= "3.8"
37
+ Requires-Dist: opentelemetry-sdk<=1.22.0; python_version <= "3.7"
38
+ Requires-Dist: opentelemetry-sdk>=1.27.0; python_version >= "3.8"
39
+ Provides-Extra: libcst
40
+ Requires-Dist: libcst>=0.3.10; extra == "libcst"
41
+ Dynamic: author
42
+ Dynamic: author-email
43
+ Dynamic: classifier
44
+ Dynamic: description
45
+ Dynamic: home-page
46
+ Dynamic: license
47
+ Dynamic: license-file
48
+ Dynamic: platform
49
+ Dynamic: provides-extra
50
+ Dynamic: requires-dist
51
+ Dynamic: requires-python
52
+ Dynamic: summary
53
+
54
+ Python Client for Google Cloud Pub / Sub
55
+ ========================================
56
+
57
+ |GA| |pypi| |versions|
58
+
59
+ `Google Cloud Pub / Sub`_ is a fully-managed real-time messaging service that
60
+ allows you to send and receive messages between independent applications. You
61
+ can leverage Cloud Pub/Sub’s flexibility to decouple systems and components
62
+ hosted on Google Cloud Platform or elsewhere on the Internet. By building on
63
+ the same technology Google uses, Cloud Pub / Sub is designed to provide “at
64
+ least once” delivery at low latency with on-demand scalability to 1 million
65
+ messages per second (and beyond).
66
+
67
+ Publisher applications can send messages to a ``topic`` and other applications
68
+ can subscribe to that topic to receive the messages. By decoupling senders and
69
+ receivers, Google Cloud Pub/Sub allows developers to communicate between
70
+ independently written applications.
71
+
72
+ - `Product Documentation`_
73
+ - `Client Library Documentation`_
74
+
75
+ .. |GA| image:: https://img.shields.io/badge/support-GA-gold.svg
76
+ :target: https://github.com/googleapis/google-cloud-python/blob/main/README.rst#general-availability
77
+ .. |pypi| image:: https://img.shields.io/pypi/v/google-cloud-pubsub.svg
78
+ :target: https://pypi.org/project/google-cloud-pubsub/
79
+ .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-pubsub.svg
80
+ :target: https://pypi.org/project/google-cloud-pubsub/
81
+ .. _Google Cloud Pub / Sub: https://cloud.google.com/pubsub/
82
+ .. _Product Documentation: https://cloud.google.com/pubsub/docs
83
+ .. _Client Library Documentation: https://cloud.google.com/python/docs/reference/pubsub/latest/summary_overview
84
+
85
+ Quick Start
86
+ -----------
87
+
88
+ In order to use this library, you first need to go through the following steps:
89
+
90
+ 1. `Select or create a Cloud Platform project.`_
91
+ 2. `Enable billing for your project.`_
92
+ 3. `Enable the Google Cloud Pub / Sub API.`_
93
+ 4. `Setup Authentication.`_
94
+
95
+ .. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
96
+ .. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
97
+ .. _Enable the Google Cloud Pub / Sub API.: https://cloud.google.com/pubsub
98
+ .. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
99
+
100
+ Installation
101
+ ~~~~~~~~~~~~
102
+
103
+ Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to
104
+ create isolated Python environments. The basic problem it addresses is one of
105
+ dependencies and versions, and indirectly permissions.
106
+
107
+ With `virtualenv`_, it's possible to install this library without needing system
108
+ install permissions, and without clashing with the installed system
109
+ dependencies.
110
+
111
+ .. _`virtualenv`: https://virtualenv.pypa.io/en/latest/
112
+
113
+
114
+ Supported Python Versions
115
+ ^^^^^^^^^^^^^^^^^^^^^^^^^
116
+ Python >= 3.7
117
+
118
+ Deprecated Python Versions
119
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
120
+ Python <= 3.6.
121
+
122
+ The last version of this library compatible with Python 2.7 is google-cloud-pubsub==1.7.0.
123
+
124
+
125
+ Mac/Linux
126
+ ^^^^^^^^^
127
+
128
+ .. code-block:: console
129
+
130
+ pip install virtualenv
131
+ virtualenv <your-env>
132
+ source <your-env>/bin/activate
133
+ <your-env>/bin/pip install google-cloud-pubsub
134
+
135
+
136
+ Windows
137
+ ^^^^^^^
138
+
139
+ .. code-block:: console
140
+
141
+ pip install virtualenv
142
+ virtualenv <your-env>
143
+ <your-env>\Scripts\activate
144
+ <your-env>\Scripts\pip.exe install google-cloud-pubsub
145
+
146
+
147
+ Example Usage
148
+ ~~~~~~~~~~~~~
149
+
150
+ Publishing
151
+ ^^^^^^^^^^
152
+
153
+ To publish data to Cloud Pub/Sub you must create a topic, and then publish
154
+ messages to it
155
+
156
+ .. code-block:: python
157
+
158
+ import os
159
+ from google.cloud import pubsub_v1
160
+
161
+ publisher = pubsub_v1.PublisherClient()
162
+ topic_name = 'projects/{project_id}/topics/{topic}'.format(
163
+ project_id=os.getenv('GOOGLE_CLOUD_PROJECT'),
164
+ topic='MY_TOPIC_NAME', # Set this to something appropriate.
165
+ )
166
+ publisher.create_topic(name=topic_name)
167
+ future = publisher.publish(topic_name, b'My first message!', spam='eggs')
168
+ future.result()
169
+
170
+ To learn more, consult the `publishing documentation`_.
171
+
172
+ .. _publishing documentation: https://cloud.google.com/python/docs/reference/pubsub/latest/google.cloud.pubsub_v1.publisher.client.Client
173
+
174
+
175
+ Subscribing
176
+ ^^^^^^^^^^^
177
+
178
+ To subscribe to data in Cloud Pub/Sub, you create a subscription based on
179
+ the topic, and subscribe to that, passing a callback function.
180
+
181
+ .. code-block:: python
182
+
183
+ import os
184
+ from google.cloud import pubsub_v1
185
+
186
+ topic_name = 'projects/{project_id}/topics/{topic}'.format(
187
+ project_id=os.getenv('GOOGLE_CLOUD_PROJECT'),
188
+ topic='MY_TOPIC_NAME', # Set this to something appropriate.
189
+ )
190
+
191
+ subscription_name = 'projects/{project_id}/subscriptions/{sub}'.format(
192
+ project_id=os.getenv('GOOGLE_CLOUD_PROJECT'),
193
+ sub='MY_SUBSCRIPTION_NAME', # Set this to something appropriate.
194
+ )
195
+
196
+ def callback(message):
197
+ print(message.data)
198
+ message.ack()
199
+
200
+ with pubsub_v1.SubscriberClient() as subscriber:
201
+ subscriber.create_subscription(
202
+ name=subscription_name, topic=topic_name)
203
+ future = subscriber.subscribe(subscription_name, callback)
204
+
205
+ The future returned by the call to ``subscriber.subscribe`` can be used to
206
+ block the current thread until a given condition obtains:
207
+
208
+ .. code-block:: python
209
+
210
+ try:
211
+ future.result()
212
+ except KeyboardInterrupt:
213
+ future.cancel()
214
+
215
+ It is also possible to pull messages in a synchronous (blocking) fashion. To
216
+ learn more about subscribing, consult the `subscriber documentation`_.
217
+
218
+ .. _subscriber documentation: https://cloud.google.com/python/docs/reference/pubsub/latest/google.cloud.pubsub_v1.subscriber.client.Client
219
+
220
+
221
+ Authentication
222
+ ^^^^^^^^^^^^^^
223
+
224
+ It is possible to specify the authentication method to use with the Pub/Sub
225
+ clients. This can be done by providing an explicit `Credentials`_ instance. Support
226
+ for various authentication methods is available from the `google-auth`_ library.
227
+
228
+ For example, to use JSON Web Tokens, provide a `google.auth.jwt.Credentials`_ instance:
229
+
230
+ .. code-block:: python
231
+
232
+ import json
233
+ from google.auth import jwt
234
+
235
+ service_account_info = json.load(open("service-account-info.json"))
236
+ audience = "https://pubsub.googleapis.com/google.pubsub.v1.Subscriber"
237
+
238
+ credentials = jwt.Credentials.from_service_account_info(
239
+ service_account_info, audience=audience
240
+ )
241
+
242
+ subscriber = pubsub_v1.SubscriberClient(credentials=credentials)
243
+
244
+ # The same for the publisher, except that the "audience" claim needs to be adjusted
245
+ publisher_audience = "https://pubsub.googleapis.com/google.pubsub.v1.Publisher"
246
+ credentials_pub = credentials.with_claims(audience=publisher_audience)
247
+ publisher = pubsub_v1.PublisherClient(credentials=credentials_pub)
248
+
249
+ .. _Credentials: https://google-auth.readthedocs.io/en/latest/reference/google.auth.credentials.html#google.auth.credentials.Credentials
250
+ .. _google-auth: https://google-auth.readthedocs.io/en/latest/index.html
251
+ .. _google.auth.jwt.Credentials: https://google-auth.readthedocs.io/en/latest/reference/google.auth.jwt.html#google.auth.jwt.Credentials
252
+
253
+
254
+ Versioning
255
+ ----------
256
+
257
+ This library follows `Semantic Versioning`_.
258
+
259
+ It is currently in major version one (1.y.z), which means that the public API should be considered stable.
260
+
261
+ .. _Semantic Versioning: http://semver.org/
262
+
263
+ Contributing
264
+ ------------
265
+
266
+ Contributions to this library are always welcome and highly encouraged.
267
+
268
+ See the `CONTRIBUTING doc`_ for more information on how to get started.
269
+
270
+ .. _CONTRIBUTING doc: https://github.com/googleapis/google-cloud-python/blob/main/CONTRIBUTING.rst
271
+
272
+ Community
273
+ ---------
274
+
275
+ The best place to ask questions is via Stackoverflow: https://stackoverflow.com/questions/tagged/google-cloud-pubsub
276
+
277
+
278
+ License
279
+ -------
280
+
281
+ Apache 2.0 - See `the LICENSE`_ for more information.
282
+
283
+ .. _the LICENSE: https://github.com/googleapis/google-cloud-python/blob/main/LICENSE
@@ -0,0 +1,85 @@
1
+ google/cloud/pubsub/__init__.py,sha256=u7SbAyeLThrmXKsKbZXgCjCfdl07LgGJhD0-dAV8arQ,945
2
+ google/cloud/pubsub_v1/__init__.py,sha256=1A5nr2pmB6E_2pR2A-SbsNeB4i4CteTDd8rgiNHJ18g,1209
3
+ google/cloud/pubsub_v1/exceptions.py,sha256=HKtrVjDgxMzD1O-Eew7btcwnX8o2be322YWPBotLRKI,711
4
+ google/cloud/pubsub_v1/futures.py,sha256=xuJn6cwTy9bPRGMnxuvpiK7Y1NFF7oo8x6lUH2XbjfY,2031
5
+ google/cloud/pubsub_v1/types.py,sha256=fUSt641z4k9HHyNbASoC7RwVcfqsKPdhlYlXL39ydfY,12819
6
+ google/cloud/pubsub_v1/open_telemetry/__init__.py,sha256=CYb9jcj8d72qQjgHOpli0rsHwrEjPoc8eJ-i4gFaNYI,596
7
+ google/cloud/pubsub_v1/open_telemetry/context_propagation.py,sha256=6RI4O3-Kf795_sF46SwpwAphJVF7wzuSCXdo-BuhOsM,1865
8
+ google/cloud/pubsub_v1/open_telemetry/publish_message_wrapper.py,sha256=spPXnY5TRlBi7qyUI4OkHrtlNN-QpwUW0Evf-GdeYTc,5733
9
+ google/cloud/pubsub_v1/open_telemetry/subscribe_opentelemetry.py,sha256=kpYrZdU84RnE2qVp7BHD6Hp2X1IONrMHMD_xfZvnun4,10724
10
+ google/cloud/pubsub_v1/proto/pubsub.proto,sha256=BttkgZix8kHmEg8AsiUilyhXIxOe3HXvYMjjct2A1AM,58070
11
+ google/cloud/pubsub_v1/proto/schema.proto,sha256=X7inK1rRvFskpadd4vg9JadsZhQHuJ4Wm5NdxID6ZVQ,8781
12
+ google/cloud/pubsub_v1/publisher/__init__.py,sha256=pua8-SSBGHMYK9h7iv9vCRSqMnqWcNNDO5USmEKHRjs,720
13
+ google/cloud/pubsub_v1/publisher/client.py,sha256=0qdNbot9rNHwXzlasz-YMq3zLToQvd3DsSXNwh5qSZU,25188
14
+ google/cloud/pubsub_v1/publisher/exceptions.py,sha256=myPVSwmemhRinVVgOqcu10YWkb9v8U12h65eNMfWnM8,1681
15
+ google/cloud/pubsub_v1/publisher/flow_controller.py,sha256=-g6BvKvxeGe0bGJgYJ8IO1_D8qdEHn96nPIyC_jm3dY,12101
16
+ google/cloud/pubsub_v1/publisher/futures.py,sha256=DyFkoK6_JrjT5x5ep_hBWkpmqxrx-mimwzAdc_u-u3Y,2905
17
+ google/cloud/pubsub_v1/publisher/_batch/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
+ google/cloud/pubsub_v1/publisher/_batch/base.py,sha256=W1_liiHDm-xSPv4oILhXtRSqu48g93VYh5_a1Kvzo4U,6056
19
+ google/cloud/pubsub_v1/publisher/_batch/thread.py,sha256=ykcxSjQrl0uDmXNLS9UQpo5d_d8xGcDyGAoQftgmFjQ,19329
20
+ google/cloud/pubsub_v1/publisher/_sequencer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
+ google/cloud/pubsub_v1/publisher/_sequencer/base.py,sha256=YdcX-yO9WaKZD2mOsm9gsh_L2et5sSkgtyksf5JvJQ8,2848
22
+ google/cloud/pubsub_v1/publisher/_sequencer/ordered_sequencer.py,sha256=BxK1UQj0DGDqiO_-AT8QhuXBE5hHNKhkVD2LXs-UKRI,14449
23
+ google/cloud/pubsub_v1/publisher/_sequencer/unordered_sequencer.py,sha256=KTXgRgXUvuBwEnKyXldUAcQqHAMvkz7Pz7aelDZ_Yig,5988
24
+ google/cloud/pubsub_v1/subscriber/__init__.py,sha256=Tp5fEzeZfNgRdn_1N1blyw1gL7_ix_4gYTarEHZ488c,721
25
+ google/cloud/pubsub_v1/subscriber/client.py,sha256=lAYXliZs5sxXsq7N7AD2PAZ3VqdRKd8EcZiMEHH98K8,13012
26
+ google/cloud/pubsub_v1/subscriber/exceptions.py,sha256=-IF1mpQ-_WcpS5mmfv_n45X5crtgj5p0JL3lvK_LnMQ,1412
27
+ google/cloud/pubsub_v1/subscriber/futures.py,sha256=xV9owQ51GKIZTFj9hdId5KecLrDVxKJWNEIzo_PO5pM,4397
28
+ google/cloud/pubsub_v1/subscriber/message.py,sha256=9sPs707y29OVfKTX7CB7ytl59NLDSNxjLPVp8Mb_Zzo,21545
29
+ google/cloud/pubsub_v1/subscriber/scheduler.py,sha256=5-SFpUwckAWA6fVUu2NNxLqLhHvwQphUwlZQOeo6HWY,6002
30
+ google/cloud/pubsub_v1/subscriber/_protocol/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
+ google/cloud/pubsub_v1/subscriber/_protocol/dispatcher.py,sha256=cjZ3drR7th7V_IRak8SGjtXEek-XaP-MY-LUvzKwcPc,27090
32
+ google/cloud/pubsub_v1/subscriber/_protocol/heartbeater.py,sha256=eDlNUn59x0y-EQssqGMVJN4-98VZQgwuoXnyWJSLggE,2669
33
+ google/cloud/pubsub_v1/subscriber/_protocol/helper_threads.py,sha256=JE5NBJJvzTlsgaIRqofNrol-SiAAI_kpy0nxBd9bo3U,4117
34
+ google/cloud/pubsub_v1/subscriber/_protocol/histogram.py,sha256=g27e-P-jNdrCZCMRkUDUjKZKv4enT1sCYhVfFtdm4Ts,5817
35
+ google/cloud/pubsub_v1/subscriber/_protocol/leaser.py,sha256=owO0IypOXt8vNRZj6KtRYuxeP4Y3raTIdxYZRL7y9Mw,12359
36
+ google/cloud/pubsub_v1/subscriber/_protocol/messages_on_hold.py,sha256=VfwO8xJ5DnpTa-wd1IGmSv1DmuIDKtsZ24YNVbgeXrk,7008
37
+ google/cloud/pubsub_v1/subscriber/_protocol/requests.py,sha256=f3dkfbyRUviknfz0ttM3qwqE3E2r9xxBYmlMbIVFm0E,1844
38
+ google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py,sha256=V8fo4tBvN6pc8rqNrGrtzCe2JfjYyep8L6kqsdVhrQo,54011
39
+ google/pubsub/__init__.py,sha256=cjMhrjqpWT3CzyNy4Fm2YSRy-d2QUERlPAuWSRhnLSc,7367
40
+ google/pubsub/gapic_version.py,sha256=BvEHxn8gVWu_AxYU-gp95PHRQdmgxwuDHyGJxQtqN6Q,653
41
+ google/pubsub/py.typed,sha256=WeASkllZQvpujwvQoRp49k_Zx99oDGPX5nftd3foRnA,80
42
+ google/pubsub_v1/__init__.py,sha256=72G5XzSSD19iIVxcxvRBEtkADYvegjulPZCYPYqngNQ,6117
43
+ google/pubsub_v1/gapic_metadata.json,sha256=obdC4umbAUn3sHZXswg0i6rYkflr2m3actGfin-f-gI,14316
44
+ google/pubsub_v1/gapic_version.py,sha256=BvEHxn8gVWu_AxYU-gp95PHRQdmgxwuDHyGJxQtqN6Q,653
45
+ google/pubsub_v1/py.typed,sha256=WeASkllZQvpujwvQoRp49k_Zx99oDGPX5nftd3foRnA,80
46
+ google/pubsub_v1/services/__init__.py,sha256=ABnBlq63X5TtiLc0JptfQUECNGc-s0WTBlbk0_83qf0,600
47
+ google/pubsub_v1/services/publisher/__init__.py,sha256=GcAiVZ3I_Q09X6v1-3jO6Sqet4ruGr2jJUiGYJecPpI,749
48
+ google/pubsub_v1/services/publisher/async_client.py,sha256=HJgquXQAgQp7oOeOsnAkP3sqcpgWGyXFZ4aFN4LFGw0,69687
49
+ google/pubsub_v1/services/publisher/client.py,sha256=dNIEuTBZCEDsEDzw7A9xkX2M9U9Zmyb5SIgtKkBfaCU,87481
50
+ google/pubsub_v1/services/publisher/pagers.py,sha256=Fnl4o98U7Dn5vAAPtwtOTLqQ9LszYoPUg_NYchNPc50,20297
51
+ google/pubsub_v1/services/publisher/transports/__init__.py,sha256=8QayKkTToh8JOQ_o6AMlSW7h4i_QVOUaVrKeNqishnw,1348
52
+ google/pubsub_v1/services/publisher/transports/base.py,sha256=x0bS9s3TxbW5zoze9SHL3yfOPlbbU4-8kmn3bD8oad0,15193
53
+ google/pubsub_v1/services/publisher/transports/grpc.py,sha256=mhZbcQ9oGRq9TPrH5pVMS-nz29KVAlb7Q_NiOUNsZyQ,29590
54
+ google/pubsub_v1/services/publisher/transports/grpc_asyncio.py,sha256=utRiDc1xLu7PsL6bdMr1IuLlWAFvnLgFxPJEEm1EQLY,36776
55
+ google/pubsub_v1/services/publisher/transports/rest.py,sha256=lErB-DeIV3cWooIQ8045K6UCN4l9gt579IMmKEAALU4,101700
56
+ google/pubsub_v1/services/publisher/transports/rest_base.py,sha256=gwyqQEc-txjTBaBLyz74xuCUTlEpRfngJwhcsdmW3mY,23949
57
+ google/pubsub_v1/services/schema_service/__init__.py,sha256=JbualnFbNc3WnvSIEfqovVuZRjujSue7wPmC2hxX5YE,765
58
+ google/pubsub_v1/services/schema_service/async_client.py,sha256=RTWgdy9KmpueOVqDP4SzFaS1uZvWXw68k9sf0u4BSao,73845
59
+ google/pubsub_v1/services/schema_service/client.py,sha256=5rTC5hB6JfnDL-kfQOm6GIz29ynYYzlUXszqZMcNOjw,90272
60
+ google/pubsub_v1/services/schema_service/pagers.py,sha256=NY6-1Ux0td6CElu0hpqVa7lTpL9yDn8rl2rlbMKcSpQ,13891
61
+ google/pubsub_v1/services/schema_service/transports/__init__.py,sha256=5hwbJko03s2lk5cE-Qr4p_9hpZXFv3kBIlYuDauIk9o,1404
62
+ google/pubsub_v1/services/schema_service/transports/base.py,sha256=DC4N__i4qgj-UJVKL2GtS_8rf0pZMcm0C9X97n8i31o,15338
63
+ google/pubsub_v1/services/schema_service/transports/grpc.py,sha256=lcN7Rea2NJdvVWZRz5gz01stNhkfCH4oChVeGsYk_Pc,29568
64
+ google/pubsub_v1/services/schema_service/transports/grpc_asyncio.py,sha256=6GnkF5gzzQvWmuzT5mwcWuU64d117SLfDDY3kCW5-BU,36626
65
+ google/pubsub_v1/services/schema_service/transports/rest.py,sha256=2eSpGY7esHJIhMmeD8JL2-Ho_KjQxY6ut-m3Z8zRY0o,111293
66
+ google/pubsub_v1/services/schema_service/transports/rest_base.py,sha256=zpDjOJSZQjV2UTuIonghYUqg_PeERwKLhDiXHMcy2yI,26354
67
+ google/pubsub_v1/services/subscriber/__init__.py,sha256=QuaaNhbGBGyNl_LZeWZ4SNeKhI3pAZKjE1W79vmUqdc,753
68
+ google/pubsub_v1/services/subscriber/async_client.py,sha256=4-mpDglCyKbG0MRU5TLgP4aquz6EF4yDLQVC-cDafVo,115568
69
+ google/pubsub_v1/services/subscriber/client.py,sha256=6v96C4YH3C9AmEH25Lv8k1pixMO-15U2MTBzIgi5_DE,132965
70
+ google/pubsub_v1/services/subscriber/pagers.py,sha256=tdB8NsZKjyvrG-29Cx1Jf_wjNQTH_bfxcSWI6hCvYYA,13953
71
+ google/pubsub_v1/services/subscriber/transports/__init__.py,sha256=M-9Gh_O_8PV3UOlJH2hOTJ-wV906e40NETk7f31yIN4,1362
72
+ google/pubsub_v1/services/subscriber/transports/base.py,sha256=zMkT6sv3iSbk4Xh5bvOlPqW241GlGRGGT3tvfIKoTJk,20659
73
+ google/pubsub_v1/services/subscriber/transports/grpc.py,sha256=FXB8QuRe9BxEQFRLGVkBoLJilYabq2nZWqR92DfPWxw,41932
74
+ google/pubsub_v1/services/subscriber/transports/grpc_asyncio.py,sha256=xxDytQ4Zzv-hujUuHP1Lu7Rb7vFM_N9r8X54J9zBwhs,53274
75
+ google/pubsub_v1/services/subscriber/transports/rest.py,sha256=pYui1MBCutpDFzWqxSvsW9lFMFl8KmatF9cuSck8vvg,144141
76
+ google/pubsub_v1/services/subscriber/transports/rest_base.py,sha256=McZ_3W9bS9aYwquTL66bL-Hs_8TvYhDDDO4He4AEX_s,35782
77
+ google/pubsub_v1/types/__init__.py,sha256=oeBo16rtV0xh45DZY_W8Xvpr_gM-6X8mDvkxZRrzh0s,4396
78
+ google/pubsub_v1/types/pubsub.py,sha256=nSltHUe3SV2ORmfJF1BXYwwnMpm3OwwXvrRuM5xO1oo,129198
79
+ google/pubsub_v1/types/schema.py,sha256=EDXRNafY8mPGNNsqw6Oc7lQXN3Zy-FMDQjvst9RBXxA,14172
80
+ google_cloud_pubsub-2.30.0.data/scripts/fixup_pubsub_v1_keywords.py,sha256=fruspMPXXALhqNffYtVunjGQoWhn5NwMIlIYv8K3hJI,8618
81
+ google_cloud_pubsub-2.30.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
82
+ google_cloud_pubsub-2.30.0.dist-info/METADATA,sha256=QErGXlp49fH-ocgtT9FDWln46sxw3xVOUQP7oXmV65s,10014
83
+ google_cloud_pubsub-2.30.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
84
+ google_cloud_pubsub-2.30.0.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
85
+ google_cloud_pubsub-2.30.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+