pubsub.proto 14 KB

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