@@ -55,25 +55,23 @@ class PubSubCreateTopicOperator(BaseOperator):
55
55
56
56
with DAG('successful DAG') as dag:
57
57
(
58
- PubSubTopicCreateOperator(project='my-project',
59
- topic='my_new_topic')
60
- >> PubSubTopicCreateOperator(project='my-project',
61
- topic='my_new_topic')
58
+ PubSubCreateTopicOperator(project_id='my-project', topic='my_new_topic')
59
+ >> PubSubCreateTopicOperator(project_id='my-project', topic='my_new_topic')
62
60
)
63
61
64
62
The operator can be configured to fail if the topic already exists. ::
65
63
66
64
with DAG('failing DAG') as dag:
67
65
(
68
- PubSubTopicCreateOperator(project='my-project',
69
- topic='my_new_topic')
70
- >> PubSubTopicCreateOperator(project='my-project',
71
- topic='my_new_topic',
72
- fail_if_exists=True)
66
+ PubSubCreateTopicOperator(project_id='my-project', topic='my_new_topic')
67
+ >> PubSubCreateTopicOperator(
68
+ project_id='my-project',
69
+ topic='my_new_topic',
70
+ fail_if_exists=True,
71
+ )
73
72
)
74
73
75
- Both ``project`` and ``topic`` are templated so you can use
76
- variables in them.
74
+ Both ``project_id`` and ``topic`` are templated so you can use Jinja templating in their values.
77
75
78
76
:param project_id: Optional, the Google Cloud project ID where the topic will be created.
79
77
If set to None or missing, the default project_id from the Google Cloud connection is used.
@@ -192,47 +190,53 @@ class PubSubCreateSubscriptionOperator(BaseOperator):
192
190
For more information on how to use this operator, take a look at the guide:
193
191
:ref:`howto/operator:PubSubCreateSubscriptionOperator`
194
192
195
- By default, the subscription will be created in ``topic_project ``. If
196
- ``subscription_project `` is specified and the Google Cloud credentials allow, the
193
+ By default, the subscription will be created in ``project_id ``. If
194
+ ``subscription_project_id `` is specified and the Google Cloud credentials allow, the
197
195
Subscription can be created in a different project from its topic.
198
196
199
197
By default, if the subscription already exists, this operator will
200
198
not cause the DAG to fail. However, the topic must exist in the project. ::
201
199
202
200
with DAG('successful DAG') as dag:
203
201
(
204
- PubSubSubscriptionCreateOperator(
205
- topic_project='my-project', topic='my-topic',
206
- subscription='my-subscription')
207
- >> PubSubSubscriptionCreateOperator(
208
- topic_project='my-project', topic='my-topic',
209
- subscription='my-subscription')
202
+ PubSubCreateSubscriptionOperator(
203
+ project_id='my-project',
204
+ topic='my-topic',
205
+ subscription='my-subscription'
206
+ )
207
+ >> PubSubCreateSubscriptionOperator(
208
+ project_id='my-project',
209
+ topic='my-topic',
210
+ subscription='my-subscription',
211
+ )
210
212
)
211
213
212
214
The operator can be configured to fail if the subscription already exists.
213
215
::
214
216
215
217
with DAG('failing DAG') as dag:
216
218
(
217
- PubSubSubscriptionCreateOperator(
218
- topic_project='my-project', topic='my-topic',
219
- subscription='my-subscription')
220
- >> PubSubSubscriptionCreateOperator(
221
- topic_project='my-project', topic='my-topic',
222
- subscription='my-subscription', fail_if_exists=True)
219
+ PubSubCreateSubscriptionOperator(
220
+ project_id='my-project',
221
+ topic='my-topic',
222
+ subscription='my-subscription',
223
+ )
224
+ >> PubSubCreateSubscriptionOperator(
225
+ project_id='my-project',
226
+ topic='my-topic',
227
+ subscription='my-subscription',
228
+ fail_if_exists=True,
229
+ )
223
230
)
224
231
225
232
Finally, subscription is not required. If not passed, the operator will
226
233
generated a universally unique identifier for the subscription's name. ::
227
234
228
235
with DAG('DAG') as dag:
229
- (
230
- PubSubSubscriptionCreateOperator(
231
- topic_project='my-project', topic='my-topic')
232
- )
236
+ PubSubCreateSubscriptionOperator(project_id='my-project', topic='my-topic')
233
237
234
- ``topic_project ``, ``topic``, ``subscription``, ``subscription_project_id`` and
235
- ``impersonation_chain`` are templated so you can use variables in them .
238
+ ``project_id ``, ``topic``, ``subscription``, ``subscription_project_id`` and
239
+ ``impersonation_chain`` are templated so you can use Jinja templating in their values .
236
240
237
241
:param project_id: Optional, the Google Cloud project ID where the topic exists.
238
242
If set to None or missing, the default project_id from the Google Cloud connection is used.
@@ -357,8 +361,8 @@ def __init__(
357
361
project_id = topic_project
358
362
if subscription_project :
359
363
warnings .warn (
360
- "The project_id parameter has been deprecated. You should pass "
361
- "the subscription_project parameter." ,
364
+ "The subscription_project parameter has been deprecated. You should pass "
365
+ "the subscription_project_id parameter." ,
362
366
DeprecationWarning ,
363
367
stacklevel = 2 ,
364
368
)
@@ -431,22 +435,16 @@ class PubSubDeleteTopicOperator(BaseOperator):
431
435
not cause the DAG to fail. ::
432
436
433
437
with DAG('successful DAG') as dag:
434
- (
435
- PubSubTopicDeleteOperator(project='my-project',
436
- topic='non_existing_topic')
437
- )
438
+ PubSubDeleteTopicOperator(project_id='my-project', topic='non_existing_topic')
438
439
439
440
The operator can be configured to fail if the topic does not exist. ::
440
441
441
442
with DAG('failing DAG') as dag:
442
- (
443
- PubSubTopicCreateOperator(project='my-project',
444
- topic='non_existing_topic',
445
- fail_if_not_exists=True)
443
+ PubSubDeleteTopicOperator(
444
+ project_id='my-project', topic='non_existing_topic', fail_if_not_exists=True,
446
445
)
447
446
448
- Both ``project`` and ``topic`` are templated so you can use
449
- variables in them.
447
+ Both ``project_id`` and ``topic`` are templated so you can use Jinja templating in their values.
450
448
451
449
:param project_id: Optional, the Google Cloud project ID in which to work (templated).
452
450
If set to None or missing, the default project_id from the Google Cloud connection is used.
@@ -551,24 +549,18 @@ class PubSubDeleteSubscriptionOperator(BaseOperator):
551
549
not cause the DAG to fail. ::
552
550
553
551
with DAG('successful DAG') as dag:
554
- (
555
- PubSubSubscriptionDeleteOperator(project='my-project',
556
- subscription='non-existing')
557
- )
552
+ PubSubDeleteSubscriptionOperator(project_id='my-project', subscription='non-existing')
558
553
559
554
The operator can be configured to fail if the subscription already exists.
560
555
561
556
::
562
557
563
558
with DAG('failing DAG') as dag:
564
- (
565
- PubSubSubscriptionDeleteOperator(
566
- project='my-project', subscription='non-existing',
567
- fail_if_not_exists=True)
559
+ PubSubDeleteSubscriptionOperator(
560
+ project_id='my-project', subscription='non-existing', fail_if_not_exists=True,
568
561
)
569
562
570
- ``project``, and ``subscription`` are templated so you can use
571
- variables in them.
563
+ ``project_id``, and ``subscription`` are templated so you can use Jinja templating in their values.
572
564
573
565
:param project_id: Optional, the Google Cloud project ID in which to work (templated).
574
566
If set to None or missing, the default project_id from the Google Cloud connection is used.
@@ -679,14 +671,16 @@ class PubSubPublishMessageOperator(BaseOperator):
679
671
m2 = {'data': b'Knock, knock'}
680
672
m3 = {'attributes': {'foo': ''}}
681
673
682
- t1 = PubSubPublishOperator(
683
- project='my-project',topic='my_topic',
674
+ t1 = PubSubPublishMessageOperator(
675
+ project_id='my-project',
676
+ topic='my_topic',
684
677
messages=[m1, m2, m3],
685
678
create_topic=True,
686
- dag=dag)
679
+ dag=dag,
680
+ )
687
681
688
- ``project`` , ``topic``, and ``messages`` are templated so you can use
689
- variables in them .
682
+ ``project_id`` , ``topic``, and ``messages`` are templated so you can use Jinja templating
683
+ in their values .
690
684
691
685
:param project_id: Optional, the Google Cloud project ID in which to work (templated).
692
686
If set to None or missing, the default project_id from the Google Cloud connection is used.
@@ -775,22 +769,20 @@ class PubSubPullOperator(BaseOperator):
775
769
instead.
776
770
777
771
.. seealso::
778
- For more information on how to use this operator, take a look at the guide:
772
+ For more information on how to use this operator and the PubSubPullSensor , take a look at the guide:
779
773
:ref:`howto/operator:PubSubPullSensor`
780
774
781
- This sensor operator will pull up to ``max_messages`` messages from the
775
+ This operator will pull up to ``max_messages`` messages from the
782
776
specified PubSub subscription. When the subscription returns messages,
783
- the poke method's criteria will be fulfilled and the messages will be
784
- returned from the operator and passed through XCom for downstream tasks.
777
+ the messages will be returned immediately from the operator and passed through XCom for downstream tasks.
785
778
786
779
If ``ack_messages`` is set to True, messages will be immediately
787
780
acknowledged before being returned, otherwise, downstream tasks will be
788
781
responsible for acknowledging them.
789
782
790
- ``project`` and ``subscription`` are templated so you can use
791
- variables in them.
783
+ ``project_id `` and ``subscription`` are templated so you can use Jinja templating in their values.
792
784
793
- :param project : the Google Cloud project ID for the subscription (templated)
785
+ :param project_id : the Google Cloud project ID for the subscription (templated)
794
786
:param subscription: the Pub/Sub subscription name. Do not include the
795
787
full subscription path.
796
788
:param max_messages: The maximum number of messages to retrieve per
0 commit comments