xref: /aosp_15_r20/external/googleapis/google/pubsub/v1/pubsub.proto (revision d5c09012810ac0c9f33fe448fb6da8260d444cc9)
1// Copyright 2023 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto3";
16
17package google.pubsub.v1;
18
19import "google/api/annotations.proto";
20import "google/api/client.proto";
21import "google/api/field_behavior.proto";
22import "google/api/resource.proto";
23import "google/protobuf/duration.proto";
24import "google/protobuf/empty.proto";
25import "google/protobuf/field_mask.proto";
26import "google/protobuf/timestamp.proto";
27import "google/pubsub/v1/schema.proto";
28
29option cc_enable_arenas = true;
30option csharp_namespace = "Google.Cloud.PubSub.V1";
31option go_package = "cloud.google.com/go/pubsub/apiv1/pubsubpb;pubsubpb";
32option java_multiple_files = true;
33option java_outer_classname = "PubsubProto";
34option java_package = "com.google.pubsub.v1";
35option php_namespace = "Google\\Cloud\\PubSub\\V1";
36option ruby_package = "Google::Cloud::PubSub::V1";
37
38// The service that an application uses to manipulate topics, and to send
39// messages to a topic.
40service Publisher {
41  option (google.api.default_host) = "pubsub.googleapis.com";
42  option (google.api.oauth_scopes) =
43      "https://www.googleapis.com/auth/cloud-platform,"
44      "https://www.googleapis.com/auth/pubsub";
45
46  // Creates the given topic with the given name. See the [resource name rules]
47  // (https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names).
48  rpc CreateTopic(Topic) returns (Topic) {
49    option (google.api.http) = {
50      put: "/v1/{name=projects/*/topics/*}"
51      body: "*"
52    };
53    option (google.api.method_signature) = "name";
54  }
55
56  // Updates an existing topic by updating the fields specified in the update
57  // mask. Note that certain properties of a topic are not modifiable.
58  rpc UpdateTopic(UpdateTopicRequest) returns (Topic) {
59    option (google.api.http) = {
60      patch: "/v1/{topic.name=projects/*/topics/*}"
61      body: "*"
62    };
63    option (google.api.method_signature) = "topic,update_mask";
64  }
65
66  // Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic
67  // does not exist.
68  rpc Publish(PublishRequest) returns (PublishResponse) {
69    option (google.api.http) = {
70      post: "/v1/{topic=projects/*/topics/*}:publish"
71      body: "*"
72    };
73    option (google.api.method_signature) = "topic,messages";
74  }
75
76  // Gets the configuration of a topic.
77  rpc GetTopic(GetTopicRequest) returns (Topic) {
78    option (google.api.http) = {
79      get: "/v1/{topic=projects/*/topics/*}"
80    };
81    option (google.api.method_signature) = "topic";
82  }
83
84  // Lists matching topics.
85  rpc ListTopics(ListTopicsRequest) returns (ListTopicsResponse) {
86    option (google.api.http) = {
87      get: "/v1/{project=projects/*}/topics"
88    };
89    option (google.api.method_signature) = "project";
90  }
91
92  // Lists the names of the attached subscriptions on this topic.
93  rpc ListTopicSubscriptions(ListTopicSubscriptionsRequest)
94      returns (ListTopicSubscriptionsResponse) {
95    option (google.api.http) = {
96      get: "/v1/{topic=projects/*/topics/*}/subscriptions"
97    };
98    option (google.api.method_signature) = "topic";
99  }
100
101  // Lists the names of the snapshots on this topic. Snapshots are used in
102  // [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations,
103  // which allow you to manage message acknowledgments in bulk. That is, you can
104  // set the acknowledgment state of messages in an existing subscription to the
105  // state captured by a snapshot.
106  rpc ListTopicSnapshots(ListTopicSnapshotsRequest)
107      returns (ListTopicSnapshotsResponse) {
108    option (google.api.http) = {
109      get: "/v1/{topic=projects/*/topics/*}/snapshots"
110    };
111    option (google.api.method_signature) = "topic";
112  }
113
114  // Deletes the topic with the given name. Returns `NOT_FOUND` if the topic
115  // does not exist. After a topic is deleted, a new topic may be created with
116  // the same name; this is an entirely new topic with none of the old
117  // configuration or subscriptions. Existing subscriptions to this topic are
118  // not deleted, but their `topic` field is set to `_deleted-topic_`.
119  rpc DeleteTopic(DeleteTopicRequest) returns (google.protobuf.Empty) {
120    option (google.api.http) = {
121      delete: "/v1/{topic=projects/*/topics/*}"
122    };
123    option (google.api.method_signature) = "topic";
124  }
125
126  // Detaches a subscription from this topic. All messages retained in the
127  // subscription are dropped. Subsequent `Pull` and `StreamingPull` requests
128  // will return FAILED_PRECONDITION. If the subscription is a push
129  // subscription, pushes to the endpoint will stop.
130  rpc DetachSubscription(DetachSubscriptionRequest)
131      returns (DetachSubscriptionResponse) {
132    option (google.api.http) = {
133      post: "/v1/{subscription=projects/*/subscriptions/*}:detach"
134    };
135  }
136}
137
138// A policy constraining the storage of messages published to the topic.
139message MessageStoragePolicy {
140  // Optional. A list of IDs of Google Cloud regions where messages that are
141  // published to the topic may be persisted in storage. Messages published by
142  // publishers running in non-allowed Google Cloud regions (or running outside
143  // of Google Cloud altogether) are routed for storage in one of the allowed
144  // regions. An empty list means that no regions are allowed, and is not a
145  // valid configuration.
146  repeated string allowed_persistence_regions = 1
147      [(google.api.field_behavior) = OPTIONAL];
148
149  // Optional. If true, `allowed_persistence_regions` is also used to enforce
150  // in-transit guarantees for messages. That is, Pub/Sub will fail
151  // Publish operations on this topic and subscribe operations
152  // on any subscription attached to this topic in any region that is
153  // not in `allowed_persistence_regions`.
154  bool enforce_in_transit = 2 [(google.api.field_behavior) = OPTIONAL];
155}
156
157// Settings for validating messages published against a schema.
158message SchemaSettings {
159  // Required. The name of the schema that messages published should be
160  // validated against. Format is `projects/{project}/schemas/{schema}`. The
161  // value of this field will be `_deleted-schema_` if the schema has been
162  // deleted.
163  string schema = 1 [
164    (google.api.field_behavior) = REQUIRED,
165    (google.api.resource_reference) = { type: "pubsub.googleapis.com/Schema" }
166  ];
167
168  // Optional. The encoding of messages validated against `schema`.
169  Encoding encoding = 2 [(google.api.field_behavior) = OPTIONAL];
170
171  // Optional. The minimum (inclusive) revision allowed for validating messages.
172  // If empty or not present, allow any revision to be validated against
173  // last_revision or any revision created before.
174  string first_revision_id = 3 [(google.api.field_behavior) = OPTIONAL];
175
176  // Optional. The maximum (inclusive) revision allowed for validating messages.
177  // If empty or not present, allow any revision to be validated against
178  // first_revision or any revision created after.
179  string last_revision_id = 4 [(google.api.field_behavior) = OPTIONAL];
180}
181
182// Settings for an ingestion data source on a topic.
183message IngestionDataSourceSettings {
184  // Ingestion settings for Amazon Kinesis Data Streams.
185  message AwsKinesis {
186    // Possible states for ingestion from Amazon Kinesis Data Streams.
187    enum State {
188      // Default value. This value is unused.
189      STATE_UNSPECIFIED = 0;
190
191      // Ingestion is active.
192      ACTIVE = 1;
193
194      // Permission denied encountered while consuming data from Kinesis.
195      // This can happen if:
196      //   - The provided `aws_role_arn` does not exist or does not have the
197      //     appropriate permissions attached.
198      //   - The provided `aws_role_arn` is not set up properly for Identity
199      //     Federation using `gcp_service_account`.
200      //   - The Pub/Sub SA is not granted the
201      //     `iam.serviceAccounts.getOpenIdToken` permission on
202      //     `gcp_service_account`.
203      KINESIS_PERMISSION_DENIED = 2;
204
205      // Permission denied encountered while publishing to the topic. This can
206      // happen if the Pub/Sub SA has not been granted the [appropriate publish
207      // permissions](https://cloud.google.com/pubsub/docs/access-control#pubsub.publisher)
208      PUBLISH_PERMISSION_DENIED = 3;
209
210      // The Kinesis stream does not exist.
211      STREAM_NOT_FOUND = 4;
212
213      // The Kinesis consumer does not exist.
214      CONSUMER_NOT_FOUND = 5;
215    }
216
217    // Output only. An output-only field that indicates the state of the Kinesis
218    // ingestion source.
219    State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
220
221    // Required. The Kinesis stream ARN to ingest data from.
222    string stream_arn = 2 [(google.api.field_behavior) = REQUIRED];
223
224    // Required. The Kinesis consumer ARN to used for ingestion in Enhanced
225    // Fan-Out mode. The consumer must be already created and ready to be used.
226    string consumer_arn = 3 [(google.api.field_behavior) = REQUIRED];
227
228    // Required. AWS role ARN to be used for Federated Identity authentication
229    // with Kinesis. Check the Pub/Sub docs for how to set up this role and the
230    // required permissions that need to be attached to it.
231    string aws_role_arn = 4 [(google.api.field_behavior) = REQUIRED];
232
233    // Required. The GCP service account to be used for Federated Identity
234    // authentication with Kinesis (via a `AssumeRoleWithWebIdentity` call for
235    // the provided role). The `aws_role_arn` must be set up with
236    // `accounts.google.com:sub` equals to this service account number.
237    string gcp_service_account = 5 [(google.api.field_behavior) = REQUIRED];
238  }
239
240  // Only one source type can have settings set.
241  oneof source {
242    // Optional. Amazon Kinesis Data Streams.
243    AwsKinesis aws_kinesis = 1 [(google.api.field_behavior) = OPTIONAL];
244  }
245}
246
247// A topic resource.
248message Topic {
249  option (google.api.resource) = {
250    type: "pubsub.googleapis.com/Topic"
251    pattern: "projects/{project}/topics/{topic}"
252    pattern: "_deleted-topic_"
253  };
254
255  // The state of the topic.
256  enum State {
257    // Default value. This value is unused.
258    STATE_UNSPECIFIED = 0;
259
260    // The topic does not have any persistent errors.
261    ACTIVE = 1;
262
263    // Ingestion from the data source has encountered a permanent error.
264    // See the more detailed error state in the corresponding ingestion
265    // source configuration.
266    INGESTION_RESOURCE_ERROR = 2;
267  }
268
269  // Required. The name of the topic. It must have the format
270  // `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
271  // and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
272  // underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
273  // signs (`%`). It must be between 3 and 255 characters in length, and it
274  // must not start with `"goog"`.
275  string name = 1 [(google.api.field_behavior) = REQUIRED];
276
277  // Optional. See [Creating and managing labels]
278  // (https://cloud.google.com/pubsub/docs/labels).
279  map<string, string> labels = 2 [(google.api.field_behavior) = OPTIONAL];
280
281  // Optional. Policy constraining the set of Google Cloud Platform regions
282  // where messages published to the topic may be stored. If not present, then
283  // no constraints are in effect.
284  MessageStoragePolicy message_storage_policy = 3
285      [(google.api.field_behavior) = OPTIONAL];
286
287  // Optional. The resource name of the Cloud KMS CryptoKey to be used to
288  // protect access to messages published on this topic.
289  //
290  // The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
291  string kms_key_name = 5 [(google.api.field_behavior) = OPTIONAL];
292
293  // Optional. Settings for validating messages published against a schema.
294  SchemaSettings schema_settings = 6 [(google.api.field_behavior) = OPTIONAL];
295
296  // Optional. Reserved for future use. This field is set only in responses from
297  // the server; it is ignored if it is set in any requests.
298  bool satisfies_pzs = 7 [(google.api.field_behavior) = OPTIONAL];
299
300  // Optional. Indicates the minimum duration to retain a message after it is
301  // published to the topic. If this field is set, messages published to the
302  // topic in the last `message_retention_duration` are always available to
303  // subscribers. For instance, it allows any attached subscription to [seek to
304  // a
305  // timestamp](https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time)
306  // that is up to `message_retention_duration` in the past. If this field is
307  // not set, message retention is controlled by settings on individual
308  // subscriptions. Cannot be more than 31 days or less than 10 minutes.
309  google.protobuf.Duration message_retention_duration = 8
310      [(google.api.field_behavior) = OPTIONAL];
311
312  // Output only. An output-only field indicating the state of the topic.
313  State state = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
314
315  // Optional. Settings for ingestion from a data source into this topic.
316  IngestionDataSourceSettings ingestion_data_source_settings = 10
317      [(google.api.field_behavior) = OPTIONAL];
318}
319
320// A message that is published by publishers and consumed by subscribers. The
321// message must contain either a non-empty data field or at least one attribute.
322// Note that client libraries represent this object differently
323// depending on the language. See the corresponding [client library
324// documentation](https://cloud.google.com/pubsub/docs/reference/libraries) for
325// more information. See [quotas and limits]
326// (https://cloud.google.com/pubsub/quotas) for more information about message
327// limits.
328message PubsubMessage {
329  // Optional. The message data field. If this field is empty, the message must
330  // contain at least one attribute.
331  bytes data = 1 [(google.api.field_behavior) = OPTIONAL];
332
333  // Optional. Attributes for this message. If this field is empty, the message
334  // must contain non-empty data. This can be used to filter messages on the
335  // subscription.
336  map<string, string> attributes = 2 [(google.api.field_behavior) = OPTIONAL];
337
338  // ID of this message, assigned by the server when the message is published.
339  // Guaranteed to be unique within the topic. This value may be read by a
340  // subscriber that receives a `PubsubMessage` via a `Pull` call or a push
341  // delivery. It must not be populated by the publisher in a `Publish` call.
342  string message_id = 3;
343
344  // The time at which the message was published, populated by the server when
345  // it receives the `Publish` call. It must not be populated by the
346  // publisher in a `Publish` call.
347  google.protobuf.Timestamp publish_time = 4;
348
349  // Optional. If non-empty, identifies related messages for which publish order
350  // should be respected. If a `Subscription` has `enable_message_ordering` set
351  // to `true`, messages published with the same non-empty `ordering_key` value
352  // will be delivered to subscribers in the order in which they are received by
353  // the Pub/Sub system. All `PubsubMessage`s published in a given
354  // `PublishRequest` must specify the same `ordering_key` value. For more
355  // information, see [ordering
356  // messages](https://cloud.google.com/pubsub/docs/ordering).
357  string ordering_key = 5 [(google.api.field_behavior) = OPTIONAL];
358}
359
360// Request for the GetTopic method.
361message GetTopicRequest {
362  // Required. The name of the topic to get.
363  // Format is `projects/{project}/topics/{topic}`.
364  string topic = 1 [
365    (google.api.field_behavior) = REQUIRED,
366    (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" }
367  ];
368}
369
370// Request for the UpdateTopic method.
371message UpdateTopicRequest {
372  // Required. The updated topic object.
373  Topic topic = 1 [(google.api.field_behavior) = REQUIRED];
374
375  // Required. Indicates which fields in the provided topic to update. Must be
376  // specified and non-empty. Note that if `update_mask` contains
377  // "message_storage_policy" but the `message_storage_policy` is not set in
378  // the `topic` provided above, then the updated value is determined by the
379  // policy configured at the project or organization level.
380  google.protobuf.FieldMask update_mask = 2
381      [(google.api.field_behavior) = REQUIRED];
382}
383
384// Request for the Publish method.
385message PublishRequest {
386  // Required. The messages in the request will be published on this topic.
387  // Format is `projects/{project}/topics/{topic}`.
388  string topic = 1 [
389    (google.api.field_behavior) = REQUIRED,
390    (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" }
391  ];
392
393  // Required. The messages to publish.
394  repeated PubsubMessage messages = 2 [(google.api.field_behavior) = REQUIRED];
395}
396
397// Response for the `Publish` method.
398message PublishResponse {
399  // Optional. The server-assigned ID of each published message, in the same
400  // order as the messages in the request. IDs are guaranteed to be unique
401  // within the topic.
402  repeated string message_ids = 1 [(google.api.field_behavior) = OPTIONAL];
403}
404
405// Request for the `ListTopics` method.
406message ListTopicsRequest {
407  // Required. The name of the project in which to list topics.
408  // Format is `projects/{project-id}`.
409  string project = 1 [
410    (google.api.field_behavior) = REQUIRED,
411    (google.api.resource_reference) = {
412      type: "cloudresourcemanager.googleapis.com/Project"
413    }
414  ];
415
416  // Optional. Maximum number of topics to return.
417  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
418
419  // Optional. The value returned by the last `ListTopicsResponse`; indicates
420  // that this is a continuation of a prior `ListTopics` call, and that the
421  // system should return the next page of data.
422  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
423}
424
425// Response for the `ListTopics` method.
426message ListTopicsResponse {
427  // Optional. The resulting topics.
428  repeated Topic topics = 1 [(google.api.field_behavior) = OPTIONAL];
429
430  // Optional. If not empty, indicates that there may be more topics that match
431  // the request; this value should be passed in a new `ListTopicsRequest`.
432  string next_page_token = 2 [(google.api.field_behavior) = OPTIONAL];
433}
434
435// Request for the `ListTopicSubscriptions` method.
436message ListTopicSubscriptionsRequest {
437  // Required. The name of the topic that subscriptions are attached to.
438  // Format is `projects/{project}/topics/{topic}`.
439  string topic = 1 [
440    (google.api.field_behavior) = REQUIRED,
441    (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" }
442  ];
443
444  // Optional. Maximum number of subscription names to return.
445  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
446
447  // Optional. The value returned by the last `ListTopicSubscriptionsResponse`;
448  // indicates that this is a continuation of a prior `ListTopicSubscriptions`
449  // call, and that the system should return the next page of data.
450  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
451}
452
453// Response for the `ListTopicSubscriptions` method.
454message ListTopicSubscriptionsResponse {
455  // Optional. The names of subscriptions attached to the topic specified in the
456  // request.
457  repeated string subscriptions = 1 [
458    (google.api.field_behavior) = OPTIONAL,
459    (google.api.resource_reference) = {
460      type: "pubsub.googleapis.com/Subscription"
461    }
462  ];
463
464  // Optional. If not empty, indicates that there may be more subscriptions that
465  // match the request; this value should be passed in a new
466  // `ListTopicSubscriptionsRequest` to get more subscriptions.
467  string next_page_token = 2 [(google.api.field_behavior) = OPTIONAL];
468}
469
470// Request for the `ListTopicSnapshots` method.
471message ListTopicSnapshotsRequest {
472  // Required. The name of the topic that snapshots are attached to.
473  // Format is `projects/{project}/topics/{topic}`.
474  string topic = 1 [
475    (google.api.field_behavior) = REQUIRED,
476    (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" }
477  ];
478
479  // Optional. Maximum number of snapshot names to return.
480  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
481
482  // Optional. The value returned by the last `ListTopicSnapshotsResponse`;
483  // indicates that this is a continuation of a prior `ListTopicSnapshots` call,
484  // and that the system should return the next page of data.
485  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
486}
487
488// Response for the `ListTopicSnapshots` method.
489message ListTopicSnapshotsResponse {
490  // Optional. The names of the snapshots that match the request.
491  repeated string snapshots = 1 [(google.api.field_behavior) = OPTIONAL];
492
493  // Optional. If not empty, indicates that there may be more snapshots that
494  // match the request; this value should be passed in a new
495  // `ListTopicSnapshotsRequest` to get more snapshots.
496  string next_page_token = 2 [(google.api.field_behavior) = OPTIONAL];
497}
498
499// Request for the `DeleteTopic` method.
500message DeleteTopicRequest {
501  // Required. Name of the topic to delete.
502  // Format is `projects/{project}/topics/{topic}`.
503  string topic = 1 [
504    (google.api.field_behavior) = REQUIRED,
505    (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" }
506  ];
507}
508
509// Request for the DetachSubscription method.
510message DetachSubscriptionRequest {
511  // Required. The subscription to detach.
512  // Format is `projects/{project}/subscriptions/{subscription}`.
513  string subscription = 1 [
514    (google.api.field_behavior) = REQUIRED,
515    (google.api.resource_reference) = {
516      type: "pubsub.googleapis.com/Subscription"
517    }
518  ];
519}
520
521// Response for the DetachSubscription method.
522// Reserved for future use.
523message DetachSubscriptionResponse {}
524
525// The service that an application uses to manipulate subscriptions and to
526// consume messages from a subscription via the `Pull` method or by
527// establishing a bi-directional stream using the `StreamingPull` method.
528service Subscriber {
529  option (google.api.default_host) = "pubsub.googleapis.com";
530  option (google.api.oauth_scopes) =
531      "https://www.googleapis.com/auth/cloud-platform,"
532      "https://www.googleapis.com/auth/pubsub";
533
534  // Creates a subscription to a given topic. See the [resource name rules]
535  // (https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names).
536  // If the subscription already exists, returns `ALREADY_EXISTS`.
537  // If the corresponding topic doesn't exist, returns `NOT_FOUND`.
538  //
539  // If the name is not provided in the request, the server will assign a random
540  // name for this subscription on the same project as the topic, conforming
541  // to the [resource name format]
542  // (https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names). The
543  // generated name is populated in the returned Subscription object. Note that
544  // for REST API requests, you must specify a name in the request.
545  rpc CreateSubscription(Subscription) returns (Subscription) {
546    option (google.api.http) = {
547      put: "/v1/{name=projects/*/subscriptions/*}"
548      body: "*"
549    };
550    option (google.api.method_signature) =
551        "name,topic,push_config,ack_deadline_seconds";
552  }
553
554  // Gets the configuration details of a subscription.
555  rpc GetSubscription(GetSubscriptionRequest) returns (Subscription) {
556    option (google.api.http) = {
557      get: "/v1/{subscription=projects/*/subscriptions/*}"
558    };
559    option (google.api.method_signature) = "subscription";
560  }
561
562  // Updates an existing subscription by updating the fields specified in the
563  // update mask. Note that certain properties of a subscription, such as its
564  // topic, are not modifiable.
565  rpc UpdateSubscription(UpdateSubscriptionRequest) returns (Subscription) {
566    option (google.api.http) = {
567      patch: "/v1/{subscription.name=projects/*/subscriptions/*}"
568      body: "*"
569    };
570    option (google.api.method_signature) = "subscription,update_mask";
571  }
572
573  // Lists matching subscriptions.
574  rpc ListSubscriptions(ListSubscriptionsRequest)
575      returns (ListSubscriptionsResponse) {
576    option (google.api.http) = {
577      get: "/v1/{project=projects/*}/subscriptions"
578    };
579    option (google.api.method_signature) = "project";
580  }
581
582  // Deletes an existing subscription. All messages retained in the subscription
583  // are immediately dropped. Calls to `Pull` after deletion will return
584  // `NOT_FOUND`. After a subscription is deleted, a new one may be created with
585  // the same name, but the new one has no association with the old
586  // subscription or its topic unless the same topic is specified.
587  rpc DeleteSubscription(DeleteSubscriptionRequest)
588      returns (google.protobuf.Empty) {
589    option (google.api.http) = {
590      delete: "/v1/{subscription=projects/*/subscriptions/*}"
591    };
592    option (google.api.method_signature) = "subscription";
593  }
594
595  // Modifies the ack deadline for a specific message. This method is useful
596  // to indicate that more time is needed to process a message by the
597  // subscriber, or to make the message available for redelivery if the
598  // processing was interrupted. Note that this does not modify the
599  // subscription-level `ackDeadlineSeconds` used for subsequent messages.
600  rpc ModifyAckDeadline(ModifyAckDeadlineRequest)
601      returns (google.protobuf.Empty) {
602    option (google.api.http) = {
603      post: "/v1/{subscription=projects/*/subscriptions/*}:modifyAckDeadline"
604      body: "*"
605    };
606    option (google.api.method_signature) =
607        "subscription,ack_ids,ack_deadline_seconds";
608  }
609
610  // Acknowledges the messages associated with the `ack_ids` in the
611  // `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages
612  // from the subscription.
613  //
614  // Acknowledging a message whose ack deadline has expired may succeed,
615  // but such a message may be redelivered later. Acknowledging a message more
616  // than once will not result in an error.
617  rpc Acknowledge(AcknowledgeRequest) returns (google.protobuf.Empty) {
618    option (google.api.http) = {
619      post: "/v1/{subscription=projects/*/subscriptions/*}:acknowledge"
620      body: "*"
621    };
622    option (google.api.method_signature) = "subscription,ack_ids";
623  }
624
625  // Pulls messages from the server.
626  rpc Pull(PullRequest) returns (PullResponse) {
627    option (google.api.http) = {
628      post: "/v1/{subscription=projects/*/subscriptions/*}:pull"
629      body: "*"
630    };
631    option (google.api.method_signature) =
632        "subscription,return_immediately,max_messages";
633    option (google.api.method_signature) = "subscription,max_messages";
634  }
635
636  // Establishes a stream with the server, which sends messages down to the
637  // client. The client streams acknowledgements and ack deadline modifications
638  // back to the server. The server will close the stream and return the status
639  // on any error. The server may close the stream with status `UNAVAILABLE` to
640  // reassign server-side resources, in which case, the client should
641  // re-establish the stream. Flow control can be achieved by configuring the
642  // underlying RPC channel.
643  rpc StreamingPull(stream StreamingPullRequest)
644      returns (stream StreamingPullResponse) {}
645
646  // Modifies the `PushConfig` for a specified subscription.
647  //
648  // This may be used to change a push subscription to a pull one (signified by
649  // an empty `PushConfig`) or vice versa, or change the endpoint URL and other
650  // attributes of a push subscription. Messages will accumulate for delivery
651  // continuously through the call regardless of changes to the `PushConfig`.
652  rpc ModifyPushConfig(ModifyPushConfigRequest)
653      returns (google.protobuf.Empty) {
654    option (google.api.http) = {
655      post: "/v1/{subscription=projects/*/subscriptions/*}:modifyPushConfig"
656      body: "*"
657    };
658    option (google.api.method_signature) = "subscription,push_config";
659  }
660
661  // Gets the configuration details of a snapshot. Snapshots are used in
662  // [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations,
663  // which allow you to manage message acknowledgments in bulk. That is, you can
664  // set the acknowledgment state of messages in an existing subscription to the
665  // state captured by a snapshot.
666  rpc GetSnapshot(GetSnapshotRequest) returns (Snapshot) {
667    option (google.api.http) = {
668      get: "/v1/{snapshot=projects/*/snapshots/*}"
669    };
670    option (google.api.method_signature) = "snapshot";
671  }
672
673  // Lists the existing snapshots. Snapshots are used in [Seek](
674  // https://cloud.google.com/pubsub/docs/replay-overview) operations, which
675  // allow you to manage message acknowledgments in bulk. That is, you can set
676  // the acknowledgment state of messages in an existing subscription to the
677  // state captured by a snapshot.
678  rpc ListSnapshots(ListSnapshotsRequest) returns (ListSnapshotsResponse) {
679    option (google.api.http) = {
680      get: "/v1/{project=projects/*}/snapshots"
681    };
682    option (google.api.method_signature) = "project";
683  }
684
685  // Creates a snapshot from the requested subscription. Snapshots are used in
686  // [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations,
687  // which allow you to manage message acknowledgments in bulk. That is, you can
688  // set the acknowledgment state of messages in an existing subscription to the
689  // state captured by a snapshot.
690  // If the snapshot already exists, returns `ALREADY_EXISTS`.
691  // If the requested subscription doesn't exist, returns `NOT_FOUND`.
692  // If the backlog in the subscription is too old -- and the resulting snapshot
693  // would expire in less than 1 hour -- then `FAILED_PRECONDITION` is returned.
694  // See also the `Snapshot.expire_time` field. If the name is not provided in
695  // the request, the server will assign a random
696  // name for this snapshot on the same project as the subscription, conforming
697  // to the [resource name format]
698  // (https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names). The
699  // generated name is populated in the returned Snapshot object. Note that for
700  // REST API requests, you must specify a name in the request.
701  rpc CreateSnapshot(CreateSnapshotRequest) returns (Snapshot) {
702    option (google.api.http) = {
703      put: "/v1/{name=projects/*/snapshots/*}"
704      body: "*"
705    };
706    option (google.api.method_signature) = "name,subscription";
707  }
708
709  // Updates an existing snapshot by updating the fields specified in the update
710  // mask. Snapshots are used in
711  // [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations,
712  // which allow you to manage message acknowledgments in bulk. That is, you can
713  // set the acknowledgment state of messages in an existing subscription to the
714  // state captured by a snapshot.
715  rpc UpdateSnapshot(UpdateSnapshotRequest) returns (Snapshot) {
716    option (google.api.http) = {
717      patch: "/v1/{snapshot.name=projects/*/snapshots/*}"
718      body: "*"
719    };
720    option (google.api.method_signature) = "snapshot,update_mask";
721  }
722
723  // Removes an existing snapshot. Snapshots are used in [Seek]
724  // (https://cloud.google.com/pubsub/docs/replay-overview) operations, which
725  // allow you to manage message acknowledgments in bulk. That is, you can set
726  // the acknowledgment state of messages in an existing subscription to the
727  // state captured by a snapshot.
728  // When the snapshot is deleted, all messages retained in the snapshot
729  // are immediately dropped. After a snapshot is deleted, a new one may be
730  // created with the same name, but the new one has no association with the old
731  // snapshot or its subscription, unless the same subscription is specified.
732  rpc DeleteSnapshot(DeleteSnapshotRequest) returns (google.protobuf.Empty) {
733    option (google.api.http) = {
734      delete: "/v1/{snapshot=projects/*/snapshots/*}"
735    };
736    option (google.api.method_signature) = "snapshot";
737  }
738
739  // Seeks an existing subscription to a point in time or to a given snapshot,
740  // whichever is provided in the request. Snapshots are used in [Seek]
741  // (https://cloud.google.com/pubsub/docs/replay-overview) operations, which
742  // allow you to manage message acknowledgments in bulk. That is, you can set
743  // the acknowledgment state of messages in an existing subscription to the
744  // state captured by a snapshot. Note that both the subscription and the
745  // snapshot must be on the same topic.
746  rpc Seek(SeekRequest) returns (SeekResponse) {
747    option (google.api.http) = {
748      post: "/v1/{subscription=projects/*/subscriptions/*}:seek"
749      body: "*"
750    };
751  }
752}
753
754// A subscription resource. If none of `push_config`, `bigquery_config`, or
755// `cloud_storage_config` is set, then the subscriber will pull and ack messages
756// using API methods. At most one of these fields may be set.
757message Subscription {
758  option (google.api.resource) = {
759    type: "pubsub.googleapis.com/Subscription"
760    pattern: "projects/{project}/subscriptions/{subscription}"
761  };
762
763  // Possible states for a subscription.
764  enum State {
765    // Default value. This value is unused.
766    STATE_UNSPECIFIED = 0;
767
768    // The subscription can actively receive messages
769    ACTIVE = 1;
770
771    // The subscription cannot receive messages because of an error with the
772    // resource to which it pushes messages. See the more detailed error state
773    // in the corresponding configuration.
774    RESOURCE_ERROR = 2;
775  }
776
777  // Required. The name of the subscription. It must have the format
778  // `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
779  // start with a letter, and contain only letters (`[A-Za-z]`), numbers
780  // (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
781  // plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
782  // in length, and it must not start with `"goog"`.
783  string name = 1 [(google.api.field_behavior) = REQUIRED];
784
785  // Required. The name of the topic from which this subscription is receiving
786  // messages. Format is `projects/{project}/topics/{topic}`. The value of this
787  // field will be `_deleted-topic_` if the topic has been deleted.
788  string topic = 2 [
789    (google.api.field_behavior) = REQUIRED,
790    (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" }
791  ];
792
793  // Optional. If push delivery is used with this subscription, this field is
794  // used to configure it.
795  PushConfig push_config = 4 [(google.api.field_behavior) = OPTIONAL];
796
797  // Optional. If delivery to BigQuery is used with this subscription, this
798  // field is used to configure it.
799  BigQueryConfig bigquery_config = 18 [(google.api.field_behavior) = OPTIONAL];
800
801  // Optional. If delivery to Google Cloud Storage is used with this
802  // subscription, this field is used to configure it.
803  CloudStorageConfig cloud_storage_config = 22
804      [(google.api.field_behavior) = OPTIONAL];
805
806  // Optional. The approximate amount of time (on a best-effort basis) Pub/Sub
807  // waits for the subscriber to acknowledge receipt before resending the
808  // message. In the interval after the message is delivered and before it is
809  // acknowledged, it is considered to be _outstanding_. During that time
810  // period, the message will not be redelivered (on a best-effort basis).
811  //
812  // For pull subscriptions, this value is used as the initial value for the ack
813  // deadline. To override this value for a given message, call
814  // `ModifyAckDeadline` with the corresponding `ack_id` if using
815  // non-streaming pull or send the `ack_id` in a
816  // `StreamingModifyAckDeadlineRequest` if using streaming pull.
817  // The minimum custom deadline you can specify is 10 seconds.
818  // The maximum custom deadline you can specify is 600 seconds (10 minutes).
819  // If this parameter is 0, a default value of 10 seconds is used.
820  //
821  // For push delivery, this value is also used to set the request timeout for
822  // the call to the push endpoint.
823  //
824  // If the subscriber never acknowledges the message, the Pub/Sub
825  // system will eventually redeliver the message.
826  int32 ack_deadline_seconds = 5 [(google.api.field_behavior) = OPTIONAL];
827
828  // Optional. Indicates whether to retain acknowledged messages. If true, then
829  // messages are not expunged from the subscription's backlog, even if they are
830  // acknowledged, until they fall out of the `message_retention_duration`
831  // window. This must be true if you would like to [`Seek` to a timestamp]
832  // (https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time) in
833  // the past to replay previously-acknowledged messages.
834  bool retain_acked_messages = 7 [(google.api.field_behavior) = OPTIONAL];
835
836  // Optional. How long to retain unacknowledged messages in the subscription's
837  // backlog, from the moment a message is published. If `retain_acked_messages`
838  // is true, then this also configures the retention of acknowledged messages,
839  // and thus configures how far back in time a `Seek` can be done. Defaults to
840  // 7 days. Cannot be more than 7 days or less than 10 minutes.
841  google.protobuf.Duration message_retention_duration = 8
842      [(google.api.field_behavior) = OPTIONAL];
843
844  // Optional. See [Creating and managing
845  // labels](https://cloud.google.com/pubsub/docs/labels).
846  map<string, string> labels = 9 [(google.api.field_behavior) = OPTIONAL];
847
848  // Optional. If true, messages published with the same `ordering_key` in
849  // `PubsubMessage` will be delivered to the subscribers in the order in which
850  // they are received by the Pub/Sub system. Otherwise, they may be delivered
851  // in any order.
852  bool enable_message_ordering = 10 [(google.api.field_behavior) = OPTIONAL];
853
854  // Optional. A policy that specifies the conditions for this subscription's
855  // expiration. A subscription is considered active as long as any connected
856  // subscriber is successfully consuming messages from the subscription or is
857  // issuing operations on the subscription. If `expiration_policy` is not set,
858  // a *default policy* with `ttl` of 31 days will be used. The minimum allowed
859  // value for `expiration_policy.ttl` is 1 day. If `expiration_policy` is set,
860  // but `expiration_policy.ttl` is not set, the subscription never expires.
861  ExpirationPolicy expiration_policy = 11
862      [(google.api.field_behavior) = OPTIONAL];
863
864  // Optional. An expression written in the Pub/Sub [filter
865  // language](https://cloud.google.com/pubsub/docs/filtering). If non-empty,
866  // then only `PubsubMessage`s whose `attributes` field matches the filter are
867  // delivered on this subscription. If empty, then no messages are filtered
868  // out.
869  string filter = 12 [(google.api.field_behavior) = OPTIONAL];
870
871  // Optional. A policy that specifies the conditions for dead lettering
872  // messages in this subscription. If dead_letter_policy is not set, dead
873  // lettering is disabled.
874  //
875  // The Pub/Sub service account associated with this subscriptions's
876  // parent project (i.e.,
877  // service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have
878  // permission to Acknowledge() messages on this subscription.
879  DeadLetterPolicy dead_letter_policy = 13
880      [(google.api.field_behavior) = OPTIONAL];
881
882  // Optional. A policy that specifies how Pub/Sub retries message delivery for
883  // this subscription.
884  //
885  // If not set, the default retry policy is applied. This generally implies
886  // that messages will be retried as soon as possible for healthy subscribers.
887  // RetryPolicy will be triggered on NACKs or acknowledgement deadline
888  // exceeded events for a given message.
889  RetryPolicy retry_policy = 14 [(google.api.field_behavior) = OPTIONAL];
890
891  // Optional. Indicates whether the subscription is detached from its topic.
892  // Detached subscriptions don't receive messages from their topic and don't
893  // retain any backlog. `Pull` and `StreamingPull` requests will return
894  // FAILED_PRECONDITION. If the subscription is a push subscription, pushes to
895  // the endpoint will not be made.
896  bool detached = 15 [(google.api.field_behavior) = OPTIONAL];
897
898  // Optional. If true, Pub/Sub provides the following guarantees for the
899  // delivery of a message with a given value of `message_id` on this
900  // subscription:
901  //
902  // * The message sent to a subscriber is guaranteed not to be resent
903  // before the message's acknowledgement deadline expires.
904  // * An acknowledged message will not be resent to a subscriber.
905  //
906  // Note that subscribers may still receive multiple copies of a message
907  // when `enable_exactly_once_delivery` is true if the message was published
908  // multiple times by a publisher client. These copies are  considered distinct
909  // by Pub/Sub and have distinct `message_id` values.
910  bool enable_exactly_once_delivery = 16
911      [(google.api.field_behavior) = OPTIONAL];
912
913  // Output only. Indicates the minimum duration for which a message is retained
914  // after it is published to the subscription's topic. If this field is set,
915  // messages published to the subscription's topic in the last
916  // `topic_message_retention_duration` are always available to subscribers. See
917  // the `message_retention_duration` field in `Topic`. This field is set only
918  // in responses from the server; it is ignored if it is set in any requests.
919  google.protobuf.Duration topic_message_retention_duration = 17
920      [(google.api.field_behavior) = OUTPUT_ONLY];
921
922  // Output only. An output-only field indicating whether or not the
923  // subscription can receive messages.
924  State state = 19 [(google.api.field_behavior) = OUTPUT_ONLY];
925}
926
927// A policy that specifies how Pub/Sub retries message delivery.
928//
929// Retry delay will be exponential based on provided minimum and maximum
930// backoffs. https://en.wikipedia.org/wiki/Exponential_backoff.
931//
932// RetryPolicy will be triggered on NACKs or acknowledgement deadline exceeded
933// events for a given message.
934//
935// Retry Policy is implemented on a best effort basis. At times, the delay
936// between consecutive deliveries may not match the configuration. That is,
937// delay can be more or less than configured backoff.
938message RetryPolicy {
939  // Optional. The minimum delay between consecutive deliveries of a given
940  // message. Value should be between 0 and 600 seconds. Defaults to 10 seconds.
941  google.protobuf.Duration minimum_backoff = 1
942      [(google.api.field_behavior) = OPTIONAL];
943
944  // Optional. The maximum delay between consecutive deliveries of a given
945  // message. Value should be between 0 and 600 seconds. Defaults to 600
946  // seconds.
947  google.protobuf.Duration maximum_backoff = 2
948      [(google.api.field_behavior) = OPTIONAL];
949}
950
951// Dead lettering is done on a best effort basis. The same message might be
952// dead lettered multiple times.
953//
954// If validation on any of the fields fails at subscription creation/updation,
955// the create/update subscription request will fail.
956message DeadLetterPolicy {
957  // Optional. The name of the topic to which dead letter messages should be
958  // published. Format is `projects/{project}/topics/{topic}`.The Pub/Sub
959  // service account associated with the enclosing subscription's parent project
960  // (i.e., service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must
961  // have permission to Publish() to this topic.
962  //
963  // The operation will fail if the topic does not exist.
964  // Users should ensure that there is a subscription attached to this topic
965  // since messages published to a topic with no subscriptions are lost.
966  string dead_letter_topic = 1 [(google.api.field_behavior) = OPTIONAL];
967
968  // Optional. The maximum number of delivery attempts for any message. The
969  // value must be between 5 and 100.
970  //
971  // The number of delivery attempts is defined as 1 + (the sum of number of
972  // NACKs and number of times the acknowledgement deadline has been exceeded
973  // for the message).
974  //
975  // A NACK is any call to ModifyAckDeadline with a 0 deadline. Note that
976  // client libraries may automatically extend ack_deadlines.
977  //
978  // This field will be honored on a best effort basis.
979  //
980  // If this parameter is 0, a default value of 5 is used.
981  int32 max_delivery_attempts = 2 [(google.api.field_behavior) = OPTIONAL];
982}
983
984// A policy that specifies the conditions for resource expiration (i.e.,
985// automatic resource deletion).
986message ExpirationPolicy {
987  // Optional. Specifies the "time-to-live" duration for an associated resource.
988  // The resource expires if it is not active for a period of `ttl`. The
989  // definition of "activity" depends on the type of the associated resource.
990  // The minimum and maximum allowed values for `ttl` depend on the type of the
991  // associated resource, as well. If `ttl` is not set, the associated resource
992  // never expires.
993  google.protobuf.Duration ttl = 1 [(google.api.field_behavior) = OPTIONAL];
994}
995
996// Configuration for a push delivery endpoint.
997message PushConfig {
998  // Contains information needed for generating an
999  // [OpenID Connect
1000  // token](https://developers.google.com/identity/protocols/OpenIDConnect).
1001  message OidcToken {
1002    // Optional. [Service account
1003    // email](https://cloud.google.com/iam/docs/service-accounts)
1004    // used for generating the OIDC token. For more information
1005    // on setting up authentication, see
1006    // [Push subscriptions](https://cloud.google.com/pubsub/docs/push).
1007    string service_account_email = 1 [(google.api.field_behavior) = OPTIONAL];
1008
1009    // Optional. Audience to be used when generating OIDC token. The audience
1010    // claim identifies the recipients that the JWT is intended for. The
1011    // audience value is a single case-sensitive string. Having multiple values
1012    // (array) for the audience field is not supported. More info about the OIDC
1013    // JWT token audience here:
1014    // https://tools.ietf.org/html/rfc7519#section-4.1.3 Note: if not specified,
1015    // the Push endpoint URL will be used.
1016    string audience = 2 [(google.api.field_behavior) = OPTIONAL];
1017  }
1018
1019  // The payload to the push endpoint is in the form of the JSON representation
1020  // of a PubsubMessage
1021  // (https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#pubsubmessage).
1022  message PubsubWrapper {}
1023
1024  // Sets the `data` field as the HTTP body for delivery.
1025  message NoWrapper {
1026    // Optional. When true, writes the Pub/Sub message metadata to
1027    // `x-goog-pubsub-<KEY>:<VAL>` headers of the HTTP request. Writes the
1028    // Pub/Sub message attributes to `<KEY>:<VAL>` headers of the HTTP request.
1029    bool write_metadata = 1 [(google.api.field_behavior) = OPTIONAL];
1030  }
1031
1032  // Optional. A URL locating the endpoint to which messages should be pushed.
1033  // For example, a Webhook endpoint might use `https://example.com/push`.
1034  string push_endpoint = 1 [(google.api.field_behavior) = OPTIONAL];
1035
1036  // Optional. Endpoint configuration attributes that can be used to control
1037  // different aspects of the message delivery.
1038  //
1039  // The only currently supported attribute is `x-goog-version`, which you can
1040  // use to change the format of the pushed message. This attribute
1041  // indicates the version of the data expected by the endpoint. This
1042  // controls the shape of the pushed message (i.e., its fields and metadata).
1043  //
1044  // If not present during the `CreateSubscription` call, it will default to
1045  // the version of the Pub/Sub API used to make such call. If not present in a
1046  // `ModifyPushConfig` call, its value will not be changed. `GetSubscription`
1047  // calls will always return a valid version, even if the subscription was
1048  // created without this attribute.
1049  //
1050  // The only supported values for the `x-goog-version` attribute are:
1051  //
1052  // * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub API.
1053  // * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub API.
1054  //
1055  // For example:
1056  // `attributes { "x-goog-version": "v1" }`
1057  map<string, string> attributes = 2 [(google.api.field_behavior) = OPTIONAL];
1058
1059  // An authentication method used by push endpoints to verify the source of
1060  // push requests. This can be used with push endpoints that are private by
1061  // default to allow requests only from the Pub/Sub system, for example.
1062  // This field is optional and should be set only by users interested in
1063  // authenticated push.
1064  oneof authentication_method {
1065    // Optional. If specified, Pub/Sub will generate and attach an OIDC JWT
1066    // token as an `Authorization` header in the HTTP request for every pushed
1067    // message.
1068    OidcToken oidc_token = 3 [(google.api.field_behavior) = OPTIONAL];
1069  }
1070
1071  // The format of the delivered message to the push endpoint is defined by
1072  // the chosen wrapper. When unset, `PubsubWrapper` is used.
1073  oneof wrapper {
1074    // Optional. When set, the payload to the push endpoint is in the form of
1075    // the JSON representation of a PubsubMessage
1076    // (https://cloud.google.com/pubsub/docs/reference/rpc/google.pubsub.v1#pubsubmessage).
1077    PubsubWrapper pubsub_wrapper = 4 [(google.api.field_behavior) = OPTIONAL];
1078
1079    // Optional. When set, the payload to the push endpoint is not wrapped.
1080    NoWrapper no_wrapper = 5 [(google.api.field_behavior) = OPTIONAL];
1081  }
1082}
1083
1084// Configuration for a BigQuery subscription.
1085message BigQueryConfig {
1086  // Possible states for a BigQuery subscription.
1087  enum State {
1088    // Default value. This value is unused.
1089    STATE_UNSPECIFIED = 0;
1090
1091    // The subscription can actively send messages to BigQuery
1092    ACTIVE = 1;
1093
1094    // Cannot write to the BigQuery table because of permission denied errors.
1095    // This can happen if
1096    // - Pub/Sub SA has not been granted the [appropriate BigQuery IAM
1097    // permissions](https://cloud.google.com/pubsub/docs/create-subscription#assign_bigquery_service_account)
1098    // - bigquery.googleapis.com API is not enabled for the project
1099    // ([instructions](https://cloud.google.com/service-usage/docs/enable-disable))
1100    PERMISSION_DENIED = 2;
1101
1102    // Cannot write to the BigQuery table because it does not exist.
1103    NOT_FOUND = 3;
1104
1105    // Cannot write to the BigQuery table due to a schema mismatch.
1106    SCHEMA_MISMATCH = 4;
1107
1108    // Cannot write to the destination because enforce_in_transit is set to true
1109    // and the destination locations are not in the allowed regions.
1110    IN_TRANSIT_LOCATION_RESTRICTION = 5;
1111  }
1112
1113  // Optional. The name of the table to which to write data, of the form
1114  // {projectId}.{datasetId}.{tableId}
1115  string table = 1 [(google.api.field_behavior) = OPTIONAL];
1116
1117  // Optional. When true, use the topic's schema as the columns to write to in
1118  // BigQuery, if it exists. `use_topic_schema` and `use_table_schema` cannot be
1119  // enabled at the same time.
1120  bool use_topic_schema = 2 [(google.api.field_behavior) = OPTIONAL];
1121
1122  // Optional. When true, write the subscription name, message_id, publish_time,
1123  // attributes, and ordering_key to additional columns in the table. The
1124  // subscription name, message_id, and publish_time fields are put in their own
1125  // columns while all other message properties (other than data) are written to
1126  // a JSON object in the attributes column.
1127  bool write_metadata = 3 [(google.api.field_behavior) = OPTIONAL];
1128
1129  // Optional. When true and use_topic_schema is true, any fields that are a
1130  // part of the topic schema that are not part of the BigQuery table schema are
1131  // dropped when writing to BigQuery. Otherwise, the schemas must be kept in
1132  // sync and any messages with extra fields are not written and remain in the
1133  // subscription's backlog.
1134  bool drop_unknown_fields = 4 [(google.api.field_behavior) = OPTIONAL];
1135
1136  // Output only. An output-only field that indicates whether or not the
1137  // subscription can receive messages.
1138  State state = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
1139
1140  // Optional. When true, use the BigQuery table's schema as the columns to
1141  // write to in BigQuery. `use_table_schema` and `use_topic_schema` cannot be
1142  // enabled at the same time.
1143  bool use_table_schema = 6 [(google.api.field_behavior) = OPTIONAL];
1144}
1145
1146// Configuration for a Cloud Storage subscription.
1147message CloudStorageConfig {
1148  // Configuration for writing message data in text format.
1149  // Message payloads will be written to files as raw text, separated by a
1150  // newline.
1151  message TextConfig {}
1152
1153  // Configuration for writing message data in Avro format.
1154  // Message payloads and metadata will be written to files as an Avro binary.
1155  message AvroConfig {
1156    // Optional. When true, write the subscription name, message_id,
1157    // publish_time, attributes, and ordering_key as additional fields in the
1158    // output. The subscription name, message_id, and publish_time fields are
1159    // put in their own fields while all other message properties other than
1160    // data (for example, an ordering_key, if present) are added as entries in
1161    // the attributes map.
1162    bool write_metadata = 1 [(google.api.field_behavior) = OPTIONAL];
1163  }
1164
1165  // Possible states for a Cloud Storage subscription.
1166  enum State {
1167    // Default value. This value is unused.
1168    STATE_UNSPECIFIED = 0;
1169
1170    // The subscription can actively send messages to Cloud Storage.
1171    ACTIVE = 1;
1172
1173    // Cannot write to the Cloud Storage bucket because of permission denied
1174    // errors.
1175    PERMISSION_DENIED = 2;
1176
1177    // Cannot write to the Cloud Storage bucket because it does not exist.
1178    NOT_FOUND = 3;
1179
1180    // Cannot write to the destination because enforce_in_transit is set to true
1181    // and the destination locations are not in the allowed regions.
1182    IN_TRANSIT_LOCATION_RESTRICTION = 4;
1183  }
1184
1185  // Required. User-provided name for the Cloud Storage bucket.
1186  // The bucket must be created by the user. The bucket name must be without
1187  // any prefix like "gs://". See the [bucket naming
1188  // requirements] (https://cloud.google.com/storage/docs/buckets#naming).
1189  string bucket = 1 [(google.api.field_behavior) = REQUIRED];
1190
1191  // Optional. User-provided prefix for Cloud Storage filename. See the [object
1192  // naming requirements](https://cloud.google.com/storage/docs/objects#naming).
1193  string filename_prefix = 2 [(google.api.field_behavior) = OPTIONAL];
1194
1195  // Optional. User-provided suffix for Cloud Storage filename. See the [object
1196  // naming requirements](https://cloud.google.com/storage/docs/objects#naming).
1197  // Must not end in "/".
1198  string filename_suffix = 3 [(google.api.field_behavior) = OPTIONAL];
1199
1200  // Optional. User-provided format string specifying how to represent datetimes
1201  // in Cloud Storage filenames. See the [datetime format
1202  // guidance](https://cloud.google.com/pubsub/docs/create-cloudstorage-subscription#file_names).
1203  string filename_datetime_format = 10 [(google.api.field_behavior) = OPTIONAL];
1204
1205  // Defaults to text format.
1206  oneof output_format {
1207    // Optional. If set, message data will be written to Cloud Storage in text
1208    // format.
1209    TextConfig text_config = 4 [(google.api.field_behavior) = OPTIONAL];
1210
1211    // Optional. If set, message data will be written to Cloud Storage in Avro
1212    // format.
1213    AvroConfig avro_config = 5 [(google.api.field_behavior) = OPTIONAL];
1214  }
1215
1216  // Optional. The maximum duration that can elapse before a new Cloud Storage
1217  // file is created. Min 1 minute, max 10 minutes, default 5 minutes. May not
1218  // exceed the subscription's acknowledgement deadline.
1219  google.protobuf.Duration max_duration = 6
1220      [(google.api.field_behavior) = OPTIONAL];
1221
1222  // Optional. The maximum bytes that can be written to a Cloud Storage file
1223  // before a new file is created. Min 1 KB, max 10 GiB. The max_bytes limit may
1224  // be exceeded in cases where messages are larger than the limit.
1225  int64 max_bytes = 7 [(google.api.field_behavior) = OPTIONAL];
1226
1227  // Output only. An output-only field that indicates whether or not the
1228  // subscription can receive messages.
1229  State state = 9 [(google.api.field_behavior) = OUTPUT_ONLY];
1230}
1231
1232// A message and its corresponding acknowledgment ID.
1233message ReceivedMessage {
1234  // Optional. This ID can be used to acknowledge the received message.
1235  string ack_id = 1 [(google.api.field_behavior) = OPTIONAL];
1236
1237  // Optional. The message.
1238  PubsubMessage message = 2 [(google.api.field_behavior) = OPTIONAL];
1239
1240  // Optional. The approximate number of times that Pub/Sub has attempted to
1241  // deliver the associated message to a subscriber.
1242  //
1243  // More precisely, this is 1 + (number of NACKs) +
1244  // (number of ack_deadline exceeds) for this message.
1245  //
1246  // A NACK is any call to ModifyAckDeadline with a 0 deadline. An ack_deadline
1247  // exceeds event is whenever a message is not acknowledged within
1248  // ack_deadline. Note that ack_deadline is initially
1249  // Subscription.ackDeadlineSeconds, but may get extended automatically by
1250  // the client library.
1251  //
1252  // Upon the first delivery of a given message, `delivery_attempt` will have a
1253  // value of 1. The value is calculated at best effort and is approximate.
1254  //
1255  // If a DeadLetterPolicy is not set on the subscription, this will be 0.
1256  int32 delivery_attempt = 3 [(google.api.field_behavior) = OPTIONAL];
1257}
1258
1259// Request for the GetSubscription method.
1260message GetSubscriptionRequest {
1261  // Required. The name of the subscription to get.
1262  // Format is `projects/{project}/subscriptions/{sub}`.
1263  string subscription = 1 [
1264    (google.api.field_behavior) = REQUIRED,
1265    (google.api.resource_reference) = {
1266      type: "pubsub.googleapis.com/Subscription"
1267    }
1268  ];
1269}
1270
1271// Request for the UpdateSubscription method.
1272message UpdateSubscriptionRequest {
1273  // Required. The updated subscription object.
1274  Subscription subscription = 1 [(google.api.field_behavior) = REQUIRED];
1275
1276  // Required. Indicates which fields in the provided subscription to update.
1277  // Must be specified and non-empty.
1278  google.protobuf.FieldMask update_mask = 2
1279      [(google.api.field_behavior) = REQUIRED];
1280}
1281
1282// Request for the `ListSubscriptions` method.
1283message ListSubscriptionsRequest {
1284  // Required. The name of the project in which to list subscriptions.
1285  // Format is `projects/{project-id}`.
1286  string project = 1 [
1287    (google.api.field_behavior) = REQUIRED,
1288    (google.api.resource_reference) = {
1289      type: "cloudresourcemanager.googleapis.com/Project"
1290    }
1291  ];
1292
1293  // Optional. Maximum number of subscriptions to return.
1294  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
1295
1296  // Optional. The value returned by the last `ListSubscriptionsResponse`;
1297  // indicates that this is a continuation of a prior `ListSubscriptions` call,
1298  // and that the system should return the next page of data.
1299  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
1300}
1301
1302// Response for the `ListSubscriptions` method.
1303message ListSubscriptionsResponse {
1304  // Optional. The subscriptions that match the request.
1305  repeated Subscription subscriptions = 1
1306      [(google.api.field_behavior) = OPTIONAL];
1307
1308  // Optional. If not empty, indicates that there may be more subscriptions that
1309  // match the request; this value should be passed in a new
1310  // `ListSubscriptionsRequest` to get more subscriptions.
1311  string next_page_token = 2 [(google.api.field_behavior) = OPTIONAL];
1312}
1313
1314// Request for the DeleteSubscription method.
1315message DeleteSubscriptionRequest {
1316  // Required. The subscription to delete.
1317  // Format is `projects/{project}/subscriptions/{sub}`.
1318  string subscription = 1 [
1319    (google.api.field_behavior) = REQUIRED,
1320    (google.api.resource_reference) = {
1321      type: "pubsub.googleapis.com/Subscription"
1322    }
1323  ];
1324}
1325
1326// Request for the ModifyPushConfig method.
1327message ModifyPushConfigRequest {
1328  // Required. The name of the subscription.
1329  // Format is `projects/{project}/subscriptions/{sub}`.
1330  string subscription = 1 [
1331    (google.api.field_behavior) = REQUIRED,
1332    (google.api.resource_reference) = {
1333      type: "pubsub.googleapis.com/Subscription"
1334    }
1335  ];
1336
1337  // Required. The push configuration for future deliveries.
1338  //
1339  // An empty `pushConfig` indicates that the Pub/Sub system should
1340  // stop pushing messages from the given subscription and allow
1341  // messages to be pulled and acknowledged - effectively pausing
1342  // the subscription if `Pull` or `StreamingPull` is not called.
1343  PushConfig push_config = 2 [(google.api.field_behavior) = REQUIRED];
1344}
1345
1346// Request for the `Pull` method.
1347message PullRequest {
1348  // Required. The subscription from which messages should be pulled.
1349  // Format is `projects/{project}/subscriptions/{sub}`.
1350  string subscription = 1 [
1351    (google.api.field_behavior) = REQUIRED,
1352    (google.api.resource_reference) = {
1353      type: "pubsub.googleapis.com/Subscription"
1354    }
1355  ];
1356
1357  // Optional. If this field set to true, the system will respond immediately
1358  // even if it there are no messages available to return in the `Pull`
1359  // response. Otherwise, the system may wait (for a bounded amount of time)
1360  // until at least one message is available, rather than returning no messages.
1361  // Warning: setting this field to `true` is discouraged because it adversely
1362  // impacts the performance of `Pull` operations. We recommend that users do
1363  // not set this field.
1364  bool return_immediately = 2
1365      [deprecated = true, (google.api.field_behavior) = OPTIONAL];
1366
1367  // Required. The maximum number of messages to return for this request. Must
1368  // be a positive integer. The Pub/Sub system may return fewer than the number
1369  // specified.
1370  int32 max_messages = 3 [(google.api.field_behavior) = REQUIRED];
1371}
1372
1373// Response for the `Pull` method.
1374message PullResponse {
1375  // Optional. Received Pub/Sub messages. The list will be empty if there are no
1376  // more messages available in the backlog, or if no messages could be returned
1377  // before the request timeout. For JSON, the response can be entirely
1378  // empty. The Pub/Sub system may return fewer than the `maxMessages` requested
1379  // even if there are more messages available in the backlog.
1380  repeated ReceivedMessage received_messages = 1
1381      [(google.api.field_behavior) = OPTIONAL];
1382}
1383
1384// Request for the ModifyAckDeadline method.
1385message ModifyAckDeadlineRequest {
1386  // Required. The name of the subscription.
1387  // Format is `projects/{project}/subscriptions/{sub}`.
1388  string subscription = 1 [
1389    (google.api.field_behavior) = REQUIRED,
1390    (google.api.resource_reference) = {
1391      type: "pubsub.googleapis.com/Subscription"
1392    }
1393  ];
1394
1395  // Required. List of acknowledgment IDs.
1396  repeated string ack_ids = 4 [(google.api.field_behavior) = REQUIRED];
1397
1398  // Required. The new ack deadline with respect to the time this request was
1399  // sent to the Pub/Sub system. For example, if the value is 10, the new ack
1400  // deadline will expire 10 seconds after the `ModifyAckDeadline` call was
1401  // made. Specifying zero might immediately make the message available for
1402  // delivery to another subscriber client. This typically results in an
1403  // increase in the rate of message redeliveries (that is, duplicates).
1404  // The minimum deadline you can specify is 0 seconds.
1405  // The maximum deadline you can specify in a single request is 600 seconds
1406  // (10 minutes).
1407  int32 ack_deadline_seconds = 3 [(google.api.field_behavior) = REQUIRED];
1408}
1409
1410// Request for the Acknowledge method.
1411message AcknowledgeRequest {
1412  // Required. The subscription whose message is being acknowledged.
1413  // Format is `projects/{project}/subscriptions/{sub}`.
1414  string subscription = 1 [
1415    (google.api.field_behavior) = REQUIRED,
1416    (google.api.resource_reference) = {
1417      type: "pubsub.googleapis.com/Subscription"
1418    }
1419  ];
1420
1421  // Required. The acknowledgment ID for the messages being acknowledged that
1422  // was returned by the Pub/Sub system in the `Pull` response. Must not be
1423  // empty.
1424  repeated string ack_ids = 2 [(google.api.field_behavior) = REQUIRED];
1425}
1426
1427// Request for the `StreamingPull` streaming RPC method. This request is used to
1428// establish the initial stream as well as to stream acknowledgements and ack
1429// deadline modifications from the client to the server.
1430message StreamingPullRequest {
1431  // Required. The subscription for which to initialize the new stream. This
1432  // must be provided in the first request on the stream, and must not be set in
1433  // subsequent requests from client to server.
1434  // Format is `projects/{project}/subscriptions/{sub}`.
1435  string subscription = 1 [
1436    (google.api.field_behavior) = REQUIRED,
1437    (google.api.resource_reference) = {
1438      type: "pubsub.googleapis.com/Subscription"
1439    }
1440  ];
1441
1442  // Optional. List of acknowledgement IDs for acknowledging previously received
1443  // messages (received on this stream or a different stream). If an ack ID has
1444  // expired, the corresponding message may be redelivered later. Acknowledging
1445  // a message more than once will not result in an error. If the
1446  // acknowledgement ID is malformed, the stream will be aborted with status
1447  // `INVALID_ARGUMENT`.
1448  repeated string ack_ids = 2 [(google.api.field_behavior) = OPTIONAL];
1449
1450  // Optional. The list of new ack deadlines for the IDs listed in
1451  // `modify_deadline_ack_ids`. The size of this list must be the same as the
1452  // size of `modify_deadline_ack_ids`. If it differs the stream will be aborted
1453  // with `INVALID_ARGUMENT`. Each element in this list is applied to the
1454  // element in the same position in `modify_deadline_ack_ids`. The new ack
1455  // deadline is with respect to the time this request was sent to the Pub/Sub
1456  // system. Must be >= 0. For example, if the value is 10, the new ack deadline
1457  // will expire 10 seconds after this request is received. If the value is 0,
1458  // the message is immediately made available for another streaming or
1459  // non-streaming pull request. If the value is < 0 (an error), the stream will
1460  // be aborted with status `INVALID_ARGUMENT`.
1461  repeated int32 modify_deadline_seconds = 3
1462      [(google.api.field_behavior) = OPTIONAL];
1463
1464  // Optional. List of acknowledgement IDs whose deadline will be modified based
1465  // on the corresponding element in `modify_deadline_seconds`. This field can
1466  // be used to indicate that more time is needed to process a message by the
1467  // subscriber, or to make the message available for redelivery if the
1468  // processing was interrupted.
1469  repeated string modify_deadline_ack_ids = 4
1470      [(google.api.field_behavior) = OPTIONAL];
1471
1472  // Required. The ack deadline to use for the stream. This must be provided in
1473  // the first request on the stream, but it can also be updated on subsequent
1474  // requests from client to server. The minimum deadline you can specify is 10
1475  // seconds. The maximum deadline you can specify is 600 seconds (10 minutes).
1476  int32 stream_ack_deadline_seconds = 5
1477      [(google.api.field_behavior) = REQUIRED];
1478
1479  // Optional. A unique identifier that is used to distinguish client instances
1480  // from each other. Only needs to be provided on the initial request. When a
1481  // stream disconnects and reconnects for the same stream, the client_id should
1482  // be set to the same value so that state associated with the old stream can
1483  // be transferred to the new stream. The same client_id should not be used for
1484  // different client instances.
1485  string client_id = 6 [(google.api.field_behavior) = OPTIONAL];
1486
1487  // Optional. Flow control settings for the maximum number of outstanding
1488  // messages. When there are `max_outstanding_messages` currently sent to the
1489  // streaming pull client that have not yet been acked or nacked, the server
1490  // stops sending more messages. The sending of messages resumes once the
1491  // number of outstanding messages is less than this value. If the value is
1492  // <= 0, there is no limit to the number of outstanding messages. This
1493  // property can only be set on the initial StreamingPullRequest. If it is set
1494  // on a subsequent request, the stream will be aborted with status
1495  // `INVALID_ARGUMENT`.
1496  int64 max_outstanding_messages = 7 [(google.api.field_behavior) = OPTIONAL];
1497
1498  // Optional. Flow control settings for the maximum number of outstanding
1499  // bytes. When there are `max_outstanding_bytes` or more worth of messages
1500  // currently sent to the streaming pull client that have not yet been acked or
1501  // nacked, the server will stop sending more messages. The sending of messages
1502  // resumes once the number of outstanding bytes is less than this value. If
1503  // the value is <= 0, there is no limit to the number of outstanding bytes.
1504  // This property can only be set on the initial StreamingPullRequest. If it is
1505  // set on a subsequent request, the stream will be aborted with status
1506  // `INVALID_ARGUMENT`.
1507  int64 max_outstanding_bytes = 8 [(google.api.field_behavior) = OPTIONAL];
1508}
1509
1510// Response for the `StreamingPull` method. This response is used to stream
1511// messages from the server to the client.
1512message StreamingPullResponse {
1513  // Acknowledgement IDs sent in one or more previous requests to acknowledge a
1514  // previously received message.
1515  message AcknowledgeConfirmation {
1516    // Optional. Successfully processed acknowledgement IDs.
1517    repeated string ack_ids = 1 [(google.api.field_behavior) = OPTIONAL];
1518
1519    // Optional. List of acknowledgement IDs that were malformed or whose
1520    // acknowledgement deadline has expired.
1521    repeated string invalid_ack_ids = 2
1522        [(google.api.field_behavior) = OPTIONAL];
1523
1524    // Optional. List of acknowledgement IDs that were out of order.
1525    repeated string unordered_ack_ids = 3
1526        [(google.api.field_behavior) = OPTIONAL];
1527
1528    // Optional. List of acknowledgement IDs that failed processing with
1529    // temporary issues.
1530    repeated string temporary_failed_ack_ids = 4
1531        [(google.api.field_behavior) = OPTIONAL];
1532  }
1533
1534  // Acknowledgement IDs sent in one or more previous requests to modify the
1535  // deadline for a specific message.
1536  message ModifyAckDeadlineConfirmation {
1537    // Optional. Successfully processed acknowledgement IDs.
1538    repeated string ack_ids = 1 [(google.api.field_behavior) = OPTIONAL];
1539
1540    // Optional. List of acknowledgement IDs that were malformed or whose
1541    // acknowledgement deadline has expired.
1542    repeated string invalid_ack_ids = 2
1543        [(google.api.field_behavior) = OPTIONAL];
1544
1545    // Optional. List of acknowledgement IDs that failed processing with
1546    // temporary issues.
1547    repeated string temporary_failed_ack_ids = 3
1548        [(google.api.field_behavior) = OPTIONAL];
1549  }
1550
1551  // Subscription properties sent as part of the response.
1552  message SubscriptionProperties {
1553    // Optional. True iff exactly once delivery is enabled for this
1554    // subscription.
1555    bool exactly_once_delivery_enabled = 1
1556        [(google.api.field_behavior) = OPTIONAL];
1557
1558    // Optional. True iff message ordering is enabled for this subscription.
1559    bool message_ordering_enabled = 2 [(google.api.field_behavior) = OPTIONAL];
1560  }
1561
1562  // Optional. Received Pub/Sub messages. This will not be empty.
1563  repeated ReceivedMessage received_messages = 1
1564      [(google.api.field_behavior) = OPTIONAL];
1565
1566  // Optional. This field will only be set if `enable_exactly_once_delivery` is
1567  // set to `true`.
1568  AcknowledgeConfirmation acknowledge_confirmation = 5
1569      [(google.api.field_behavior) = OPTIONAL];
1570
1571  // Optional. This field will only be set if `enable_exactly_once_delivery` is
1572  // set to `true`.
1573  ModifyAckDeadlineConfirmation modify_ack_deadline_confirmation = 3
1574      [(google.api.field_behavior) = OPTIONAL];
1575
1576  // Optional. Properties associated with this subscription.
1577  SubscriptionProperties subscription_properties = 4
1578      [(google.api.field_behavior) = OPTIONAL];
1579}
1580
1581// Request for the `CreateSnapshot` method.
1582message CreateSnapshotRequest {
1583  // Required. User-provided name for this snapshot. If the name is not provided
1584  // in the request, the server will assign a random name for this snapshot on
1585  // the same project as the subscription. Note that for REST API requests, you
1586  // must specify a name.  See the [resource name
1587  // rules](https://cloud.google.com/pubsub/docs/pubsub-basics#resource_names).
1588  // Format is `projects/{project}/snapshots/{snap}`.
1589  string name = 1 [
1590    (google.api.field_behavior) = REQUIRED,
1591    (google.api.resource_reference) = { type: "pubsub.googleapis.com/Snapshot" }
1592  ];
1593
1594  // Required. The subscription whose backlog the snapshot retains.
1595  // Specifically, the created snapshot is guaranteed to retain:
1596  //  (a) The existing backlog on the subscription. More precisely, this is
1597  //      defined as the messages in the subscription's backlog that are
1598  //      unacknowledged upon the successful completion of the
1599  //      `CreateSnapshot` request; as well as:
1600  //  (b) Any messages published to the subscription's topic following the
1601  //      successful completion of the CreateSnapshot request.
1602  // Format is `projects/{project}/subscriptions/{sub}`.
1603  string subscription = 2 [
1604    (google.api.field_behavior) = REQUIRED,
1605    (google.api.resource_reference) = {
1606      type: "pubsub.googleapis.com/Subscription"
1607    }
1608  ];
1609
1610  // Optional. See [Creating and managing
1611  // labels](https://cloud.google.com/pubsub/docs/labels).
1612  map<string, string> labels = 3 [(google.api.field_behavior) = OPTIONAL];
1613}
1614
1615// Request for the UpdateSnapshot method.
1616message UpdateSnapshotRequest {
1617  // Required. The updated snapshot object.
1618  Snapshot snapshot = 1 [(google.api.field_behavior) = REQUIRED];
1619
1620  // Required. Indicates which fields in the provided snapshot to update.
1621  // Must be specified and non-empty.
1622  google.protobuf.FieldMask update_mask = 2
1623      [(google.api.field_behavior) = REQUIRED];
1624}
1625
1626// A snapshot resource. Snapshots are used in
1627// [Seek](https://cloud.google.com/pubsub/docs/replay-overview)
1628// operations, which allow you to manage message acknowledgments in bulk. That
1629// is, you can set the acknowledgment state of messages in an existing
1630// subscription to the state captured by a snapshot.
1631message Snapshot {
1632  option (google.api.resource) = {
1633    type: "pubsub.googleapis.com/Snapshot"
1634    pattern: "projects/{project}/snapshots/{snapshot}"
1635  };
1636
1637  // Optional. The name of the snapshot.
1638  string name = 1 [(google.api.field_behavior) = OPTIONAL];
1639
1640  // Optional. The name of the topic from which this snapshot is retaining
1641  // messages.
1642  string topic = 2 [
1643    (google.api.field_behavior) = OPTIONAL,
1644    (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" }
1645  ];
1646
1647  // Optional. The snapshot is guaranteed to exist up until this time.
1648  // A newly-created snapshot expires no later than 7 days from the time of its
1649  // creation. Its exact lifetime is determined at creation by the existing
1650  // backlog in the source subscription. Specifically, the lifetime of the
1651  // snapshot is `7 days - (age of oldest unacked message in the subscription)`.
1652  // For example, consider a subscription whose oldest unacked message is 3 days
1653  // old. If a snapshot is created from this subscription, the snapshot -- which
1654  // will always capture this 3-day-old backlog as long as the snapshot
1655  // exists -- will expire in 4 days. The service will refuse to create a
1656  // snapshot that would expire in less than 1 hour after creation.
1657  google.protobuf.Timestamp expire_time = 3
1658      [(google.api.field_behavior) = OPTIONAL];
1659
1660  // Optional. See [Creating and managing labels]
1661  // (https://cloud.google.com/pubsub/docs/labels).
1662  map<string, string> labels = 4 [(google.api.field_behavior) = OPTIONAL];
1663}
1664
1665// Request for the GetSnapshot method.
1666message GetSnapshotRequest {
1667  // Required. The name of the snapshot to get.
1668  // Format is `projects/{project}/snapshots/{snap}`.
1669  string snapshot = 1 [
1670    (google.api.field_behavior) = REQUIRED,
1671    (google.api.resource_reference) = { type: "pubsub.googleapis.com/Snapshot" }
1672  ];
1673}
1674
1675// Request for the `ListSnapshots` method.
1676message ListSnapshotsRequest {
1677  // Required. The name of the project in which to list snapshots.
1678  // Format is `projects/{project-id}`.
1679  string project = 1 [
1680    (google.api.field_behavior) = REQUIRED,
1681    (google.api.resource_reference) = {
1682      type: "cloudresourcemanager.googleapis.com/Project"
1683    }
1684  ];
1685
1686  // Optional. Maximum number of snapshots to return.
1687  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
1688
1689  // Optional. The value returned by the last `ListSnapshotsResponse`; indicates
1690  // that this is a continuation of a prior `ListSnapshots` call, and that the
1691  // system should return the next page of data.
1692  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
1693}
1694
1695// Response for the `ListSnapshots` method.
1696message ListSnapshotsResponse {
1697  // Optional. The resulting snapshots.
1698  repeated Snapshot snapshots = 1 [(google.api.field_behavior) = OPTIONAL];
1699
1700  // Optional. If not empty, indicates that there may be more snapshot that
1701  // match the request; this value should be passed in a new
1702  // `ListSnapshotsRequest`.
1703  string next_page_token = 2 [(google.api.field_behavior) = OPTIONAL];
1704}
1705
1706// Request for the `DeleteSnapshot` method.
1707message DeleteSnapshotRequest {
1708  // Required. The name of the snapshot to delete.
1709  // Format is `projects/{project}/snapshots/{snap}`.
1710  string snapshot = 1 [
1711    (google.api.field_behavior) = REQUIRED,
1712    (google.api.resource_reference) = { type: "pubsub.googleapis.com/Snapshot" }
1713  ];
1714}
1715
1716// Request for the `Seek` method.
1717message SeekRequest {
1718  // Required. The subscription to affect.
1719  string subscription = 1 [
1720    (google.api.field_behavior) = REQUIRED,
1721    (google.api.resource_reference) = {
1722      type: "pubsub.googleapis.com/Subscription"
1723    }
1724  ];
1725
1726  oneof target {
1727    // Optional. The time to seek to.
1728    // Messages retained in the subscription that were published before this
1729    // time are marked as acknowledged, and messages retained in the
1730    // subscription that were published after this time are marked as
1731    // unacknowledged. Note that this operation affects only those messages
1732    // retained in the subscription (configured by the combination of
1733    // `message_retention_duration` and `retain_acked_messages`). For example,
1734    // if `time` corresponds to a point before the message retention
1735    // window (or to a point before the system's notion of the subscription
1736    // creation time), only retained messages will be marked as unacknowledged,
1737    // and already-expunged messages will not be restored.
1738    google.protobuf.Timestamp time = 2 [(google.api.field_behavior) = OPTIONAL];
1739
1740    // Optional. The snapshot to seek to. The snapshot's topic must be the same
1741    // as that of the provided subscription. Format is
1742    // `projects/{project}/snapshots/{snap}`.
1743    string snapshot = 3 [
1744      (google.api.field_behavior) = OPTIONAL,
1745      (google.api.resource_reference) = {
1746        type: "pubsub.googleapis.com/Snapshot"
1747      }
1748    ];
1749  }
1750}
1751
1752// Response for the `Seek` method (this response is empty).
1753message SeekResponse {}
1754