pubsub.proto 14 KB

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