pubsub.proto 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324
  1. // Copyright 2021 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. syntax = "proto3";
  15. package google.pubsub.v1;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/api/resource.proto";
  20. import "google/protobuf/duration.proto";
  21. import "google/protobuf/empty.proto";
  22. import "google/protobuf/field_mask.proto";
  23. import "google/protobuf/timestamp.proto";
  24. import "google/pubsub/v1/schema.proto";
  25. option cc_enable_arenas = true;
  26. option csharp_namespace = "Google.Cloud.PubSub.V1";
  27. option go_package = "google.golang.org/genproto/googleapis/pubsub/v1;pubsub";
  28. option java_multiple_files = true;
  29. option java_outer_classname = "PubsubProto";
  30. option java_package = "com.google.pubsub.v1";
  31. option php_namespace = "Google\\Cloud\\PubSub\\V1";
  32. option ruby_package = "Google::Cloud::PubSub::V1";
  33. // The service that an application uses to manipulate topics, and to send
  34. // messages to a topic.
  35. service Publisher {
  36. option (google.api.default_host) = "pubsub.googleapis.com";
  37. option (google.api.oauth_scopes) =
  38. "https://www.googleapis.com/auth/cloud-platform,"
  39. "https://www.googleapis.com/auth/pubsub";
  40. // Creates the given topic with the given name. See the [resource name rules]
  41. // (https://cloud.google.com/pubsub/docs/admin#resource_names).
  42. rpc CreateTopic(Topic) returns (Topic) {
  43. option (google.api.http) = {
  44. put: "/v1/{name=projects/*/topics/*}"
  45. body: "*"
  46. };
  47. option (google.api.method_signature) = "name";
  48. }
  49. // Updates an existing topic. Note that certain properties of a
  50. // topic are not modifiable.
  51. rpc UpdateTopic(UpdateTopicRequest) returns (Topic) {
  52. option (google.api.http) = {
  53. patch: "/v1/{topic.name=projects/*/topics/*}"
  54. body: "*"
  55. };
  56. }
  57. // Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic
  58. // does not exist.
  59. rpc Publish(PublishRequest) returns (PublishResponse) {
  60. option (google.api.http) = {
  61. post: "/v1/{topic=projects/*/topics/*}:publish"
  62. body: "*"
  63. };
  64. option (google.api.method_signature) = "topic,messages";
  65. }
  66. // Gets the configuration of a topic.
  67. rpc GetTopic(GetTopicRequest) returns (Topic) {
  68. option (google.api.http) = {
  69. get: "/v1/{topic=projects/*/topics/*}"
  70. };
  71. option (google.api.method_signature) = "topic";
  72. }
  73. // Lists matching topics.
  74. rpc ListTopics(ListTopicsRequest) returns (ListTopicsResponse) {
  75. option (google.api.http) = {
  76. get: "/v1/{project=projects/*}/topics"
  77. };
  78. option (google.api.method_signature) = "project";
  79. }
  80. // Lists the names of the attached subscriptions on this topic.
  81. rpc ListTopicSubscriptions(ListTopicSubscriptionsRequest)
  82. returns (ListTopicSubscriptionsResponse) {
  83. option (google.api.http) = {
  84. get: "/v1/{topic=projects/*/topics/*}/subscriptions"
  85. };
  86. option (google.api.method_signature) = "topic";
  87. }
  88. // Lists the names of the snapshots on this topic. Snapshots are used in
  89. // [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations,
  90. // which allow you to manage message acknowledgments in bulk. That is, you can
  91. // set the acknowledgment state of messages in an existing subscription to the
  92. // state captured by a snapshot.
  93. rpc ListTopicSnapshots(ListTopicSnapshotsRequest)
  94. returns (ListTopicSnapshotsResponse) {
  95. option (google.api.http) = {
  96. get: "/v1/{topic=projects/*/topics/*}/snapshots"
  97. };
  98. option (google.api.method_signature) = "topic";
  99. }
  100. // Deletes the topic with the given name. Returns `NOT_FOUND` if the topic
  101. // does not exist. After a topic is deleted, a new topic may be created with
  102. // the same name; this is an entirely new topic with none of the old
  103. // configuration or subscriptions. Existing subscriptions to this topic are
  104. // not deleted, but their `topic` field is set to `_deleted-topic_`.
  105. rpc DeleteTopic(DeleteTopicRequest) returns (google.protobuf.Empty) {
  106. option (google.api.http) = {
  107. delete: "/v1/{topic=projects/*/topics/*}"
  108. };
  109. option (google.api.method_signature) = "topic";
  110. }
  111. // Detaches a subscription from this topic. All messages retained in the
  112. // subscription are dropped. Subsequent `Pull` and `StreamingPull` requests
  113. // will return FAILED_PRECONDITION. If the subscription is a push
  114. // subscription, pushes to the endpoint will stop.
  115. rpc DetachSubscription(DetachSubscriptionRequest)
  116. returns (DetachSubscriptionResponse) {
  117. option (google.api.http) = {
  118. post: "/v1/{subscription=projects/*/subscriptions/*}:detach"
  119. };
  120. }
  121. }
  122. // A policy constraining the storage of messages published to the topic.
  123. message MessageStoragePolicy {
  124. // A list of IDs of GCP regions where messages that are published to the topic
  125. // may be persisted in storage. Messages published by publishers running in
  126. // non-allowed GCP regions (or running outside of GCP altogether) will be
  127. // routed for storage in one of the allowed regions. An empty list means that
  128. // no regions are allowed, and is not a valid configuration.
  129. repeated string allowed_persistence_regions = 1;
  130. }
  131. // Settings for validating messages published against a schema.
  132. message SchemaSettings {
  133. // Required. The name of the schema that messages published should be
  134. // validated against. Format is `projects/{project}/schemas/{schema}`. The
  135. // value of this field will be `_deleted-schema_` if the schema has been
  136. // deleted.
  137. string schema = 1 [
  138. (google.api.field_behavior) = REQUIRED,
  139. (google.api.resource_reference) = { type: "pubsub.googleapis.com/Schema" }
  140. ];
  141. // The encoding of messages validated against `schema`.
  142. Encoding encoding = 2;
  143. }
  144. // A topic resource.
  145. message Topic {
  146. option (google.api.resource) = {
  147. type: "pubsub.googleapis.com/Topic"
  148. pattern: "projects/{project}/topics/{topic}"
  149. pattern: "_deleted-topic_"
  150. };
  151. // Required. The name of the topic. It must have the format
  152. // `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
  153. // and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
  154. // underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
  155. // signs (`%`). It must be between 3 and 255 characters in length, and it
  156. // must not start with `"goog"`.
  157. string name = 1 [(google.api.field_behavior) = REQUIRED];
  158. // See [Creating and managing labels]
  159. // (https://cloud.google.com/pubsub/docs/labels).
  160. map<string, string> labels = 2;
  161. // Policy constraining the set of Google Cloud Platform regions where messages
  162. // published to the topic may be stored. If not present, then no constraints
  163. // are in effect.
  164. MessageStoragePolicy message_storage_policy = 3;
  165. // The resource name of the Cloud KMS CryptoKey to be used to protect access
  166. // to messages published on this topic.
  167. //
  168. // The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
  169. string kms_key_name = 5;
  170. // Settings for validating messages published against a schema.
  171. SchemaSettings schema_settings = 6;
  172. // Reserved for future use. This field is set only in responses from the
  173. // server; it is ignored if it is set in any requests.
  174. bool satisfies_pzs = 7;
  175. }
  176. // A message that is published by publishers and consumed by subscribers. The
  177. // message must contain either a non-empty data field or at least one attribute.
  178. // Note that client libraries represent this object differently
  179. // depending on the language. See the corresponding [client library
  180. // documentation](https://cloud.google.com/pubsub/docs/reference/libraries) for
  181. // more information. See [quotas and limits]
  182. // (https://cloud.google.com/pubsub/quotas) for more information about message
  183. // limits.
  184. message PubsubMessage {
  185. // The message data field. If this field is empty, the message must contain
  186. // at least one attribute.
  187. bytes data = 1;
  188. // Attributes for this message. If this field is empty, the message must
  189. // contain non-empty data. This can be used to filter messages on the
  190. // subscription.
  191. map<string, string> attributes = 2;
  192. // ID of this message, assigned by the server when the message is published.
  193. // Guaranteed to be unique within the topic. This value may be read by a
  194. // subscriber that receives a `PubsubMessage` via a `Pull` call or a push
  195. // delivery. It must not be populated by the publisher in a `Publish` call.
  196. string message_id = 3;
  197. // The time at which the message was published, populated by the server when
  198. // it receives the `Publish` call. It must not be populated by the
  199. // publisher in a `Publish` call.
  200. google.protobuf.Timestamp publish_time = 4;
  201. // If non-empty, identifies related messages for which publish order should be
  202. // respected. If a `Subscription` has `enable_message_ordering` set to `true`,
  203. // messages published with the same non-empty `ordering_key` value will be
  204. // delivered to subscribers in the order in which they are received by the
  205. // Pub/Sub system. All `PubsubMessage`s published in a given `PublishRequest`
  206. // must specify the same `ordering_key` value.
  207. string ordering_key = 5;
  208. }
  209. // Request for the GetTopic method.
  210. message GetTopicRequest {
  211. // Required. The name of the topic to get.
  212. // Format is `projects/{project}/topics/{topic}`.
  213. string topic = 1 [
  214. (google.api.field_behavior) = REQUIRED,
  215. (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" }
  216. ];
  217. }
  218. // Request for the UpdateTopic method.
  219. message UpdateTopicRequest {
  220. // Required. The updated topic object.
  221. Topic topic = 1 [(google.api.field_behavior) = REQUIRED];
  222. // Required. Indicates which fields in the provided topic to update. Must be
  223. // specified and non-empty. Note that if `update_mask` contains
  224. // "message_storage_policy" but the `message_storage_policy` is not set in
  225. // the `topic` provided above, then the updated value is determined by the
  226. // policy configured at the project or organization level.
  227. google.protobuf.FieldMask update_mask = 2
  228. [(google.api.field_behavior) = REQUIRED];
  229. }
  230. // Request for the Publish method.
  231. message PublishRequest {
  232. // Required. The messages in the request will be published on this topic.
  233. // Format is `projects/{project}/topics/{topic}`.
  234. string topic = 1 [
  235. (google.api.field_behavior) = REQUIRED,
  236. (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" }
  237. ];
  238. // Required. The messages to publish.
  239. repeated PubsubMessage messages = 2 [(google.api.field_behavior) = REQUIRED];
  240. }
  241. // Response for the `Publish` method.
  242. message PublishResponse {
  243. // The server-assigned ID of each published message, in the same order as
  244. // the messages in the request. IDs are guaranteed to be unique within
  245. // the topic.
  246. repeated string message_ids = 1;
  247. }
  248. // Request for the `ListTopics` method.
  249. message ListTopicsRequest {
  250. // Required. The name of the project in which to list topics.
  251. // Format is `projects/{project-id}`.
  252. string project = 1 [
  253. (google.api.field_behavior) = REQUIRED,
  254. (google.api.resource_reference) = {
  255. type: "cloudresourcemanager.googleapis.com/Project"
  256. }
  257. ];
  258. // Maximum number of topics to return.
  259. int32 page_size = 2;
  260. // The value returned by the last `ListTopicsResponse`; indicates that this is
  261. // a continuation of a prior `ListTopics` call, and that the system should
  262. // return the next page of data.
  263. string page_token = 3;
  264. }
  265. // Response for the `ListTopics` method.
  266. message ListTopicsResponse {
  267. // The resulting topics.
  268. repeated Topic topics = 1;
  269. // If not empty, indicates that there may be more topics that match the
  270. // request; this value should be passed in a new `ListTopicsRequest`.
  271. string next_page_token = 2;
  272. }
  273. // Request for the `ListTopicSubscriptions` method.
  274. message ListTopicSubscriptionsRequest {
  275. // Required. The name of the topic that subscriptions are attached to.
  276. // Format is `projects/{project}/topics/{topic}`.
  277. string topic = 1 [
  278. (google.api.field_behavior) = REQUIRED,
  279. (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" }
  280. ];
  281. // Maximum number of subscription names to return.
  282. int32 page_size = 2;
  283. // The value returned by the last `ListTopicSubscriptionsResponse`; indicates
  284. // that this is a continuation of a prior `ListTopicSubscriptions` call, and
  285. // that the system should return the next page of data.
  286. string page_token = 3;
  287. }
  288. // Response for the `ListTopicSubscriptions` method.
  289. message ListTopicSubscriptionsResponse {
  290. // The names of subscriptions attached to the topic specified in the request.
  291. repeated string subscriptions = 1 [(google.api.resource_reference) = {
  292. type: "pubsub.googleapis.com/Subscription"
  293. }];
  294. // If not empty, indicates that there may be more subscriptions that match
  295. // the request; this value should be passed in a new
  296. // `ListTopicSubscriptionsRequest` to get more subscriptions.
  297. string next_page_token = 2;
  298. }
  299. // Request for the `ListTopicSnapshots` method.
  300. message ListTopicSnapshotsRequest {
  301. // Required. The name of the topic that snapshots are attached to.
  302. // Format is `projects/{project}/topics/{topic}`.
  303. string topic = 1 [
  304. (google.api.field_behavior) = REQUIRED,
  305. (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" }
  306. ];
  307. // Maximum number of snapshot names to return.
  308. int32 page_size = 2;
  309. // The value returned by the last `ListTopicSnapshotsResponse`; indicates
  310. // that this is a continuation of a prior `ListTopicSnapshots` call, and
  311. // that the system should return the next page of data.
  312. string page_token = 3;
  313. }
  314. // Response for the `ListTopicSnapshots` method.
  315. message ListTopicSnapshotsResponse {
  316. // The names of the snapshots that match the request.
  317. repeated string snapshots = 1;
  318. // If not empty, indicates that there may be more snapshots that match
  319. // the request; this value should be passed in a new
  320. // `ListTopicSnapshotsRequest` to get more snapshots.
  321. string next_page_token = 2;
  322. }
  323. // Request for the `DeleteTopic` method.
  324. message DeleteTopicRequest {
  325. // Required. Name of the topic to delete.
  326. // Format is `projects/{project}/topics/{topic}`.
  327. string topic = 1 [
  328. (google.api.field_behavior) = REQUIRED,
  329. (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" }
  330. ];
  331. }
  332. // Request for the DetachSubscription method.
  333. message DetachSubscriptionRequest {
  334. // Required. The subscription to detach.
  335. // Format is `projects/{project}/subscriptions/{subscription}`.
  336. string subscription = 1 [
  337. (google.api.field_behavior) = REQUIRED,
  338. (google.api.resource_reference) = {
  339. type: "pubsub.googleapis.com/Subscription"
  340. }
  341. ];
  342. }
  343. // Response for the DetachSubscription method.
  344. // Reserved for future use.
  345. message DetachSubscriptionResponse {}
  346. // The service that an application uses to manipulate subscriptions and to
  347. // consume messages from a subscription via the `Pull` method or by
  348. // establishing a bi-directional stream using the `StreamingPull` method.
  349. service Subscriber {
  350. option (google.api.default_host) = "pubsub.googleapis.com";
  351. option (google.api.oauth_scopes) =
  352. "https://www.googleapis.com/auth/cloud-platform,"
  353. "https://www.googleapis.com/auth/pubsub";
  354. // Creates a subscription to a given topic. See the [resource name rules]
  355. // (https://cloud.google.com/pubsub/docs/admin#resource_names).
  356. // If the subscription already exists, returns `ALREADY_EXISTS`.
  357. // If the corresponding topic doesn't exist, returns `NOT_FOUND`.
  358. //
  359. // If the name is not provided in the request, the server will assign a random
  360. // name for this subscription on the same project as the topic, conforming
  361. // to the [resource name format]
  362. // (https://cloud.google.com/pubsub/docs/admin#resource_names). The generated
  363. // name is populated in the returned Subscription object. Note that for REST
  364. // API requests, you must specify a name in the request.
  365. rpc CreateSubscription(Subscription) returns (Subscription) {
  366. option (google.api.http) = {
  367. put: "/v1/{name=projects/*/subscriptions/*}"
  368. body: "*"
  369. };
  370. option (google.api.method_signature) =
  371. "name,topic,push_config,ack_deadline_seconds";
  372. }
  373. // Gets the configuration details of a subscription.
  374. rpc GetSubscription(GetSubscriptionRequest) returns (Subscription) {
  375. option (google.api.http) = {
  376. get: "/v1/{subscription=projects/*/subscriptions/*}"
  377. };
  378. option (google.api.method_signature) = "subscription";
  379. }
  380. // Updates an existing subscription. Note that certain properties of a
  381. // subscription, such as its topic, are not modifiable.
  382. rpc UpdateSubscription(UpdateSubscriptionRequest) returns (Subscription) {
  383. option (google.api.http) = {
  384. patch: "/v1/{subscription.name=projects/*/subscriptions/*}"
  385. body: "*"
  386. };
  387. }
  388. // Lists matching subscriptions.
  389. rpc ListSubscriptions(ListSubscriptionsRequest)
  390. returns (ListSubscriptionsResponse) {
  391. option (google.api.http) = {
  392. get: "/v1/{project=projects/*}/subscriptions"
  393. };
  394. option (google.api.method_signature) = "project";
  395. }
  396. // Deletes an existing subscription. All messages retained in the subscription
  397. // are immediately dropped. Calls to `Pull` after deletion will return
  398. // `NOT_FOUND`. After a subscription is deleted, a new one may be created with
  399. // the same name, but the new one has no association with the old
  400. // subscription or its topic unless the same topic is specified.
  401. rpc DeleteSubscription(DeleteSubscriptionRequest)
  402. returns (google.protobuf.Empty) {
  403. option (google.api.http) = {
  404. delete: "/v1/{subscription=projects/*/subscriptions/*}"
  405. };
  406. option (google.api.method_signature) = "subscription";
  407. }
  408. // Modifies the ack deadline for a specific message. This method is useful
  409. // to indicate that more time is needed to process a message by the
  410. // subscriber, or to make the message available for redelivery if the
  411. // processing was interrupted. Note that this does not modify the
  412. // subscription-level `ackDeadlineSeconds` used for subsequent messages.
  413. rpc ModifyAckDeadline(ModifyAckDeadlineRequest)
  414. returns (google.protobuf.Empty) {
  415. option (google.api.http) = {
  416. post: "/v1/{subscription=projects/*/subscriptions/*}:modifyAckDeadline"
  417. body: "*"
  418. };
  419. option (google.api.method_signature) =
  420. "subscription,ack_ids,ack_deadline_seconds";
  421. }
  422. // Acknowledges the messages associated with the `ack_ids` in the
  423. // `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages
  424. // from the subscription.
  425. //
  426. // Acknowledging a message whose ack deadline has expired may succeed,
  427. // but such a message may be redelivered later. Acknowledging a message more
  428. // than once will not result in an error.
  429. rpc Acknowledge(AcknowledgeRequest) returns (google.protobuf.Empty) {
  430. option (google.api.http) = {
  431. post: "/v1/{subscription=projects/*/subscriptions/*}:acknowledge"
  432. body: "*"
  433. };
  434. option (google.api.method_signature) = "subscription,ack_ids";
  435. }
  436. // Pulls messages from the server. The server may return `UNAVAILABLE` if
  437. // there are too many concurrent pull requests pending for the given
  438. // subscription.
  439. rpc Pull(PullRequest) returns (PullResponse) {
  440. option (google.api.http) = {
  441. post: "/v1/{subscription=projects/*/subscriptions/*}:pull"
  442. body: "*"
  443. };
  444. option (google.api.method_signature) =
  445. "subscription,return_immediately,max_messages";
  446. option (google.api.method_signature) = "subscription,max_messages";
  447. }
  448. // Establishes a stream with the server, which sends messages down to the
  449. // client. The client streams acknowledgements and ack deadline modifications
  450. // back to the server. The server will close the stream and return the status
  451. // on any error. The server may close the stream with status `UNAVAILABLE` to
  452. // reassign server-side resources, in which case, the client should
  453. // re-establish the stream. Flow control can be achieved by configuring the
  454. // underlying RPC channel.
  455. rpc StreamingPull(stream StreamingPullRequest)
  456. returns (stream StreamingPullResponse) {}
  457. // Modifies the `PushConfig` for a specified subscription.
  458. //
  459. // This may be used to change a push subscription to a pull one (signified by
  460. // an empty `PushConfig`) or vice versa, or change the endpoint URL and other
  461. // attributes of a push subscription. Messages will accumulate for delivery
  462. // continuously through the call regardless of changes to the `PushConfig`.
  463. rpc ModifyPushConfig(ModifyPushConfigRequest)
  464. returns (google.protobuf.Empty) {
  465. option (google.api.http) = {
  466. post: "/v1/{subscription=projects/*/subscriptions/*}:modifyPushConfig"
  467. body: "*"
  468. };
  469. option (google.api.method_signature) = "subscription,push_config";
  470. }
  471. // Gets the configuration details of a snapshot. Snapshots are used in
  472. // <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
  473. // operations, which allow you to manage message acknowledgments in bulk. That
  474. // is, you can set the acknowledgment state of messages in an existing
  475. // subscription to the state captured by a snapshot.
  476. rpc GetSnapshot(GetSnapshotRequest) returns (Snapshot) {
  477. option (google.api.http) = {
  478. get: "/v1/{snapshot=projects/*/snapshots/*}"
  479. };
  480. option (google.api.method_signature) = "snapshot";
  481. }
  482. // Lists the existing snapshots. Snapshots are used in [Seek](
  483. // https://cloud.google.com/pubsub/docs/replay-overview) operations, which
  484. // allow you to manage message acknowledgments in bulk. That is, you can set
  485. // the acknowledgment state of messages in an existing subscription to the
  486. // state captured by a snapshot.
  487. rpc ListSnapshots(ListSnapshotsRequest) returns (ListSnapshotsResponse) {
  488. option (google.api.http) = {
  489. get: "/v1/{project=projects/*}/snapshots"
  490. };
  491. option (google.api.method_signature) = "project";
  492. }
  493. // Creates a snapshot from the requested subscription. Snapshots are used in
  494. // [Seek](https://cloud.google.com/pubsub/docs/replay-overview) operations,
  495. // which allow you to manage message acknowledgments in bulk. That is, you can
  496. // set the acknowledgment state of messages in an existing subscription to the
  497. // state captured by a snapshot.
  498. // If the snapshot already exists, returns `ALREADY_EXISTS`.
  499. // If the requested subscription doesn't exist, returns `NOT_FOUND`.
  500. // If the backlog in the subscription is too old -- and the resulting snapshot
  501. // would expire in less than 1 hour -- then `FAILED_PRECONDITION` is returned.
  502. // See also the `Snapshot.expire_time` field. If the name is not provided in
  503. // the request, the server will assign a random
  504. // name for this snapshot on the same project as the subscription, conforming
  505. // to the [resource name format]
  506. // (https://cloud.google.com/pubsub/docs/admin#resource_names). The
  507. // generated name is populated in the returned Snapshot object. Note that for
  508. // REST API requests, you must specify a name in the request.
  509. rpc CreateSnapshot(CreateSnapshotRequest) returns (Snapshot) {
  510. option (google.api.http) = {
  511. put: "/v1/{name=projects/*/snapshots/*}"
  512. body: "*"
  513. };
  514. option (google.api.method_signature) = "name,subscription";
  515. }
  516. // Updates an existing snapshot. Snapshots are used in
  517. // <a href="https://cloud.google.com/pubsub/docs/replay-overview">Seek</a>
  518. // operations, which allow
  519. // you to manage message acknowledgments in bulk. That is, you can set the
  520. // acknowledgment state of messages in an existing subscription to the state
  521. // captured by a snapshot.
  522. rpc UpdateSnapshot(UpdateSnapshotRequest) returns (Snapshot) {
  523. option (google.api.http) = {
  524. patch: "/v1/{snapshot.name=projects/*/snapshots/*}"
  525. body: "*"
  526. };
  527. }
  528. // Removes an existing snapshot. Snapshots are used in [Seek]
  529. // (https://cloud.google.com/pubsub/docs/replay-overview) operations, which
  530. // allow you to manage message acknowledgments in bulk. That is, you can set
  531. // the acknowledgment state of messages in an existing subscription to the
  532. // state captured by a snapshot.
  533. // When the snapshot is deleted, all messages retained in the snapshot
  534. // are immediately dropped. After a snapshot is deleted, a new one may be
  535. // created with the same name, but the new one has no association with the old
  536. // snapshot or its subscription, unless the same subscription is specified.
  537. rpc DeleteSnapshot(DeleteSnapshotRequest) returns (google.protobuf.Empty) {
  538. option (google.api.http) = {
  539. delete: "/v1/{snapshot=projects/*/snapshots/*}"
  540. };
  541. option (google.api.method_signature) = "snapshot";
  542. }
  543. // Seeks an existing subscription to a point in time or to a given snapshot,
  544. // whichever is provided in the request. Snapshots are used in [Seek]
  545. // (https://cloud.google.com/pubsub/docs/replay-overview) operations, which
  546. // allow you to manage message acknowledgments in bulk. That is, you can set
  547. // the acknowledgment state of messages in an existing subscription to the
  548. // state captured by a snapshot. Note that both the subscription and the
  549. // snapshot must be on the same topic.
  550. rpc Seek(SeekRequest) returns (SeekResponse) {
  551. option (google.api.http) = {
  552. post: "/v1/{subscription=projects/*/subscriptions/*}:seek"
  553. body: "*"
  554. };
  555. }
  556. }
  557. // A subscription resource.
  558. message Subscription {
  559. option (google.api.resource) = {
  560. type: "pubsub.googleapis.com/Subscription"
  561. pattern: "projects/{project}/subscriptions/{subscription}"
  562. };
  563. // Required. The name of the subscription. It must have the format
  564. // `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
  565. // start with a letter, and contain only letters (`[A-Za-z]`), numbers
  566. // (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
  567. // plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
  568. // in length, and it must not start with `"goog"`.
  569. string name = 1 [(google.api.field_behavior) = REQUIRED];
  570. // Required. The name of the topic from which this subscription is receiving
  571. // messages. Format is `projects/{project}/topics/{topic}`. The value of this
  572. // field will be `_deleted-topic_` if the topic has been deleted.
  573. string topic = 2 [
  574. (google.api.field_behavior) = REQUIRED,
  575. (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" }
  576. ];
  577. // If push delivery is used with this subscription, this field is
  578. // used to configure it. An empty `pushConfig` signifies that the subscriber
  579. // will pull and ack messages using API methods.
  580. PushConfig push_config = 4;
  581. // The approximate amount of time (on a best-effort basis) Pub/Sub waits for
  582. // the subscriber to acknowledge receipt before resending the message. In the
  583. // interval after the message is delivered and before it is acknowledged, it
  584. // is considered to be <i>outstanding</i>. During that time period, the
  585. // message will not be redelivered (on a best-effort basis).
  586. //
  587. // For pull subscriptions, this value is used as the initial value for the ack
  588. // deadline. To override this value for a given message, call
  589. // `ModifyAckDeadline` with the corresponding `ack_id` if using
  590. // non-streaming pull or send the `ack_id` in a
  591. // `StreamingModifyAckDeadlineRequest` if using streaming pull.
  592. // The minimum custom deadline you can specify is 10 seconds.
  593. // The maximum custom deadline you can specify is 600 seconds (10 minutes).
  594. // If this parameter is 0, a default value of 10 seconds is used.
  595. //
  596. // For push delivery, this value is also used to set the request timeout for
  597. // the call to the push endpoint.
  598. //
  599. // If the subscriber never acknowledges the message, the Pub/Sub
  600. // system will eventually redeliver the message.
  601. int32 ack_deadline_seconds = 5;
  602. // Indicates whether to retain acknowledged messages. If true, then
  603. // messages are not expunged from the subscription's backlog, even if they are
  604. // acknowledged, until they fall out of the `message_retention_duration`
  605. // window. This must be true if you would like to [Seek to a timestamp]
  606. // (https://cloud.google.com/pubsub/docs/replay-overview#seek_to_a_time).
  607. bool retain_acked_messages = 7;
  608. // How long to retain unacknowledged messages in the subscription's backlog,
  609. // from the moment a message is published.
  610. // If `retain_acked_messages` is true, then this also configures the retention
  611. // of acknowledged messages, and thus configures how far back in time a `Seek`
  612. // can be done. Defaults to 7 days. Cannot be more than 7 days or less than 10
  613. // minutes.
  614. google.protobuf.Duration message_retention_duration = 8;
  615. // See <a href="https://cloud.google.com/pubsub/docs/labels"> Creating and
  616. // managing labels</a>.
  617. map<string, string> labels = 9;
  618. // If true, messages published with the same `ordering_key` in `PubsubMessage`
  619. // will be delivered to the subscribers in the order in which they
  620. // are received by the Pub/Sub system. Otherwise, they may be delivered in
  621. // any order.
  622. bool enable_message_ordering = 10;
  623. // A policy that specifies the conditions for this subscription's expiration.
  624. // A subscription is considered active as long as any connected subscriber is
  625. // successfully consuming messages from the subscription or is issuing
  626. // operations on the subscription. If `expiration_policy` is not set, a
  627. // *default policy* with `ttl` of 31 days will be used. The minimum allowed
  628. // value for `expiration_policy.ttl` is 1 day.
  629. ExpirationPolicy expiration_policy = 11;
  630. // An expression written in the Pub/Sub [filter
  631. // language](https://cloud.google.com/pubsub/docs/filtering). If non-empty,
  632. // then only `PubsubMessage`s whose `attributes` field matches the filter are
  633. // delivered on this subscription. If empty, then no messages are filtered
  634. // out.
  635. string filter = 12;
  636. // A policy that specifies the conditions for dead lettering messages in
  637. // this subscription. If dead_letter_policy is not set, dead lettering
  638. // is disabled.
  639. //
  640. // The Cloud Pub/Sub service account associated with this subscriptions's
  641. // parent project (i.e.,
  642. // service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have
  643. // permission to Acknowledge() messages on this subscription.
  644. DeadLetterPolicy dead_letter_policy = 13;
  645. // A policy that specifies how Pub/Sub retries message delivery for this
  646. // subscription.
  647. //
  648. // If not set, the default retry policy is applied. This generally implies
  649. // that messages will be retried as soon as possible for healthy subscribers.
  650. // RetryPolicy will be triggered on NACKs or acknowledgement deadline
  651. // exceeded events for a given message.
  652. RetryPolicy retry_policy = 14;
  653. // Indicates whether the subscription is detached from its topic. Detached
  654. // subscriptions don't receive messages from their topic and don't retain any
  655. // backlog. `Pull` and `StreamingPull` requests will return
  656. // FAILED_PRECONDITION. If the subscription is a push subscription, pushes to
  657. // the endpoint will not be made.
  658. bool detached = 15;
  659. }
  660. // A policy that specifies how Cloud Pub/Sub retries message delivery.
  661. //
  662. // Retry delay will be exponential based on provided minimum and maximum
  663. // backoffs. https://en.wikipedia.org/wiki/Exponential_backoff.
  664. //
  665. // RetryPolicy will be triggered on NACKs or acknowledgement deadline exceeded
  666. // events for a given message.
  667. //
  668. // Retry Policy is implemented on a best effort basis. At times, the delay
  669. // between consecutive deliveries may not match the configuration. That is,
  670. // delay can be more or less than configured backoff.
  671. message RetryPolicy {
  672. // The minimum delay between consecutive deliveries of a given message.
  673. // Value should be between 0 and 600 seconds. Defaults to 10 seconds.
  674. google.protobuf.Duration minimum_backoff = 1;
  675. // The maximum delay between consecutive deliveries of a given message.
  676. // Value should be between 0 and 600 seconds. Defaults to 600 seconds.
  677. google.protobuf.Duration maximum_backoff = 2;
  678. }
  679. // Dead lettering is done on a best effort basis. The same message might be
  680. // dead lettered multiple times.
  681. //
  682. // If validation on any of the fields fails at subscription creation/updation,
  683. // the create/update subscription request will fail.
  684. message DeadLetterPolicy {
  685. // The name of the topic to which dead letter messages should be published.
  686. // Format is `projects/{project}/topics/{topic}`.The Cloud Pub/Sub service
  687. // account associated with the enclosing subscription's parent project (i.e.,
  688. // service-{project_number}@gcp-sa-pubsub.iam.gserviceaccount.com) must have
  689. // permission to Publish() to this topic.
  690. //
  691. // The operation will fail if the topic does not exist.
  692. // Users should ensure that there is a subscription attached to this topic
  693. // since messages published to a topic with no subscriptions are lost.
  694. string dead_letter_topic = 1;
  695. // The maximum number of delivery attempts for any message. The value must be
  696. // between 5 and 100.
  697. //
  698. // The number of delivery attempts is defined as 1 + (the sum of number of
  699. // NACKs and number of times the acknowledgement deadline has been exceeded
  700. // for the message).
  701. //
  702. // A NACK is any call to ModifyAckDeadline with a 0 deadline. Note that
  703. // client libraries may automatically extend ack_deadlines.
  704. //
  705. // This field will be honored on a best effort basis.
  706. //
  707. // If this parameter is 0, a default value of 5 is used.
  708. int32 max_delivery_attempts = 2;
  709. }
  710. // A policy that specifies the conditions for resource expiration (i.e.,
  711. // automatic resource deletion).
  712. message ExpirationPolicy {
  713. // Specifies the "time-to-live" duration for an associated resource. The
  714. // resource expires if it is not active for a period of `ttl`. The definition
  715. // of "activity" depends on the type of the associated resource. The minimum
  716. // and maximum allowed values for `ttl` depend on the type of the associated
  717. // resource, as well. If `ttl` is not set, the associated resource never
  718. // expires.
  719. google.protobuf.Duration ttl = 1;
  720. }
  721. // Configuration for a push delivery endpoint.
  722. message PushConfig {
  723. // Contains information needed for generating an
  724. // [OpenID Connect
  725. // token](https://developers.google.com/identity/protocols/OpenIDConnect).
  726. message OidcToken {
  727. // [Service account
  728. // email](https://cloud.google.com/iam/docs/service-accounts)
  729. // to be used for generating the OIDC token. The caller (for
  730. // CreateSubscription, UpdateSubscription, and ModifyPushConfig RPCs) must
  731. // have the iam.serviceAccounts.actAs permission for the service account.
  732. string service_account_email = 1;
  733. // Audience to be used when generating OIDC token. The audience claim
  734. // identifies the recipients that the JWT is intended for. The audience
  735. // value is a single case-sensitive string. Having multiple values (array)
  736. // for the audience field is not supported. More info about the OIDC JWT
  737. // token audience here: https://tools.ietf.org/html/rfc7519#section-4.1.3
  738. // Note: if not specified, the Push endpoint URL will be used.
  739. string audience = 2;
  740. }
  741. // A URL locating the endpoint to which messages should be pushed.
  742. // For example, a Webhook endpoint might use `https://example.com/push`.
  743. string push_endpoint = 1;
  744. // Endpoint configuration attributes that can be used to control different
  745. // aspects of the message delivery.
  746. //
  747. // The only currently supported attribute is `x-goog-version`, which you can
  748. // use to change the format of the pushed message. This attribute
  749. // indicates the version of the data expected by the endpoint. This
  750. // controls the shape of the pushed message (i.e., its fields and metadata).
  751. //
  752. // If not present during the `CreateSubscription` call, it will default to
  753. // the version of the Pub/Sub API used to make such call. If not present in a
  754. // `ModifyPushConfig` call, its value will not be changed. `GetSubscription`
  755. // calls will always return a valid version, even if the subscription was
  756. // created without this attribute.
  757. //
  758. // The only supported values for the `x-goog-version` attribute are:
  759. //
  760. // * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub API.
  761. // * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub API.
  762. //
  763. // For example:
  764. // <pre><code>attributes { "x-goog-version": "v1" } </code></pre>
  765. map<string, string> attributes = 2;
  766. // An authentication method used by push endpoints to verify the source of
  767. // push requests. This can be used with push endpoints that are private by
  768. // default to allow requests only from the Cloud Pub/Sub system, for example.
  769. // This field is optional and should be set only by users interested in
  770. // authenticated push.
  771. oneof authentication_method {
  772. // If specified, Pub/Sub will generate and attach an OIDC JWT token as an
  773. // `Authorization` header in the HTTP request for every pushed message.
  774. OidcToken oidc_token = 3;
  775. }
  776. }
  777. // A message and its corresponding acknowledgment ID.
  778. message ReceivedMessage {
  779. // This ID can be used to acknowledge the received message.
  780. string ack_id = 1;
  781. // The message.
  782. PubsubMessage message = 2;
  783. // The approximate number of times that Cloud Pub/Sub has attempted to deliver
  784. // the associated message to a subscriber.
  785. //
  786. // More precisely, this is 1 + (number of NACKs) +
  787. // (number of ack_deadline exceeds) for this message.
  788. //
  789. // A NACK is any call to ModifyAckDeadline with a 0 deadline. An ack_deadline
  790. // exceeds event is whenever a message is not acknowledged within
  791. // ack_deadline. Note that ack_deadline is initially
  792. // Subscription.ackDeadlineSeconds, but may get extended automatically by
  793. // the client library.
  794. //
  795. // Upon the first delivery of a given message, `delivery_attempt` will have a
  796. // value of 1. The value is calculated at best effort and is approximate.
  797. //
  798. // If a DeadLetterPolicy is not set on the subscription, this will be 0.
  799. int32 delivery_attempt = 3;
  800. }
  801. // Request for the GetSubscription method.
  802. message GetSubscriptionRequest {
  803. // Required. The name of the subscription to get.
  804. // Format is `projects/{project}/subscriptions/{sub}`.
  805. string subscription = 1 [
  806. (google.api.field_behavior) = REQUIRED,
  807. (google.api.resource_reference) = {
  808. type: "pubsub.googleapis.com/Subscription"
  809. }
  810. ];
  811. }
  812. // Request for the UpdateSubscription method.
  813. message UpdateSubscriptionRequest {
  814. // Required. The updated subscription object.
  815. Subscription subscription = 1 [(google.api.field_behavior) = REQUIRED];
  816. // Required. Indicates which fields in the provided subscription to update.
  817. // Must be specified and non-empty.
  818. google.protobuf.FieldMask update_mask = 2
  819. [(google.api.field_behavior) = REQUIRED];
  820. }
  821. // Request for the `ListSubscriptions` method.
  822. message ListSubscriptionsRequest {
  823. // Required. The name of the project in which to list subscriptions.
  824. // Format is `projects/{project-id}`.
  825. string project = 1 [
  826. (google.api.field_behavior) = REQUIRED,
  827. (google.api.resource_reference) = {
  828. type: "cloudresourcemanager.googleapis.com/Project"
  829. }
  830. ];
  831. // Maximum number of subscriptions to return.
  832. int32 page_size = 2;
  833. // The value returned by the last `ListSubscriptionsResponse`; indicates that
  834. // this is a continuation of a prior `ListSubscriptions` call, and that the
  835. // system should return the next page of data.
  836. string page_token = 3;
  837. }
  838. // Response for the `ListSubscriptions` method.
  839. message ListSubscriptionsResponse {
  840. // The subscriptions that match the request.
  841. repeated Subscription subscriptions = 1;
  842. // If not empty, indicates that there may be more subscriptions that match
  843. // the request; this value should be passed in a new
  844. // `ListSubscriptionsRequest` to get more subscriptions.
  845. string next_page_token = 2;
  846. }
  847. // Request for the DeleteSubscription method.
  848. message DeleteSubscriptionRequest {
  849. // Required. The subscription to delete.
  850. // Format is `projects/{project}/subscriptions/{sub}`.
  851. string subscription = 1 [
  852. (google.api.field_behavior) = REQUIRED,
  853. (google.api.resource_reference) = {
  854. type: "pubsub.googleapis.com/Subscription"
  855. }
  856. ];
  857. }
  858. // Request for the ModifyPushConfig method.
  859. message ModifyPushConfigRequest {
  860. // Required. The name of the subscription.
  861. // Format is `projects/{project}/subscriptions/{sub}`.
  862. string subscription = 1 [
  863. (google.api.field_behavior) = REQUIRED,
  864. (google.api.resource_reference) = {
  865. type: "pubsub.googleapis.com/Subscription"
  866. }
  867. ];
  868. // Required. The push configuration for future deliveries.
  869. //
  870. // An empty `pushConfig` indicates that the Pub/Sub system should
  871. // stop pushing messages from the given subscription and allow
  872. // messages to be pulled and acknowledged - effectively pausing
  873. // the subscription if `Pull` or `StreamingPull` is not called.
  874. PushConfig push_config = 2 [(google.api.field_behavior) = REQUIRED];
  875. }
  876. // Request for the `Pull` method.
  877. message PullRequest {
  878. // Required. The subscription from which messages should be pulled.
  879. // Format is `projects/{project}/subscriptions/{sub}`.
  880. string subscription = 1 [
  881. (google.api.field_behavior) = REQUIRED,
  882. (google.api.resource_reference) = {
  883. type: "pubsub.googleapis.com/Subscription"
  884. }
  885. ];
  886. // Optional. If this field set to true, the system will respond immediately
  887. // even if it there are no messages available to return in the `Pull`
  888. // response. Otherwise, the system may wait (for a bounded amount of time)
  889. // until at least one message is available, rather than returning no messages.
  890. // Warning: setting this field to `true` is discouraged because it adversely
  891. // impacts the performance of `Pull` operations. We recommend that users do
  892. // not set this field.
  893. bool return_immediately = 2
  894. [deprecated = true, (google.api.field_behavior) = OPTIONAL];
  895. // Required. The maximum number of messages to return for this request. Must
  896. // be a positive integer. The Pub/Sub system may return fewer than the number
  897. // specified.
  898. int32 max_messages = 3 [(google.api.field_behavior) = REQUIRED];
  899. }
  900. // Response for the `Pull` method.
  901. message PullResponse {
  902. // Received Pub/Sub messages. The list will be empty if there are no more
  903. // messages available in the backlog. For JSON, the response can be entirely
  904. // empty. The Pub/Sub system may return fewer than the `maxMessages` requested
  905. // even if there are more messages available in the backlog.
  906. repeated ReceivedMessage received_messages = 1;
  907. }
  908. // Request for the ModifyAckDeadline method.
  909. message ModifyAckDeadlineRequest {
  910. // Required. The name of the subscription.
  911. // Format is `projects/{project}/subscriptions/{sub}`.
  912. string subscription = 1 [
  913. (google.api.field_behavior) = REQUIRED,
  914. (google.api.resource_reference) = {
  915. type: "pubsub.googleapis.com/Subscription"
  916. }
  917. ];
  918. // Required. List of acknowledgment IDs.
  919. repeated string ack_ids = 4 [(google.api.field_behavior) = REQUIRED];
  920. // Required. The new ack deadline with respect to the time this request was
  921. // sent to the Pub/Sub system. For example, if the value is 10, the new ack
  922. // deadline will expire 10 seconds after the `ModifyAckDeadline` call was
  923. // made. Specifying zero might immediately make the message available for
  924. // delivery to another subscriber client. This typically results in an
  925. // increase in the rate of message redeliveries (that is, duplicates).
  926. // The minimum deadline you can specify is 0 seconds.
  927. // The maximum deadline you can specify is 600 seconds (10 minutes).
  928. int32 ack_deadline_seconds = 3 [(google.api.field_behavior) = REQUIRED];
  929. }
  930. // Request for the Acknowledge method.
  931. message AcknowledgeRequest {
  932. // Required. The subscription whose message is being acknowledged.
  933. // Format is `projects/{project}/subscriptions/{sub}`.
  934. string subscription = 1 [
  935. (google.api.field_behavior) = REQUIRED,
  936. (google.api.resource_reference) = {
  937. type: "pubsub.googleapis.com/Subscription"
  938. }
  939. ];
  940. // Required. The acknowledgment ID for the messages being acknowledged that
  941. // was returned by the Pub/Sub system in the `Pull` response. Must not be
  942. // empty.
  943. repeated string ack_ids = 2 [(google.api.field_behavior) = REQUIRED];
  944. }
  945. // Request for the `StreamingPull` streaming RPC method. This request is used to
  946. // establish the initial stream as well as to stream acknowledgements and ack
  947. // deadline modifications from the client to the server.
  948. message StreamingPullRequest {
  949. // Required. The subscription for which to initialize the new stream. This
  950. // must be provided in the first request on the stream, and must not be set in
  951. // subsequent requests from client to server.
  952. // Format is `projects/{project}/subscriptions/{sub}`.
  953. string subscription = 1 [
  954. (google.api.field_behavior) = REQUIRED,
  955. (google.api.resource_reference) = {
  956. type: "pubsub.googleapis.com/Subscription"
  957. }
  958. ];
  959. // List of acknowledgement IDs for acknowledging previously received messages
  960. // (received on this stream or a different stream). If an ack ID has expired,
  961. // the corresponding message may be redelivered later. Acknowledging a message
  962. // more than once will not result in an error. If the acknowledgement ID is
  963. // malformed, the stream will be aborted with status `INVALID_ARGUMENT`.
  964. repeated string ack_ids = 2;
  965. // The list of new ack deadlines for the IDs listed in
  966. // `modify_deadline_ack_ids`. The size of this list must be the same as the
  967. // size of `modify_deadline_ack_ids`. If it differs the stream will be aborted
  968. // with `INVALID_ARGUMENT`. Each element in this list is applied to the
  969. // element in the same position in `modify_deadline_ack_ids`. The new ack
  970. // deadline is with respect to the time this request was sent to the Pub/Sub
  971. // system. Must be >= 0. For example, if the value is 10, the new ack deadline
  972. // will expire 10 seconds after this request is received. If the value is 0,
  973. // the message is immediately made available for another streaming or
  974. // non-streaming pull request. If the value is < 0 (an error), the stream will
  975. // be aborted with status `INVALID_ARGUMENT`.
  976. repeated int32 modify_deadline_seconds = 3;
  977. // List of acknowledgement IDs whose deadline will be modified based on the
  978. // corresponding element in `modify_deadline_seconds`. This field can be used
  979. // to indicate that more time is needed to process a message by the
  980. // subscriber, or to make the message available for redelivery if the
  981. // processing was interrupted.
  982. repeated string modify_deadline_ack_ids = 4;
  983. // Required. The ack deadline to use for the stream. This must be provided in
  984. // the first request on the stream, but it can also be updated on subsequent
  985. // requests from client to server. The minimum deadline you can specify is 10
  986. // seconds. The maximum deadline you can specify is 600 seconds (10 minutes).
  987. int32 stream_ack_deadline_seconds = 5
  988. [(google.api.field_behavior) = REQUIRED];
  989. // A unique identifier that is used to distinguish client instances from each
  990. // other. Only needs to be provided on the initial request. When a stream
  991. // disconnects and reconnects for the same stream, the client_id should be set
  992. // to the same value so that state associated with the old stream can be
  993. // transferred to the new stream. The same client_id should not be used for
  994. // different client instances.
  995. string client_id = 6;
  996. // Flow control settings for the maximum number of outstanding messages. When
  997. // there are `max_outstanding_messages` or more currently sent to the
  998. // streaming pull client that have not yet been acked or nacked, the server
  999. // stops sending more messages. The sending of messages resumes once the
  1000. // number of outstanding messages is less than this value. If the value is
  1001. // <= 0, there is no limit to the number of outstanding messages. This
  1002. // property can only be set on the initial StreamingPullRequest. If it is set
  1003. // on a subsequent request, the stream will be aborted with status
  1004. // `INVALID_ARGUMENT`.
  1005. int64 max_outstanding_messages = 7;
  1006. // Flow control settings for the maximum number of outstanding bytes. When
  1007. // there are `max_outstanding_bytes` or more worth of messages currently sent
  1008. // to the streaming pull client that have not yet been acked or nacked, the
  1009. // server will stop sending more messages. The sending of messages resumes
  1010. // once the number of outstanding bytes is less than this value. If the value
  1011. // is <= 0, there is no limit to the number of outstanding bytes. This
  1012. // property can only be set on the initial StreamingPullRequest. If it is set
  1013. // on a subsequent request, the stream will be aborted with status
  1014. // `INVALID_ARGUMENT`.
  1015. int64 max_outstanding_bytes = 8;
  1016. }
  1017. // Response for the `StreamingPull` method. This response is used to stream
  1018. // messages from the server to the client.
  1019. message StreamingPullResponse {
  1020. // Subscription properties sent as part of the response.
  1021. message SubscriptionProperties {
  1022. // True iff message ordering is enabled for this subscription.
  1023. bool message_ordering_enabled = 2;
  1024. }
  1025. // Received Pub/Sub messages. This will not be empty.
  1026. repeated ReceivedMessage received_messages = 1;
  1027. // Properties associated with this subscription.
  1028. SubscriptionProperties subscription_properties = 4;
  1029. }
  1030. // Request for the `CreateSnapshot` method.
  1031. message CreateSnapshotRequest {
  1032. // Required. User-provided name for this snapshot. If the name is not provided
  1033. // in the request, the server will assign a random name for this snapshot on
  1034. // the same project as the subscription. Note that for REST API requests, you
  1035. // must specify a name. See the <a
  1036. // href="https://cloud.google.com/pubsub/docs/admin#resource_names"> resource
  1037. // name rules</a>. Format is `projects/{project}/snapshots/{snap}`.
  1038. string name = 1 [
  1039. (google.api.field_behavior) = REQUIRED,
  1040. (google.api.resource_reference) = { type: "pubsub.googleapis.com/Snapshot" }
  1041. ];
  1042. // Required. The subscription whose backlog the snapshot retains.
  1043. // Specifically, the created snapshot is guaranteed to retain:
  1044. // (a) The existing backlog on the subscription. More precisely, this is
  1045. // defined as the messages in the subscription's backlog that are
  1046. // unacknowledged upon the successful completion of the
  1047. // `CreateSnapshot` request; as well as:
  1048. // (b) Any messages published to the subscription's topic following the
  1049. // successful completion of the CreateSnapshot request.
  1050. // Format is `projects/{project}/subscriptions/{sub}`.
  1051. string subscription = 2 [
  1052. (google.api.field_behavior) = REQUIRED,
  1053. (google.api.resource_reference) = {
  1054. type: "pubsub.googleapis.com/Subscription"
  1055. }
  1056. ];
  1057. // See <a href="https://cloud.google.com/pubsub/docs/labels"> Creating and
  1058. // managing labels</a>.
  1059. map<string, string> labels = 3;
  1060. }
  1061. // Request for the UpdateSnapshot method.
  1062. message UpdateSnapshotRequest {
  1063. // Required. The updated snapshot object.
  1064. Snapshot snapshot = 1 [(google.api.field_behavior) = REQUIRED];
  1065. // Required. Indicates which fields in the provided snapshot to update.
  1066. // Must be specified and non-empty.
  1067. google.protobuf.FieldMask update_mask = 2
  1068. [(google.api.field_behavior) = REQUIRED];
  1069. }
  1070. // A snapshot resource. Snapshots are used in
  1071. // [Seek](https://cloud.google.com/pubsub/docs/replay-overview)
  1072. // operations, which allow you to manage message acknowledgments in bulk. That
  1073. // is, you can set the acknowledgment state of messages in an existing
  1074. // subscription to the state captured by a snapshot.
  1075. message Snapshot {
  1076. option (google.api.resource) = {
  1077. type: "pubsub.googleapis.com/Snapshot"
  1078. pattern: "projects/{project}/snapshots/{snapshot}"
  1079. };
  1080. // The name of the snapshot.
  1081. string name = 1;
  1082. // The name of the topic from which this snapshot is retaining messages.
  1083. string topic = 2 [
  1084. (google.api.resource_reference) = { type: "pubsub.googleapis.com/Topic" }
  1085. ];
  1086. // The snapshot is guaranteed to exist up until this time.
  1087. // A newly-created snapshot expires no later than 7 days from the time of its
  1088. // creation. Its exact lifetime is determined at creation by the existing
  1089. // backlog in the source subscription. Specifically, the lifetime of the
  1090. // snapshot is `7 days - (age of oldest unacked message in the subscription)`.
  1091. // For example, consider a subscription whose oldest unacked message is 3 days
  1092. // old. If a snapshot is created from this subscription, the snapshot -- which
  1093. // will always capture this 3-day-old backlog as long as the snapshot
  1094. // exists -- will expire in 4 days. The service will refuse to create a
  1095. // snapshot that would expire in less than 1 hour after creation.
  1096. google.protobuf.Timestamp expire_time = 3;
  1097. // See [Creating and managing labels]
  1098. // (https://cloud.google.com/pubsub/docs/labels).
  1099. map<string, string> labels = 4;
  1100. }
  1101. // Request for the GetSnapshot method.
  1102. message GetSnapshotRequest {
  1103. // Required. The name of the snapshot to get.
  1104. // Format is `projects/{project}/snapshots/{snap}`.
  1105. string snapshot = 1 [
  1106. (google.api.field_behavior) = REQUIRED,
  1107. (google.api.resource_reference) = { type: "pubsub.googleapis.com/Snapshot" }
  1108. ];
  1109. }
  1110. // Request for the `ListSnapshots` method.
  1111. message ListSnapshotsRequest {
  1112. // Required. The name of the project in which to list snapshots.
  1113. // Format is `projects/{project-id}`.
  1114. string project = 1 [
  1115. (google.api.field_behavior) = REQUIRED,
  1116. (google.api.resource_reference) = {
  1117. type: "cloudresourcemanager.googleapis.com/Project"
  1118. }
  1119. ];
  1120. // Maximum number of snapshots to return.
  1121. int32 page_size = 2;
  1122. // The value returned by the last `ListSnapshotsResponse`; indicates that this
  1123. // is a continuation of a prior `ListSnapshots` call, and that the system
  1124. // should return the next page of data.
  1125. string page_token = 3;
  1126. }
  1127. // Response for the `ListSnapshots` method.
  1128. message ListSnapshotsResponse {
  1129. // The resulting snapshots.
  1130. repeated Snapshot snapshots = 1;
  1131. // If not empty, indicates that there may be more snapshot that match the
  1132. // request; this value should be passed in a new `ListSnapshotsRequest`.
  1133. string next_page_token = 2;
  1134. }
  1135. // Request for the `DeleteSnapshot` method.
  1136. message DeleteSnapshotRequest {
  1137. // Required. The name of the snapshot to delete.
  1138. // Format is `projects/{project}/snapshots/{snap}`.
  1139. string snapshot = 1 [
  1140. (google.api.field_behavior) = REQUIRED,
  1141. (google.api.resource_reference) = { type: "pubsub.googleapis.com/Snapshot" }
  1142. ];
  1143. }
  1144. // Request for the `Seek` method.
  1145. message SeekRequest {
  1146. // Required. The subscription to affect.
  1147. string subscription = 1 [
  1148. (google.api.field_behavior) = REQUIRED,
  1149. (google.api.resource_reference) = {
  1150. type: "pubsub.googleapis.com/Subscription"
  1151. }
  1152. ];
  1153. oneof target {
  1154. // The time to seek to.
  1155. // Messages retained in the subscription that were published before this
  1156. // time are marked as acknowledged, and messages retained in the
  1157. // subscription that were published after this time are marked as
  1158. // unacknowledged. Note that this operation affects only those messages
  1159. // retained in the subscription (configured by the combination of
  1160. // `message_retention_duration` and `retain_acked_messages`). For example,
  1161. // if `time` corresponds to a point before the message retention
  1162. // window (or to a point before the system's notion of the subscription
  1163. // creation time), only retained messages will be marked as unacknowledged,
  1164. // and already-expunged messages will not be restored.
  1165. google.protobuf.Timestamp time = 2;
  1166. // The snapshot to seek to. The snapshot's topic must be the same as that of
  1167. // the provided subscription.
  1168. // Format is `projects/{project}/snapshots/{snap}`.
  1169. string snapshot = 3 [(google.api.resource_reference) = {
  1170. type: "pubsub.googleapis.com/Snapshot"
  1171. }];
  1172. }
  1173. }
  1174. // Response for the `Seek` method (this response is empty).
  1175. message SeekResponse {}