pubsub-gen.go 83 KB

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