pubsub-gen.go 119 KB

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