Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/google/pubsub_v1/types/pubsub.py: 98%

217 statements  

« prev     ^ index     » next       coverage.py v7.2.2, created at 2023-03-26 06:25 +0000

1# -*- coding: utf-8 -*- 

2# Copyright 2022 Google LLC 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); 

5# you may not use this file except in compliance with the License. 

6# You may obtain a copy of the License at 

7# 

8# http://www.apache.org/licenses/LICENSE-2.0 

9# 

10# Unless required by applicable law or agreed to in writing, software 

11# distributed under the License is distributed on an "AS IS" BASIS, 

12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 

13# See the License for the specific language governing permissions and 

14# limitations under the License. 

15# 

16from typing import MutableMapping, MutableSequence 

17 

18import proto # type: ignore 

19 

20from google.protobuf import duration_pb2 # type: ignore 

21from google.protobuf import field_mask_pb2 # type: ignore 

22from google.protobuf import timestamp_pb2 # type: ignore 

23from google.pubsub_v1.types import schema as gp_schema 

24 

25 

26__protobuf__ = proto.module( 

27 package="google.pubsub.v1", 

28 manifest={ 

29 "MessageStoragePolicy", 

30 "SchemaSettings", 

31 "Topic", 

32 "PubsubMessage", 

33 "GetTopicRequest", 

34 "UpdateTopicRequest", 

35 "PublishRequest", 

36 "PublishResponse", 

37 "ListTopicsRequest", 

38 "ListTopicsResponse", 

39 "ListTopicSubscriptionsRequest", 

40 "ListTopicSubscriptionsResponse", 

41 "ListTopicSnapshotsRequest", 

42 "ListTopicSnapshotsResponse", 

43 "DeleteTopicRequest", 

44 "DetachSubscriptionRequest", 

45 "DetachSubscriptionResponse", 

46 "Subscription", 

47 "RetryPolicy", 

48 "DeadLetterPolicy", 

49 "ExpirationPolicy", 

50 "PushConfig", 

51 "BigQueryConfig", 

52 "ReceivedMessage", 

53 "GetSubscriptionRequest", 

54 "UpdateSubscriptionRequest", 

55 "ListSubscriptionsRequest", 

56 "ListSubscriptionsResponse", 

57 "DeleteSubscriptionRequest", 

58 "ModifyPushConfigRequest", 

59 "PullRequest", 

60 "PullResponse", 

61 "ModifyAckDeadlineRequest", 

62 "AcknowledgeRequest", 

63 "StreamingPullRequest", 

64 "StreamingPullResponse", 

65 "CreateSnapshotRequest", 

66 "UpdateSnapshotRequest", 

67 "Snapshot", 

68 "GetSnapshotRequest", 

69 "ListSnapshotsRequest", 

70 "ListSnapshotsResponse", 

71 "DeleteSnapshotRequest", 

72 "SeekRequest", 

73 "SeekResponse", 

74 }, 

75) 

76 

77 

78class MessageStoragePolicy(proto.Message): 

79 r"""A policy constraining the storage of messages published to 

80 the topic. 

81 

82 Attributes: 

83 allowed_persistence_regions (MutableSequence[str]): 

84 A list of IDs of GCP regions where messages 

85 that are published to the topic may be persisted 

86 in storage. Messages published by publishers 

87 running in non-allowed GCP regions (or running 

88 outside of GCP altogether) will be routed for 

89 storage in one of the allowed regions. An empty 

90 list means that no regions are allowed, and is 

91 not a valid configuration. 

92 """ 

93 

94 allowed_persistence_regions: MutableSequence[str] = proto.RepeatedField( 

95 proto.STRING, 

96 number=1, 

97 ) 

98 

99 

100class SchemaSettings(proto.Message): 

101 r"""Settings for validating messages published against a schema. 

102 

103 Attributes: 

104 schema (str): 

105 Required. The name of the schema that messages published 

106 should be validated against. Format is 

107 ``projects/{project}/schemas/{schema}``. The value of this 

108 field will be ``_deleted-schema_`` if the schema has been 

109 deleted. 

110 encoding (google.pubsub_v1.types.Encoding): 

111 The encoding of messages validated against ``schema``. 

112 first_revision_id (str): 

113 The minimum (inclusive) revision allowed for validating 

114 messages. If empty or not present, allow any revision to be 

115 validated against last_revision or any revision created 

116 before. 

117 last_revision_id (str): 

118 The maximum (inclusive) revision allowed for validating 

119 messages. If empty or not present, allow any revision to be 

120 validated against first_revision or any revision created 

121 after. 

122 """ 

123 

124 schema: str = proto.Field( 

125 proto.STRING, 

126 number=1, 

127 ) 

128 encoding: gp_schema.Encoding = proto.Field( 

129 proto.ENUM, 

130 number=2, 

131 enum=gp_schema.Encoding, 

132 ) 

133 first_revision_id: str = proto.Field( 

134 proto.STRING, 

135 number=3, 

136 ) 

137 last_revision_id: str = proto.Field( 

138 proto.STRING, 

139 number=4, 

140 ) 

141 

142 

143class Topic(proto.Message): 

144 r"""A topic resource. 

145 

146 Attributes: 

147 name (str): 

148 Required. The name of the topic. It must have the format 

149 ``"projects/{project}/topics/{topic}"``. ``{topic}`` must 

150 start with a letter, and contain only letters 

151 (``[A-Za-z]``), numbers (``[0-9]``), dashes (``-``), 

152 underscores (``_``), periods (``.``), tildes (``~``), plus 

153 (``+``) or percent signs (``%``). It must be between 3 and 

154 255 characters in length, and it must not start with 

155 ``"goog"``. 

156 labels (MutableMapping[str, str]): 

157 See [Creating and managing labels] 

158 (https://cloud.google.com/pubsub/docs/labels). 

159 message_storage_policy (google.pubsub_v1.types.MessageStoragePolicy): 

160 Policy constraining the set of Google Cloud 

161 Platform regions where messages published to the 

162 topic may be stored. If not present, then no 

163 constraints are in effect. 

164 kms_key_name (str): 

165 The resource name of the Cloud KMS CryptoKey to be used to 

166 protect access to messages published on this topic. 

167 

168 The expected format is 

169 ``projects/*/locations/*/keyRings/*/cryptoKeys/*``. 

170 schema_settings (google.pubsub_v1.types.SchemaSettings): 

171 Settings for validating messages published 

172 against a schema. 

173 satisfies_pzs (bool): 

174 Reserved for future use. This field is set 

175 only in responses from the server; it is ignored 

176 if it is set in any requests. 

177 message_retention_duration (google.protobuf.duration_pb2.Duration): 

178 Indicates the minimum duration to retain a message after it 

179 is published to the topic. If this field is set, messages 

180 published to the topic in the last 

181 ``message_retention_duration`` are always available to 

182 subscribers. For instance, it allows any attached 

183 subscription to `seek to a 

184 timestamp <https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time>`__ 

185 that is up to ``message_retention_duration`` in the past. If 

186 this field is not set, message retention is controlled by 

187 settings on individual subscriptions. Cannot be more than 31 

188 days or less than 10 minutes. 

189 """ 

190 

191 name: str = proto.Field( 

192 proto.STRING, 

193 number=1, 

194 ) 

195 labels: MutableMapping[str, str] = proto.MapField( 

196 proto.STRING, 

197 proto.STRING, 

198 number=2, 

199 ) 

200 message_storage_policy: "MessageStoragePolicy" = proto.Field( 

201 proto.MESSAGE, 

202 number=3, 

203 message="MessageStoragePolicy", 

204 ) 

205 kms_key_name: str = proto.Field( 

206 proto.STRING, 

207 number=5, 

208 ) 

209 schema_settings: "SchemaSettings" = proto.Field( 

210 proto.MESSAGE, 

211 number=6, 

212 message="SchemaSettings", 

213 ) 

214 satisfies_pzs: bool = proto.Field( 

215 proto.BOOL, 

216 number=7, 

217 ) 

218 message_retention_duration: duration_pb2.Duration = proto.Field( 

219 proto.MESSAGE, 

220 number=8, 

221 message=duration_pb2.Duration, 

222 ) 

223 

224 

225class PubsubMessage(proto.Message): 

226 r"""A message that is published by publishers and consumed by 

227 subscribers. The message must contain either a non-empty data field 

228 or at least one attribute. Note that client libraries represent this 

229 object differently depending on the language. See the corresponding 

230 `client library 

231 documentation <https://cloud.google.com/pubsub/docs/reference/libraries>`__ 

232 for more information. See [quotas and limits] 

233 (https://cloud.google.com/pubsub/quotas) for more information about 

234 message limits. 

235 

236 Attributes: 

237 data (bytes): 

238 The message data field. If this field is 

239 empty, the message must contain at least one 

240 attribute. 

241 attributes (MutableMapping[str, str]): 

242 Attributes for this message. If this field is 

243 empty, the message must contain non-empty data. 

244 This can be used to filter messages on the 

245 subscription. 

246 message_id (str): 

247 ID of this message, assigned by the server when the message 

248 is published. Guaranteed to be unique within the topic. This 

249 value may be read by a subscriber that receives a 

250 ``PubsubMessage`` via a ``Pull`` call or a push delivery. It 

251 must not be populated by the publisher in a ``Publish`` 

252 call. 

253 publish_time (google.protobuf.timestamp_pb2.Timestamp): 

254 The time at which the message was published, populated by 

255 the server when it receives the ``Publish`` call. It must 

256 not be populated by the publisher in a ``Publish`` call. 

257 ordering_key (str): 

258 If non-empty, identifies related messages for which publish 

259 order should be respected. If a ``Subscription`` has 

260 ``enable_message_ordering`` set to ``true``, messages 

261 published with the same non-empty ``ordering_key`` value 

262 will be delivered to subscribers in the order in which they 

263 are received by the Pub/Sub system. All ``PubsubMessage``\ s 

264 published in a given ``PublishRequest`` must specify the 

265 same ``ordering_key`` value. 

266 """ 

267 

268 data: bytes = proto.Field( 

269 proto.BYTES, 

270 number=1, 

271 ) 

272 attributes: MutableMapping[str, str] = proto.MapField( 

273 proto.STRING, 

274 proto.STRING, 

275 number=2, 

276 ) 

277 message_id: str = proto.Field( 

278 proto.STRING, 

279 number=3, 

280 ) 

281 publish_time: timestamp_pb2.Timestamp = proto.Field( 

282 proto.MESSAGE, 

283 number=4, 

284 message=timestamp_pb2.Timestamp, 

285 ) 

286 ordering_key: str = proto.Field( 

287 proto.STRING, 

288 number=5, 

289 ) 

290 

291 

292class GetTopicRequest(proto.Message): 

293 r"""Request for the GetTopic method. 

294 

295 Attributes: 

296 topic (str): 

297 Required. The name of the topic to get. Format is 

298 ``projects/{project}/topics/{topic}``. 

299 """ 

300 

301 topic: str = proto.Field( 

302 proto.STRING, 

303 number=1, 

304 ) 

305 

306 

307class UpdateTopicRequest(proto.Message): 

308 r"""Request for the UpdateTopic method. 

309 

310 Attributes: 

311 topic (google.pubsub_v1.types.Topic): 

312 Required. The updated topic object. 

313 update_mask (google.protobuf.field_mask_pb2.FieldMask): 

314 Required. Indicates which fields in the provided topic to 

315 update. Must be specified and non-empty. Note that if 

316 ``update_mask`` contains "message_storage_policy" but the 

317 ``message_storage_policy`` is not set in the ``topic`` 

318 provided above, then the updated value is determined by the 

319 policy configured at the project or organization level. 

320 """ 

321 

322 topic: "Topic" = proto.Field( 

323 proto.MESSAGE, 

324 number=1, 

325 message="Topic", 

326 ) 

327 update_mask: field_mask_pb2.FieldMask = proto.Field( 

328 proto.MESSAGE, 

329 number=2, 

330 message=field_mask_pb2.FieldMask, 

331 ) 

332 

333 

334class PublishRequest(proto.Message): 

335 r"""Request for the Publish method. 

336 

337 Attributes: 

338 topic (str): 

339 Required. The messages in the request will be published on 

340 this topic. Format is ``projects/{project}/topics/{topic}``. 

341 messages (MutableSequence[google.pubsub_v1.types.PubsubMessage]): 

342 Required. The messages to publish. 

343 """ 

344 

345 topic: str = proto.Field( 

346 proto.STRING, 

347 number=1, 

348 ) 

349 messages: MutableSequence["PubsubMessage"] = proto.RepeatedField( 

350 proto.MESSAGE, 

351 number=2, 

352 message="PubsubMessage", 

353 ) 

354 

355 

356class PublishResponse(proto.Message): 

357 r"""Response for the ``Publish`` method. 

358 

359 Attributes: 

360 message_ids (MutableSequence[str]): 

361 The server-assigned ID of each published 

362 message, in the same order as the messages in 

363 the request. IDs are guaranteed to be unique 

364 within the topic. 

365 """ 

366 

367 message_ids: MutableSequence[str] = proto.RepeatedField( 

368 proto.STRING, 

369 number=1, 

370 ) 

371 

372 

373class ListTopicsRequest(proto.Message): 

374 r"""Request for the ``ListTopics`` method. 

375 

376 Attributes: 

377 project (str): 

378 Required. The name of the project in which to list topics. 

379 Format is ``projects/{project-id}``. 

380 page_size (int): 

381 Maximum number of topics to return. 

382 page_token (str): 

383 The value returned by the last ``ListTopicsResponse``; 

384 indicates that this is a continuation of a prior 

385 ``ListTopics`` call, and that the system should return the 

386 next page of data. 

387 """ 

388 

389 project: str = proto.Field( 

390 proto.STRING, 

391 number=1, 

392 ) 

393 page_size: int = proto.Field( 

394 proto.INT32, 

395 number=2, 

396 ) 

397 page_token: str = proto.Field( 

398 proto.STRING, 

399 number=3, 

400 ) 

401 

402 

403class ListTopicsResponse(proto.Message): 

404 r"""Response for the ``ListTopics`` method. 

405 

406 Attributes: 

407 topics (MutableSequence[google.pubsub_v1.types.Topic]): 

408 The resulting topics. 

409 next_page_token (str): 

410 If not empty, indicates that there may be more topics that 

411 match the request; this value should be passed in a new 

412 ``ListTopicsRequest``. 

413 """ 

414 

415 @property 

416 def raw_page(self): 

417 return self 

418 

419 topics: MutableSequence["Topic"] = proto.RepeatedField( 

420 proto.MESSAGE, 

421 number=1, 

422 message="Topic", 

423 ) 

424 next_page_token: str = proto.Field( 

425 proto.STRING, 

426 number=2, 

427 ) 

428 

429 

430class ListTopicSubscriptionsRequest(proto.Message): 

431 r"""Request for the ``ListTopicSubscriptions`` method. 

432 

433 Attributes: 

434 topic (str): 

435 Required. The name of the topic that subscriptions are 

436 attached to. Format is 

437 ``projects/{project}/topics/{topic}``. 

438 page_size (int): 

439 Maximum number of subscription names to 

440 return. 

441 page_token (str): 

442 The value returned by the last 

443 ``ListTopicSubscriptionsResponse``; indicates that this is a 

444 continuation of a prior ``ListTopicSubscriptions`` call, and 

445 that the system should return the next page of data. 

446 """ 

447 

448 topic: str = proto.Field( 

449 proto.STRING, 

450 number=1, 

451 ) 

452 page_size: int = proto.Field( 

453 proto.INT32, 

454 number=2, 

455 ) 

456 page_token: str = proto.Field( 

457 proto.STRING, 

458 number=3, 

459 ) 

460 

461 

462class ListTopicSubscriptionsResponse(proto.Message): 

463 r"""Response for the ``ListTopicSubscriptions`` method. 

464 

465 Attributes: 

466 subscriptions (MutableSequence[str]): 

467 The names of subscriptions attached to the 

468 topic specified in the request. 

469 next_page_token (str): 

470 If not empty, indicates that there may be more subscriptions 

471 that match the request; this value should be passed in a new 

472 ``ListTopicSubscriptionsRequest`` to get more subscriptions. 

473 """ 

474 

475 @property 

476 def raw_page(self): 

477 return self 

478 

479 subscriptions: MutableSequence[str] = proto.RepeatedField( 

480 proto.STRING, 

481 number=1, 

482 ) 

483 next_page_token: str = proto.Field( 

484 proto.STRING, 

485 number=2, 

486 ) 

487 

488 

489class ListTopicSnapshotsRequest(proto.Message): 

490 r"""Request for the ``ListTopicSnapshots`` method. 

491 

492 Attributes: 

493 topic (str): 

494 Required. The name of the topic that snapshots are attached 

495 to. Format is ``projects/{project}/topics/{topic}``. 

496 page_size (int): 

497 Maximum number of snapshot names to return. 

498 page_token (str): 

499 The value returned by the last 

500 ``ListTopicSnapshotsResponse``; indicates that this is a 

501 continuation of a prior ``ListTopicSnapshots`` call, and 

502 that the system should return the next page of data. 

503 """ 

504 

505 topic: str = proto.Field( 

506 proto.STRING, 

507 number=1, 

508 ) 

509 page_size: int = proto.Field( 

510 proto.INT32, 

511 number=2, 

512 ) 

513 page_token: str = proto.Field( 

514 proto.STRING, 

515 number=3, 

516 ) 

517 

518 

519class ListTopicSnapshotsResponse(proto.Message): 

520 r"""Response for the ``ListTopicSnapshots`` method. 

521 

522 Attributes: 

523 snapshots (MutableSequence[str]): 

524 The names of the snapshots that match the 

525 request. 

526 next_page_token (str): 

527 If not empty, indicates that there may be more snapshots 

528 that match the request; this value should be passed in a new 

529 ``ListTopicSnapshotsRequest`` to get more snapshots. 

530 """ 

531 

532 @property 

533 def raw_page(self): 

534 return self 

535 

536 snapshots: MutableSequence[str] = proto.RepeatedField( 

537 proto.STRING, 

538 number=1, 

539 ) 

540 next_page_token: str = proto.Field( 

541 proto.STRING, 

542 number=2, 

543 ) 

544 

545 

546class DeleteTopicRequest(proto.Message): 

547 r"""Request for the ``DeleteTopic`` method. 

548 

549 Attributes: 

550 topic (str): 

551 Required. Name of the topic to delete. Format is 

552 ``projects/{project}/topics/{topic}``. 

553 """ 

554 

555 topic: str = proto.Field( 

556 proto.STRING, 

557 number=1, 

558 ) 

559 

560 

561class DetachSubscriptionRequest(proto.Message): 

562 r"""Request for the DetachSubscription method. 

563 

564 Attributes: 

565 subscription (str): 

566 Required. The subscription to detach. Format is 

567 ``projects/{project}/subscriptions/{subscription}``. 

568 """ 

569 

570 subscription: str = proto.Field( 

571 proto.STRING, 

572 number=1, 

573 ) 

574 

575 

576class DetachSubscriptionResponse(proto.Message): 

577 r"""Response for the DetachSubscription method. 

578 Reserved for future use. 

579 

580 """ 

581 

582 

583class Subscription(proto.Message): 

584 r"""A subscription resource. If none of ``push_config`` or 

585 ``bigquery_config`` is set, then the subscriber will pull and ack 

586 messages using API methods. At most one of these fields may be set. 

587 

588 Attributes: 

589 name (str): 

590 Required. The name of the subscription. It must have the 

591 format 

592 ``"projects/{project}/subscriptions/{subscription}"``. 

593 ``{subscription}`` must start with a letter, and contain 

594 only letters (``[A-Za-z]``), numbers (``[0-9]``), dashes 

595 (``-``), underscores (``_``), periods (``.``), tildes 

596 (``~``), plus (``+``) or percent signs (``%``). It must be 

597 between 3 and 255 characters in length, and it must not 

598 start with ``"goog"``. 

599 topic (str): 

600 Required. The name of the topic from which this subscription 

601 is receiving messages. Format is 

602 ``projects/{project}/topics/{topic}``. The value of this 

603 field will be ``_deleted-topic_`` if the topic has been 

604 deleted. 

605 push_config (google.pubsub_v1.types.PushConfig): 

606 If push delivery is used with this 

607 subscription, this field is used to configure 

608 it. 

609 bigquery_config (google.pubsub_v1.types.BigQueryConfig): 

610 If delivery to BigQuery is used with this 

611 subscription, this field is used to configure 

612 it. 

613 ack_deadline_seconds (int): 

614 The approximate amount of time (on a best-effort basis) 

615 Pub/Sub waits for the subscriber to acknowledge receipt 

616 before resending the message. In the interval after the 

617 message is delivered and before it is acknowledged, it is 

618 considered to be *outstanding*. During that time period, the 

619 message will not be redelivered (on a best-effort basis). 

620 

621 For pull subscriptions, this value is used as the initial 

622 value for the ack deadline. To override this value for a 

623 given message, call ``ModifyAckDeadline`` with the 

624 corresponding ``ack_id`` if using non-streaming pull or send 

625 the ``ack_id`` in a ``StreamingModifyAckDeadlineRequest`` if 

626 using streaming pull. The minimum custom deadline you can 

627 specify is 10 seconds. The maximum custom deadline you can 

628 specify is 600 seconds (10 minutes). If this parameter is 0, 

629 a default value of 10 seconds is used. 

630 

631 For push delivery, this value is also used to set the 

632 request timeout for the call to the push endpoint. 

633 

634 If the subscriber never acknowledges the message, the 

635 Pub/Sub system will eventually redeliver the message. 

636 retain_acked_messages (bool): 

637 Indicates whether to retain acknowledged messages. If true, 

638 then messages are not expunged from the subscription's 

639 backlog, even if they are acknowledged, until they fall out 

640 of the ``message_retention_duration`` window. This must be 

641 true if you would like to [``Seek`` to a timestamp] 

642 (https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time) 

643 in the past to replay previously-acknowledged messages. 

644 message_retention_duration (google.protobuf.duration_pb2.Duration): 

645 How long to retain unacknowledged messages in the 

646 subscription's backlog, from the moment a message is 

647 published. If ``retain_acked_messages`` is true, then this 

648 also configures the retention of acknowledged messages, and 

649 thus configures how far back in time a ``Seek`` can be done. 

650 Defaults to 7 days. Cannot be more than 7 days or less than 

651 10 minutes. 

652 labels (MutableMapping[str, str]): 

653 See `Creating and managing 

654 labels <https://cloud.google.com/pubsub/docs/labels>`__. 

655 enable_message_ordering (bool): 

656 If true, messages published with the same ``ordering_key`` 

657 in ``PubsubMessage`` will be delivered to the subscribers in 

658 the order in which they are received by the Pub/Sub system. 

659 Otherwise, they may be delivered in any order. 

660 expiration_policy (google.pubsub_v1.types.ExpirationPolicy): 

661 A policy that specifies the conditions for this 

662 subscription's expiration. A subscription is considered 

663 active as long as any connected subscriber is successfully 

664 consuming messages from the subscription or is issuing 

665 operations on the subscription. If ``expiration_policy`` is 

666 not set, a *default policy* with ``ttl`` of 31 days will be 

667 used. The minimum allowed value for 

668 ``expiration_policy.ttl`` is 1 day. 

669 filter (str): 

670 An expression written in the Pub/Sub `filter 

671 language <https://cloud.google.com/pubsub/docs/filtering>`__. 

672 If non-empty, then only ``PubsubMessage``\ s whose 

673 ``attributes`` field matches the filter are delivered on 

674 this subscription. If empty, then no messages are filtered 

675 out. 

676 dead_letter_policy (google.pubsub_v1.types.DeadLetterPolicy): 

677 A policy that specifies the conditions for dead lettering 

678 messages in this subscription. If dead_letter_policy is not 

679 set, dead lettering is disabled. 

680 

681 The Cloud Pub/Sub service account associated with this 

682 subscriptions's parent project (i.e., 

683 service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) 

684 must have permission to Acknowledge() messages on this 

685 subscription. 

686 retry_policy (google.pubsub_v1.types.RetryPolicy): 

687 A policy that specifies how Pub/Sub retries 

688 message delivery for this subscription. 

689 

690 If not set, the default retry policy is applied. 

691 This generally implies that messages will be 

692 retried as soon as possible for healthy 

693 subscribers. RetryPolicy will be triggered on 

694 NACKs or acknowledgement deadline exceeded 

695 events for a given message. 

696 detached (bool): 

697 Indicates whether the subscription is detached from its 

698 topic. Detached subscriptions don't receive messages from 

699 their topic and don't retain any backlog. ``Pull`` and 

700 ``StreamingPull`` requests will return FAILED_PRECONDITION. 

701 If the subscription is a push subscription, pushes to the 

702 endpoint will not be made. 

703 enable_exactly_once_delivery (bool): 

704 If true, Pub/Sub provides the following guarantees for the 

705 delivery of a message with a given value of ``message_id`` 

706 on this subscription: 

707 

708 - The message sent to a subscriber is guaranteed not to be 

709 resent before the message's acknowledgement deadline 

710 expires. 

711 - An acknowledged message will not be resent to a 

712 subscriber. 

713 

714 Note that subscribers may still receive multiple copies of a 

715 message when ``enable_exactly_once_delivery`` is true if the 

716 message was published multiple times by a publisher client. 

717 These copies are considered distinct by Pub/Sub and have 

718 distinct ``message_id`` values. 

719 topic_message_retention_duration (google.protobuf.duration_pb2.Duration): 

720 Output only. Indicates the minimum duration for which a 

721 message is retained after it is published to the 

722 subscription's topic. If this field is set, messages 

723 published to the subscription's topic in the last 

724 ``topic_message_retention_duration`` are always available to 

725 subscribers. See the ``message_retention_duration`` field in 

726 ``Topic``. This field is set only in responses from the 

727 server; it is ignored if it is set in any requests. 

728 state (google.pubsub_v1.types.Subscription.State): 

729 Output only. An output-only field indicating 

730 whether or not the subscription can receive 

731 messages. 

732 """ 

733 

734 class State(proto.Enum): 

735 r"""Possible states for a subscription. 

736 

737 Values: 

738 STATE_UNSPECIFIED (0): 

739 Default value. This value is unused. 

740 ACTIVE (1): 

741 The subscription can actively receive 

742 messages 

743 RESOURCE_ERROR (2): 

744 The subscription cannot receive messages 

745 because of an error with the resource to which 

746 it pushes messages. See the more detailed error 

747 state in the corresponding configuration. 

748 """ 

749 STATE_UNSPECIFIED = 0 

750 ACTIVE = 1 

751 RESOURCE_ERROR = 2 

752 

753 name: str = proto.Field( 

754 proto.STRING, 

755 number=1, 

756 ) 

757 topic: str = proto.Field( 

758 proto.STRING, 

759 number=2, 

760 ) 

761 push_config: "PushConfig" = proto.Field( 

762 proto.MESSAGE, 

763 number=4, 

764 message="PushConfig", 

765 ) 

766 bigquery_config: "BigQueryConfig" = proto.Field( 

767 proto.MESSAGE, 

768 number=18, 

769 message="BigQueryConfig", 

770 ) 

771 ack_deadline_seconds: int = proto.Field( 

772 proto.INT32, 

773 number=5, 

774 ) 

775 retain_acked_messages: bool = proto.Field( 

776 proto.BOOL, 

777 number=7, 

778 ) 

779 message_retention_duration: duration_pb2.Duration = proto.Field( 

780 proto.MESSAGE, 

781 number=8, 

782 message=duration_pb2.Duration, 

783 ) 

784 labels: MutableMapping[str, str] = proto.MapField( 

785 proto.STRING, 

786 proto.STRING, 

787 number=9, 

788 ) 

789 enable_message_ordering: bool = proto.Field( 

790 proto.BOOL, 

791 number=10, 

792 ) 

793 expiration_policy: "ExpirationPolicy" = proto.Field( 

794 proto.MESSAGE, 

795 number=11, 

796 message="ExpirationPolicy", 

797 ) 

798 filter: str = proto.Field( 

799 proto.STRING, 

800 number=12, 

801 ) 

802 dead_letter_policy: "DeadLetterPolicy" = proto.Field( 

803 proto.MESSAGE, 

804 number=13, 

805 message="DeadLetterPolicy", 

806 ) 

807 retry_policy: "RetryPolicy" = proto.Field( 

808 proto.MESSAGE, 

809 number=14, 

810 message="RetryPolicy", 

811 ) 

812 detached: bool = proto.Field( 

813 proto.BOOL, 

814 number=15, 

815 ) 

816 enable_exactly_once_delivery: bool = proto.Field( 

817 proto.BOOL, 

818 number=16, 

819 ) 

820 topic_message_retention_duration: duration_pb2.Duration = proto.Field( 

821 proto.MESSAGE, 

822 number=17, 

823 message=duration_pb2.Duration, 

824 ) 

825 state: State = proto.Field( 

826 proto.ENUM, 

827 number=19, 

828 enum=State, 

829 ) 

830 

831 

832class RetryPolicy(proto.Message): 

833 r"""A policy that specifies how Cloud Pub/Sub retries message delivery. 

834 

835 Retry delay will be exponential based on provided minimum and 

836 maximum backoffs. https://en.wikipedia.org/wiki/Exponential_backoff. 

837 

838 RetryPolicy will be triggered on NACKs or acknowledgement deadline 

839 exceeded events for a given message. 

840 

841 Retry Policy is implemented on a best effort basis. At times, the 

842 delay between consecutive deliveries may not match the 

843 configuration. That is, delay can be more or less than configured 

844 backoff. 

845 

846 Attributes: 

847 minimum_backoff (google.protobuf.duration_pb2.Duration): 

848 The minimum delay between consecutive 

849 deliveries of a given message. Value should be 

850 between 0 and 600 seconds. Defaults to 10 

851 seconds. 

852 maximum_backoff (google.protobuf.duration_pb2.Duration): 

853 The maximum delay between consecutive 

854 deliveries of a given message. Value should be 

855 between 0 and 600 seconds. Defaults to 600 

856 seconds. 

857 """ 

858 

859 minimum_backoff: duration_pb2.Duration = proto.Field( 

860 proto.MESSAGE, 

861 number=1, 

862 message=duration_pb2.Duration, 

863 ) 

864 maximum_backoff: duration_pb2.Duration = proto.Field( 

865 proto.MESSAGE, 

866 number=2, 

867 message=duration_pb2.Duration, 

868 ) 

869 

870 

871class DeadLetterPolicy(proto.Message): 

872 r"""Dead lettering is done on a best effort basis. The same 

873 message might be dead lettered multiple times. 

874 

875 If validation on any of the fields fails at subscription 

876 creation/updation, the create/update subscription request will 

877 fail. 

878 

879 Attributes: 

880 dead_letter_topic (str): 

881 The name of the topic to which dead letter messages should 

882 be published. Format is 

883 ``projects/{project}/topics/{topic}``.The Cloud Pub/Sub 

884 service account associated with the enclosing subscription's 

885 parent project (i.e., 

886 service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) 

887 must have permission to Publish() to this topic. 

888 

889 The operation will fail if the topic does not exist. Users 

890 should ensure that there is a subscription attached to this 

891 topic since messages published to a topic with no 

892 subscriptions are lost. 

893 max_delivery_attempts (int): 

894 The maximum number of delivery attempts for any message. The 

895 value must be between 5 and 100. 

896 

897 The number of delivery attempts is defined as 1 + (the sum 

898 of number of NACKs and number of times the acknowledgement 

899 deadline has been exceeded for the message). 

900 

901 A NACK is any call to ModifyAckDeadline with a 0 deadline. 

902 Note that client libraries may automatically extend 

903 ack_deadlines. 

904 

905 This field will be honored on a best effort basis. 

906 

907 If this parameter is 0, a default value of 5 is used. 

908 """ 

909 

910 dead_letter_topic: str = proto.Field( 

911 proto.STRING, 

912 number=1, 

913 ) 

914 max_delivery_attempts: int = proto.Field( 

915 proto.INT32, 

916 number=2, 

917 ) 

918 

919 

920class ExpirationPolicy(proto.Message): 

921 r"""A policy that specifies the conditions for resource 

922 expiration (i.e., automatic resource deletion). 

923 

924 Attributes: 

925 ttl (google.protobuf.duration_pb2.Duration): 

926 Specifies the "time-to-live" duration for an associated 

927 resource. The resource expires if it is not active for a 

928 period of ``ttl``. The definition of "activity" depends on 

929 the type of the associated resource. The minimum and maximum 

930 allowed values for ``ttl`` depend on the type of the 

931 associated resource, as well. If ``ttl`` is not set, the 

932 associated resource never expires. 

933 """ 

934 

935 ttl: duration_pb2.Duration = proto.Field( 

936 proto.MESSAGE, 

937 number=1, 

938 message=duration_pb2.Duration, 

939 ) 

940 

941 

942class PushConfig(proto.Message): 

943 r"""Configuration for a push delivery endpoint. 

944 

945 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields 

946 

947 Attributes: 

948 push_endpoint (str): 

949 A URL locating the endpoint to which messages should be 

950 pushed. For example, a Webhook endpoint might use 

951 ``https://example.com/push``. 

952 attributes (MutableMapping[str, str]): 

953 Endpoint configuration attributes that can be used to 

954 control different aspects of the message delivery. 

955 

956 The only currently supported attribute is 

957 ``x-goog-version``, which you can use to change the format 

958 of the pushed message. This attribute indicates the version 

959 of the data expected by the endpoint. This controls the 

960 shape of the pushed message (i.e., its fields and metadata). 

961 

962 If not present during the ``CreateSubscription`` call, it 

963 will default to the version of the Pub/Sub API used to make 

964 such call. If not present in a ``ModifyPushConfig`` call, 

965 its value will not be changed. ``GetSubscription`` calls 

966 will always return a valid version, even if the subscription 

967 was created without this attribute. 

968 

969 The only supported values for the ``x-goog-version`` 

970 attribute are: 

971 

972 - ``v1beta1``: uses the push format defined in the v1beta1 

973 Pub/Sub API. 

974 - ``v1`` or ``v1beta2``: uses the push format defined in 

975 the v1 Pub/Sub API. 

976 

977 For example: ``attributes { "x-goog-version": "v1" }`` 

978 oidc_token (google.pubsub_v1.types.PushConfig.OidcToken): 

979 If specified, Pub/Sub will generate and attach an OIDC JWT 

980 token as an ``Authorization`` header in the HTTP request for 

981 every pushed message. 

982 

983 This field is a member of `oneof`_ ``authentication_method``. 

984 """ 

985 

986 class OidcToken(proto.Message): 

987 r"""Contains information needed for generating an `OpenID Connect 

988 token <https://developers.google.com/identity/protocols/OpenIDConnect>`__. 

989 

990 Attributes: 

991 service_account_email (str): 

992 `Service account 

993 email <https://cloud.google.com/iam/docs/service-accounts>`__ 

994 to be used for generating the OIDC token. The caller (for 

995 CreateSubscription, UpdateSubscription, and ModifyPushConfig 

996 RPCs) must have the iam.serviceAccounts.actAs permission for 

997 the service account. 

998 audience (str): 

999 Audience to be used when generating OIDC 

1000 token. The audience claim identifies the 

1001 recipients that the JWT is intended for. The 

1002 audience value is a single case-sensitive 

1003 string. Having multiple values (array) for the 

1004 audience field is not supported. More info about 

1005 the OIDC JWT token audience here: 

1006 https://tools.ietf.org/html/rfc7519#section-4.1.3 

1007 Note: if not specified, the Push endpoint URL 

1008 will be used. 

1009 """ 

1010 

1011 service_account_email: str = proto.Field( 

1012 proto.STRING, 

1013 number=1, 

1014 ) 

1015 audience: str = proto.Field( 

1016 proto.STRING, 

1017 number=2, 

1018 ) 

1019 

1020 push_endpoint: str = proto.Field( 

1021 proto.STRING, 

1022 number=1, 

1023 ) 

1024 attributes: MutableMapping[str, str] = proto.MapField( 

1025 proto.STRING, 

1026 proto.STRING, 

1027 number=2, 

1028 ) 

1029 oidc_token: OidcToken = proto.Field( 

1030 proto.MESSAGE, 

1031 number=3, 

1032 oneof="authentication_method", 

1033 message=OidcToken, 

1034 ) 

1035 

1036 

1037class BigQueryConfig(proto.Message): 

1038 r"""Configuration for a BigQuery subscription. 

1039 

1040 Attributes: 

1041 table (str): 

1042 The name of the table to which to write data, 

1043 of the form {projectId}.{datasetId}.{tableId} 

1044 use_topic_schema (bool): 

1045 When true, use the topic's schema as the 

1046 columns to write to in BigQuery, if it exists. 

1047 write_metadata (bool): 

1048 When true, write the subscription name, message_id, 

1049 publish_time, attributes, and ordering_key to additional 

1050 columns in the table. The subscription name, message_id, and 

1051 publish_time fields are put in their own columns while all 

1052 other message properties (other than data) are written to a 

1053 JSON object in the attributes column. 

1054 drop_unknown_fields (bool): 

1055 When true and use_topic_schema is true, any fields that are 

1056 a part of the topic schema that are not part of the BigQuery 

1057 table schema are dropped when writing to BigQuery. 

1058 Otherwise, the schemas must be kept in sync and any messages 

1059 with extra fields are not written and remain in the 

1060 subscription's backlog. 

1061 state (google.pubsub_v1.types.BigQueryConfig.State): 

1062 Output only. An output-only field that 

1063 indicates whether or not the subscription can 

1064 receive messages. 

1065 """ 

1066 

1067 class State(proto.Enum): 

1068 r"""Possible states for a BigQuery subscription. 

1069 

1070 Values: 

1071 STATE_UNSPECIFIED (0): 

1072 Default value. This value is unused. 

1073 ACTIVE (1): 

1074 The subscription can actively send messages 

1075 to BigQuery 

1076 PERMISSION_DENIED (2): 

1077 Cannot write to the BigQuery table because of permission 

1078 denied errors. This can happen if 

1079 

1080 - Pub/Sub SA has not been granted the `appropriate BigQuery 

1081 IAM 

1082 permissions <https://cloud.google.com/pubsub/docs/create-subscription#assign_bigquery_service_account>`__ 

1083 - bigquery.googleapis.com API is not enabled for the 

1084 project 

1085 (`instructions <https://cloud.google.com/service-usage/docs/enable-disable>`__) 

1086 NOT_FOUND (3): 

1087 Cannot write to the BigQuery table because it 

1088 does not exist. 

1089 SCHEMA_MISMATCH (4): 

1090 Cannot write to the BigQuery table due to a 

1091 schema mismatch. 

1092 """ 

1093 STATE_UNSPECIFIED = 0 

1094 ACTIVE = 1 

1095 PERMISSION_DENIED = 2 

1096 NOT_FOUND = 3 

1097 SCHEMA_MISMATCH = 4 

1098 

1099 table: str = proto.Field( 

1100 proto.STRING, 

1101 number=1, 

1102 ) 

1103 use_topic_schema: bool = proto.Field( 

1104 proto.BOOL, 

1105 number=2, 

1106 ) 

1107 write_metadata: bool = proto.Field( 

1108 proto.BOOL, 

1109 number=3, 

1110 ) 

1111 drop_unknown_fields: bool = proto.Field( 

1112 proto.BOOL, 

1113 number=4, 

1114 ) 

1115 state: State = proto.Field( 

1116 proto.ENUM, 

1117 number=5, 

1118 enum=State, 

1119 ) 

1120 

1121 

1122class ReceivedMessage(proto.Message): 

1123 r"""A message and its corresponding acknowledgment ID. 

1124 

1125 Attributes: 

1126 ack_id (str): 

1127 This ID can be used to acknowledge the 

1128 received message. 

1129 message (google.pubsub_v1.types.PubsubMessage): 

1130 The message. 

1131 delivery_attempt (int): 

1132 The approximate number of times that Cloud Pub/Sub has 

1133 attempted to deliver the associated message to a subscriber. 

1134 

1135 More precisely, this is 1 + (number of NACKs) + (number of 

1136 ack_deadline exceeds) for this message. 

1137 

1138 A NACK is any call to ModifyAckDeadline with a 0 deadline. 

1139 An ack_deadline exceeds event is whenever a message is not 

1140 acknowledged within ack_deadline. Note that ack_deadline is 

1141 initially Subscription.ackDeadlineSeconds, but may get 

1142 extended automatically by the client library. 

1143 

1144 Upon the first delivery of a given message, 

1145 ``delivery_attempt`` will have a value of 1. The value is 

1146 calculated at best effort and is approximate. 

1147 

1148 If a DeadLetterPolicy is not set on the subscription, this 

1149 will be 0. 

1150 """ 

1151 

1152 ack_id: str = proto.Field( 

1153 proto.STRING, 

1154 number=1, 

1155 ) 

1156 message: "PubsubMessage" = proto.Field( 

1157 proto.MESSAGE, 

1158 number=2, 

1159 message="PubsubMessage", 

1160 ) 

1161 delivery_attempt: int = proto.Field( 

1162 proto.INT32, 

1163 number=3, 

1164 ) 

1165 

1166 

1167class GetSubscriptionRequest(proto.Message): 

1168 r"""Request for the GetSubscription method. 

1169 

1170 Attributes: 

1171 subscription (str): 

1172 Required. The name of the subscription to get. Format is 

1173 ``projects/{project}/subscriptions/{sub}``. 

1174 """ 

1175 

1176 subscription: str = proto.Field( 

1177 proto.STRING, 

1178 number=1, 

1179 ) 

1180 

1181 

1182class UpdateSubscriptionRequest(proto.Message): 

1183 r"""Request for the UpdateSubscription method. 

1184 

1185 Attributes: 

1186 subscription (google.pubsub_v1.types.Subscription): 

1187 Required. The updated subscription object. 

1188 update_mask (google.protobuf.field_mask_pb2.FieldMask): 

1189 Required. Indicates which fields in the 

1190 provided subscription to update. Must be 

1191 specified and non-empty. 

1192 """ 

1193 

1194 subscription: "Subscription" = proto.Field( 

1195 proto.MESSAGE, 

1196 number=1, 

1197 message="Subscription", 

1198 ) 

1199 update_mask: field_mask_pb2.FieldMask = proto.Field( 

1200 proto.MESSAGE, 

1201 number=2, 

1202 message=field_mask_pb2.FieldMask, 

1203 ) 

1204 

1205 

1206class ListSubscriptionsRequest(proto.Message): 

1207 r"""Request for the ``ListSubscriptions`` method. 

1208 

1209 Attributes: 

1210 project (str): 

1211 Required. The name of the project in which to list 

1212 subscriptions. Format is ``projects/{project-id}``. 

1213 page_size (int): 

1214 Maximum number of subscriptions to return. 

1215 page_token (str): 

1216 The value returned by the last 

1217 ``ListSubscriptionsResponse``; indicates that this is a 

1218 continuation of a prior ``ListSubscriptions`` call, and that 

1219 the system should return the next page of data. 

1220 """ 

1221 

1222 project: str = proto.Field( 

1223 proto.STRING, 

1224 number=1, 

1225 ) 

1226 page_size: int = proto.Field( 

1227 proto.INT32, 

1228 number=2, 

1229 ) 

1230 page_token: str = proto.Field( 

1231 proto.STRING, 

1232 number=3, 

1233 ) 

1234 

1235 

1236class ListSubscriptionsResponse(proto.Message): 

1237 r"""Response for the ``ListSubscriptions`` method. 

1238 

1239 Attributes: 

1240 subscriptions (MutableSequence[google.pubsub_v1.types.Subscription]): 

1241 The subscriptions that match the request. 

1242 next_page_token (str): 

1243 If not empty, indicates that there may be more subscriptions 

1244 that match the request; this value should be passed in a new 

1245 ``ListSubscriptionsRequest`` to get more subscriptions. 

1246 """ 

1247 

1248 @property 

1249 def raw_page(self): 

1250 return self 

1251 

1252 subscriptions: MutableSequence["Subscription"] = proto.RepeatedField( 

1253 proto.MESSAGE, 

1254 number=1, 

1255 message="Subscription", 

1256 ) 

1257 next_page_token: str = proto.Field( 

1258 proto.STRING, 

1259 number=2, 

1260 ) 

1261 

1262 

1263class DeleteSubscriptionRequest(proto.Message): 

1264 r"""Request for the DeleteSubscription method. 

1265 

1266 Attributes: 

1267 subscription (str): 

1268 Required. The subscription to delete. Format is 

1269 ``projects/{project}/subscriptions/{sub}``. 

1270 """ 

1271 

1272 subscription: str = proto.Field( 

1273 proto.STRING, 

1274 number=1, 

1275 ) 

1276 

1277 

1278class ModifyPushConfigRequest(proto.Message): 

1279 r"""Request for the ModifyPushConfig method. 

1280 

1281 Attributes: 

1282 subscription (str): 

1283 Required. The name of the subscription. Format is 

1284 ``projects/{project}/subscriptions/{sub}``. 

1285 push_config (google.pubsub_v1.types.PushConfig): 

1286 Required. The push configuration for future deliveries. 

1287 

1288 An empty ``pushConfig`` indicates that the Pub/Sub system 

1289 should stop pushing messages from the given subscription and 

1290 allow messages to be pulled and acknowledged - effectively 

1291 pausing the subscription if ``Pull`` or ``StreamingPull`` is 

1292 not called. 

1293 """ 

1294 

1295 subscription: str = proto.Field( 

1296 proto.STRING, 

1297 number=1, 

1298 ) 

1299 push_config: "PushConfig" = proto.Field( 

1300 proto.MESSAGE, 

1301 number=2, 

1302 message="PushConfig", 

1303 ) 

1304 

1305 

1306class PullRequest(proto.Message): 

1307 r"""Request for the ``Pull`` method. 

1308 

1309 Attributes: 

1310 subscription (str): 

1311 Required. The subscription from which messages should be 

1312 pulled. Format is 

1313 ``projects/{project}/subscriptions/{sub}``. 

1314 return_immediately (bool): 

1315 Optional. If this field set to true, the system will respond 

1316 immediately even if it there are no messages available to 

1317 return in the ``Pull`` response. Otherwise, the system may 

1318 wait (for a bounded amount of time) until at least one 

1319 message is available, rather than returning no messages. 

1320 Warning: setting this field to ``true`` is discouraged 

1321 because it adversely impacts the performance of ``Pull`` 

1322 operations. We recommend that users do not set this field. 

1323 max_messages (int): 

1324 Required. The maximum number of messages to 

1325 return for this request. Must be a positive 

1326 integer. The Pub/Sub system may return fewer 

1327 than the number specified. 

1328 """ 

1329 

1330 subscription: str = proto.Field( 

1331 proto.STRING, 

1332 number=1, 

1333 ) 

1334 return_immediately: bool = proto.Field( 

1335 proto.BOOL, 

1336 number=2, 

1337 ) 

1338 max_messages: int = proto.Field( 

1339 proto.INT32, 

1340 number=3, 

1341 ) 

1342 

1343 

1344class PullResponse(proto.Message): 

1345 r"""Response for the ``Pull`` method. 

1346 

1347 Attributes: 

1348 received_messages (MutableSequence[google.pubsub_v1.types.ReceivedMessage]): 

1349 Received Pub/Sub messages. The list will be empty if there 

1350 are no more messages available in the backlog, or if no 

1351 messages could be returned before the request timeout. For 

1352 JSON, the response can be entirely empty. The Pub/Sub system 

1353 may return fewer than the ``maxMessages`` requested even if 

1354 there are more messages available in the backlog. 

1355 """ 

1356 

1357 received_messages: MutableSequence["ReceivedMessage"] = proto.RepeatedField( 

1358 proto.MESSAGE, 

1359 number=1, 

1360 message="ReceivedMessage", 

1361 ) 

1362 

1363 

1364class ModifyAckDeadlineRequest(proto.Message): 

1365 r"""Request for the ModifyAckDeadline method. 

1366 

1367 Attributes: 

1368 subscription (str): 

1369 Required. The name of the subscription. Format is 

1370 ``projects/{project}/subscriptions/{sub}``. 

1371 ack_ids (MutableSequence[str]): 

1372 Required. List of acknowledgment IDs. 

1373 ack_deadline_seconds (int): 

1374 Required. The new ack deadline with respect to the time this 

1375 request was sent to the Pub/Sub system. For example, if the 

1376 value is 10, the new ack deadline will expire 10 seconds 

1377 after the ``ModifyAckDeadline`` call was made. Specifying 

1378 zero might immediately make the message available for 

1379 delivery to another subscriber client. This typically 

1380 results in an increase in the rate of message redeliveries 

1381 (that is, duplicates). The minimum deadline you can specify 

1382 is 0 seconds. The maximum deadline you can specify is 600 

1383 seconds (10 minutes). 

1384 """ 

1385 

1386 subscription: str = proto.Field( 

1387 proto.STRING, 

1388 number=1, 

1389 ) 

1390 ack_ids: MutableSequence[str] = proto.RepeatedField( 

1391 proto.STRING, 

1392 number=4, 

1393 ) 

1394 ack_deadline_seconds: int = proto.Field( 

1395 proto.INT32, 

1396 number=3, 

1397 ) 

1398 

1399 

1400class AcknowledgeRequest(proto.Message): 

1401 r"""Request for the Acknowledge method. 

1402 

1403 Attributes: 

1404 subscription (str): 

1405 Required. The subscription whose message is being 

1406 acknowledged. Format is 

1407 ``projects/{project}/subscriptions/{sub}``. 

1408 ack_ids (MutableSequence[str]): 

1409 Required. The acknowledgment ID for the messages being 

1410 acknowledged that was returned by the Pub/Sub system in the 

1411 ``Pull`` response. Must not be empty. 

1412 """ 

1413 

1414 subscription: str = proto.Field( 

1415 proto.STRING, 

1416 number=1, 

1417 ) 

1418 ack_ids: MutableSequence[str] = proto.RepeatedField( 

1419 proto.STRING, 

1420 number=2, 

1421 ) 

1422 

1423 

1424class StreamingPullRequest(proto.Message): 

1425 r"""Request for the ``StreamingPull`` streaming RPC method. This request 

1426 is used to establish the initial stream as well as to stream 

1427 acknowledgements and ack deadline modifications from the client to 

1428 the server. 

1429 

1430 Attributes: 

1431 subscription (str): 

1432 Required. The subscription for which to initialize the new 

1433 stream. This must be provided in the first request on the 

1434 stream, and must not be set in subsequent requests from 

1435 client to server. Format is 

1436 ``projects/{project}/subscriptions/{sub}``. 

1437 ack_ids (MutableSequence[str]): 

1438 List of acknowledgement IDs for acknowledging previously 

1439 received messages (received on this stream or a different 

1440 stream). If an ack ID has expired, the corresponding message 

1441 may be redelivered later. Acknowledging a message more than 

1442 once will not result in an error. If the acknowledgement ID 

1443 is malformed, the stream will be aborted with status 

1444 ``INVALID_ARGUMENT``. 

1445 modify_deadline_seconds (MutableSequence[int]): 

1446 The list of new ack deadlines for the IDs listed in 

1447 ``modify_deadline_ack_ids``. The size of this list must be 

1448 the same as the size of ``modify_deadline_ack_ids``. If it 

1449 differs the stream will be aborted with 

1450 ``INVALID_ARGUMENT``. Each element in this list is applied 

1451 to the element in the same position in 

1452 ``modify_deadline_ack_ids``. The new ack deadline is with 

1453 respect to the time this request was sent to the Pub/Sub 

1454 system. Must be >= 0. For example, if the value is 10, the 

1455 new ack deadline will expire 10 seconds after this request 

1456 is received. If the value is 0, the message is immediately 

1457 made available for another streaming or non-streaming pull 

1458 request. If the value is < 0 (an error), the stream will be 

1459 aborted with status ``INVALID_ARGUMENT``. 

1460 modify_deadline_ack_ids (MutableSequence[str]): 

1461 List of acknowledgement IDs whose deadline will be modified 

1462 based on the corresponding element in 

1463 ``modify_deadline_seconds``. This field can be used to 

1464 indicate that more time is needed to process a message by 

1465 the subscriber, or to make the message available for 

1466 redelivery if the processing was interrupted. 

1467 stream_ack_deadline_seconds (int): 

1468 Required. The ack deadline to use for the 

1469 stream. This must be provided in the first 

1470 request on the stream, but it can also be 

1471 updated on subsequent requests from client to 

1472 server. The minimum deadline you can specify is 

1473 10 seconds. The maximum deadline you can specify 

1474 is 600 seconds (10 minutes). 

1475 client_id (str): 

1476 A unique identifier that is used to distinguish client 

1477 instances from each other. Only needs to be provided on the 

1478 initial request. When a stream disconnects and reconnects 

1479 for the same stream, the client_id should be set to the same 

1480 value so that state associated with the old stream can be 

1481 transferred to the new stream. The same client_id should not 

1482 be used for different client instances. 

1483 max_outstanding_messages (int): 

1484 Flow control settings for the maximum number of outstanding 

1485 messages. When there are ``max_outstanding_messages`` or 

1486 more currently sent to the streaming pull client that have 

1487 not yet been acked or nacked, the server stops sending more 

1488 messages. The sending of messages resumes once the number of 

1489 outstanding messages is less than this value. If the value 

1490 is <= 0, there is no limit to the number of outstanding 

1491 messages. This property can only be set on the initial 

1492 StreamingPullRequest. If it is set on a subsequent request, 

1493 the stream will be aborted with status ``INVALID_ARGUMENT``. 

1494 max_outstanding_bytes (int): 

1495 Flow control settings for the maximum number of outstanding 

1496 bytes. When there are ``max_outstanding_bytes`` or more 

1497 worth of messages currently sent to the streaming pull 

1498 client that have not yet been acked or nacked, the server 

1499 will stop sending more messages. The sending of messages 

1500 resumes once the number of outstanding bytes is less than 

1501 this value. If the value is <= 0, there is no limit to the 

1502 number of outstanding bytes. This property can only be set 

1503 on the initial StreamingPullRequest. If it is set on a 

1504 subsequent request, the stream will be aborted with status 

1505 ``INVALID_ARGUMENT``. 

1506 """ 

1507 

1508 subscription: str = proto.Field( 

1509 proto.STRING, 

1510 number=1, 

1511 ) 

1512 ack_ids: MutableSequence[str] = proto.RepeatedField( 

1513 proto.STRING, 

1514 number=2, 

1515 ) 

1516 modify_deadline_seconds: MutableSequence[int] = proto.RepeatedField( 

1517 proto.INT32, 

1518 number=3, 

1519 ) 

1520 modify_deadline_ack_ids: MutableSequence[str] = proto.RepeatedField( 

1521 proto.STRING, 

1522 number=4, 

1523 ) 

1524 stream_ack_deadline_seconds: int = proto.Field( 

1525 proto.INT32, 

1526 number=5, 

1527 ) 

1528 client_id: str = proto.Field( 

1529 proto.STRING, 

1530 number=6, 

1531 ) 

1532 max_outstanding_messages: int = proto.Field( 

1533 proto.INT64, 

1534 number=7, 

1535 ) 

1536 max_outstanding_bytes: int = proto.Field( 

1537 proto.INT64, 

1538 number=8, 

1539 ) 

1540 

1541 

1542class StreamingPullResponse(proto.Message): 

1543 r"""Response for the ``StreamingPull`` method. This response is used to 

1544 stream messages from the server to the client. 

1545 

1546 Attributes: 

1547 received_messages (MutableSequence[google.pubsub_v1.types.ReceivedMessage]): 

1548 Received Pub/Sub messages. This will not be 

1549 empty. 

1550 acknowledge_confirmation (google.pubsub_v1.types.StreamingPullResponse.AcknowledgeConfirmation): 

1551 This field will only be set if 

1552 ``enable_exactly_once_delivery`` is set to ``true``. 

1553 modify_ack_deadline_confirmation (google.pubsub_v1.types.StreamingPullResponse.ModifyAckDeadlineConfirmation): 

1554 This field will only be set if 

1555 ``enable_exactly_once_delivery`` is set to ``true``. 

1556 subscription_properties (google.pubsub_v1.types.StreamingPullResponse.SubscriptionProperties): 

1557 Properties associated with this subscription. 

1558 """ 

1559 

1560 class AcknowledgeConfirmation(proto.Message): 

1561 r"""Acknowledgement IDs sent in one or more previous requests to 

1562 acknowledge a previously received message. 

1563 

1564 Attributes: 

1565 ack_ids (MutableSequence[str]): 

1566 Successfully processed acknowledgement IDs. 

1567 invalid_ack_ids (MutableSequence[str]): 

1568 List of acknowledgement IDs that were 

1569 malformed or whose acknowledgement deadline has 

1570 expired. 

1571 unordered_ack_ids (MutableSequence[str]): 

1572 List of acknowledgement IDs that were out of 

1573 order. 

1574 temporary_failed_ack_ids (MutableSequence[str]): 

1575 List of acknowledgement IDs that failed 

1576 processing with temporary issues. 

1577 """ 

1578 

1579 ack_ids: MutableSequence[str] = proto.RepeatedField( 

1580 proto.STRING, 

1581 number=1, 

1582 ) 

1583 invalid_ack_ids: MutableSequence[str] = proto.RepeatedField( 

1584 proto.STRING, 

1585 number=2, 

1586 ) 

1587 unordered_ack_ids: MutableSequence[str] = proto.RepeatedField( 

1588 proto.STRING, 

1589 number=3, 

1590 ) 

1591 temporary_failed_ack_ids: MutableSequence[str] = proto.RepeatedField( 

1592 proto.STRING, 

1593 number=4, 

1594 ) 

1595 

1596 class ModifyAckDeadlineConfirmation(proto.Message): 

1597 r"""Acknowledgement IDs sent in one or more previous requests to 

1598 modify the deadline for a specific message. 

1599 

1600 Attributes: 

1601 ack_ids (MutableSequence[str]): 

1602 Successfully processed acknowledgement IDs. 

1603 invalid_ack_ids (MutableSequence[str]): 

1604 List of acknowledgement IDs that were 

1605 malformed or whose acknowledgement deadline has 

1606 expired. 

1607 temporary_failed_ack_ids (MutableSequence[str]): 

1608 List of acknowledgement IDs that failed 

1609 processing with temporary issues. 

1610 """ 

1611 

1612 ack_ids: MutableSequence[str] = proto.RepeatedField( 

1613 proto.STRING, 

1614 number=1, 

1615 ) 

1616 invalid_ack_ids: MutableSequence[str] = proto.RepeatedField( 

1617 proto.STRING, 

1618 number=2, 

1619 ) 

1620 temporary_failed_ack_ids: MutableSequence[str] = proto.RepeatedField( 

1621 proto.STRING, 

1622 number=3, 

1623 ) 

1624 

1625 class SubscriptionProperties(proto.Message): 

1626 r"""Subscription properties sent as part of the response. 

1627 

1628 Attributes: 

1629 exactly_once_delivery_enabled (bool): 

1630 True iff exactly once delivery is enabled for 

1631 this subscription. 

1632 message_ordering_enabled (bool): 

1633 True iff message ordering is enabled for this 

1634 subscription. 

1635 """ 

1636 

1637 exactly_once_delivery_enabled: bool = proto.Field( 

1638 proto.BOOL, 

1639 number=1, 

1640 ) 

1641 message_ordering_enabled: bool = proto.Field( 

1642 proto.BOOL, 

1643 number=2, 

1644 ) 

1645 

1646 received_messages: MutableSequence["ReceivedMessage"] = proto.RepeatedField( 

1647 proto.MESSAGE, 

1648 number=1, 

1649 message="ReceivedMessage", 

1650 ) 

1651 acknowledge_confirmation: AcknowledgeConfirmation = proto.Field( 

1652 proto.MESSAGE, 

1653 number=5, 

1654 message=AcknowledgeConfirmation, 

1655 ) 

1656 modify_ack_deadline_confirmation: ModifyAckDeadlineConfirmation = proto.Field( 

1657 proto.MESSAGE, 

1658 number=3, 

1659 message=ModifyAckDeadlineConfirmation, 

1660 ) 

1661 subscription_properties: SubscriptionProperties = proto.Field( 

1662 proto.MESSAGE, 

1663 number=4, 

1664 message=SubscriptionProperties, 

1665 ) 

1666 

1667 

1668class CreateSnapshotRequest(proto.Message): 

1669 r"""Request for the ``CreateSnapshot`` method. 

1670 

1671 Attributes: 

1672 name (str): 

1673 Required. User-provided name for this snapshot. If the name 

1674 is not provided in the request, the server will assign a 

1675 random name for this snapshot on the same project as the 

1676 subscription. Note that for REST API requests, you must 

1677 specify a name. See the `resource name 

1678 rules <https://cloud.google.com/pubsub/docs/admin#resource_names>`__. 

1679 Format is ``projects/{project}/snapshots/{snap}``. 

1680 subscription (str): 

1681 Required. The subscription whose backlog the snapshot 

1682 retains. Specifically, the created snapshot is guaranteed to 

1683 retain: (a) The existing backlog on the subscription. More 

1684 precisely, this is defined as the messages in the 

1685 subscription's backlog that are unacknowledged upon the 

1686 successful completion of the ``CreateSnapshot`` request; as 

1687 well as: (b) Any messages published to the subscription's 

1688 topic following the successful completion of the 

1689 CreateSnapshot request. Format is 

1690 ``projects/{project}/subscriptions/{sub}``. 

1691 labels (MutableMapping[str, str]): 

1692 See `Creating and managing 

1693 labels <https://cloud.google.com/pubsub/docs/labels>`__. 

1694 """ 

1695 

1696 name: str = proto.Field( 

1697 proto.STRING, 

1698 number=1, 

1699 ) 

1700 subscription: str = proto.Field( 

1701 proto.STRING, 

1702 number=2, 

1703 ) 

1704 labels: MutableMapping[str, str] = proto.MapField( 

1705 proto.STRING, 

1706 proto.STRING, 

1707 number=3, 

1708 ) 

1709 

1710 

1711class UpdateSnapshotRequest(proto.Message): 

1712 r"""Request for the UpdateSnapshot method. 

1713 

1714 Attributes: 

1715 snapshot (google.pubsub_v1.types.Snapshot): 

1716 Required. The updated snapshot object. 

1717 update_mask (google.protobuf.field_mask_pb2.FieldMask): 

1718 Required. Indicates which fields in the 

1719 provided snapshot to update. Must be specified 

1720 and non-empty. 

1721 """ 

1722 

1723 snapshot: "Snapshot" = proto.Field( 

1724 proto.MESSAGE, 

1725 number=1, 

1726 message="Snapshot", 

1727 ) 

1728 update_mask: field_mask_pb2.FieldMask = proto.Field( 

1729 proto.MESSAGE, 

1730 number=2, 

1731 message=field_mask_pb2.FieldMask, 

1732 ) 

1733 

1734 

1735class Snapshot(proto.Message): 

1736 r"""A snapshot resource. Snapshots are used in 

1737 `Seek <https://cloud.google.com/pubsub/docs/replay-overview>`__ 

1738 operations, which allow you to manage message acknowledgments in 

1739 bulk. That is, you can set the acknowledgment state of messages in 

1740 an existing subscription to the state captured by a snapshot. 

1741 

1742 Attributes: 

1743 name (str): 

1744 The name of the snapshot. 

1745 topic (str): 

1746 The name of the topic from which this 

1747 snapshot is retaining messages. 

1748 expire_time (google.protobuf.timestamp_pb2.Timestamp): 

1749 The snapshot is guaranteed to exist up until this time. A 

1750 newly-created snapshot expires no later than 7 days from the 

1751 time of its creation. Its exact lifetime is determined at 

1752 creation by the existing backlog in the source subscription. 

1753 Specifically, the lifetime of the snapshot is 

1754 ``7 days - (age of oldest unacked message in the subscription)``. 

1755 For example, consider a subscription whose oldest unacked 

1756 message is 3 days old. If a snapshot is created from this 

1757 subscription, the snapshot -- which will always capture this 

1758 3-day-old backlog as long as the snapshot exists -- will 

1759 expire in 4 days. The service will refuse to create a 

1760 snapshot that would expire in less than 1 hour after 

1761 creation. 

1762 labels (MutableMapping[str, str]): 

1763 See [Creating and managing labels] 

1764 (https://cloud.google.com/pubsub/docs/labels). 

1765 """ 

1766 

1767 name: str = proto.Field( 

1768 proto.STRING, 

1769 number=1, 

1770 ) 

1771 topic: str = proto.Field( 

1772 proto.STRING, 

1773 number=2, 

1774 ) 

1775 expire_time: timestamp_pb2.Timestamp = proto.Field( 

1776 proto.MESSAGE, 

1777 number=3, 

1778 message=timestamp_pb2.Timestamp, 

1779 ) 

1780 labels: MutableMapping[str, str] = proto.MapField( 

1781 proto.STRING, 

1782 proto.STRING, 

1783 number=4, 

1784 ) 

1785 

1786 

1787class GetSnapshotRequest(proto.Message): 

1788 r"""Request for the GetSnapshot method. 

1789 

1790 Attributes: 

1791 snapshot (str): 

1792 Required. The name of the snapshot to get. Format is 

1793 ``projects/{project}/snapshots/{snap}``. 

1794 """ 

1795 

1796 snapshot: str = proto.Field( 

1797 proto.STRING, 

1798 number=1, 

1799 ) 

1800 

1801 

1802class ListSnapshotsRequest(proto.Message): 

1803 r"""Request for the ``ListSnapshots`` method. 

1804 

1805 Attributes: 

1806 project (str): 

1807 Required. The name of the project in which to list 

1808 snapshots. Format is ``projects/{project-id}``. 

1809 page_size (int): 

1810 Maximum number of snapshots to return. 

1811 page_token (str): 

1812 The value returned by the last ``ListSnapshotsResponse``; 

1813 indicates that this is a continuation of a prior 

1814 ``ListSnapshots`` call, and that the system should return 

1815 the next page of data. 

1816 """ 

1817 

1818 project: str = proto.Field( 

1819 proto.STRING, 

1820 number=1, 

1821 ) 

1822 page_size: int = proto.Field( 

1823 proto.INT32, 

1824 number=2, 

1825 ) 

1826 page_token: str = proto.Field( 

1827 proto.STRING, 

1828 number=3, 

1829 ) 

1830 

1831 

1832class ListSnapshotsResponse(proto.Message): 

1833 r"""Response for the ``ListSnapshots`` method. 

1834 

1835 Attributes: 

1836 snapshots (MutableSequence[google.pubsub_v1.types.Snapshot]): 

1837 The resulting snapshots. 

1838 next_page_token (str): 

1839 If not empty, indicates that there may be more snapshot that 

1840 match the request; this value should be passed in a new 

1841 ``ListSnapshotsRequest``. 

1842 """ 

1843 

1844 @property 

1845 def raw_page(self): 

1846 return self 

1847 

1848 snapshots: MutableSequence["Snapshot"] = proto.RepeatedField( 

1849 proto.MESSAGE, 

1850 number=1, 

1851 message="Snapshot", 

1852 ) 

1853 next_page_token: str = proto.Field( 

1854 proto.STRING, 

1855 number=2, 

1856 ) 

1857 

1858 

1859class DeleteSnapshotRequest(proto.Message): 

1860 r"""Request for the ``DeleteSnapshot`` method. 

1861 

1862 Attributes: 

1863 snapshot (str): 

1864 Required. The name of the snapshot to delete. Format is 

1865 ``projects/{project}/snapshots/{snap}``. 

1866 """ 

1867 

1868 snapshot: str = proto.Field( 

1869 proto.STRING, 

1870 number=1, 

1871 ) 

1872 

1873 

1874class SeekRequest(proto.Message): 

1875 r"""Request for the ``Seek`` method. 

1876 

1877 This message has `oneof`_ fields (mutually exclusive fields). 

1878 For each oneof, at most one member field can be set at the same time. 

1879 Setting any member of the oneof automatically clears all other 

1880 members. 

1881 

1882 .. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields 

1883 

1884 Attributes: 

1885 subscription (str): 

1886 Required. The subscription to affect. 

1887 time (google.protobuf.timestamp_pb2.Timestamp): 

1888 The time to seek to. Messages retained in the subscription 

1889 that were published before this time are marked as 

1890 acknowledged, and messages retained in the subscription that 

1891 were published after this time are marked as unacknowledged. 

1892 Note that this operation affects only those messages 

1893 retained in the subscription (configured by the combination 

1894 of ``message_retention_duration`` and 

1895 ``retain_acked_messages``). For example, if ``time`` 

1896 corresponds to a point before the message retention window 

1897 (or to a point before the system's notion of the 

1898 subscription creation time), only retained messages will be 

1899 marked as unacknowledged, and already-expunged messages will 

1900 not be restored. 

1901 

1902 This field is a member of `oneof`_ ``target``. 

1903 snapshot (str): 

1904 The snapshot to seek to. The snapshot's topic must be the 

1905 same as that of the provided subscription. Format is 

1906 ``projects/{project}/snapshots/{snap}``. 

1907 

1908 This field is a member of `oneof`_ ``target``. 

1909 """ 

1910 

1911 subscription: str = proto.Field( 

1912 proto.STRING, 

1913 number=1, 

1914 ) 

1915 time: timestamp_pb2.Timestamp = proto.Field( 

1916 proto.MESSAGE, 

1917 number=2, 

1918 oneof="target", 

1919 message=timestamp_pb2.Timestamp, 

1920 ) 

1921 snapshot: str = proto.Field( 

1922 proto.STRING, 

1923 number=3, 

1924 oneof="target", 

1925 ) 

1926 

1927 

1928class SeekResponse(proto.Message): 

1929 r"""Response for the ``Seek`` method (this response is empty).""" 

1930 

1931 

1932__all__ = tuple(sorted(__protobuf__.manifest))