pubsub.proto 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. // Copyright (c) 2015, Google Inc.
  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/protobuf/empty.proto";
  18. import "google/protobuf/timestamp.proto";
  19. option java_multiple_files = true;
  20. option java_outer_classname = "PubsubProto";
  21. option java_package = "com.google.pubsub.v1";
  22. option go_package = "google.golang.org/genproto/googleapis/pubsub/v1";
  23. // The service that an application uses to manipulate subscriptions and to
  24. // consume messages from a subscription via the `Pull` method.
  25. service Subscriber {
  26. // Creates a subscription to a given topic for a given subscriber.
  27. // If the subscription already exists, returns `ALREADY_EXISTS`.
  28. // If the corresponding topic doesn't exist, returns `NOT_FOUND`.
  29. //
  30. // If the name is not provided in the request, the server will assign a random
  31. // name for this subscription on the same project as the topic.
  32. rpc CreateSubscription(Subscription) returns (Subscription) {
  33. option (google.api.http) = { put: "/v1/{name=projects/*/subscriptions/*}" body: "*" };
  34. }
  35. // Gets the configuration details of a subscription.
  36. rpc GetSubscription(GetSubscriptionRequest) returns (Subscription) {
  37. option (google.api.http) = { get: "/v1/{subscription=projects/*/subscriptions/*}" };
  38. }
  39. // Lists matching subscriptions.
  40. rpc ListSubscriptions(ListSubscriptionsRequest) returns (ListSubscriptionsResponse) {
  41. option (google.api.http) = { get: "/v1/{project=projects/*}/subscriptions" };
  42. }
  43. // Deletes an existing subscription. All pending messages in the subscription
  44. // are immediately dropped. Calls to `Pull` after deletion will return
  45. // `NOT_FOUND`. After a subscription is deleted, a new one may be created with
  46. // the same name, but the new one has no association with the old
  47. // subscription, or its topic unless the same topic is specified.
  48. rpc DeleteSubscription(DeleteSubscriptionRequest) returns (google.protobuf.Empty) {
  49. option (google.api.http) = { delete: "/v1/{subscription=projects/*/subscriptions/*}" };
  50. }
  51. // Modifies the ack deadline for a specific message. This method is useful
  52. // to indicate that more time is needed to process a message by the
  53. // subscriber, or to make the message available for redelivery if the
  54. // processing was interrupted.
  55. rpc ModifyAckDeadline(ModifyAckDeadlineRequest) returns (google.protobuf.Empty) {
  56. option (google.api.http) = { post: "/v1/{subscription=projects/*/subscriptions/*}:modifyAckDeadline" body: "*" };
  57. }
  58. // Acknowledges the messages associated with the `ack_ids` in the
  59. // `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages
  60. // from the subscription.
  61. //
  62. // Acknowledging a message whose ack deadline has expired may succeed,
  63. // but such a message may be redelivered later. Acknowledging a message more
  64. // than once will not result in an error.
  65. rpc Acknowledge(AcknowledgeRequest) returns (google.protobuf.Empty) {
  66. option (google.api.http) = { post: "/v1/{subscription=projects/*/subscriptions/*}:acknowledge" body: "*" };
  67. }
  68. // Pulls messages from the server. Returns an empty list if there are no
  69. // messages available in the backlog. The server may return `UNAVAILABLE` if
  70. // there are too many concurrent pull requests pending for the given
  71. // subscription.
  72. rpc Pull(PullRequest) returns (PullResponse) {
  73. option (google.api.http) = { post: "/v1/{subscription=projects/*/subscriptions/*}:pull" body: "*" };
  74. }
  75. // Modifies the `PushConfig` for a specified subscription.
  76. //
  77. // This may be used to change a push subscription to a pull one (signified by
  78. // an empty `PushConfig`) or vice versa, or change the endpoint URL and other
  79. // attributes of a push subscription. Messages will accumulate for delivery
  80. // continuously through the call regardless of changes to the `PushConfig`.
  81. rpc ModifyPushConfig(ModifyPushConfigRequest) returns (google.protobuf.Empty) {
  82. option (google.api.http) = { post: "/v1/{subscription=projects/*/subscriptions/*}:modifyPushConfig" body: "*" };
  83. }
  84. }
  85. // The service that an application uses to manipulate topics, and to send
  86. // messages to a topic.
  87. service Publisher {
  88. // Creates the given topic with the given name.
  89. rpc CreateTopic(Topic) returns (Topic) {
  90. option (google.api.http) = { put: "/v1/{name=projects/*/topics/*}" body: "*" };
  91. }
  92. // Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic
  93. // does not exist. The message payload must not be empty; it must contain
  94. // either a non-empty data field, or at least one attribute.
  95. rpc Publish(PublishRequest) returns (PublishResponse) {
  96. option (google.api.http) = { post: "/v1/{topic=projects/*/topics/*}:publish" body: "*" };
  97. }
  98. // Gets the configuration of a topic.
  99. rpc GetTopic(GetTopicRequest) returns (Topic) {
  100. option (google.api.http) = { get: "/v1/{topic=projects/*/topics/*}" };
  101. }
  102. // Lists matching topics.
  103. rpc ListTopics(ListTopicsRequest) returns (ListTopicsResponse) {
  104. option (google.api.http) = { get: "/v1/{project=projects/*}/topics" };
  105. }
  106. // Lists the name of the subscriptions for this topic.
  107. rpc ListTopicSubscriptions(ListTopicSubscriptionsRequest) returns (ListTopicSubscriptionsResponse) {
  108. option (google.api.http) = { get: "/v1/{topic=projects/*/topics/*}/subscriptions" };
  109. }
  110. // Deletes the topic with the given name. Returns `NOT_FOUND` if the topic
  111. // does not exist. After a topic is deleted, a new topic may be created with
  112. // the same name; this is an entirely new topic with none of the old
  113. // configuration or subscriptions. Existing subscriptions to this topic are
  114. // not deleted, but their `topic` field is set to `_deleted-topic_`.
  115. rpc DeleteTopic(DeleteTopicRequest) returns (google.protobuf.Empty) {
  116. option (google.api.http) = { delete: "/v1/{topic=projects/*/topics/*}" };
  117. }
  118. }
  119. // A topic resource.
  120. message Topic {
  121. // The name of the topic. It must have the format
  122. // `"projects/{project}/topics/{topic}"`. `{topic}` must start with a letter,
  123. // and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),
  124. // underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent
  125. // signs (`%`). It must be between 3 and 255 characters in length, and it
  126. // must not start with `"goog"`.
  127. string name = 1;
  128. }
  129. // A message data and its attributes. The message payload must not be empty;
  130. // it must contain either a non-empty data field, or at least one attribute.
  131. message PubsubMessage {
  132. // The message payload. For JSON requests, the value of this field must be
  133. // base64-encoded.
  134. bytes data = 1;
  135. // Optional attributes for this message.
  136. map<string, string> attributes = 2;
  137. // ID of this message, assigned by the server when the message is published.
  138. // Guaranteed to be unique within the topic. This value may be read by a
  139. // subscriber that receives a `PubsubMessage` via a `Pull` call or a push
  140. // delivery. It must not be populated by the publisher in a `Publish` call.
  141. string message_id = 3;
  142. // The time at which the message was published, populated by the server when
  143. // it receives the `Publish` call. It must not be populated by the
  144. // publisher in a `Publish` call.
  145. google.protobuf.Timestamp publish_time = 4;
  146. }
  147. // Request for the GetTopic method.
  148. message GetTopicRequest {
  149. // The name of the topic to get.
  150. string topic = 1;
  151. }
  152. // Request for the Publish method.
  153. message PublishRequest {
  154. // The messages in the request will be published on this topic.
  155. string topic = 1;
  156. // The messages to publish.
  157. repeated PubsubMessage messages = 2;
  158. }
  159. // Response for the `Publish` method.
  160. message PublishResponse {
  161. // The server-assigned ID of each published message, in the same order as
  162. // the messages in the request. IDs are guaranteed to be unique within
  163. // the topic.
  164. repeated string message_ids = 1;
  165. }
  166. // Request for the `ListTopics` method.
  167. message ListTopicsRequest {
  168. // The name of the cloud project that topics belong to.
  169. string project = 1;
  170. // Maximum number of topics to return.
  171. int32 page_size = 2;
  172. // The value returned by the last `ListTopicsResponse`; indicates that this is
  173. // a continuation of a prior `ListTopics` call, and that the system should
  174. // return the next page of data.
  175. string page_token = 3;
  176. }
  177. // Response for the `ListTopics` method.
  178. message ListTopicsResponse {
  179. // The resulting topics.
  180. repeated Topic topics = 1;
  181. // If not empty, indicates that there may be more topics that match the
  182. // request; this value should be passed in a new `ListTopicsRequest`.
  183. string next_page_token = 2;
  184. }
  185. // Request for the `ListTopicSubscriptions` method.
  186. message ListTopicSubscriptionsRequest {
  187. // The name of the topic that subscriptions are attached to.
  188. string topic = 1;
  189. // Maximum number of subscription names to return.
  190. int32 page_size = 2;
  191. // The value returned by the last `ListTopicSubscriptionsResponse`; indicates
  192. // that this is a continuation of a prior `ListTopicSubscriptions` call, and
  193. // that the system should return the next page of data.
  194. string page_token = 3;
  195. }
  196. // Response for the `ListTopicSubscriptions` method.
  197. message ListTopicSubscriptionsResponse {
  198. // The names of the subscriptions that match the request.
  199. repeated string subscriptions = 1;
  200. // If not empty, indicates that there may be more subscriptions that match
  201. // the request; this value should be passed in a new
  202. // `ListTopicSubscriptionsRequest` to get more subscriptions.
  203. string next_page_token = 2;
  204. }
  205. // Request for the `DeleteTopic` method.
  206. message DeleteTopicRequest {
  207. // Name of the topic to delete.
  208. string topic = 1;
  209. }
  210. // A subscription resource.
  211. message Subscription {
  212. // The name of the subscription. It must have the format
  213. // `"projects/{project}/subscriptions/{subscription}"`. `{subscription}` must
  214. // start with a letter, and contain only letters (`[A-Za-z]`), numbers
  215. // (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),
  216. // plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters
  217. // in length, and it must not start with `"goog"`.
  218. string name = 1;
  219. // The name of the topic from which this subscription is receiving messages.
  220. // The value of this field will be `_deleted-topic_` if the topic has been
  221. // deleted.
  222. string topic = 2;
  223. // If push delivery is used with this subscription, this field is
  224. // used to configure it. An empty `pushConfig` signifies that the subscriber
  225. // will pull and ack messages using API methods.
  226. PushConfig push_config = 4;
  227. // This value is the maximum time after a subscriber receives a message
  228. // before the subscriber should acknowledge the message. After message
  229. // delivery but before the ack deadline expires and before the message is
  230. // acknowledged, it is an outstanding message and will not be delivered
  231. // again during that time (on a best-effort basis).
  232. //
  233. // For pull subscriptions, this value is used as the initial value for the ack
  234. // deadline. To override this value for a given message, call
  235. // `ModifyAckDeadline` with the corresponding `ack_id` if using
  236. // pull.
  237. //
  238. // For push delivery, this value is also used to set the request timeout for
  239. // the call to the push endpoint.
  240. //
  241. // If the subscriber never acknowledges the message, the Pub/Sub
  242. // system will eventually redeliver the message.
  243. //
  244. // If this parameter is not set, the default value of 10 seconds is used.
  245. int32 ack_deadline_seconds = 5;
  246. }
  247. // Configuration for a push delivery endpoint.
  248. message PushConfig {
  249. // A URL locating the endpoint to which messages should be pushed.
  250. // For example, a Webhook endpoint might use "https://example.com/push".
  251. string push_endpoint = 1;
  252. // Endpoint configuration attributes.
  253. //
  254. // Every endpoint has a set of API supported attributes that can be used to
  255. // control different aspects of the message delivery.
  256. //
  257. // The currently supported attribute is `x-goog-version`, which you can
  258. // use to change the format of the push message. This attribute
  259. // indicates the version of the data expected by the endpoint. This
  260. // controls the shape of the envelope (i.e. its fields and metadata).
  261. // The endpoint version is based on the version of the Pub/Sub
  262. // API.
  263. //
  264. // If not present during the `CreateSubscription` call, it will default to
  265. // the version of the API used to make such call. If not present during a
  266. // `ModifyPushConfig` call, its value will not be changed. `GetSubscription`
  267. // calls will always return a valid version, even if the subscription was
  268. // created without this attribute.
  269. //
  270. // The possible values for this attribute are:
  271. //
  272. // * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub API.
  273. // * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub API.
  274. map<string, string> attributes = 2;
  275. }
  276. // A message and its corresponding acknowledgment ID.
  277. message ReceivedMessage {
  278. // This ID can be used to acknowledge the received message.
  279. string ack_id = 1;
  280. // The message.
  281. PubsubMessage message = 2;
  282. }
  283. // Request for the GetSubscription method.
  284. message GetSubscriptionRequest {
  285. // The name of the subscription to get.
  286. string subscription = 1;
  287. }
  288. // Request for the `ListSubscriptions` method.
  289. message ListSubscriptionsRequest {
  290. // The name of the cloud project that subscriptions belong to.
  291. string project = 1;
  292. // Maximum number of subscriptions to return.
  293. int32 page_size = 2;
  294. // The value returned by the last `ListSubscriptionsResponse`; indicates that
  295. // this is a continuation of a prior `ListSubscriptions` call, and that the
  296. // system should return the next page of data.
  297. string page_token = 3;
  298. }
  299. // Response for the `ListSubscriptions` method.
  300. message ListSubscriptionsResponse {
  301. // The subscriptions that match the request.
  302. repeated Subscription subscriptions = 1;
  303. // If not empty, indicates that there may be more subscriptions that match
  304. // the request; this value should be passed in a new
  305. // `ListSubscriptionsRequest` to get more subscriptions.
  306. string next_page_token = 2;
  307. }
  308. // Request for the DeleteSubscription method.
  309. message DeleteSubscriptionRequest {
  310. // The subscription to delete.
  311. string subscription = 1;
  312. }
  313. // Request for the ModifyPushConfig method.
  314. message ModifyPushConfigRequest {
  315. // The name of the subscription.
  316. string subscription = 1;
  317. // The push configuration for future deliveries.
  318. //
  319. // An empty `pushConfig` indicates that the Pub/Sub system should
  320. // stop pushing messages from the given subscription and allow
  321. // messages to be pulled and acknowledged - effectively pausing
  322. // the subscription if `Pull` is not called.
  323. PushConfig push_config = 2;
  324. }
  325. // Request for the `Pull` method.
  326. message PullRequest {
  327. // The subscription from which messages should be pulled.
  328. string subscription = 1;
  329. // If this is specified as true the system will respond immediately even if
  330. // it is not able to return a message in the `Pull` response. Otherwise the
  331. // system is allowed to wait until at least one message is available rather
  332. // than returning no messages. The client may cancel the request if it does
  333. // not wish to wait any longer for the response.
  334. bool return_immediately = 2;
  335. // The maximum number of messages returned for this request. The Pub/Sub
  336. // system may return fewer than the number specified.
  337. int32 max_messages = 3;
  338. }
  339. // Response for the `Pull` method.
  340. message PullResponse {
  341. // Received Pub/Sub messages. The Pub/Sub system will return zero messages if
  342. // there are no more available in the backlog. The Pub/Sub system may return
  343. // fewer than the `maxMessages` requested even if there are more messages
  344. // available in the backlog.
  345. repeated ReceivedMessage received_messages = 1;
  346. }
  347. // Request for the ModifyAckDeadline method.
  348. message ModifyAckDeadlineRequest {
  349. // The name of the subscription.
  350. string subscription = 1;
  351. // List of acknowledgment IDs.
  352. repeated string ack_ids = 4;
  353. // The new ack deadline with respect to the time this request was sent to
  354. // the Pub/Sub system. Must be >= 0. For example, if the value is 10, the new
  355. // ack deadline will expire 10 seconds after the `ModifyAckDeadline` call
  356. // was made. Specifying zero may immediately make the message available for
  357. // another pull request.
  358. int32 ack_deadline_seconds = 3;
  359. }
  360. // Request for the Acknowledge method.
  361. message AcknowledgeRequest {
  362. // The subscription whose message is being acknowledged.
  363. string subscription = 1;
  364. // The acknowledgment ID for the messages being acknowledged that was returned
  365. // by the Pub/Sub system in the `Pull` response. Must not be empty.
  366. repeated string ack_ids = 2;
  367. }