pubsub-gen.go 119 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383
  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/v1beta2"
  8. // ...
  9. // pubsubService, err := pubsub.New(oauthHttpClient)
  10. package pubsub // import "google.golang.org/api/pubsub/v1beta2"
  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:v1beta2"
  41. const apiName = "pubsub"
  42. const apiVersion = "v1beta2"
  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.Projects = NewProjectsService(s)
  57. return s, nil
  58. }
  59. type Service struct {
  60. client *http.Client
  61. BasePath string // API endpoint base URL
  62. UserAgent string // optional additional User-Agent fragment
  63. Projects *ProjectsService
  64. }
  65. func (s *Service) userAgent() string {
  66. if s.UserAgent == "" {
  67. return googleapi.UserAgent
  68. }
  69. return googleapi.UserAgent + " " + s.UserAgent
  70. }
  71. func NewProjectsService(s *Service) *ProjectsService {
  72. rs := &ProjectsService{s: s}
  73. rs.Subscriptions = NewProjectsSubscriptionsService(s)
  74. rs.Topics = NewProjectsTopicsService(s)
  75. return rs
  76. }
  77. type ProjectsService struct {
  78. s *Service
  79. Subscriptions *ProjectsSubscriptionsService
  80. Topics *ProjectsTopicsService
  81. }
  82. func NewProjectsSubscriptionsService(s *Service) *ProjectsSubscriptionsService {
  83. rs := &ProjectsSubscriptionsService{s: s}
  84. return rs
  85. }
  86. type ProjectsSubscriptionsService struct {
  87. s *Service
  88. }
  89. func NewProjectsTopicsService(s *Service) *ProjectsTopicsService {
  90. rs := &ProjectsTopicsService{s: s}
  91. rs.Subscriptions = NewProjectsTopicsSubscriptionsService(s)
  92. return rs
  93. }
  94. type ProjectsTopicsService struct {
  95. s *Service
  96. Subscriptions *ProjectsTopicsSubscriptionsService
  97. }
  98. func NewProjectsTopicsSubscriptionsService(s *Service) *ProjectsTopicsSubscriptionsService {
  99. rs := &ProjectsTopicsSubscriptionsService{s: s}
  100. return rs
  101. }
  102. type ProjectsTopicsSubscriptionsService struct {
  103. s *Service
  104. }
  105. // AcknowledgeRequest: Request for the Acknowledge method.
  106. type AcknowledgeRequest struct {
  107. // AckIds: The acknowledgment ID for the messages being acknowledged
  108. // that was returned by the Pub/Sub system in the `Pull` response. Must
  109. // not be empty.
  110. AckIds []string `json:"ackIds,omitempty"`
  111. // ForceSendFields is a list of field names (e.g. "AckIds") to
  112. // unconditionally include in API requests. By default, fields with
  113. // empty values are omitted from API requests. However, any non-pointer,
  114. // non-interface field appearing in ForceSendFields will be sent to the
  115. // server regardless of whether the field is empty or not. This may be
  116. // used to include empty fields in Patch requests.
  117. ForceSendFields []string `json:"-"`
  118. }
  119. func (s *AcknowledgeRequest) MarshalJSON() ([]byte, error) {
  120. type noMethod AcknowledgeRequest
  121. raw := noMethod(*s)
  122. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  123. }
  124. // Binding: Associates `members` with a `role`.
  125. type Binding struct {
  126. // Members: Specifies the identities requesting access for a Cloud
  127. // Platform resource. `members` can have the following formats: *
  128. // `allUsers`: A special identifier that represents anyone who is on the
  129. // internet; with or without a Google account. *
  130. // `allAuthenticatedUsers`: A special identifier that represents anyone
  131. // who is authenticated with a Google account or a service account. *
  132. // `user:{emailid}`: An email address that represents a specific Google
  133. // account. For example, `alice@gmail.com` or `joe@example.com`. *
  134. // `serviceAccount:{emailid}`: An email address that represents a
  135. // service account. For example,
  136. // `my-other-app@appspot.gserviceaccount.com`. * `group:{emailid}`: An
  137. // email address that represents a Google group. For example,
  138. // `admins@example.com`. * `domain:{domain}`: A Google Apps domain name
  139. // that represents all the users of that domain. For example,
  140. // `google.com` or `example.com`.
  141. Members []string `json:"members,omitempty"`
  142. // Role: Role that is assigned to `members`. For example,
  143. // `roles/viewer`, `roles/editor`, or `roles/owner`. Required
  144. Role string `json:"role,omitempty"`
  145. // ForceSendFields is a list of field names (e.g. "Members") to
  146. // unconditionally include in API requests. By default, fields with
  147. // empty values are omitted from API requests. However, any non-pointer,
  148. // non-interface field appearing in ForceSendFields will be sent to the
  149. // server regardless of whether the field is empty or not. This may be
  150. // used to include empty fields in Patch requests.
  151. ForceSendFields []string `json:"-"`
  152. }
  153. func (s *Binding) MarshalJSON() ([]byte, error) {
  154. type noMethod Binding
  155. raw := noMethod(*s)
  156. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  157. }
  158. // Empty: A generic empty message that you can re-use to avoid defining
  159. // duplicated empty messages in your APIs. A typical example is to use
  160. // it as the request or the response type of an API method. For
  161. // instance: service Foo { rpc Bar(google.protobuf.Empty) returns
  162. // (google.protobuf.Empty); } The JSON representation for `Empty` is
  163. // empty JSON object `{}`.
  164. type Empty struct {
  165. // ServerResponse contains the HTTP response code and headers from the
  166. // server.
  167. googleapi.ServerResponse `json:"-"`
  168. }
  169. // ListSubscriptionsResponse: Response for the `ListSubscriptions`
  170. // method.
  171. type ListSubscriptionsResponse struct {
  172. // NextPageToken: If not empty, indicates that there may be more
  173. // subscriptions that match the request; this value should be passed in
  174. // a new `ListSubscriptionsRequest` to get more subscriptions.
  175. NextPageToken string `json:"nextPageToken,omitempty"`
  176. // Subscriptions: The subscriptions that match the request.
  177. Subscriptions []*Subscription `json:"subscriptions,omitempty"`
  178. // ServerResponse contains the HTTP response code and headers from the
  179. // server.
  180. googleapi.ServerResponse `json:"-"`
  181. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  182. // unconditionally include in API requests. By default, fields with
  183. // empty values are omitted from API requests. However, any non-pointer,
  184. // non-interface field appearing in ForceSendFields will be sent to the
  185. // server regardless of whether the field is empty or not. This may be
  186. // used to include empty fields in Patch requests.
  187. ForceSendFields []string `json:"-"`
  188. }
  189. func (s *ListSubscriptionsResponse) MarshalJSON() ([]byte, error) {
  190. type noMethod ListSubscriptionsResponse
  191. raw := noMethod(*s)
  192. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  193. }
  194. // ListTopicSubscriptionsResponse: Response for the
  195. // `ListTopicSubscriptions` method.
  196. type ListTopicSubscriptionsResponse struct {
  197. // NextPageToken: If not empty, indicates that there may be more
  198. // subscriptions that match the request; this value should be passed in
  199. // a new `ListTopicSubscriptionsRequest` to get more subscriptions.
  200. NextPageToken string `json:"nextPageToken,omitempty"`
  201. // Subscriptions: The names of the subscriptions that match the request.
  202. Subscriptions []string `json:"subscriptions,omitempty"`
  203. // ServerResponse contains the HTTP response code and headers from the
  204. // server.
  205. googleapi.ServerResponse `json:"-"`
  206. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  207. // unconditionally include in API requests. By default, fields with
  208. // empty values are omitted from API requests. However, any non-pointer,
  209. // non-interface field appearing in ForceSendFields will be sent to the
  210. // server regardless of whether the field is empty or not. This may be
  211. // used to include empty fields in Patch requests.
  212. ForceSendFields []string `json:"-"`
  213. }
  214. func (s *ListTopicSubscriptionsResponse) MarshalJSON() ([]byte, error) {
  215. type noMethod ListTopicSubscriptionsResponse
  216. raw := noMethod(*s)
  217. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  218. }
  219. // ListTopicsResponse: Response for the `ListTopics` method.
  220. type ListTopicsResponse struct {
  221. // NextPageToken: If not empty, indicates that there may be more topics
  222. // that match the request; this value should be passed in a new
  223. // `ListTopicsRequest`.
  224. NextPageToken string `json:"nextPageToken,omitempty"`
  225. // Topics: The resulting topics.
  226. Topics []*Topic `json:"topics,omitempty"`
  227. // ServerResponse contains the HTTP response code and headers from the
  228. // server.
  229. googleapi.ServerResponse `json:"-"`
  230. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  231. // unconditionally include in API requests. By default, fields with
  232. // empty values are omitted from API requests. However, any non-pointer,
  233. // non-interface field appearing in ForceSendFields will be sent to the
  234. // server regardless of whether the field is empty or not. This may be
  235. // used to include empty fields in Patch requests.
  236. ForceSendFields []string `json:"-"`
  237. }
  238. func (s *ListTopicsResponse) MarshalJSON() ([]byte, error) {
  239. type noMethod ListTopicsResponse
  240. raw := noMethod(*s)
  241. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  242. }
  243. // ModifyAckDeadlineRequest: Request for the ModifyAckDeadline method.
  244. type ModifyAckDeadlineRequest struct {
  245. // AckDeadlineSeconds: The new ack deadline with respect to the time
  246. // this request was sent to the Pub/Sub system. Must be >= 0. For
  247. // example, if the value is 10, the new ack deadline will expire 10
  248. // seconds after the `ModifyAckDeadline` call was made. Specifying zero
  249. // may immediately make the message available for another pull request.
  250. AckDeadlineSeconds int64 `json:"ackDeadlineSeconds,omitempty"`
  251. // AckId: The acknowledgment ID. Either this or ack_ids must be
  252. // populated, but not both.
  253. AckId string `json:"ackId,omitempty"`
  254. // AckIds: List of acknowledgment IDs.
  255. AckIds []string `json:"ackIds,omitempty"`
  256. // ForceSendFields is a list of field names (e.g. "AckDeadlineSeconds")
  257. // to unconditionally include in API requests. By default, fields with
  258. // empty values are omitted from API requests. However, any non-pointer,
  259. // non-interface field appearing in ForceSendFields will be sent to the
  260. // server regardless of whether the field is empty or not. This may be
  261. // used to include empty fields in Patch requests.
  262. ForceSendFields []string `json:"-"`
  263. }
  264. func (s *ModifyAckDeadlineRequest) MarshalJSON() ([]byte, error) {
  265. type noMethod ModifyAckDeadlineRequest
  266. raw := noMethod(*s)
  267. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  268. }
  269. // ModifyPushConfigRequest: Request for the ModifyPushConfig method.
  270. type ModifyPushConfigRequest struct {
  271. // PushConfig: The push configuration for future deliveries. An empty
  272. // `pushConfig` indicates that the Pub/Sub system should stop pushing
  273. // messages from the given subscription and allow messages to be pulled
  274. // and acknowledged - effectively pausing the subscription if `Pull` is
  275. // not called.
  276. PushConfig *PushConfig `json:"pushConfig,omitempty"`
  277. // ForceSendFields is a list of field names (e.g. "PushConfig") 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 *ModifyPushConfigRequest) MarshalJSON() ([]byte, error) {
  286. type noMethod ModifyPushConfigRequest
  287. raw := noMethod(*s)
  288. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  289. }
  290. // Policy: Defines an Identity and Access Management (IAM) policy. It is
  291. // used to specify access control policies for Cloud Platform resources.
  292. // A `Policy` consists of a list of `bindings`. A `Binding` binds a list
  293. // of `members` to a `role`, where the members can be user accounts,
  294. // Google groups, Google domains, and service accounts. A `role` is a
  295. // named list of permissions defined by IAM. **Example** { "bindings": [
  296. // { "role": "roles/owner", "members": [ "user:mike@example.com",
  297. // "group:admins@example.com", "domain:google.com",
  298. // "serviceAccount:my-other-app@appspot.gserviceaccount.com"] }, {
  299. // "role": "roles/viewer", "members": ["user:sean@example.com"] } ] }
  300. // For a description of IAM and its features, see the [IAM developer's
  301. // guide](https://cloud.google.com/iam).
  302. type Policy struct {
  303. // Bindings: Associates a list of `members` to a `role`. Multiple
  304. // `bindings` must not be specified for the same `role`. `bindings` with
  305. // no members will result in an error.
  306. Bindings []*Binding `json:"bindings,omitempty"`
  307. // Etag: Can be used to perform a read-modify-write.
  308. Etag string `json:"etag,omitempty"`
  309. // Version: Version of the `Policy`. The default version is 0.
  310. Version int64 `json:"version,omitempty"`
  311. // ServerResponse contains the HTTP response code and headers from the
  312. // server.
  313. googleapi.ServerResponse `json:"-"`
  314. // ForceSendFields is a list of field names (e.g. "Bindings") to
  315. // unconditionally include in API requests. By default, fields with
  316. // empty values are omitted from API requests. However, any non-pointer,
  317. // non-interface field appearing in ForceSendFields will be sent to the
  318. // server regardless of whether the field is empty or not. This may be
  319. // used to include empty fields in Patch requests.
  320. ForceSendFields []string `json:"-"`
  321. }
  322. func (s *Policy) MarshalJSON() ([]byte, error) {
  323. type noMethod Policy
  324. raw := noMethod(*s)
  325. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  326. }
  327. // PublishRequest: Request for the Publish method.
  328. type PublishRequest struct {
  329. // Messages: The messages to publish.
  330. Messages []*PubsubMessage `json:"messages,omitempty"`
  331. // ForceSendFields is a list of field names (e.g. "Messages") to
  332. // unconditionally include in API requests. By default, fields with
  333. // empty values are omitted from API requests. However, any non-pointer,
  334. // non-interface field appearing in ForceSendFields will be sent to the
  335. // server regardless of whether the field is empty or not. This may be
  336. // used to include empty fields in Patch requests.
  337. ForceSendFields []string `json:"-"`
  338. }
  339. func (s *PublishRequest) MarshalJSON() ([]byte, error) {
  340. type noMethod PublishRequest
  341. raw := noMethod(*s)
  342. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  343. }
  344. // PublishResponse: Response for the `Publish` method.
  345. type PublishResponse struct {
  346. // MessageIds: The server-assigned ID of each published message, in the
  347. // same order as the messages in the request. IDs are guaranteed to be
  348. // unique within the topic.
  349. MessageIds []string `json:"messageIds,omitempty"`
  350. // ServerResponse contains the HTTP response code and headers from the
  351. // server.
  352. googleapi.ServerResponse `json:"-"`
  353. // ForceSendFields is a list of field names (e.g. "MessageIds") to
  354. // unconditionally include in API requests. By default, fields with
  355. // empty values are omitted from API requests. However, any non-pointer,
  356. // non-interface field appearing in ForceSendFields will be sent to the
  357. // server regardless of whether the field is empty or not. This may be
  358. // used to include empty fields in Patch requests.
  359. ForceSendFields []string `json:"-"`
  360. }
  361. func (s *PublishResponse) MarshalJSON() ([]byte, error) {
  362. type noMethod PublishResponse
  363. raw := noMethod(*s)
  364. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  365. }
  366. // PubsubMessage: A message data and its attributes. The message payload
  367. // must not be empty; it must contain either a non-empty data field, or
  368. // at least one attribute.
  369. type PubsubMessage struct {
  370. // Attributes: Optional attributes for this message.
  371. Attributes map[string]string `json:"attributes,omitempty"`
  372. // Data: The message payload. For JSON requests, the value of this field
  373. // must be base64-encoded.
  374. Data string `json:"data,omitempty"`
  375. // MessageId: ID of this message, assigned by the server when the
  376. // message is published. Guaranteed to be unique within the topic. This
  377. // value may be read by a subscriber that receives a `PubsubMessage` via
  378. // a `Pull` call or a push delivery. It must not be populated by the
  379. // publisher in a `Publish` call.
  380. MessageId string `json:"messageId,omitempty"`
  381. // PublishTime: The time at which the message was published, populated
  382. // by the server when it receives the `Publish` call. It must not be
  383. // populated by the publisher in a `Publish` call.
  384. PublishTime string `json:"publishTime,omitempty"`
  385. // ForceSendFields is a list of field names (e.g. "Attributes") to
  386. // unconditionally include in API requests. By default, fields with
  387. // empty values are omitted from API requests. However, any non-pointer,
  388. // non-interface field appearing in ForceSendFields will be sent to the
  389. // server regardless of whether the field is empty or not. This may be
  390. // used to include empty fields in Patch requests.
  391. ForceSendFields []string `json:"-"`
  392. }
  393. func (s *PubsubMessage) MarshalJSON() ([]byte, error) {
  394. type noMethod PubsubMessage
  395. raw := noMethod(*s)
  396. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  397. }
  398. // PullRequest: Request for the `Pull` method.
  399. type PullRequest struct {
  400. // MaxMessages: The maximum number of messages returned for this
  401. // request. The Pub/Sub system may return fewer than the number
  402. // specified.
  403. MaxMessages int64 `json:"maxMessages,omitempty"`
  404. // ReturnImmediately: If this is specified as true the system will
  405. // respond immediately even if it is not able to return a message in the
  406. // `Pull` response. Otherwise the system is allowed to wait until at
  407. // least one message is available rather than returning no messages. The
  408. // client may cancel the request if it does not wish to wait any longer
  409. // for the response.
  410. ReturnImmediately bool `json:"returnImmediately,omitempty"`
  411. // ForceSendFields is a list of field names (e.g. "MaxMessages") to
  412. // unconditionally include in API requests. By default, fields with
  413. // empty values are omitted from API requests. However, any non-pointer,
  414. // non-interface field appearing in ForceSendFields will be sent to the
  415. // server regardless of whether the field is empty or not. This may be
  416. // used to include empty fields in Patch requests.
  417. ForceSendFields []string `json:"-"`
  418. }
  419. func (s *PullRequest) MarshalJSON() ([]byte, error) {
  420. type noMethod PullRequest
  421. raw := noMethod(*s)
  422. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  423. }
  424. // PullResponse: Response for the `Pull` method.
  425. type PullResponse struct {
  426. // ReceivedMessages: Received Pub/Sub messages. The Pub/Sub system will
  427. // return zero messages if there are no more available in the backlog.
  428. // The Pub/Sub system may return fewer than the `maxMessages` requested
  429. // even if there are more messages available in the backlog.
  430. ReceivedMessages []*ReceivedMessage `json:"receivedMessages,omitempty"`
  431. // ServerResponse contains the HTTP response code and headers from the
  432. // server.
  433. googleapi.ServerResponse `json:"-"`
  434. // ForceSendFields is a list of field names (e.g. "ReceivedMessages") to
  435. // unconditionally include in API requests. By default, fields with
  436. // empty values are omitted from API requests. However, any non-pointer,
  437. // non-interface field appearing in ForceSendFields will be sent to the
  438. // server regardless of whether the field is empty or not. This may be
  439. // used to include empty fields in Patch requests.
  440. ForceSendFields []string `json:"-"`
  441. }
  442. func (s *PullResponse) MarshalJSON() ([]byte, error) {
  443. type noMethod PullResponse
  444. raw := noMethod(*s)
  445. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  446. }
  447. // PushConfig: Configuration for a push delivery endpoint.
  448. type PushConfig struct {
  449. // Attributes: Endpoint configuration attributes. Every endpoint has a
  450. // set of API supported attributes that can be used to control different
  451. // aspects of the message delivery. The currently supported attribute is
  452. // `x-goog-version`, which you can use to change the format of the push
  453. // message. This attribute indicates the version of the data expected by
  454. // the endpoint. This controls the shape of the envelope (i.e. its
  455. // fields and metadata). The endpoint version is based on the version of
  456. // the Pub/Sub API. If not present during the `CreateSubscription` call,
  457. // it will default to the version of the API used to make such call. If
  458. // not present during a `ModifyPushConfig` call, its value will not be
  459. // changed. `GetSubscription` calls will always return a valid version,
  460. // even if the subscription was created without this attribute. The
  461. // possible values for this attribute are: * `v1beta1`: uses the push
  462. // format defined in the v1beta1 Pub/Sub API. * `v1` or `v1beta2`: uses
  463. // the push format defined in the v1 Pub/Sub API.
  464. Attributes map[string]string `json:"attributes,omitempty"`
  465. // PushEndpoint: A URL locating the endpoint to which messages should be
  466. // pushed. For example, a Webhook endpoint might use
  467. // "https://example.com/push".
  468. PushEndpoint string `json:"pushEndpoint,omitempty"`
  469. // ForceSendFields is a list of field names (e.g. "Attributes") to
  470. // unconditionally include in API requests. By default, fields with
  471. // empty values are omitted from API requests. However, any non-pointer,
  472. // non-interface field appearing in ForceSendFields will be sent to the
  473. // server regardless of whether the field is empty or not. This may be
  474. // used to include empty fields in Patch requests.
  475. ForceSendFields []string `json:"-"`
  476. }
  477. func (s *PushConfig) MarshalJSON() ([]byte, error) {
  478. type noMethod PushConfig
  479. raw := noMethod(*s)
  480. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  481. }
  482. // ReceivedMessage: A message and its corresponding acknowledgment ID.
  483. type ReceivedMessage struct {
  484. // AckId: This ID can be used to acknowledge the received message.
  485. AckId string `json:"ackId,omitempty"`
  486. // Message: The message.
  487. Message *PubsubMessage `json:"message,omitempty"`
  488. // ForceSendFields is a list of field names (e.g. "AckId") to
  489. // unconditionally include in API requests. By default, fields with
  490. // empty values are omitted from API requests. However, any non-pointer,
  491. // non-interface field appearing in ForceSendFields will be sent to the
  492. // server regardless of whether the field is empty or not. This may be
  493. // used to include empty fields in Patch requests.
  494. ForceSendFields []string `json:"-"`
  495. }
  496. func (s *ReceivedMessage) MarshalJSON() ([]byte, error) {
  497. type noMethod ReceivedMessage
  498. raw := noMethod(*s)
  499. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  500. }
  501. // SetIamPolicyRequest: Request message for `SetIamPolicy` method.
  502. type SetIamPolicyRequest struct {
  503. // Policy: REQUIRED: The complete policy to be applied to the
  504. // `resource`. The size of the policy is limited to a few 10s of KB. An
  505. // empty policy is a valid policy but certain Cloud Platform services
  506. // (such as Projects) might reject them.
  507. Policy *Policy `json:"policy,omitempty"`
  508. // ForceSendFields is a list of field names (e.g. "Policy") to
  509. // unconditionally include in API requests. By default, fields with
  510. // empty values are omitted from API requests. However, any non-pointer,
  511. // non-interface field appearing in ForceSendFields will be sent to the
  512. // server regardless of whether the field is empty or not. This may be
  513. // used to include empty fields in Patch requests.
  514. ForceSendFields []string `json:"-"`
  515. }
  516. func (s *SetIamPolicyRequest) MarshalJSON() ([]byte, error) {
  517. type noMethod SetIamPolicyRequest
  518. raw := noMethod(*s)
  519. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  520. }
  521. // Subscription: A subscription resource.
  522. type Subscription struct {
  523. // AckDeadlineSeconds: This value is the maximum time after a subscriber
  524. // receives a message before the subscriber should acknowledge the
  525. // message. After message delivery but before the ack deadline expires
  526. // and before the message is acknowledged, it is an outstanding message
  527. // and will not be delivered again during that time (on a best-effort
  528. // basis). For pull delivery this value is used as the initial value for
  529. // the ack deadline. To override this value for a given message, call
  530. // `ModifyAckDeadline` with the corresponding `ack_id`. For push
  531. // delivery, this value is also used to set the request timeout for the
  532. // call to the push endpoint. If the subscriber never acknowledges the
  533. // message, the Pub/Sub system will eventually redeliver the message. If
  534. // this parameter is not set, the default value of 10 seconds is used.
  535. AckDeadlineSeconds int64 `json:"ackDeadlineSeconds,omitempty"`
  536. // Name: The name of the subscription. It must have the format
  537. // "projects/{project}/subscriptions/{subscription}". `{subscription}`
  538. // must start with a letter, and contain only letters (`[A-Za-z]`),
  539. // numbers (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`),
  540. // tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3
  541. // and 255 characters in length, and it must not start with "goog".
  542. Name string `json:"name,omitempty"`
  543. // PushConfig: If push delivery is used with this subscription, this
  544. // field is used to configure it. An empty `pushConfig` signifies that
  545. // the subscriber will pull and ack messages using API methods.
  546. PushConfig *PushConfig `json:"pushConfig,omitempty"`
  547. // Topic: The name of the topic from which this subscription is
  548. // receiving messages. The value of this field will be `_deleted-topic_`
  549. // if the topic has been deleted.
  550. Topic string `json:"topic,omitempty"`
  551. // ServerResponse contains the HTTP response code and headers from the
  552. // server.
  553. googleapi.ServerResponse `json:"-"`
  554. // ForceSendFields is a list of field names (e.g. "AckDeadlineSeconds")
  555. // to unconditionally include in API requests. By default, fields with
  556. // empty values are omitted from API requests. However, any non-pointer,
  557. // non-interface field appearing in ForceSendFields will be sent to the
  558. // server regardless of whether the field is empty or not. This may be
  559. // used to include empty fields in Patch requests.
  560. ForceSendFields []string `json:"-"`
  561. }
  562. func (s *Subscription) MarshalJSON() ([]byte, error) {
  563. type noMethod Subscription
  564. raw := noMethod(*s)
  565. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  566. }
  567. // TestIamPermissionsRequest: Request message for `TestIamPermissions`
  568. // method.
  569. type TestIamPermissionsRequest struct {
  570. // Permissions: The set of permissions to check for the `resource`.
  571. // Permissions with wildcards (such as '*' or 'storage.*') are not
  572. // allowed.
  573. Permissions []string `json:"permissions,omitempty"`
  574. // ForceSendFields is a list of field names (e.g. "Permissions") to
  575. // unconditionally include in API requests. By default, fields with
  576. // empty values are omitted from API requests. However, any non-pointer,
  577. // non-interface field appearing in ForceSendFields will be sent to the
  578. // server regardless of whether the field is empty or not. This may be
  579. // used to include empty fields in Patch requests.
  580. ForceSendFields []string `json:"-"`
  581. }
  582. func (s *TestIamPermissionsRequest) MarshalJSON() ([]byte, error) {
  583. type noMethod TestIamPermissionsRequest
  584. raw := noMethod(*s)
  585. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  586. }
  587. // TestIamPermissionsResponse: Response message for `TestIamPermissions`
  588. // method.
  589. type TestIamPermissionsResponse struct {
  590. // Permissions: A subset of `TestPermissionsRequest.permissions` that
  591. // the caller is allowed.
  592. Permissions []string `json:"permissions,omitempty"`
  593. // ServerResponse contains the HTTP response code and headers from the
  594. // server.
  595. googleapi.ServerResponse `json:"-"`
  596. // ForceSendFields is a list of field names (e.g. "Permissions") to
  597. // unconditionally include in API requests. By default, fields with
  598. // empty values are omitted from API requests. However, any non-pointer,
  599. // non-interface field appearing in ForceSendFields will be sent to the
  600. // server regardless of whether the field is empty or not. This may be
  601. // used to include empty fields in Patch requests.
  602. ForceSendFields []string `json:"-"`
  603. }
  604. func (s *TestIamPermissionsResponse) MarshalJSON() ([]byte, error) {
  605. type noMethod TestIamPermissionsResponse
  606. raw := noMethod(*s)
  607. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  608. }
  609. // Topic: A topic resource.
  610. type Topic struct {
  611. // Name: The name of the topic. It must have the format
  612. // "projects/{project}/topics/{topic}". `{topic}` must start with a
  613. // letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`),
  614. // dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), plus
  615. // (`+`) or percent signs (`%`). It must be between 3 and 255 characters
  616. // in length, and it must not start with "goog".
  617. Name string `json:"name,omitempty"`
  618. // ServerResponse contains the HTTP response code and headers from the
  619. // server.
  620. googleapi.ServerResponse `json:"-"`
  621. // ForceSendFields is a list of field names (e.g. "Name") to
  622. // unconditionally include in API requests. By default, fields with
  623. // empty values are omitted from API requests. However, any non-pointer,
  624. // non-interface field appearing in ForceSendFields will be sent to the
  625. // server regardless of whether the field is empty or not. This may be
  626. // used to include empty fields in Patch requests.
  627. ForceSendFields []string `json:"-"`
  628. }
  629. func (s *Topic) MarshalJSON() ([]byte, error) {
  630. type noMethod Topic
  631. raw := noMethod(*s)
  632. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  633. }
  634. // method id "pubsub.projects.subscriptions.acknowledge":
  635. type ProjectsSubscriptionsAcknowledgeCall struct {
  636. s *Service
  637. subscription string
  638. acknowledgerequest *AcknowledgeRequest
  639. urlParams_ gensupport.URLParams
  640. ctx_ context.Context
  641. }
  642. // Acknowledge: Acknowledges the messages associated with the `ack_ids`
  643. // in the `AcknowledgeRequest`. The Pub/Sub system can remove the
  644. // relevant messages from the subscription. Acknowledging a message
  645. // whose ack deadline has expired may succeed, but such a message may be
  646. // redelivered later. Acknowledging a message more than once will not
  647. // result in an error.
  648. func (r *ProjectsSubscriptionsService) Acknowledge(subscription string, acknowledgerequest *AcknowledgeRequest) *ProjectsSubscriptionsAcknowledgeCall {
  649. c := &ProjectsSubscriptionsAcknowledgeCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  650. c.subscription = subscription
  651. c.acknowledgerequest = acknowledgerequest
  652. return c
  653. }
  654. // Fields allows partial responses to be retrieved. See
  655. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  656. // for more information.
  657. func (c *ProjectsSubscriptionsAcknowledgeCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsAcknowledgeCall {
  658. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  659. return c
  660. }
  661. // Context sets the context to be used in this call's Do method. Any
  662. // pending HTTP request will be aborted if the provided context is
  663. // canceled.
  664. func (c *ProjectsSubscriptionsAcknowledgeCall) Context(ctx context.Context) *ProjectsSubscriptionsAcknowledgeCall {
  665. c.ctx_ = ctx
  666. return c
  667. }
  668. func (c *ProjectsSubscriptionsAcknowledgeCall) doRequest(alt string) (*http.Response, error) {
  669. var body io.Reader = nil
  670. body, err := googleapi.WithoutDataWrapper.JSONReader(c.acknowledgerequest)
  671. if err != nil {
  672. return nil, err
  673. }
  674. ctype := "application/json"
  675. c.urlParams_.Set("alt", alt)
  676. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+subscription}:acknowledge")
  677. urls += "?" + c.urlParams_.Encode()
  678. req, _ := http.NewRequest("POST", urls, body)
  679. googleapi.Expand(req.URL, map[string]string{
  680. "subscription": c.subscription,
  681. })
  682. req.Header.Set("Content-Type", ctype)
  683. req.Header.Set("User-Agent", c.s.userAgent())
  684. if c.ctx_ != nil {
  685. return ctxhttp.Do(c.ctx_, c.s.client, req)
  686. }
  687. return c.s.client.Do(req)
  688. }
  689. // Do executes the "pubsub.projects.subscriptions.acknowledge" call.
  690. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  691. // code is an error. Response headers are in either
  692. // *Empty.ServerResponse.Header or (if a response was returned at all)
  693. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  694. // check whether the returned error was because http.StatusNotModified
  695. // was returned.
  696. func (c *ProjectsSubscriptionsAcknowledgeCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  697. gensupport.SetOptions(c.urlParams_, opts...)
  698. res, err := c.doRequest("json")
  699. if res != nil && res.StatusCode == http.StatusNotModified {
  700. if res.Body != nil {
  701. res.Body.Close()
  702. }
  703. return nil, &googleapi.Error{
  704. Code: res.StatusCode,
  705. Header: res.Header,
  706. }
  707. }
  708. if err != nil {
  709. return nil, err
  710. }
  711. defer googleapi.CloseBody(res)
  712. if err := googleapi.CheckResponse(res); err != nil {
  713. return nil, err
  714. }
  715. ret := &Empty{
  716. ServerResponse: googleapi.ServerResponse{
  717. Header: res.Header,
  718. HTTPStatusCode: res.StatusCode,
  719. },
  720. }
  721. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  722. return nil, err
  723. }
  724. return ret, nil
  725. // {
  726. // "description": "Acknowledges the messages associated with the `ack_ids` in the `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages from the subscription. Acknowledging a message whose ack deadline has expired may succeed, but such a message may be redelivered later. Acknowledging a message more than once will not result in an error.",
  727. // "httpMethod": "POST",
  728. // "id": "pubsub.projects.subscriptions.acknowledge",
  729. // "parameterOrder": [
  730. // "subscription"
  731. // ],
  732. // "parameters": {
  733. // "subscription": {
  734. // "description": "The subscription whose message is being acknowledged.",
  735. // "location": "path",
  736. // "pattern": "^projects/[^/]*/subscriptions/[^/]*$",
  737. // "required": true,
  738. // "type": "string"
  739. // }
  740. // },
  741. // "path": "v1beta2/{+subscription}:acknowledge",
  742. // "request": {
  743. // "$ref": "AcknowledgeRequest"
  744. // },
  745. // "response": {
  746. // "$ref": "Empty"
  747. // },
  748. // "scopes": [
  749. // "https://www.googleapis.com/auth/cloud-platform",
  750. // "https://www.googleapis.com/auth/pubsub"
  751. // ]
  752. // }
  753. }
  754. // method id "pubsub.projects.subscriptions.create":
  755. type ProjectsSubscriptionsCreateCall struct {
  756. s *Service
  757. name string
  758. subscription *Subscription
  759. urlParams_ gensupport.URLParams
  760. ctx_ context.Context
  761. }
  762. // Create: Creates a subscription to a given topic for a given
  763. // subscriber. If the subscription already exists, returns
  764. // `ALREADY_EXISTS`. If the corresponding topic doesn't exist, returns
  765. // `NOT_FOUND`. If the name is not provided in the request, the server
  766. // will assign a random name for this subscription on the same project
  767. // as the topic.
  768. func (r *ProjectsSubscriptionsService) Create(name string, subscription *Subscription) *ProjectsSubscriptionsCreateCall {
  769. c := &ProjectsSubscriptionsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  770. c.name = name
  771. c.subscription = subscription
  772. return c
  773. }
  774. // Fields allows partial responses to be retrieved. See
  775. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  776. // for more information.
  777. func (c *ProjectsSubscriptionsCreateCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsCreateCall {
  778. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  779. return c
  780. }
  781. // Context sets the context to be used in this call's Do method. Any
  782. // pending HTTP request will be aborted if the provided context is
  783. // canceled.
  784. func (c *ProjectsSubscriptionsCreateCall) Context(ctx context.Context) *ProjectsSubscriptionsCreateCall {
  785. c.ctx_ = ctx
  786. return c
  787. }
  788. func (c *ProjectsSubscriptionsCreateCall) doRequest(alt string) (*http.Response, error) {
  789. var body io.Reader = nil
  790. body, err := googleapi.WithoutDataWrapper.JSONReader(c.subscription)
  791. if err != nil {
  792. return nil, err
  793. }
  794. ctype := "application/json"
  795. c.urlParams_.Set("alt", alt)
  796. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+name}")
  797. urls += "?" + c.urlParams_.Encode()
  798. req, _ := http.NewRequest("PUT", urls, body)
  799. googleapi.Expand(req.URL, map[string]string{
  800. "name": c.name,
  801. })
  802. req.Header.Set("Content-Type", ctype)
  803. req.Header.Set("User-Agent", c.s.userAgent())
  804. if c.ctx_ != nil {
  805. return ctxhttp.Do(c.ctx_, c.s.client, req)
  806. }
  807. return c.s.client.Do(req)
  808. }
  809. // Do executes the "pubsub.projects.subscriptions.create" call.
  810. // Exactly one of *Subscription or error will be non-nil. Any non-2xx
  811. // status code is an error. Response headers are in either
  812. // *Subscription.ServerResponse.Header or (if a response was returned at
  813. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  814. // to check whether the returned error was because
  815. // http.StatusNotModified was returned.
  816. func (c *ProjectsSubscriptionsCreateCall) Do(opts ...googleapi.CallOption) (*Subscription, error) {
  817. gensupport.SetOptions(c.urlParams_, opts...)
  818. res, err := c.doRequest("json")
  819. if res != nil && res.StatusCode == http.StatusNotModified {
  820. if res.Body != nil {
  821. res.Body.Close()
  822. }
  823. return nil, &googleapi.Error{
  824. Code: res.StatusCode,
  825. Header: res.Header,
  826. }
  827. }
  828. if err != nil {
  829. return nil, err
  830. }
  831. defer googleapi.CloseBody(res)
  832. if err := googleapi.CheckResponse(res); err != nil {
  833. return nil, err
  834. }
  835. ret := &Subscription{
  836. ServerResponse: googleapi.ServerResponse{
  837. Header: res.Header,
  838. HTTPStatusCode: res.StatusCode,
  839. },
  840. }
  841. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  842. return nil, err
  843. }
  844. return ret, nil
  845. // {
  846. // "description": "Creates a subscription to 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.",
  847. // "httpMethod": "PUT",
  848. // "id": "pubsub.projects.subscriptions.create",
  849. // "parameterOrder": [
  850. // "name"
  851. // ],
  852. // "parameters": {
  853. // "name": {
  854. // "description": "The name of the subscription. It must have the format `\"projects/{project}/subscriptions/{subscription}\"`. `{subscription}` must start with a letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters in length, and it must not start with `\"goog\"`.",
  855. // "location": "path",
  856. // "pattern": "^projects/[^/]*/subscriptions/[^/]*$",
  857. // "required": true,
  858. // "type": "string"
  859. // }
  860. // },
  861. // "path": "v1beta2/{+name}",
  862. // "request": {
  863. // "$ref": "Subscription"
  864. // },
  865. // "response": {
  866. // "$ref": "Subscription"
  867. // },
  868. // "scopes": [
  869. // "https://www.googleapis.com/auth/cloud-platform",
  870. // "https://www.googleapis.com/auth/pubsub"
  871. // ]
  872. // }
  873. }
  874. // method id "pubsub.projects.subscriptions.delete":
  875. type ProjectsSubscriptionsDeleteCall struct {
  876. s *Service
  877. subscription string
  878. urlParams_ gensupport.URLParams
  879. ctx_ context.Context
  880. }
  881. // Delete: Deletes an existing subscription. All pending messages in the
  882. // subscription are immediately dropped. Calls to `Pull` after deletion
  883. // will return `NOT_FOUND`. After a subscription is deleted, a new one
  884. // may be created with the same name, but the new one has no association
  885. // with the old subscription, or its topic unless the same topic is
  886. // specified.
  887. func (r *ProjectsSubscriptionsService) Delete(subscription string) *ProjectsSubscriptionsDeleteCall {
  888. c := &ProjectsSubscriptionsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  889. c.subscription = subscription
  890. return c
  891. }
  892. // Fields allows partial responses to be retrieved. See
  893. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  894. // for more information.
  895. func (c *ProjectsSubscriptionsDeleteCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsDeleteCall {
  896. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  897. return c
  898. }
  899. // Context sets the context to be used in this call's Do method. Any
  900. // pending HTTP request will be aborted if the provided context is
  901. // canceled.
  902. func (c *ProjectsSubscriptionsDeleteCall) Context(ctx context.Context) *ProjectsSubscriptionsDeleteCall {
  903. c.ctx_ = ctx
  904. return c
  905. }
  906. func (c *ProjectsSubscriptionsDeleteCall) doRequest(alt string) (*http.Response, error) {
  907. var body io.Reader = nil
  908. c.urlParams_.Set("alt", alt)
  909. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+subscription}")
  910. urls += "?" + c.urlParams_.Encode()
  911. req, _ := http.NewRequest("DELETE", urls, body)
  912. googleapi.Expand(req.URL, map[string]string{
  913. "subscription": c.subscription,
  914. })
  915. req.Header.Set("User-Agent", c.s.userAgent())
  916. if c.ctx_ != nil {
  917. return ctxhttp.Do(c.ctx_, c.s.client, req)
  918. }
  919. return c.s.client.Do(req)
  920. }
  921. // Do executes the "pubsub.projects.subscriptions.delete" call.
  922. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  923. // code is an error. Response headers are in either
  924. // *Empty.ServerResponse.Header or (if a response was returned at all)
  925. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  926. // check whether the returned error was because http.StatusNotModified
  927. // was returned.
  928. func (c *ProjectsSubscriptionsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  929. gensupport.SetOptions(c.urlParams_, opts...)
  930. res, err := c.doRequest("json")
  931. if res != nil && res.StatusCode == http.StatusNotModified {
  932. if res.Body != nil {
  933. res.Body.Close()
  934. }
  935. return nil, &googleapi.Error{
  936. Code: res.StatusCode,
  937. Header: res.Header,
  938. }
  939. }
  940. if err != nil {
  941. return nil, err
  942. }
  943. defer googleapi.CloseBody(res)
  944. if err := googleapi.CheckResponse(res); err != nil {
  945. return nil, err
  946. }
  947. ret := &Empty{
  948. ServerResponse: googleapi.ServerResponse{
  949. Header: res.Header,
  950. HTTPStatusCode: res.StatusCode,
  951. },
  952. }
  953. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  954. return nil, err
  955. }
  956. return ret, nil
  957. // {
  958. // "description": "Deletes an existing subscription. All pending messages in the subscription are immediately dropped. Calls to `Pull` after deletion will return `NOT_FOUND`. After a subscription is deleted, a new one may be created with the same name, but the new one has no association with the old subscription, or its topic unless the same topic is specified.",
  959. // "httpMethod": "DELETE",
  960. // "id": "pubsub.projects.subscriptions.delete",
  961. // "parameterOrder": [
  962. // "subscription"
  963. // ],
  964. // "parameters": {
  965. // "subscription": {
  966. // "description": "The subscription to delete.",
  967. // "location": "path",
  968. // "pattern": "^projects/[^/]*/subscriptions/[^/]*$",
  969. // "required": true,
  970. // "type": "string"
  971. // }
  972. // },
  973. // "path": "v1beta2/{+subscription}",
  974. // "response": {
  975. // "$ref": "Empty"
  976. // },
  977. // "scopes": [
  978. // "https://www.googleapis.com/auth/cloud-platform",
  979. // "https://www.googleapis.com/auth/pubsub"
  980. // ]
  981. // }
  982. }
  983. // method id "pubsub.projects.subscriptions.get":
  984. type ProjectsSubscriptionsGetCall struct {
  985. s *Service
  986. subscription string
  987. urlParams_ gensupport.URLParams
  988. ifNoneMatch_ string
  989. ctx_ context.Context
  990. }
  991. // Get: Gets the configuration details of a subscription.
  992. func (r *ProjectsSubscriptionsService) Get(subscription string) *ProjectsSubscriptionsGetCall {
  993. c := &ProjectsSubscriptionsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  994. c.subscription = subscription
  995. return c
  996. }
  997. // Fields allows partial responses to be retrieved. See
  998. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  999. // for more information.
  1000. func (c *ProjectsSubscriptionsGetCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsGetCall {
  1001. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1002. return c
  1003. }
  1004. // IfNoneMatch sets the optional parameter which makes the operation
  1005. // fail if the object's ETag matches the given value. This is useful for
  1006. // getting updates only after the object has changed since the last
  1007. // request. Use googleapi.IsNotModified to check whether the response
  1008. // error from Do is the result of In-None-Match.
  1009. func (c *ProjectsSubscriptionsGetCall) IfNoneMatch(entityTag string) *ProjectsSubscriptionsGetCall {
  1010. c.ifNoneMatch_ = entityTag
  1011. return c
  1012. }
  1013. // Context sets the context to be used in this call's Do method. Any
  1014. // pending HTTP request will be aborted if the provided context is
  1015. // canceled.
  1016. func (c *ProjectsSubscriptionsGetCall) Context(ctx context.Context) *ProjectsSubscriptionsGetCall {
  1017. c.ctx_ = ctx
  1018. return c
  1019. }
  1020. func (c *ProjectsSubscriptionsGetCall) doRequest(alt string) (*http.Response, error) {
  1021. var body io.Reader = nil
  1022. c.urlParams_.Set("alt", alt)
  1023. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+subscription}")
  1024. urls += "?" + c.urlParams_.Encode()
  1025. req, _ := http.NewRequest("GET", urls, body)
  1026. googleapi.Expand(req.URL, map[string]string{
  1027. "subscription": c.subscription,
  1028. })
  1029. req.Header.Set("User-Agent", c.s.userAgent())
  1030. if c.ifNoneMatch_ != "" {
  1031. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  1032. }
  1033. if c.ctx_ != nil {
  1034. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1035. }
  1036. return c.s.client.Do(req)
  1037. }
  1038. // Do executes the "pubsub.projects.subscriptions.get" call.
  1039. // Exactly one of *Subscription or error will be non-nil. Any non-2xx
  1040. // status code is an error. Response headers are in either
  1041. // *Subscription.ServerResponse.Header or (if a response was returned at
  1042. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1043. // to check whether the returned error was because
  1044. // http.StatusNotModified was returned.
  1045. func (c *ProjectsSubscriptionsGetCall) Do(opts ...googleapi.CallOption) (*Subscription, error) {
  1046. gensupport.SetOptions(c.urlParams_, opts...)
  1047. res, err := c.doRequest("json")
  1048. if res != nil && res.StatusCode == http.StatusNotModified {
  1049. if res.Body != nil {
  1050. res.Body.Close()
  1051. }
  1052. return nil, &googleapi.Error{
  1053. Code: res.StatusCode,
  1054. Header: res.Header,
  1055. }
  1056. }
  1057. if err != nil {
  1058. return nil, err
  1059. }
  1060. defer googleapi.CloseBody(res)
  1061. if err := googleapi.CheckResponse(res); err != nil {
  1062. return nil, err
  1063. }
  1064. ret := &Subscription{
  1065. ServerResponse: googleapi.ServerResponse{
  1066. Header: res.Header,
  1067. HTTPStatusCode: res.StatusCode,
  1068. },
  1069. }
  1070. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1071. return nil, err
  1072. }
  1073. return ret, nil
  1074. // {
  1075. // "description": "Gets the configuration details of a subscription.",
  1076. // "httpMethod": "GET",
  1077. // "id": "pubsub.projects.subscriptions.get",
  1078. // "parameterOrder": [
  1079. // "subscription"
  1080. // ],
  1081. // "parameters": {
  1082. // "subscription": {
  1083. // "description": "The name of the subscription to get.",
  1084. // "location": "path",
  1085. // "pattern": "^projects/[^/]*/subscriptions/[^/]*$",
  1086. // "required": true,
  1087. // "type": "string"
  1088. // }
  1089. // },
  1090. // "path": "v1beta2/{+subscription}",
  1091. // "response": {
  1092. // "$ref": "Subscription"
  1093. // },
  1094. // "scopes": [
  1095. // "https://www.googleapis.com/auth/cloud-platform",
  1096. // "https://www.googleapis.com/auth/pubsub"
  1097. // ]
  1098. // }
  1099. }
  1100. // method id "pubsub.projects.subscriptions.getIamPolicy":
  1101. type ProjectsSubscriptionsGetIamPolicyCall struct {
  1102. s *Service
  1103. resource string
  1104. urlParams_ gensupport.URLParams
  1105. ifNoneMatch_ string
  1106. ctx_ context.Context
  1107. }
  1108. // GetIamPolicy: Gets the access control policy for a `resource`. Is
  1109. // empty if the policy or the resource does not exist.
  1110. func (r *ProjectsSubscriptionsService) GetIamPolicy(resource string) *ProjectsSubscriptionsGetIamPolicyCall {
  1111. c := &ProjectsSubscriptionsGetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1112. c.resource = resource
  1113. return c
  1114. }
  1115. // Fields allows partial responses to be retrieved. See
  1116. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1117. // for more information.
  1118. func (c *ProjectsSubscriptionsGetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsGetIamPolicyCall {
  1119. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1120. return c
  1121. }
  1122. // IfNoneMatch sets the optional parameter which makes the operation
  1123. // fail if the object's ETag matches the given value. This is useful for
  1124. // getting updates only after the object has changed since the last
  1125. // request. Use googleapi.IsNotModified to check whether the response
  1126. // error from Do is the result of In-None-Match.
  1127. func (c *ProjectsSubscriptionsGetIamPolicyCall) IfNoneMatch(entityTag string) *ProjectsSubscriptionsGetIamPolicyCall {
  1128. c.ifNoneMatch_ = entityTag
  1129. return c
  1130. }
  1131. // Context sets the context to be used in this call's Do method. Any
  1132. // pending HTTP request will be aborted if the provided context is
  1133. // canceled.
  1134. func (c *ProjectsSubscriptionsGetIamPolicyCall) Context(ctx context.Context) *ProjectsSubscriptionsGetIamPolicyCall {
  1135. c.ctx_ = ctx
  1136. return c
  1137. }
  1138. func (c *ProjectsSubscriptionsGetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  1139. var body io.Reader = nil
  1140. c.urlParams_.Set("alt", alt)
  1141. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+resource}:getIamPolicy")
  1142. urls += "?" + c.urlParams_.Encode()
  1143. req, _ := http.NewRequest("GET", urls, body)
  1144. googleapi.Expand(req.URL, map[string]string{
  1145. "resource": c.resource,
  1146. })
  1147. req.Header.Set("User-Agent", c.s.userAgent())
  1148. if c.ifNoneMatch_ != "" {
  1149. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  1150. }
  1151. if c.ctx_ != nil {
  1152. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1153. }
  1154. return c.s.client.Do(req)
  1155. }
  1156. // Do executes the "pubsub.projects.subscriptions.getIamPolicy" call.
  1157. // Exactly one of *Policy or error will be non-nil. Any non-2xx status
  1158. // code is an error. Response headers are in either
  1159. // *Policy.ServerResponse.Header or (if a response was returned at all)
  1160. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1161. // check whether the returned error was because http.StatusNotModified
  1162. // was returned.
  1163. func (c *ProjectsSubscriptionsGetIamPolicyCall) Do(opts ...googleapi.CallOption) (*Policy, error) {
  1164. gensupport.SetOptions(c.urlParams_, opts...)
  1165. res, err := c.doRequest("json")
  1166. if res != nil && res.StatusCode == http.StatusNotModified {
  1167. if res.Body != nil {
  1168. res.Body.Close()
  1169. }
  1170. return nil, &googleapi.Error{
  1171. Code: res.StatusCode,
  1172. Header: res.Header,
  1173. }
  1174. }
  1175. if err != nil {
  1176. return nil, err
  1177. }
  1178. defer googleapi.CloseBody(res)
  1179. if err := googleapi.CheckResponse(res); err != nil {
  1180. return nil, err
  1181. }
  1182. ret := &Policy{
  1183. ServerResponse: googleapi.ServerResponse{
  1184. Header: res.Header,
  1185. HTTPStatusCode: res.StatusCode,
  1186. },
  1187. }
  1188. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1189. return nil, err
  1190. }
  1191. return ret, nil
  1192. // {
  1193. // "description": "Gets the access control policy for a `resource`. Is empty if the policy or the resource does not exist.",
  1194. // "httpMethod": "GET",
  1195. // "id": "pubsub.projects.subscriptions.getIamPolicy",
  1196. // "parameterOrder": [
  1197. // "resource"
  1198. // ],
  1199. // "parameters": {
  1200. // "resource": {
  1201. // "description": "REQUIRED: The resource for which policy is being requested. `resource` is usually specified as a path, such as, `projects/{project}/zones/{zone}/disks/{disk}`. The format for the path specified in this value is resource specific and is specified in the documentation for the respective GetIamPolicy rpc.",
  1202. // "location": "path",
  1203. // "pattern": "^projects/[^/]*/subscriptions/[^/]*$",
  1204. // "required": true,
  1205. // "type": "string"
  1206. // }
  1207. // },
  1208. // "path": "v1beta2/{+resource}:getIamPolicy",
  1209. // "response": {
  1210. // "$ref": "Policy"
  1211. // },
  1212. // "scopes": [
  1213. // "https://www.googleapis.com/auth/cloud-platform",
  1214. // "https://www.googleapis.com/auth/pubsub"
  1215. // ]
  1216. // }
  1217. }
  1218. // method id "pubsub.projects.subscriptions.list":
  1219. type ProjectsSubscriptionsListCall struct {
  1220. s *Service
  1221. project string
  1222. urlParams_ gensupport.URLParams
  1223. ifNoneMatch_ string
  1224. ctx_ context.Context
  1225. }
  1226. // List: Lists matching subscriptions.
  1227. func (r *ProjectsSubscriptionsService) List(project string) *ProjectsSubscriptionsListCall {
  1228. c := &ProjectsSubscriptionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1229. c.project = project
  1230. return c
  1231. }
  1232. // PageSize sets the optional parameter "pageSize": Maximum number of
  1233. // subscriptions to return.
  1234. func (c *ProjectsSubscriptionsListCall) PageSize(pageSize int64) *ProjectsSubscriptionsListCall {
  1235. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  1236. return c
  1237. }
  1238. // PageToken sets the optional parameter "pageToken": The value returned
  1239. // by the last `ListSubscriptionsResponse`; indicates that this is a
  1240. // continuation of a prior `ListSubscriptions` call, and that the system
  1241. // should return the next page of data.
  1242. func (c *ProjectsSubscriptionsListCall) PageToken(pageToken string) *ProjectsSubscriptionsListCall {
  1243. c.urlParams_.Set("pageToken", pageToken)
  1244. return c
  1245. }
  1246. // Fields allows partial responses to be retrieved. See
  1247. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1248. // for more information.
  1249. func (c *ProjectsSubscriptionsListCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsListCall {
  1250. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1251. return c
  1252. }
  1253. // IfNoneMatch sets the optional parameter which makes the operation
  1254. // fail if the object's ETag matches the given value. This is useful for
  1255. // getting updates only after the object has changed since the last
  1256. // request. Use googleapi.IsNotModified to check whether the response
  1257. // error from Do is the result of In-None-Match.
  1258. func (c *ProjectsSubscriptionsListCall) IfNoneMatch(entityTag string) *ProjectsSubscriptionsListCall {
  1259. c.ifNoneMatch_ = entityTag
  1260. return c
  1261. }
  1262. // Context sets the context to be used in this call's Do method. Any
  1263. // pending HTTP request will be aborted if the provided context is
  1264. // canceled.
  1265. func (c *ProjectsSubscriptionsListCall) Context(ctx context.Context) *ProjectsSubscriptionsListCall {
  1266. c.ctx_ = ctx
  1267. return c
  1268. }
  1269. func (c *ProjectsSubscriptionsListCall) doRequest(alt string) (*http.Response, error) {
  1270. var body io.Reader = nil
  1271. c.urlParams_.Set("alt", alt)
  1272. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+project}/subscriptions")
  1273. urls += "?" + c.urlParams_.Encode()
  1274. req, _ := http.NewRequest("GET", urls, body)
  1275. googleapi.Expand(req.URL, map[string]string{
  1276. "project": c.project,
  1277. })
  1278. req.Header.Set("User-Agent", c.s.userAgent())
  1279. if c.ifNoneMatch_ != "" {
  1280. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  1281. }
  1282. if c.ctx_ != nil {
  1283. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1284. }
  1285. return c.s.client.Do(req)
  1286. }
  1287. // Do executes the "pubsub.projects.subscriptions.list" call.
  1288. // Exactly one of *ListSubscriptionsResponse or error will be non-nil.
  1289. // Any non-2xx status code is an error. Response headers are in either
  1290. // *ListSubscriptionsResponse.ServerResponse.Header or (if a response
  1291. // was returned at all) in error.(*googleapi.Error).Header. Use
  1292. // googleapi.IsNotModified to check whether the returned error was
  1293. // because http.StatusNotModified was returned.
  1294. func (c *ProjectsSubscriptionsListCall) Do(opts ...googleapi.CallOption) (*ListSubscriptionsResponse, error) {
  1295. gensupport.SetOptions(c.urlParams_, opts...)
  1296. res, err := c.doRequest("json")
  1297. if res != nil && res.StatusCode == http.StatusNotModified {
  1298. if res.Body != nil {
  1299. res.Body.Close()
  1300. }
  1301. return nil, &googleapi.Error{
  1302. Code: res.StatusCode,
  1303. Header: res.Header,
  1304. }
  1305. }
  1306. if err != nil {
  1307. return nil, err
  1308. }
  1309. defer googleapi.CloseBody(res)
  1310. if err := googleapi.CheckResponse(res); err != nil {
  1311. return nil, err
  1312. }
  1313. ret := &ListSubscriptionsResponse{
  1314. ServerResponse: googleapi.ServerResponse{
  1315. Header: res.Header,
  1316. HTTPStatusCode: res.StatusCode,
  1317. },
  1318. }
  1319. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1320. return nil, err
  1321. }
  1322. return ret, nil
  1323. // {
  1324. // "description": "Lists matching subscriptions.",
  1325. // "httpMethod": "GET",
  1326. // "id": "pubsub.projects.subscriptions.list",
  1327. // "parameterOrder": [
  1328. // "project"
  1329. // ],
  1330. // "parameters": {
  1331. // "pageSize": {
  1332. // "description": "Maximum number of subscriptions to return.",
  1333. // "format": "int32",
  1334. // "location": "query",
  1335. // "type": "integer"
  1336. // },
  1337. // "pageToken": {
  1338. // "description": "The value returned by the last `ListSubscriptionsResponse`; indicates that this is a continuation of a prior `ListSubscriptions` call, and that the system should return the next page of data.",
  1339. // "location": "query",
  1340. // "type": "string"
  1341. // },
  1342. // "project": {
  1343. // "description": "The name of the cloud project that subscriptions belong to.",
  1344. // "location": "path",
  1345. // "pattern": "^projects/[^/]*$",
  1346. // "required": true,
  1347. // "type": "string"
  1348. // }
  1349. // },
  1350. // "path": "v1beta2/{+project}/subscriptions",
  1351. // "response": {
  1352. // "$ref": "ListSubscriptionsResponse"
  1353. // },
  1354. // "scopes": [
  1355. // "https://www.googleapis.com/auth/cloud-platform",
  1356. // "https://www.googleapis.com/auth/pubsub"
  1357. // ]
  1358. // }
  1359. }
  1360. // Pages invokes f for each page of results.
  1361. // A non-nil error returned from f will halt the iteration.
  1362. // The provided context supersedes any context provided to the Context method.
  1363. func (c *ProjectsSubscriptionsListCall) Pages(ctx context.Context, f func(*ListSubscriptionsResponse) error) error {
  1364. c.ctx_ = ctx
  1365. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1366. for {
  1367. x, err := c.Do()
  1368. if err != nil {
  1369. return err
  1370. }
  1371. if err := f(x); err != nil {
  1372. return err
  1373. }
  1374. if x.NextPageToken == "" {
  1375. return nil
  1376. }
  1377. c.PageToken(x.NextPageToken)
  1378. }
  1379. }
  1380. // method id "pubsub.projects.subscriptions.modifyAckDeadline":
  1381. type ProjectsSubscriptionsModifyAckDeadlineCall struct {
  1382. s *Service
  1383. subscription string
  1384. modifyackdeadlinerequest *ModifyAckDeadlineRequest
  1385. urlParams_ gensupport.URLParams
  1386. ctx_ context.Context
  1387. }
  1388. // ModifyAckDeadline: Modifies the ack deadline for a specific message.
  1389. // This method is useful to indicate that more time is needed to process
  1390. // a message by the subscriber, or to make the message available for
  1391. // redelivery if the processing was interrupted.
  1392. func (r *ProjectsSubscriptionsService) ModifyAckDeadline(subscription string, modifyackdeadlinerequest *ModifyAckDeadlineRequest) *ProjectsSubscriptionsModifyAckDeadlineCall {
  1393. c := &ProjectsSubscriptionsModifyAckDeadlineCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1394. c.subscription = subscription
  1395. c.modifyackdeadlinerequest = modifyackdeadlinerequest
  1396. return c
  1397. }
  1398. // Fields allows partial responses to be retrieved. See
  1399. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1400. // for more information.
  1401. func (c *ProjectsSubscriptionsModifyAckDeadlineCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsModifyAckDeadlineCall {
  1402. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1403. return c
  1404. }
  1405. // Context sets the context to be used in this call's Do method. Any
  1406. // pending HTTP request will be aborted if the provided context is
  1407. // canceled.
  1408. func (c *ProjectsSubscriptionsModifyAckDeadlineCall) Context(ctx context.Context) *ProjectsSubscriptionsModifyAckDeadlineCall {
  1409. c.ctx_ = ctx
  1410. return c
  1411. }
  1412. func (c *ProjectsSubscriptionsModifyAckDeadlineCall) doRequest(alt string) (*http.Response, error) {
  1413. var body io.Reader = nil
  1414. body, err := googleapi.WithoutDataWrapper.JSONReader(c.modifyackdeadlinerequest)
  1415. if err != nil {
  1416. return nil, err
  1417. }
  1418. ctype := "application/json"
  1419. c.urlParams_.Set("alt", alt)
  1420. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+subscription}:modifyAckDeadline")
  1421. urls += "?" + c.urlParams_.Encode()
  1422. req, _ := http.NewRequest("POST", urls, body)
  1423. googleapi.Expand(req.URL, map[string]string{
  1424. "subscription": c.subscription,
  1425. })
  1426. req.Header.Set("Content-Type", ctype)
  1427. req.Header.Set("User-Agent", c.s.userAgent())
  1428. if c.ctx_ != nil {
  1429. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1430. }
  1431. return c.s.client.Do(req)
  1432. }
  1433. // Do executes the "pubsub.projects.subscriptions.modifyAckDeadline" call.
  1434. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  1435. // code is an error. Response headers are in either
  1436. // *Empty.ServerResponse.Header or (if a response was returned at all)
  1437. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1438. // check whether the returned error was because http.StatusNotModified
  1439. // was returned.
  1440. func (c *ProjectsSubscriptionsModifyAckDeadlineCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  1441. gensupport.SetOptions(c.urlParams_, opts...)
  1442. res, err := c.doRequest("json")
  1443. if res != nil && res.StatusCode == http.StatusNotModified {
  1444. if res.Body != nil {
  1445. res.Body.Close()
  1446. }
  1447. return nil, &googleapi.Error{
  1448. Code: res.StatusCode,
  1449. Header: res.Header,
  1450. }
  1451. }
  1452. if err != nil {
  1453. return nil, err
  1454. }
  1455. defer googleapi.CloseBody(res)
  1456. if err := googleapi.CheckResponse(res); err != nil {
  1457. return nil, err
  1458. }
  1459. ret := &Empty{
  1460. ServerResponse: googleapi.ServerResponse{
  1461. Header: res.Header,
  1462. HTTPStatusCode: res.StatusCode,
  1463. },
  1464. }
  1465. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1466. return nil, err
  1467. }
  1468. return ret, nil
  1469. // {
  1470. // "description": "Modifies the ack deadline for a specific message. This method is useful to indicate that more time is needed to process a message by the subscriber, or to make the message available for redelivery if the processing was interrupted.",
  1471. // "httpMethod": "POST",
  1472. // "id": "pubsub.projects.subscriptions.modifyAckDeadline",
  1473. // "parameterOrder": [
  1474. // "subscription"
  1475. // ],
  1476. // "parameters": {
  1477. // "subscription": {
  1478. // "description": "The name of the subscription.",
  1479. // "location": "path",
  1480. // "pattern": "^projects/[^/]*/subscriptions/[^/]*$",
  1481. // "required": true,
  1482. // "type": "string"
  1483. // }
  1484. // },
  1485. // "path": "v1beta2/{+subscription}:modifyAckDeadline",
  1486. // "request": {
  1487. // "$ref": "ModifyAckDeadlineRequest"
  1488. // },
  1489. // "response": {
  1490. // "$ref": "Empty"
  1491. // },
  1492. // "scopes": [
  1493. // "https://www.googleapis.com/auth/cloud-platform",
  1494. // "https://www.googleapis.com/auth/pubsub"
  1495. // ]
  1496. // }
  1497. }
  1498. // method id "pubsub.projects.subscriptions.modifyPushConfig":
  1499. type ProjectsSubscriptionsModifyPushConfigCall struct {
  1500. s *Service
  1501. subscription string
  1502. modifypushconfigrequest *ModifyPushConfigRequest
  1503. urlParams_ gensupport.URLParams
  1504. ctx_ context.Context
  1505. }
  1506. // ModifyPushConfig: Modifies the `PushConfig` for a specified
  1507. // subscription. This may be used to change a push subscription to a
  1508. // pull one (signified by an empty `PushConfig`) or vice versa, or
  1509. // change the endpoint URL and other attributes of a push subscription.
  1510. // Messages will accumulate for delivery continuously through the call
  1511. // regardless of changes to the `PushConfig`.
  1512. func (r *ProjectsSubscriptionsService) ModifyPushConfig(subscription string, modifypushconfigrequest *ModifyPushConfigRequest) *ProjectsSubscriptionsModifyPushConfigCall {
  1513. c := &ProjectsSubscriptionsModifyPushConfigCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1514. c.subscription = subscription
  1515. c.modifypushconfigrequest = modifypushconfigrequest
  1516. return c
  1517. }
  1518. // Fields allows partial responses to be retrieved. See
  1519. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1520. // for more information.
  1521. func (c *ProjectsSubscriptionsModifyPushConfigCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsModifyPushConfigCall {
  1522. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1523. return c
  1524. }
  1525. // Context sets the context to be used in this call's Do method. Any
  1526. // pending HTTP request will be aborted if the provided context is
  1527. // canceled.
  1528. func (c *ProjectsSubscriptionsModifyPushConfigCall) Context(ctx context.Context) *ProjectsSubscriptionsModifyPushConfigCall {
  1529. c.ctx_ = ctx
  1530. return c
  1531. }
  1532. func (c *ProjectsSubscriptionsModifyPushConfigCall) doRequest(alt string) (*http.Response, error) {
  1533. var body io.Reader = nil
  1534. body, err := googleapi.WithoutDataWrapper.JSONReader(c.modifypushconfigrequest)
  1535. if err != nil {
  1536. return nil, err
  1537. }
  1538. ctype := "application/json"
  1539. c.urlParams_.Set("alt", alt)
  1540. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+subscription}:modifyPushConfig")
  1541. urls += "?" + c.urlParams_.Encode()
  1542. req, _ := http.NewRequest("POST", urls, body)
  1543. googleapi.Expand(req.URL, map[string]string{
  1544. "subscription": c.subscription,
  1545. })
  1546. req.Header.Set("Content-Type", ctype)
  1547. req.Header.Set("User-Agent", c.s.userAgent())
  1548. if c.ctx_ != nil {
  1549. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1550. }
  1551. return c.s.client.Do(req)
  1552. }
  1553. // Do executes the "pubsub.projects.subscriptions.modifyPushConfig" call.
  1554. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  1555. // code is an error. Response headers are in either
  1556. // *Empty.ServerResponse.Header or (if a response was returned at all)
  1557. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1558. // check whether the returned error was because http.StatusNotModified
  1559. // was returned.
  1560. func (c *ProjectsSubscriptionsModifyPushConfigCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  1561. gensupport.SetOptions(c.urlParams_, opts...)
  1562. res, err := c.doRequest("json")
  1563. if res != nil && res.StatusCode == http.StatusNotModified {
  1564. if res.Body != nil {
  1565. res.Body.Close()
  1566. }
  1567. return nil, &googleapi.Error{
  1568. Code: res.StatusCode,
  1569. Header: res.Header,
  1570. }
  1571. }
  1572. if err != nil {
  1573. return nil, err
  1574. }
  1575. defer googleapi.CloseBody(res)
  1576. if err := googleapi.CheckResponse(res); err != nil {
  1577. return nil, err
  1578. }
  1579. ret := &Empty{
  1580. ServerResponse: googleapi.ServerResponse{
  1581. Header: res.Header,
  1582. HTTPStatusCode: res.StatusCode,
  1583. },
  1584. }
  1585. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1586. return nil, err
  1587. }
  1588. return ret, nil
  1589. // {
  1590. // "description": "Modifies the `PushConfig` for a specified subscription. This may be used to change a push subscription to a pull one (signified by an empty `PushConfig`) or vice versa, or change the endpoint URL and other attributes of a push subscription. Messages will accumulate for delivery continuously through the call regardless of changes to the `PushConfig`.",
  1591. // "httpMethod": "POST",
  1592. // "id": "pubsub.projects.subscriptions.modifyPushConfig",
  1593. // "parameterOrder": [
  1594. // "subscription"
  1595. // ],
  1596. // "parameters": {
  1597. // "subscription": {
  1598. // "description": "The name of the subscription.",
  1599. // "location": "path",
  1600. // "pattern": "^projects/[^/]*/subscriptions/[^/]*$",
  1601. // "required": true,
  1602. // "type": "string"
  1603. // }
  1604. // },
  1605. // "path": "v1beta2/{+subscription}:modifyPushConfig",
  1606. // "request": {
  1607. // "$ref": "ModifyPushConfigRequest"
  1608. // },
  1609. // "response": {
  1610. // "$ref": "Empty"
  1611. // },
  1612. // "scopes": [
  1613. // "https://www.googleapis.com/auth/cloud-platform",
  1614. // "https://www.googleapis.com/auth/pubsub"
  1615. // ]
  1616. // }
  1617. }
  1618. // method id "pubsub.projects.subscriptions.pull":
  1619. type ProjectsSubscriptionsPullCall struct {
  1620. s *Service
  1621. subscription string
  1622. pullrequest *PullRequest
  1623. urlParams_ gensupport.URLParams
  1624. ctx_ context.Context
  1625. }
  1626. // Pull: Pulls messages from the server. Returns an empty list if there
  1627. // are no messages available in the backlog. The server may return
  1628. // `UNAVAILABLE` if there are too many concurrent pull requests pending
  1629. // for the given subscription.
  1630. func (r *ProjectsSubscriptionsService) Pull(subscription string, pullrequest *PullRequest) *ProjectsSubscriptionsPullCall {
  1631. c := &ProjectsSubscriptionsPullCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1632. c.subscription = subscription
  1633. c.pullrequest = pullrequest
  1634. return c
  1635. }
  1636. // Fields allows partial responses to be retrieved. See
  1637. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1638. // for more information.
  1639. func (c *ProjectsSubscriptionsPullCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsPullCall {
  1640. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1641. return c
  1642. }
  1643. // Context sets the context to be used in this call's Do method. Any
  1644. // pending HTTP request will be aborted if the provided context is
  1645. // canceled.
  1646. func (c *ProjectsSubscriptionsPullCall) Context(ctx context.Context) *ProjectsSubscriptionsPullCall {
  1647. c.ctx_ = ctx
  1648. return c
  1649. }
  1650. func (c *ProjectsSubscriptionsPullCall) doRequest(alt string) (*http.Response, error) {
  1651. var body io.Reader = nil
  1652. body, err := googleapi.WithoutDataWrapper.JSONReader(c.pullrequest)
  1653. if err != nil {
  1654. return nil, err
  1655. }
  1656. ctype := "application/json"
  1657. c.urlParams_.Set("alt", alt)
  1658. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+subscription}:pull")
  1659. urls += "?" + c.urlParams_.Encode()
  1660. req, _ := http.NewRequest("POST", urls, body)
  1661. googleapi.Expand(req.URL, map[string]string{
  1662. "subscription": c.subscription,
  1663. })
  1664. req.Header.Set("Content-Type", ctype)
  1665. req.Header.Set("User-Agent", c.s.userAgent())
  1666. if c.ctx_ != nil {
  1667. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1668. }
  1669. return c.s.client.Do(req)
  1670. }
  1671. // Do executes the "pubsub.projects.subscriptions.pull" call.
  1672. // Exactly one of *PullResponse or error will be non-nil. Any non-2xx
  1673. // status code is an error. Response headers are in either
  1674. // *PullResponse.ServerResponse.Header or (if a response was returned at
  1675. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1676. // to check whether the returned error was because
  1677. // http.StatusNotModified was returned.
  1678. func (c *ProjectsSubscriptionsPullCall) Do(opts ...googleapi.CallOption) (*PullResponse, error) {
  1679. gensupport.SetOptions(c.urlParams_, opts...)
  1680. res, err := c.doRequest("json")
  1681. if res != nil && res.StatusCode == http.StatusNotModified {
  1682. if res.Body != nil {
  1683. res.Body.Close()
  1684. }
  1685. return nil, &googleapi.Error{
  1686. Code: res.StatusCode,
  1687. Header: res.Header,
  1688. }
  1689. }
  1690. if err != nil {
  1691. return nil, err
  1692. }
  1693. defer googleapi.CloseBody(res)
  1694. if err := googleapi.CheckResponse(res); err != nil {
  1695. return nil, err
  1696. }
  1697. ret := &PullResponse{
  1698. ServerResponse: googleapi.ServerResponse{
  1699. Header: res.Header,
  1700. HTTPStatusCode: res.StatusCode,
  1701. },
  1702. }
  1703. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1704. return nil, err
  1705. }
  1706. return ret, nil
  1707. // {
  1708. // "description": "Pulls messages from the server. Returns an empty list if there are no messages available in the backlog. The server may return `UNAVAILABLE` if there are too many concurrent pull requests pending for the given subscription.",
  1709. // "httpMethod": "POST",
  1710. // "id": "pubsub.projects.subscriptions.pull",
  1711. // "parameterOrder": [
  1712. // "subscription"
  1713. // ],
  1714. // "parameters": {
  1715. // "subscription": {
  1716. // "description": "The subscription from which messages should be pulled.",
  1717. // "location": "path",
  1718. // "pattern": "^projects/[^/]*/subscriptions/[^/]*$",
  1719. // "required": true,
  1720. // "type": "string"
  1721. // }
  1722. // },
  1723. // "path": "v1beta2/{+subscription}:pull",
  1724. // "request": {
  1725. // "$ref": "PullRequest"
  1726. // },
  1727. // "response": {
  1728. // "$ref": "PullResponse"
  1729. // },
  1730. // "scopes": [
  1731. // "https://www.googleapis.com/auth/cloud-platform",
  1732. // "https://www.googleapis.com/auth/pubsub"
  1733. // ]
  1734. // }
  1735. }
  1736. // method id "pubsub.projects.subscriptions.setIamPolicy":
  1737. type ProjectsSubscriptionsSetIamPolicyCall struct {
  1738. s *Service
  1739. resource string
  1740. setiampolicyrequest *SetIamPolicyRequest
  1741. urlParams_ gensupport.URLParams
  1742. ctx_ context.Context
  1743. }
  1744. // SetIamPolicy: Sets the access control policy on the specified
  1745. // resource. Replaces any existing policy.
  1746. func (r *ProjectsSubscriptionsService) SetIamPolicy(resource string, setiampolicyrequest *SetIamPolicyRequest) *ProjectsSubscriptionsSetIamPolicyCall {
  1747. c := &ProjectsSubscriptionsSetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1748. c.resource = resource
  1749. c.setiampolicyrequest = setiampolicyrequest
  1750. return c
  1751. }
  1752. // Fields allows partial responses to be retrieved. See
  1753. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1754. // for more information.
  1755. func (c *ProjectsSubscriptionsSetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsSetIamPolicyCall {
  1756. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1757. return c
  1758. }
  1759. // Context sets the context to be used in this call's Do method. Any
  1760. // pending HTTP request will be aborted if the provided context is
  1761. // canceled.
  1762. func (c *ProjectsSubscriptionsSetIamPolicyCall) Context(ctx context.Context) *ProjectsSubscriptionsSetIamPolicyCall {
  1763. c.ctx_ = ctx
  1764. return c
  1765. }
  1766. func (c *ProjectsSubscriptionsSetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  1767. var body io.Reader = nil
  1768. body, err := googleapi.WithoutDataWrapper.JSONReader(c.setiampolicyrequest)
  1769. if err != nil {
  1770. return nil, err
  1771. }
  1772. ctype := "application/json"
  1773. c.urlParams_.Set("alt", alt)
  1774. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+resource}:setIamPolicy")
  1775. urls += "?" + c.urlParams_.Encode()
  1776. req, _ := http.NewRequest("POST", urls, body)
  1777. googleapi.Expand(req.URL, map[string]string{
  1778. "resource": c.resource,
  1779. })
  1780. req.Header.Set("Content-Type", ctype)
  1781. req.Header.Set("User-Agent", c.s.userAgent())
  1782. if c.ctx_ != nil {
  1783. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1784. }
  1785. return c.s.client.Do(req)
  1786. }
  1787. // Do executes the "pubsub.projects.subscriptions.setIamPolicy" call.
  1788. // Exactly one of *Policy or error will be non-nil. Any non-2xx status
  1789. // code is an error. Response headers are in either
  1790. // *Policy.ServerResponse.Header or (if a response was returned at all)
  1791. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1792. // check whether the returned error was because http.StatusNotModified
  1793. // was returned.
  1794. func (c *ProjectsSubscriptionsSetIamPolicyCall) Do(opts ...googleapi.CallOption) (*Policy, error) {
  1795. gensupport.SetOptions(c.urlParams_, opts...)
  1796. res, err := c.doRequest("json")
  1797. if res != nil && res.StatusCode == http.StatusNotModified {
  1798. if res.Body != nil {
  1799. res.Body.Close()
  1800. }
  1801. return nil, &googleapi.Error{
  1802. Code: res.StatusCode,
  1803. Header: res.Header,
  1804. }
  1805. }
  1806. if err != nil {
  1807. return nil, err
  1808. }
  1809. defer googleapi.CloseBody(res)
  1810. if err := googleapi.CheckResponse(res); err != nil {
  1811. return nil, err
  1812. }
  1813. ret := &Policy{
  1814. ServerResponse: googleapi.ServerResponse{
  1815. Header: res.Header,
  1816. HTTPStatusCode: res.StatusCode,
  1817. },
  1818. }
  1819. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1820. return nil, err
  1821. }
  1822. return ret, nil
  1823. // {
  1824. // "description": "Sets the access control policy on the specified resource. Replaces any existing policy.",
  1825. // "httpMethod": "POST",
  1826. // "id": "pubsub.projects.subscriptions.setIamPolicy",
  1827. // "parameterOrder": [
  1828. // "resource"
  1829. // ],
  1830. // "parameters": {
  1831. // "resource": {
  1832. // "description": "REQUIRED: The resource for which policy is being specified. `resource` is usually specified as a path, such as, `projects/{project}/zones/{zone}/disks/{disk}`. The format for the path specified in this value is resource specific and is specified in the documentation for the respective SetIamPolicy rpc.",
  1833. // "location": "path",
  1834. // "pattern": "^projects/[^/]*/subscriptions/[^/]*$",
  1835. // "required": true,
  1836. // "type": "string"
  1837. // }
  1838. // },
  1839. // "path": "v1beta2/{+resource}:setIamPolicy",
  1840. // "request": {
  1841. // "$ref": "SetIamPolicyRequest"
  1842. // },
  1843. // "response": {
  1844. // "$ref": "Policy"
  1845. // },
  1846. // "scopes": [
  1847. // "https://www.googleapis.com/auth/cloud-platform",
  1848. // "https://www.googleapis.com/auth/pubsub"
  1849. // ]
  1850. // }
  1851. }
  1852. // method id "pubsub.projects.subscriptions.testIamPermissions":
  1853. type ProjectsSubscriptionsTestIamPermissionsCall struct {
  1854. s *Service
  1855. resource string
  1856. testiampermissionsrequest *TestIamPermissionsRequest
  1857. urlParams_ gensupport.URLParams
  1858. ctx_ context.Context
  1859. }
  1860. // TestIamPermissions: Returns permissions that a caller has on the
  1861. // specified resource.
  1862. func (r *ProjectsSubscriptionsService) TestIamPermissions(resource string, testiampermissionsrequest *TestIamPermissionsRequest) *ProjectsSubscriptionsTestIamPermissionsCall {
  1863. c := &ProjectsSubscriptionsTestIamPermissionsCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1864. c.resource = resource
  1865. c.testiampermissionsrequest = testiampermissionsrequest
  1866. return c
  1867. }
  1868. // Fields allows partial responses to be retrieved. See
  1869. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1870. // for more information.
  1871. func (c *ProjectsSubscriptionsTestIamPermissionsCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsTestIamPermissionsCall {
  1872. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1873. return c
  1874. }
  1875. // Context sets the context to be used in this call's Do method. Any
  1876. // pending HTTP request will be aborted if the provided context is
  1877. // canceled.
  1878. func (c *ProjectsSubscriptionsTestIamPermissionsCall) Context(ctx context.Context) *ProjectsSubscriptionsTestIamPermissionsCall {
  1879. c.ctx_ = ctx
  1880. return c
  1881. }
  1882. func (c *ProjectsSubscriptionsTestIamPermissionsCall) doRequest(alt string) (*http.Response, error) {
  1883. var body io.Reader = nil
  1884. body, err := googleapi.WithoutDataWrapper.JSONReader(c.testiampermissionsrequest)
  1885. if err != nil {
  1886. return nil, err
  1887. }
  1888. ctype := "application/json"
  1889. c.urlParams_.Set("alt", alt)
  1890. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+resource}:testIamPermissions")
  1891. urls += "?" + c.urlParams_.Encode()
  1892. req, _ := http.NewRequest("POST", urls, body)
  1893. googleapi.Expand(req.URL, map[string]string{
  1894. "resource": c.resource,
  1895. })
  1896. req.Header.Set("Content-Type", ctype)
  1897. req.Header.Set("User-Agent", c.s.userAgent())
  1898. if c.ctx_ != nil {
  1899. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1900. }
  1901. return c.s.client.Do(req)
  1902. }
  1903. // Do executes the "pubsub.projects.subscriptions.testIamPermissions" call.
  1904. // Exactly one of *TestIamPermissionsResponse or error will be non-nil.
  1905. // Any non-2xx status code is an error. Response headers are in either
  1906. // *TestIamPermissionsResponse.ServerResponse.Header or (if a response
  1907. // was returned at all) in error.(*googleapi.Error).Header. Use
  1908. // googleapi.IsNotModified to check whether the returned error was
  1909. // because http.StatusNotModified was returned.
  1910. func (c *ProjectsSubscriptionsTestIamPermissionsCall) Do(opts ...googleapi.CallOption) (*TestIamPermissionsResponse, error) {
  1911. gensupport.SetOptions(c.urlParams_, opts...)
  1912. res, err := c.doRequest("json")
  1913. if res != nil && res.StatusCode == http.StatusNotModified {
  1914. if res.Body != nil {
  1915. res.Body.Close()
  1916. }
  1917. return nil, &googleapi.Error{
  1918. Code: res.StatusCode,
  1919. Header: res.Header,
  1920. }
  1921. }
  1922. if err != nil {
  1923. return nil, err
  1924. }
  1925. defer googleapi.CloseBody(res)
  1926. if err := googleapi.CheckResponse(res); err != nil {
  1927. return nil, err
  1928. }
  1929. ret := &TestIamPermissionsResponse{
  1930. ServerResponse: googleapi.ServerResponse{
  1931. Header: res.Header,
  1932. HTTPStatusCode: res.StatusCode,
  1933. },
  1934. }
  1935. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1936. return nil, err
  1937. }
  1938. return ret, nil
  1939. // {
  1940. // "description": "Returns permissions that a caller has on the specified resource.",
  1941. // "httpMethod": "POST",
  1942. // "id": "pubsub.projects.subscriptions.testIamPermissions",
  1943. // "parameterOrder": [
  1944. // "resource"
  1945. // ],
  1946. // "parameters": {
  1947. // "resource": {
  1948. // "description": "REQUIRED: The resource for which policy detail is being requested. `resource` is usually specified as a path, such as, `projects/{project}/zones/{zone}/disks/{disk}`. The format for the path specified in this value is resource specific and is specified in the documentation for the respective TestIamPermissions rpc.",
  1949. // "location": "path",
  1950. // "pattern": "^projects/[^/]*/subscriptions/[^/]*$",
  1951. // "required": true,
  1952. // "type": "string"
  1953. // }
  1954. // },
  1955. // "path": "v1beta2/{+resource}:testIamPermissions",
  1956. // "request": {
  1957. // "$ref": "TestIamPermissionsRequest"
  1958. // },
  1959. // "response": {
  1960. // "$ref": "TestIamPermissionsResponse"
  1961. // },
  1962. // "scopes": [
  1963. // "https://www.googleapis.com/auth/cloud-platform",
  1964. // "https://www.googleapis.com/auth/pubsub"
  1965. // ]
  1966. // }
  1967. }
  1968. // method id "pubsub.projects.topics.create":
  1969. type ProjectsTopicsCreateCall struct {
  1970. s *Service
  1971. name string
  1972. topic *Topic
  1973. urlParams_ gensupport.URLParams
  1974. ctx_ context.Context
  1975. }
  1976. // Create: Creates the given topic with the given name.
  1977. func (r *ProjectsTopicsService) Create(name string, topic *Topic) *ProjectsTopicsCreateCall {
  1978. c := &ProjectsTopicsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1979. c.name = name
  1980. c.topic = topic
  1981. return c
  1982. }
  1983. // Fields allows partial responses to be retrieved. See
  1984. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1985. // for more information.
  1986. func (c *ProjectsTopicsCreateCall) Fields(s ...googleapi.Field) *ProjectsTopicsCreateCall {
  1987. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1988. return c
  1989. }
  1990. // Context sets the context to be used in this call's Do method. Any
  1991. // pending HTTP request will be aborted if the provided context is
  1992. // canceled.
  1993. func (c *ProjectsTopicsCreateCall) Context(ctx context.Context) *ProjectsTopicsCreateCall {
  1994. c.ctx_ = ctx
  1995. return c
  1996. }
  1997. func (c *ProjectsTopicsCreateCall) doRequest(alt string) (*http.Response, error) {
  1998. var body io.Reader = nil
  1999. body, err := googleapi.WithoutDataWrapper.JSONReader(c.topic)
  2000. if err != nil {
  2001. return nil, err
  2002. }
  2003. ctype := "application/json"
  2004. c.urlParams_.Set("alt", alt)
  2005. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+name}")
  2006. urls += "?" + c.urlParams_.Encode()
  2007. req, _ := http.NewRequest("PUT", urls, body)
  2008. googleapi.Expand(req.URL, map[string]string{
  2009. "name": c.name,
  2010. })
  2011. req.Header.Set("Content-Type", ctype)
  2012. req.Header.Set("User-Agent", c.s.userAgent())
  2013. if c.ctx_ != nil {
  2014. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2015. }
  2016. return c.s.client.Do(req)
  2017. }
  2018. // Do executes the "pubsub.projects.topics.create" call.
  2019. // Exactly one of *Topic or error will be non-nil. Any non-2xx status
  2020. // code is an error. Response headers are in either
  2021. // *Topic.ServerResponse.Header or (if a response was returned at all)
  2022. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2023. // check whether the returned error was because http.StatusNotModified
  2024. // was returned.
  2025. func (c *ProjectsTopicsCreateCall) Do(opts ...googleapi.CallOption) (*Topic, error) {
  2026. gensupport.SetOptions(c.urlParams_, opts...)
  2027. res, err := c.doRequest("json")
  2028. if res != nil && res.StatusCode == http.StatusNotModified {
  2029. if res.Body != nil {
  2030. res.Body.Close()
  2031. }
  2032. return nil, &googleapi.Error{
  2033. Code: res.StatusCode,
  2034. Header: res.Header,
  2035. }
  2036. }
  2037. if err != nil {
  2038. return nil, err
  2039. }
  2040. defer googleapi.CloseBody(res)
  2041. if err := googleapi.CheckResponse(res); err != nil {
  2042. return nil, err
  2043. }
  2044. ret := &Topic{
  2045. ServerResponse: googleapi.ServerResponse{
  2046. Header: res.Header,
  2047. HTTPStatusCode: res.StatusCode,
  2048. },
  2049. }
  2050. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2051. return nil, err
  2052. }
  2053. return ret, nil
  2054. // {
  2055. // "description": "Creates the given topic with the given name.",
  2056. // "httpMethod": "PUT",
  2057. // "id": "pubsub.projects.topics.create",
  2058. // "parameterOrder": [
  2059. // "name"
  2060. // ],
  2061. // "parameters": {
  2062. // "name": {
  2063. // "description": "The name of the topic. It must have the format `\"projects/{project}/topics/{topic}\"`. `{topic}` must start with a letter, and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent signs (`%`). It must be between 3 and 255 characters in length, and it must not start with `\"goog\"`.",
  2064. // "location": "path",
  2065. // "pattern": "^projects/[^/]*/topics/[^/]*$",
  2066. // "required": true,
  2067. // "type": "string"
  2068. // }
  2069. // },
  2070. // "path": "v1beta2/{+name}",
  2071. // "request": {
  2072. // "$ref": "Topic"
  2073. // },
  2074. // "response": {
  2075. // "$ref": "Topic"
  2076. // },
  2077. // "scopes": [
  2078. // "https://www.googleapis.com/auth/cloud-platform",
  2079. // "https://www.googleapis.com/auth/pubsub"
  2080. // ]
  2081. // }
  2082. }
  2083. // method id "pubsub.projects.topics.delete":
  2084. type ProjectsTopicsDeleteCall struct {
  2085. s *Service
  2086. topic string
  2087. urlParams_ gensupport.URLParams
  2088. ctx_ context.Context
  2089. }
  2090. // Delete: Deletes the topic with the given name. Returns `NOT_FOUND` if
  2091. // the topic does not exist. After a topic is deleted, a new topic may
  2092. // be created with the same name; this is an entirely new topic with
  2093. // none of the old configuration or subscriptions. Existing
  2094. // subscriptions to this topic are not deleted, but their `topic` field
  2095. // is set to `_deleted-topic_`.
  2096. func (r *ProjectsTopicsService) Delete(topic string) *ProjectsTopicsDeleteCall {
  2097. c := &ProjectsTopicsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2098. c.topic = topic
  2099. return c
  2100. }
  2101. // Fields allows partial responses to be retrieved. See
  2102. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2103. // for more information.
  2104. func (c *ProjectsTopicsDeleteCall) Fields(s ...googleapi.Field) *ProjectsTopicsDeleteCall {
  2105. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2106. return c
  2107. }
  2108. // Context sets the context to be used in this call's Do method. Any
  2109. // pending HTTP request will be aborted if the provided context is
  2110. // canceled.
  2111. func (c *ProjectsTopicsDeleteCall) Context(ctx context.Context) *ProjectsTopicsDeleteCall {
  2112. c.ctx_ = ctx
  2113. return c
  2114. }
  2115. func (c *ProjectsTopicsDeleteCall) doRequest(alt string) (*http.Response, error) {
  2116. var body io.Reader = nil
  2117. c.urlParams_.Set("alt", alt)
  2118. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+topic}")
  2119. urls += "?" + c.urlParams_.Encode()
  2120. req, _ := http.NewRequest("DELETE", urls, body)
  2121. googleapi.Expand(req.URL, map[string]string{
  2122. "topic": c.topic,
  2123. })
  2124. req.Header.Set("User-Agent", c.s.userAgent())
  2125. if c.ctx_ != nil {
  2126. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2127. }
  2128. return c.s.client.Do(req)
  2129. }
  2130. // Do executes the "pubsub.projects.topics.delete" call.
  2131. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  2132. // code is an error. Response headers are in either
  2133. // *Empty.ServerResponse.Header or (if a response was returned at all)
  2134. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2135. // check whether the returned error was because http.StatusNotModified
  2136. // was returned.
  2137. func (c *ProjectsTopicsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  2138. gensupport.SetOptions(c.urlParams_, opts...)
  2139. res, err := c.doRequest("json")
  2140. if res != nil && res.StatusCode == http.StatusNotModified {
  2141. if res.Body != nil {
  2142. res.Body.Close()
  2143. }
  2144. return nil, &googleapi.Error{
  2145. Code: res.StatusCode,
  2146. Header: res.Header,
  2147. }
  2148. }
  2149. if err != nil {
  2150. return nil, err
  2151. }
  2152. defer googleapi.CloseBody(res)
  2153. if err := googleapi.CheckResponse(res); err != nil {
  2154. return nil, err
  2155. }
  2156. ret := &Empty{
  2157. ServerResponse: googleapi.ServerResponse{
  2158. Header: res.Header,
  2159. HTTPStatusCode: res.StatusCode,
  2160. },
  2161. }
  2162. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2163. return nil, err
  2164. }
  2165. return ret, nil
  2166. // {
  2167. // "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; this is an entirely new topic with none of the old configuration or subscriptions. Existing subscriptions to this topic are not deleted, but their `topic` field is set to `_deleted-topic_`.",
  2168. // "httpMethod": "DELETE",
  2169. // "id": "pubsub.projects.topics.delete",
  2170. // "parameterOrder": [
  2171. // "topic"
  2172. // ],
  2173. // "parameters": {
  2174. // "topic": {
  2175. // "description": "Name of the topic to delete.",
  2176. // "location": "path",
  2177. // "pattern": "^projects/[^/]*/topics/[^/]*$",
  2178. // "required": true,
  2179. // "type": "string"
  2180. // }
  2181. // },
  2182. // "path": "v1beta2/{+topic}",
  2183. // "response": {
  2184. // "$ref": "Empty"
  2185. // },
  2186. // "scopes": [
  2187. // "https://www.googleapis.com/auth/cloud-platform",
  2188. // "https://www.googleapis.com/auth/pubsub"
  2189. // ]
  2190. // }
  2191. }
  2192. // method id "pubsub.projects.topics.get":
  2193. type ProjectsTopicsGetCall struct {
  2194. s *Service
  2195. topic string
  2196. urlParams_ gensupport.URLParams
  2197. ifNoneMatch_ string
  2198. ctx_ context.Context
  2199. }
  2200. // Get: Gets the configuration of a topic.
  2201. func (r *ProjectsTopicsService) Get(topic string) *ProjectsTopicsGetCall {
  2202. c := &ProjectsTopicsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2203. c.topic = topic
  2204. return c
  2205. }
  2206. // Fields allows partial responses to be retrieved. See
  2207. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2208. // for more information.
  2209. func (c *ProjectsTopicsGetCall) Fields(s ...googleapi.Field) *ProjectsTopicsGetCall {
  2210. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2211. return c
  2212. }
  2213. // IfNoneMatch sets the optional parameter which makes the operation
  2214. // fail if the object's ETag matches the given value. This is useful for
  2215. // getting updates only after the object has changed since the last
  2216. // request. Use googleapi.IsNotModified to check whether the response
  2217. // error from Do is the result of In-None-Match.
  2218. func (c *ProjectsTopicsGetCall) IfNoneMatch(entityTag string) *ProjectsTopicsGetCall {
  2219. c.ifNoneMatch_ = entityTag
  2220. return c
  2221. }
  2222. // Context sets the context to be used in this call's Do method. Any
  2223. // pending HTTP request will be aborted if the provided context is
  2224. // canceled.
  2225. func (c *ProjectsTopicsGetCall) Context(ctx context.Context) *ProjectsTopicsGetCall {
  2226. c.ctx_ = ctx
  2227. return c
  2228. }
  2229. func (c *ProjectsTopicsGetCall) doRequest(alt string) (*http.Response, error) {
  2230. var body io.Reader = nil
  2231. c.urlParams_.Set("alt", alt)
  2232. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+topic}")
  2233. urls += "?" + c.urlParams_.Encode()
  2234. req, _ := http.NewRequest("GET", urls, body)
  2235. googleapi.Expand(req.URL, map[string]string{
  2236. "topic": c.topic,
  2237. })
  2238. req.Header.Set("User-Agent", c.s.userAgent())
  2239. if c.ifNoneMatch_ != "" {
  2240. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  2241. }
  2242. if c.ctx_ != nil {
  2243. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2244. }
  2245. return c.s.client.Do(req)
  2246. }
  2247. // Do executes the "pubsub.projects.topics.get" call.
  2248. // Exactly one of *Topic or error will be non-nil. Any non-2xx status
  2249. // code is an error. Response headers are in either
  2250. // *Topic.ServerResponse.Header or (if a response was returned at all)
  2251. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2252. // check whether the returned error was because http.StatusNotModified
  2253. // was returned.
  2254. func (c *ProjectsTopicsGetCall) Do(opts ...googleapi.CallOption) (*Topic, error) {
  2255. gensupport.SetOptions(c.urlParams_, opts...)
  2256. res, err := c.doRequest("json")
  2257. if res != nil && res.StatusCode == http.StatusNotModified {
  2258. if res.Body != nil {
  2259. res.Body.Close()
  2260. }
  2261. return nil, &googleapi.Error{
  2262. Code: res.StatusCode,
  2263. Header: res.Header,
  2264. }
  2265. }
  2266. if err != nil {
  2267. return nil, err
  2268. }
  2269. defer googleapi.CloseBody(res)
  2270. if err := googleapi.CheckResponse(res); err != nil {
  2271. return nil, err
  2272. }
  2273. ret := &Topic{
  2274. ServerResponse: googleapi.ServerResponse{
  2275. Header: res.Header,
  2276. HTTPStatusCode: res.StatusCode,
  2277. },
  2278. }
  2279. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2280. return nil, err
  2281. }
  2282. return ret, nil
  2283. // {
  2284. // "description": "Gets the configuration of a topic.",
  2285. // "httpMethod": "GET",
  2286. // "id": "pubsub.projects.topics.get",
  2287. // "parameterOrder": [
  2288. // "topic"
  2289. // ],
  2290. // "parameters": {
  2291. // "topic": {
  2292. // "description": "The name of the topic to get.",
  2293. // "location": "path",
  2294. // "pattern": "^projects/[^/]*/topics/[^/]*$",
  2295. // "required": true,
  2296. // "type": "string"
  2297. // }
  2298. // },
  2299. // "path": "v1beta2/{+topic}",
  2300. // "response": {
  2301. // "$ref": "Topic"
  2302. // },
  2303. // "scopes": [
  2304. // "https://www.googleapis.com/auth/cloud-platform",
  2305. // "https://www.googleapis.com/auth/pubsub"
  2306. // ]
  2307. // }
  2308. }
  2309. // method id "pubsub.projects.topics.getIamPolicy":
  2310. type ProjectsTopicsGetIamPolicyCall struct {
  2311. s *Service
  2312. resource string
  2313. urlParams_ gensupport.URLParams
  2314. ifNoneMatch_ string
  2315. ctx_ context.Context
  2316. }
  2317. // GetIamPolicy: Gets the access control policy for a `resource`. Is
  2318. // empty if the policy or the resource does not exist.
  2319. func (r *ProjectsTopicsService) GetIamPolicy(resource string) *ProjectsTopicsGetIamPolicyCall {
  2320. c := &ProjectsTopicsGetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2321. c.resource = resource
  2322. return c
  2323. }
  2324. // Fields allows partial responses to be retrieved. See
  2325. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2326. // for more information.
  2327. func (c *ProjectsTopicsGetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsTopicsGetIamPolicyCall {
  2328. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2329. return c
  2330. }
  2331. // IfNoneMatch sets the optional parameter which makes the operation
  2332. // fail if the object's ETag matches the given value. This is useful for
  2333. // getting updates only after the object has changed since the last
  2334. // request. Use googleapi.IsNotModified to check whether the response
  2335. // error from Do is the result of In-None-Match.
  2336. func (c *ProjectsTopicsGetIamPolicyCall) IfNoneMatch(entityTag string) *ProjectsTopicsGetIamPolicyCall {
  2337. c.ifNoneMatch_ = entityTag
  2338. return c
  2339. }
  2340. // Context sets the context to be used in this call's Do method. Any
  2341. // pending HTTP request will be aborted if the provided context is
  2342. // canceled.
  2343. func (c *ProjectsTopicsGetIamPolicyCall) Context(ctx context.Context) *ProjectsTopicsGetIamPolicyCall {
  2344. c.ctx_ = ctx
  2345. return c
  2346. }
  2347. func (c *ProjectsTopicsGetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  2348. var body io.Reader = nil
  2349. c.urlParams_.Set("alt", alt)
  2350. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+resource}:getIamPolicy")
  2351. urls += "?" + c.urlParams_.Encode()
  2352. req, _ := http.NewRequest("GET", urls, body)
  2353. googleapi.Expand(req.URL, map[string]string{
  2354. "resource": c.resource,
  2355. })
  2356. req.Header.Set("User-Agent", c.s.userAgent())
  2357. if c.ifNoneMatch_ != "" {
  2358. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  2359. }
  2360. if c.ctx_ != nil {
  2361. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2362. }
  2363. return c.s.client.Do(req)
  2364. }
  2365. // Do executes the "pubsub.projects.topics.getIamPolicy" call.
  2366. // Exactly one of *Policy or error will be non-nil. Any non-2xx status
  2367. // code is an error. Response headers are in either
  2368. // *Policy.ServerResponse.Header or (if a response was returned at all)
  2369. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2370. // check whether the returned error was because http.StatusNotModified
  2371. // was returned.
  2372. func (c *ProjectsTopicsGetIamPolicyCall) Do(opts ...googleapi.CallOption) (*Policy, error) {
  2373. gensupport.SetOptions(c.urlParams_, opts...)
  2374. res, err := c.doRequest("json")
  2375. if res != nil && res.StatusCode == http.StatusNotModified {
  2376. if res.Body != nil {
  2377. res.Body.Close()
  2378. }
  2379. return nil, &googleapi.Error{
  2380. Code: res.StatusCode,
  2381. Header: res.Header,
  2382. }
  2383. }
  2384. if err != nil {
  2385. return nil, err
  2386. }
  2387. defer googleapi.CloseBody(res)
  2388. if err := googleapi.CheckResponse(res); err != nil {
  2389. return nil, err
  2390. }
  2391. ret := &Policy{
  2392. ServerResponse: googleapi.ServerResponse{
  2393. Header: res.Header,
  2394. HTTPStatusCode: res.StatusCode,
  2395. },
  2396. }
  2397. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2398. return nil, err
  2399. }
  2400. return ret, nil
  2401. // {
  2402. // "description": "Gets the access control policy for a `resource`. Is empty if the policy or the resource does not exist.",
  2403. // "httpMethod": "GET",
  2404. // "id": "pubsub.projects.topics.getIamPolicy",
  2405. // "parameterOrder": [
  2406. // "resource"
  2407. // ],
  2408. // "parameters": {
  2409. // "resource": {
  2410. // "description": "REQUIRED: The resource for which policy is being requested. `resource` is usually specified as a path, such as, `projects/{project}/zones/{zone}/disks/{disk}`. The format for the path specified in this value is resource specific and is specified in the documentation for the respective GetIamPolicy rpc.",
  2411. // "location": "path",
  2412. // "pattern": "^projects/[^/]*/topics/[^/]*$",
  2413. // "required": true,
  2414. // "type": "string"
  2415. // }
  2416. // },
  2417. // "path": "v1beta2/{+resource}:getIamPolicy",
  2418. // "response": {
  2419. // "$ref": "Policy"
  2420. // },
  2421. // "scopes": [
  2422. // "https://www.googleapis.com/auth/cloud-platform",
  2423. // "https://www.googleapis.com/auth/pubsub"
  2424. // ]
  2425. // }
  2426. }
  2427. // method id "pubsub.projects.topics.list":
  2428. type ProjectsTopicsListCall struct {
  2429. s *Service
  2430. project string
  2431. urlParams_ gensupport.URLParams
  2432. ifNoneMatch_ string
  2433. ctx_ context.Context
  2434. }
  2435. // List: Lists matching topics.
  2436. func (r *ProjectsTopicsService) List(project string) *ProjectsTopicsListCall {
  2437. c := &ProjectsTopicsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2438. c.project = project
  2439. return c
  2440. }
  2441. // PageSize sets the optional parameter "pageSize": Maximum number of
  2442. // topics to return.
  2443. func (c *ProjectsTopicsListCall) PageSize(pageSize int64) *ProjectsTopicsListCall {
  2444. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  2445. return c
  2446. }
  2447. // PageToken sets the optional parameter "pageToken": The value returned
  2448. // by the last `ListTopicsResponse`; indicates that this is a
  2449. // continuation of a prior `ListTopics` call, and that the system should
  2450. // return the next page of data.
  2451. func (c *ProjectsTopicsListCall) PageToken(pageToken string) *ProjectsTopicsListCall {
  2452. c.urlParams_.Set("pageToken", pageToken)
  2453. return c
  2454. }
  2455. // Fields allows partial responses to be retrieved. See
  2456. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2457. // for more information.
  2458. func (c *ProjectsTopicsListCall) Fields(s ...googleapi.Field) *ProjectsTopicsListCall {
  2459. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2460. return c
  2461. }
  2462. // IfNoneMatch sets the optional parameter which makes the operation
  2463. // fail if the object's ETag matches the given value. This is useful for
  2464. // getting updates only after the object has changed since the last
  2465. // request. Use googleapi.IsNotModified to check whether the response
  2466. // error from Do is the result of In-None-Match.
  2467. func (c *ProjectsTopicsListCall) IfNoneMatch(entityTag string) *ProjectsTopicsListCall {
  2468. c.ifNoneMatch_ = entityTag
  2469. return c
  2470. }
  2471. // Context sets the context to be used in this call's Do method. Any
  2472. // pending HTTP request will be aborted if the provided context is
  2473. // canceled.
  2474. func (c *ProjectsTopicsListCall) Context(ctx context.Context) *ProjectsTopicsListCall {
  2475. c.ctx_ = ctx
  2476. return c
  2477. }
  2478. func (c *ProjectsTopicsListCall) doRequest(alt string) (*http.Response, error) {
  2479. var body io.Reader = nil
  2480. c.urlParams_.Set("alt", alt)
  2481. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+project}/topics")
  2482. urls += "?" + c.urlParams_.Encode()
  2483. req, _ := http.NewRequest("GET", urls, body)
  2484. googleapi.Expand(req.URL, map[string]string{
  2485. "project": c.project,
  2486. })
  2487. req.Header.Set("User-Agent", c.s.userAgent())
  2488. if c.ifNoneMatch_ != "" {
  2489. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  2490. }
  2491. if c.ctx_ != nil {
  2492. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2493. }
  2494. return c.s.client.Do(req)
  2495. }
  2496. // Do executes the "pubsub.projects.topics.list" call.
  2497. // Exactly one of *ListTopicsResponse or error will be non-nil. Any
  2498. // non-2xx status code is an error. Response headers are in either
  2499. // *ListTopicsResponse.ServerResponse.Header or (if a response was
  2500. // returned at all) in error.(*googleapi.Error).Header. Use
  2501. // googleapi.IsNotModified to check whether the returned error was
  2502. // because http.StatusNotModified was returned.
  2503. func (c *ProjectsTopicsListCall) Do(opts ...googleapi.CallOption) (*ListTopicsResponse, error) {
  2504. gensupport.SetOptions(c.urlParams_, opts...)
  2505. res, err := c.doRequest("json")
  2506. if res != nil && res.StatusCode == http.StatusNotModified {
  2507. if res.Body != nil {
  2508. res.Body.Close()
  2509. }
  2510. return nil, &googleapi.Error{
  2511. Code: res.StatusCode,
  2512. Header: res.Header,
  2513. }
  2514. }
  2515. if err != nil {
  2516. return nil, err
  2517. }
  2518. defer googleapi.CloseBody(res)
  2519. if err := googleapi.CheckResponse(res); err != nil {
  2520. return nil, err
  2521. }
  2522. ret := &ListTopicsResponse{
  2523. ServerResponse: googleapi.ServerResponse{
  2524. Header: res.Header,
  2525. HTTPStatusCode: res.StatusCode,
  2526. },
  2527. }
  2528. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2529. return nil, err
  2530. }
  2531. return ret, nil
  2532. // {
  2533. // "description": "Lists matching topics.",
  2534. // "httpMethod": "GET",
  2535. // "id": "pubsub.projects.topics.list",
  2536. // "parameterOrder": [
  2537. // "project"
  2538. // ],
  2539. // "parameters": {
  2540. // "pageSize": {
  2541. // "description": "Maximum number of topics to return.",
  2542. // "format": "int32",
  2543. // "location": "query",
  2544. // "type": "integer"
  2545. // },
  2546. // "pageToken": {
  2547. // "description": "The value returned by the last `ListTopicsResponse`; indicates that this is a continuation of a prior `ListTopics` call, and that the system should return the next page of data.",
  2548. // "location": "query",
  2549. // "type": "string"
  2550. // },
  2551. // "project": {
  2552. // "description": "The name of the cloud project that topics belong to.",
  2553. // "location": "path",
  2554. // "pattern": "^projects/[^/]*$",
  2555. // "required": true,
  2556. // "type": "string"
  2557. // }
  2558. // },
  2559. // "path": "v1beta2/{+project}/topics",
  2560. // "response": {
  2561. // "$ref": "ListTopicsResponse"
  2562. // },
  2563. // "scopes": [
  2564. // "https://www.googleapis.com/auth/cloud-platform",
  2565. // "https://www.googleapis.com/auth/pubsub"
  2566. // ]
  2567. // }
  2568. }
  2569. // Pages invokes f for each page of results.
  2570. // A non-nil error returned from f will halt the iteration.
  2571. // The provided context supersedes any context provided to the Context method.
  2572. func (c *ProjectsTopicsListCall) Pages(ctx context.Context, f func(*ListTopicsResponse) error) error {
  2573. c.ctx_ = ctx
  2574. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  2575. for {
  2576. x, err := c.Do()
  2577. if err != nil {
  2578. return err
  2579. }
  2580. if err := f(x); err != nil {
  2581. return err
  2582. }
  2583. if x.NextPageToken == "" {
  2584. return nil
  2585. }
  2586. c.PageToken(x.NextPageToken)
  2587. }
  2588. }
  2589. // method id "pubsub.projects.topics.publish":
  2590. type ProjectsTopicsPublishCall struct {
  2591. s *Service
  2592. topic string
  2593. publishrequest *PublishRequest
  2594. urlParams_ gensupport.URLParams
  2595. ctx_ context.Context
  2596. }
  2597. // Publish: Adds one or more messages to the topic. Returns `NOT_FOUND`
  2598. // if the topic does not exist. The message payload must not be empty;
  2599. // it must contain either a non-empty data field, or at least one
  2600. // attribute.
  2601. func (r *ProjectsTopicsService) Publish(topic string, publishrequest *PublishRequest) *ProjectsTopicsPublishCall {
  2602. c := &ProjectsTopicsPublishCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2603. c.topic = topic
  2604. c.publishrequest = publishrequest
  2605. return c
  2606. }
  2607. // Fields allows partial responses to be retrieved. See
  2608. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2609. // for more information.
  2610. func (c *ProjectsTopicsPublishCall) Fields(s ...googleapi.Field) *ProjectsTopicsPublishCall {
  2611. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2612. return c
  2613. }
  2614. // Context sets the context to be used in this call's Do method. Any
  2615. // pending HTTP request will be aborted if the provided context is
  2616. // canceled.
  2617. func (c *ProjectsTopicsPublishCall) Context(ctx context.Context) *ProjectsTopicsPublishCall {
  2618. c.ctx_ = ctx
  2619. return c
  2620. }
  2621. func (c *ProjectsTopicsPublishCall) doRequest(alt string) (*http.Response, error) {
  2622. var body io.Reader = nil
  2623. body, err := googleapi.WithoutDataWrapper.JSONReader(c.publishrequest)
  2624. if err != nil {
  2625. return nil, err
  2626. }
  2627. ctype := "application/json"
  2628. c.urlParams_.Set("alt", alt)
  2629. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+topic}:publish")
  2630. urls += "?" + c.urlParams_.Encode()
  2631. req, _ := http.NewRequest("POST", urls, body)
  2632. googleapi.Expand(req.URL, map[string]string{
  2633. "topic": c.topic,
  2634. })
  2635. req.Header.Set("Content-Type", ctype)
  2636. req.Header.Set("User-Agent", c.s.userAgent())
  2637. if c.ctx_ != nil {
  2638. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2639. }
  2640. return c.s.client.Do(req)
  2641. }
  2642. // Do executes the "pubsub.projects.topics.publish" call.
  2643. // Exactly one of *PublishResponse or error will be non-nil. Any non-2xx
  2644. // status code is an error. Response headers are in either
  2645. // *PublishResponse.ServerResponse.Header or (if a response was returned
  2646. // at all) in error.(*googleapi.Error).Header. Use
  2647. // googleapi.IsNotModified to check whether the returned error was
  2648. // because http.StatusNotModified was returned.
  2649. func (c *ProjectsTopicsPublishCall) Do(opts ...googleapi.CallOption) (*PublishResponse, error) {
  2650. gensupport.SetOptions(c.urlParams_, opts...)
  2651. res, err := c.doRequest("json")
  2652. if res != nil && res.StatusCode == http.StatusNotModified {
  2653. if res.Body != nil {
  2654. res.Body.Close()
  2655. }
  2656. return nil, &googleapi.Error{
  2657. Code: res.StatusCode,
  2658. Header: res.Header,
  2659. }
  2660. }
  2661. if err != nil {
  2662. return nil, err
  2663. }
  2664. defer googleapi.CloseBody(res)
  2665. if err := googleapi.CheckResponse(res); err != nil {
  2666. return nil, err
  2667. }
  2668. ret := &PublishResponse{
  2669. ServerResponse: googleapi.ServerResponse{
  2670. Header: res.Header,
  2671. HTTPStatusCode: res.StatusCode,
  2672. },
  2673. }
  2674. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2675. return nil, err
  2676. }
  2677. return ret, nil
  2678. // {
  2679. // "description": "Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic does not exist. The message payload must not be empty; it must contain either a non-empty data field, or at least one attribute.",
  2680. // "httpMethod": "POST",
  2681. // "id": "pubsub.projects.topics.publish",
  2682. // "parameterOrder": [
  2683. // "topic"
  2684. // ],
  2685. // "parameters": {
  2686. // "topic": {
  2687. // "description": "The messages in the request will be published on this topic.",
  2688. // "location": "path",
  2689. // "pattern": "^projects/[^/]*/topics/[^/]*$",
  2690. // "required": true,
  2691. // "type": "string"
  2692. // }
  2693. // },
  2694. // "path": "v1beta2/{+topic}:publish",
  2695. // "request": {
  2696. // "$ref": "PublishRequest"
  2697. // },
  2698. // "response": {
  2699. // "$ref": "PublishResponse"
  2700. // },
  2701. // "scopes": [
  2702. // "https://www.googleapis.com/auth/cloud-platform",
  2703. // "https://www.googleapis.com/auth/pubsub"
  2704. // ]
  2705. // }
  2706. }
  2707. // method id "pubsub.projects.topics.setIamPolicy":
  2708. type ProjectsTopicsSetIamPolicyCall struct {
  2709. s *Service
  2710. resource string
  2711. setiampolicyrequest *SetIamPolicyRequest
  2712. urlParams_ gensupport.URLParams
  2713. ctx_ context.Context
  2714. }
  2715. // SetIamPolicy: Sets the access control policy on the specified
  2716. // resource. Replaces any existing policy.
  2717. func (r *ProjectsTopicsService) SetIamPolicy(resource string, setiampolicyrequest *SetIamPolicyRequest) *ProjectsTopicsSetIamPolicyCall {
  2718. c := &ProjectsTopicsSetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2719. c.resource = resource
  2720. c.setiampolicyrequest = setiampolicyrequest
  2721. return c
  2722. }
  2723. // Fields allows partial responses to be retrieved. See
  2724. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2725. // for more information.
  2726. func (c *ProjectsTopicsSetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsTopicsSetIamPolicyCall {
  2727. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2728. return c
  2729. }
  2730. // Context sets the context to be used in this call's Do method. Any
  2731. // pending HTTP request will be aborted if the provided context is
  2732. // canceled.
  2733. func (c *ProjectsTopicsSetIamPolicyCall) Context(ctx context.Context) *ProjectsTopicsSetIamPolicyCall {
  2734. c.ctx_ = ctx
  2735. return c
  2736. }
  2737. func (c *ProjectsTopicsSetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  2738. var body io.Reader = nil
  2739. body, err := googleapi.WithoutDataWrapper.JSONReader(c.setiampolicyrequest)
  2740. if err != nil {
  2741. return nil, err
  2742. }
  2743. ctype := "application/json"
  2744. c.urlParams_.Set("alt", alt)
  2745. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+resource}:setIamPolicy")
  2746. urls += "?" + c.urlParams_.Encode()
  2747. req, _ := http.NewRequest("POST", urls, body)
  2748. googleapi.Expand(req.URL, map[string]string{
  2749. "resource": c.resource,
  2750. })
  2751. req.Header.Set("Content-Type", ctype)
  2752. req.Header.Set("User-Agent", c.s.userAgent())
  2753. if c.ctx_ != nil {
  2754. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2755. }
  2756. return c.s.client.Do(req)
  2757. }
  2758. // Do executes the "pubsub.projects.topics.setIamPolicy" call.
  2759. // Exactly one of *Policy or error will be non-nil. Any non-2xx status
  2760. // code is an error. Response headers are in either
  2761. // *Policy.ServerResponse.Header or (if a response was returned at all)
  2762. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2763. // check whether the returned error was because http.StatusNotModified
  2764. // was returned.
  2765. func (c *ProjectsTopicsSetIamPolicyCall) Do(opts ...googleapi.CallOption) (*Policy, error) {
  2766. gensupport.SetOptions(c.urlParams_, opts...)
  2767. res, err := c.doRequest("json")
  2768. if res != nil && res.StatusCode == http.StatusNotModified {
  2769. if res.Body != nil {
  2770. res.Body.Close()
  2771. }
  2772. return nil, &googleapi.Error{
  2773. Code: res.StatusCode,
  2774. Header: res.Header,
  2775. }
  2776. }
  2777. if err != nil {
  2778. return nil, err
  2779. }
  2780. defer googleapi.CloseBody(res)
  2781. if err := googleapi.CheckResponse(res); err != nil {
  2782. return nil, err
  2783. }
  2784. ret := &Policy{
  2785. ServerResponse: googleapi.ServerResponse{
  2786. Header: res.Header,
  2787. HTTPStatusCode: res.StatusCode,
  2788. },
  2789. }
  2790. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2791. return nil, err
  2792. }
  2793. return ret, nil
  2794. // {
  2795. // "description": "Sets the access control policy on the specified resource. Replaces any existing policy.",
  2796. // "httpMethod": "POST",
  2797. // "id": "pubsub.projects.topics.setIamPolicy",
  2798. // "parameterOrder": [
  2799. // "resource"
  2800. // ],
  2801. // "parameters": {
  2802. // "resource": {
  2803. // "description": "REQUIRED: The resource for which policy is being specified. `resource` is usually specified as a path, such as, `projects/{project}/zones/{zone}/disks/{disk}`. The format for the path specified in this value is resource specific and is specified in the documentation for the respective SetIamPolicy rpc.",
  2804. // "location": "path",
  2805. // "pattern": "^projects/[^/]*/topics/[^/]*$",
  2806. // "required": true,
  2807. // "type": "string"
  2808. // }
  2809. // },
  2810. // "path": "v1beta2/{+resource}:setIamPolicy",
  2811. // "request": {
  2812. // "$ref": "SetIamPolicyRequest"
  2813. // },
  2814. // "response": {
  2815. // "$ref": "Policy"
  2816. // },
  2817. // "scopes": [
  2818. // "https://www.googleapis.com/auth/cloud-platform",
  2819. // "https://www.googleapis.com/auth/pubsub"
  2820. // ]
  2821. // }
  2822. }
  2823. // method id "pubsub.projects.topics.testIamPermissions":
  2824. type ProjectsTopicsTestIamPermissionsCall struct {
  2825. s *Service
  2826. resource string
  2827. testiampermissionsrequest *TestIamPermissionsRequest
  2828. urlParams_ gensupport.URLParams
  2829. ctx_ context.Context
  2830. }
  2831. // TestIamPermissions: Returns permissions that a caller has on the
  2832. // specified resource.
  2833. func (r *ProjectsTopicsService) TestIamPermissions(resource string, testiampermissionsrequest *TestIamPermissionsRequest) *ProjectsTopicsTestIamPermissionsCall {
  2834. c := &ProjectsTopicsTestIamPermissionsCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2835. c.resource = resource
  2836. c.testiampermissionsrequest = testiampermissionsrequest
  2837. return c
  2838. }
  2839. // Fields allows partial responses to be retrieved. See
  2840. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2841. // for more information.
  2842. func (c *ProjectsTopicsTestIamPermissionsCall) Fields(s ...googleapi.Field) *ProjectsTopicsTestIamPermissionsCall {
  2843. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2844. return c
  2845. }
  2846. // Context sets the context to be used in this call's Do method. Any
  2847. // pending HTTP request will be aborted if the provided context is
  2848. // canceled.
  2849. func (c *ProjectsTopicsTestIamPermissionsCall) Context(ctx context.Context) *ProjectsTopicsTestIamPermissionsCall {
  2850. c.ctx_ = ctx
  2851. return c
  2852. }
  2853. func (c *ProjectsTopicsTestIamPermissionsCall) doRequest(alt string) (*http.Response, error) {
  2854. var body io.Reader = nil
  2855. body, err := googleapi.WithoutDataWrapper.JSONReader(c.testiampermissionsrequest)
  2856. if err != nil {
  2857. return nil, err
  2858. }
  2859. ctype := "application/json"
  2860. c.urlParams_.Set("alt", alt)
  2861. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+resource}:testIamPermissions")
  2862. urls += "?" + c.urlParams_.Encode()
  2863. req, _ := http.NewRequest("POST", urls, body)
  2864. googleapi.Expand(req.URL, map[string]string{
  2865. "resource": c.resource,
  2866. })
  2867. req.Header.Set("Content-Type", ctype)
  2868. req.Header.Set("User-Agent", c.s.userAgent())
  2869. if c.ctx_ != nil {
  2870. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2871. }
  2872. return c.s.client.Do(req)
  2873. }
  2874. // Do executes the "pubsub.projects.topics.testIamPermissions" call.
  2875. // Exactly one of *TestIamPermissionsResponse or error will be non-nil.
  2876. // Any non-2xx status code is an error. Response headers are in either
  2877. // *TestIamPermissionsResponse.ServerResponse.Header or (if a response
  2878. // was returned at all) in error.(*googleapi.Error).Header. Use
  2879. // googleapi.IsNotModified to check whether the returned error was
  2880. // because http.StatusNotModified was returned.
  2881. func (c *ProjectsTopicsTestIamPermissionsCall) Do(opts ...googleapi.CallOption) (*TestIamPermissionsResponse, error) {
  2882. gensupport.SetOptions(c.urlParams_, opts...)
  2883. res, err := c.doRequest("json")
  2884. if res != nil && res.StatusCode == http.StatusNotModified {
  2885. if res.Body != nil {
  2886. res.Body.Close()
  2887. }
  2888. return nil, &googleapi.Error{
  2889. Code: res.StatusCode,
  2890. Header: res.Header,
  2891. }
  2892. }
  2893. if err != nil {
  2894. return nil, err
  2895. }
  2896. defer googleapi.CloseBody(res)
  2897. if err := googleapi.CheckResponse(res); err != nil {
  2898. return nil, err
  2899. }
  2900. ret := &TestIamPermissionsResponse{
  2901. ServerResponse: googleapi.ServerResponse{
  2902. Header: res.Header,
  2903. HTTPStatusCode: res.StatusCode,
  2904. },
  2905. }
  2906. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2907. return nil, err
  2908. }
  2909. return ret, nil
  2910. // {
  2911. // "description": "Returns permissions that a caller has on the specified resource.",
  2912. // "httpMethod": "POST",
  2913. // "id": "pubsub.projects.topics.testIamPermissions",
  2914. // "parameterOrder": [
  2915. // "resource"
  2916. // ],
  2917. // "parameters": {
  2918. // "resource": {
  2919. // "description": "REQUIRED: The resource for which policy detail is being requested. `resource` is usually specified as a path, such as, `projects/{project}/zones/{zone}/disks/{disk}`. The format for the path specified in this value is resource specific and is specified in the documentation for the respective TestIamPermissions rpc.",
  2920. // "location": "path",
  2921. // "pattern": "^projects/[^/]*/topics/[^/]*$",
  2922. // "required": true,
  2923. // "type": "string"
  2924. // }
  2925. // },
  2926. // "path": "v1beta2/{+resource}:testIamPermissions",
  2927. // "request": {
  2928. // "$ref": "TestIamPermissionsRequest"
  2929. // },
  2930. // "response": {
  2931. // "$ref": "TestIamPermissionsResponse"
  2932. // },
  2933. // "scopes": [
  2934. // "https://www.googleapis.com/auth/cloud-platform",
  2935. // "https://www.googleapis.com/auth/pubsub"
  2936. // ]
  2937. // }
  2938. }
  2939. // method id "pubsub.projects.topics.subscriptions.list":
  2940. type ProjectsTopicsSubscriptionsListCall struct {
  2941. s *Service
  2942. topic string
  2943. urlParams_ gensupport.URLParams
  2944. ifNoneMatch_ string
  2945. ctx_ context.Context
  2946. }
  2947. // List: Lists the name of the subscriptions for this topic.
  2948. func (r *ProjectsTopicsSubscriptionsService) List(topic string) *ProjectsTopicsSubscriptionsListCall {
  2949. c := &ProjectsTopicsSubscriptionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2950. c.topic = topic
  2951. return c
  2952. }
  2953. // PageSize sets the optional parameter "pageSize": Maximum number of
  2954. // subscription names to return.
  2955. func (c *ProjectsTopicsSubscriptionsListCall) PageSize(pageSize int64) *ProjectsTopicsSubscriptionsListCall {
  2956. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  2957. return c
  2958. }
  2959. // PageToken sets the optional parameter "pageToken": The value returned
  2960. // by the last `ListTopicSubscriptionsResponse`; indicates that this is
  2961. // a continuation of a prior `ListTopicSubscriptions` call, and that the
  2962. // system should return the next page of data.
  2963. func (c *ProjectsTopicsSubscriptionsListCall) PageToken(pageToken string) *ProjectsTopicsSubscriptionsListCall {
  2964. c.urlParams_.Set("pageToken", pageToken)
  2965. return c
  2966. }
  2967. // Fields allows partial responses to be retrieved. See
  2968. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2969. // for more information.
  2970. func (c *ProjectsTopicsSubscriptionsListCall) Fields(s ...googleapi.Field) *ProjectsTopicsSubscriptionsListCall {
  2971. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2972. return c
  2973. }
  2974. // IfNoneMatch sets the optional parameter which makes the operation
  2975. // fail if the object's ETag matches the given value. This is useful for
  2976. // getting updates only after the object has changed since the last
  2977. // request. Use googleapi.IsNotModified to check whether the response
  2978. // error from Do is the result of In-None-Match.
  2979. func (c *ProjectsTopicsSubscriptionsListCall) IfNoneMatch(entityTag string) *ProjectsTopicsSubscriptionsListCall {
  2980. c.ifNoneMatch_ = entityTag
  2981. return c
  2982. }
  2983. // Context sets the context to be used in this call's Do method. Any
  2984. // pending HTTP request will be aborted if the provided context is
  2985. // canceled.
  2986. func (c *ProjectsTopicsSubscriptionsListCall) Context(ctx context.Context) *ProjectsTopicsSubscriptionsListCall {
  2987. c.ctx_ = ctx
  2988. return c
  2989. }
  2990. func (c *ProjectsTopicsSubscriptionsListCall) doRequest(alt string) (*http.Response, error) {
  2991. var body io.Reader = nil
  2992. c.urlParams_.Set("alt", alt)
  2993. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+topic}/subscriptions")
  2994. urls += "?" + c.urlParams_.Encode()
  2995. req, _ := http.NewRequest("GET", urls, body)
  2996. googleapi.Expand(req.URL, map[string]string{
  2997. "topic": c.topic,
  2998. })
  2999. req.Header.Set("User-Agent", c.s.userAgent())
  3000. if c.ifNoneMatch_ != "" {
  3001. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  3002. }
  3003. if c.ctx_ != nil {
  3004. return ctxhttp.Do(c.ctx_, c.s.client, req)
  3005. }
  3006. return c.s.client.Do(req)
  3007. }
  3008. // Do executes the "pubsub.projects.topics.subscriptions.list" call.
  3009. // Exactly one of *ListTopicSubscriptionsResponse or error will be
  3010. // non-nil. Any non-2xx status code is an error. Response headers are in
  3011. // either *ListTopicSubscriptionsResponse.ServerResponse.Header or (if a
  3012. // response was returned at all) in error.(*googleapi.Error).Header. Use
  3013. // googleapi.IsNotModified to check whether the returned error was
  3014. // because http.StatusNotModified was returned.
  3015. func (c *ProjectsTopicsSubscriptionsListCall) Do(opts ...googleapi.CallOption) (*ListTopicSubscriptionsResponse, error) {
  3016. gensupport.SetOptions(c.urlParams_, opts...)
  3017. res, err := c.doRequest("json")
  3018. if res != nil && res.StatusCode == http.StatusNotModified {
  3019. if res.Body != nil {
  3020. res.Body.Close()
  3021. }
  3022. return nil, &googleapi.Error{
  3023. Code: res.StatusCode,
  3024. Header: res.Header,
  3025. }
  3026. }
  3027. if err != nil {
  3028. return nil, err
  3029. }
  3030. defer googleapi.CloseBody(res)
  3031. if err := googleapi.CheckResponse(res); err != nil {
  3032. return nil, err
  3033. }
  3034. ret := &ListTopicSubscriptionsResponse{
  3035. ServerResponse: googleapi.ServerResponse{
  3036. Header: res.Header,
  3037. HTTPStatusCode: res.StatusCode,
  3038. },
  3039. }
  3040. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  3041. return nil, err
  3042. }
  3043. return ret, nil
  3044. // {
  3045. // "description": "Lists the name of the subscriptions for this topic.",
  3046. // "httpMethod": "GET",
  3047. // "id": "pubsub.projects.topics.subscriptions.list",
  3048. // "parameterOrder": [
  3049. // "topic"
  3050. // ],
  3051. // "parameters": {
  3052. // "pageSize": {
  3053. // "description": "Maximum number of subscription names to return.",
  3054. // "format": "int32",
  3055. // "location": "query",
  3056. // "type": "integer"
  3057. // },
  3058. // "pageToken": {
  3059. // "description": "The value returned by the last `ListTopicSubscriptionsResponse`; indicates that this is a continuation of a prior `ListTopicSubscriptions` call, and that the system should return the next page of data.",
  3060. // "location": "query",
  3061. // "type": "string"
  3062. // },
  3063. // "topic": {
  3064. // "description": "The name of the topic that subscriptions are attached to.",
  3065. // "location": "path",
  3066. // "pattern": "^projects/[^/]*/topics/[^/]*$",
  3067. // "required": true,
  3068. // "type": "string"
  3069. // }
  3070. // },
  3071. // "path": "v1beta2/{+topic}/subscriptions",
  3072. // "response": {
  3073. // "$ref": "ListTopicSubscriptionsResponse"
  3074. // },
  3075. // "scopes": [
  3076. // "https://www.googleapis.com/auth/cloud-platform",
  3077. // "https://www.googleapis.com/auth/pubsub"
  3078. // ]
  3079. // }
  3080. }
  3081. // Pages invokes f for each page of results.
  3082. // A non-nil error returned from f will halt the iteration.
  3083. // The provided context supersedes any context provided to the Context method.
  3084. func (c *ProjectsTopicsSubscriptionsListCall) Pages(ctx context.Context, f func(*ListTopicSubscriptionsResponse) error) error {
  3085. c.ctx_ = ctx
  3086. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  3087. for {
  3088. x, err := c.Do()
  3089. if err != nil {
  3090. return err
  3091. }
  3092. if err := f(x); err != nil {
  3093. return err
  3094. }
  3095. if x.NextPageToken == "" {
  3096. return nil
  3097. }
  3098. c.PageToken(x.NextPageToken)
  3099. }
  3100. }