You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

2905 lines
98 KiB

  1. // Package pubsub provides access to the Cloud Pub/Sub API.
  2. //
  3. // See https://cloud.google.com/pubsub/docs
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/pubsub/v1beta1a"
  8. // ...
  9. // pubsubService, err := pubsub.New(oauthHttpClient)
  10. package pubsub // import "google.golang.org/api/pubsub/v1beta1a"
  11. import (
  12. "bytes"
  13. "encoding/json"
  14. "errors"
  15. "fmt"
  16. context "golang.org/x/net/context"
  17. ctxhttp "golang.org/x/net/context/ctxhttp"
  18. gensupport "google.golang.org/api/gensupport"
  19. googleapi "google.golang.org/api/googleapi"
  20. "io"
  21. "net/http"
  22. "net/url"
  23. "strconv"
  24. "strings"
  25. )
  26. // Always reference these packages, just in case the auto-generated code
  27. // below doesn't.
  28. var _ = bytes.NewBuffer
  29. var _ = strconv.Itoa
  30. var _ = fmt.Sprintf
  31. var _ = json.NewDecoder
  32. var _ = io.Copy
  33. var _ = url.Parse
  34. var _ = gensupport.MarshalJSON
  35. var _ = googleapi.Version
  36. var _ = errors.New
  37. var _ = strings.Replace
  38. var _ = context.Canceled
  39. var _ = ctxhttp.Do
  40. const apiId = "pubsub:v1beta1a"
  41. const apiName = "pubsub"
  42. const apiVersion = "v1beta1a"
  43. const basePath = "https://pubsub.googleapis.com/"
  44. // OAuth2 scopes used by this API.
  45. const (
  46. // View and manage your data across Google Cloud Platform services
  47. CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
  48. // View and manage Pub/Sub topics and subscriptions
  49. PubsubScope = "https://www.googleapis.com/auth/pubsub"
  50. )
  51. func New(client *http.Client) (*Service, error) {
  52. if client == nil {
  53. return nil, errors.New("client is nil")
  54. }
  55. s := &Service{client: client, BasePath: basePath}
  56. s.Subscriptions = NewSubscriptionsService(s)
  57. s.Topics = NewTopicsService(s)
  58. return s, nil
  59. }
  60. type Service struct {
  61. client *http.Client
  62. BasePath string // API endpoint base URL
  63. UserAgent string // optional additional User-Agent fragment
  64. Subscriptions *SubscriptionsService
  65. Topics *TopicsService
  66. }
  67. func (s *Service) userAgent() string {
  68. if s.UserAgent == "" {
  69. return googleapi.UserAgent
  70. }
  71. return googleapi.UserAgent + " " + s.UserAgent
  72. }
  73. func NewSubscriptionsService(s *Service) *SubscriptionsService {
  74. rs := &SubscriptionsService{s: s}
  75. return rs
  76. }
  77. type SubscriptionsService struct {
  78. s *Service
  79. }
  80. func NewTopicsService(s *Service) *TopicsService {
  81. rs := &TopicsService{s: s}
  82. return rs
  83. }
  84. type TopicsService struct {
  85. s *Service
  86. }
  87. // AcknowledgeRequest: Request for the Acknowledge method.
  88. type AcknowledgeRequest struct {
  89. // AckId: The acknowledgment ID for the message being acknowledged. This
  90. // was
  91. // returned by the Pub/Sub system in the Pull response.
  92. AckId []string `json:"ackId,omitempty"`
  93. // Subscription: The subscription whose message is being acknowledged.
  94. Subscription string `json:"subscription,omitempty"`
  95. // ForceSendFields is a list of field names (e.g. "AckId") to
  96. // unconditionally include in API requests. By default, fields with
  97. // empty values are omitted from API requests. However, any non-pointer,
  98. // non-interface field appearing in ForceSendFields will be sent to the
  99. // server regardless of whether the field is empty or not. This may be
  100. // used to include empty fields in Patch requests.
  101. ForceSendFields []string `json:"-"`
  102. // NullFields is a list of field names (e.g. "AckId") to include in API
  103. // requests with the JSON null value. By default, fields with empty
  104. // values are omitted from API requests. However, any field with an
  105. // empty value appearing in NullFields will be sent to the server as
  106. // null. It is an error if a field in this list has a non-empty value.
  107. // This may be used to include null fields in Patch requests.
  108. NullFields []string `json:"-"`
  109. }
  110. func (s *AcknowledgeRequest) MarshalJSON() ([]byte, error) {
  111. type NoMethod AcknowledgeRequest
  112. raw := NoMethod(*s)
  113. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  114. }
  115. // Empty: An empty message that you can re-use to avoid defining
  116. // duplicated empty
  117. // messages in your project. A typical example is to use it as argument
  118. // or the
  119. // return value of a service API. For instance:
  120. //
  121. // service Foo {
  122. // rpc Bar (proto2.Empty) returns (proto2.Empty) { };
  123. // };
  124. //
  125. // BEGIN GOOGLE-INTERNAL
  126. // The difference between this one and net/rpc/empty-message.proto is
  127. // that
  128. // 1) The generated message here is in proto2 C++ API.
  129. // 2) The proto2.Empty has minimum dependencies
  130. // (no message_set or net/rpc dependencies)
  131. // END GOOGLE-INTERNAL
  132. type Empty struct {
  133. // ServerResponse contains the HTTP response code and headers from the
  134. // server.
  135. googleapi.ServerResponse `json:"-"`
  136. }
  137. // Label: A key-value pair applied to a given object.
  138. type Label struct {
  139. // Key: The key of a label is a syntactically valid URL (as per RFC
  140. // 1738) with
  141. // the "scheme" and initial slashes omitted and with the
  142. // additional
  143. // restrictions noted below. Each key should be globally unique.
  144. // The
  145. // "host" portion is called the "namespace" and is not
  146. // necessarily
  147. // resolvable to a network endpoint. Instead, the namespace indicates
  148. // what
  149. // system or entity defines the semantics of the label. Namespaces do
  150. // not
  151. // restrict the set of objects to which a label may be associated.
  152. //
  153. // Keys are defined by the following grammar:
  154. //
  155. // key = hostname "/" kpath
  156. // kpath = ksegment *[ "/" ksegment ]
  157. // ksegment = alphadigit | *[ alphadigit | "-" | "_" | "."
  158. // ]
  159. //
  160. // where "hostname" and "alphadigit" are defined as in RFC
  161. // 1738.
  162. //
  163. // Example key:
  164. // spanner.google.com/universe
  165. Key string `json:"key,omitempty"`
  166. // NumValue: An integer value.
  167. NumValue int64 `json:"numValue,omitempty,string"`
  168. // StrValue: A string value.
  169. StrValue string `json:"strValue,omitempty"`
  170. // ForceSendFields is a list of field names (e.g. "Key") to
  171. // unconditionally include in API requests. By default, fields with
  172. // empty values are omitted from API requests. However, any non-pointer,
  173. // non-interface field appearing in ForceSendFields will be sent to the
  174. // server regardless of whether the field is empty or not. This may be
  175. // used to include empty fields in Patch requests.
  176. ForceSendFields []string `json:"-"`
  177. // NullFields is a list of field names (e.g. "Key") to include in API
  178. // requests with the JSON null value. By default, fields with empty
  179. // values are omitted from API requests. However, any field with an
  180. // empty value appearing in NullFields will be sent to the server as
  181. // null. It is an error if a field in this list has a non-empty value.
  182. // This may be used to include null fields in Patch requests.
  183. NullFields []string `json:"-"`
  184. }
  185. func (s *Label) MarshalJSON() ([]byte, error) {
  186. type NoMethod Label
  187. raw := NoMethod(*s)
  188. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  189. }
  190. // ListSubscriptionsResponse: Response for the ListSubscriptions method.
  191. type ListSubscriptionsResponse struct {
  192. // NextPageToken: If not empty, indicates that there are more
  193. // subscriptions that match the
  194. // request and this value should be passed to the
  195. // next
  196. // <code>ListSubscriptionsRequest</code> to continue.
  197. NextPageToken string `json:"nextPageToken,omitempty"`
  198. // Subscription: The subscriptions that match the request.
  199. Subscription []*Subscription `json:"subscription,omitempty"`
  200. // ServerResponse contains the HTTP response code and headers from the
  201. // server.
  202. googleapi.ServerResponse `json:"-"`
  203. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  204. // unconditionally include in API requests. By default, fields with
  205. // empty values are omitted from API requests. However, any non-pointer,
  206. // non-interface field appearing in ForceSendFields will be sent to the
  207. // server regardless of whether the field is empty or not. This may be
  208. // used to include empty fields in Patch requests.
  209. ForceSendFields []string `json:"-"`
  210. // NullFields is a list of field names (e.g. "NextPageToken") to include
  211. // in API requests with the JSON null value. By default, fields with
  212. // empty values are omitted from API requests. However, any field with
  213. // an empty value appearing in NullFields will be sent to the server as
  214. // null. It is an error if a field in this list has a non-empty value.
  215. // This may be used to include null fields in Patch requests.
  216. NullFields []string `json:"-"`
  217. }
  218. func (s *ListSubscriptionsResponse) MarshalJSON() ([]byte, error) {
  219. type NoMethod ListSubscriptionsResponse
  220. raw := NoMethod(*s)
  221. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  222. }
  223. // ListTopicsResponse: Response for the ListTopics method.
  224. type ListTopicsResponse struct {
  225. // NextPageToken: If not empty, indicates that there are more topics
  226. // that match the request,
  227. // and this value should be passed to the next
  228. // <code>ListTopicsRequest</code>
  229. // to continue.
  230. NextPageToken string `json:"nextPageToken,omitempty"`
  231. // Topic: The resulting topics.
  232. Topic []*Topic `json:"topic,omitempty"`
  233. // ServerResponse contains the HTTP response code and headers from the
  234. // server.
  235. googleapi.ServerResponse `json:"-"`
  236. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  237. // unconditionally include in API requests. By default, fields with
  238. // empty values are omitted from API requests. However, any non-pointer,
  239. // non-interface field appearing in ForceSendFields will be sent to the
  240. // server regardless of whether the field is empty or not. This may be
  241. // used to include empty fields in Patch requests.
  242. ForceSendFields []string `json:"-"`
  243. // NullFields is a list of field names (e.g. "NextPageToken") to include
  244. // in API requests with the JSON null value. By default, fields with
  245. // empty values are omitted from API requests. However, any field with
  246. // an empty value appearing in NullFields will be sent to the server as
  247. // null. It is an error if a field in this list has a non-empty value.
  248. // This may be used to include null fields in Patch requests.
  249. NullFields []string `json:"-"`
  250. }
  251. func (s *ListTopicsResponse) MarshalJSON() ([]byte, error) {
  252. type NoMethod ListTopicsResponse
  253. raw := NoMethod(*s)
  254. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  255. }
  256. // ModifyAckDeadlineRequest: Request for the ModifyAckDeadline method.
  257. type ModifyAckDeadlineRequest struct {
  258. // AckDeadlineSeconds: The new ack deadline with respect to the time
  259. // this request was sent to the
  260. // Pub/Sub system. Must be >= 0. For example, if the value is 10, the
  261. // new ack
  262. // deadline will expire 10 seconds after the ModifyAckDeadline call was
  263. // made.
  264. // Specifying zero may immediately make the message available for
  265. // another pull
  266. // request.
  267. AckDeadlineSeconds int64 `json:"ackDeadlineSeconds,omitempty"`
  268. // AckId: The acknowledgment ID. Either this or ack_ids must be
  269. // populated,
  270. // not both.
  271. AckId string `json:"ackId,omitempty"`
  272. // AckIds: List of acknowledgment IDs. Either this field or
  273. // ack_id
  274. // should be populated, not both.
  275. AckIds []string `json:"ackIds,omitempty"`
  276. // Subscription: Next Index: 5
  277. // The name of the subscription from which messages are being pulled.
  278. Subscription string `json:"subscription,omitempty"`
  279. // ForceSendFields is a list of field names (e.g. "AckDeadlineSeconds")
  280. // to unconditionally include in API requests. By default, fields with
  281. // empty values are omitted from API requests. However, any non-pointer,
  282. // non-interface field appearing in ForceSendFields will be sent to the
  283. // server regardless of whether the field is empty or not. This may be
  284. // used to include empty fields in Patch requests.
  285. ForceSendFields []string `json:"-"`
  286. // NullFields is a list of field names (e.g. "AckDeadlineSeconds") to
  287. // include in API requests with the JSON null value. By default, fields
  288. // with empty values are omitted from API requests. However, any field
  289. // with an empty value appearing in NullFields will be sent to the
  290. // server as null. It is an error if a field in this list has a
  291. // non-empty value. This may be used to include null fields in Patch
  292. // requests.
  293. NullFields []string `json:"-"`
  294. }
  295. func (s *ModifyAckDeadlineRequest) MarshalJSON() ([]byte, error) {
  296. type NoMethod ModifyAckDeadlineRequest
  297. raw := NoMethod(*s)
  298. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  299. }
  300. // ModifyPushConfigRequest: Request for the ModifyPushConfig method.
  301. type ModifyPushConfigRequest struct {
  302. // PushConfig: An empty <code>push_config</code> indicates that the
  303. // Pub/Sub system should
  304. // pause pushing messages from the given subscription.
  305. PushConfig *PushConfig `json:"pushConfig,omitempty"`
  306. // Subscription: The name of the subscription.
  307. Subscription string `json:"subscription,omitempty"`
  308. // ForceSendFields is a list of field names (e.g. "PushConfig") to
  309. // unconditionally include in API requests. By default, fields with
  310. // empty values are omitted from API requests. However, any non-pointer,
  311. // non-interface field appearing in ForceSendFields will be sent to the
  312. // server regardless of whether the field is empty or not. This may be
  313. // used to include empty fields in Patch requests.
  314. ForceSendFields []string `json:"-"`
  315. // NullFields is a list of field names (e.g. "PushConfig") to include in
  316. // API requests with the JSON null value. By default, fields with empty
  317. // values are omitted from API requests. However, any field with an
  318. // empty value appearing in NullFields will be sent to the server as
  319. // null. It is an error if a field in this list has a non-empty value.
  320. // This may be used to include null fields in Patch requests.
  321. NullFields []string `json:"-"`
  322. }
  323. func (s *ModifyPushConfigRequest) MarshalJSON() ([]byte, error) {
  324. type NoMethod ModifyPushConfigRequest
  325. raw := NoMethod(*s)
  326. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  327. }
  328. // PublishBatchRequest: Request for the PublishBatch method.
  329. type PublishBatchRequest struct {
  330. // Messages: The messages to publish.
  331. Messages []*PubsubMessage `json:"messages,omitempty"`
  332. // Topic: The messages in the request will be published on this topic.
  333. Topic string `json:"topic,omitempty"`
  334. // ForceSendFields is a list of field names (e.g. "Messages") to
  335. // unconditionally include in API requests. By default, fields with
  336. // empty values are omitted from API requests. However, any non-pointer,
  337. // non-interface field appearing in ForceSendFields will be sent to the
  338. // server regardless of whether the field is empty or not. This may be
  339. // used to include empty fields in Patch requests.
  340. ForceSendFields []string `json:"-"`
  341. // NullFields is a list of field names (e.g. "Messages") to include in
  342. // API requests with the JSON null value. By default, fields with empty
  343. // values are omitted from API requests. However, any field with an
  344. // empty value appearing in NullFields will be sent to the server as
  345. // null. It is an error if a field in this list has a non-empty value.
  346. // This may be used to include null fields in Patch requests.
  347. NullFields []string `json:"-"`
  348. }
  349. func (s *PublishBatchRequest) MarshalJSON() ([]byte, error) {
  350. type NoMethod PublishBatchRequest
  351. raw := NoMethod(*s)
  352. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  353. }
  354. // PublishBatchResponse: Response for the PublishBatch method.
  355. type PublishBatchResponse struct {
  356. // MessageIds: The server-assigned ID of each published message, in the
  357. // same order as
  358. // the messages in the request. IDs are guaranteed to be unique
  359. // within
  360. // the topic.
  361. MessageIds []string `json:"messageIds,omitempty"`
  362. // ServerResponse contains the HTTP response code and headers from the
  363. // server.
  364. googleapi.ServerResponse `json:"-"`
  365. // ForceSendFields is a list of field names (e.g. "MessageIds") to
  366. // unconditionally include in API requests. By default, fields with
  367. // empty values are omitted from API requests. However, any non-pointer,
  368. // non-interface field appearing in ForceSendFields will be sent to the
  369. // server regardless of whether the field is empty or not. This may be
  370. // used to include empty fields in Patch requests.
  371. ForceSendFields []string `json:"-"`
  372. // NullFields is a list of field names (e.g. "MessageIds") to include in
  373. // API requests with the JSON null value. By default, fields with empty
  374. // values are omitted from API requests. However, any field with an
  375. // empty value appearing in NullFields will be sent to the server as
  376. // null. It is an error if a field in this list has a non-empty value.
  377. // This may be used to include null fields in Patch requests.
  378. NullFields []string `json:"-"`
  379. }
  380. func (s *PublishBatchResponse) MarshalJSON() ([]byte, error) {
  381. type NoMethod PublishBatchResponse
  382. raw := NoMethod(*s)
  383. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  384. }
  385. // PublishRequest: Request for the Publish method.
  386. type PublishRequest struct {
  387. // Message: The message to publish.
  388. Message *PubsubMessage `json:"message,omitempty"`
  389. // Topic: The message in the request will be published on this topic.
  390. Topic string `json:"topic,omitempty"`
  391. // ForceSendFields is a list of field names (e.g. "Message") to
  392. // unconditionally include in API requests. By default, fields with
  393. // empty values are omitted from API requests. However, any non-pointer,
  394. // non-interface field appearing in ForceSendFields will be sent to the
  395. // server regardless of whether the field is empty or not. This may be
  396. // used to include empty fields in Patch requests.
  397. ForceSendFields []string `json:"-"`
  398. // NullFields is a list of field names (e.g. "Message") to include in
  399. // API requests with the JSON null value. By default, fields with empty
  400. // values are omitted from API requests. However, any field with an
  401. // empty value appearing in NullFields will be sent to the server as
  402. // null. It is an error if a field in this list has a non-empty value.
  403. // This may be used to include null fields in Patch requests.
  404. NullFields []string `json:"-"`
  405. }
  406. func (s *PublishRequest) MarshalJSON() ([]byte, error) {
  407. type NoMethod PublishRequest
  408. raw := NoMethod(*s)
  409. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  410. }
  411. // PubsubEvent: An event indicating a received message or truncation
  412. // event.
  413. type PubsubEvent struct {
  414. // Deleted: Indicates that this subscription has been deleted. (Note
  415. // that pull
  416. // subscribers will always receive NOT_FOUND in response in their
  417. // pull
  418. // request on the subscription, rather than seeing this boolean.)
  419. Deleted bool `json:"deleted,omitempty"`
  420. // Message: A received message.
  421. Message *PubsubMessage `json:"message,omitempty"`
  422. // Subscription: The subscription that received the event.
  423. Subscription string `json:"subscription,omitempty"`
  424. // Truncated: Indicates that this subscription has been truncated.
  425. Truncated bool `json:"truncated,omitempty"`
  426. // ForceSendFields is a list of field names (e.g. "Deleted") to
  427. // unconditionally include in API requests. By default, fields with
  428. // empty values are omitted from API requests. However, any non-pointer,
  429. // non-interface field appearing in ForceSendFields will be sent to the
  430. // server regardless of whether the field is empty or not. This may be
  431. // used to include empty fields in Patch requests.
  432. ForceSendFields []string `json:"-"`
  433. // NullFields is a list of field names (e.g. "Deleted") to include in
  434. // API requests with the JSON null value. By default, fields with empty
  435. // values are omitted from API requests. However, any field with an
  436. // empty value appearing in NullFields will be sent to the server as
  437. // null. It is an error if a field in this list has a non-empty value.
  438. // This may be used to include null fields in Patch requests.
  439. NullFields []string `json:"-"`
  440. }
  441. func (s *PubsubEvent) MarshalJSON() ([]byte, error) {
  442. type NoMethod PubsubEvent
  443. raw := NoMethod(*s)
  444. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  445. }
  446. // PubsubMessage: A message data and its labels.
  447. type PubsubMessage struct {
  448. // Data: The message payload.
  449. Data string `json:"data,omitempty"`
  450. // Label: Optional list of labels for this message. Keys in this
  451. // collection must
  452. // be unique.
  453. Label []*Label `json:"label,omitempty"`
  454. // MessageId: ID of this message assigned by the server at publication
  455. // time. Guaranteed
  456. // to be unique within the topic. This value may be read by a
  457. // subscriber
  458. // that receives a PubsubMessage via a Pull call or a push delivery. It
  459. // must
  460. // not be populated by a publisher in a Publish call.
  461. MessageId string `json:"messageId,omitempty"`
  462. // PublishTime: The time at which the message was published.
  463. // The time is milliseconds since the UNIX epoch.
  464. PublishTime int64 `json:"publishTime,omitempty,string"`
  465. // ForceSendFields is a list of field names (e.g. "Data") to
  466. // unconditionally include in API requests. By default, fields with
  467. // empty values are omitted from API requests. However, any non-pointer,
  468. // non-interface field appearing in ForceSendFields will be sent to the
  469. // server regardless of whether the field is empty or not. This may be
  470. // used to include empty fields in Patch requests.
  471. ForceSendFields []string `json:"-"`
  472. // NullFields is a list of field names (e.g. "Data") to include in API
  473. // requests with the JSON null value. By default, fields with empty
  474. // values are omitted from API requests. However, any field with an
  475. // empty value appearing in NullFields will be sent to the server as
  476. // null. It is an error if a field in this list has a non-empty value.
  477. // This may be used to include null fields in Patch requests.
  478. NullFields []string `json:"-"`
  479. }
  480. func (s *PubsubMessage) MarshalJSON() ([]byte, error) {
  481. type NoMethod PubsubMessage
  482. raw := NoMethod(*s)
  483. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  484. }
  485. // PullBatchRequest: Request for the PullBatch method.
  486. type PullBatchRequest struct {
  487. // MaxEvents: The maximum number of PubsubEvents returned for this
  488. // request. The Pub/Sub
  489. // system may return fewer than the number of events specified.
  490. MaxEvents int64 `json:"maxEvents,omitempty"`
  491. // ReturnImmediately: If this is specified as true the system will
  492. // respond immediately even if
  493. // it is not able to return a message in the Pull response. Otherwise
  494. // the
  495. // system is allowed to wait until at least one message is available
  496. // rather
  497. // than returning no messages. The client may cancel the request if it
  498. // does
  499. // not wish to wait any longer for the response.
  500. ReturnImmediately bool `json:"returnImmediately,omitempty"`
  501. // Subscription: The subscription from which messages should be pulled.
  502. Subscription string `json:"subscription,omitempty"`
  503. // ForceSendFields is a list of field names (e.g. "MaxEvents") to
  504. // unconditionally include in API requests. By default, fields with
  505. // empty values are omitted from API requests. However, any non-pointer,
  506. // non-interface field appearing in ForceSendFields will be sent to the
  507. // server regardless of whether the field is empty or not. This may be
  508. // used to include empty fields in Patch requests.
  509. ForceSendFields []string `json:"-"`
  510. // NullFields is a list of field names (e.g. "MaxEvents") to include in
  511. // API requests with the JSON null value. By default, fields with empty
  512. // values are omitted from API requests. However, any field with an
  513. // empty value appearing in NullFields will be sent to the server as
  514. // null. It is an error if a field in this list has a non-empty value.
  515. // This may be used to include null fields in Patch requests.
  516. NullFields []string `json:"-"`
  517. }
  518. func (s *PullBatchRequest) MarshalJSON() ([]byte, error) {
  519. type NoMethod PullBatchRequest
  520. raw := NoMethod(*s)
  521. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  522. }
  523. // PullBatchResponse: Response for the PullBatch method.
  524. type PullBatchResponse struct {
  525. // PullResponses: Received Pub/Sub messages or status events. The
  526. // Pub/Sub system will return
  527. // zero messages if there are no more messages available in the backlog.
  528. // The
  529. // Pub/Sub system may return fewer than the max_events requested even
  530. // if
  531. // there are more messages available in the backlog.
  532. PullResponses []*PullResponse `json:"pullResponses,omitempty"`
  533. // ServerResponse contains the HTTP response code and headers from the
  534. // server.
  535. googleapi.ServerResponse `json:"-"`
  536. // ForceSendFields is a list of field names (e.g. "PullResponses") to
  537. // unconditionally include in API requests. By default, fields with
  538. // empty values are omitted from API requests. However, any non-pointer,
  539. // non-interface field appearing in ForceSendFields will be sent to the
  540. // server regardless of whether the field is empty or not. This may be
  541. // used to include empty fields in Patch requests.
  542. ForceSendFields []string `json:"-"`
  543. // NullFields is a list of field names (e.g. "PullResponses") to include
  544. // in API requests with the JSON null value. By default, fields with
  545. // empty values are omitted from API requests. However, any field with
  546. // an empty value appearing in NullFields will be sent to the server as
  547. // null. It is an error if a field in this list has a non-empty value.
  548. // This may be used to include null fields in Patch requests.
  549. NullFields []string `json:"-"`
  550. }
  551. func (s *PullBatchResponse) MarshalJSON() ([]byte, error) {
  552. type NoMethod PullBatchResponse
  553. raw := NoMethod(*s)
  554. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  555. }
  556. // PullRequest: Request for the Pull method.
  557. type PullRequest struct {
  558. // ReturnImmediately: If this is specified as true the system will
  559. // respond immediately even if
  560. // it is not able to return a message in the Pull response. Otherwise
  561. // the
  562. // system is allowed to wait until at least one message is available
  563. // rather
  564. // than returning FAILED_PRECONDITION. The client may cancel the request
  565. // if
  566. // it does not wish to wait any longer for the response.
  567. ReturnImmediately bool `json:"returnImmediately,omitempty"`
  568. // Subscription: The subscription from which a message should be pulled.
  569. Subscription string `json:"subscription,omitempty"`
  570. // ForceSendFields is a list of field names (e.g. "ReturnImmediately")
  571. // to unconditionally include in API requests. By default, fields with
  572. // empty values are omitted from API requests. However, any non-pointer,
  573. // non-interface field appearing in ForceSendFields will be sent to the
  574. // server regardless of whether the field is empty or not. This may be
  575. // used to include empty fields in Patch requests.
  576. ForceSendFields []string `json:"-"`
  577. // NullFields is a list of field names (e.g. "ReturnImmediately") to
  578. // include in API requests with the JSON null value. By default, fields
  579. // with empty values are omitted from API requests. However, any field
  580. // with an empty value appearing in NullFields will be sent to the
  581. // server as null. It is an error if a field in this list has a
  582. // non-empty value. This may be used to include null fields in Patch
  583. // requests.
  584. NullFields []string `json:"-"`
  585. }
  586. func (s *PullRequest) MarshalJSON() ([]byte, error) {
  587. type NoMethod PullRequest
  588. raw := NoMethod(*s)
  589. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  590. }
  591. // PullResponse: Either a <code>PubsubMessage</code> or a truncation
  592. // event. One of these two
  593. // must be populated.
  594. type PullResponse struct {
  595. // AckId: This ID must be used to acknowledge the received event or
  596. // message.
  597. AckId string `json:"ackId,omitempty"`
  598. // PubsubEvent: A pubsub message or truncation event.
  599. PubsubEvent *PubsubEvent `json:"pubsubEvent,omitempty"`
  600. // ServerResponse contains the HTTP response code and headers from the
  601. // server.
  602. googleapi.ServerResponse `json:"-"`
  603. // ForceSendFields is a list of field names (e.g. "AckId") to
  604. // unconditionally include in API requests. By default, fields with
  605. // empty values are omitted from API requests. However, any non-pointer,
  606. // non-interface field appearing in ForceSendFields will be sent to the
  607. // server regardless of whether the field is empty or not. This may be
  608. // used to include empty fields in Patch requests.
  609. ForceSendFields []string `json:"-"`
  610. // NullFields is a list of field names (e.g. "AckId") to include in API
  611. // requests with the JSON null value. By default, fields with empty
  612. // values are omitted from API requests. However, any field with an
  613. // empty value appearing in NullFields will be sent to the server as
  614. // null. It is an error if a field in this list has a non-empty value.
  615. // This may be used to include null fields in Patch requests.
  616. NullFields []string `json:"-"`
  617. }
  618. func (s *PullResponse) MarshalJSON() ([]byte, error) {
  619. type NoMethod PullResponse
  620. raw := NoMethod(*s)
  621. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  622. }
  623. // PushConfig: Configuration for a push delivery endpoint.
  624. type PushConfig struct {
  625. // PushEndpoint: A URL locating the endpoint to which messages should be
  626. // pushed.
  627. // For example, a Webhook endpoint might use "https://example.com/push".
  628. PushEndpoint string `json:"pushEndpoint,omitempty"`
  629. // ForceSendFields is a list of field names (e.g. "PushEndpoint") to
  630. // unconditionally include in API requests. By default, fields with
  631. // empty values are omitted from API requests. However, any non-pointer,
  632. // non-interface field appearing in ForceSendFields will be sent to the
  633. // server regardless of whether the field is empty or not. This may be
  634. // used to include empty fields in Patch requests.
  635. ForceSendFields []string `json:"-"`
  636. // NullFields is a list of field names (e.g. "PushEndpoint") to include
  637. // in API requests with the JSON null value. By default, fields with
  638. // empty values are omitted from API requests. However, any field with
  639. // an empty value appearing in NullFields will be sent to the server as
  640. // null. It is an error if a field in this list has a non-empty value.
  641. // This may be used to include null fields in Patch requests.
  642. NullFields []string `json:"-"`
  643. }
  644. func (s *PushConfig) MarshalJSON() ([]byte, error) {
  645. type NoMethod PushConfig
  646. raw := NoMethod(*s)
  647. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  648. }
  649. // Subscription: A subscription resource.
  650. type Subscription struct {
  651. // AckDeadlineSeconds: For either push or pull delivery, the value is
  652. // the maximum time after a
  653. // subscriber receives a message before the subscriber should
  654. // acknowledge or
  655. // Nack the message. If the Ack deadline for a message passes without
  656. // an
  657. // Ack or a Nack, the Pub/Sub system will eventually redeliver the
  658. // message.
  659. // If a subscriber acknowledges after the deadline, the Pub/Sub system
  660. // may
  661. // accept the Ack, but it is possible that the message has been
  662. // already
  663. // delivered again. Multiple Acks to the message are allowed and
  664. // will
  665. // succeed.
  666. //
  667. // For push delivery, this value is used to set the request timeout
  668. // for
  669. // the call to the push endpoint.
  670. //
  671. // For pull delivery, this value is used as the initial value for the
  672. // Ack
  673. // deadline. It may be overridden for each message using its
  674. // corresponding
  675. // ack_id with <code>ModifyAckDeadline</code>.
  676. // While a message is outstanding (i.e. it has been delivered to a
  677. // pull
  678. // subscriber and the subscriber has not yet Acked or Nacked), the
  679. // Pub/Sub
  680. // system will not deliver that message to another pull subscriber
  681. // (on a best-effort basis).
  682. AckDeadlineSeconds int64 `json:"ackDeadlineSeconds,omitempty"`
  683. // Name: Name of the subscription.
  684. Name string `json:"name,omitempty"`
  685. // PushConfig: If push delivery is used with this subscription, this
  686. // field is
  687. // used to configure it.
  688. PushConfig *PushConfig `json:"pushConfig,omitempty"`
  689. // Topic: The name of the topic from which this subscription is
  690. // receiving messages.
  691. Topic string `json:"topic,omitempty"`
  692. // ServerResponse contains the HTTP response code and headers from the
  693. // server.
  694. googleapi.ServerResponse `json:"-"`
  695. // ForceSendFields is a list of field names (e.g. "AckDeadlineSeconds")
  696. // to unconditionally include in API requests. By default, fields with
  697. // empty values are omitted from API requests. However, any non-pointer,
  698. // non-interface field appearing in ForceSendFields will be sent to the
  699. // server regardless of whether the field is empty or not. This may be
  700. // used to include empty fields in Patch requests.
  701. ForceSendFields []string `json:"-"`
  702. // NullFields is a list of field names (e.g. "AckDeadlineSeconds") to
  703. // include in API requests with the JSON null value. By default, fields
  704. // with empty values are omitted from API requests. However, any field
  705. // with an empty value appearing in NullFields will be sent to the
  706. // server as null. It is an error if a field in this list has a
  707. // non-empty value. This may be used to include null fields in Patch
  708. // requests.
  709. NullFields []string `json:"-"`
  710. }
  711. func (s *Subscription) MarshalJSON() ([]byte, error) {
  712. type NoMethod Subscription
  713. raw := NoMethod(*s)
  714. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  715. }
  716. // Topic: A topic resource.
  717. type Topic struct {
  718. // Name: Name of the topic.
  719. Name string `json:"name,omitempty"`
  720. // ServerResponse contains the HTTP response code and headers from the
  721. // server.
  722. googleapi.ServerResponse `json:"-"`
  723. // ForceSendFields is a list of field names (e.g. "Name") to
  724. // unconditionally include in API requests. By default, fields with
  725. // empty values are omitted from API requests. However, any non-pointer,
  726. // non-interface field appearing in ForceSendFields will be sent to the
  727. // server regardless of whether the field is empty or not. This may be
  728. // used to include empty fields in Patch requests.
  729. ForceSendFields []string `json:"-"`
  730. // NullFields is a list of field names (e.g. "Name") to include in API
  731. // requests with the JSON null value. By default, fields with empty
  732. // values are omitted from API requests. However, any field with an
  733. // empty value appearing in NullFields will be sent to the server as
  734. // null. It is an error if a field in this list has a non-empty value.
  735. // This may be used to include null fields in Patch requests.
  736. NullFields []string `json:"-"`
  737. }
  738. func (s *Topic) MarshalJSON() ([]byte, error) {
  739. type NoMethod Topic
  740. raw := NoMethod(*s)
  741. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  742. }
  743. // method id "pubsub.subscriptions.acknowledge":
  744. type SubscriptionsAcknowledgeCall struct {
  745. s *Service
  746. acknowledgerequest *AcknowledgeRequest
  747. urlParams_ gensupport.URLParams
  748. ctx_ context.Context
  749. header_ http.Header
  750. }
  751. // Acknowledge: Acknowledges a particular received message: the Pub/Sub
  752. // system can remove
  753. // the given message from the subscription. Acknowledging a message
  754. // whose
  755. // Ack deadline has expired may succeed, but the message could have
  756. // been
  757. // already redelivered. Acknowledging a message more than once will
  758. // not
  759. // result in an error. This is only used for messages received via pull.
  760. func (r *SubscriptionsService) Acknowledge(acknowledgerequest *AcknowledgeRequest) *SubscriptionsAcknowledgeCall {
  761. c := &SubscriptionsAcknowledgeCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  762. c.acknowledgerequest = acknowledgerequest
  763. return c
  764. }
  765. // Fields allows partial responses to be retrieved. See
  766. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  767. // for more information.
  768. func (c *SubscriptionsAcknowledgeCall) Fields(s ...googleapi.Field) *SubscriptionsAcknowledgeCall {
  769. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  770. return c
  771. }
  772. // Context sets the context to be used in this call's Do method. Any
  773. // pending HTTP request will be aborted if the provided context is
  774. // canceled.
  775. func (c *SubscriptionsAcknowledgeCall) Context(ctx context.Context) *SubscriptionsAcknowledgeCall {
  776. c.ctx_ = ctx
  777. return c
  778. }
  779. // Header returns an http.Header that can be modified by the caller to
  780. // add HTTP headers to the request.
  781. func (c *SubscriptionsAcknowledgeCall) Header() http.Header {
  782. if c.header_ == nil {
  783. c.header_ = make(http.Header)
  784. }
  785. return c.header_
  786. }
  787. func (c *SubscriptionsAcknowledgeCall) doRequest(alt string) (*http.Response, error) {
  788. reqHeaders := make(http.Header)
  789. for k, v := range c.header_ {
  790. reqHeaders[k] = v
  791. }
  792. reqHeaders.Set("User-Agent", c.s.userAgent())
  793. var body io.Reader = nil
  794. body, err := googleapi.WithoutDataWrapper.JSONReader(c.acknowledgerequest)
  795. if err != nil {
  796. return nil, err
  797. }
  798. reqHeaders.Set("Content-Type", "application/json")
  799. c.urlParams_.Set("alt", alt)
  800. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1a/subscriptions/acknowledge")
  801. urls += "?" + c.urlParams_.Encode()
  802. req, _ := http.NewRequest("POST", urls, body)
  803. req.Header = reqHeaders
  804. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  805. }
  806. // Do executes the "pubsub.subscriptions.acknowledge" call.
  807. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  808. // code is an error. Response headers are in either
  809. // *Empty.ServerResponse.Header or (if a response was returned at all)
  810. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  811. // check whether the returned error was because http.StatusNotModified
  812. // was returned.
  813. func (c *SubscriptionsAcknowledgeCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  814. gensupport.SetOptions(c.urlParams_, opts...)
  815. res, err := c.doRequest("json")
  816. if res != nil && res.StatusCode == http.StatusNotModified {
  817. if res.Body != nil {
  818. res.Body.Close()
  819. }
  820. return nil, &googleapi.Error{
  821. Code: res.StatusCode,
  822. Header: res.Header,
  823. }
  824. }
  825. if err != nil {
  826. return nil, err
  827. }
  828. defer googleapi.CloseBody(res)
  829. if err := googleapi.CheckResponse(res); err != nil {
  830. return nil, err
  831. }
  832. ret := &Empty{
  833. ServerResponse: googleapi.ServerResponse{
  834. Header: res.Header,
  835. HTTPStatusCode: res.StatusCode,
  836. },
  837. }
  838. target := &ret
  839. if err := gensupport.DecodeResponse(target, res); err != nil {
  840. return nil, err
  841. }
  842. return ret, nil
  843. // {
  844. // "description": "Acknowledges a particular received message: the Pub/Sub system can remove\nthe given message from the subscription. Acknowledging a message whose\nAck deadline has expired may succeed, but the message could have been\nalready redelivered. Acknowledging a message more than once will not\nresult in an error. This is only used for messages received via pull.",
  845. // "flatPath": "v1beta1a/subscriptions/acknowledge",
  846. // "httpMethod": "POST",
  847. // "id": "pubsub.subscriptions.acknowledge",
  848. // "parameterOrder": [],
  849. // "parameters": {},
  850. // "path": "v1beta1a/subscriptions/acknowledge",
  851. // "request": {
  852. // "$ref": "AcknowledgeRequest"
  853. // },
  854. // "response": {
  855. // "$ref": "Empty"
  856. // },
  857. // "scopes": [
  858. // "https://www.googleapis.com/auth/cloud-platform",
  859. // "https://www.googleapis.com/auth/pubsub"
  860. // ]
  861. // }
  862. }
  863. // method id "pubsub.subscriptions.create":
  864. type SubscriptionsCreateCall struct {
  865. s *Service
  866. subscription *Subscription
  867. urlParams_ gensupport.URLParams
  868. ctx_ context.Context
  869. header_ http.Header
  870. }
  871. // Create: Creates a subscription on a given topic for a given
  872. // subscriber.
  873. // If the subscription already exists, returns ALREADY_EXISTS.
  874. // If the corresponding topic doesn't exist, returns NOT_FOUND.
  875. //
  876. // If the name is not provided in the request, the server will assign a
  877. // random
  878. // name for this subscription on the same project as the topic.
  879. func (r *SubscriptionsService) Create(subscription *Subscription) *SubscriptionsCreateCall {
  880. c := &SubscriptionsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  881. c.subscription = subscription
  882. return c
  883. }
  884. // Fields allows partial responses to be retrieved. See
  885. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  886. // for more information.
  887. func (c *SubscriptionsCreateCall) Fields(s ...googleapi.Field) *SubscriptionsCreateCall {
  888. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  889. return c
  890. }
  891. // Context sets the context to be used in this call's Do method. Any
  892. // pending HTTP request will be aborted if the provided context is
  893. // canceled.
  894. func (c *SubscriptionsCreateCall) Context(ctx context.Context) *SubscriptionsCreateCall {
  895. c.ctx_ = ctx
  896. return c
  897. }
  898. // Header returns an http.Header that can be modified by the caller to
  899. // add HTTP headers to the request.
  900. func (c *SubscriptionsCreateCall) Header() http.Header {
  901. if c.header_ == nil {
  902. c.header_ = make(http.Header)
  903. }
  904. return c.header_
  905. }
  906. func (c *SubscriptionsCreateCall) doRequest(alt string) (*http.Response, error) {
  907. reqHeaders := make(http.Header)
  908. for k, v := range c.header_ {
  909. reqHeaders[k] = v
  910. }
  911. reqHeaders.Set("User-Agent", c.s.userAgent())
  912. var body io.Reader = nil
  913. body, err := googleapi.WithoutDataWrapper.JSONReader(c.subscription)
  914. if err != nil {
  915. return nil, err
  916. }
  917. reqHeaders.Set("Content-Type", "application/json")
  918. c.urlParams_.Set("alt", alt)
  919. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1a/subscriptions")
  920. urls += "?" + c.urlParams_.Encode()
  921. req, _ := http.NewRequest("POST", urls, body)
  922. req.Header = reqHeaders
  923. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  924. }
  925. // Do executes the "pubsub.subscriptions.create" call.
  926. // Exactly one of *Subscription or error will be non-nil. Any non-2xx
  927. // status code is an error. Response headers are in either
  928. // *Subscription.ServerResponse.Header or (if a response was returned at
  929. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  930. // to check whether the returned error was because
  931. // http.StatusNotModified was returned.
  932. func (c *SubscriptionsCreateCall) Do(opts ...googleapi.CallOption) (*Subscription, error) {
  933. gensupport.SetOptions(c.urlParams_, opts...)
  934. res, err := c.doRequest("json")
  935. if res != nil && res.StatusCode == http.StatusNotModified {
  936. if res.Body != nil {
  937. res.Body.Close()
  938. }
  939. return nil, &googleapi.Error{
  940. Code: res.StatusCode,
  941. Header: res.Header,
  942. }
  943. }
  944. if err != nil {
  945. return nil, err
  946. }
  947. defer googleapi.CloseBody(res)
  948. if err := googleapi.CheckResponse(res); err != nil {
  949. return nil, err
  950. }
  951. ret := &Subscription{
  952. ServerResponse: googleapi.ServerResponse{
  953. Header: res.Header,
  954. HTTPStatusCode: res.StatusCode,
  955. },
  956. }
  957. target := &ret
  958. if err := gensupport.DecodeResponse(target, res); err != nil {
  959. return nil, err
  960. }
  961. return ret, nil
  962. // {
  963. // "description": "Creates a subscription on a given topic for a given subscriber.\nIf the subscription already exists, returns ALREADY_EXISTS.\nIf the corresponding topic doesn't exist, returns NOT_FOUND.\n\nIf the name is not provided in the request, the server will assign a random\nname for this subscription on the same project as the topic.",
  964. // "flatPath": "v1beta1a/subscriptions",
  965. // "httpMethod": "POST",
  966. // "id": "pubsub.subscriptions.create",
  967. // "parameterOrder": [],
  968. // "parameters": {},
  969. // "path": "v1beta1a/subscriptions",
  970. // "request": {
  971. // "$ref": "Subscription"
  972. // },
  973. // "response": {
  974. // "$ref": "Subscription"
  975. // },
  976. // "scopes": [
  977. // "https://www.googleapis.com/auth/cloud-platform",
  978. // "https://www.googleapis.com/auth/pubsub"
  979. // ]
  980. // }
  981. }
  982. // method id "pubsub.subscriptions.delete":
  983. type SubscriptionsDeleteCall struct {
  984. s *Service
  985. subscription string
  986. urlParams_ gensupport.URLParams
  987. ctx_ context.Context
  988. header_ http.Header
  989. }
  990. // Delete: Deletes an existing subscription. All pending messages in the
  991. // subscription
  992. // are immediately dropped. Calls to Pull after deletion will
  993. // return
  994. // NOT_FOUND.
  995. func (r *SubscriptionsService) Delete(subscription string) *SubscriptionsDeleteCall {
  996. c := &SubscriptionsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  997. c.subscription = subscription
  998. return c
  999. }
  1000. // Fields allows partial responses to be retrieved. See
  1001. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1002. // for more information.
  1003. func (c *SubscriptionsDeleteCall) Fields(s ...googleapi.Field) *SubscriptionsDeleteCall {
  1004. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1005. return c
  1006. }
  1007. // Context sets the context to be used in this call's Do method. Any
  1008. // pending HTTP request will be aborted if the provided context is
  1009. // canceled.
  1010. func (c *SubscriptionsDeleteCall) Context(ctx context.Context) *SubscriptionsDeleteCall {
  1011. c.ctx_ = ctx
  1012. return c
  1013. }
  1014. // Header returns an http.Header that can be modified by the caller to
  1015. // add HTTP headers to the request.
  1016. func (c *SubscriptionsDeleteCall) Header() http.Header {
  1017. if c.header_ == nil {
  1018. c.header_ = make(http.Header)
  1019. }
  1020. return c.header_
  1021. }
  1022. func (c *SubscriptionsDeleteCall) doRequest(alt string) (*http.Response, error) {
  1023. reqHeaders := make(http.Header)
  1024. for k, v := range c.header_ {
  1025. reqHeaders[k] = v
  1026. }
  1027. reqHeaders.Set("User-Agent", c.s.userAgent())
  1028. var body io.Reader = nil
  1029. c.urlParams_.Set("alt", alt)
  1030. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1a/subscriptions/{+subscription}")
  1031. urls += "?" + c.urlParams_.Encode()
  1032. req, _ := http.NewRequest("DELETE", urls, body)
  1033. req.Header = reqHeaders
  1034. googleapi.Expand(req.URL, map[string]string{
  1035. "subscription": c.subscription,
  1036. })
  1037. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1038. }
  1039. // Do executes the "pubsub.subscriptions.delete" call.
  1040. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  1041. // code is an error. Response headers are in either
  1042. // *Empty.ServerResponse.Header or (if a response was returned at all)
  1043. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1044. // check whether the returned error was because http.StatusNotModified
  1045. // was returned.
  1046. func (c *SubscriptionsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  1047. gensupport.SetOptions(c.urlParams_, opts...)
  1048. res, err := c.doRequest("json")
  1049. if res != nil && res.StatusCode == http.StatusNotModified {
  1050. if res.Body != nil {
  1051. res.Body.Close()
  1052. }
  1053. return nil, &googleapi.Error{
  1054. Code: res.StatusCode,
  1055. Header: res.Header,
  1056. }
  1057. }
  1058. if err != nil {
  1059. return nil, err
  1060. }
  1061. defer googleapi.CloseBody(res)
  1062. if err := googleapi.CheckResponse(res); err != nil {
  1063. return nil, err
  1064. }
  1065. ret := &Empty{
  1066. ServerResponse: googleapi.ServerResponse{
  1067. Header: res.Header,
  1068. HTTPStatusCode: res.StatusCode,
  1069. },
  1070. }
  1071. target := &ret
  1072. if err := gensupport.DecodeResponse(target, res); err != nil {
  1073. return nil, err
  1074. }
  1075. return ret, nil
  1076. // {
  1077. // "description": "Deletes an existing subscription. All pending messages in the subscription\nare immediately dropped. Calls to Pull after deletion will return\nNOT_FOUND.",
  1078. // "flatPath": "v1beta1a/subscriptions/{subscriptionsId}",
  1079. // "httpMethod": "DELETE",
  1080. // "id": "pubsub.subscriptions.delete",
  1081. // "parameterOrder": [
  1082. // "subscription"
  1083. // ],
  1084. // "parameters": {
  1085. // "subscription": {
  1086. // "description": "The subscription to delete.",
  1087. // "location": "path",
  1088. // "pattern": "^.+$",
  1089. // "required": true,
  1090. // "type": "string"
  1091. // }
  1092. // },
  1093. // "path": "v1beta1a/subscriptions/{+subscription}",
  1094. // "response": {
  1095. // "$ref": "Empty"
  1096. // },
  1097. // "scopes": [
  1098. // "https://www.googleapis.com/auth/cloud-platform",
  1099. // "https://www.googleapis.com/auth/pubsub"
  1100. // ]
  1101. // }
  1102. }
  1103. // method id "pubsub.subscriptions.get":
  1104. type SubscriptionsGetCall struct {
  1105. s *Service
  1106. subscription string
  1107. urlParams_ gensupport.URLParams
  1108. ifNoneMatch_ string
  1109. ctx_ context.Context
  1110. header_ http.Header
  1111. }
  1112. // Get: Gets the configuration details of a subscription.
  1113. func (r *SubscriptionsService) Get(subscription string) *SubscriptionsGetCall {
  1114. c := &SubscriptionsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1115. c.subscription = subscription
  1116. return c
  1117. }
  1118. // Fields allows partial responses to be retrieved. See
  1119. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1120. // for more information.
  1121. func (c *SubscriptionsGetCall) Fields(s ...googleapi.Field) *SubscriptionsGetCall {
  1122. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1123. return c
  1124. }
  1125. // IfNoneMatch sets the optional parameter which makes the operation
  1126. // fail if the object's ETag matches the given value. This is useful for
  1127. // getting updates only after the object has changed since the last
  1128. // request. Use googleapi.IsNotModified to check whether the response
  1129. // error from Do is the result of In-None-Match.
  1130. func (c *SubscriptionsGetCall) IfNoneMatch(entityTag string) *SubscriptionsGetCall {
  1131. c.ifNoneMatch_ = entityTag
  1132. return c
  1133. }
  1134. // Context sets the context to be used in this call's Do method. Any
  1135. // pending HTTP request will be aborted if the provided context is
  1136. // canceled.
  1137. func (c *SubscriptionsGetCall) Context(ctx context.Context) *SubscriptionsGetCall {
  1138. c.ctx_ = ctx
  1139. return c
  1140. }
  1141. // Header returns an http.Header that can be modified by the caller to
  1142. // add HTTP headers to the request.
  1143. func (c *SubscriptionsGetCall) Header() http.Header {
  1144. if c.header_ == nil {
  1145. c.header_ = make(http.Header)
  1146. }
  1147. return c.header_
  1148. }
  1149. func (c *SubscriptionsGetCall) doRequest(alt string) (*http.Response, error) {
  1150. reqHeaders := make(http.Header)
  1151. for k, v := range c.header_ {
  1152. reqHeaders[k] = v
  1153. }
  1154. reqHeaders.Set("User-Agent", c.s.userAgent())
  1155. if c.ifNoneMatch_ != "" {
  1156. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1157. }
  1158. var body io.Reader = nil
  1159. c.urlParams_.Set("alt", alt)
  1160. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1a/subscriptions/{+subscription}")
  1161. urls += "?" + c.urlParams_.Encode()
  1162. req, _ := http.NewRequest("GET", urls, body)
  1163. req.Header = reqHeaders
  1164. googleapi.Expand(req.URL, map[string]string{
  1165. "subscription": c.subscription,
  1166. })
  1167. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1168. }
  1169. // Do executes the "pubsub.subscriptions.get" call.
  1170. // Exactly one of *Subscription or error will be non-nil. Any non-2xx
  1171. // status code is an error. Response headers are in either
  1172. // *Subscription.ServerResponse.Header or (if a response was returned at
  1173. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1174. // to check whether the returned error was because
  1175. // http.StatusNotModified was returned.
  1176. func (c *SubscriptionsGetCall) Do(opts ...googleapi.CallOption) (*Subscription, error) {
  1177. gensupport.SetOptions(c.urlParams_, opts...)
  1178. res, err := c.doRequest("json")
  1179. if res != nil && res.StatusCode == http.StatusNotModified {
  1180. if res.Body != nil {
  1181. res.Body.Close()
  1182. }
  1183. return nil, &googleapi.Error{
  1184. Code: res.StatusCode,
  1185. Header: res.Header,
  1186. }
  1187. }
  1188. if err != nil {
  1189. return nil, err
  1190. }
  1191. defer googleapi.CloseBody(res)
  1192. if err := googleapi.CheckResponse(res); err != nil {
  1193. return nil, err
  1194. }
  1195. ret := &Subscription{
  1196. ServerResponse: googleapi.ServerResponse{
  1197. Header: res.Header,
  1198. HTTPStatusCode: res.StatusCode,
  1199. },
  1200. }
  1201. target := &ret
  1202. if err := gensupport.DecodeResponse(target, res); err != nil {
  1203. return nil, err
  1204. }
  1205. return ret, nil
  1206. // {
  1207. // "description": "Gets the configuration details of a subscription.",
  1208. // "flatPath": "v1beta1a/subscriptions/{subscriptionsId}",
  1209. // "httpMethod": "GET",
  1210. // "id": "pubsub.subscriptions.get",
  1211. // "parameterOrder": [
  1212. // "subscription"
  1213. // ],
  1214. // "parameters": {
  1215. // "subscription": {
  1216. // "description": "The name of the subscription to get.",
  1217. // "location": "path",
  1218. // "pattern": "^.+$",
  1219. // "required": true,
  1220. // "type": "string"
  1221. // }
  1222. // },
  1223. // "path": "v1beta1a/subscriptions/{+subscription}",
  1224. // "response": {
  1225. // "$ref": "Subscription"
  1226. // },
  1227. // "scopes": [
  1228. // "https://www.googleapis.com/auth/cloud-platform",
  1229. // "https://www.googleapis.com/auth/pubsub"
  1230. // ]
  1231. // }
  1232. }
  1233. // method id "pubsub.subscriptions.list":
  1234. type SubscriptionsListCall struct {
  1235. s *Service
  1236. urlParams_ gensupport.URLParams
  1237. ifNoneMatch_ string
  1238. ctx_ context.Context
  1239. header_ http.Header
  1240. }
  1241. // List: Lists matching subscriptions.
  1242. func (r *SubscriptionsService) List() *SubscriptionsListCall {
  1243. c := &SubscriptionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1244. return c
  1245. }
  1246. // MaxResults sets the optional parameter "maxResults": Maximum number
  1247. // of subscriptions to return.
  1248. func (c *SubscriptionsListCall) MaxResults(maxResults int64) *SubscriptionsListCall {
  1249. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  1250. return c
  1251. }
  1252. // PageToken sets the optional parameter "pageToken": The value obtained
  1253. // in the last <code>ListSubscriptionsResponse</code>
  1254. // for continuation.
  1255. func (c *SubscriptionsListCall) PageToken(pageToken string) *SubscriptionsListCall {
  1256. c.urlParams_.Set("pageToken", pageToken)
  1257. return c
  1258. }
  1259. // Query sets the optional parameter "query": A valid label query
  1260. // expression.
  1261. func (c *SubscriptionsListCall) Query(query string) *SubscriptionsListCall {
  1262. c.urlParams_.Set("query", query)
  1263. return c
  1264. }
  1265. // Fields allows partial responses to be retrieved. See
  1266. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1267. // for more information.
  1268. func (c *SubscriptionsListCall) Fields(s ...googleapi.Field) *SubscriptionsListCall {
  1269. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1270. return c
  1271. }
  1272. // IfNoneMatch sets the optional parameter which makes the operation
  1273. // fail if the object's ETag matches the given value. This is useful for
  1274. // getting updates only after the object has changed since the last
  1275. // request. Use googleapi.IsNotModified to check whether the response
  1276. // error from Do is the result of In-None-Match.
  1277. func (c *SubscriptionsListCall) IfNoneMatch(entityTag string) *SubscriptionsListCall {
  1278. c.ifNoneMatch_ = entityTag
  1279. return c
  1280. }
  1281. // Context sets the context to be used in this call's Do method. Any
  1282. // pending HTTP request will be aborted if the provided context is
  1283. // canceled.
  1284. func (c *SubscriptionsListCall) Context(ctx context.Context) *SubscriptionsListCall {
  1285. c.ctx_ = ctx
  1286. return c
  1287. }
  1288. // Header returns an http.Header that can be modified by the caller to
  1289. // add HTTP headers to the request.
  1290. func (c *SubscriptionsListCall) Header() http.Header {
  1291. if c.header_ == nil {
  1292. c.header_ = make(http.Header)
  1293. }
  1294. return c.header_
  1295. }
  1296. func (c *SubscriptionsListCall) doRequest(alt string) (*http.Response, error) {
  1297. reqHeaders := make(http.Header)
  1298. for k, v := range c.header_ {
  1299. reqHeaders[k] = v
  1300. }
  1301. reqHeaders.Set("User-Agent", c.s.userAgent())
  1302. if c.ifNoneMatch_ != "" {
  1303. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1304. }
  1305. var body io.Reader = nil
  1306. c.urlParams_.Set("alt", alt)
  1307. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1a/subscriptions")
  1308. urls += "?" + c.urlParams_.Encode()
  1309. req, _ := http.NewRequest("GET", urls, body)
  1310. req.Header = reqHeaders
  1311. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1312. }
  1313. // Do executes the "pubsub.subscriptions.list" call.
  1314. // Exactly one of *ListSubscriptionsResponse or error will be non-nil.
  1315. // Any non-2xx status code is an error. Response headers are in either
  1316. // *ListSubscriptionsResponse.ServerResponse.Header or (if a response
  1317. // was returned at all) in error.(*googleapi.Error).Header. Use
  1318. // googleapi.IsNotModified to check whether the returned error was
  1319. // because http.StatusNotModified was returned.
  1320. func (c *SubscriptionsListCall) Do(opts ...googleapi.CallOption) (*ListSubscriptionsResponse, error) {
  1321. gensupport.SetOptions(c.urlParams_, opts...)
  1322. res, err := c.doRequest("json")
  1323. if res != nil && res.StatusCode == http.StatusNotModified {
  1324. if res.Body != nil {
  1325. res.Body.Close()
  1326. }
  1327. return nil, &googleapi.Error{
  1328. Code: res.StatusCode,
  1329. Header: res.Header,
  1330. }
  1331. }
  1332. if err != nil {
  1333. return nil, err
  1334. }
  1335. defer googleapi.CloseBody(res)
  1336. if err := googleapi.CheckResponse(res); err != nil {
  1337. return nil, err
  1338. }
  1339. ret := &ListSubscriptionsResponse{
  1340. ServerResponse: googleapi.ServerResponse{
  1341. Header: res.Header,
  1342. HTTPStatusCode: res.StatusCode,
  1343. },
  1344. }
  1345. target := &ret
  1346. if err := gensupport.DecodeResponse(target, res); err != nil {
  1347. return nil, err
  1348. }
  1349. return ret, nil
  1350. // {
  1351. // "description": "Lists matching subscriptions.",
  1352. // "flatPath": "v1beta1a/subscriptions",
  1353. // "httpMethod": "GET",
  1354. // "id": "pubsub.subscriptions.list",
  1355. // "parameterOrder": [],
  1356. // "parameters": {
  1357. // "maxResults": {
  1358. // "description": "Maximum number of subscriptions to return.",
  1359. // "format": "int32",
  1360. // "location": "query",
  1361. // "type": "integer"
  1362. // },
  1363. // "pageToken": {
  1364. // "description": "The value obtained in the last \u003ccode\u003eListSubscriptionsResponse\u003c/code\u003e\nfor continuation.",
  1365. // "location": "query",
  1366. // "type": "string"
  1367. // },
  1368. // "query": {
  1369. // "description": "A valid label query expression.",
  1370. // "location": "query",
  1371. // "type": "string"
  1372. // }
  1373. // },
  1374. // "path": "v1beta1a/subscriptions",
  1375. // "response": {
  1376. // "$ref": "ListSubscriptionsResponse"
  1377. // },
  1378. // "scopes": [
  1379. // "https://www.googleapis.com/auth/cloud-platform",
  1380. // "https://www.googleapis.com/auth/pubsub"
  1381. // ]
  1382. // }
  1383. }
  1384. // Pages invokes f for each page of results.
  1385. // A non-nil error returned from f will halt the iteration.
  1386. // The provided context supersedes any context provided to the Context method.
  1387. func (c *SubscriptionsListCall) Pages(ctx context.Context, f func(*ListSubscriptionsResponse) error) error {
  1388. c.ctx_ = ctx
  1389. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1390. for {
  1391. x, err := c.Do()
  1392. if err != nil {
  1393. return err
  1394. }
  1395. if err := f(x); err != nil {
  1396. return err
  1397. }
  1398. if x.NextPageToken == "" {
  1399. return nil
  1400. }
  1401. c.PageToken(x.NextPageToken)
  1402. }
  1403. }
  1404. // method id "pubsub.subscriptions.modifyAckDeadline":
  1405. type SubscriptionsModifyAckDeadlineCall struct {
  1406. s *Service
  1407. modifyackdeadlinerequest *ModifyAckDeadlineRequest
  1408. urlParams_ gensupport.URLParams
  1409. ctx_ context.Context
  1410. header_ http.Header
  1411. }
  1412. // ModifyAckDeadline: Modifies the Ack deadline for a message received
  1413. // from a pull request.
  1414. func (r *SubscriptionsService) ModifyAckDeadline(modifyackdeadlinerequest *ModifyAckDeadlineRequest) *SubscriptionsModifyAckDeadlineCall {
  1415. c := &SubscriptionsModifyAckDeadlineCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1416. c.modifyackdeadlinerequest = modifyackdeadlinerequest
  1417. return c
  1418. }
  1419. // Fields allows partial responses to be retrieved. See
  1420. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1421. // for more information.
  1422. func (c *SubscriptionsModifyAckDeadlineCall) Fields(s ...googleapi.Field) *SubscriptionsModifyAckDeadlineCall {
  1423. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1424. return c
  1425. }
  1426. // Context sets the context to be used in this call's Do method. Any
  1427. // pending HTTP request will be aborted if the provided context is
  1428. // canceled.
  1429. func (c *SubscriptionsModifyAckDeadlineCall) Context(ctx context.Context) *SubscriptionsModifyAckDeadlineCall {
  1430. c.ctx_ = ctx
  1431. return c
  1432. }
  1433. // Header returns an http.Header that can be modified by the caller to
  1434. // add HTTP headers to the request.
  1435. func (c *SubscriptionsModifyAckDeadlineCall) Header() http.Header {
  1436. if c.header_ == nil {
  1437. c.header_ = make(http.Header)
  1438. }
  1439. return c.header_
  1440. }
  1441. func (c *SubscriptionsModifyAckDeadlineCall) doRequest(alt string) (*http.Response, error) {
  1442. reqHeaders := make(http.Header)
  1443. for k, v := range c.header_ {
  1444. reqHeaders[k] = v
  1445. }
  1446. reqHeaders.Set("User-Agent", c.s.userAgent())
  1447. var body io.Reader = nil
  1448. body, err := googleapi.WithoutDataWrapper.JSONReader(c.modifyackdeadlinerequest)
  1449. if err != nil {
  1450. return nil, err
  1451. }
  1452. reqHeaders.Set("Content-Type", "application/json")
  1453. c.urlParams_.Set("alt", alt)
  1454. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1a/subscriptions/modifyAckDeadline")
  1455. urls += "?" + c.urlParams_.Encode()
  1456. req, _ := http.NewRequest("POST", urls, body)
  1457. req.Header = reqHeaders
  1458. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1459. }
  1460. // Do executes the "pubsub.subscriptions.modifyAckDeadline" call.
  1461. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  1462. // code is an error. Response headers are in either
  1463. // *Empty.ServerResponse.Header or (if a response was returned at all)
  1464. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1465. // check whether the returned error was because http.StatusNotModified
  1466. // was returned.
  1467. func (c *SubscriptionsModifyAckDeadlineCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  1468. gensupport.SetOptions(c.urlParams_, opts...)
  1469. res, err := c.doRequest("json")
  1470. if res != nil && res.StatusCode == http.StatusNotModified {
  1471. if res.Body != nil {
  1472. res.Body.Close()
  1473. }
  1474. return nil, &googleapi.Error{
  1475. Code: res.StatusCode,
  1476. Header: res.Header,
  1477. }
  1478. }
  1479. if err != nil {
  1480. return nil, err
  1481. }
  1482. defer googleapi.CloseBody(res)
  1483. if err := googleapi.CheckResponse(res); err != nil {
  1484. return nil, err
  1485. }
  1486. ret := &Empty{
  1487. ServerResponse: googleapi.ServerResponse{
  1488. Header: res.Header,
  1489. HTTPStatusCode: res.StatusCode,
  1490. },
  1491. }
  1492. target := &ret
  1493. if err := gensupport.DecodeResponse(target, res); err != nil {
  1494. return nil, err
  1495. }
  1496. return ret, nil
  1497. // {
  1498. // "description": "Modifies the Ack deadline for a message received from a pull request.",
  1499. // "flatPath": "v1beta1a/subscriptions/modifyAckDeadline",
  1500. // "httpMethod": "POST",
  1501. // "id": "pubsub.subscriptions.modifyAckDeadline",
  1502. // "parameterOrder": [],
  1503. // "parameters": {},
  1504. // "path": "v1beta1a/subscriptions/modifyAckDeadline",
  1505. // "request": {
  1506. // "$ref": "ModifyAckDeadlineRequest"
  1507. // },
  1508. // "response": {
  1509. // "$ref": "Empty"
  1510. // },
  1511. // "scopes": [
  1512. // "https://www.googleapis.com/auth/cloud-platform",
  1513. // "https://www.googleapis.com/auth/pubsub"
  1514. // ]
  1515. // }
  1516. }
  1517. // method id "pubsub.subscriptions.modifyPushConfig":
  1518. type SubscriptionsModifyPushConfigCall struct {
  1519. s *Service
  1520. modifypushconfigrequest *ModifyPushConfigRequest
  1521. urlParams_ gensupport.URLParams
  1522. ctx_ context.Context
  1523. header_ http.Header
  1524. }
  1525. // ModifyPushConfig: Modifies the <code>PushConfig</code> for a
  1526. // specified subscription.
  1527. // This method can be used to suspend the flow of messages to an
  1528. // endpoint
  1529. // by clearing the <code>PushConfig</code> field in the request.
  1530. // Messages
  1531. // will be accumulated for delivery even if no push configuration
  1532. // is
  1533. // defined or while the configuration is modified.
  1534. func (r *SubscriptionsService) ModifyPushConfig(modifypushconfigrequest *ModifyPushConfigRequest) *SubscriptionsModifyPushConfigCall {
  1535. c := &SubscriptionsModifyPushConfigCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1536. c.modifypushconfigrequest = modifypushconfigrequest
  1537. return c
  1538. }
  1539. // Fields allows partial responses to be retrieved. See
  1540. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1541. // for more information.
  1542. func (c *SubscriptionsModifyPushConfigCall) Fields(s ...googleapi.Field) *SubscriptionsModifyPushConfigCall {
  1543. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1544. return c
  1545. }
  1546. // Context sets the context to be used in this call's Do method. Any
  1547. // pending HTTP request will be aborted if the provided context is
  1548. // canceled.
  1549. func (c *SubscriptionsModifyPushConfigCall) Context(ctx context.Context) *SubscriptionsModifyPushConfigCall {
  1550. c.ctx_ = ctx
  1551. return c
  1552. }
  1553. // Header returns an http.Header that can be modified by the caller to
  1554. // add HTTP headers to the request.
  1555. func (c *SubscriptionsModifyPushConfigCall) Header() http.Header {
  1556. if c.header_ == nil {
  1557. c.header_ = make(http.Header)
  1558. }
  1559. return c.header_
  1560. }
  1561. func (c *SubscriptionsModifyPushConfigCall) doRequest(alt string) (*http.Response, error) {
  1562. reqHeaders := make(http.Header)
  1563. for k, v := range c.header_ {
  1564. reqHeaders[k] = v
  1565. }
  1566. reqHeaders.Set("User-Agent", c.s.userAgent())
  1567. var body io.Reader = nil
  1568. body, err := googleapi.WithoutDataWrapper.JSONReader(c.modifypushconfigrequest)
  1569. if err != nil {
  1570. return nil, err
  1571. }
  1572. reqHeaders.Set("Content-Type", "application/json")
  1573. c.urlParams_.Set("alt", alt)
  1574. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1a/subscriptions/modifyPushConfig")
  1575. urls += "?" + c.urlParams_.Encode()
  1576. req, _ := http.NewRequest("POST", urls, body)
  1577. req.Header = reqHeaders
  1578. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1579. }
  1580. // Do executes the "pubsub.subscriptions.modifyPushConfig" call.
  1581. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  1582. // code is an error. Response headers are in either
  1583. // *Empty.ServerResponse.Header or (if a response was returned at all)
  1584. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1585. // check whether the returned error was because http.StatusNotModified
  1586. // was returned.
  1587. func (c *SubscriptionsModifyPushConfigCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  1588. gensupport.SetOptions(c.urlParams_, opts...)
  1589. res, err := c.doRequest("json")
  1590. if res != nil && res.StatusCode == http.StatusNotModified {
  1591. if res.Body != nil {
  1592. res.Body.Close()
  1593. }
  1594. return nil, &googleapi.Error{
  1595. Code: res.StatusCode,
  1596. Header: res.Header,
  1597. }
  1598. }
  1599. if err != nil {
  1600. return nil, err
  1601. }
  1602. defer googleapi.CloseBody(res)
  1603. if err := googleapi.CheckResponse(res); err != nil {
  1604. return nil, err
  1605. }
  1606. ret := &Empty{
  1607. ServerResponse: googleapi.ServerResponse{
  1608. Header: res.Header,
  1609. HTTPStatusCode: res.StatusCode,
  1610. },
  1611. }
  1612. target := &ret
  1613. if err := gensupport.DecodeResponse(target, res); err != nil {
  1614. return nil, err
  1615. }
  1616. return ret, nil
  1617. // {
  1618. // "description": "Modifies the \u003ccode\u003ePushConfig\u003c/code\u003e for a specified subscription.\nThis method can be used to suspend the flow of messages to an endpoint\nby clearing the \u003ccode\u003ePushConfig\u003c/code\u003e field in the request. Messages\nwill be accumulated for delivery even if no push configuration is\ndefined or while the configuration is modified.",
  1619. // "flatPath": "v1beta1a/subscriptions/modifyPushConfig",
  1620. // "httpMethod": "POST",
  1621. // "id": "pubsub.subscriptions.modifyPushConfig",
  1622. // "parameterOrder": [],
  1623. // "parameters": {},
  1624. // "path": "v1beta1a/subscriptions/modifyPushConfig",
  1625. // "request": {
  1626. // "$ref": "ModifyPushConfigRequest"
  1627. // },
  1628. // "response": {
  1629. // "$ref": "Empty"
  1630. // },
  1631. // "scopes": [
  1632. // "https://www.googleapis.com/auth/cloud-platform",
  1633. // "https://www.googleapis.com/auth/pubsub"
  1634. // ]
  1635. // }
  1636. }
  1637. // method id "pubsub.subscriptions.pull":
  1638. type SubscriptionsPullCall struct {
  1639. s *Service
  1640. pullrequest *PullRequest
  1641. urlParams_ gensupport.URLParams
  1642. ctx_ context.Context
  1643. header_ http.Header
  1644. }
  1645. // Pull: Pulls a single message from the server.
  1646. // If return_immediately is true, and no messages are available in
  1647. // the
  1648. // subscription, this method returns FAILED_PRECONDITION. The system is
  1649. // free
  1650. // to return an UNAVAILABLE error if no messages are available in
  1651. // a
  1652. // reasonable amount of time (to reduce system load).
  1653. func (r *SubscriptionsService) Pull(pullrequest *PullRequest) *SubscriptionsPullCall {
  1654. c := &SubscriptionsPullCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1655. c.pullrequest = pullrequest
  1656. return c
  1657. }
  1658. // Fields allows partial responses to be retrieved. See
  1659. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1660. // for more information.
  1661. func (c *SubscriptionsPullCall) Fields(s ...googleapi.Field) *SubscriptionsPullCall {
  1662. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1663. return c
  1664. }
  1665. // Context sets the context to be used in this call's Do method. Any
  1666. // pending HTTP request will be aborted if the provided context is
  1667. // canceled.
  1668. func (c *SubscriptionsPullCall) Context(ctx context.Context) *SubscriptionsPullCall {
  1669. c.ctx_ = ctx
  1670. return c
  1671. }
  1672. // Header returns an http.Header that can be modified by the caller to
  1673. // add HTTP headers to the request.
  1674. func (c *SubscriptionsPullCall) Header() http.Header {
  1675. if c.header_ == nil {
  1676. c.header_ = make(http.Header)
  1677. }
  1678. return c.header_
  1679. }
  1680. func (c *SubscriptionsPullCall) doRequest(alt string) (*http.Response, error) {
  1681. reqHeaders := make(http.Header)
  1682. for k, v := range c.header_ {
  1683. reqHeaders[k] = v
  1684. }
  1685. reqHeaders.Set("User-Agent", c.s.userAgent())
  1686. var body io.Reader = nil
  1687. body, err := googleapi.WithoutDataWrapper.JSONReader(c.pullrequest)
  1688. if err != nil {
  1689. return nil, err
  1690. }
  1691. reqHeaders.Set("Content-Type", "application/json")
  1692. c.urlParams_.Set("alt", alt)
  1693. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1a/subscriptions/pull")
  1694. urls += "?" + c.urlParams_.Encode()
  1695. req, _ := http.NewRequest("POST", urls, body)
  1696. req.Header = reqHeaders
  1697. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1698. }
  1699. // Do executes the "pubsub.subscriptions.pull" call.
  1700. // Exactly one of *PullResponse or error will be non-nil. Any non-2xx
  1701. // status code is an error. Response headers are in either
  1702. // *PullResponse.ServerResponse.Header or (if a response was returned at
  1703. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1704. // to check whether the returned error was because
  1705. // http.StatusNotModified was returned.
  1706. func (c *SubscriptionsPullCall) Do(opts ...googleapi.CallOption) (*PullResponse, error) {
  1707. gensupport.SetOptions(c.urlParams_, opts...)
  1708. res, err := c.doRequest("json")
  1709. if res != nil && res.StatusCode == http.StatusNotModified {
  1710. if res.Body != nil {
  1711. res.Body.Close()
  1712. }
  1713. return nil, &googleapi.Error{
  1714. Code: res.StatusCode,
  1715. Header: res.Header,
  1716. }
  1717. }
  1718. if err != nil {
  1719. return nil, err
  1720. }
  1721. defer googleapi.CloseBody(res)
  1722. if err := googleapi.CheckResponse(res); err != nil {
  1723. return nil, err
  1724. }
  1725. ret := &PullResponse{
  1726. ServerResponse: googleapi.ServerResponse{
  1727. Header: res.Header,
  1728. HTTPStatusCode: res.StatusCode,
  1729. },
  1730. }
  1731. target := &ret
  1732. if err := gensupport.DecodeResponse(target, res); err != nil {
  1733. return nil, err
  1734. }
  1735. return ret, nil
  1736. // {
  1737. // "description": "Pulls a single message from the server.\nIf return_immediately is true, and no messages are available in the\nsubscription, this method returns FAILED_PRECONDITION. The system is free\nto return an UNAVAILABLE error if no messages are available in a\nreasonable amount of time (to reduce system load).",
  1738. // "flatPath": "v1beta1a/subscriptions/pull",
  1739. // "httpMethod": "POST",
  1740. // "id": "pubsub.subscriptions.pull",
  1741. // "parameterOrder": [],
  1742. // "parameters": {},
  1743. // "path": "v1beta1a/subscriptions/pull",
  1744. // "request": {
  1745. // "$ref": "PullRequest"
  1746. // },
  1747. // "response": {
  1748. // "$ref": "PullResponse"
  1749. // },
  1750. // "scopes": [
  1751. // "https://www.googleapis.com/auth/cloud-platform",
  1752. // "https://www.googleapis.com/auth/pubsub"
  1753. // ]
  1754. // }
  1755. }
  1756. // method id "pubsub.subscriptions.pullBatch":
  1757. type SubscriptionsPullBatchCall struct {
  1758. s *Service
  1759. pullbatchrequest *PullBatchRequest
  1760. urlParams_ gensupport.URLParams
  1761. ctx_ context.Context
  1762. header_ http.Header
  1763. }
  1764. // PullBatch: Pulls messages from the server. Returns an empty list if
  1765. // there are no
  1766. // messages available in the backlog. The system is free to return
  1767. // UNAVAILABLE
  1768. // if there are too many pull requests outstanding for the given
  1769. // subscription.
  1770. func (r *SubscriptionsService) PullBatch(pullbatchrequest *PullBatchRequest) *SubscriptionsPullBatchCall {
  1771. c := &SubscriptionsPullBatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1772. c.pullbatchrequest = pullbatchrequest
  1773. return c
  1774. }
  1775. // Fields allows partial responses to be retrieved. See
  1776. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1777. // for more information.
  1778. func (c *SubscriptionsPullBatchCall) Fields(s ...googleapi.Field) *SubscriptionsPullBatchCall {
  1779. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1780. return c
  1781. }
  1782. // Context sets the context to be used in this call's Do method. Any
  1783. // pending HTTP request will be aborted if the provided context is
  1784. // canceled.
  1785. func (c *SubscriptionsPullBatchCall) Context(ctx context.Context) *SubscriptionsPullBatchCall {
  1786. c.ctx_ = ctx
  1787. return c
  1788. }
  1789. // Header returns an http.Header that can be modified by the caller to
  1790. // add HTTP headers to the request.
  1791. func (c *SubscriptionsPullBatchCall) Header() http.Header {
  1792. if c.header_ == nil {
  1793. c.header_ = make(http.Header)
  1794. }
  1795. return c.header_
  1796. }
  1797. func (c *SubscriptionsPullBatchCall) doRequest(alt string) (*http.Response, error) {
  1798. reqHeaders := make(http.Header)
  1799. for k, v := range c.header_ {
  1800. reqHeaders[k] = v
  1801. }
  1802. reqHeaders.Set("User-Agent", c.s.userAgent())
  1803. var body io.Reader = nil
  1804. body, err := googleapi.WithoutDataWrapper.JSONReader(c.pullbatchrequest)
  1805. if err != nil {
  1806. return nil, err
  1807. }
  1808. reqHeaders.Set("Content-Type", "application/json")
  1809. c.urlParams_.Set("alt", alt)
  1810. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1a/subscriptions/pullBatch")
  1811. urls += "?" + c.urlParams_.Encode()
  1812. req, _ := http.NewRequest("POST", urls, body)
  1813. req.Header = reqHeaders
  1814. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1815. }
  1816. // Do executes the "pubsub.subscriptions.pullBatch" call.
  1817. // Exactly one of *PullBatchResponse or error will be non-nil. Any
  1818. // non-2xx status code is an error. Response headers are in either
  1819. // *PullBatchResponse.ServerResponse.Header or (if a response was
  1820. // returned at all) in error.(*googleapi.Error).Header. Use
  1821. // googleapi.IsNotModified to check whether the returned error was
  1822. // because http.StatusNotModified was returned.
  1823. func (c *SubscriptionsPullBatchCall) Do(opts ...googleapi.CallOption) (*PullBatchResponse, error) {
  1824. gensupport.SetOptions(c.urlParams_, opts...)
  1825. res, err := c.doRequest("json")
  1826. if res != nil && res.StatusCode == http.StatusNotModified {
  1827. if res.Body != nil {
  1828. res.Body.Close()
  1829. }
  1830. return nil, &googleapi.Error{
  1831. Code: res.StatusCode,
  1832. Header: res.Header,
  1833. }
  1834. }
  1835. if err != nil {
  1836. return nil, err
  1837. }
  1838. defer googleapi.CloseBody(res)
  1839. if err := googleapi.CheckResponse(res); err != nil {
  1840. return nil, err
  1841. }
  1842. ret := &PullBatchResponse{
  1843. ServerResponse: googleapi.ServerResponse{
  1844. Header: res.Header,
  1845. HTTPStatusCode: res.StatusCode,
  1846. },
  1847. }
  1848. target := &ret
  1849. if err := gensupport.DecodeResponse(target, res); err != nil {
  1850. return nil, err
  1851. }
  1852. return ret, nil
  1853. // {
  1854. // "description": "Pulls messages from the server. Returns an empty list if there are no\nmessages available in the backlog. The system is free to return UNAVAILABLE\nif there are too many pull requests outstanding for the given subscription.",
  1855. // "flatPath": "v1beta1a/subscriptions/pullBatch",
  1856. // "httpMethod": "POST",
  1857. // "id": "pubsub.subscriptions.pullBatch",
  1858. // "parameterOrder": [],
  1859. // "parameters": {},
  1860. // "path": "v1beta1a/subscriptions/pullBatch",
  1861. // "request": {
  1862. // "$ref": "PullBatchRequest"
  1863. // },
  1864. // "response": {
  1865. // "$ref": "PullBatchResponse"
  1866. // },
  1867. // "scopes": [
  1868. // "https://www.googleapis.com/auth/cloud-platform",
  1869. // "https://www.googleapis.com/auth/pubsub"
  1870. // ]
  1871. // }
  1872. }
  1873. // method id "pubsub.topics.create":
  1874. type TopicsCreateCall struct {
  1875. s *Service
  1876. topic *Topic
  1877. urlParams_ gensupport.URLParams
  1878. ctx_ context.Context
  1879. header_ http.Header
  1880. }
  1881. // Create: Creates the given topic with the given name.
  1882. func (r *TopicsService) Create(topic *Topic) *TopicsCreateCall {
  1883. c := &TopicsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1884. c.topic = topic
  1885. return c
  1886. }
  1887. // Fields allows partial responses to be retrieved. See
  1888. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1889. // for more information.
  1890. func (c *TopicsCreateCall) Fields(s ...googleapi.Field) *TopicsCreateCall {
  1891. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1892. return c
  1893. }
  1894. // Context sets the context to be used in this call's Do method. Any
  1895. // pending HTTP request will be aborted if the provided context is
  1896. // canceled.
  1897. func (c *TopicsCreateCall) Context(ctx context.Context) *TopicsCreateCall {
  1898. c.ctx_ = ctx
  1899. return c
  1900. }
  1901. // Header returns an http.Header that can be modified by the caller to
  1902. // add HTTP headers to the request.
  1903. func (c *TopicsCreateCall) Header() http.Header {
  1904. if c.header_ == nil {
  1905. c.header_ = make(http.Header)
  1906. }
  1907. return c.header_
  1908. }
  1909. func (c *TopicsCreateCall) doRequest(alt string) (*http.Response, error) {
  1910. reqHeaders := make(http.Header)
  1911. for k, v := range c.header_ {
  1912. reqHeaders[k] = v
  1913. }
  1914. reqHeaders.Set("User-Agent", c.s.userAgent())
  1915. var body io.Reader = nil
  1916. body, err := googleapi.WithoutDataWrapper.JSONReader(c.topic)
  1917. if err != nil {
  1918. return nil, err
  1919. }
  1920. reqHeaders.Set("Content-Type", "application/json")
  1921. c.urlParams_.Set("alt", alt)
  1922. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1a/topics")
  1923. urls += "?" + c.urlParams_.Encode()
  1924. req, _ := http.NewRequest("POST", urls, body)
  1925. req.Header = reqHeaders
  1926. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1927. }
  1928. // Do executes the "pubsub.topics.create" call.
  1929. // Exactly one of *Topic or error will be non-nil. Any non-2xx status
  1930. // code is an error. Response headers are in either
  1931. // *Topic.ServerResponse.Header or (if a response was returned at all)
  1932. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1933. // check whether the returned error was because http.StatusNotModified
  1934. // was returned.
  1935. func (c *TopicsCreateCall) Do(opts ...googleapi.CallOption) (*Topic, error) {
  1936. gensupport.SetOptions(c.urlParams_, opts...)
  1937. res, err := c.doRequest("json")
  1938. if res != nil && res.StatusCode == http.StatusNotModified {
  1939. if res.Body != nil {
  1940. res.Body.Close()
  1941. }
  1942. return nil, &googleapi.Error{
  1943. Code: res.StatusCode,
  1944. Header: res.Header,
  1945. }
  1946. }
  1947. if err != nil {
  1948. return nil, err
  1949. }
  1950. defer googleapi.CloseBody(res)
  1951. if err := googleapi.CheckResponse(res); err != nil {
  1952. return nil, err
  1953. }
  1954. ret := &Topic{
  1955. ServerResponse: googleapi.ServerResponse{
  1956. Header: res.Header,
  1957. HTTPStatusCode: res.StatusCode,
  1958. },
  1959. }
  1960. target := &ret
  1961. if err := gensupport.DecodeResponse(target, res); err != nil {
  1962. return nil, err
  1963. }
  1964. return ret, nil
  1965. // {
  1966. // "description": "Creates the given topic with the given name.",
  1967. // "flatPath": "v1beta1a/topics",
  1968. // "httpMethod": "POST",
  1969. // "id": "pubsub.topics.create",
  1970. // "parameterOrder": [],
  1971. // "parameters": {},
  1972. // "path": "v1beta1a/topics",
  1973. // "request": {
  1974. // "$ref": "Topic"
  1975. // },
  1976. // "response": {
  1977. // "$ref": "Topic"
  1978. // },
  1979. // "scopes": [
  1980. // "https://www.googleapis.com/auth/cloud-platform",
  1981. // "https://www.googleapis.com/auth/pubsub"
  1982. // ]
  1983. // }
  1984. }
  1985. // method id "pubsub.topics.delete":
  1986. type TopicsDeleteCall struct {
  1987. s *Service
  1988. topic string
  1989. urlParams_ gensupport.URLParams
  1990. ctx_ context.Context
  1991. header_ http.Header
  1992. }
  1993. // Delete: Deletes the topic with the given name. Returns NOT_FOUND if
  1994. // the topic does
  1995. // not exist. After a topic is deleted, a new topic may be created with
  1996. // the
  1997. // same name.
  1998. func (r *TopicsService) Delete(topic string) *TopicsDeleteCall {
  1999. c := &TopicsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2000. c.topic = topic
  2001. return c
  2002. }
  2003. // Fields allows partial responses to be retrieved. See
  2004. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2005. // for more information.
  2006. func (c *TopicsDeleteCall) Fields(s ...googleapi.Field) *TopicsDeleteCall {
  2007. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2008. return c
  2009. }
  2010. // Context sets the context to be used in this call's Do method. Any
  2011. // pending HTTP request will be aborted if the provided context is
  2012. // canceled.
  2013. func (c *TopicsDeleteCall) Context(ctx context.Context) *TopicsDeleteCall {
  2014. c.ctx_ = ctx
  2015. return c
  2016. }
  2017. // Header returns an http.Header that can be modified by the caller to
  2018. // add HTTP headers to the request.
  2019. func (c *TopicsDeleteCall) Header() http.Header {
  2020. if c.header_ == nil {
  2021. c.header_ = make(http.Header)
  2022. }
  2023. return c.header_
  2024. }
  2025. func (c *TopicsDeleteCall) doRequest(alt string) (*http.Response, error) {
  2026. reqHeaders := make(http.Header)
  2027. for k, v := range c.header_ {
  2028. reqHeaders[k] = v
  2029. }
  2030. reqHeaders.Set("User-Agent", c.s.userAgent())
  2031. var body io.Reader = nil
  2032. c.urlParams_.Set("alt", alt)
  2033. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1a/topics/{+topic}")
  2034. urls += "?" + c.urlParams_.Encode()
  2035. req, _ := http.NewRequest("DELETE", urls, body)
  2036. req.Header = reqHeaders
  2037. googleapi.Expand(req.URL, map[string]string{
  2038. "topic": c.topic,
  2039. })
  2040. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2041. }
  2042. // Do executes the "pubsub.topics.delete" call.
  2043. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  2044. // code is an error. Response headers are in either
  2045. // *Empty.ServerResponse.Header or (if a response was returned at all)
  2046. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2047. // check whether the returned error was because http.StatusNotModified
  2048. // was returned.
  2049. func (c *TopicsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  2050. gensupport.SetOptions(c.urlParams_, opts...)
  2051. res, err := c.doRequest("json")
  2052. if res != nil && res.StatusCode == http.StatusNotModified {
  2053. if res.Body != nil {
  2054. res.Body.Close()
  2055. }
  2056. return nil, &googleapi.Error{
  2057. Code: res.StatusCode,
  2058. Header: res.Header,
  2059. }
  2060. }
  2061. if err != nil {
  2062. return nil, err
  2063. }
  2064. defer googleapi.CloseBody(res)
  2065. if err := googleapi.CheckResponse(res); err != nil {
  2066. return nil, err
  2067. }
  2068. ret := &Empty{
  2069. ServerResponse: googleapi.ServerResponse{
  2070. Header: res.Header,
  2071. HTTPStatusCode: res.StatusCode,
  2072. },
  2073. }
  2074. target := &ret
  2075. if err := gensupport.DecodeResponse(target, res); err != nil {
  2076. return nil, err
  2077. }
  2078. return ret, nil
  2079. // {
  2080. // "description": "Deletes the topic with the given name. Returns NOT_FOUND if the topic does\nnot exist. After a topic is deleted, a new topic may be created with the\nsame name.",
  2081. // "flatPath": "v1beta1a/topics/{topicsId}",
  2082. // "httpMethod": "DELETE",
  2083. // "id": "pubsub.topics.delete",
  2084. // "parameterOrder": [
  2085. // "topic"
  2086. // ],
  2087. // "parameters": {
  2088. // "topic": {
  2089. // "description": "Name of the topic to delete.",
  2090. // "location": "path",
  2091. // "pattern": "^.+$",
  2092. // "required": true,
  2093. // "type": "string"
  2094. // }
  2095. // },
  2096. // "path": "v1beta1a/topics/{+topic}",
  2097. // "response": {
  2098. // "$ref": "Empty"
  2099. // },
  2100. // "scopes": [
  2101. // "https://www.googleapis.com/auth/cloud-platform",
  2102. // "https://www.googleapis.com/auth/pubsub"
  2103. // ]
  2104. // }
  2105. }
  2106. // method id "pubsub.topics.get":
  2107. type TopicsGetCall struct {
  2108. s *Service
  2109. topic string
  2110. urlParams_ gensupport.URLParams
  2111. ifNoneMatch_ string
  2112. ctx_ context.Context
  2113. header_ http.Header
  2114. }
  2115. // Get: Gets the configuration of a topic. Since the topic only has the
  2116. // name
  2117. // attribute, this method is only useful to check the existence of a
  2118. // topic.
  2119. // If other attributes are added in the future, they will be returned
  2120. // here.
  2121. func (r *TopicsService) Get(topic string) *TopicsGetCall {
  2122. c := &TopicsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2123. c.topic = topic
  2124. return c
  2125. }
  2126. // Fields allows partial responses to be retrieved. See
  2127. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2128. // for more information.
  2129. func (c *TopicsGetCall) Fields(s ...googleapi.Field) *TopicsGetCall {
  2130. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2131. return c
  2132. }
  2133. // IfNoneMatch sets the optional parameter which makes the operation
  2134. // fail if the object's ETag matches the given value. This is useful for
  2135. // getting updates only after the object has changed since the last
  2136. // request. Use googleapi.IsNotModified to check whether the response
  2137. // error from Do is the result of In-None-Match.
  2138. func (c *TopicsGetCall) IfNoneMatch(entityTag string) *TopicsGetCall {
  2139. c.ifNoneMatch_ = entityTag
  2140. return c
  2141. }
  2142. // Context sets the context to be used in this call's Do method. Any
  2143. // pending HTTP request will be aborted if the provided context is
  2144. // canceled.
  2145. func (c *TopicsGetCall) Context(ctx context.Context) *TopicsGetCall {
  2146. c.ctx_ = ctx
  2147. return c
  2148. }
  2149. // Header returns an http.Header that can be modified by the caller to
  2150. // add HTTP headers to the request.
  2151. func (c *TopicsGetCall) Header() http.Header {
  2152. if c.header_ == nil {
  2153. c.header_ = make(http.Header)
  2154. }
  2155. return c.header_
  2156. }
  2157. func (c *TopicsGetCall) doRequest(alt string) (*http.Response, error) {
  2158. reqHeaders := make(http.Header)
  2159. for k, v := range c.header_ {
  2160. reqHeaders[k] = v
  2161. }
  2162. reqHeaders.Set("User-Agent", c.s.userAgent())
  2163. if c.ifNoneMatch_ != "" {
  2164. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  2165. }
  2166. var body io.Reader = nil
  2167. c.urlParams_.Set("alt", alt)
  2168. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1a/topics/{+topic}")
  2169. urls += "?" + c.urlParams_.Encode()
  2170. req, _ := http.NewRequest("GET", urls, body)
  2171. req.Header = reqHeaders
  2172. googleapi.Expand(req.URL, map[string]string{
  2173. "topic": c.topic,
  2174. })
  2175. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2176. }
  2177. // Do executes the "pubsub.topics.get" call.
  2178. // Exactly one of *Topic or error will be non-nil. Any non-2xx status
  2179. // code is an error. Response headers are in either
  2180. // *Topic.ServerResponse.Header or (if a response was returned at all)
  2181. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2182. // check whether the returned error was because http.StatusNotModified
  2183. // was returned.
  2184. func (c *TopicsGetCall) Do(opts ...googleapi.CallOption) (*Topic, error) {
  2185. gensupport.SetOptions(c.urlParams_, opts...)
  2186. res, err := c.doRequest("json")
  2187. if res != nil && res.StatusCode == http.StatusNotModified {
  2188. if res.Body != nil {
  2189. res.Body.Close()
  2190. }
  2191. return nil, &googleapi.Error{
  2192. Code: res.StatusCode,
  2193. Header: res.Header,
  2194. }
  2195. }
  2196. if err != nil {
  2197. return nil, err
  2198. }
  2199. defer googleapi.CloseBody(res)
  2200. if err := googleapi.CheckResponse(res); err != nil {
  2201. return nil, err
  2202. }
  2203. ret := &Topic{
  2204. ServerResponse: googleapi.ServerResponse{
  2205. Header: res.Header,
  2206. HTTPStatusCode: res.StatusCode,
  2207. },
  2208. }
  2209. target := &ret
  2210. if err := gensupport.DecodeResponse(target, res); err != nil {
  2211. return nil, err
  2212. }
  2213. return ret, nil
  2214. // {
  2215. // "description": "Gets the configuration of a topic. Since the topic only has the name\nattribute, this method is only useful to check the existence of a topic.\nIf other attributes are added in the future, they will be returned here.",
  2216. // "flatPath": "v1beta1a/topics/{topicsId}",
  2217. // "httpMethod": "GET",
  2218. // "id": "pubsub.topics.get",
  2219. // "parameterOrder": [
  2220. // "topic"
  2221. // ],
  2222. // "parameters": {
  2223. // "topic": {
  2224. // "description": "The name of the topic to get.",
  2225. // "location": "path",
  2226. // "pattern": "^.+$",
  2227. // "required": true,
  2228. // "type": "string"
  2229. // }
  2230. // },
  2231. // "path": "v1beta1a/topics/{+topic}",
  2232. // "response": {
  2233. // "$ref": "Topic"
  2234. // },
  2235. // "scopes": [
  2236. // "https://www.googleapis.com/auth/cloud-platform",
  2237. // "https://www.googleapis.com/auth/pubsub"
  2238. // ]
  2239. // }
  2240. }
  2241. // method id "pubsub.topics.list":
  2242. type TopicsListCall struct {
  2243. s *Service
  2244. urlParams_ gensupport.URLParams
  2245. ifNoneMatch_ string
  2246. ctx_ context.Context
  2247. header_ http.Header
  2248. }
  2249. // List: Lists matching topics.
  2250. func (r *TopicsService) List() *TopicsListCall {
  2251. c := &TopicsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2252. return c
  2253. }
  2254. // MaxResults sets the optional parameter "maxResults": Maximum number
  2255. // of topics to return.
  2256. func (c *TopicsListCall) MaxResults(maxResults int64) *TopicsListCall {
  2257. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  2258. return c
  2259. }
  2260. // PageToken sets the optional parameter "pageToken": The value obtained
  2261. // in the last <code>ListTopicsResponse</code>
  2262. // for continuation.
  2263. func (c *TopicsListCall) PageToken(pageToken string) *TopicsListCall {
  2264. c.urlParams_.Set("pageToken", pageToken)
  2265. return c
  2266. }
  2267. // Query sets the optional parameter "query": A valid label query
  2268. // expression.
  2269. func (c *TopicsListCall) Query(query string) *TopicsListCall {
  2270. c.urlParams_.Set("query", query)
  2271. return c
  2272. }
  2273. // Fields allows partial responses to be retrieved. See
  2274. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2275. // for more information.
  2276. func (c *TopicsListCall) Fields(s ...googleapi.Field) *TopicsListCall {
  2277. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2278. return c
  2279. }
  2280. // IfNoneMatch sets the optional parameter which makes the operation
  2281. // fail if the object's ETag matches the given value. This is useful for
  2282. // getting updates only after the object has changed since the last
  2283. // request. Use googleapi.IsNotModified to check whether the response
  2284. // error from Do is the result of In-None-Match.
  2285. func (c *TopicsListCall) IfNoneMatch(entityTag string) *TopicsListCall {
  2286. c.ifNoneMatch_ = entityTag
  2287. return c
  2288. }
  2289. // Context sets the context to be used in this call's Do method. Any
  2290. // pending HTTP request will be aborted if the provided context is
  2291. // canceled.
  2292. func (c *TopicsListCall) Context(ctx context.Context) *TopicsListCall {
  2293. c.ctx_ = ctx
  2294. return c
  2295. }
  2296. // Header returns an http.Header that can be modified by the caller to
  2297. // add HTTP headers to the request.
  2298. func (c *TopicsListCall) Header() http.Header {
  2299. if c.header_ == nil {
  2300. c.header_ = make(http.Header)
  2301. }
  2302. return c.header_
  2303. }
  2304. func (c *TopicsListCall) doRequest(alt string) (*http.Response, error) {
  2305. reqHeaders := make(http.Header)
  2306. for k, v := range c.header_ {
  2307. reqHeaders[k] = v
  2308. }
  2309. reqHeaders.Set("User-Agent", c.s.userAgent())
  2310. if c.ifNoneMatch_ != "" {
  2311. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  2312. }
  2313. var body io.Reader = nil
  2314. c.urlParams_.Set("alt", alt)
  2315. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1a/topics")
  2316. urls += "?" + c.urlParams_.Encode()
  2317. req, _ := http.NewRequest("GET", urls, body)
  2318. req.Header = reqHeaders
  2319. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2320. }
  2321. // Do executes the "pubsub.topics.list" call.
  2322. // Exactly one of *ListTopicsResponse or error will be non-nil. Any
  2323. // non-2xx status code is an error. Response headers are in either
  2324. // *ListTopicsResponse.ServerResponse.Header or (if a response was
  2325. // returned at all) in error.(*googleapi.Error).Header. Use
  2326. // googleapi.IsNotModified to check whether the returned error was
  2327. // because http.StatusNotModified was returned.
  2328. func (c *TopicsListCall) Do(opts ...googleapi.CallOption) (*ListTopicsResponse, error) {
  2329. gensupport.SetOptions(c.urlParams_, opts...)
  2330. res, err := c.doRequest("json")
  2331. if res != nil && res.StatusCode == http.StatusNotModified {
  2332. if res.Body != nil {
  2333. res.Body.Close()
  2334. }
  2335. return nil, &googleapi.Error{
  2336. Code: res.StatusCode,
  2337. Header: res.Header,
  2338. }
  2339. }
  2340. if err != nil {
  2341. return nil, err
  2342. }
  2343. defer googleapi.CloseBody(res)
  2344. if err := googleapi.CheckResponse(res); err != nil {
  2345. return nil, err
  2346. }
  2347. ret := &ListTopicsResponse{
  2348. ServerResponse: googleapi.ServerResponse{
  2349. Header: res.Header,
  2350. HTTPStatusCode: res.StatusCode,
  2351. },
  2352. }
  2353. target := &ret
  2354. if err := gensupport.DecodeResponse(target, res); err != nil {
  2355. return nil, err
  2356. }
  2357. return ret, nil
  2358. // {
  2359. // "description": "Lists matching topics.",
  2360. // "flatPath": "v1beta1a/topics",
  2361. // "httpMethod": "GET",
  2362. // "id": "pubsub.topics.list",
  2363. // "parameterOrder": [],
  2364. // "parameters": {
  2365. // "maxResults": {
  2366. // "description": "Maximum number of topics to return.",
  2367. // "format": "int32",
  2368. // "location": "query",
  2369. // "type": "integer"
  2370. // },
  2371. // "pageToken": {
  2372. // "description": "The value obtained in the last \u003ccode\u003eListTopicsResponse\u003c/code\u003e\nfor continuation.",
  2373. // "location": "query",
  2374. // "type": "string"
  2375. // },
  2376. // "query": {
  2377. // "description": "A valid label query expression.",
  2378. // "location": "query",
  2379. // "type": "string"
  2380. // }
  2381. // },
  2382. // "path": "v1beta1a/topics",
  2383. // "response": {
  2384. // "$ref": "ListTopicsResponse"
  2385. // },
  2386. // "scopes": [
  2387. // "https://www.googleapis.com/auth/cloud-platform",
  2388. // "https://www.googleapis.com/auth/pubsub"
  2389. // ]
  2390. // }
  2391. }
  2392. // Pages invokes f for each page of results.
  2393. // A non-nil error returned from f will halt the iteration.
  2394. // The provided context supersedes any context provided to the Context method.
  2395. func (c *TopicsListCall) Pages(ctx context.Context, f func(*ListTopicsResponse) error) error {
  2396. c.ctx_ = ctx
  2397. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  2398. for {
  2399. x, err := c.Do()
  2400. if err != nil {
  2401. return err
  2402. }
  2403. if err := f(x); err != nil {
  2404. return err
  2405. }
  2406. if x.NextPageToken == "" {
  2407. return nil
  2408. }
  2409. c.PageToken(x.NextPageToken)
  2410. }
  2411. }
  2412. // method id "pubsub.topics.publish":
  2413. type TopicsPublishCall struct {
  2414. s *Service
  2415. publishrequest *PublishRequest
  2416. urlParams_ gensupport.URLParams
  2417. ctx_ context.Context
  2418. header_ http.Header
  2419. }
  2420. // Publish: Adds a message to the topic. Returns NOT_FOUND if the topic
  2421. // does not
  2422. // exist.
  2423. func (r *TopicsService) Publish(publishrequest *PublishRequest) *TopicsPublishCall {
  2424. c := &TopicsPublishCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2425. c.publishrequest = publishrequest
  2426. return c
  2427. }
  2428. // Fields allows partial responses to be retrieved. See
  2429. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2430. // for more information.
  2431. func (c *TopicsPublishCall) Fields(s ...googleapi.Field) *TopicsPublishCall {
  2432. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2433. return c
  2434. }
  2435. // Context sets the context to be used in this call's Do method. Any
  2436. // pending HTTP request will be aborted if the provided context is
  2437. // canceled.
  2438. func (c *TopicsPublishCall) Context(ctx context.Context) *TopicsPublishCall {
  2439. c.ctx_ = ctx
  2440. return c
  2441. }
  2442. // Header returns an http.Header that can be modified by the caller to
  2443. // add HTTP headers to the request.
  2444. func (c *TopicsPublishCall) Header() http.Header {
  2445. if c.header_ == nil {
  2446. c.header_ = make(http.Header)
  2447. }
  2448. return c.header_
  2449. }
  2450. func (c *TopicsPublishCall) doRequest(alt string) (*http.Response, error) {
  2451. reqHeaders := make(http.Header)
  2452. for k, v := range c.header_ {
  2453. reqHeaders[k] = v
  2454. }
  2455. reqHeaders.Set("User-Agent", c.s.userAgent())
  2456. var body io.Reader = nil
  2457. body, err := googleapi.WithoutDataWrapper.JSONReader(c.publishrequest)
  2458. if err != nil {
  2459. return nil, err
  2460. }
  2461. reqHeaders.Set("Content-Type", "application/json")
  2462. c.urlParams_.Set("alt", alt)
  2463. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1a/topics/publish")
  2464. urls += "?" + c.urlParams_.Encode()
  2465. req, _ := http.NewRequest("POST", urls, body)
  2466. req.Header = reqHeaders
  2467. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2468. }
  2469. // Do executes the "pubsub.topics.publish" call.
  2470. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  2471. // code is an error. Response headers are in either
  2472. // *Empty.ServerResponse.Header or (if a response was returned at all)
  2473. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2474. // check whether the returned error was because http.StatusNotModified
  2475. // was returned.
  2476. func (c *TopicsPublishCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  2477. gensupport.SetOptions(c.urlParams_, opts...)
  2478. res, err := c.doRequest("json")
  2479. if res != nil && res.StatusCode == http.StatusNotModified {
  2480. if res.Body != nil {
  2481. res.Body.Close()
  2482. }
  2483. return nil, &googleapi.Error{
  2484. Code: res.StatusCode,
  2485. Header: res.Header,
  2486. }
  2487. }
  2488. if err != nil {
  2489. return nil, err
  2490. }
  2491. defer googleapi.CloseBody(res)
  2492. if err := googleapi.CheckResponse(res); err != nil {
  2493. return nil, err
  2494. }
  2495. ret := &Empty{
  2496. ServerResponse: googleapi.ServerResponse{
  2497. Header: res.Header,
  2498. HTTPStatusCode: res.StatusCode,
  2499. },
  2500. }
  2501. target := &ret
  2502. if err := gensupport.DecodeResponse(target, res); err != nil {
  2503. return nil, err
  2504. }
  2505. return ret, nil
  2506. // {
  2507. // "description": "Adds a message to the topic. Returns NOT_FOUND if the topic does not\nexist.",
  2508. // "flatPath": "v1beta1a/topics/publish",
  2509. // "httpMethod": "POST",
  2510. // "id": "pubsub.topics.publish",
  2511. // "parameterOrder": [],
  2512. // "parameters": {},
  2513. // "path": "v1beta1a/topics/publish",
  2514. // "request": {
  2515. // "$ref": "PublishRequest"
  2516. // },
  2517. // "response": {
  2518. // "$ref": "Empty"
  2519. // },
  2520. // "scopes": [
  2521. // "https://www.googleapis.com/auth/cloud-platform",
  2522. // "https://www.googleapis.com/auth/pubsub"
  2523. // ]
  2524. // }
  2525. }
  2526. // method id "pubsub.topics.publishBatch":
  2527. type TopicsPublishBatchCall struct {
  2528. s *Service
  2529. publishbatchrequest *PublishBatchRequest
  2530. urlParams_ gensupport.URLParams
  2531. ctx_ context.Context
  2532. header_ http.Header
  2533. }
  2534. // PublishBatch: Adds one or more messages to the topic. Returns
  2535. // NOT_FOUND if the topic does
  2536. // not exist.
  2537. func (r *TopicsService) PublishBatch(publishbatchrequest *PublishBatchRequest) *TopicsPublishBatchCall {
  2538. c := &TopicsPublishBatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2539. c.publishbatchrequest = publishbatchrequest
  2540. return c
  2541. }
  2542. // Fields allows partial responses to be retrieved. See
  2543. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2544. // for more information.
  2545. func (c *TopicsPublishBatchCall) Fields(s ...googleapi.Field) *TopicsPublishBatchCall {
  2546. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2547. return c
  2548. }
  2549. // Context sets the context to be used in this call's Do method. Any
  2550. // pending HTTP request will be aborted if the provided context is
  2551. // canceled.
  2552. func (c *TopicsPublishBatchCall) Context(ctx context.Context) *TopicsPublishBatchCall {
  2553. c.ctx_ = ctx
  2554. return c
  2555. }
  2556. // Header returns an http.Header that can be modified by the caller to
  2557. // add HTTP headers to the request.
  2558. func (c *TopicsPublishBatchCall) Header() http.Header {
  2559. if c.header_ == nil {
  2560. c.header_ = make(http.Header)
  2561. }
  2562. return c.header_
  2563. }
  2564. func (c *TopicsPublishBatchCall) doRequest(alt string) (*http.Response, error) {
  2565. reqHeaders := make(http.Header)
  2566. for k, v := range c.header_ {
  2567. reqHeaders[k] = v
  2568. }
  2569. reqHeaders.Set("User-Agent", c.s.userAgent())
  2570. var body io.Reader = nil
  2571. body, err := googleapi.WithoutDataWrapper.JSONReader(c.publishbatchrequest)
  2572. if err != nil {
  2573. return nil, err
  2574. }
  2575. reqHeaders.Set("Content-Type", "application/json")
  2576. c.urlParams_.Set("alt", alt)
  2577. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1a/topics/publishBatch")
  2578. urls += "?" + c.urlParams_.Encode()
  2579. req, _ := http.NewRequest("POST", urls, body)
  2580. req.Header = reqHeaders
  2581. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2582. }
  2583. // Do executes the "pubsub.topics.publishBatch" call.
  2584. // Exactly one of *PublishBatchResponse or error will be non-nil. Any
  2585. // non-2xx status code is an error. Response headers are in either
  2586. // *PublishBatchResponse.ServerResponse.Header or (if a response was
  2587. // returned at all) in error.(*googleapi.Error).Header. Use
  2588. // googleapi.IsNotModified to check whether the returned error was
  2589. // because http.StatusNotModified was returned.
  2590. func (c *TopicsPublishBatchCall) Do(opts ...googleapi.CallOption) (*PublishBatchResponse, error) {
  2591. gensupport.SetOptions(c.urlParams_, opts...)
  2592. res, err := c.doRequest("json")
  2593. if res != nil && res.StatusCode == http.StatusNotModified {
  2594. if res.Body != nil {
  2595. res.Body.Close()
  2596. }
  2597. return nil, &googleapi.Error{
  2598. Code: res.StatusCode,
  2599. Header: res.Header,
  2600. }
  2601. }
  2602. if err != nil {
  2603. return nil, err
  2604. }
  2605. defer googleapi.CloseBody(res)
  2606. if err := googleapi.CheckResponse(res); err != nil {
  2607. return nil, err
  2608. }
  2609. ret := &PublishBatchResponse{
  2610. ServerResponse: googleapi.ServerResponse{
  2611. Header: res.Header,
  2612. HTTPStatusCode: res.StatusCode,
  2613. },
  2614. }
  2615. target := &ret
  2616. if err := gensupport.DecodeResponse(target, res); err != nil {
  2617. return nil, err
  2618. }
  2619. return ret, nil
  2620. // {
  2621. // "description": "Adds one or more messages to the topic. Returns NOT_FOUND if the topic does\nnot exist.",
  2622. // "flatPath": "v1beta1a/topics/publishBatch",
  2623. // "httpMethod": "POST",
  2624. // "id": "pubsub.topics.publishBatch",
  2625. // "parameterOrder": [],
  2626. // "parameters": {},
  2627. // "path": "v1beta1a/topics/publishBatch",
  2628. // "request": {
  2629. // "$ref": "PublishBatchRequest"
  2630. // },
  2631. // "response": {
  2632. // "$ref": "PublishBatchResponse"
  2633. // },
  2634. // "scopes": [
  2635. // "https://www.googleapis.com/auth/cloud-platform",
  2636. // "https://www.googleapis.com/auth/pubsub"
  2637. // ]
  2638. // }
  2639. }