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

6105 lines
214 KiB

  1. // Package pubsub provides access to the Cloud Pub/Sub API.
  2. //
  3. // See https://cloud.google.com/pubsub/docs
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/pubsub/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.Snapshots = NewProjectsSnapshotsService(s)
  74. rs.Subscriptions = NewProjectsSubscriptionsService(s)
  75. rs.Topics = NewProjectsTopicsService(s)
  76. return rs
  77. }
  78. type ProjectsService struct {
  79. s *Service
  80. Snapshots *ProjectsSnapshotsService
  81. Subscriptions *ProjectsSubscriptionsService
  82. Topics *ProjectsTopicsService
  83. }
  84. func NewProjectsSnapshotsService(s *Service) *ProjectsSnapshotsService {
  85. rs := &ProjectsSnapshotsService{s: s}
  86. return rs
  87. }
  88. type ProjectsSnapshotsService struct {
  89. s *Service
  90. }
  91. func NewProjectsSubscriptionsService(s *Service) *ProjectsSubscriptionsService {
  92. rs := &ProjectsSubscriptionsService{s: s}
  93. return rs
  94. }
  95. type ProjectsSubscriptionsService struct {
  96. s *Service
  97. }
  98. func NewProjectsTopicsService(s *Service) *ProjectsTopicsService {
  99. rs := &ProjectsTopicsService{s: s}
  100. rs.Snapshots = NewProjectsTopicsSnapshotsService(s)
  101. rs.Subscriptions = NewProjectsTopicsSubscriptionsService(s)
  102. return rs
  103. }
  104. type ProjectsTopicsService struct {
  105. s *Service
  106. Snapshots *ProjectsTopicsSnapshotsService
  107. Subscriptions *ProjectsTopicsSubscriptionsService
  108. }
  109. func NewProjectsTopicsSnapshotsService(s *Service) *ProjectsTopicsSnapshotsService {
  110. rs := &ProjectsTopicsSnapshotsService{s: s}
  111. return rs
  112. }
  113. type ProjectsTopicsSnapshotsService struct {
  114. s *Service
  115. }
  116. func NewProjectsTopicsSubscriptionsService(s *Service) *ProjectsTopicsSubscriptionsService {
  117. rs := &ProjectsTopicsSubscriptionsService{s: s}
  118. return rs
  119. }
  120. type ProjectsTopicsSubscriptionsService struct {
  121. s *Service
  122. }
  123. // AcknowledgeRequest: Request for the Acknowledge method.
  124. type AcknowledgeRequest struct {
  125. // AckIds: The acknowledgment ID for the messages being acknowledged
  126. // that was returned
  127. // by the Pub/Sub system in the `Pull` response. Must not be empty.
  128. AckIds []string `json:"ackIds,omitempty"`
  129. // ForceSendFields is a list of field names (e.g. "AckIds") to
  130. // unconditionally include in API requests. By default, fields with
  131. // empty values are omitted from API requests. However, any non-pointer,
  132. // non-interface field appearing in ForceSendFields will be sent to the
  133. // server regardless of whether the field is empty or not. This may be
  134. // used to include empty fields in Patch requests.
  135. ForceSendFields []string `json:"-"`
  136. // NullFields is a list of field names (e.g. "AckIds") to include in API
  137. // requests with the JSON null value. By default, fields with empty
  138. // values are omitted from API requests. However, any field with an
  139. // empty value appearing in NullFields will be sent to the server as
  140. // null. It is an error if a field in this list has a non-empty value.
  141. // This may be used to include null fields in Patch requests.
  142. NullFields []string `json:"-"`
  143. }
  144. func (s *AcknowledgeRequest) MarshalJSON() ([]byte, error) {
  145. type NoMethod AcknowledgeRequest
  146. raw := NoMethod(*s)
  147. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  148. }
  149. // Binding: Associates `members` with a `role`.
  150. type Binding struct {
  151. // Members: Specifies the identities requesting access for a Cloud
  152. // Platform resource.
  153. // `members` can have the following values:
  154. //
  155. // * `allUsers`: A special identifier that represents anyone who is
  156. // on the internet; with or without a Google account.
  157. //
  158. // * `allAuthenticatedUsers`: A special identifier that represents
  159. // anyone
  160. // who is authenticated with a Google account or a service
  161. // account.
  162. //
  163. // * `user:{emailid}`: An email address that represents a specific
  164. // Google
  165. // account. For example, `alice@gmail.com` .
  166. //
  167. //
  168. // * `serviceAccount:{emailid}`: An email address that represents a
  169. // service
  170. // account. For example,
  171. // `my-other-app@appspot.gserviceaccount.com`.
  172. //
  173. // * `group:{emailid}`: An email address that represents a Google
  174. // group.
  175. // For example, `admins@example.com`.
  176. //
  177. //
  178. // * `domain:{domain}`: A Google Apps domain name that represents all
  179. // the
  180. // users of that domain. For example, `google.com` or
  181. // `example.com`.
  182. //
  183. //
  184. Members []string `json:"members,omitempty"`
  185. // Role: Role that is assigned to `members`.
  186. // For example, `roles/viewer`, `roles/editor`, or
  187. // `roles/owner`.
  188. // Required
  189. Role string `json:"role,omitempty"`
  190. // ForceSendFields is a list of field names (e.g. "Members") to
  191. // unconditionally include in API requests. By default, fields with
  192. // empty values are omitted from API requests. However, any non-pointer,
  193. // non-interface field appearing in ForceSendFields will be sent to the
  194. // server regardless of whether the field is empty or not. This may be
  195. // used to include empty fields in Patch requests.
  196. ForceSendFields []string `json:"-"`
  197. // NullFields is a list of field names (e.g. "Members") to include in
  198. // API requests with the JSON null value. By default, fields with empty
  199. // values are omitted from API requests. However, any field with an
  200. // empty value appearing in NullFields will be sent to the server as
  201. // null. It is an error if a field in this list has a non-empty value.
  202. // This may be used to include null fields in Patch requests.
  203. NullFields []string `json:"-"`
  204. }
  205. func (s *Binding) MarshalJSON() ([]byte, error) {
  206. type NoMethod Binding
  207. raw := NoMethod(*s)
  208. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  209. }
  210. // CreateSnapshotRequest: Request for the `CreateSnapshot`
  211. // method.<br><br>
  212. // <b>ALPHA:</b> This feature is part of an alpha release. This API
  213. // might be changed in
  214. // backward-incompatible ways and is not recommended for production
  215. // use.
  216. // It is not subject to any SLA or deprecation policy.
  217. type CreateSnapshotRequest struct {
  218. // Subscription: The subscription whose backlog the snapshot
  219. // retains.
  220. // Specifically, the created snapshot is guaranteed to retain:
  221. // (a) The existing backlog on the subscription. More precisely, this
  222. // is
  223. // defined as the messages in the subscription's backlog that are
  224. // unacknowledged upon the successful completion of the
  225. // `CreateSnapshot` request; as well as:
  226. // (b) Any messages published to the subscription's topic following
  227. // the
  228. // successful completion of the CreateSnapshot request.
  229. // Format is `projects/{project}/subscriptions/{sub}`.
  230. Subscription string `json:"subscription,omitempty"`
  231. // ForceSendFields is a list of field names (e.g. "Subscription") to
  232. // unconditionally include in API requests. By default, fields with
  233. // empty values are omitted from API requests. However, any non-pointer,
  234. // non-interface field appearing in ForceSendFields will be sent to the
  235. // server regardless of whether the field is empty or not. This may be
  236. // used to include empty fields in Patch requests.
  237. ForceSendFields []string `json:"-"`
  238. // NullFields is a list of field names (e.g. "Subscription") to include
  239. // in API requests with the JSON null value. By default, fields with
  240. // empty values are omitted from API requests. However, any field with
  241. // an empty value appearing in NullFields will be sent to the server as
  242. // null. It is an error if a field in this list has a non-empty value.
  243. // This may be used to include null fields in Patch requests.
  244. NullFields []string `json:"-"`
  245. }
  246. func (s *CreateSnapshotRequest) MarshalJSON() ([]byte, error) {
  247. type NoMethod CreateSnapshotRequest
  248. raw := NoMethod(*s)
  249. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  250. }
  251. // Empty: A generic empty message that you can re-use to avoid defining
  252. // duplicated
  253. // empty messages in your APIs. A typical example is to use it as the
  254. // request
  255. // or the response type of an API method. For instance:
  256. //
  257. // service Foo {
  258. // rpc Bar(google.protobuf.Empty) returns
  259. // (google.protobuf.Empty);
  260. // }
  261. //
  262. // The JSON representation for `Empty` is empty JSON object `{}`.
  263. type Empty struct {
  264. // ServerResponse contains the HTTP response code and headers from the
  265. // server.
  266. googleapi.ServerResponse `json:"-"`
  267. }
  268. // ListSnapshotsResponse: Response for the `ListSnapshots`
  269. // method.<br><br>
  270. // <b>ALPHA:</b> This feature is part of an alpha release. This API
  271. // might be
  272. // changed in backward-incompatible ways and is not recommended for
  273. // production
  274. // use. It is not subject to any SLA or deprecation policy.
  275. type ListSnapshotsResponse struct {
  276. // NextPageToken: If not empty, indicates that there may be more
  277. // snapshot that match the
  278. // request; this value should be passed in a new `ListSnapshotsRequest`.
  279. NextPageToken string `json:"nextPageToken,omitempty"`
  280. // Snapshots: The resulting snapshots.
  281. Snapshots []*Snapshot `json:"snapshots,omitempty"`
  282. // ServerResponse contains the HTTP response code and headers from the
  283. // server.
  284. googleapi.ServerResponse `json:"-"`
  285. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  286. // unconditionally include in API requests. By default, fields with
  287. // empty values are omitted from API requests. However, any non-pointer,
  288. // non-interface field appearing in ForceSendFields will be sent to the
  289. // server regardless of whether the field is empty or not. This may be
  290. // used to include empty fields in Patch requests.
  291. ForceSendFields []string `json:"-"`
  292. // NullFields is a list of field names (e.g. "NextPageToken") to include
  293. // in API requests with the JSON null value. By default, fields with
  294. // empty values are omitted from API requests. However, any field with
  295. // an empty value appearing in NullFields will be sent to the server as
  296. // null. It is an error if a field in this list has a non-empty value.
  297. // This may be used to include null fields in Patch requests.
  298. NullFields []string `json:"-"`
  299. }
  300. func (s *ListSnapshotsResponse) MarshalJSON() ([]byte, error) {
  301. type NoMethod ListSnapshotsResponse
  302. raw := NoMethod(*s)
  303. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  304. }
  305. // ListSubscriptionsResponse: Response for the `ListSubscriptions`
  306. // method.
  307. type ListSubscriptionsResponse struct {
  308. // NextPageToken: If not empty, indicates that there may be more
  309. // subscriptions that match
  310. // the request; this value should be passed in a
  311. // new
  312. // `ListSubscriptionsRequest` to get more subscriptions.
  313. NextPageToken string `json:"nextPageToken,omitempty"`
  314. // Subscriptions: The subscriptions that match the request.
  315. Subscriptions []*Subscription `json:"subscriptions,omitempty"`
  316. // ServerResponse contains the HTTP response code and headers from the
  317. // server.
  318. googleapi.ServerResponse `json:"-"`
  319. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  320. // unconditionally include in API requests. By default, fields with
  321. // empty values are omitted from API requests. However, any non-pointer,
  322. // non-interface field appearing in ForceSendFields will be sent to the
  323. // server regardless of whether the field is empty or not. This may be
  324. // used to include empty fields in Patch requests.
  325. ForceSendFields []string `json:"-"`
  326. // NullFields is a list of field names (e.g. "NextPageToken") to include
  327. // in API requests with the JSON null value. By default, fields with
  328. // empty values are omitted from API requests. However, any field with
  329. // an empty value appearing in NullFields will be sent to the server as
  330. // null. It is an error if a field in this list has a non-empty value.
  331. // This may be used to include null fields in Patch requests.
  332. NullFields []string `json:"-"`
  333. }
  334. func (s *ListSubscriptionsResponse) MarshalJSON() ([]byte, error) {
  335. type NoMethod ListSubscriptionsResponse
  336. raw := NoMethod(*s)
  337. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  338. }
  339. // ListTopicSnapshotsResponse: Response for the `ListTopicSnapshots`
  340. // method.<br><br>
  341. // <b>ALPHA:</b> This feature is part of an alpha release. This API
  342. // might be
  343. // changed in backward-incompatible ways and is not recommended for
  344. // production
  345. // use. It is not subject to any SLA or deprecation policy.
  346. type ListTopicSnapshotsResponse struct {
  347. // NextPageToken: If not empty, indicates that there may be more
  348. // snapshots that match
  349. // the request; this value should be passed in a
  350. // new
  351. // `ListTopicSnapshotsRequest` to get more snapshots.
  352. NextPageToken string `json:"nextPageToken,omitempty"`
  353. // Snapshots: The names of the snapshots that match the request.
  354. Snapshots []string `json:"snapshots,omitempty"`
  355. // ServerResponse contains the HTTP response code and headers from the
  356. // server.
  357. googleapi.ServerResponse `json:"-"`
  358. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  359. // unconditionally include in API requests. By default, fields with
  360. // empty values are omitted from API requests. However, any non-pointer,
  361. // non-interface field appearing in ForceSendFields will be sent to the
  362. // server regardless of whether the field is empty or not. This may be
  363. // used to include empty fields in Patch requests.
  364. ForceSendFields []string `json:"-"`
  365. // NullFields is a list of field names (e.g. "NextPageToken") to include
  366. // in API requests with the JSON null value. By default, fields with
  367. // empty values are omitted from API requests. However, any field with
  368. // an empty value appearing in NullFields will be sent to the server as
  369. // null. It is an error if a field in this list has a non-empty value.
  370. // This may be used to include null fields in Patch requests.
  371. NullFields []string `json:"-"`
  372. }
  373. func (s *ListTopicSnapshotsResponse) MarshalJSON() ([]byte, error) {
  374. type NoMethod ListTopicSnapshotsResponse
  375. raw := NoMethod(*s)
  376. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  377. }
  378. // ListTopicSubscriptionsResponse: Response for the
  379. // `ListTopicSubscriptions` method.
  380. type ListTopicSubscriptionsResponse struct {
  381. // NextPageToken: If not empty, indicates that there may be more
  382. // subscriptions that match
  383. // the request; this value should be passed in a
  384. // new
  385. // `ListTopicSubscriptionsRequest` to get more subscriptions.
  386. NextPageToken string `json:"nextPageToken,omitempty"`
  387. // Subscriptions: The names of the subscriptions that match the request.
  388. Subscriptions []string `json:"subscriptions,omitempty"`
  389. // ServerResponse contains the HTTP response code and headers from the
  390. // server.
  391. googleapi.ServerResponse `json:"-"`
  392. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  393. // unconditionally include in API requests. By default, fields with
  394. // empty values are omitted from API requests. However, any non-pointer,
  395. // non-interface field appearing in ForceSendFields will be sent to the
  396. // server regardless of whether the field is empty or not. This may be
  397. // used to include empty fields in Patch requests.
  398. ForceSendFields []string `json:"-"`
  399. // NullFields is a list of field names (e.g. "NextPageToken") to include
  400. // in API requests with the JSON null value. By default, fields with
  401. // empty values are omitted from API requests. However, any field with
  402. // an empty value appearing in NullFields will be sent to the server as
  403. // null. It is an error if a field in this list has a non-empty value.
  404. // This may be used to include null fields in Patch requests.
  405. NullFields []string `json:"-"`
  406. }
  407. func (s *ListTopicSubscriptionsResponse) MarshalJSON() ([]byte, error) {
  408. type NoMethod ListTopicSubscriptionsResponse
  409. raw := NoMethod(*s)
  410. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  411. }
  412. // ListTopicsResponse: Response for the `ListTopics` method.
  413. type ListTopicsResponse struct {
  414. // NextPageToken: If not empty, indicates that there may be more topics
  415. // that match the
  416. // request; this value should be passed in a new `ListTopicsRequest`.
  417. NextPageToken string `json:"nextPageToken,omitempty"`
  418. // Topics: The resulting topics.
  419. Topics []*Topic `json:"topics,omitempty"`
  420. // ServerResponse contains the HTTP response code and headers from the
  421. // server.
  422. googleapi.ServerResponse `json:"-"`
  423. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  424. // unconditionally include in API requests. By default, fields with
  425. // empty values are omitted from API requests. However, any non-pointer,
  426. // non-interface field appearing in ForceSendFields will be sent to the
  427. // server regardless of whether the field is empty or not. This may be
  428. // used to include empty fields in Patch requests.
  429. ForceSendFields []string `json:"-"`
  430. // NullFields is a list of field names (e.g. "NextPageToken") to include
  431. // in API requests with the JSON null value. By default, fields with
  432. // empty values are omitted from API requests. However, any field with
  433. // an empty value appearing in NullFields will be sent to the server as
  434. // null. It is an error if a field in this list has a non-empty value.
  435. // This may be used to include null fields in Patch requests.
  436. NullFields []string `json:"-"`
  437. }
  438. func (s *ListTopicsResponse) MarshalJSON() ([]byte, error) {
  439. type NoMethod ListTopicsResponse
  440. raw := NoMethod(*s)
  441. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  442. }
  443. // ModifyAckDeadlineRequest: Request for the ModifyAckDeadline method.
  444. type ModifyAckDeadlineRequest struct {
  445. // AckDeadlineSeconds: The new ack deadline with respect to the time
  446. // this request was sent to
  447. // the Pub/Sub system. For example, if the value is 10, the new
  448. // ack deadline will expire 10 seconds after the `ModifyAckDeadline`
  449. // call
  450. // was made. Specifying zero may immediately make the message available
  451. // for
  452. // another pull request.
  453. // The minimum deadline you can specify is 0 seconds.
  454. // The maximum deadline you can specify is 600 seconds (10 minutes).
  455. AckDeadlineSeconds int64 `json:"ackDeadlineSeconds,omitempty"`
  456. // AckIds: List of acknowledgment IDs.
  457. AckIds []string `json:"ackIds,omitempty"`
  458. // ForceSendFields is a list of field names (e.g. "AckDeadlineSeconds")
  459. // to unconditionally include in API requests. By default, fields with
  460. // empty values are omitted from API requests. However, any non-pointer,
  461. // non-interface field appearing in ForceSendFields will be sent to the
  462. // server regardless of whether the field is empty or not. This may be
  463. // used to include empty fields in Patch requests.
  464. ForceSendFields []string `json:"-"`
  465. // NullFields is a list of field names (e.g. "AckDeadlineSeconds") to
  466. // include in API requests with the JSON null value. By default, fields
  467. // with empty values are omitted from API requests. However, any field
  468. // with an empty value appearing in NullFields will be sent to the
  469. // server as null. It is an error if a field in this list has a
  470. // non-empty value. This may be used to include null fields in Patch
  471. // requests.
  472. NullFields []string `json:"-"`
  473. }
  474. func (s *ModifyAckDeadlineRequest) MarshalJSON() ([]byte, error) {
  475. type NoMethod ModifyAckDeadlineRequest
  476. raw := NoMethod(*s)
  477. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  478. }
  479. // ModifyPushConfigRequest: Request for the ModifyPushConfig method.
  480. type ModifyPushConfigRequest struct {
  481. // PushConfig: The push configuration for future deliveries.
  482. //
  483. // An empty `pushConfig` indicates that the Pub/Sub system should
  484. // stop pushing messages from the given subscription and allow
  485. // messages to be pulled and acknowledged - effectively pausing
  486. // the subscription if `Pull` or `StreamingPull` is not called.
  487. PushConfig *PushConfig `json:"pushConfig,omitempty"`
  488. // ForceSendFields is a list of field names (e.g. "PushConfig") to
  489. // unconditionally include in API requests. By default, fields with
  490. // empty values are omitted from API requests. However, any non-pointer,
  491. // non-interface field appearing in ForceSendFields will be sent to the
  492. // server regardless of whether the field is empty or not. This may be
  493. // used to include empty fields in Patch requests.
  494. ForceSendFields []string `json:"-"`
  495. // NullFields is a list of field names (e.g. "PushConfig") to include in
  496. // API requests with the JSON null value. By default, fields with empty
  497. // values are omitted from API requests. However, any field with an
  498. // empty value appearing in NullFields will be sent to the server as
  499. // null. It is an error if a field in this list has a non-empty value.
  500. // This may be used to include null fields in Patch requests.
  501. NullFields []string `json:"-"`
  502. }
  503. func (s *ModifyPushConfigRequest) MarshalJSON() ([]byte, error) {
  504. type NoMethod ModifyPushConfigRequest
  505. raw := NoMethod(*s)
  506. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  507. }
  508. // Policy: Defines an Identity and Access Management (IAM) policy. It is
  509. // used to
  510. // specify access control policies for Cloud Platform resources.
  511. //
  512. //
  513. // A `Policy` consists of a list of `bindings`. A `binding` binds a list
  514. // of
  515. // `members` to a `role`, where the members can be user accounts, Google
  516. // groups,
  517. // Google domains, and service accounts. A `role` is a named list of
  518. // permissions
  519. // defined by IAM.
  520. //
  521. // **JSON Example**
  522. //
  523. // {
  524. // "bindings": [
  525. // {
  526. // "role": "roles/owner",
  527. // "members": [
  528. // "user:mike@example.com",
  529. // "group:admins@example.com",
  530. // "domain:google.com",
  531. //
  532. // "serviceAccount:my-other-app@appspot.gserviceaccount.com"
  533. // ]
  534. // },
  535. // {
  536. // "role": "roles/viewer",
  537. // "members": ["user:sean@example.com"]
  538. // }
  539. // ]
  540. // }
  541. //
  542. // **YAML Example**
  543. //
  544. // bindings:
  545. // - members:
  546. // - user:mike@example.com
  547. // - group:admins@example.com
  548. // - domain:google.com
  549. // - serviceAccount:my-other-app@appspot.gserviceaccount.com
  550. // role: roles/owner
  551. // - members:
  552. // - user:sean@example.com
  553. // role: roles/viewer
  554. //
  555. //
  556. // For a description of IAM and its features, see the
  557. // [IAM developer's guide](https://cloud.google.com/iam/docs).
  558. type Policy struct {
  559. // Bindings: Associates a list of `members` to a `role`.
  560. // `bindings` with no members will result in an error.
  561. Bindings []*Binding `json:"bindings,omitempty"`
  562. // Etag: `etag` is used for optimistic concurrency control as a way to
  563. // help
  564. // prevent simultaneous updates of a policy from overwriting each
  565. // other.
  566. // It is strongly suggested that systems make use of the `etag` in
  567. // the
  568. // read-modify-write cycle to perform policy updates in order to avoid
  569. // race
  570. // conditions: An `etag` is returned in the response to `getIamPolicy`,
  571. // and
  572. // systems are expected to put that etag in the request to
  573. // `setIamPolicy` to
  574. // ensure that their change will be applied to the same version of the
  575. // policy.
  576. //
  577. // If no `etag` is provided in the call to `setIamPolicy`, then the
  578. // existing
  579. // policy is overwritten blindly.
  580. Etag string `json:"etag,omitempty"`
  581. // Version: Deprecated.
  582. Version int64 `json:"version,omitempty"`
  583. // ServerResponse contains the HTTP response code and headers from the
  584. // server.
  585. googleapi.ServerResponse `json:"-"`
  586. // ForceSendFields is a list of field names (e.g. "Bindings") to
  587. // unconditionally include in API requests. By default, fields with
  588. // empty values are omitted from API requests. However, any non-pointer,
  589. // non-interface field appearing in ForceSendFields will be sent to the
  590. // server regardless of whether the field is empty or not. This may be
  591. // used to include empty fields in Patch requests.
  592. ForceSendFields []string `json:"-"`
  593. // NullFields is a list of field names (e.g. "Bindings") to include in
  594. // API requests with the JSON null value. By default, fields with empty
  595. // values are omitted from API requests. However, any field with an
  596. // empty value appearing in NullFields will be sent to the server as
  597. // null. It is an error if a field in this list has a non-empty value.
  598. // This may be used to include null fields in Patch requests.
  599. NullFields []string `json:"-"`
  600. }
  601. func (s *Policy) MarshalJSON() ([]byte, error) {
  602. type NoMethod Policy
  603. raw := NoMethod(*s)
  604. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  605. }
  606. // PublishRequest: Request for the Publish method.
  607. type PublishRequest struct {
  608. // Messages: The messages to publish.
  609. Messages []*PubsubMessage `json:"messages,omitempty"`
  610. // ForceSendFields is a list of field names (e.g. "Messages") to
  611. // unconditionally include in API requests. By default, fields with
  612. // empty values are omitted from API requests. However, any non-pointer,
  613. // non-interface field appearing in ForceSendFields will be sent to the
  614. // server regardless of whether the field is empty or not. This may be
  615. // used to include empty fields in Patch requests.
  616. ForceSendFields []string `json:"-"`
  617. // NullFields is a list of field names (e.g. "Messages") to include in
  618. // API requests with the JSON null value. By default, fields with empty
  619. // values are omitted from API requests. However, any field with an
  620. // empty value appearing in NullFields will be sent to the server as
  621. // null. It is an error if a field in this list has a non-empty value.
  622. // This may be used to include null fields in Patch requests.
  623. NullFields []string `json:"-"`
  624. }
  625. func (s *PublishRequest) MarshalJSON() ([]byte, error) {
  626. type NoMethod PublishRequest
  627. raw := NoMethod(*s)
  628. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  629. }
  630. // PublishResponse: Response for the `Publish` method.
  631. type PublishResponse struct {
  632. // MessageIds: The server-assigned ID of each published message, in the
  633. // same order as
  634. // the messages in the request. IDs are guaranteed to be unique
  635. // within
  636. // the topic.
  637. MessageIds []string `json:"messageIds,omitempty"`
  638. // ServerResponse contains the HTTP response code and headers from the
  639. // server.
  640. googleapi.ServerResponse `json:"-"`
  641. // ForceSendFields is a list of field names (e.g. "MessageIds") to
  642. // unconditionally include in API requests. By default, fields with
  643. // empty values are omitted from API requests. However, any non-pointer,
  644. // non-interface field appearing in ForceSendFields will be sent to the
  645. // server regardless of whether the field is empty or not. This may be
  646. // used to include empty fields in Patch requests.
  647. ForceSendFields []string `json:"-"`
  648. // NullFields is a list of field names (e.g. "MessageIds") to include in
  649. // API requests with the JSON null value. By default, fields with empty
  650. // values are omitted from API requests. However, any field with an
  651. // empty value appearing in NullFields will be sent to the server as
  652. // null. It is an error if a field in this list has a non-empty value.
  653. // This may be used to include null fields in Patch requests.
  654. NullFields []string `json:"-"`
  655. }
  656. func (s *PublishResponse) MarshalJSON() ([]byte, error) {
  657. type NoMethod PublishResponse
  658. raw := NoMethod(*s)
  659. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  660. }
  661. // PubsubMessage: A message data and its attributes. The message payload
  662. // must not be empty;
  663. // it must contain either a non-empty data field, or at least one
  664. // attribute.
  665. type PubsubMessage struct {
  666. // Attributes: Optional attributes for this message.
  667. Attributes map[string]string `json:"attributes,omitempty"`
  668. // Data: The message payload.
  669. Data string `json:"data,omitempty"`
  670. // MessageId: ID of this message, assigned by the server when the
  671. // message is published.
  672. // Guaranteed to be unique within the topic. This value may be read by
  673. // a
  674. // subscriber that receives a `PubsubMessage` via a `Pull` call or a
  675. // push
  676. // delivery. It must not be populated by the publisher in a `Publish`
  677. // call.
  678. MessageId string `json:"messageId,omitempty"`
  679. // PublishTime: The time at which the message was published, populated
  680. // by the server when
  681. // it receives the `Publish` call. It must not be populated by
  682. // the
  683. // publisher in a `Publish` call.
  684. PublishTime string `json:"publishTime,omitempty"`
  685. // ForceSendFields is a list of field names (e.g. "Attributes") to
  686. // unconditionally include in API requests. By default, fields with
  687. // empty values are omitted from API requests. However, any non-pointer,
  688. // non-interface field appearing in ForceSendFields will be sent to the
  689. // server regardless of whether the field is empty or not. This may be
  690. // used to include empty fields in Patch requests.
  691. ForceSendFields []string `json:"-"`
  692. // NullFields is a list of field names (e.g. "Attributes") to include in
  693. // API requests with the JSON null value. By default, fields with empty
  694. // values are omitted from API requests. However, any field with an
  695. // empty value appearing in NullFields will be sent to the server as
  696. // null. It is an error if a field in this list has a non-empty value.
  697. // This may be used to include null fields in Patch requests.
  698. NullFields []string `json:"-"`
  699. }
  700. func (s *PubsubMessage) MarshalJSON() ([]byte, error) {
  701. type NoMethod PubsubMessage
  702. raw := NoMethod(*s)
  703. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  704. }
  705. // PullRequest: Request for the `Pull` method.
  706. type PullRequest struct {
  707. // MaxMessages: The maximum number of messages returned for this
  708. // request. The Pub/Sub
  709. // system may return fewer than the number specified.
  710. MaxMessages int64 `json:"maxMessages,omitempty"`
  711. // ReturnImmediately: If this field set to true, the system will respond
  712. // immediately even if
  713. // it there are no messages available to return in the `Pull`
  714. // response.
  715. // Otherwise, the system may wait (for a bounded amount of time) until
  716. // at
  717. // least one message is available, rather than returning no messages.
  718. // The
  719. // client may cancel the request if it does not wish to wait any longer
  720. // for
  721. // the response.
  722. ReturnImmediately bool `json:"returnImmediately,omitempty"`
  723. // ForceSendFields is a list of field names (e.g. "MaxMessages") to
  724. // unconditionally include in API requests. By default, fields with
  725. // empty values are omitted from API requests. However, any non-pointer,
  726. // non-interface field appearing in ForceSendFields will be sent to the
  727. // server regardless of whether the field is empty or not. This may be
  728. // used to include empty fields in Patch requests.
  729. ForceSendFields []string `json:"-"`
  730. // NullFields is a list of field names (e.g. "MaxMessages") to include
  731. // in API requests with the JSON null value. By default, fields with
  732. // empty values are omitted from API requests. However, any field with
  733. // an empty value appearing in NullFields will be sent to the server as
  734. // null. It is an error if a field in this list has a non-empty value.
  735. // This may be used to include null fields in Patch requests.
  736. NullFields []string `json:"-"`
  737. }
  738. func (s *PullRequest) MarshalJSON() ([]byte, error) {
  739. type NoMethod PullRequest
  740. raw := NoMethod(*s)
  741. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  742. }
  743. // PullResponse: Response for the `Pull` method.
  744. type PullResponse struct {
  745. // ReceivedMessages: Received Pub/Sub messages. The Pub/Sub system will
  746. // return zero messages if
  747. // there are no more available in the backlog. The Pub/Sub system may
  748. // return
  749. // fewer than the `maxMessages` requested even if there are more
  750. // messages
  751. // available in the backlog.
  752. ReceivedMessages []*ReceivedMessage `json:"receivedMessages,omitempty"`
  753. // ServerResponse contains the HTTP response code and headers from the
  754. // server.
  755. googleapi.ServerResponse `json:"-"`
  756. // ForceSendFields is a list of field names (e.g. "ReceivedMessages") to
  757. // unconditionally include in API requests. By default, fields with
  758. // empty values are omitted from API requests. However, any non-pointer,
  759. // non-interface field appearing in ForceSendFields will be sent to the
  760. // server regardless of whether the field is empty or not. This may be
  761. // used to include empty fields in Patch requests.
  762. ForceSendFields []string `json:"-"`
  763. // NullFields is a list of field names (e.g. "ReceivedMessages") to
  764. // include in API requests with the JSON null value. By default, fields
  765. // with empty values are omitted from API requests. However, any field
  766. // with an empty value appearing in NullFields will be sent to the
  767. // server as null. It is an error if a field in this list has a
  768. // non-empty value. This may be used to include null fields in Patch
  769. // requests.
  770. NullFields []string `json:"-"`
  771. }
  772. func (s *PullResponse) MarshalJSON() ([]byte, error) {
  773. type NoMethod PullResponse
  774. raw := NoMethod(*s)
  775. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  776. }
  777. // PushConfig: Configuration for a push delivery endpoint.
  778. type PushConfig struct {
  779. // Attributes: Endpoint configuration attributes.
  780. //
  781. // Every endpoint has a set of API supported attributes that can be used
  782. // to
  783. // control different aspects of the message delivery.
  784. //
  785. // The currently supported attribute is `x-goog-version`, which you
  786. // can
  787. // use to change the format of the pushed message. This
  788. // attribute
  789. // indicates the version of the data expected by the endpoint.
  790. // This
  791. // controls the shape of the pushed message (i.e., its fields and
  792. // metadata).
  793. // The endpoint version is based on the version of the Pub/Sub API.
  794. //
  795. // If not present during the `CreateSubscription` call, it will default
  796. // to
  797. // the version of the API used to make such call. If not present during
  798. // a
  799. // `ModifyPushConfig` call, its value will not be changed.
  800. // `GetSubscription`
  801. // calls will always return a valid version, even if the subscription
  802. // was
  803. // created without this attribute.
  804. //
  805. // The possible values for this attribute are:
  806. //
  807. // * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub
  808. // API.
  809. // * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub
  810. // API.
  811. Attributes map[string]string `json:"attributes,omitempty"`
  812. // PushEndpoint: A URL locating the endpoint to which messages should be
  813. // pushed.
  814. // For example, a Webhook endpoint might use "https://example.com/push".
  815. PushEndpoint string `json:"pushEndpoint,omitempty"`
  816. // ForceSendFields is a list of field names (e.g. "Attributes") to
  817. // unconditionally include in API requests. By default, fields with
  818. // empty values are omitted from API requests. However, any non-pointer,
  819. // non-interface field appearing in ForceSendFields will be sent to the
  820. // server regardless of whether the field is empty or not. This may be
  821. // used to include empty fields in Patch requests.
  822. ForceSendFields []string `json:"-"`
  823. // NullFields is a list of field names (e.g. "Attributes") to include in
  824. // API requests with the JSON null value. By default, fields with empty
  825. // values are omitted from API requests. However, any field with an
  826. // empty value appearing in NullFields will be sent to the server as
  827. // null. It is an error if a field in this list has a non-empty value.
  828. // This may be used to include null fields in Patch requests.
  829. NullFields []string `json:"-"`
  830. }
  831. func (s *PushConfig) MarshalJSON() ([]byte, error) {
  832. type NoMethod PushConfig
  833. raw := NoMethod(*s)
  834. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  835. }
  836. // ReceivedMessage: A message and its corresponding acknowledgment ID.
  837. type ReceivedMessage struct {
  838. // AckId: This ID can be used to acknowledge the received message.
  839. AckId string `json:"ackId,omitempty"`
  840. // Message: The message.
  841. Message *PubsubMessage `json:"message,omitempty"`
  842. // ForceSendFields is a list of field names (e.g. "AckId") to
  843. // unconditionally include in API requests. By default, fields with
  844. // empty values are omitted from API requests. However, any non-pointer,
  845. // non-interface field appearing in ForceSendFields will be sent to the
  846. // server regardless of whether the field is empty or not. This may be
  847. // used to include empty fields in Patch requests.
  848. ForceSendFields []string `json:"-"`
  849. // NullFields is a list of field names (e.g. "AckId") to include in API
  850. // requests with the JSON null value. By default, fields with empty
  851. // values are omitted from API requests. However, any field with an
  852. // empty value appearing in NullFields will be sent to the server as
  853. // null. It is an error if a field in this list has a non-empty value.
  854. // This may be used to include null fields in Patch requests.
  855. NullFields []string `json:"-"`
  856. }
  857. func (s *ReceivedMessage) MarshalJSON() ([]byte, error) {
  858. type NoMethod ReceivedMessage
  859. raw := NoMethod(*s)
  860. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  861. }
  862. // SeekRequest: Request for the `Seek` method.<br><br>
  863. // <b>ALPHA:</b> This feature is part of an alpha release. This API
  864. // might be
  865. // changed in backward-incompatible ways and is not recommended for
  866. // production
  867. // use. It is not subject to any SLA or deprecation policy.
  868. type SeekRequest struct {
  869. // Snapshot: The snapshot to seek to. The snapshot's topic must be the
  870. // same as that of
  871. // the provided subscription.
  872. // Format is `projects/{project}/snapshots/{snap}`.
  873. Snapshot string `json:"snapshot,omitempty"`
  874. // Time: The time to seek to.
  875. // Messages retained in the subscription that were published before
  876. // this
  877. // time are marked as acknowledged, and messages retained in
  878. // the
  879. // subscription that were published after this time are marked
  880. // as
  881. // unacknowledged. Note that this operation affects only those
  882. // messages
  883. // retained in the subscription (configured by the combination
  884. // of
  885. // `message_retention_duration` and `retain_acked_messages`). For
  886. // example,
  887. // if `time` corresponds to a point before the message retention
  888. // window (or to a point before the system's notion of the
  889. // subscription
  890. // creation time), only retained messages will be marked as
  891. // unacknowledged,
  892. // and already-expunged messages will not be restored.
  893. Time string `json:"time,omitempty"`
  894. // ForceSendFields is a list of field names (e.g. "Snapshot") to
  895. // unconditionally include in API requests. By default, fields with
  896. // empty values are omitted from API requests. However, any non-pointer,
  897. // non-interface field appearing in ForceSendFields will be sent to the
  898. // server regardless of whether the field is empty or not. This may be
  899. // used to include empty fields in Patch requests.
  900. ForceSendFields []string `json:"-"`
  901. // NullFields is a list of field names (e.g. "Snapshot") to include in
  902. // API requests with the JSON null value. By default, fields with empty
  903. // values are omitted from API requests. However, any field with an
  904. // empty value appearing in NullFields will be sent to the server as
  905. // null. It is an error if a field in this list has a non-empty value.
  906. // This may be used to include null fields in Patch requests.
  907. NullFields []string `json:"-"`
  908. }
  909. func (s *SeekRequest) MarshalJSON() ([]byte, error) {
  910. type NoMethod SeekRequest
  911. raw := NoMethod(*s)
  912. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  913. }
  914. type SeekResponse struct {
  915. // ServerResponse contains the HTTP response code and headers from the
  916. // server.
  917. googleapi.ServerResponse `json:"-"`
  918. }
  919. // SetIamPolicyRequest: Request message for `SetIamPolicy` method.
  920. type SetIamPolicyRequest struct {
  921. // Policy: REQUIRED: The complete policy to be applied to the
  922. // `resource`. The size of
  923. // the policy is limited to a few 10s of KB. An empty policy is a
  924. // valid policy but certain Cloud Platform services (such as
  925. // Projects)
  926. // might reject them.
  927. Policy *Policy `json:"policy,omitempty"`
  928. // ForceSendFields is a list of field names (e.g. "Policy") to
  929. // unconditionally include in API requests. By default, fields with
  930. // empty values are omitted from API requests. However, any non-pointer,
  931. // non-interface field appearing in ForceSendFields will be sent to the
  932. // server regardless of whether the field is empty or not. This may be
  933. // used to include empty fields in Patch requests.
  934. ForceSendFields []string `json:"-"`
  935. // NullFields is a list of field names (e.g. "Policy") to include in API
  936. // requests with the JSON null value. By default, fields with empty
  937. // values are omitted from API requests. However, any field with an
  938. // empty value appearing in NullFields will be sent to the server as
  939. // null. It is an error if a field in this list has a non-empty value.
  940. // This may be used to include null fields in Patch requests.
  941. NullFields []string `json:"-"`
  942. }
  943. func (s *SetIamPolicyRequest) MarshalJSON() ([]byte, error) {
  944. type NoMethod SetIamPolicyRequest
  945. raw := NoMethod(*s)
  946. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  947. }
  948. // Snapshot: A snapshot resource.<br><br>
  949. // <b>ALPHA:</b> This feature is part of an alpha release. This API
  950. // might be
  951. // changed in backward-incompatible ways and is not recommended for
  952. // production
  953. // use. It is not subject to any SLA or deprecation policy.
  954. type Snapshot struct {
  955. // ExpireTime: The snapshot is guaranteed to exist up until this time.
  956. // A newly-created snapshot expires no later than 7 days from the time
  957. // of its
  958. // creation. Its exact lifetime is determined at creation by the
  959. // existing
  960. // backlog in the source subscription. Specifically, the lifetime of
  961. // the
  962. // snapshot is `7 days - (age of oldest unacked message in the
  963. // subscription)`.
  964. // For example, consider a subscription whose oldest unacked message is
  965. // 3 days
  966. // old. If a snapshot is created from this subscription, the snapshot --
  967. // which
  968. // will always capture this 3-day-old backlog as long as the
  969. // snapshot
  970. // exists -- will expire in 4 days. The service will refuse to create
  971. // a
  972. // snapshot that would expire in less than 1 hour after creation.
  973. ExpireTime string `json:"expireTime,omitempty"`
  974. // Name: The name of the snapshot.
  975. Name string `json:"name,omitempty"`
  976. // Topic: The name of the topic from which this snapshot is retaining
  977. // messages.
  978. Topic string `json:"topic,omitempty"`
  979. // ServerResponse contains the HTTP response code and headers from the
  980. // server.
  981. googleapi.ServerResponse `json:"-"`
  982. // ForceSendFields is a list of field names (e.g. "ExpireTime") to
  983. // unconditionally include in API requests. By default, fields with
  984. // empty values are omitted from API requests. However, any non-pointer,
  985. // non-interface field appearing in ForceSendFields will be sent to the
  986. // server regardless of whether the field is empty or not. This may be
  987. // used to include empty fields in Patch requests.
  988. ForceSendFields []string `json:"-"`
  989. // NullFields is a list of field names (e.g. "ExpireTime") to include in
  990. // API requests with the JSON null value. By default, fields with empty
  991. // values are omitted from API requests. However, any field with an
  992. // empty value appearing in NullFields will be sent to the server as
  993. // null. It is an error if a field in this list has a non-empty value.
  994. // This may be used to include null fields in Patch requests.
  995. NullFields []string `json:"-"`
  996. }
  997. func (s *Snapshot) MarshalJSON() ([]byte, error) {
  998. type NoMethod Snapshot
  999. raw := NoMethod(*s)
  1000. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1001. }
  1002. // Subscription: A subscription resource.
  1003. type Subscription struct {
  1004. // AckDeadlineSeconds: This value is the maximum time after a subscriber
  1005. // receives a message
  1006. // before the subscriber should acknowledge the message. After
  1007. // message
  1008. // delivery but before the ack deadline expires and before the message
  1009. // is
  1010. // acknowledged, it is an outstanding message and will not be
  1011. // delivered
  1012. // again during that time (on a best-effort basis).
  1013. //
  1014. // For pull subscriptions, this value is used as the initial value for
  1015. // the ack
  1016. // deadline. To override this value for a given message,
  1017. // call
  1018. // `ModifyAckDeadline` with the corresponding `ack_id` if
  1019. // using
  1020. // non-streaming pull or send the `ack_id` in
  1021. // a
  1022. // `StreamingModifyAckDeadlineRequest` if using streaming pull.
  1023. // The minimum custom deadline you can specify is 10 seconds.
  1024. // The maximum custom deadline you can specify is 600 seconds (10
  1025. // minutes).
  1026. // If this parameter is 0, a default value of 10 seconds is used.
  1027. //
  1028. // For push delivery, this value is also used to set the request timeout
  1029. // for
  1030. // the call to the push endpoint.
  1031. //
  1032. // If the subscriber never acknowledges the message, the Pub/Sub
  1033. // system will eventually redeliver the message.
  1034. AckDeadlineSeconds int64 `json:"ackDeadlineSeconds,omitempty"`
  1035. // MessageRetentionDuration: How long to retain unacknowledged messages
  1036. // in the subscription's backlog,
  1037. // from the moment a message is published.
  1038. // If `retain_acked_messages` is true, then this also configures the
  1039. // retention
  1040. // of acknowledged messages, and thus configures how far back in time a
  1041. // `Seek`
  1042. // can be done. Defaults to 7 days. Cannot be more than 7 days or less
  1043. // than 10
  1044. // minutes.<br><br>
  1045. // <b>ALPHA:</b> This feature is part of an alpha release. This API
  1046. // might be
  1047. // changed in backward-incompatible ways and is not recommended for
  1048. // production
  1049. // use. It is not subject to any SLA or deprecation policy.
  1050. MessageRetentionDuration string `json:"messageRetentionDuration,omitempty"`
  1051. // Name: The name of the subscription. It must have the
  1052. // format
  1053. // "projects/{project}/subscriptions/{subscription}". `{subscription}`
  1054. // must
  1055. // start with a letter, and contain only letters (`[A-Za-z]`),
  1056. // numbers
  1057. // (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes
  1058. // (`~`),
  1059. // plus (`+`) or percent signs (`%`). It must be between 3 and 255
  1060. // characters
  1061. // in length, and it must not start with "goog".
  1062. Name string `json:"name,omitempty"`
  1063. // PushConfig: If push delivery is used with this subscription, this
  1064. // field is
  1065. // used to configure it. An empty `pushConfig` signifies that the
  1066. // subscriber
  1067. // will pull and ack messages using API methods.
  1068. PushConfig *PushConfig `json:"pushConfig,omitempty"`
  1069. // RetainAckedMessages: Indicates whether to retain acknowledged
  1070. // messages. If true, then
  1071. // messages are not expunged from the subscription's backlog, even if
  1072. // they are
  1073. // acknowledged, until they fall out of the
  1074. // `message_retention_duration`
  1075. // window.<br><br>
  1076. // <b>ALPHA:</b> This feature is part of an alpha release. This API
  1077. // might be
  1078. // changed in backward-incompatible ways and is not recommended for
  1079. // production
  1080. // use. It is not subject to any SLA or deprecation policy.
  1081. RetainAckedMessages bool `json:"retainAckedMessages,omitempty"`
  1082. // Topic: The name of the topic from which this subscription is
  1083. // receiving messages.
  1084. // Format is `projects/{project}/topics/{topic}`.
  1085. // The value of this field will be `_deleted-topic_` if the topic has
  1086. // been
  1087. // deleted.
  1088. Topic string `json:"topic,omitempty"`
  1089. // ServerResponse contains the HTTP response code and headers from the
  1090. // server.
  1091. googleapi.ServerResponse `json:"-"`
  1092. // ForceSendFields is a list of field names (e.g. "AckDeadlineSeconds")
  1093. // to unconditionally include in API requests. By default, fields with
  1094. // empty values are omitted from API requests. However, any non-pointer,
  1095. // non-interface field appearing in ForceSendFields will be sent to the
  1096. // server regardless of whether the field is empty or not. This may be
  1097. // used to include empty fields in Patch requests.
  1098. ForceSendFields []string `json:"-"`
  1099. // NullFields is a list of field names (e.g. "AckDeadlineSeconds") to
  1100. // include in API requests with the JSON null value. By default, fields
  1101. // with empty values are omitted from API requests. However, any field
  1102. // with an empty value appearing in NullFields will be sent to the
  1103. // server as null. It is an error if a field in this list has a
  1104. // non-empty value. This may be used to include null fields in Patch
  1105. // requests.
  1106. NullFields []string `json:"-"`
  1107. }
  1108. func (s *Subscription) MarshalJSON() ([]byte, error) {
  1109. type NoMethod Subscription
  1110. raw := NoMethod(*s)
  1111. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1112. }
  1113. // TestIamPermissionsRequest: Request message for `TestIamPermissions`
  1114. // method.
  1115. type TestIamPermissionsRequest struct {
  1116. // Permissions: The set of permissions to check for the `resource`.
  1117. // Permissions with
  1118. // wildcards (such as '*' or 'storage.*') are not allowed. For
  1119. // more
  1120. // information see
  1121. // [IAM
  1122. // Overview](https://cloud.google.com/iam/docs/overview#permissions).
  1123. Permissions []string `json:"permissions,omitempty"`
  1124. // ForceSendFields is a list of field names (e.g. "Permissions") to
  1125. // unconditionally include in API requests. By default, fields with
  1126. // empty values are omitted from API requests. However, any non-pointer,
  1127. // non-interface field appearing in ForceSendFields will be sent to the
  1128. // server regardless of whether the field is empty or not. This may be
  1129. // used to include empty fields in Patch requests.
  1130. ForceSendFields []string `json:"-"`
  1131. // NullFields is a list of field names (e.g. "Permissions") to include
  1132. // in API requests with the JSON null value. By default, fields with
  1133. // empty values are omitted from API requests. However, any field with
  1134. // an empty value appearing in NullFields will be sent to the server as
  1135. // null. It is an error if a field in this list has a non-empty value.
  1136. // This may be used to include null fields in Patch requests.
  1137. NullFields []string `json:"-"`
  1138. }
  1139. func (s *TestIamPermissionsRequest) MarshalJSON() ([]byte, error) {
  1140. type NoMethod TestIamPermissionsRequest
  1141. raw := NoMethod(*s)
  1142. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1143. }
  1144. // TestIamPermissionsResponse: Response message for `TestIamPermissions`
  1145. // method.
  1146. type TestIamPermissionsResponse struct {
  1147. // Permissions: A subset of `TestPermissionsRequest.permissions` that
  1148. // the caller is
  1149. // allowed.
  1150. Permissions []string `json:"permissions,omitempty"`
  1151. // ServerResponse contains the HTTP response code and headers from the
  1152. // server.
  1153. googleapi.ServerResponse `json:"-"`
  1154. // ForceSendFields is a list of field names (e.g. "Permissions") to
  1155. // unconditionally include in API requests. By default, fields with
  1156. // empty values are omitted from API requests. However, any non-pointer,
  1157. // non-interface field appearing in ForceSendFields will be sent to the
  1158. // server regardless of whether the field is empty or not. This may be
  1159. // used to include empty fields in Patch requests.
  1160. ForceSendFields []string `json:"-"`
  1161. // NullFields is a list of field names (e.g. "Permissions") to include
  1162. // in API requests with the JSON null value. By default, fields with
  1163. // empty values are omitted from API requests. However, any field with
  1164. // an empty value appearing in NullFields will be sent to the server as
  1165. // null. It is an error if a field in this list has a non-empty value.
  1166. // This may be used to include null fields in Patch requests.
  1167. NullFields []string `json:"-"`
  1168. }
  1169. func (s *TestIamPermissionsResponse) MarshalJSON() ([]byte, error) {
  1170. type NoMethod TestIamPermissionsResponse
  1171. raw := NoMethod(*s)
  1172. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1173. }
  1174. // Topic: A topic resource.
  1175. type Topic struct {
  1176. // Name: The name of the topic. It must have the
  1177. // format
  1178. // "projects/{project}/topics/{topic}". `{topic}` must start with a
  1179. // letter,
  1180. // and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes
  1181. // (`-`),
  1182. // underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or
  1183. // percent
  1184. // signs (`%`). It must be between 3 and 255 characters in length, and
  1185. // it
  1186. // must not start with "goog".
  1187. Name string `json:"name,omitempty"`
  1188. // ServerResponse contains the HTTP response code and headers from the
  1189. // server.
  1190. googleapi.ServerResponse `json:"-"`
  1191. // ForceSendFields is a list of field names (e.g. "Name") to
  1192. // unconditionally include in API requests. By default, fields with
  1193. // empty values are omitted from API requests. However, any non-pointer,
  1194. // non-interface field appearing in ForceSendFields will be sent to the
  1195. // server regardless of whether the field is empty or not. This may be
  1196. // used to include empty fields in Patch requests.
  1197. ForceSendFields []string `json:"-"`
  1198. // NullFields is a list of field names (e.g. "Name") to include in API
  1199. // requests with the JSON null value. By default, fields with empty
  1200. // values are omitted from API requests. However, any field with an
  1201. // empty value appearing in NullFields will be sent to the server as
  1202. // null. It is an error if a field in this list has a non-empty value.
  1203. // This may be used to include null fields in Patch requests.
  1204. NullFields []string `json:"-"`
  1205. }
  1206. func (s *Topic) MarshalJSON() ([]byte, error) {
  1207. type NoMethod Topic
  1208. raw := NoMethod(*s)
  1209. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1210. }
  1211. // UpdateSnapshotRequest: Request for the UpdateSnapshot
  1212. // method.<br><br>
  1213. // <b>ALPHA:</b> This feature is part of an alpha release. This API
  1214. // might be
  1215. // changed in backward-incompatible ways and is not recommended for
  1216. // production
  1217. // use. It is not subject to any SLA or deprecation policy.
  1218. type UpdateSnapshotRequest struct {
  1219. // Snapshot: The updated snapshot object.
  1220. Snapshot *Snapshot `json:"snapshot,omitempty"`
  1221. // UpdateMask: Indicates which fields in the provided snapshot to
  1222. // update.
  1223. // Must be specified and non-empty.
  1224. UpdateMask string `json:"updateMask,omitempty"`
  1225. // ForceSendFields is a list of field names (e.g. "Snapshot") to
  1226. // unconditionally include in API requests. By default, fields with
  1227. // empty values are omitted from API requests. However, any non-pointer,
  1228. // non-interface field appearing in ForceSendFields will be sent to the
  1229. // server regardless of whether the field is empty or not. This may be
  1230. // used to include empty fields in Patch requests.
  1231. ForceSendFields []string `json:"-"`
  1232. // NullFields is a list of field names (e.g. "Snapshot") to include in
  1233. // API requests with the JSON null value. By default, fields with empty
  1234. // values are omitted from API requests. However, any field with an
  1235. // empty value appearing in NullFields will be sent to the server as
  1236. // null. It is an error if a field in this list has a non-empty value.
  1237. // This may be used to include null fields in Patch requests.
  1238. NullFields []string `json:"-"`
  1239. }
  1240. func (s *UpdateSnapshotRequest) MarshalJSON() ([]byte, error) {
  1241. type NoMethod UpdateSnapshotRequest
  1242. raw := NoMethod(*s)
  1243. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1244. }
  1245. // UpdateSubscriptionRequest: Request for the UpdateSubscription method.
  1246. type UpdateSubscriptionRequest struct {
  1247. // Subscription: The updated subscription object.
  1248. Subscription *Subscription `json:"subscription,omitempty"`
  1249. // UpdateMask: Indicates which fields in the provided subscription to
  1250. // update.
  1251. // Must be specified and non-empty.
  1252. UpdateMask string `json:"updateMask,omitempty"`
  1253. // ForceSendFields is a list of field names (e.g. "Subscription") to
  1254. // unconditionally include in API requests. By default, fields with
  1255. // empty values are omitted from API requests. However, any non-pointer,
  1256. // non-interface field appearing in ForceSendFields will be sent to the
  1257. // server regardless of whether the field is empty or not. This may be
  1258. // used to include empty fields in Patch requests.
  1259. ForceSendFields []string `json:"-"`
  1260. // NullFields is a list of field names (e.g. "Subscription") to include
  1261. // in API requests with the JSON null value. By default, fields with
  1262. // empty values are omitted from API requests. However, any field with
  1263. // an empty value appearing in NullFields will be sent to the server as
  1264. // null. It is an error if a field in this list has a non-empty value.
  1265. // This may be used to include null fields in Patch requests.
  1266. NullFields []string `json:"-"`
  1267. }
  1268. func (s *UpdateSubscriptionRequest) MarshalJSON() ([]byte, error) {
  1269. type NoMethod UpdateSubscriptionRequest
  1270. raw := NoMethod(*s)
  1271. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1272. }
  1273. // method id "pubsub.projects.snapshots.create":
  1274. type ProjectsSnapshotsCreateCall struct {
  1275. s *Service
  1276. name string
  1277. createsnapshotrequest *CreateSnapshotRequest
  1278. urlParams_ gensupport.URLParams
  1279. ctx_ context.Context
  1280. header_ http.Header
  1281. }
  1282. // Create: Creates a snapshot from the requested
  1283. // subscription.<br><br>
  1284. // <b>ALPHA:</b> This feature is part of an alpha release. This API
  1285. // might be
  1286. // changed in backward-incompatible ways and is not recommended for
  1287. // production
  1288. // use. It is not subject to any SLA or deprecation policy.
  1289. // If the snapshot already exists, returns `ALREADY_EXISTS`.
  1290. // If the requested subscription doesn't exist, returns `NOT_FOUND`.
  1291. // If the backlog in the subscription is too old -- and the resulting
  1292. // snapshot
  1293. // would expire in less than 1 hour -- then `FAILED_PRECONDITION` is
  1294. // returned.
  1295. // See also the `Snapshot.expire_time` field. If the name is not
  1296. // provided in
  1297. // the request, the server will assign a random
  1298. // name for this snapshot on the same project as the subscription,
  1299. // conforming
  1300. // to the [resource name
  1301. // format](https://cloud.google.com/pubsub/docs/overview#names).
  1302. // The generated
  1303. // name is populated in the returned Snapshot object. Note that for REST
  1304. // API
  1305. // requests, you must specify a name in the request.
  1306. func (r *ProjectsSnapshotsService) Create(name string, createsnapshotrequest *CreateSnapshotRequest) *ProjectsSnapshotsCreateCall {
  1307. c := &ProjectsSnapshotsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1308. c.name = name
  1309. c.createsnapshotrequest = createsnapshotrequest
  1310. return c
  1311. }
  1312. // Fields allows partial responses to be retrieved. See
  1313. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1314. // for more information.
  1315. func (c *ProjectsSnapshotsCreateCall) Fields(s ...googleapi.Field) *ProjectsSnapshotsCreateCall {
  1316. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1317. return c
  1318. }
  1319. // Context sets the context to be used in this call's Do method. Any
  1320. // pending HTTP request will be aborted if the provided context is
  1321. // canceled.
  1322. func (c *ProjectsSnapshotsCreateCall) Context(ctx context.Context) *ProjectsSnapshotsCreateCall {
  1323. c.ctx_ = ctx
  1324. return c
  1325. }
  1326. // Header returns an http.Header that can be modified by the caller to
  1327. // add HTTP headers to the request.
  1328. func (c *ProjectsSnapshotsCreateCall) Header() http.Header {
  1329. if c.header_ == nil {
  1330. c.header_ = make(http.Header)
  1331. }
  1332. return c.header_
  1333. }
  1334. func (c *ProjectsSnapshotsCreateCall) doRequest(alt string) (*http.Response, error) {
  1335. reqHeaders := make(http.Header)
  1336. for k, v := range c.header_ {
  1337. reqHeaders[k] = v
  1338. }
  1339. reqHeaders.Set("User-Agent", c.s.userAgent())
  1340. var body io.Reader = nil
  1341. body, err := googleapi.WithoutDataWrapper.JSONReader(c.createsnapshotrequest)
  1342. if err != nil {
  1343. return nil, err
  1344. }
  1345. reqHeaders.Set("Content-Type", "application/json")
  1346. c.urlParams_.Set("alt", alt)
  1347. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  1348. urls += "?" + c.urlParams_.Encode()
  1349. req, _ := http.NewRequest("PUT", urls, body)
  1350. req.Header = reqHeaders
  1351. googleapi.Expand(req.URL, map[string]string{
  1352. "name": c.name,
  1353. })
  1354. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1355. }
  1356. // Do executes the "pubsub.projects.snapshots.create" call.
  1357. // Exactly one of *Snapshot or error will be non-nil. Any non-2xx status
  1358. // code is an error. Response headers are in either
  1359. // *Snapshot.ServerResponse.Header or (if a response was returned at
  1360. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1361. // to check whether the returned error was because
  1362. // http.StatusNotModified was returned.
  1363. func (c *ProjectsSnapshotsCreateCall) Do(opts ...googleapi.CallOption) (*Snapshot, error) {
  1364. gensupport.SetOptions(c.urlParams_, opts...)
  1365. res, err := c.doRequest("json")
  1366. if res != nil && res.StatusCode == http.StatusNotModified {
  1367. if res.Body != nil {
  1368. res.Body.Close()
  1369. }
  1370. return nil, &googleapi.Error{
  1371. Code: res.StatusCode,
  1372. Header: res.Header,
  1373. }
  1374. }
  1375. if err != nil {
  1376. return nil, err
  1377. }
  1378. defer googleapi.CloseBody(res)
  1379. if err := googleapi.CheckResponse(res); err != nil {
  1380. return nil, err
  1381. }
  1382. ret := &Snapshot{
  1383. ServerResponse: googleapi.ServerResponse{
  1384. Header: res.Header,
  1385. HTTPStatusCode: res.StatusCode,
  1386. },
  1387. }
  1388. target := &ret
  1389. if err := gensupport.DecodeResponse(target, res); err != nil {
  1390. return nil, err
  1391. }
  1392. return ret, nil
  1393. // {
  1394. // "description": "Creates a snapshot from the requested subscription.\u003cbr\u003e\u003cbr\u003e\n\u003cb\u003eALPHA:\u003c/b\u003e This feature is part of an alpha release. This API might be\nchanged in backward-incompatible ways and is not recommended for production\nuse. It is not subject to any SLA or deprecation policy.\nIf the snapshot already exists, returns `ALREADY_EXISTS`.\nIf the requested subscription doesn't exist, returns `NOT_FOUND`.\nIf the backlog in the subscription is too old -- and the resulting snapshot\nwould expire in less than 1 hour -- then `FAILED_PRECONDITION` is returned.\nSee also the `Snapshot.expire_time` field. If the name is not provided in\nthe request, the server will assign a random\nname for this snapshot on the same project as the subscription, conforming\nto the [resource name format](https://cloud.google.com/pubsub/docs/overview#names).\nThe generated\nname is populated in the returned Snapshot object. Note that for REST API\nrequests, you must specify a name in the request.",
  1395. // "flatPath": "v1/projects/{projectsId}/snapshots/{snapshotsId}",
  1396. // "httpMethod": "PUT",
  1397. // "id": "pubsub.projects.snapshots.create",
  1398. // "parameterOrder": [
  1399. // "name"
  1400. // ],
  1401. // "parameters": {
  1402. // "name": {
  1403. // "description": "Optional user-provided name for this snapshot.\nIf the name is not provided in the request, the server will assign a random\nname for this snapshot on the same project as the subscription.\nNote that for REST API requests, you must specify a name.\nFormat is `projects/{project}/snapshots/{snap}`.",
  1404. // "location": "path",
  1405. // "pattern": "^projects/[^/]+/snapshots/[^/]+$",
  1406. // "required": true,
  1407. // "type": "string"
  1408. // }
  1409. // },
  1410. // "path": "v1/{+name}",
  1411. // "request": {
  1412. // "$ref": "CreateSnapshotRequest"
  1413. // },
  1414. // "response": {
  1415. // "$ref": "Snapshot"
  1416. // },
  1417. // "scopes": [
  1418. // "https://www.googleapis.com/auth/cloud-platform",
  1419. // "https://www.googleapis.com/auth/pubsub"
  1420. // ]
  1421. // }
  1422. }
  1423. // method id "pubsub.projects.snapshots.delete":
  1424. type ProjectsSnapshotsDeleteCall struct {
  1425. s *Service
  1426. snapshot string
  1427. urlParams_ gensupport.URLParams
  1428. ctx_ context.Context
  1429. header_ http.Header
  1430. }
  1431. // Delete: Removes an existing snapshot. <br><br>
  1432. // <b>ALPHA:</b> This feature is part of an alpha release. This API
  1433. // might be
  1434. // changed in backward-incompatible ways and is not recommended for
  1435. // production
  1436. // use. It is not subject to any SLA or deprecation policy.
  1437. // When the snapshot is deleted, all messages retained in the
  1438. // snapshot
  1439. // are immediately dropped. After a snapshot is deleted, a new one may
  1440. // be
  1441. // created with the same name, but the new one has no association with
  1442. // the old
  1443. // snapshot or its subscription, unless the same subscription is
  1444. // specified.
  1445. func (r *ProjectsSnapshotsService) Delete(snapshot string) *ProjectsSnapshotsDeleteCall {
  1446. c := &ProjectsSnapshotsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1447. c.snapshot = snapshot
  1448. return c
  1449. }
  1450. // Fields allows partial responses to be retrieved. See
  1451. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1452. // for more information.
  1453. func (c *ProjectsSnapshotsDeleteCall) Fields(s ...googleapi.Field) *ProjectsSnapshotsDeleteCall {
  1454. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1455. return c
  1456. }
  1457. // Context sets the context to be used in this call's Do method. Any
  1458. // pending HTTP request will be aborted if the provided context is
  1459. // canceled.
  1460. func (c *ProjectsSnapshotsDeleteCall) Context(ctx context.Context) *ProjectsSnapshotsDeleteCall {
  1461. c.ctx_ = ctx
  1462. return c
  1463. }
  1464. // Header returns an http.Header that can be modified by the caller to
  1465. // add HTTP headers to the request.
  1466. func (c *ProjectsSnapshotsDeleteCall) Header() http.Header {
  1467. if c.header_ == nil {
  1468. c.header_ = make(http.Header)
  1469. }
  1470. return c.header_
  1471. }
  1472. func (c *ProjectsSnapshotsDeleteCall) doRequest(alt string) (*http.Response, error) {
  1473. reqHeaders := make(http.Header)
  1474. for k, v := range c.header_ {
  1475. reqHeaders[k] = v
  1476. }
  1477. reqHeaders.Set("User-Agent", c.s.userAgent())
  1478. var body io.Reader = nil
  1479. c.urlParams_.Set("alt", alt)
  1480. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+snapshot}")
  1481. urls += "?" + c.urlParams_.Encode()
  1482. req, _ := http.NewRequest("DELETE", urls, body)
  1483. req.Header = reqHeaders
  1484. googleapi.Expand(req.URL, map[string]string{
  1485. "snapshot": c.snapshot,
  1486. })
  1487. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1488. }
  1489. // Do executes the "pubsub.projects.snapshots.delete" call.
  1490. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  1491. // code is an error. Response headers are in either
  1492. // *Empty.ServerResponse.Header or (if a response was returned at all)
  1493. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1494. // check whether the returned error was because http.StatusNotModified
  1495. // was returned.
  1496. func (c *ProjectsSnapshotsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  1497. gensupport.SetOptions(c.urlParams_, opts...)
  1498. res, err := c.doRequest("json")
  1499. if res != nil && res.StatusCode == http.StatusNotModified {
  1500. if res.Body != nil {
  1501. res.Body.Close()
  1502. }
  1503. return nil, &googleapi.Error{
  1504. Code: res.StatusCode,
  1505. Header: res.Header,
  1506. }
  1507. }
  1508. if err != nil {
  1509. return nil, err
  1510. }
  1511. defer googleapi.CloseBody(res)
  1512. if err := googleapi.CheckResponse(res); err != nil {
  1513. return nil, err
  1514. }
  1515. ret := &Empty{
  1516. ServerResponse: googleapi.ServerResponse{
  1517. Header: res.Header,
  1518. HTTPStatusCode: res.StatusCode,
  1519. },
  1520. }
  1521. target := &ret
  1522. if err := gensupport.DecodeResponse(target, res); err != nil {
  1523. return nil, err
  1524. }
  1525. return ret, nil
  1526. // {
  1527. // "description": "Removes an existing snapshot. \u003cbr\u003e\u003cbr\u003e\n\u003cb\u003eALPHA:\u003c/b\u003e This feature is part of an alpha release. This API might be\nchanged in backward-incompatible ways and is not recommended for production\nuse. It is not subject to any SLA or deprecation policy.\nWhen the snapshot is deleted, all messages retained in the snapshot\nare immediately dropped. After a snapshot is deleted, a new one may be\ncreated with the same name, but the new one has no association with the old\nsnapshot or its subscription, unless the same subscription is specified.",
  1528. // "flatPath": "v1/projects/{projectsId}/snapshots/{snapshotsId}",
  1529. // "httpMethod": "DELETE",
  1530. // "id": "pubsub.projects.snapshots.delete",
  1531. // "parameterOrder": [
  1532. // "snapshot"
  1533. // ],
  1534. // "parameters": {
  1535. // "snapshot": {
  1536. // "description": "The name of the snapshot to delete.\nFormat is `projects/{project}/snapshots/{snap}`.",
  1537. // "location": "path",
  1538. // "pattern": "^projects/[^/]+/snapshots/[^/]+$",
  1539. // "required": true,
  1540. // "type": "string"
  1541. // }
  1542. // },
  1543. // "path": "v1/{+snapshot}",
  1544. // "response": {
  1545. // "$ref": "Empty"
  1546. // },
  1547. // "scopes": [
  1548. // "https://www.googleapis.com/auth/cloud-platform",
  1549. // "https://www.googleapis.com/auth/pubsub"
  1550. // ]
  1551. // }
  1552. }
  1553. // method id "pubsub.projects.snapshots.get":
  1554. type ProjectsSnapshotsGetCall struct {
  1555. s *Service
  1556. snapshot string
  1557. urlParams_ gensupport.URLParams
  1558. ifNoneMatch_ string
  1559. ctx_ context.Context
  1560. header_ http.Header
  1561. }
  1562. // Get: Gets the configuration details of a
  1563. // snapshot.<br><br>
  1564. // <b>ALPHA:</b> This feature is part of an alpha release. This API
  1565. // might be
  1566. // changed in backward-incompatible ways and is not recommended for
  1567. // production
  1568. // use. It is not subject to any SLA or deprecation policy.
  1569. func (r *ProjectsSnapshotsService) Get(snapshot string) *ProjectsSnapshotsGetCall {
  1570. c := &ProjectsSnapshotsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1571. c.snapshot = snapshot
  1572. return c
  1573. }
  1574. // Fields allows partial responses to be retrieved. See
  1575. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1576. // for more information.
  1577. func (c *ProjectsSnapshotsGetCall) Fields(s ...googleapi.Field) *ProjectsSnapshotsGetCall {
  1578. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1579. return c
  1580. }
  1581. // IfNoneMatch sets the optional parameter which makes the operation
  1582. // fail if the object's ETag matches the given value. This is useful for
  1583. // getting updates only after the object has changed since the last
  1584. // request. Use googleapi.IsNotModified to check whether the response
  1585. // error from Do is the result of In-None-Match.
  1586. func (c *ProjectsSnapshotsGetCall) IfNoneMatch(entityTag string) *ProjectsSnapshotsGetCall {
  1587. c.ifNoneMatch_ = entityTag
  1588. return c
  1589. }
  1590. // Context sets the context to be used in this call's Do method. Any
  1591. // pending HTTP request will be aborted if the provided context is
  1592. // canceled.
  1593. func (c *ProjectsSnapshotsGetCall) Context(ctx context.Context) *ProjectsSnapshotsGetCall {
  1594. c.ctx_ = ctx
  1595. return c
  1596. }
  1597. // Header returns an http.Header that can be modified by the caller to
  1598. // add HTTP headers to the request.
  1599. func (c *ProjectsSnapshotsGetCall) Header() http.Header {
  1600. if c.header_ == nil {
  1601. c.header_ = make(http.Header)
  1602. }
  1603. return c.header_
  1604. }
  1605. func (c *ProjectsSnapshotsGetCall) doRequest(alt string) (*http.Response, error) {
  1606. reqHeaders := make(http.Header)
  1607. for k, v := range c.header_ {
  1608. reqHeaders[k] = v
  1609. }
  1610. reqHeaders.Set("User-Agent", c.s.userAgent())
  1611. if c.ifNoneMatch_ != "" {
  1612. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1613. }
  1614. var body io.Reader = nil
  1615. c.urlParams_.Set("alt", alt)
  1616. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+snapshot}")
  1617. urls += "?" + c.urlParams_.Encode()
  1618. req, _ := http.NewRequest("GET", urls, body)
  1619. req.Header = reqHeaders
  1620. googleapi.Expand(req.URL, map[string]string{
  1621. "snapshot": c.snapshot,
  1622. })
  1623. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1624. }
  1625. // Do executes the "pubsub.projects.snapshots.get" call.
  1626. // Exactly one of *Snapshot or error will be non-nil. Any non-2xx status
  1627. // code is an error. Response headers are in either
  1628. // *Snapshot.ServerResponse.Header or (if a response was returned at
  1629. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1630. // to check whether the returned error was because
  1631. // http.StatusNotModified was returned.
  1632. func (c *ProjectsSnapshotsGetCall) Do(opts ...googleapi.CallOption) (*Snapshot, error) {
  1633. gensupport.SetOptions(c.urlParams_, opts...)
  1634. res, err := c.doRequest("json")
  1635. if res != nil && res.StatusCode == http.StatusNotModified {
  1636. if res.Body != nil {
  1637. res.Body.Close()
  1638. }
  1639. return nil, &googleapi.Error{
  1640. Code: res.StatusCode,
  1641. Header: res.Header,
  1642. }
  1643. }
  1644. if err != nil {
  1645. return nil, err
  1646. }
  1647. defer googleapi.CloseBody(res)
  1648. if err := googleapi.CheckResponse(res); err != nil {
  1649. return nil, err
  1650. }
  1651. ret := &Snapshot{
  1652. ServerResponse: googleapi.ServerResponse{
  1653. Header: res.Header,
  1654. HTTPStatusCode: res.StatusCode,
  1655. },
  1656. }
  1657. target := &ret
  1658. if err := gensupport.DecodeResponse(target, res); err != nil {
  1659. return nil, err
  1660. }
  1661. return ret, nil
  1662. // {
  1663. // "description": "Gets the configuration details of a snapshot.\u003cbr\u003e\u003cbr\u003e\n\u003cb\u003eALPHA:\u003c/b\u003e This feature is part of an alpha release. This API might be\nchanged in backward-incompatible ways and is not recommended for production\nuse. It is not subject to any SLA or deprecation policy.",
  1664. // "flatPath": "v1/projects/{projectsId}/snapshots/{snapshotsId}",
  1665. // "httpMethod": "GET",
  1666. // "id": "pubsub.projects.snapshots.get",
  1667. // "parameterOrder": [
  1668. // "snapshot"
  1669. // ],
  1670. // "parameters": {
  1671. // "snapshot": {
  1672. // "description": "The name of the snapshot to get.\nFormat is `projects/{project}/snapshots/{snap}`.",
  1673. // "location": "path",
  1674. // "pattern": "^projects/[^/]+/snapshots/[^/]+$",
  1675. // "required": true,
  1676. // "type": "string"
  1677. // }
  1678. // },
  1679. // "path": "v1/{+snapshot}",
  1680. // "response": {
  1681. // "$ref": "Snapshot"
  1682. // },
  1683. // "scopes": [
  1684. // "https://www.googleapis.com/auth/cloud-platform",
  1685. // "https://www.googleapis.com/auth/pubsub"
  1686. // ]
  1687. // }
  1688. }
  1689. // method id "pubsub.projects.snapshots.getIamPolicy":
  1690. type ProjectsSnapshotsGetIamPolicyCall struct {
  1691. s *Service
  1692. resource string
  1693. urlParams_ gensupport.URLParams
  1694. ifNoneMatch_ string
  1695. ctx_ context.Context
  1696. header_ http.Header
  1697. }
  1698. // GetIamPolicy: Gets the access control policy for a resource.
  1699. // Returns an empty policy if the resource exists and does not have a
  1700. // policy
  1701. // set.
  1702. func (r *ProjectsSnapshotsService) GetIamPolicy(resource string) *ProjectsSnapshotsGetIamPolicyCall {
  1703. c := &ProjectsSnapshotsGetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1704. c.resource = resource
  1705. return c
  1706. }
  1707. // Fields allows partial responses to be retrieved. See
  1708. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1709. // for more information.
  1710. func (c *ProjectsSnapshotsGetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsSnapshotsGetIamPolicyCall {
  1711. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1712. return c
  1713. }
  1714. // IfNoneMatch sets the optional parameter which makes the operation
  1715. // fail if the object's ETag matches the given value. This is useful for
  1716. // getting updates only after the object has changed since the last
  1717. // request. Use googleapi.IsNotModified to check whether the response
  1718. // error from Do is the result of In-None-Match.
  1719. func (c *ProjectsSnapshotsGetIamPolicyCall) IfNoneMatch(entityTag string) *ProjectsSnapshotsGetIamPolicyCall {
  1720. c.ifNoneMatch_ = entityTag
  1721. return c
  1722. }
  1723. // Context sets the context to be used in this call's Do method. Any
  1724. // pending HTTP request will be aborted if the provided context is
  1725. // canceled.
  1726. func (c *ProjectsSnapshotsGetIamPolicyCall) Context(ctx context.Context) *ProjectsSnapshotsGetIamPolicyCall {
  1727. c.ctx_ = ctx
  1728. return c
  1729. }
  1730. // Header returns an http.Header that can be modified by the caller to
  1731. // add HTTP headers to the request.
  1732. func (c *ProjectsSnapshotsGetIamPolicyCall) Header() http.Header {
  1733. if c.header_ == nil {
  1734. c.header_ = make(http.Header)
  1735. }
  1736. return c.header_
  1737. }
  1738. func (c *ProjectsSnapshotsGetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  1739. reqHeaders := make(http.Header)
  1740. for k, v := range c.header_ {
  1741. reqHeaders[k] = v
  1742. }
  1743. reqHeaders.Set("User-Agent", c.s.userAgent())
  1744. if c.ifNoneMatch_ != "" {
  1745. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1746. }
  1747. var body io.Reader = nil
  1748. c.urlParams_.Set("alt", alt)
  1749. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+resource}:getIamPolicy")
  1750. urls += "?" + c.urlParams_.Encode()
  1751. req, _ := http.NewRequest("GET", urls, body)
  1752. req.Header = reqHeaders
  1753. googleapi.Expand(req.URL, map[string]string{
  1754. "resource": c.resource,
  1755. })
  1756. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1757. }
  1758. // Do executes the "pubsub.projects.snapshots.getIamPolicy" call.
  1759. // Exactly one of *Policy or error will be non-nil. Any non-2xx status
  1760. // code is an error. Response headers are in either
  1761. // *Policy.ServerResponse.Header or (if a response was returned at all)
  1762. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1763. // check whether the returned error was because http.StatusNotModified
  1764. // was returned.
  1765. func (c *ProjectsSnapshotsGetIamPolicyCall) Do(opts ...googleapi.CallOption) (*Policy, error) {
  1766. gensupport.SetOptions(c.urlParams_, opts...)
  1767. res, err := c.doRequest("json")
  1768. if res != nil && res.StatusCode == http.StatusNotModified {
  1769. if res.Body != nil {
  1770. res.Body.Close()
  1771. }
  1772. return nil, &googleapi.Error{
  1773. Code: res.StatusCode,
  1774. Header: res.Header,
  1775. }
  1776. }
  1777. if err != nil {
  1778. return nil, err
  1779. }
  1780. defer googleapi.CloseBody(res)
  1781. if err := googleapi.CheckResponse(res); err != nil {
  1782. return nil, err
  1783. }
  1784. ret := &Policy{
  1785. ServerResponse: googleapi.ServerResponse{
  1786. Header: res.Header,
  1787. HTTPStatusCode: res.StatusCode,
  1788. },
  1789. }
  1790. target := &ret
  1791. if err := gensupport.DecodeResponse(target, res); err != nil {
  1792. return nil, err
  1793. }
  1794. return ret, nil
  1795. // {
  1796. // "description": "Gets the access control policy for a resource.\nReturns an empty policy if the resource exists and does not have a policy\nset.",
  1797. // "flatPath": "v1/projects/{projectsId}/snapshots/{snapshotsId}:getIamPolicy",
  1798. // "httpMethod": "GET",
  1799. // "id": "pubsub.projects.snapshots.getIamPolicy",
  1800. // "parameterOrder": [
  1801. // "resource"
  1802. // ],
  1803. // "parameters": {
  1804. // "resource": {
  1805. // "description": "REQUIRED: The resource for which the policy is being requested.\nSee the operation documentation for the appropriate value for this field.",
  1806. // "location": "path",
  1807. // "pattern": "^projects/[^/]+/snapshots/[^/]+$",
  1808. // "required": true,
  1809. // "type": "string"
  1810. // }
  1811. // },
  1812. // "path": "v1/{+resource}:getIamPolicy",
  1813. // "response": {
  1814. // "$ref": "Policy"
  1815. // },
  1816. // "scopes": [
  1817. // "https://www.googleapis.com/auth/cloud-platform",
  1818. // "https://www.googleapis.com/auth/pubsub"
  1819. // ]
  1820. // }
  1821. }
  1822. // method id "pubsub.projects.snapshots.list":
  1823. type ProjectsSnapshotsListCall struct {
  1824. s *Service
  1825. project string
  1826. urlParams_ gensupport.URLParams
  1827. ifNoneMatch_ string
  1828. ctx_ context.Context
  1829. header_ http.Header
  1830. }
  1831. // List: Lists the existing snapshots.<br><br>
  1832. // <b>ALPHA:</b> This feature is part of an alpha release. This API
  1833. // might be
  1834. // changed in backward-incompatible ways and is not recommended for
  1835. // production
  1836. // use. It is not subject to any SLA or deprecation policy.
  1837. func (r *ProjectsSnapshotsService) List(project string) *ProjectsSnapshotsListCall {
  1838. c := &ProjectsSnapshotsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1839. c.project = project
  1840. return c
  1841. }
  1842. // PageSize sets the optional parameter "pageSize": Maximum number of
  1843. // snapshots to return.
  1844. func (c *ProjectsSnapshotsListCall) PageSize(pageSize int64) *ProjectsSnapshotsListCall {
  1845. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  1846. return c
  1847. }
  1848. // PageToken sets the optional parameter "pageToken": The value returned
  1849. // by the last `ListSnapshotsResponse`; indicates that this
  1850. // is a continuation of a prior `ListSnapshots` call, and that the
  1851. // system
  1852. // should return the next page of data.
  1853. func (c *ProjectsSnapshotsListCall) PageToken(pageToken string) *ProjectsSnapshotsListCall {
  1854. c.urlParams_.Set("pageToken", pageToken)
  1855. return c
  1856. }
  1857. // Fields allows partial responses to be retrieved. See
  1858. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1859. // for more information.
  1860. func (c *ProjectsSnapshotsListCall) Fields(s ...googleapi.Field) *ProjectsSnapshotsListCall {
  1861. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1862. return c
  1863. }
  1864. // IfNoneMatch sets the optional parameter which makes the operation
  1865. // fail if the object's ETag matches the given value. This is useful for
  1866. // getting updates only after the object has changed since the last
  1867. // request. Use googleapi.IsNotModified to check whether the response
  1868. // error from Do is the result of In-None-Match.
  1869. func (c *ProjectsSnapshotsListCall) IfNoneMatch(entityTag string) *ProjectsSnapshotsListCall {
  1870. c.ifNoneMatch_ = entityTag
  1871. return c
  1872. }
  1873. // Context sets the context to be used in this call's Do method. Any
  1874. // pending HTTP request will be aborted if the provided context is
  1875. // canceled.
  1876. func (c *ProjectsSnapshotsListCall) Context(ctx context.Context) *ProjectsSnapshotsListCall {
  1877. c.ctx_ = ctx
  1878. return c
  1879. }
  1880. // Header returns an http.Header that can be modified by the caller to
  1881. // add HTTP headers to the request.
  1882. func (c *ProjectsSnapshotsListCall) Header() http.Header {
  1883. if c.header_ == nil {
  1884. c.header_ = make(http.Header)
  1885. }
  1886. return c.header_
  1887. }
  1888. func (c *ProjectsSnapshotsListCall) doRequest(alt string) (*http.Response, error) {
  1889. reqHeaders := make(http.Header)
  1890. for k, v := range c.header_ {
  1891. reqHeaders[k] = v
  1892. }
  1893. reqHeaders.Set("User-Agent", c.s.userAgent())
  1894. if c.ifNoneMatch_ != "" {
  1895. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1896. }
  1897. var body io.Reader = nil
  1898. c.urlParams_.Set("alt", alt)
  1899. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+project}/snapshots")
  1900. urls += "?" + c.urlParams_.Encode()
  1901. req, _ := http.NewRequest("GET", urls, body)
  1902. req.Header = reqHeaders
  1903. googleapi.Expand(req.URL, map[string]string{
  1904. "project": c.project,
  1905. })
  1906. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1907. }
  1908. // Do executes the "pubsub.projects.snapshots.list" call.
  1909. // Exactly one of *ListSnapshotsResponse or error will be non-nil. Any
  1910. // non-2xx status code is an error. Response headers are in either
  1911. // *ListSnapshotsResponse.ServerResponse.Header or (if a response was
  1912. // returned at all) in error.(*googleapi.Error).Header. Use
  1913. // googleapi.IsNotModified to check whether the returned error was
  1914. // because http.StatusNotModified was returned.
  1915. func (c *ProjectsSnapshotsListCall) Do(opts ...googleapi.CallOption) (*ListSnapshotsResponse, error) {
  1916. gensupport.SetOptions(c.urlParams_, opts...)
  1917. res, err := c.doRequest("json")
  1918. if res != nil && res.StatusCode == http.StatusNotModified {
  1919. if res.Body != nil {
  1920. res.Body.Close()
  1921. }
  1922. return nil, &googleapi.Error{
  1923. Code: res.StatusCode,
  1924. Header: res.Header,
  1925. }
  1926. }
  1927. if err != nil {
  1928. return nil, err
  1929. }
  1930. defer googleapi.CloseBody(res)
  1931. if err := googleapi.CheckResponse(res); err != nil {
  1932. return nil, err
  1933. }
  1934. ret := &ListSnapshotsResponse{
  1935. ServerResponse: googleapi.ServerResponse{
  1936. Header: res.Header,
  1937. HTTPStatusCode: res.StatusCode,
  1938. },
  1939. }
  1940. target := &ret
  1941. if err := gensupport.DecodeResponse(target, res); err != nil {
  1942. return nil, err
  1943. }
  1944. return ret, nil
  1945. // {
  1946. // "description": "Lists the existing snapshots.\u003cbr\u003e\u003cbr\u003e\n\u003cb\u003eALPHA:\u003c/b\u003e This feature is part of an alpha release. This API might be\nchanged in backward-incompatible ways and is not recommended for production\nuse. It is not subject to any SLA or deprecation policy.",
  1947. // "flatPath": "v1/projects/{projectsId}/snapshots",
  1948. // "httpMethod": "GET",
  1949. // "id": "pubsub.projects.snapshots.list",
  1950. // "parameterOrder": [
  1951. // "project"
  1952. // ],
  1953. // "parameters": {
  1954. // "pageSize": {
  1955. // "description": "Maximum number of snapshots to return.",
  1956. // "format": "int32",
  1957. // "location": "query",
  1958. // "type": "integer"
  1959. // },
  1960. // "pageToken": {
  1961. // "description": "The value returned by the last `ListSnapshotsResponse`; indicates that this\nis a continuation of a prior `ListSnapshots` call, and that the system\nshould return the next page of data.",
  1962. // "location": "query",
  1963. // "type": "string"
  1964. // },
  1965. // "project": {
  1966. // "description": "The name of the cloud project that snapshots belong to.\nFormat is `projects/{project}`.",
  1967. // "location": "path",
  1968. // "pattern": "^projects/[^/]+$",
  1969. // "required": true,
  1970. // "type": "string"
  1971. // }
  1972. // },
  1973. // "path": "v1/{+project}/snapshots",
  1974. // "response": {
  1975. // "$ref": "ListSnapshotsResponse"
  1976. // },
  1977. // "scopes": [
  1978. // "https://www.googleapis.com/auth/cloud-platform",
  1979. // "https://www.googleapis.com/auth/pubsub"
  1980. // ]
  1981. // }
  1982. }
  1983. // Pages invokes f for each page of results.
  1984. // A non-nil error returned from f will halt the iteration.
  1985. // The provided context supersedes any context provided to the Context method.
  1986. func (c *ProjectsSnapshotsListCall) Pages(ctx context.Context, f func(*ListSnapshotsResponse) error) error {
  1987. c.ctx_ = ctx
  1988. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1989. for {
  1990. x, err := c.Do()
  1991. if err != nil {
  1992. return err
  1993. }
  1994. if err := f(x); err != nil {
  1995. return err
  1996. }
  1997. if x.NextPageToken == "" {
  1998. return nil
  1999. }
  2000. c.PageToken(x.NextPageToken)
  2001. }
  2002. }
  2003. // method id "pubsub.projects.snapshots.patch":
  2004. type ProjectsSnapshotsPatchCall struct {
  2005. s *Service
  2006. name string
  2007. updatesnapshotrequest *UpdateSnapshotRequest
  2008. urlParams_ gensupport.URLParams
  2009. ctx_ context.Context
  2010. header_ http.Header
  2011. }
  2012. // Patch: Updates an existing snapshot.<br><br>
  2013. // <b>ALPHA:</b> This feature is part of an alpha release. This API
  2014. // might be
  2015. // changed in backward-incompatible ways and is not recommended for
  2016. // production
  2017. // use. It is not subject to any SLA or deprecation policy.
  2018. // Note that certain properties of a snapshot are not modifiable.
  2019. func (r *ProjectsSnapshotsService) Patch(name string, updatesnapshotrequest *UpdateSnapshotRequest) *ProjectsSnapshotsPatchCall {
  2020. c := &ProjectsSnapshotsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2021. c.name = name
  2022. c.updatesnapshotrequest = updatesnapshotrequest
  2023. return c
  2024. }
  2025. // Fields allows partial responses to be retrieved. See
  2026. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2027. // for more information.
  2028. func (c *ProjectsSnapshotsPatchCall) Fields(s ...googleapi.Field) *ProjectsSnapshotsPatchCall {
  2029. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2030. return c
  2031. }
  2032. // Context sets the context to be used in this call's Do method. Any
  2033. // pending HTTP request will be aborted if the provided context is
  2034. // canceled.
  2035. func (c *ProjectsSnapshotsPatchCall) Context(ctx context.Context) *ProjectsSnapshotsPatchCall {
  2036. c.ctx_ = ctx
  2037. return c
  2038. }
  2039. // Header returns an http.Header that can be modified by the caller to
  2040. // add HTTP headers to the request.
  2041. func (c *ProjectsSnapshotsPatchCall) Header() http.Header {
  2042. if c.header_ == nil {
  2043. c.header_ = make(http.Header)
  2044. }
  2045. return c.header_
  2046. }
  2047. func (c *ProjectsSnapshotsPatchCall) doRequest(alt string) (*http.Response, error) {
  2048. reqHeaders := make(http.Header)
  2049. for k, v := range c.header_ {
  2050. reqHeaders[k] = v
  2051. }
  2052. reqHeaders.Set("User-Agent", c.s.userAgent())
  2053. var body io.Reader = nil
  2054. body, err := googleapi.WithoutDataWrapper.JSONReader(c.updatesnapshotrequest)
  2055. if err != nil {
  2056. return nil, err
  2057. }
  2058. reqHeaders.Set("Content-Type", "application/json")
  2059. c.urlParams_.Set("alt", alt)
  2060. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  2061. urls += "?" + c.urlParams_.Encode()
  2062. req, _ := http.NewRequest("PATCH", urls, body)
  2063. req.Header = reqHeaders
  2064. googleapi.Expand(req.URL, map[string]string{
  2065. "name": c.name,
  2066. })
  2067. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2068. }
  2069. // Do executes the "pubsub.projects.snapshots.patch" call.
  2070. // Exactly one of *Snapshot or error will be non-nil. Any non-2xx status
  2071. // code is an error. Response headers are in either
  2072. // *Snapshot.ServerResponse.Header or (if a response was returned at
  2073. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  2074. // to check whether the returned error was because
  2075. // http.StatusNotModified was returned.
  2076. func (c *ProjectsSnapshotsPatchCall) Do(opts ...googleapi.CallOption) (*Snapshot, error) {
  2077. gensupport.SetOptions(c.urlParams_, opts...)
  2078. res, err := c.doRequest("json")
  2079. if res != nil && res.StatusCode == http.StatusNotModified {
  2080. if res.Body != nil {
  2081. res.Body.Close()
  2082. }
  2083. return nil, &googleapi.Error{
  2084. Code: res.StatusCode,
  2085. Header: res.Header,
  2086. }
  2087. }
  2088. if err != nil {
  2089. return nil, err
  2090. }
  2091. defer googleapi.CloseBody(res)
  2092. if err := googleapi.CheckResponse(res); err != nil {
  2093. return nil, err
  2094. }
  2095. ret := &Snapshot{
  2096. ServerResponse: googleapi.ServerResponse{
  2097. Header: res.Header,
  2098. HTTPStatusCode: res.StatusCode,
  2099. },
  2100. }
  2101. target := &ret
  2102. if err := gensupport.DecodeResponse(target, res); err != nil {
  2103. return nil, err
  2104. }
  2105. return ret, nil
  2106. // {
  2107. // "description": "Updates an existing snapshot.\u003cbr\u003e\u003cbr\u003e\n\u003cb\u003eALPHA:\u003c/b\u003e This feature is part of an alpha release. This API might be\nchanged in backward-incompatible ways and is not recommended for production\nuse. It is not subject to any SLA or deprecation policy.\nNote that certain properties of a snapshot are not modifiable.",
  2108. // "flatPath": "v1/projects/{projectsId}/snapshots/{snapshotsId}",
  2109. // "httpMethod": "PATCH",
  2110. // "id": "pubsub.projects.snapshots.patch",
  2111. // "parameterOrder": [
  2112. // "name"
  2113. // ],
  2114. // "parameters": {
  2115. // "name": {
  2116. // "description": "The name of the snapshot.",
  2117. // "location": "path",
  2118. // "pattern": "^projects/[^/]+/snapshots/[^/]+$",
  2119. // "required": true,
  2120. // "type": "string"
  2121. // }
  2122. // },
  2123. // "path": "v1/{+name}",
  2124. // "request": {
  2125. // "$ref": "UpdateSnapshotRequest"
  2126. // },
  2127. // "response": {
  2128. // "$ref": "Snapshot"
  2129. // },
  2130. // "scopes": [
  2131. // "https://www.googleapis.com/auth/cloud-platform",
  2132. // "https://www.googleapis.com/auth/pubsub"
  2133. // ]
  2134. // }
  2135. }
  2136. // method id "pubsub.projects.snapshots.setIamPolicy":
  2137. type ProjectsSnapshotsSetIamPolicyCall struct {
  2138. s *Service
  2139. resource string
  2140. setiampolicyrequest *SetIamPolicyRequest
  2141. urlParams_ gensupport.URLParams
  2142. ctx_ context.Context
  2143. header_ http.Header
  2144. }
  2145. // SetIamPolicy: Sets the access control policy on the specified
  2146. // resource. Replaces any
  2147. // existing policy.
  2148. func (r *ProjectsSnapshotsService) SetIamPolicy(resource string, setiampolicyrequest *SetIamPolicyRequest) *ProjectsSnapshotsSetIamPolicyCall {
  2149. c := &ProjectsSnapshotsSetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2150. c.resource = resource
  2151. c.setiampolicyrequest = setiampolicyrequest
  2152. return c
  2153. }
  2154. // Fields allows partial responses to be retrieved. See
  2155. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2156. // for more information.
  2157. func (c *ProjectsSnapshotsSetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsSnapshotsSetIamPolicyCall {
  2158. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2159. return c
  2160. }
  2161. // Context sets the context to be used in this call's Do method. Any
  2162. // pending HTTP request will be aborted if the provided context is
  2163. // canceled.
  2164. func (c *ProjectsSnapshotsSetIamPolicyCall) Context(ctx context.Context) *ProjectsSnapshotsSetIamPolicyCall {
  2165. c.ctx_ = ctx
  2166. return c
  2167. }
  2168. // Header returns an http.Header that can be modified by the caller to
  2169. // add HTTP headers to the request.
  2170. func (c *ProjectsSnapshotsSetIamPolicyCall) Header() http.Header {
  2171. if c.header_ == nil {
  2172. c.header_ = make(http.Header)
  2173. }
  2174. return c.header_
  2175. }
  2176. func (c *ProjectsSnapshotsSetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  2177. reqHeaders := make(http.Header)
  2178. for k, v := range c.header_ {
  2179. reqHeaders[k] = v
  2180. }
  2181. reqHeaders.Set("User-Agent", c.s.userAgent())
  2182. var body io.Reader = nil
  2183. body, err := googleapi.WithoutDataWrapper.JSONReader(c.setiampolicyrequest)
  2184. if err != nil {
  2185. return nil, err
  2186. }
  2187. reqHeaders.Set("Content-Type", "application/json")
  2188. c.urlParams_.Set("alt", alt)
  2189. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+resource}:setIamPolicy")
  2190. urls += "?" + c.urlParams_.Encode()
  2191. req, _ := http.NewRequest("POST", urls, body)
  2192. req.Header = reqHeaders
  2193. googleapi.Expand(req.URL, map[string]string{
  2194. "resource": c.resource,
  2195. })
  2196. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2197. }
  2198. // Do executes the "pubsub.projects.snapshots.setIamPolicy" call.
  2199. // Exactly one of *Policy or error will be non-nil. Any non-2xx status
  2200. // code is an error. Response headers are in either
  2201. // *Policy.ServerResponse.Header or (if a response was returned at all)
  2202. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2203. // check whether the returned error was because http.StatusNotModified
  2204. // was returned.
  2205. func (c *ProjectsSnapshotsSetIamPolicyCall) Do(opts ...googleapi.CallOption) (*Policy, error) {
  2206. gensupport.SetOptions(c.urlParams_, opts...)
  2207. res, err := c.doRequest("json")
  2208. if res != nil && res.StatusCode == http.StatusNotModified {
  2209. if res.Body != nil {
  2210. res.Body.Close()
  2211. }
  2212. return nil, &googleapi.Error{
  2213. Code: res.StatusCode,
  2214. Header: res.Header,
  2215. }
  2216. }
  2217. if err != nil {
  2218. return nil, err
  2219. }
  2220. defer googleapi.CloseBody(res)
  2221. if err := googleapi.CheckResponse(res); err != nil {
  2222. return nil, err
  2223. }
  2224. ret := &Policy{
  2225. ServerResponse: googleapi.ServerResponse{
  2226. Header: res.Header,
  2227. HTTPStatusCode: res.StatusCode,
  2228. },
  2229. }
  2230. target := &ret
  2231. if err := gensupport.DecodeResponse(target, res); err != nil {
  2232. return nil, err
  2233. }
  2234. return ret, nil
  2235. // {
  2236. // "description": "Sets the access control policy on the specified resource. Replaces any\nexisting policy.",
  2237. // "flatPath": "v1/projects/{projectsId}/snapshots/{snapshotsId}:setIamPolicy",
  2238. // "httpMethod": "POST",
  2239. // "id": "pubsub.projects.snapshots.setIamPolicy",
  2240. // "parameterOrder": [
  2241. // "resource"
  2242. // ],
  2243. // "parameters": {
  2244. // "resource": {
  2245. // "description": "REQUIRED: The resource for which the policy is being specified.\nSee the operation documentation for the appropriate value for this field.",
  2246. // "location": "path",
  2247. // "pattern": "^projects/[^/]+/snapshots/[^/]+$",
  2248. // "required": true,
  2249. // "type": "string"
  2250. // }
  2251. // },
  2252. // "path": "v1/{+resource}:setIamPolicy",
  2253. // "request": {
  2254. // "$ref": "SetIamPolicyRequest"
  2255. // },
  2256. // "response": {
  2257. // "$ref": "Policy"
  2258. // },
  2259. // "scopes": [
  2260. // "https://www.googleapis.com/auth/cloud-platform",
  2261. // "https://www.googleapis.com/auth/pubsub"
  2262. // ]
  2263. // }
  2264. }
  2265. // method id "pubsub.projects.snapshots.testIamPermissions":
  2266. type ProjectsSnapshotsTestIamPermissionsCall struct {
  2267. s *Service
  2268. resource string
  2269. testiampermissionsrequest *TestIamPermissionsRequest
  2270. urlParams_ gensupport.URLParams
  2271. ctx_ context.Context
  2272. header_ http.Header
  2273. }
  2274. // TestIamPermissions: Returns permissions that a caller has on the
  2275. // specified resource.
  2276. // If the resource does not exist, this will return an empty set
  2277. // of
  2278. // permissions, not a NOT_FOUND error.
  2279. //
  2280. // Note: This operation is designed to be used for building
  2281. // permission-aware
  2282. // UIs and command-line tools, not for authorization checking. This
  2283. // operation
  2284. // may "fail open" without warning.
  2285. func (r *ProjectsSnapshotsService) TestIamPermissions(resource string, testiampermissionsrequest *TestIamPermissionsRequest) *ProjectsSnapshotsTestIamPermissionsCall {
  2286. c := &ProjectsSnapshotsTestIamPermissionsCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2287. c.resource = resource
  2288. c.testiampermissionsrequest = testiampermissionsrequest
  2289. return c
  2290. }
  2291. // Fields allows partial responses to be retrieved. See
  2292. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2293. // for more information.
  2294. func (c *ProjectsSnapshotsTestIamPermissionsCall) Fields(s ...googleapi.Field) *ProjectsSnapshotsTestIamPermissionsCall {
  2295. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2296. return c
  2297. }
  2298. // Context sets the context to be used in this call's Do method. Any
  2299. // pending HTTP request will be aborted if the provided context is
  2300. // canceled.
  2301. func (c *ProjectsSnapshotsTestIamPermissionsCall) Context(ctx context.Context) *ProjectsSnapshotsTestIamPermissionsCall {
  2302. c.ctx_ = ctx
  2303. return c
  2304. }
  2305. // Header returns an http.Header that can be modified by the caller to
  2306. // add HTTP headers to the request.
  2307. func (c *ProjectsSnapshotsTestIamPermissionsCall) Header() http.Header {
  2308. if c.header_ == nil {
  2309. c.header_ = make(http.Header)
  2310. }
  2311. return c.header_
  2312. }
  2313. func (c *ProjectsSnapshotsTestIamPermissionsCall) doRequest(alt string) (*http.Response, error) {
  2314. reqHeaders := make(http.Header)
  2315. for k, v := range c.header_ {
  2316. reqHeaders[k] = v
  2317. }
  2318. reqHeaders.Set("User-Agent", c.s.userAgent())
  2319. var body io.Reader = nil
  2320. body, err := googleapi.WithoutDataWrapper.JSONReader(c.testiampermissionsrequest)
  2321. if err != nil {
  2322. return nil, err
  2323. }
  2324. reqHeaders.Set("Content-Type", "application/json")
  2325. c.urlParams_.Set("alt", alt)
  2326. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+resource}:testIamPermissions")
  2327. urls += "?" + c.urlParams_.Encode()
  2328. req, _ := http.NewRequest("POST", urls, body)
  2329. req.Header = reqHeaders
  2330. googleapi.Expand(req.URL, map[string]string{
  2331. "resource": c.resource,
  2332. })
  2333. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2334. }
  2335. // Do executes the "pubsub.projects.snapshots.testIamPermissions" call.
  2336. // Exactly one of *TestIamPermissionsResponse or error will be non-nil.
  2337. // Any non-2xx status code is an error. Response headers are in either
  2338. // *TestIamPermissionsResponse.ServerResponse.Header or (if a response
  2339. // was returned at all) in error.(*googleapi.Error).Header. Use
  2340. // googleapi.IsNotModified to check whether the returned error was
  2341. // because http.StatusNotModified was returned.
  2342. func (c *ProjectsSnapshotsTestIamPermissionsCall) Do(opts ...googleapi.CallOption) (*TestIamPermissionsResponse, error) {
  2343. gensupport.SetOptions(c.urlParams_, opts...)
  2344. res, err := c.doRequest("json")
  2345. if res != nil && res.StatusCode == http.StatusNotModified {
  2346. if res.Body != nil {
  2347. res.Body.Close()
  2348. }
  2349. return nil, &googleapi.Error{
  2350. Code: res.StatusCode,
  2351. Header: res.Header,
  2352. }
  2353. }
  2354. if err != nil {
  2355. return nil, err
  2356. }
  2357. defer googleapi.CloseBody(res)
  2358. if err := googleapi.CheckResponse(res); err != nil {
  2359. return nil, err
  2360. }
  2361. ret := &TestIamPermissionsResponse{
  2362. ServerResponse: googleapi.ServerResponse{
  2363. Header: res.Header,
  2364. HTTPStatusCode: res.StatusCode,
  2365. },
  2366. }
  2367. target := &ret
  2368. if err := gensupport.DecodeResponse(target, res); err != nil {
  2369. return nil, err
  2370. }
  2371. return ret, nil
  2372. // {
  2373. // "description": "Returns permissions that a caller has on the specified resource.\nIf the resource does not exist, this will return an empty set of\npermissions, not a NOT_FOUND error.\n\nNote: This operation is designed to be used for building permission-aware\nUIs and command-line tools, not for authorization checking. This operation\nmay \"fail open\" without warning.",
  2374. // "flatPath": "v1/projects/{projectsId}/snapshots/{snapshotsId}:testIamPermissions",
  2375. // "httpMethod": "POST",
  2376. // "id": "pubsub.projects.snapshots.testIamPermissions",
  2377. // "parameterOrder": [
  2378. // "resource"
  2379. // ],
  2380. // "parameters": {
  2381. // "resource": {
  2382. // "description": "REQUIRED: The resource for which the policy detail is being requested.\nSee the operation documentation for the appropriate value for this field.",
  2383. // "location": "path",
  2384. // "pattern": "^projects/[^/]+/snapshots/[^/]+$",
  2385. // "required": true,
  2386. // "type": "string"
  2387. // }
  2388. // },
  2389. // "path": "v1/{+resource}:testIamPermissions",
  2390. // "request": {
  2391. // "$ref": "TestIamPermissionsRequest"
  2392. // },
  2393. // "response": {
  2394. // "$ref": "TestIamPermissionsResponse"
  2395. // },
  2396. // "scopes": [
  2397. // "https://www.googleapis.com/auth/cloud-platform",
  2398. // "https://www.googleapis.com/auth/pubsub"
  2399. // ]
  2400. // }
  2401. }
  2402. // method id "pubsub.projects.subscriptions.acknowledge":
  2403. type ProjectsSubscriptionsAcknowledgeCall struct {
  2404. s *Service
  2405. subscription string
  2406. acknowledgerequest *AcknowledgeRequest
  2407. urlParams_ gensupport.URLParams
  2408. ctx_ context.Context
  2409. header_ http.Header
  2410. }
  2411. // Acknowledge: Acknowledges the messages associated with the `ack_ids`
  2412. // in the
  2413. // `AcknowledgeRequest`. The Pub/Sub system can remove the relevant
  2414. // messages
  2415. // from the subscription.
  2416. //
  2417. // Acknowledging a message whose ack deadline has expired may
  2418. // succeed,
  2419. // but such a message may be redelivered later. Acknowledging a message
  2420. // more
  2421. // than once will not result in an error.
  2422. func (r *ProjectsSubscriptionsService) Acknowledge(subscription string, acknowledgerequest *AcknowledgeRequest) *ProjectsSubscriptionsAcknowledgeCall {
  2423. c := &ProjectsSubscriptionsAcknowledgeCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2424. c.subscription = subscription
  2425. c.acknowledgerequest = acknowledgerequest
  2426. return c
  2427. }
  2428. // Fields allows partial responses to be retrieved. See
  2429. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2430. // for more information.
  2431. func (c *ProjectsSubscriptionsAcknowledgeCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsAcknowledgeCall {
  2432. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2433. return c
  2434. }
  2435. // Context sets the context to be used in this call's Do method. Any
  2436. // pending HTTP request will be aborted if the provided context is
  2437. // canceled.
  2438. func (c *ProjectsSubscriptionsAcknowledgeCall) Context(ctx context.Context) *ProjectsSubscriptionsAcknowledgeCall {
  2439. c.ctx_ = ctx
  2440. return c
  2441. }
  2442. // Header returns an http.Header that can be modified by the caller to
  2443. // add HTTP headers to the request.
  2444. func (c *ProjectsSubscriptionsAcknowledgeCall) Header() http.Header {
  2445. if c.header_ == nil {
  2446. c.header_ = make(http.Header)
  2447. }
  2448. return c.header_
  2449. }
  2450. func (c *ProjectsSubscriptionsAcknowledgeCall) doRequest(alt string) (*http.Response, error) {
  2451. reqHeaders := make(http.Header)
  2452. for k, v := range c.header_ {
  2453. reqHeaders[k] = v
  2454. }
  2455. reqHeaders.Set("User-Agent", c.s.userAgent())
  2456. var body io.Reader = nil
  2457. body, err := googleapi.WithoutDataWrapper.JSONReader(c.acknowledgerequest)
  2458. if err != nil {
  2459. return nil, err
  2460. }
  2461. reqHeaders.Set("Content-Type", "application/json")
  2462. c.urlParams_.Set("alt", alt)
  2463. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+subscription}:acknowledge")
  2464. urls += "?" + c.urlParams_.Encode()
  2465. req, _ := http.NewRequest("POST", urls, body)
  2466. req.Header = reqHeaders
  2467. googleapi.Expand(req.URL, map[string]string{
  2468. "subscription": c.subscription,
  2469. })
  2470. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2471. }
  2472. // Do executes the "pubsub.projects.subscriptions.acknowledge" call.
  2473. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  2474. // code is an error. Response headers are in either
  2475. // *Empty.ServerResponse.Header or (if a response was returned at all)
  2476. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2477. // check whether the returned error was because http.StatusNotModified
  2478. // was returned.
  2479. func (c *ProjectsSubscriptionsAcknowledgeCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  2480. gensupport.SetOptions(c.urlParams_, opts...)
  2481. res, err := c.doRequest("json")
  2482. if res != nil && res.StatusCode == http.StatusNotModified {
  2483. if res.Body != nil {
  2484. res.Body.Close()
  2485. }
  2486. return nil, &googleapi.Error{
  2487. Code: res.StatusCode,
  2488. Header: res.Header,
  2489. }
  2490. }
  2491. if err != nil {
  2492. return nil, err
  2493. }
  2494. defer googleapi.CloseBody(res)
  2495. if err := googleapi.CheckResponse(res); err != nil {
  2496. return nil, err
  2497. }
  2498. ret := &Empty{
  2499. ServerResponse: googleapi.ServerResponse{
  2500. Header: res.Header,
  2501. HTTPStatusCode: res.StatusCode,
  2502. },
  2503. }
  2504. target := &ret
  2505. if err := gensupport.DecodeResponse(target, res); err != nil {
  2506. return nil, err
  2507. }
  2508. return ret, nil
  2509. // {
  2510. // "description": "Acknowledges the messages associated with the `ack_ids` in the\n`AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages\nfrom the subscription.\n\nAcknowledging a message whose ack deadline has expired may succeed,\nbut such a message may be redelivered later. Acknowledging a message more\nthan once will not result in an error.",
  2511. // "flatPath": "v1/projects/{projectsId}/subscriptions/{subscriptionsId}:acknowledge",
  2512. // "httpMethod": "POST",
  2513. // "id": "pubsub.projects.subscriptions.acknowledge",
  2514. // "parameterOrder": [
  2515. // "subscription"
  2516. // ],
  2517. // "parameters": {
  2518. // "subscription": {
  2519. // "description": "The subscription whose message is being acknowledged.\nFormat is `projects/{project}/subscriptions/{sub}`.",
  2520. // "location": "path",
  2521. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  2522. // "required": true,
  2523. // "type": "string"
  2524. // }
  2525. // },
  2526. // "path": "v1/{+subscription}:acknowledge",
  2527. // "request": {
  2528. // "$ref": "AcknowledgeRequest"
  2529. // },
  2530. // "response": {
  2531. // "$ref": "Empty"
  2532. // },
  2533. // "scopes": [
  2534. // "https://www.googleapis.com/auth/cloud-platform",
  2535. // "https://www.googleapis.com/auth/pubsub"
  2536. // ]
  2537. // }
  2538. }
  2539. // method id "pubsub.projects.subscriptions.create":
  2540. type ProjectsSubscriptionsCreateCall struct {
  2541. s *Service
  2542. name string
  2543. subscription *Subscription
  2544. urlParams_ gensupport.URLParams
  2545. ctx_ context.Context
  2546. header_ http.Header
  2547. }
  2548. // Create: Creates a subscription to a given topic. See the
  2549. // <a href="/pubsub/docs/admin#resource_names"> resource name
  2550. // rules</a>.
  2551. // If the subscription already exists, returns `ALREADY_EXISTS`.
  2552. // If the corresponding topic doesn't exist, returns `NOT_FOUND`.
  2553. //
  2554. // If the name is not provided in the request, the server will assign a
  2555. // random
  2556. // name for this subscription on the same project as the topic,
  2557. // conforming
  2558. // to the
  2559. // [resource name
  2560. // format](https://cloud.google.com/pubsub/docs/overview#names).
  2561. // The generated name is populated in the returned Subscription
  2562. // object.
  2563. // Note that for REST API requests, you must specify a name in the
  2564. // request.
  2565. func (r *ProjectsSubscriptionsService) Create(name string, subscription *Subscription) *ProjectsSubscriptionsCreateCall {
  2566. c := &ProjectsSubscriptionsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2567. c.name = name
  2568. c.subscription = subscription
  2569. return c
  2570. }
  2571. // Fields allows partial responses to be retrieved. See
  2572. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2573. // for more information.
  2574. func (c *ProjectsSubscriptionsCreateCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsCreateCall {
  2575. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2576. return c
  2577. }
  2578. // Context sets the context to be used in this call's Do method. Any
  2579. // pending HTTP request will be aborted if the provided context is
  2580. // canceled.
  2581. func (c *ProjectsSubscriptionsCreateCall) Context(ctx context.Context) *ProjectsSubscriptionsCreateCall {
  2582. c.ctx_ = ctx
  2583. return c
  2584. }
  2585. // Header returns an http.Header that can be modified by the caller to
  2586. // add HTTP headers to the request.
  2587. func (c *ProjectsSubscriptionsCreateCall) Header() http.Header {
  2588. if c.header_ == nil {
  2589. c.header_ = make(http.Header)
  2590. }
  2591. return c.header_
  2592. }
  2593. func (c *ProjectsSubscriptionsCreateCall) doRequest(alt string) (*http.Response, error) {
  2594. reqHeaders := make(http.Header)
  2595. for k, v := range c.header_ {
  2596. reqHeaders[k] = v
  2597. }
  2598. reqHeaders.Set("User-Agent", c.s.userAgent())
  2599. var body io.Reader = nil
  2600. body, err := googleapi.WithoutDataWrapper.JSONReader(c.subscription)
  2601. if err != nil {
  2602. return nil, err
  2603. }
  2604. reqHeaders.Set("Content-Type", "application/json")
  2605. c.urlParams_.Set("alt", alt)
  2606. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  2607. urls += "?" + c.urlParams_.Encode()
  2608. req, _ := http.NewRequest("PUT", urls, body)
  2609. req.Header = reqHeaders
  2610. googleapi.Expand(req.URL, map[string]string{
  2611. "name": c.name,
  2612. })
  2613. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2614. }
  2615. // Do executes the "pubsub.projects.subscriptions.create" call.
  2616. // Exactly one of *Subscription or error will be non-nil. Any non-2xx
  2617. // status code is an error. Response headers are in either
  2618. // *Subscription.ServerResponse.Header or (if a response was returned at
  2619. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  2620. // to check whether the returned error was because
  2621. // http.StatusNotModified was returned.
  2622. func (c *ProjectsSubscriptionsCreateCall) Do(opts ...googleapi.CallOption) (*Subscription, error) {
  2623. gensupport.SetOptions(c.urlParams_, opts...)
  2624. res, err := c.doRequest("json")
  2625. if res != nil && res.StatusCode == http.StatusNotModified {
  2626. if res.Body != nil {
  2627. res.Body.Close()
  2628. }
  2629. return nil, &googleapi.Error{
  2630. Code: res.StatusCode,
  2631. Header: res.Header,
  2632. }
  2633. }
  2634. if err != nil {
  2635. return nil, err
  2636. }
  2637. defer googleapi.CloseBody(res)
  2638. if err := googleapi.CheckResponse(res); err != nil {
  2639. return nil, err
  2640. }
  2641. ret := &Subscription{
  2642. ServerResponse: googleapi.ServerResponse{
  2643. Header: res.Header,
  2644. HTTPStatusCode: res.StatusCode,
  2645. },
  2646. }
  2647. target := &ret
  2648. if err := gensupport.DecodeResponse(target, res); err != nil {
  2649. return nil, err
  2650. }
  2651. return ret, nil
  2652. // {
  2653. // "description": "Creates a subscription to a given topic. See the\n\u003ca href=\"/pubsub/docs/admin#resource_names\"\u003e resource name rules\u003c/a\u003e.\nIf the subscription already exists, returns `ALREADY_EXISTS`.\nIf the corresponding topic doesn't exist, returns `NOT_FOUND`.\n\nIf the name is not provided in the request, the server will assign a random\nname for this subscription on the same project as the topic, conforming\nto the\n[resource name format](https://cloud.google.com/pubsub/docs/overview#names).\nThe generated name is populated in the returned Subscription object.\nNote that for REST API requests, you must specify a name in the request.",
  2654. // "flatPath": "v1/projects/{projectsId}/subscriptions/{subscriptionsId}",
  2655. // "httpMethod": "PUT",
  2656. // "id": "pubsub.projects.subscriptions.create",
  2657. // "parameterOrder": [
  2658. // "name"
  2659. // ],
  2660. // "parameters": {
  2661. // "name": {
  2662. // "description": "The name of the subscription. It must have the format\n`\"projects/{project}/subscriptions/{subscription}\"`. `{subscription}` must\nstart with a letter, and contain only letters (`[A-Za-z]`), numbers\n(`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),\nplus (`+`) or percent signs (`%`). It must be between 3 and 255 characters\nin length, and it must not start with `\"goog\"`.",
  2663. // "location": "path",
  2664. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  2665. // "required": true,
  2666. // "type": "string"
  2667. // }
  2668. // },
  2669. // "path": "v1/{+name}",
  2670. // "request": {
  2671. // "$ref": "Subscription"
  2672. // },
  2673. // "response": {
  2674. // "$ref": "Subscription"
  2675. // },
  2676. // "scopes": [
  2677. // "https://www.googleapis.com/auth/cloud-platform",
  2678. // "https://www.googleapis.com/auth/pubsub"
  2679. // ]
  2680. // }
  2681. }
  2682. // method id "pubsub.projects.subscriptions.delete":
  2683. type ProjectsSubscriptionsDeleteCall struct {
  2684. s *Service
  2685. subscription string
  2686. urlParams_ gensupport.URLParams
  2687. ctx_ context.Context
  2688. header_ http.Header
  2689. }
  2690. // Delete: Deletes an existing subscription. All messages retained in
  2691. // the subscription
  2692. // are immediately dropped. Calls to `Pull` after deletion will
  2693. // return
  2694. // `NOT_FOUND`. After a subscription is deleted, a new one may be
  2695. // created with
  2696. // the same name, but the new one has no association with the
  2697. // old
  2698. // subscription or its topic unless the same topic is specified.
  2699. func (r *ProjectsSubscriptionsService) Delete(subscription string) *ProjectsSubscriptionsDeleteCall {
  2700. c := &ProjectsSubscriptionsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2701. c.subscription = subscription
  2702. return c
  2703. }
  2704. // Fields allows partial responses to be retrieved. See
  2705. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2706. // for more information.
  2707. func (c *ProjectsSubscriptionsDeleteCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsDeleteCall {
  2708. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2709. return c
  2710. }
  2711. // Context sets the context to be used in this call's Do method. Any
  2712. // pending HTTP request will be aborted if the provided context is
  2713. // canceled.
  2714. func (c *ProjectsSubscriptionsDeleteCall) Context(ctx context.Context) *ProjectsSubscriptionsDeleteCall {
  2715. c.ctx_ = ctx
  2716. return c
  2717. }
  2718. // Header returns an http.Header that can be modified by the caller to
  2719. // add HTTP headers to the request.
  2720. func (c *ProjectsSubscriptionsDeleteCall) Header() http.Header {
  2721. if c.header_ == nil {
  2722. c.header_ = make(http.Header)
  2723. }
  2724. return c.header_
  2725. }
  2726. func (c *ProjectsSubscriptionsDeleteCall) doRequest(alt string) (*http.Response, error) {
  2727. reqHeaders := make(http.Header)
  2728. for k, v := range c.header_ {
  2729. reqHeaders[k] = v
  2730. }
  2731. reqHeaders.Set("User-Agent", c.s.userAgent())
  2732. var body io.Reader = nil
  2733. c.urlParams_.Set("alt", alt)
  2734. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+subscription}")
  2735. urls += "?" + c.urlParams_.Encode()
  2736. req, _ := http.NewRequest("DELETE", urls, body)
  2737. req.Header = reqHeaders
  2738. googleapi.Expand(req.URL, map[string]string{
  2739. "subscription": c.subscription,
  2740. })
  2741. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2742. }
  2743. // Do executes the "pubsub.projects.subscriptions.delete" call.
  2744. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  2745. // code is an error. Response headers are in either
  2746. // *Empty.ServerResponse.Header or (if a response was returned at all)
  2747. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2748. // check whether the returned error was because http.StatusNotModified
  2749. // was returned.
  2750. func (c *ProjectsSubscriptionsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  2751. gensupport.SetOptions(c.urlParams_, opts...)
  2752. res, err := c.doRequest("json")
  2753. if res != nil && res.StatusCode == http.StatusNotModified {
  2754. if res.Body != nil {
  2755. res.Body.Close()
  2756. }
  2757. return nil, &googleapi.Error{
  2758. Code: res.StatusCode,
  2759. Header: res.Header,
  2760. }
  2761. }
  2762. if err != nil {
  2763. return nil, err
  2764. }
  2765. defer googleapi.CloseBody(res)
  2766. if err := googleapi.CheckResponse(res); err != nil {
  2767. return nil, err
  2768. }
  2769. ret := &Empty{
  2770. ServerResponse: googleapi.ServerResponse{
  2771. Header: res.Header,
  2772. HTTPStatusCode: res.StatusCode,
  2773. },
  2774. }
  2775. target := &ret
  2776. if err := gensupport.DecodeResponse(target, res); err != nil {
  2777. return nil, err
  2778. }
  2779. return ret, nil
  2780. // {
  2781. // "description": "Deletes an existing subscription. All messages retained in the subscription\nare immediately dropped. Calls to `Pull` after deletion will return\n`NOT_FOUND`. After a subscription is deleted, a new one may be created with\nthe same name, but the new one has no association with the old\nsubscription or its topic unless the same topic is specified.",
  2782. // "flatPath": "v1/projects/{projectsId}/subscriptions/{subscriptionsId}",
  2783. // "httpMethod": "DELETE",
  2784. // "id": "pubsub.projects.subscriptions.delete",
  2785. // "parameterOrder": [
  2786. // "subscription"
  2787. // ],
  2788. // "parameters": {
  2789. // "subscription": {
  2790. // "description": "The subscription to delete.\nFormat is `projects/{project}/subscriptions/{sub}`.",
  2791. // "location": "path",
  2792. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  2793. // "required": true,
  2794. // "type": "string"
  2795. // }
  2796. // },
  2797. // "path": "v1/{+subscription}",
  2798. // "response": {
  2799. // "$ref": "Empty"
  2800. // },
  2801. // "scopes": [
  2802. // "https://www.googleapis.com/auth/cloud-platform",
  2803. // "https://www.googleapis.com/auth/pubsub"
  2804. // ]
  2805. // }
  2806. }
  2807. // method id "pubsub.projects.subscriptions.get":
  2808. type ProjectsSubscriptionsGetCall struct {
  2809. s *Service
  2810. subscription string
  2811. urlParams_ gensupport.URLParams
  2812. ifNoneMatch_ string
  2813. ctx_ context.Context
  2814. header_ http.Header
  2815. }
  2816. // Get: Gets the configuration details of a subscription.
  2817. func (r *ProjectsSubscriptionsService) Get(subscription string) *ProjectsSubscriptionsGetCall {
  2818. c := &ProjectsSubscriptionsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2819. c.subscription = subscription
  2820. return c
  2821. }
  2822. // Fields allows partial responses to be retrieved. See
  2823. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2824. // for more information.
  2825. func (c *ProjectsSubscriptionsGetCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsGetCall {
  2826. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2827. return c
  2828. }
  2829. // IfNoneMatch sets the optional parameter which makes the operation
  2830. // fail if the object's ETag matches the given value. This is useful for
  2831. // getting updates only after the object has changed since the last
  2832. // request. Use googleapi.IsNotModified to check whether the response
  2833. // error from Do is the result of In-None-Match.
  2834. func (c *ProjectsSubscriptionsGetCall) IfNoneMatch(entityTag string) *ProjectsSubscriptionsGetCall {
  2835. c.ifNoneMatch_ = entityTag
  2836. return c
  2837. }
  2838. // Context sets the context to be used in this call's Do method. Any
  2839. // pending HTTP request will be aborted if the provided context is
  2840. // canceled.
  2841. func (c *ProjectsSubscriptionsGetCall) Context(ctx context.Context) *ProjectsSubscriptionsGetCall {
  2842. c.ctx_ = ctx
  2843. return c
  2844. }
  2845. // Header returns an http.Header that can be modified by the caller to
  2846. // add HTTP headers to the request.
  2847. func (c *ProjectsSubscriptionsGetCall) Header() http.Header {
  2848. if c.header_ == nil {
  2849. c.header_ = make(http.Header)
  2850. }
  2851. return c.header_
  2852. }
  2853. func (c *ProjectsSubscriptionsGetCall) doRequest(alt string) (*http.Response, error) {
  2854. reqHeaders := make(http.Header)
  2855. for k, v := range c.header_ {
  2856. reqHeaders[k] = v
  2857. }
  2858. reqHeaders.Set("User-Agent", c.s.userAgent())
  2859. if c.ifNoneMatch_ != "" {
  2860. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  2861. }
  2862. var body io.Reader = nil
  2863. c.urlParams_.Set("alt", alt)
  2864. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+subscription}")
  2865. urls += "?" + c.urlParams_.Encode()
  2866. req, _ := http.NewRequest("GET", urls, body)
  2867. req.Header = reqHeaders
  2868. googleapi.Expand(req.URL, map[string]string{
  2869. "subscription": c.subscription,
  2870. })
  2871. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2872. }
  2873. // Do executes the "pubsub.projects.subscriptions.get" call.
  2874. // Exactly one of *Subscription or error will be non-nil. Any non-2xx
  2875. // status code is an error. Response headers are in either
  2876. // *Subscription.ServerResponse.Header or (if a response was returned at
  2877. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  2878. // to check whether the returned error was because
  2879. // http.StatusNotModified was returned.
  2880. func (c *ProjectsSubscriptionsGetCall) Do(opts ...googleapi.CallOption) (*Subscription, error) {
  2881. gensupport.SetOptions(c.urlParams_, opts...)
  2882. res, err := c.doRequest("json")
  2883. if res != nil && res.StatusCode == http.StatusNotModified {
  2884. if res.Body != nil {
  2885. res.Body.Close()
  2886. }
  2887. return nil, &googleapi.Error{
  2888. Code: res.StatusCode,
  2889. Header: res.Header,
  2890. }
  2891. }
  2892. if err != nil {
  2893. return nil, err
  2894. }
  2895. defer googleapi.CloseBody(res)
  2896. if err := googleapi.CheckResponse(res); err != nil {
  2897. return nil, err
  2898. }
  2899. ret := &Subscription{
  2900. ServerResponse: googleapi.ServerResponse{
  2901. Header: res.Header,
  2902. HTTPStatusCode: res.StatusCode,
  2903. },
  2904. }
  2905. target := &ret
  2906. if err := gensupport.DecodeResponse(target, res); err != nil {
  2907. return nil, err
  2908. }
  2909. return ret, nil
  2910. // {
  2911. // "description": "Gets the configuration details of a subscription.",
  2912. // "flatPath": "v1/projects/{projectsId}/subscriptions/{subscriptionsId}",
  2913. // "httpMethod": "GET",
  2914. // "id": "pubsub.projects.subscriptions.get",
  2915. // "parameterOrder": [
  2916. // "subscription"
  2917. // ],
  2918. // "parameters": {
  2919. // "subscription": {
  2920. // "description": "The name of the subscription to get.\nFormat is `projects/{project}/subscriptions/{sub}`.",
  2921. // "location": "path",
  2922. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  2923. // "required": true,
  2924. // "type": "string"
  2925. // }
  2926. // },
  2927. // "path": "v1/{+subscription}",
  2928. // "response": {
  2929. // "$ref": "Subscription"
  2930. // },
  2931. // "scopes": [
  2932. // "https://www.googleapis.com/auth/cloud-platform",
  2933. // "https://www.googleapis.com/auth/pubsub"
  2934. // ]
  2935. // }
  2936. }
  2937. // method id "pubsub.projects.subscriptions.getIamPolicy":
  2938. type ProjectsSubscriptionsGetIamPolicyCall struct {
  2939. s *Service
  2940. resource string
  2941. urlParams_ gensupport.URLParams
  2942. ifNoneMatch_ string
  2943. ctx_ context.Context
  2944. header_ http.Header
  2945. }
  2946. // GetIamPolicy: Gets the access control policy for a resource.
  2947. // Returns an empty policy if the resource exists and does not have a
  2948. // policy
  2949. // set.
  2950. func (r *ProjectsSubscriptionsService) GetIamPolicy(resource string) *ProjectsSubscriptionsGetIamPolicyCall {
  2951. c := &ProjectsSubscriptionsGetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2952. c.resource = resource
  2953. return c
  2954. }
  2955. // Fields allows partial responses to be retrieved. See
  2956. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2957. // for more information.
  2958. func (c *ProjectsSubscriptionsGetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsGetIamPolicyCall {
  2959. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2960. return c
  2961. }
  2962. // IfNoneMatch sets the optional parameter which makes the operation
  2963. // fail if the object's ETag matches the given value. This is useful for
  2964. // getting updates only after the object has changed since the last
  2965. // request. Use googleapi.IsNotModified to check whether the response
  2966. // error from Do is the result of In-None-Match.
  2967. func (c *ProjectsSubscriptionsGetIamPolicyCall) IfNoneMatch(entityTag string) *ProjectsSubscriptionsGetIamPolicyCall {
  2968. c.ifNoneMatch_ = entityTag
  2969. return c
  2970. }
  2971. // Context sets the context to be used in this call's Do method. Any
  2972. // pending HTTP request will be aborted if the provided context is
  2973. // canceled.
  2974. func (c *ProjectsSubscriptionsGetIamPolicyCall) Context(ctx context.Context) *ProjectsSubscriptionsGetIamPolicyCall {
  2975. c.ctx_ = ctx
  2976. return c
  2977. }
  2978. // Header returns an http.Header that can be modified by the caller to
  2979. // add HTTP headers to the request.
  2980. func (c *ProjectsSubscriptionsGetIamPolicyCall) Header() http.Header {
  2981. if c.header_ == nil {
  2982. c.header_ = make(http.Header)
  2983. }
  2984. return c.header_
  2985. }
  2986. func (c *ProjectsSubscriptionsGetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  2987. reqHeaders := make(http.Header)
  2988. for k, v := range c.header_ {
  2989. reqHeaders[k] = v
  2990. }
  2991. reqHeaders.Set("User-Agent", c.s.userAgent())
  2992. if c.ifNoneMatch_ != "" {
  2993. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  2994. }
  2995. var body io.Reader = nil
  2996. c.urlParams_.Set("alt", alt)
  2997. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+resource}:getIamPolicy")
  2998. urls += "?" + c.urlParams_.Encode()
  2999. req, _ := http.NewRequest("GET", urls, body)
  3000. req.Header = reqHeaders
  3001. googleapi.Expand(req.URL, map[string]string{
  3002. "resource": c.resource,
  3003. })
  3004. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3005. }
  3006. // Do executes the "pubsub.projects.subscriptions.getIamPolicy" call.
  3007. // Exactly one of *Policy or error will be non-nil. Any non-2xx status
  3008. // code is an error. Response headers are in either
  3009. // *Policy.ServerResponse.Header or (if a response was returned at all)
  3010. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  3011. // check whether the returned error was because http.StatusNotModified
  3012. // was returned.
  3013. func (c *ProjectsSubscriptionsGetIamPolicyCall) Do(opts ...googleapi.CallOption) (*Policy, error) {
  3014. gensupport.SetOptions(c.urlParams_, opts...)
  3015. res, err := c.doRequest("json")
  3016. if res != nil && res.StatusCode == http.StatusNotModified {
  3017. if res.Body != nil {
  3018. res.Body.Close()
  3019. }
  3020. return nil, &googleapi.Error{
  3021. Code: res.StatusCode,
  3022. Header: res.Header,
  3023. }
  3024. }
  3025. if err != nil {
  3026. return nil, err
  3027. }
  3028. defer googleapi.CloseBody(res)
  3029. if err := googleapi.CheckResponse(res); err != nil {
  3030. return nil, err
  3031. }
  3032. ret := &Policy{
  3033. ServerResponse: googleapi.ServerResponse{
  3034. Header: res.Header,
  3035. HTTPStatusCode: res.StatusCode,
  3036. },
  3037. }
  3038. target := &ret
  3039. if err := gensupport.DecodeResponse(target, res); err != nil {
  3040. return nil, err
  3041. }
  3042. return ret, nil
  3043. // {
  3044. // "description": "Gets the access control policy for a resource.\nReturns an empty policy if the resource exists and does not have a policy\nset.",
  3045. // "flatPath": "v1/projects/{projectsId}/subscriptions/{subscriptionsId}:getIamPolicy",
  3046. // "httpMethod": "GET",
  3047. // "id": "pubsub.projects.subscriptions.getIamPolicy",
  3048. // "parameterOrder": [
  3049. // "resource"
  3050. // ],
  3051. // "parameters": {
  3052. // "resource": {
  3053. // "description": "REQUIRED: The resource for which the policy is being requested.\nSee the operation documentation for the appropriate value for this field.",
  3054. // "location": "path",
  3055. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  3056. // "required": true,
  3057. // "type": "string"
  3058. // }
  3059. // },
  3060. // "path": "v1/{+resource}:getIamPolicy",
  3061. // "response": {
  3062. // "$ref": "Policy"
  3063. // },
  3064. // "scopes": [
  3065. // "https://www.googleapis.com/auth/cloud-platform",
  3066. // "https://www.googleapis.com/auth/pubsub"
  3067. // ]
  3068. // }
  3069. }
  3070. // method id "pubsub.projects.subscriptions.list":
  3071. type ProjectsSubscriptionsListCall struct {
  3072. s *Service
  3073. project string
  3074. urlParams_ gensupport.URLParams
  3075. ifNoneMatch_ string
  3076. ctx_ context.Context
  3077. header_ http.Header
  3078. }
  3079. // List: Lists matching subscriptions.
  3080. func (r *ProjectsSubscriptionsService) List(project string) *ProjectsSubscriptionsListCall {
  3081. c := &ProjectsSubscriptionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3082. c.project = project
  3083. return c
  3084. }
  3085. // PageSize sets the optional parameter "pageSize": Maximum number of
  3086. // subscriptions to return.
  3087. func (c *ProjectsSubscriptionsListCall) PageSize(pageSize int64) *ProjectsSubscriptionsListCall {
  3088. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  3089. return c
  3090. }
  3091. // PageToken sets the optional parameter "pageToken": The value returned
  3092. // by the last `ListSubscriptionsResponse`; indicates that
  3093. // this is a continuation of a prior `ListSubscriptions` call, and that
  3094. // the
  3095. // system should return the next page of data.
  3096. func (c *ProjectsSubscriptionsListCall) PageToken(pageToken string) *ProjectsSubscriptionsListCall {
  3097. c.urlParams_.Set("pageToken", pageToken)
  3098. return c
  3099. }
  3100. // Fields allows partial responses to be retrieved. See
  3101. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3102. // for more information.
  3103. func (c *ProjectsSubscriptionsListCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsListCall {
  3104. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3105. return c
  3106. }
  3107. // IfNoneMatch sets the optional parameter which makes the operation
  3108. // fail if the object's ETag matches the given value. This is useful for
  3109. // getting updates only after the object has changed since the last
  3110. // request. Use googleapi.IsNotModified to check whether the response
  3111. // error from Do is the result of In-None-Match.
  3112. func (c *ProjectsSubscriptionsListCall) IfNoneMatch(entityTag string) *ProjectsSubscriptionsListCall {
  3113. c.ifNoneMatch_ = entityTag
  3114. return c
  3115. }
  3116. // Context sets the context to be used in this call's Do method. Any
  3117. // pending HTTP request will be aborted if the provided context is
  3118. // canceled.
  3119. func (c *ProjectsSubscriptionsListCall) Context(ctx context.Context) *ProjectsSubscriptionsListCall {
  3120. c.ctx_ = ctx
  3121. return c
  3122. }
  3123. // Header returns an http.Header that can be modified by the caller to
  3124. // add HTTP headers to the request.
  3125. func (c *ProjectsSubscriptionsListCall) Header() http.Header {
  3126. if c.header_ == nil {
  3127. c.header_ = make(http.Header)
  3128. }
  3129. return c.header_
  3130. }
  3131. func (c *ProjectsSubscriptionsListCall) doRequest(alt string) (*http.Response, error) {
  3132. reqHeaders := make(http.Header)
  3133. for k, v := range c.header_ {
  3134. reqHeaders[k] = v
  3135. }
  3136. reqHeaders.Set("User-Agent", c.s.userAgent())
  3137. if c.ifNoneMatch_ != "" {
  3138. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  3139. }
  3140. var body io.Reader = nil
  3141. c.urlParams_.Set("alt", alt)
  3142. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+project}/subscriptions")
  3143. urls += "?" + c.urlParams_.Encode()
  3144. req, _ := http.NewRequest("GET", urls, body)
  3145. req.Header = reqHeaders
  3146. googleapi.Expand(req.URL, map[string]string{
  3147. "project": c.project,
  3148. })
  3149. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3150. }
  3151. // Do executes the "pubsub.projects.subscriptions.list" call.
  3152. // Exactly one of *ListSubscriptionsResponse or error will be non-nil.
  3153. // Any non-2xx status code is an error. Response headers are in either
  3154. // *ListSubscriptionsResponse.ServerResponse.Header or (if a response
  3155. // was returned at all) in error.(*googleapi.Error).Header. Use
  3156. // googleapi.IsNotModified to check whether the returned error was
  3157. // because http.StatusNotModified was returned.
  3158. func (c *ProjectsSubscriptionsListCall) Do(opts ...googleapi.CallOption) (*ListSubscriptionsResponse, error) {
  3159. gensupport.SetOptions(c.urlParams_, opts...)
  3160. res, err := c.doRequest("json")
  3161. if res != nil && res.StatusCode == http.StatusNotModified {
  3162. if res.Body != nil {
  3163. res.Body.Close()
  3164. }
  3165. return nil, &googleapi.Error{
  3166. Code: res.StatusCode,
  3167. Header: res.Header,
  3168. }
  3169. }
  3170. if err != nil {
  3171. return nil, err
  3172. }
  3173. defer googleapi.CloseBody(res)
  3174. if err := googleapi.CheckResponse(res); err != nil {
  3175. return nil, err
  3176. }
  3177. ret := &ListSubscriptionsResponse{
  3178. ServerResponse: googleapi.ServerResponse{
  3179. Header: res.Header,
  3180. HTTPStatusCode: res.StatusCode,
  3181. },
  3182. }
  3183. target := &ret
  3184. if err := gensupport.DecodeResponse(target, res); err != nil {
  3185. return nil, err
  3186. }
  3187. return ret, nil
  3188. // {
  3189. // "description": "Lists matching subscriptions.",
  3190. // "flatPath": "v1/projects/{projectsId}/subscriptions",
  3191. // "httpMethod": "GET",
  3192. // "id": "pubsub.projects.subscriptions.list",
  3193. // "parameterOrder": [
  3194. // "project"
  3195. // ],
  3196. // "parameters": {
  3197. // "pageSize": {
  3198. // "description": "Maximum number of subscriptions to return.",
  3199. // "format": "int32",
  3200. // "location": "query",
  3201. // "type": "integer"
  3202. // },
  3203. // "pageToken": {
  3204. // "description": "The value returned by the last `ListSubscriptionsResponse`; indicates that\nthis is a continuation of a prior `ListSubscriptions` call, and that the\nsystem should return the next page of data.",
  3205. // "location": "query",
  3206. // "type": "string"
  3207. // },
  3208. // "project": {
  3209. // "description": "The name of the cloud project that subscriptions belong to.\nFormat is `projects/{project}`.",
  3210. // "location": "path",
  3211. // "pattern": "^projects/[^/]+$",
  3212. // "required": true,
  3213. // "type": "string"
  3214. // }
  3215. // },
  3216. // "path": "v1/{+project}/subscriptions",
  3217. // "response": {
  3218. // "$ref": "ListSubscriptionsResponse"
  3219. // },
  3220. // "scopes": [
  3221. // "https://www.googleapis.com/auth/cloud-platform",
  3222. // "https://www.googleapis.com/auth/pubsub"
  3223. // ]
  3224. // }
  3225. }
  3226. // Pages invokes f for each page of results.
  3227. // A non-nil error returned from f will halt the iteration.
  3228. // The provided context supersedes any context provided to the Context method.
  3229. func (c *ProjectsSubscriptionsListCall) Pages(ctx context.Context, f func(*ListSubscriptionsResponse) error) error {
  3230. c.ctx_ = ctx
  3231. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  3232. for {
  3233. x, err := c.Do()
  3234. if err != nil {
  3235. return err
  3236. }
  3237. if err := f(x); err != nil {
  3238. return err
  3239. }
  3240. if x.NextPageToken == "" {
  3241. return nil
  3242. }
  3243. c.PageToken(x.NextPageToken)
  3244. }
  3245. }
  3246. // method id "pubsub.projects.subscriptions.modifyAckDeadline":
  3247. type ProjectsSubscriptionsModifyAckDeadlineCall struct {
  3248. s *Service
  3249. subscription string
  3250. modifyackdeadlinerequest *ModifyAckDeadlineRequest
  3251. urlParams_ gensupport.URLParams
  3252. ctx_ context.Context
  3253. header_ http.Header
  3254. }
  3255. // ModifyAckDeadline: Modifies the ack deadline for a specific message.
  3256. // This method is useful
  3257. // to indicate that more time is needed to process a message by
  3258. // the
  3259. // subscriber, or to make the message available for redelivery if
  3260. // the
  3261. // processing was interrupted. Note that this does not modify
  3262. // the
  3263. // subscription-level `ackDeadlineSeconds` used for subsequent messages.
  3264. func (r *ProjectsSubscriptionsService) ModifyAckDeadline(subscription string, modifyackdeadlinerequest *ModifyAckDeadlineRequest) *ProjectsSubscriptionsModifyAckDeadlineCall {
  3265. c := &ProjectsSubscriptionsModifyAckDeadlineCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3266. c.subscription = subscription
  3267. c.modifyackdeadlinerequest = modifyackdeadlinerequest
  3268. return c
  3269. }
  3270. // Fields allows partial responses to be retrieved. See
  3271. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3272. // for more information.
  3273. func (c *ProjectsSubscriptionsModifyAckDeadlineCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsModifyAckDeadlineCall {
  3274. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3275. return c
  3276. }
  3277. // Context sets the context to be used in this call's Do method. Any
  3278. // pending HTTP request will be aborted if the provided context is
  3279. // canceled.
  3280. func (c *ProjectsSubscriptionsModifyAckDeadlineCall) Context(ctx context.Context) *ProjectsSubscriptionsModifyAckDeadlineCall {
  3281. c.ctx_ = ctx
  3282. return c
  3283. }
  3284. // Header returns an http.Header that can be modified by the caller to
  3285. // add HTTP headers to the request.
  3286. func (c *ProjectsSubscriptionsModifyAckDeadlineCall) Header() http.Header {
  3287. if c.header_ == nil {
  3288. c.header_ = make(http.Header)
  3289. }
  3290. return c.header_
  3291. }
  3292. func (c *ProjectsSubscriptionsModifyAckDeadlineCall) doRequest(alt string) (*http.Response, error) {
  3293. reqHeaders := make(http.Header)
  3294. for k, v := range c.header_ {
  3295. reqHeaders[k] = v
  3296. }
  3297. reqHeaders.Set("User-Agent", c.s.userAgent())
  3298. var body io.Reader = nil
  3299. body, err := googleapi.WithoutDataWrapper.JSONReader(c.modifyackdeadlinerequest)
  3300. if err != nil {
  3301. return nil, err
  3302. }
  3303. reqHeaders.Set("Content-Type", "application/json")
  3304. c.urlParams_.Set("alt", alt)
  3305. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+subscription}:modifyAckDeadline")
  3306. urls += "?" + c.urlParams_.Encode()
  3307. req, _ := http.NewRequest("POST", urls, body)
  3308. req.Header = reqHeaders
  3309. googleapi.Expand(req.URL, map[string]string{
  3310. "subscription": c.subscription,
  3311. })
  3312. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3313. }
  3314. // Do executes the "pubsub.projects.subscriptions.modifyAckDeadline" call.
  3315. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  3316. // code is an error. Response headers are in either
  3317. // *Empty.ServerResponse.Header or (if a response was returned at all)
  3318. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  3319. // check whether the returned error was because http.StatusNotModified
  3320. // was returned.
  3321. func (c *ProjectsSubscriptionsModifyAckDeadlineCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  3322. gensupport.SetOptions(c.urlParams_, opts...)
  3323. res, err := c.doRequest("json")
  3324. if res != nil && res.StatusCode == http.StatusNotModified {
  3325. if res.Body != nil {
  3326. res.Body.Close()
  3327. }
  3328. return nil, &googleapi.Error{
  3329. Code: res.StatusCode,
  3330. Header: res.Header,
  3331. }
  3332. }
  3333. if err != nil {
  3334. return nil, err
  3335. }
  3336. defer googleapi.CloseBody(res)
  3337. if err := googleapi.CheckResponse(res); err != nil {
  3338. return nil, err
  3339. }
  3340. ret := &Empty{
  3341. ServerResponse: googleapi.ServerResponse{
  3342. Header: res.Header,
  3343. HTTPStatusCode: res.StatusCode,
  3344. },
  3345. }
  3346. target := &ret
  3347. if err := gensupport.DecodeResponse(target, res); err != nil {
  3348. return nil, err
  3349. }
  3350. return ret, nil
  3351. // {
  3352. // "description": "Modifies the ack deadline for a specific message. This method is useful\nto indicate that more time is needed to process a message by the\nsubscriber, or to make the message available for redelivery if the\nprocessing was interrupted. Note that this does not modify the\nsubscription-level `ackDeadlineSeconds` used for subsequent messages.",
  3353. // "flatPath": "v1/projects/{projectsId}/subscriptions/{subscriptionsId}:modifyAckDeadline",
  3354. // "httpMethod": "POST",
  3355. // "id": "pubsub.projects.subscriptions.modifyAckDeadline",
  3356. // "parameterOrder": [
  3357. // "subscription"
  3358. // ],
  3359. // "parameters": {
  3360. // "subscription": {
  3361. // "description": "The name of the subscription.\nFormat is `projects/{project}/subscriptions/{sub}`.",
  3362. // "location": "path",
  3363. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  3364. // "required": true,
  3365. // "type": "string"
  3366. // }
  3367. // },
  3368. // "path": "v1/{+subscription}:modifyAckDeadline",
  3369. // "request": {
  3370. // "$ref": "ModifyAckDeadlineRequest"
  3371. // },
  3372. // "response": {
  3373. // "$ref": "Empty"
  3374. // },
  3375. // "scopes": [
  3376. // "https://www.googleapis.com/auth/cloud-platform",
  3377. // "https://www.googleapis.com/auth/pubsub"
  3378. // ]
  3379. // }
  3380. }
  3381. // method id "pubsub.projects.subscriptions.modifyPushConfig":
  3382. type ProjectsSubscriptionsModifyPushConfigCall struct {
  3383. s *Service
  3384. subscription string
  3385. modifypushconfigrequest *ModifyPushConfigRequest
  3386. urlParams_ gensupport.URLParams
  3387. ctx_ context.Context
  3388. header_ http.Header
  3389. }
  3390. // ModifyPushConfig: Modifies the `PushConfig` for a specified
  3391. // subscription.
  3392. //
  3393. // This may be used to change a push subscription to a pull one
  3394. // (signified by
  3395. // an empty `PushConfig`) or vice versa, or change the endpoint URL and
  3396. // other
  3397. // attributes of a push subscription. Messages will accumulate for
  3398. // delivery
  3399. // continuously through the call regardless of changes to the
  3400. // `PushConfig`.
  3401. func (r *ProjectsSubscriptionsService) ModifyPushConfig(subscription string, modifypushconfigrequest *ModifyPushConfigRequest) *ProjectsSubscriptionsModifyPushConfigCall {
  3402. c := &ProjectsSubscriptionsModifyPushConfigCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3403. c.subscription = subscription
  3404. c.modifypushconfigrequest = modifypushconfigrequest
  3405. return c
  3406. }
  3407. // Fields allows partial responses to be retrieved. See
  3408. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3409. // for more information.
  3410. func (c *ProjectsSubscriptionsModifyPushConfigCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsModifyPushConfigCall {
  3411. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3412. return c
  3413. }
  3414. // Context sets the context to be used in this call's Do method. Any
  3415. // pending HTTP request will be aborted if the provided context is
  3416. // canceled.
  3417. func (c *ProjectsSubscriptionsModifyPushConfigCall) Context(ctx context.Context) *ProjectsSubscriptionsModifyPushConfigCall {
  3418. c.ctx_ = ctx
  3419. return c
  3420. }
  3421. // Header returns an http.Header that can be modified by the caller to
  3422. // add HTTP headers to the request.
  3423. func (c *ProjectsSubscriptionsModifyPushConfigCall) Header() http.Header {
  3424. if c.header_ == nil {
  3425. c.header_ = make(http.Header)
  3426. }
  3427. return c.header_
  3428. }
  3429. func (c *ProjectsSubscriptionsModifyPushConfigCall) doRequest(alt string) (*http.Response, error) {
  3430. reqHeaders := make(http.Header)
  3431. for k, v := range c.header_ {
  3432. reqHeaders[k] = v
  3433. }
  3434. reqHeaders.Set("User-Agent", c.s.userAgent())
  3435. var body io.Reader = nil
  3436. body, err := googleapi.WithoutDataWrapper.JSONReader(c.modifypushconfigrequest)
  3437. if err != nil {
  3438. return nil, err
  3439. }
  3440. reqHeaders.Set("Content-Type", "application/json")
  3441. c.urlParams_.Set("alt", alt)
  3442. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+subscription}:modifyPushConfig")
  3443. urls += "?" + c.urlParams_.Encode()
  3444. req, _ := http.NewRequest("POST", urls, body)
  3445. req.Header = reqHeaders
  3446. googleapi.Expand(req.URL, map[string]string{
  3447. "subscription": c.subscription,
  3448. })
  3449. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3450. }
  3451. // Do executes the "pubsub.projects.subscriptions.modifyPushConfig" call.
  3452. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  3453. // code is an error. Response headers are in either
  3454. // *Empty.ServerResponse.Header or (if a response was returned at all)
  3455. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  3456. // check whether the returned error was because http.StatusNotModified
  3457. // was returned.
  3458. func (c *ProjectsSubscriptionsModifyPushConfigCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  3459. gensupport.SetOptions(c.urlParams_, opts...)
  3460. res, err := c.doRequest("json")
  3461. if res != nil && res.StatusCode == http.StatusNotModified {
  3462. if res.Body != nil {
  3463. res.Body.Close()
  3464. }
  3465. return nil, &googleapi.Error{
  3466. Code: res.StatusCode,
  3467. Header: res.Header,
  3468. }
  3469. }
  3470. if err != nil {
  3471. return nil, err
  3472. }
  3473. defer googleapi.CloseBody(res)
  3474. if err := googleapi.CheckResponse(res); err != nil {
  3475. return nil, err
  3476. }
  3477. ret := &Empty{
  3478. ServerResponse: googleapi.ServerResponse{
  3479. Header: res.Header,
  3480. HTTPStatusCode: res.StatusCode,
  3481. },
  3482. }
  3483. target := &ret
  3484. if err := gensupport.DecodeResponse(target, res); err != nil {
  3485. return nil, err
  3486. }
  3487. return ret, nil
  3488. // {
  3489. // "description": "Modifies the `PushConfig` for a specified subscription.\n\nThis may be used to change a push subscription to a pull one (signified by\nan empty `PushConfig`) or vice versa, or change the endpoint URL and other\nattributes of a push subscription. Messages will accumulate for delivery\ncontinuously through the call regardless of changes to the `PushConfig`.",
  3490. // "flatPath": "v1/projects/{projectsId}/subscriptions/{subscriptionsId}:modifyPushConfig",
  3491. // "httpMethod": "POST",
  3492. // "id": "pubsub.projects.subscriptions.modifyPushConfig",
  3493. // "parameterOrder": [
  3494. // "subscription"
  3495. // ],
  3496. // "parameters": {
  3497. // "subscription": {
  3498. // "description": "The name of the subscription.\nFormat is `projects/{project}/subscriptions/{sub}`.",
  3499. // "location": "path",
  3500. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  3501. // "required": true,
  3502. // "type": "string"
  3503. // }
  3504. // },
  3505. // "path": "v1/{+subscription}:modifyPushConfig",
  3506. // "request": {
  3507. // "$ref": "ModifyPushConfigRequest"
  3508. // },
  3509. // "response": {
  3510. // "$ref": "Empty"
  3511. // },
  3512. // "scopes": [
  3513. // "https://www.googleapis.com/auth/cloud-platform",
  3514. // "https://www.googleapis.com/auth/pubsub"
  3515. // ]
  3516. // }
  3517. }
  3518. // method id "pubsub.projects.subscriptions.patch":
  3519. type ProjectsSubscriptionsPatchCall struct {
  3520. s *Service
  3521. name string
  3522. updatesubscriptionrequest *UpdateSubscriptionRequest
  3523. urlParams_ gensupport.URLParams
  3524. ctx_ context.Context
  3525. header_ http.Header
  3526. }
  3527. // Patch: Updates an existing subscription. Note that certain properties
  3528. // of a
  3529. // subscription, such as its topic, are not modifiable.
  3530. func (r *ProjectsSubscriptionsService) Patch(name string, updatesubscriptionrequest *UpdateSubscriptionRequest) *ProjectsSubscriptionsPatchCall {
  3531. c := &ProjectsSubscriptionsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3532. c.name = name
  3533. c.updatesubscriptionrequest = updatesubscriptionrequest
  3534. return c
  3535. }
  3536. // Fields allows partial responses to be retrieved. See
  3537. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3538. // for more information.
  3539. func (c *ProjectsSubscriptionsPatchCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsPatchCall {
  3540. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3541. return c
  3542. }
  3543. // Context sets the context to be used in this call's Do method. Any
  3544. // pending HTTP request will be aborted if the provided context is
  3545. // canceled.
  3546. func (c *ProjectsSubscriptionsPatchCall) Context(ctx context.Context) *ProjectsSubscriptionsPatchCall {
  3547. c.ctx_ = ctx
  3548. return c
  3549. }
  3550. // Header returns an http.Header that can be modified by the caller to
  3551. // add HTTP headers to the request.
  3552. func (c *ProjectsSubscriptionsPatchCall) Header() http.Header {
  3553. if c.header_ == nil {
  3554. c.header_ = make(http.Header)
  3555. }
  3556. return c.header_
  3557. }
  3558. func (c *ProjectsSubscriptionsPatchCall) doRequest(alt string) (*http.Response, error) {
  3559. reqHeaders := make(http.Header)
  3560. for k, v := range c.header_ {
  3561. reqHeaders[k] = v
  3562. }
  3563. reqHeaders.Set("User-Agent", c.s.userAgent())
  3564. var body io.Reader = nil
  3565. body, err := googleapi.WithoutDataWrapper.JSONReader(c.updatesubscriptionrequest)
  3566. if err != nil {
  3567. return nil, err
  3568. }
  3569. reqHeaders.Set("Content-Type", "application/json")
  3570. c.urlParams_.Set("alt", alt)
  3571. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  3572. urls += "?" + c.urlParams_.Encode()
  3573. req, _ := http.NewRequest("PATCH", urls, body)
  3574. req.Header = reqHeaders
  3575. googleapi.Expand(req.URL, map[string]string{
  3576. "name": c.name,
  3577. })
  3578. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3579. }
  3580. // Do executes the "pubsub.projects.subscriptions.patch" call.
  3581. // Exactly one of *Subscription or error will be non-nil. Any non-2xx
  3582. // status code is an error. Response headers are in either
  3583. // *Subscription.ServerResponse.Header or (if a response was returned at
  3584. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  3585. // to check whether the returned error was because
  3586. // http.StatusNotModified was returned.
  3587. func (c *ProjectsSubscriptionsPatchCall) Do(opts ...googleapi.CallOption) (*Subscription, error) {
  3588. gensupport.SetOptions(c.urlParams_, opts...)
  3589. res, err := c.doRequest("json")
  3590. if res != nil && res.StatusCode == http.StatusNotModified {
  3591. if res.Body != nil {
  3592. res.Body.Close()
  3593. }
  3594. return nil, &googleapi.Error{
  3595. Code: res.StatusCode,
  3596. Header: res.Header,
  3597. }
  3598. }
  3599. if err != nil {
  3600. return nil, err
  3601. }
  3602. defer googleapi.CloseBody(res)
  3603. if err := googleapi.CheckResponse(res); err != nil {
  3604. return nil, err
  3605. }
  3606. ret := &Subscription{
  3607. ServerResponse: googleapi.ServerResponse{
  3608. Header: res.Header,
  3609. HTTPStatusCode: res.StatusCode,
  3610. },
  3611. }
  3612. target := &ret
  3613. if err := gensupport.DecodeResponse(target, res); err != nil {
  3614. return nil, err
  3615. }
  3616. return ret, nil
  3617. // {
  3618. // "description": "Updates an existing subscription. Note that certain properties of a\nsubscription, such as its topic, are not modifiable.",
  3619. // "flatPath": "v1/projects/{projectsId}/subscriptions/{subscriptionsId}",
  3620. // "httpMethod": "PATCH",
  3621. // "id": "pubsub.projects.subscriptions.patch",
  3622. // "parameterOrder": [
  3623. // "name"
  3624. // ],
  3625. // "parameters": {
  3626. // "name": {
  3627. // "description": "The name of the subscription. It must have the format\n`\"projects/{project}/subscriptions/{subscription}\"`. `{subscription}` must\nstart with a letter, and contain only letters (`[A-Za-z]`), numbers\n(`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes (`~`),\nplus (`+`) or percent signs (`%`). It must be between 3 and 255 characters\nin length, and it must not start with `\"goog\"`.",
  3628. // "location": "path",
  3629. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  3630. // "required": true,
  3631. // "type": "string"
  3632. // }
  3633. // },
  3634. // "path": "v1/{+name}",
  3635. // "request": {
  3636. // "$ref": "UpdateSubscriptionRequest"
  3637. // },
  3638. // "response": {
  3639. // "$ref": "Subscription"
  3640. // },
  3641. // "scopes": [
  3642. // "https://www.googleapis.com/auth/cloud-platform",
  3643. // "https://www.googleapis.com/auth/pubsub"
  3644. // ]
  3645. // }
  3646. }
  3647. // method id "pubsub.projects.subscriptions.pull":
  3648. type ProjectsSubscriptionsPullCall struct {
  3649. s *Service
  3650. subscription string
  3651. pullrequest *PullRequest
  3652. urlParams_ gensupport.URLParams
  3653. ctx_ context.Context
  3654. header_ http.Header
  3655. }
  3656. // Pull: Pulls messages from the server. Returns an empty list if there
  3657. // are no
  3658. // messages available in the backlog. The server may return
  3659. // `UNAVAILABLE` if
  3660. // there are too many concurrent pull requests pending for the
  3661. // given
  3662. // subscription.
  3663. func (r *ProjectsSubscriptionsService) Pull(subscription string, pullrequest *PullRequest) *ProjectsSubscriptionsPullCall {
  3664. c := &ProjectsSubscriptionsPullCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3665. c.subscription = subscription
  3666. c.pullrequest = pullrequest
  3667. return c
  3668. }
  3669. // Fields allows partial responses to be retrieved. See
  3670. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3671. // for more information.
  3672. func (c *ProjectsSubscriptionsPullCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsPullCall {
  3673. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3674. return c
  3675. }
  3676. // Context sets the context to be used in this call's Do method. Any
  3677. // pending HTTP request will be aborted if the provided context is
  3678. // canceled.
  3679. func (c *ProjectsSubscriptionsPullCall) Context(ctx context.Context) *ProjectsSubscriptionsPullCall {
  3680. c.ctx_ = ctx
  3681. return c
  3682. }
  3683. // Header returns an http.Header that can be modified by the caller to
  3684. // add HTTP headers to the request.
  3685. func (c *ProjectsSubscriptionsPullCall) Header() http.Header {
  3686. if c.header_ == nil {
  3687. c.header_ = make(http.Header)
  3688. }
  3689. return c.header_
  3690. }
  3691. func (c *ProjectsSubscriptionsPullCall) doRequest(alt string) (*http.Response, error) {
  3692. reqHeaders := make(http.Header)
  3693. for k, v := range c.header_ {
  3694. reqHeaders[k] = v
  3695. }
  3696. reqHeaders.Set("User-Agent", c.s.userAgent())
  3697. var body io.Reader = nil
  3698. body, err := googleapi.WithoutDataWrapper.JSONReader(c.pullrequest)
  3699. if err != nil {
  3700. return nil, err
  3701. }
  3702. reqHeaders.Set("Content-Type", "application/json")
  3703. c.urlParams_.Set("alt", alt)
  3704. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+subscription}:pull")
  3705. urls += "?" + c.urlParams_.Encode()
  3706. req, _ := http.NewRequest("POST", urls, body)
  3707. req.Header = reqHeaders
  3708. googleapi.Expand(req.URL, map[string]string{
  3709. "subscription": c.subscription,
  3710. })
  3711. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3712. }
  3713. // Do executes the "pubsub.projects.subscriptions.pull" call.
  3714. // Exactly one of *PullResponse or error will be non-nil. Any non-2xx
  3715. // status code is an error. Response headers are in either
  3716. // *PullResponse.ServerResponse.Header or (if a response was returned at
  3717. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  3718. // to check whether the returned error was because
  3719. // http.StatusNotModified was returned.
  3720. func (c *ProjectsSubscriptionsPullCall) Do(opts ...googleapi.CallOption) (*PullResponse, error) {
  3721. gensupport.SetOptions(c.urlParams_, opts...)
  3722. res, err := c.doRequest("json")
  3723. if res != nil && res.StatusCode == http.StatusNotModified {
  3724. if res.Body != nil {
  3725. res.Body.Close()
  3726. }
  3727. return nil, &googleapi.Error{
  3728. Code: res.StatusCode,
  3729. Header: res.Header,
  3730. }
  3731. }
  3732. if err != nil {
  3733. return nil, err
  3734. }
  3735. defer googleapi.CloseBody(res)
  3736. if err := googleapi.CheckResponse(res); err != nil {
  3737. return nil, err
  3738. }
  3739. ret := &PullResponse{
  3740. ServerResponse: googleapi.ServerResponse{
  3741. Header: res.Header,
  3742. HTTPStatusCode: res.StatusCode,
  3743. },
  3744. }
  3745. target := &ret
  3746. if err := gensupport.DecodeResponse(target, res); err != nil {
  3747. return nil, err
  3748. }
  3749. return ret, nil
  3750. // {
  3751. // "description": "Pulls messages from the server. Returns an empty list if there are no\nmessages available in the backlog. The server may return `UNAVAILABLE` if\nthere are too many concurrent pull requests pending for the given\nsubscription.",
  3752. // "flatPath": "v1/projects/{projectsId}/subscriptions/{subscriptionsId}:pull",
  3753. // "httpMethod": "POST",
  3754. // "id": "pubsub.projects.subscriptions.pull",
  3755. // "parameterOrder": [
  3756. // "subscription"
  3757. // ],
  3758. // "parameters": {
  3759. // "subscription": {
  3760. // "description": "The subscription from which messages should be pulled.\nFormat is `projects/{project}/subscriptions/{sub}`.",
  3761. // "location": "path",
  3762. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  3763. // "required": true,
  3764. // "type": "string"
  3765. // }
  3766. // },
  3767. // "path": "v1/{+subscription}:pull",
  3768. // "request": {
  3769. // "$ref": "PullRequest"
  3770. // },
  3771. // "response": {
  3772. // "$ref": "PullResponse"
  3773. // },
  3774. // "scopes": [
  3775. // "https://www.googleapis.com/auth/cloud-platform",
  3776. // "https://www.googleapis.com/auth/pubsub"
  3777. // ]
  3778. // }
  3779. }
  3780. // method id "pubsub.projects.subscriptions.seek":
  3781. type ProjectsSubscriptionsSeekCall struct {
  3782. s *Service
  3783. subscription string
  3784. seekrequest *SeekRequest
  3785. urlParams_ gensupport.URLParams
  3786. ctx_ context.Context
  3787. header_ http.Header
  3788. }
  3789. // Seek: Seeks an existing subscription to a point in time or to a given
  3790. // snapshot,
  3791. // whichever is provided in the request.<br><br>
  3792. // <b>ALPHA:</b> This feature is part of an alpha release. This API
  3793. // might be
  3794. // changed in backward-incompatible ways and is not recommended for
  3795. // production
  3796. // use. It is not subject to any SLA or deprecation policy.
  3797. func (r *ProjectsSubscriptionsService) Seek(subscription string, seekrequest *SeekRequest) *ProjectsSubscriptionsSeekCall {
  3798. c := &ProjectsSubscriptionsSeekCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3799. c.subscription = subscription
  3800. c.seekrequest = seekrequest
  3801. return c
  3802. }
  3803. // Fields allows partial responses to be retrieved. See
  3804. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3805. // for more information.
  3806. func (c *ProjectsSubscriptionsSeekCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsSeekCall {
  3807. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3808. return c
  3809. }
  3810. // Context sets the context to be used in this call's Do method. Any
  3811. // pending HTTP request will be aborted if the provided context is
  3812. // canceled.
  3813. func (c *ProjectsSubscriptionsSeekCall) Context(ctx context.Context) *ProjectsSubscriptionsSeekCall {
  3814. c.ctx_ = ctx
  3815. return c
  3816. }
  3817. // Header returns an http.Header that can be modified by the caller to
  3818. // add HTTP headers to the request.
  3819. func (c *ProjectsSubscriptionsSeekCall) Header() http.Header {
  3820. if c.header_ == nil {
  3821. c.header_ = make(http.Header)
  3822. }
  3823. return c.header_
  3824. }
  3825. func (c *ProjectsSubscriptionsSeekCall) doRequest(alt string) (*http.Response, error) {
  3826. reqHeaders := make(http.Header)
  3827. for k, v := range c.header_ {
  3828. reqHeaders[k] = v
  3829. }
  3830. reqHeaders.Set("User-Agent", c.s.userAgent())
  3831. var body io.Reader = nil
  3832. body, err := googleapi.WithoutDataWrapper.JSONReader(c.seekrequest)
  3833. if err != nil {
  3834. return nil, err
  3835. }
  3836. reqHeaders.Set("Content-Type", "application/json")
  3837. c.urlParams_.Set("alt", alt)
  3838. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+subscription}:seek")
  3839. urls += "?" + c.urlParams_.Encode()
  3840. req, _ := http.NewRequest("POST", urls, body)
  3841. req.Header = reqHeaders
  3842. googleapi.Expand(req.URL, map[string]string{
  3843. "subscription": c.subscription,
  3844. })
  3845. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3846. }
  3847. // Do executes the "pubsub.projects.subscriptions.seek" call.
  3848. // Exactly one of *SeekResponse or error will be non-nil. Any non-2xx
  3849. // status code is an error. Response headers are in either
  3850. // *SeekResponse.ServerResponse.Header or (if a response was returned at
  3851. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  3852. // to check whether the returned error was because
  3853. // http.StatusNotModified was returned.
  3854. func (c *ProjectsSubscriptionsSeekCall) Do(opts ...googleapi.CallOption) (*SeekResponse, error) {
  3855. gensupport.SetOptions(c.urlParams_, opts...)
  3856. res, err := c.doRequest("json")
  3857. if res != nil && res.StatusCode == http.StatusNotModified {
  3858. if res.Body != nil {
  3859. res.Body.Close()
  3860. }
  3861. return nil, &googleapi.Error{
  3862. Code: res.StatusCode,
  3863. Header: res.Header,
  3864. }
  3865. }
  3866. if err != nil {
  3867. return nil, err
  3868. }
  3869. defer googleapi.CloseBody(res)
  3870. if err := googleapi.CheckResponse(res); err != nil {
  3871. return nil, err
  3872. }
  3873. ret := &SeekResponse{
  3874. ServerResponse: googleapi.ServerResponse{
  3875. Header: res.Header,
  3876. HTTPStatusCode: res.StatusCode,
  3877. },
  3878. }
  3879. target := &ret
  3880. if err := gensupport.DecodeResponse(target, res); err != nil {
  3881. return nil, err
  3882. }
  3883. return ret, nil
  3884. // {
  3885. // "description": "Seeks an existing subscription to a point in time or to a given snapshot,\nwhichever is provided in the request.\u003cbr\u003e\u003cbr\u003e\n\u003cb\u003eALPHA:\u003c/b\u003e This feature is part of an alpha release. This API might be\nchanged in backward-incompatible ways and is not recommended for production\nuse. It is not subject to any SLA or deprecation policy.",
  3886. // "flatPath": "v1/projects/{projectsId}/subscriptions/{subscriptionsId}:seek",
  3887. // "httpMethod": "POST",
  3888. // "id": "pubsub.projects.subscriptions.seek",
  3889. // "parameterOrder": [
  3890. // "subscription"
  3891. // ],
  3892. // "parameters": {
  3893. // "subscription": {
  3894. // "description": "The subscription to affect.",
  3895. // "location": "path",
  3896. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  3897. // "required": true,
  3898. // "type": "string"
  3899. // }
  3900. // },
  3901. // "path": "v1/{+subscription}:seek",
  3902. // "request": {
  3903. // "$ref": "SeekRequest"
  3904. // },
  3905. // "response": {
  3906. // "$ref": "SeekResponse"
  3907. // },
  3908. // "scopes": [
  3909. // "https://www.googleapis.com/auth/cloud-platform",
  3910. // "https://www.googleapis.com/auth/pubsub"
  3911. // ]
  3912. // }
  3913. }
  3914. // method id "pubsub.projects.subscriptions.setIamPolicy":
  3915. type ProjectsSubscriptionsSetIamPolicyCall struct {
  3916. s *Service
  3917. resource string
  3918. setiampolicyrequest *SetIamPolicyRequest
  3919. urlParams_ gensupport.URLParams
  3920. ctx_ context.Context
  3921. header_ http.Header
  3922. }
  3923. // SetIamPolicy: Sets the access control policy on the specified
  3924. // resource. Replaces any
  3925. // existing policy.
  3926. func (r *ProjectsSubscriptionsService) SetIamPolicy(resource string, setiampolicyrequest *SetIamPolicyRequest) *ProjectsSubscriptionsSetIamPolicyCall {
  3927. c := &ProjectsSubscriptionsSetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3928. c.resource = resource
  3929. c.setiampolicyrequest = setiampolicyrequest
  3930. return c
  3931. }
  3932. // Fields allows partial responses to be retrieved. See
  3933. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3934. // for more information.
  3935. func (c *ProjectsSubscriptionsSetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsSetIamPolicyCall {
  3936. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3937. return c
  3938. }
  3939. // Context sets the context to be used in this call's Do method. Any
  3940. // pending HTTP request will be aborted if the provided context is
  3941. // canceled.
  3942. func (c *ProjectsSubscriptionsSetIamPolicyCall) Context(ctx context.Context) *ProjectsSubscriptionsSetIamPolicyCall {
  3943. c.ctx_ = ctx
  3944. return c
  3945. }
  3946. // Header returns an http.Header that can be modified by the caller to
  3947. // add HTTP headers to the request.
  3948. func (c *ProjectsSubscriptionsSetIamPolicyCall) Header() http.Header {
  3949. if c.header_ == nil {
  3950. c.header_ = make(http.Header)
  3951. }
  3952. return c.header_
  3953. }
  3954. func (c *ProjectsSubscriptionsSetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  3955. reqHeaders := make(http.Header)
  3956. for k, v := range c.header_ {
  3957. reqHeaders[k] = v
  3958. }
  3959. reqHeaders.Set("User-Agent", c.s.userAgent())
  3960. var body io.Reader = nil
  3961. body, err := googleapi.WithoutDataWrapper.JSONReader(c.setiampolicyrequest)
  3962. if err != nil {
  3963. return nil, err
  3964. }
  3965. reqHeaders.Set("Content-Type", "application/json")
  3966. c.urlParams_.Set("alt", alt)
  3967. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+resource}:setIamPolicy")
  3968. urls += "?" + c.urlParams_.Encode()
  3969. req, _ := http.NewRequest("POST", urls, body)
  3970. req.Header = reqHeaders
  3971. googleapi.Expand(req.URL, map[string]string{
  3972. "resource": c.resource,
  3973. })
  3974. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3975. }
  3976. // Do executes the "pubsub.projects.subscriptions.setIamPolicy" call.
  3977. // Exactly one of *Policy or error will be non-nil. Any non-2xx status
  3978. // code is an error. Response headers are in either
  3979. // *Policy.ServerResponse.Header or (if a response was returned at all)
  3980. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  3981. // check whether the returned error was because http.StatusNotModified
  3982. // was returned.
  3983. func (c *ProjectsSubscriptionsSetIamPolicyCall) Do(opts ...googleapi.CallOption) (*Policy, error) {
  3984. gensupport.SetOptions(c.urlParams_, opts...)
  3985. res, err := c.doRequest("json")
  3986. if res != nil && res.StatusCode == http.StatusNotModified {
  3987. if res.Body != nil {
  3988. res.Body.Close()
  3989. }
  3990. return nil, &googleapi.Error{
  3991. Code: res.StatusCode,
  3992. Header: res.Header,
  3993. }
  3994. }
  3995. if err != nil {
  3996. return nil, err
  3997. }
  3998. defer googleapi.CloseBody(res)
  3999. if err := googleapi.CheckResponse(res); err != nil {
  4000. return nil, err
  4001. }
  4002. ret := &Policy{
  4003. ServerResponse: googleapi.ServerResponse{
  4004. Header: res.Header,
  4005. HTTPStatusCode: res.StatusCode,
  4006. },
  4007. }
  4008. target := &ret
  4009. if err := gensupport.DecodeResponse(target, res); err != nil {
  4010. return nil, err
  4011. }
  4012. return ret, nil
  4013. // {
  4014. // "description": "Sets the access control policy on the specified resource. Replaces any\nexisting policy.",
  4015. // "flatPath": "v1/projects/{projectsId}/subscriptions/{subscriptionsId}:setIamPolicy",
  4016. // "httpMethod": "POST",
  4017. // "id": "pubsub.projects.subscriptions.setIamPolicy",
  4018. // "parameterOrder": [
  4019. // "resource"
  4020. // ],
  4021. // "parameters": {
  4022. // "resource": {
  4023. // "description": "REQUIRED: The resource for which the policy is being specified.\nSee the operation documentation for the appropriate value for this field.",
  4024. // "location": "path",
  4025. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  4026. // "required": true,
  4027. // "type": "string"
  4028. // }
  4029. // },
  4030. // "path": "v1/{+resource}:setIamPolicy",
  4031. // "request": {
  4032. // "$ref": "SetIamPolicyRequest"
  4033. // },
  4034. // "response": {
  4035. // "$ref": "Policy"
  4036. // },
  4037. // "scopes": [
  4038. // "https://www.googleapis.com/auth/cloud-platform",
  4039. // "https://www.googleapis.com/auth/pubsub"
  4040. // ]
  4041. // }
  4042. }
  4043. // method id "pubsub.projects.subscriptions.testIamPermissions":
  4044. type ProjectsSubscriptionsTestIamPermissionsCall struct {
  4045. s *Service
  4046. resource string
  4047. testiampermissionsrequest *TestIamPermissionsRequest
  4048. urlParams_ gensupport.URLParams
  4049. ctx_ context.Context
  4050. header_ http.Header
  4051. }
  4052. // TestIamPermissions: Returns permissions that a caller has on the
  4053. // specified resource.
  4054. // If the resource does not exist, this will return an empty set
  4055. // of
  4056. // permissions, not a NOT_FOUND error.
  4057. //
  4058. // Note: This operation is designed to be used for building
  4059. // permission-aware
  4060. // UIs and command-line tools, not for authorization checking. This
  4061. // operation
  4062. // may "fail open" without warning.
  4063. func (r *ProjectsSubscriptionsService) TestIamPermissions(resource string, testiampermissionsrequest *TestIamPermissionsRequest) *ProjectsSubscriptionsTestIamPermissionsCall {
  4064. c := &ProjectsSubscriptionsTestIamPermissionsCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4065. c.resource = resource
  4066. c.testiampermissionsrequest = testiampermissionsrequest
  4067. return c
  4068. }
  4069. // Fields allows partial responses to be retrieved. See
  4070. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4071. // for more information.
  4072. func (c *ProjectsSubscriptionsTestIamPermissionsCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsTestIamPermissionsCall {
  4073. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4074. return c
  4075. }
  4076. // Context sets the context to be used in this call's Do method. Any
  4077. // pending HTTP request will be aborted if the provided context is
  4078. // canceled.
  4079. func (c *ProjectsSubscriptionsTestIamPermissionsCall) Context(ctx context.Context) *ProjectsSubscriptionsTestIamPermissionsCall {
  4080. c.ctx_ = ctx
  4081. return c
  4082. }
  4083. // Header returns an http.Header that can be modified by the caller to
  4084. // add HTTP headers to the request.
  4085. func (c *ProjectsSubscriptionsTestIamPermissionsCall) Header() http.Header {
  4086. if c.header_ == nil {
  4087. c.header_ = make(http.Header)
  4088. }
  4089. return c.header_
  4090. }
  4091. func (c *ProjectsSubscriptionsTestIamPermissionsCall) doRequest(alt string) (*http.Response, error) {
  4092. reqHeaders := make(http.Header)
  4093. for k, v := range c.header_ {
  4094. reqHeaders[k] = v
  4095. }
  4096. reqHeaders.Set("User-Agent", c.s.userAgent())
  4097. var body io.Reader = nil
  4098. body, err := googleapi.WithoutDataWrapper.JSONReader(c.testiampermissionsrequest)
  4099. if err != nil {
  4100. return nil, err
  4101. }
  4102. reqHeaders.Set("Content-Type", "application/json")
  4103. c.urlParams_.Set("alt", alt)
  4104. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+resource}:testIamPermissions")
  4105. urls += "?" + c.urlParams_.Encode()
  4106. req, _ := http.NewRequest("POST", urls, body)
  4107. req.Header = reqHeaders
  4108. googleapi.Expand(req.URL, map[string]string{
  4109. "resource": c.resource,
  4110. })
  4111. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4112. }
  4113. // Do executes the "pubsub.projects.subscriptions.testIamPermissions" call.
  4114. // Exactly one of *TestIamPermissionsResponse or error will be non-nil.
  4115. // Any non-2xx status code is an error. Response headers are in either
  4116. // *TestIamPermissionsResponse.ServerResponse.Header or (if a response
  4117. // was returned at all) in error.(*googleapi.Error).Header. Use
  4118. // googleapi.IsNotModified to check whether the returned error was
  4119. // because http.StatusNotModified was returned.
  4120. func (c *ProjectsSubscriptionsTestIamPermissionsCall) Do(opts ...googleapi.CallOption) (*TestIamPermissionsResponse, error) {
  4121. gensupport.SetOptions(c.urlParams_, opts...)
  4122. res, err := c.doRequest("json")
  4123. if res != nil && res.StatusCode == http.StatusNotModified {
  4124. if res.Body != nil {
  4125. res.Body.Close()
  4126. }
  4127. return nil, &googleapi.Error{
  4128. Code: res.StatusCode,
  4129. Header: res.Header,
  4130. }
  4131. }
  4132. if err != nil {
  4133. return nil, err
  4134. }
  4135. defer googleapi.CloseBody(res)
  4136. if err := googleapi.CheckResponse(res); err != nil {
  4137. return nil, err
  4138. }
  4139. ret := &TestIamPermissionsResponse{
  4140. ServerResponse: googleapi.ServerResponse{
  4141. Header: res.Header,
  4142. HTTPStatusCode: res.StatusCode,
  4143. },
  4144. }
  4145. target := &ret
  4146. if err := gensupport.DecodeResponse(target, res); err != nil {
  4147. return nil, err
  4148. }
  4149. return ret, nil
  4150. // {
  4151. // "description": "Returns permissions that a caller has on the specified resource.\nIf the resource does not exist, this will return an empty set of\npermissions, not a NOT_FOUND error.\n\nNote: This operation is designed to be used for building permission-aware\nUIs and command-line tools, not for authorization checking. This operation\nmay \"fail open\" without warning.",
  4152. // "flatPath": "v1/projects/{projectsId}/subscriptions/{subscriptionsId}:testIamPermissions",
  4153. // "httpMethod": "POST",
  4154. // "id": "pubsub.projects.subscriptions.testIamPermissions",
  4155. // "parameterOrder": [
  4156. // "resource"
  4157. // ],
  4158. // "parameters": {
  4159. // "resource": {
  4160. // "description": "REQUIRED: The resource for which the policy detail is being requested.\nSee the operation documentation for the appropriate value for this field.",
  4161. // "location": "path",
  4162. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  4163. // "required": true,
  4164. // "type": "string"
  4165. // }
  4166. // },
  4167. // "path": "v1/{+resource}:testIamPermissions",
  4168. // "request": {
  4169. // "$ref": "TestIamPermissionsRequest"
  4170. // },
  4171. // "response": {
  4172. // "$ref": "TestIamPermissionsResponse"
  4173. // },
  4174. // "scopes": [
  4175. // "https://www.googleapis.com/auth/cloud-platform",
  4176. // "https://www.googleapis.com/auth/pubsub"
  4177. // ]
  4178. // }
  4179. }
  4180. // method id "pubsub.projects.topics.create":
  4181. type ProjectsTopicsCreateCall struct {
  4182. s *Service
  4183. name string
  4184. topic *Topic
  4185. urlParams_ gensupport.URLParams
  4186. ctx_ context.Context
  4187. header_ http.Header
  4188. }
  4189. // Create: Creates the given topic with the given name. See the
  4190. // <a href="/pubsub/docs/admin#resource_names"> resource name rules</a>.
  4191. func (r *ProjectsTopicsService) Create(name string, topic *Topic) *ProjectsTopicsCreateCall {
  4192. c := &ProjectsTopicsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4193. c.name = name
  4194. c.topic = topic
  4195. return c
  4196. }
  4197. // Fields allows partial responses to be retrieved. See
  4198. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4199. // for more information.
  4200. func (c *ProjectsTopicsCreateCall) Fields(s ...googleapi.Field) *ProjectsTopicsCreateCall {
  4201. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4202. return c
  4203. }
  4204. // Context sets the context to be used in this call's Do method. Any
  4205. // pending HTTP request will be aborted if the provided context is
  4206. // canceled.
  4207. func (c *ProjectsTopicsCreateCall) Context(ctx context.Context) *ProjectsTopicsCreateCall {
  4208. c.ctx_ = ctx
  4209. return c
  4210. }
  4211. // Header returns an http.Header that can be modified by the caller to
  4212. // add HTTP headers to the request.
  4213. func (c *ProjectsTopicsCreateCall) Header() http.Header {
  4214. if c.header_ == nil {
  4215. c.header_ = make(http.Header)
  4216. }
  4217. return c.header_
  4218. }
  4219. func (c *ProjectsTopicsCreateCall) doRequest(alt string) (*http.Response, error) {
  4220. reqHeaders := make(http.Header)
  4221. for k, v := range c.header_ {
  4222. reqHeaders[k] = v
  4223. }
  4224. reqHeaders.Set("User-Agent", c.s.userAgent())
  4225. var body io.Reader = nil
  4226. body, err := googleapi.WithoutDataWrapper.JSONReader(c.topic)
  4227. if err != nil {
  4228. return nil, err
  4229. }
  4230. reqHeaders.Set("Content-Type", "application/json")
  4231. c.urlParams_.Set("alt", alt)
  4232. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  4233. urls += "?" + c.urlParams_.Encode()
  4234. req, _ := http.NewRequest("PUT", urls, body)
  4235. req.Header = reqHeaders
  4236. googleapi.Expand(req.URL, map[string]string{
  4237. "name": c.name,
  4238. })
  4239. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4240. }
  4241. // Do executes the "pubsub.projects.topics.create" call.
  4242. // Exactly one of *Topic or error will be non-nil. Any non-2xx status
  4243. // code is an error. Response headers are in either
  4244. // *Topic.ServerResponse.Header or (if a response was returned at all)
  4245. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  4246. // check whether the returned error was because http.StatusNotModified
  4247. // was returned.
  4248. func (c *ProjectsTopicsCreateCall) Do(opts ...googleapi.CallOption) (*Topic, error) {
  4249. gensupport.SetOptions(c.urlParams_, opts...)
  4250. res, err := c.doRequest("json")
  4251. if res != nil && res.StatusCode == http.StatusNotModified {
  4252. if res.Body != nil {
  4253. res.Body.Close()
  4254. }
  4255. return nil, &googleapi.Error{
  4256. Code: res.StatusCode,
  4257. Header: res.Header,
  4258. }
  4259. }
  4260. if err != nil {
  4261. return nil, err
  4262. }
  4263. defer googleapi.CloseBody(res)
  4264. if err := googleapi.CheckResponse(res); err != nil {
  4265. return nil, err
  4266. }
  4267. ret := &Topic{
  4268. ServerResponse: googleapi.ServerResponse{
  4269. Header: res.Header,
  4270. HTTPStatusCode: res.StatusCode,
  4271. },
  4272. }
  4273. target := &ret
  4274. if err := gensupport.DecodeResponse(target, res); err != nil {
  4275. return nil, err
  4276. }
  4277. return ret, nil
  4278. // {
  4279. // "description": "Creates the given topic with the given name. See the\n\u003ca href=\"/pubsub/docs/admin#resource_names\"\u003e resource name rules\u003c/a\u003e.",
  4280. // "flatPath": "v1/projects/{projectsId}/topics/{topicsId}",
  4281. // "httpMethod": "PUT",
  4282. // "id": "pubsub.projects.topics.create",
  4283. // "parameterOrder": [
  4284. // "name"
  4285. // ],
  4286. // "parameters": {
  4287. // "name": {
  4288. // "description": "The name of the topic. It must have the format\n`\"projects/{project}/topics/{topic}\"`. `{topic}` must start with a letter,\nand contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes (`-`),\nunderscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or percent\nsigns (`%`). It must be between 3 and 255 characters in length, and it\nmust not start with `\"goog\"`.",
  4289. // "location": "path",
  4290. // "pattern": "^projects/[^/]+/topics/[^/]+$",
  4291. // "required": true,
  4292. // "type": "string"
  4293. // }
  4294. // },
  4295. // "path": "v1/{+name}",
  4296. // "request": {
  4297. // "$ref": "Topic"
  4298. // },
  4299. // "response": {
  4300. // "$ref": "Topic"
  4301. // },
  4302. // "scopes": [
  4303. // "https://www.googleapis.com/auth/cloud-platform",
  4304. // "https://www.googleapis.com/auth/pubsub"
  4305. // ]
  4306. // }
  4307. }
  4308. // method id "pubsub.projects.topics.delete":
  4309. type ProjectsTopicsDeleteCall struct {
  4310. s *Service
  4311. topic string
  4312. urlParams_ gensupport.URLParams
  4313. ctx_ context.Context
  4314. header_ http.Header
  4315. }
  4316. // Delete: Deletes the topic with the given name. Returns `NOT_FOUND` if
  4317. // the topic
  4318. // does not exist. After a topic is deleted, a new topic may be created
  4319. // with
  4320. // the same name; this is an entirely new topic with none of the
  4321. // old
  4322. // configuration or subscriptions. Existing subscriptions to this topic
  4323. // are
  4324. // not deleted, but their `topic` field is set to `_deleted-topic_`.
  4325. func (r *ProjectsTopicsService) Delete(topic string) *ProjectsTopicsDeleteCall {
  4326. c := &ProjectsTopicsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4327. c.topic = topic
  4328. return c
  4329. }
  4330. // Fields allows partial responses to be retrieved. See
  4331. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4332. // for more information.
  4333. func (c *ProjectsTopicsDeleteCall) Fields(s ...googleapi.Field) *ProjectsTopicsDeleteCall {
  4334. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4335. return c
  4336. }
  4337. // Context sets the context to be used in this call's Do method. Any
  4338. // pending HTTP request will be aborted if the provided context is
  4339. // canceled.
  4340. func (c *ProjectsTopicsDeleteCall) Context(ctx context.Context) *ProjectsTopicsDeleteCall {
  4341. c.ctx_ = ctx
  4342. return c
  4343. }
  4344. // Header returns an http.Header that can be modified by the caller to
  4345. // add HTTP headers to the request.
  4346. func (c *ProjectsTopicsDeleteCall) Header() http.Header {
  4347. if c.header_ == nil {
  4348. c.header_ = make(http.Header)
  4349. }
  4350. return c.header_
  4351. }
  4352. func (c *ProjectsTopicsDeleteCall) doRequest(alt string) (*http.Response, error) {
  4353. reqHeaders := make(http.Header)
  4354. for k, v := range c.header_ {
  4355. reqHeaders[k] = v
  4356. }
  4357. reqHeaders.Set("User-Agent", c.s.userAgent())
  4358. var body io.Reader = nil
  4359. c.urlParams_.Set("alt", alt)
  4360. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+topic}")
  4361. urls += "?" + c.urlParams_.Encode()
  4362. req, _ := http.NewRequest("DELETE", urls, body)
  4363. req.Header = reqHeaders
  4364. googleapi.Expand(req.URL, map[string]string{
  4365. "topic": c.topic,
  4366. })
  4367. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4368. }
  4369. // Do executes the "pubsub.projects.topics.delete" call.
  4370. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  4371. // code is an error. Response headers are in either
  4372. // *Empty.ServerResponse.Header or (if a response was returned at all)
  4373. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  4374. // check whether the returned error was because http.StatusNotModified
  4375. // was returned.
  4376. func (c *ProjectsTopicsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  4377. gensupport.SetOptions(c.urlParams_, opts...)
  4378. res, err := c.doRequest("json")
  4379. if res != nil && res.StatusCode == http.StatusNotModified {
  4380. if res.Body != nil {
  4381. res.Body.Close()
  4382. }
  4383. return nil, &googleapi.Error{
  4384. Code: res.StatusCode,
  4385. Header: res.Header,
  4386. }
  4387. }
  4388. if err != nil {
  4389. return nil, err
  4390. }
  4391. defer googleapi.CloseBody(res)
  4392. if err := googleapi.CheckResponse(res); err != nil {
  4393. return nil, err
  4394. }
  4395. ret := &Empty{
  4396. ServerResponse: googleapi.ServerResponse{
  4397. Header: res.Header,
  4398. HTTPStatusCode: res.StatusCode,
  4399. },
  4400. }
  4401. target := &ret
  4402. if err := gensupport.DecodeResponse(target, res); err != nil {
  4403. return nil, err
  4404. }
  4405. return ret, nil
  4406. // {
  4407. // "description": "Deletes the topic with the given name. Returns `NOT_FOUND` if the topic\ndoes not exist. After a topic is deleted, a new topic may be created with\nthe same name; this is an entirely new topic with none of the old\nconfiguration or subscriptions. Existing subscriptions to this topic are\nnot deleted, but their `topic` field is set to `_deleted-topic_`.",
  4408. // "flatPath": "v1/projects/{projectsId}/topics/{topicsId}",
  4409. // "httpMethod": "DELETE",
  4410. // "id": "pubsub.projects.topics.delete",
  4411. // "parameterOrder": [
  4412. // "topic"
  4413. // ],
  4414. // "parameters": {
  4415. // "topic": {
  4416. // "description": "Name of the topic to delete.\nFormat is `projects/{project}/topics/{topic}`.",
  4417. // "location": "path",
  4418. // "pattern": "^projects/[^/]+/topics/[^/]+$",
  4419. // "required": true,
  4420. // "type": "string"
  4421. // }
  4422. // },
  4423. // "path": "v1/{+topic}",
  4424. // "response": {
  4425. // "$ref": "Empty"
  4426. // },
  4427. // "scopes": [
  4428. // "https://www.googleapis.com/auth/cloud-platform",
  4429. // "https://www.googleapis.com/auth/pubsub"
  4430. // ]
  4431. // }
  4432. }
  4433. // method id "pubsub.projects.topics.get":
  4434. type ProjectsTopicsGetCall struct {
  4435. s *Service
  4436. topic string
  4437. urlParams_ gensupport.URLParams
  4438. ifNoneMatch_ string
  4439. ctx_ context.Context
  4440. header_ http.Header
  4441. }
  4442. // Get: Gets the configuration of a topic.
  4443. func (r *ProjectsTopicsService) Get(topic string) *ProjectsTopicsGetCall {
  4444. c := &ProjectsTopicsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4445. c.topic = topic
  4446. return c
  4447. }
  4448. // Fields allows partial responses to be retrieved. See
  4449. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4450. // for more information.
  4451. func (c *ProjectsTopicsGetCall) Fields(s ...googleapi.Field) *ProjectsTopicsGetCall {
  4452. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4453. return c
  4454. }
  4455. // IfNoneMatch sets the optional parameter which makes the operation
  4456. // fail if the object's ETag matches the given value. This is useful for
  4457. // getting updates only after the object has changed since the last
  4458. // request. Use googleapi.IsNotModified to check whether the response
  4459. // error from Do is the result of In-None-Match.
  4460. func (c *ProjectsTopicsGetCall) IfNoneMatch(entityTag string) *ProjectsTopicsGetCall {
  4461. c.ifNoneMatch_ = entityTag
  4462. return c
  4463. }
  4464. // Context sets the context to be used in this call's Do method. Any
  4465. // pending HTTP request will be aborted if the provided context is
  4466. // canceled.
  4467. func (c *ProjectsTopicsGetCall) Context(ctx context.Context) *ProjectsTopicsGetCall {
  4468. c.ctx_ = ctx
  4469. return c
  4470. }
  4471. // Header returns an http.Header that can be modified by the caller to
  4472. // add HTTP headers to the request.
  4473. func (c *ProjectsTopicsGetCall) Header() http.Header {
  4474. if c.header_ == nil {
  4475. c.header_ = make(http.Header)
  4476. }
  4477. return c.header_
  4478. }
  4479. func (c *ProjectsTopicsGetCall) doRequest(alt string) (*http.Response, error) {
  4480. reqHeaders := make(http.Header)
  4481. for k, v := range c.header_ {
  4482. reqHeaders[k] = v
  4483. }
  4484. reqHeaders.Set("User-Agent", c.s.userAgent())
  4485. if c.ifNoneMatch_ != "" {
  4486. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  4487. }
  4488. var body io.Reader = nil
  4489. c.urlParams_.Set("alt", alt)
  4490. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+topic}")
  4491. urls += "?" + c.urlParams_.Encode()
  4492. req, _ := http.NewRequest("GET", urls, body)
  4493. req.Header = reqHeaders
  4494. googleapi.Expand(req.URL, map[string]string{
  4495. "topic": c.topic,
  4496. })
  4497. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4498. }
  4499. // Do executes the "pubsub.projects.topics.get" call.
  4500. // Exactly one of *Topic or error will be non-nil. Any non-2xx status
  4501. // code is an error. Response headers are in either
  4502. // *Topic.ServerResponse.Header or (if a response was returned at all)
  4503. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  4504. // check whether the returned error was because http.StatusNotModified
  4505. // was returned.
  4506. func (c *ProjectsTopicsGetCall) Do(opts ...googleapi.CallOption) (*Topic, error) {
  4507. gensupport.SetOptions(c.urlParams_, opts...)
  4508. res, err := c.doRequest("json")
  4509. if res != nil && res.StatusCode == http.StatusNotModified {
  4510. if res.Body != nil {
  4511. res.Body.Close()
  4512. }
  4513. return nil, &googleapi.Error{
  4514. Code: res.StatusCode,
  4515. Header: res.Header,
  4516. }
  4517. }
  4518. if err != nil {
  4519. return nil, err
  4520. }
  4521. defer googleapi.CloseBody(res)
  4522. if err := googleapi.CheckResponse(res); err != nil {
  4523. return nil, err
  4524. }
  4525. ret := &Topic{
  4526. ServerResponse: googleapi.ServerResponse{
  4527. Header: res.Header,
  4528. HTTPStatusCode: res.StatusCode,
  4529. },
  4530. }
  4531. target := &ret
  4532. if err := gensupport.DecodeResponse(target, res); err != nil {
  4533. return nil, err
  4534. }
  4535. return ret, nil
  4536. // {
  4537. // "description": "Gets the configuration of a topic.",
  4538. // "flatPath": "v1/projects/{projectsId}/topics/{topicsId}",
  4539. // "httpMethod": "GET",
  4540. // "id": "pubsub.projects.topics.get",
  4541. // "parameterOrder": [
  4542. // "topic"
  4543. // ],
  4544. // "parameters": {
  4545. // "topic": {
  4546. // "description": "The name of the topic to get.\nFormat is `projects/{project}/topics/{topic}`.",
  4547. // "location": "path",
  4548. // "pattern": "^projects/[^/]+/topics/[^/]+$",
  4549. // "required": true,
  4550. // "type": "string"
  4551. // }
  4552. // },
  4553. // "path": "v1/{+topic}",
  4554. // "response": {
  4555. // "$ref": "Topic"
  4556. // },
  4557. // "scopes": [
  4558. // "https://www.googleapis.com/auth/cloud-platform",
  4559. // "https://www.googleapis.com/auth/pubsub"
  4560. // ]
  4561. // }
  4562. }
  4563. // method id "pubsub.projects.topics.getIamPolicy":
  4564. type ProjectsTopicsGetIamPolicyCall struct {
  4565. s *Service
  4566. resource string
  4567. urlParams_ gensupport.URLParams
  4568. ifNoneMatch_ string
  4569. ctx_ context.Context
  4570. header_ http.Header
  4571. }
  4572. // GetIamPolicy: Gets the access control policy for a resource.
  4573. // Returns an empty policy if the resource exists and does not have a
  4574. // policy
  4575. // set.
  4576. func (r *ProjectsTopicsService) GetIamPolicy(resource string) *ProjectsTopicsGetIamPolicyCall {
  4577. c := &ProjectsTopicsGetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4578. c.resource = resource
  4579. return c
  4580. }
  4581. // Fields allows partial responses to be retrieved. See
  4582. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4583. // for more information.
  4584. func (c *ProjectsTopicsGetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsTopicsGetIamPolicyCall {
  4585. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4586. return c
  4587. }
  4588. // IfNoneMatch sets the optional parameter which makes the operation
  4589. // fail if the object's ETag matches the given value. This is useful for
  4590. // getting updates only after the object has changed since the last
  4591. // request. Use googleapi.IsNotModified to check whether the response
  4592. // error from Do is the result of In-None-Match.
  4593. func (c *ProjectsTopicsGetIamPolicyCall) IfNoneMatch(entityTag string) *ProjectsTopicsGetIamPolicyCall {
  4594. c.ifNoneMatch_ = entityTag
  4595. return c
  4596. }
  4597. // Context sets the context to be used in this call's Do method. Any
  4598. // pending HTTP request will be aborted if the provided context is
  4599. // canceled.
  4600. func (c *ProjectsTopicsGetIamPolicyCall) Context(ctx context.Context) *ProjectsTopicsGetIamPolicyCall {
  4601. c.ctx_ = ctx
  4602. return c
  4603. }
  4604. // Header returns an http.Header that can be modified by the caller to
  4605. // add HTTP headers to the request.
  4606. func (c *ProjectsTopicsGetIamPolicyCall) Header() http.Header {
  4607. if c.header_ == nil {
  4608. c.header_ = make(http.Header)
  4609. }
  4610. return c.header_
  4611. }
  4612. func (c *ProjectsTopicsGetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  4613. reqHeaders := make(http.Header)
  4614. for k, v := range c.header_ {
  4615. reqHeaders[k] = v
  4616. }
  4617. reqHeaders.Set("User-Agent", c.s.userAgent())
  4618. if c.ifNoneMatch_ != "" {
  4619. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  4620. }
  4621. var body io.Reader = nil
  4622. c.urlParams_.Set("alt", alt)
  4623. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+resource}:getIamPolicy")
  4624. urls += "?" + c.urlParams_.Encode()
  4625. req, _ := http.NewRequest("GET", urls, body)
  4626. req.Header = reqHeaders
  4627. googleapi.Expand(req.URL, map[string]string{
  4628. "resource": c.resource,
  4629. })
  4630. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4631. }
  4632. // Do executes the "pubsub.projects.topics.getIamPolicy" call.
  4633. // Exactly one of *Policy or error will be non-nil. Any non-2xx status
  4634. // code is an error. Response headers are in either
  4635. // *Policy.ServerResponse.Header or (if a response was returned at all)
  4636. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  4637. // check whether the returned error was because http.StatusNotModified
  4638. // was returned.
  4639. func (c *ProjectsTopicsGetIamPolicyCall) Do(opts ...googleapi.CallOption) (*Policy, error) {
  4640. gensupport.SetOptions(c.urlParams_, opts...)
  4641. res, err := c.doRequest("json")
  4642. if res != nil && res.StatusCode == http.StatusNotModified {
  4643. if res.Body != nil {
  4644. res.Body.Close()
  4645. }
  4646. return nil, &googleapi.Error{
  4647. Code: res.StatusCode,
  4648. Header: res.Header,
  4649. }
  4650. }
  4651. if err != nil {
  4652. return nil, err
  4653. }
  4654. defer googleapi.CloseBody(res)
  4655. if err := googleapi.CheckResponse(res); err != nil {
  4656. return nil, err
  4657. }
  4658. ret := &Policy{
  4659. ServerResponse: googleapi.ServerResponse{
  4660. Header: res.Header,
  4661. HTTPStatusCode: res.StatusCode,
  4662. },
  4663. }
  4664. target := &ret
  4665. if err := gensupport.DecodeResponse(target, res); err != nil {
  4666. return nil, err
  4667. }
  4668. return ret, nil
  4669. // {
  4670. // "description": "Gets the access control policy for a resource.\nReturns an empty policy if the resource exists and does not have a policy\nset.",
  4671. // "flatPath": "v1/projects/{projectsId}/topics/{topicsId}:getIamPolicy",
  4672. // "httpMethod": "GET",
  4673. // "id": "pubsub.projects.topics.getIamPolicy",
  4674. // "parameterOrder": [
  4675. // "resource"
  4676. // ],
  4677. // "parameters": {
  4678. // "resource": {
  4679. // "description": "REQUIRED: The resource for which the policy is being requested.\nSee the operation documentation for the appropriate value for this field.",
  4680. // "location": "path",
  4681. // "pattern": "^projects/[^/]+/topics/[^/]+$",
  4682. // "required": true,
  4683. // "type": "string"
  4684. // }
  4685. // },
  4686. // "path": "v1/{+resource}:getIamPolicy",
  4687. // "response": {
  4688. // "$ref": "Policy"
  4689. // },
  4690. // "scopes": [
  4691. // "https://www.googleapis.com/auth/cloud-platform",
  4692. // "https://www.googleapis.com/auth/pubsub"
  4693. // ]
  4694. // }
  4695. }
  4696. // method id "pubsub.projects.topics.list":
  4697. type ProjectsTopicsListCall struct {
  4698. s *Service
  4699. project string
  4700. urlParams_ gensupport.URLParams
  4701. ifNoneMatch_ string
  4702. ctx_ context.Context
  4703. header_ http.Header
  4704. }
  4705. // List: Lists matching topics.
  4706. func (r *ProjectsTopicsService) List(project string) *ProjectsTopicsListCall {
  4707. c := &ProjectsTopicsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4708. c.project = project
  4709. return c
  4710. }
  4711. // PageSize sets the optional parameter "pageSize": Maximum number of
  4712. // topics to return.
  4713. func (c *ProjectsTopicsListCall) PageSize(pageSize int64) *ProjectsTopicsListCall {
  4714. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  4715. return c
  4716. }
  4717. // PageToken sets the optional parameter "pageToken": The value returned
  4718. // by the last `ListTopicsResponse`; indicates that this is
  4719. // a continuation of a prior `ListTopics` call, and that the system
  4720. // should
  4721. // return the next page of data.
  4722. func (c *ProjectsTopicsListCall) PageToken(pageToken string) *ProjectsTopicsListCall {
  4723. c.urlParams_.Set("pageToken", pageToken)
  4724. return c
  4725. }
  4726. // Fields allows partial responses to be retrieved. See
  4727. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4728. // for more information.
  4729. func (c *ProjectsTopicsListCall) Fields(s ...googleapi.Field) *ProjectsTopicsListCall {
  4730. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4731. return c
  4732. }
  4733. // IfNoneMatch sets the optional parameter which makes the operation
  4734. // fail if the object's ETag matches the given value. This is useful for
  4735. // getting updates only after the object has changed since the last
  4736. // request. Use googleapi.IsNotModified to check whether the response
  4737. // error from Do is the result of In-None-Match.
  4738. func (c *ProjectsTopicsListCall) IfNoneMatch(entityTag string) *ProjectsTopicsListCall {
  4739. c.ifNoneMatch_ = entityTag
  4740. return c
  4741. }
  4742. // Context sets the context to be used in this call's Do method. Any
  4743. // pending HTTP request will be aborted if the provided context is
  4744. // canceled.
  4745. func (c *ProjectsTopicsListCall) Context(ctx context.Context) *ProjectsTopicsListCall {
  4746. c.ctx_ = ctx
  4747. return c
  4748. }
  4749. // Header returns an http.Header that can be modified by the caller to
  4750. // add HTTP headers to the request.
  4751. func (c *ProjectsTopicsListCall) Header() http.Header {
  4752. if c.header_ == nil {
  4753. c.header_ = make(http.Header)
  4754. }
  4755. return c.header_
  4756. }
  4757. func (c *ProjectsTopicsListCall) doRequest(alt string) (*http.Response, error) {
  4758. reqHeaders := make(http.Header)
  4759. for k, v := range c.header_ {
  4760. reqHeaders[k] = v
  4761. }
  4762. reqHeaders.Set("User-Agent", c.s.userAgent())
  4763. if c.ifNoneMatch_ != "" {
  4764. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  4765. }
  4766. var body io.Reader = nil
  4767. c.urlParams_.Set("alt", alt)
  4768. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+project}/topics")
  4769. urls += "?" + c.urlParams_.Encode()
  4770. req, _ := http.NewRequest("GET", urls, body)
  4771. req.Header = reqHeaders
  4772. googleapi.Expand(req.URL, map[string]string{
  4773. "project": c.project,
  4774. })
  4775. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4776. }
  4777. // Do executes the "pubsub.projects.topics.list" call.
  4778. // Exactly one of *ListTopicsResponse or error will be non-nil. Any
  4779. // non-2xx status code is an error. Response headers are in either
  4780. // *ListTopicsResponse.ServerResponse.Header or (if a response was
  4781. // returned at all) in error.(*googleapi.Error).Header. Use
  4782. // googleapi.IsNotModified to check whether the returned error was
  4783. // because http.StatusNotModified was returned.
  4784. func (c *ProjectsTopicsListCall) Do(opts ...googleapi.CallOption) (*ListTopicsResponse, error) {
  4785. gensupport.SetOptions(c.urlParams_, opts...)
  4786. res, err := c.doRequest("json")
  4787. if res != nil && res.StatusCode == http.StatusNotModified {
  4788. if res.Body != nil {
  4789. res.Body.Close()
  4790. }
  4791. return nil, &googleapi.Error{
  4792. Code: res.StatusCode,
  4793. Header: res.Header,
  4794. }
  4795. }
  4796. if err != nil {
  4797. return nil, err
  4798. }
  4799. defer googleapi.CloseBody(res)
  4800. if err := googleapi.CheckResponse(res); err != nil {
  4801. return nil, err
  4802. }
  4803. ret := &ListTopicsResponse{
  4804. ServerResponse: googleapi.ServerResponse{
  4805. Header: res.Header,
  4806. HTTPStatusCode: res.StatusCode,
  4807. },
  4808. }
  4809. target := &ret
  4810. if err := gensupport.DecodeResponse(target, res); err != nil {
  4811. return nil, err
  4812. }
  4813. return ret, nil
  4814. // {
  4815. // "description": "Lists matching topics.",
  4816. // "flatPath": "v1/projects/{projectsId}/topics",
  4817. // "httpMethod": "GET",
  4818. // "id": "pubsub.projects.topics.list",
  4819. // "parameterOrder": [
  4820. // "project"
  4821. // ],
  4822. // "parameters": {
  4823. // "pageSize": {
  4824. // "description": "Maximum number of topics to return.",
  4825. // "format": "int32",
  4826. // "location": "query",
  4827. // "type": "integer"
  4828. // },
  4829. // "pageToken": {
  4830. // "description": "The value returned by the last `ListTopicsResponse`; indicates that this is\na continuation of a prior `ListTopics` call, and that the system should\nreturn the next page of data.",
  4831. // "location": "query",
  4832. // "type": "string"
  4833. // },
  4834. // "project": {
  4835. // "description": "The name of the cloud project that topics belong to.\nFormat is `projects/{project}`.",
  4836. // "location": "path",
  4837. // "pattern": "^projects/[^/]+$",
  4838. // "required": true,
  4839. // "type": "string"
  4840. // }
  4841. // },
  4842. // "path": "v1/{+project}/topics",
  4843. // "response": {
  4844. // "$ref": "ListTopicsResponse"
  4845. // },
  4846. // "scopes": [
  4847. // "https://www.googleapis.com/auth/cloud-platform",
  4848. // "https://www.googleapis.com/auth/pubsub"
  4849. // ]
  4850. // }
  4851. }
  4852. // Pages invokes f for each page of results.
  4853. // A non-nil error returned from f will halt the iteration.
  4854. // The provided context supersedes any context provided to the Context method.
  4855. func (c *ProjectsTopicsListCall) Pages(ctx context.Context, f func(*ListTopicsResponse) error) error {
  4856. c.ctx_ = ctx
  4857. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  4858. for {
  4859. x, err := c.Do()
  4860. if err != nil {
  4861. return err
  4862. }
  4863. if err := f(x); err != nil {
  4864. return err
  4865. }
  4866. if x.NextPageToken == "" {
  4867. return nil
  4868. }
  4869. c.PageToken(x.NextPageToken)
  4870. }
  4871. }
  4872. // method id "pubsub.projects.topics.publish":
  4873. type ProjectsTopicsPublishCall struct {
  4874. s *Service
  4875. topic string
  4876. publishrequest *PublishRequest
  4877. urlParams_ gensupport.URLParams
  4878. ctx_ context.Context
  4879. header_ http.Header
  4880. }
  4881. // Publish: Adds one or more messages to the topic. Returns `NOT_FOUND`
  4882. // if the topic
  4883. // does not exist. The message payload must not be empty; it must
  4884. // contain
  4885. // either a non-empty data field, or at least one attribute.
  4886. func (r *ProjectsTopicsService) Publish(topic string, publishrequest *PublishRequest) *ProjectsTopicsPublishCall {
  4887. c := &ProjectsTopicsPublishCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4888. c.topic = topic
  4889. c.publishrequest = publishrequest
  4890. return c
  4891. }
  4892. // Fields allows partial responses to be retrieved. See
  4893. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4894. // for more information.
  4895. func (c *ProjectsTopicsPublishCall) Fields(s ...googleapi.Field) *ProjectsTopicsPublishCall {
  4896. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4897. return c
  4898. }
  4899. // Context sets the context to be used in this call's Do method. Any
  4900. // pending HTTP request will be aborted if the provided context is
  4901. // canceled.
  4902. func (c *ProjectsTopicsPublishCall) Context(ctx context.Context) *ProjectsTopicsPublishCall {
  4903. c.ctx_ = ctx
  4904. return c
  4905. }
  4906. // Header returns an http.Header that can be modified by the caller to
  4907. // add HTTP headers to the request.
  4908. func (c *ProjectsTopicsPublishCall) Header() http.Header {
  4909. if c.header_ == nil {
  4910. c.header_ = make(http.Header)
  4911. }
  4912. return c.header_
  4913. }
  4914. func (c *ProjectsTopicsPublishCall) doRequest(alt string) (*http.Response, error) {
  4915. reqHeaders := make(http.Header)
  4916. for k, v := range c.header_ {
  4917. reqHeaders[k] = v
  4918. }
  4919. reqHeaders.Set("User-Agent", c.s.userAgent())
  4920. var body io.Reader = nil
  4921. body, err := googleapi.WithoutDataWrapper.JSONReader(c.publishrequest)
  4922. if err != nil {
  4923. return nil, err
  4924. }
  4925. reqHeaders.Set("Content-Type", "application/json")
  4926. c.urlParams_.Set("alt", alt)
  4927. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+topic}:publish")
  4928. urls += "?" + c.urlParams_.Encode()
  4929. req, _ := http.NewRequest("POST", urls, body)
  4930. req.Header = reqHeaders
  4931. googleapi.Expand(req.URL, map[string]string{
  4932. "topic": c.topic,
  4933. })
  4934. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4935. }
  4936. // Do executes the "pubsub.projects.topics.publish" call.
  4937. // Exactly one of *PublishResponse or error will be non-nil. Any non-2xx
  4938. // status code is an error. Response headers are in either
  4939. // *PublishResponse.ServerResponse.Header or (if a response was returned
  4940. // at all) in error.(*googleapi.Error).Header. Use
  4941. // googleapi.IsNotModified to check whether the returned error was
  4942. // because http.StatusNotModified was returned.
  4943. func (c *ProjectsTopicsPublishCall) Do(opts ...googleapi.CallOption) (*PublishResponse, error) {
  4944. gensupport.SetOptions(c.urlParams_, opts...)
  4945. res, err := c.doRequest("json")
  4946. if res != nil && res.StatusCode == http.StatusNotModified {
  4947. if res.Body != nil {
  4948. res.Body.Close()
  4949. }
  4950. return nil, &googleapi.Error{
  4951. Code: res.StatusCode,
  4952. Header: res.Header,
  4953. }
  4954. }
  4955. if err != nil {
  4956. return nil, err
  4957. }
  4958. defer googleapi.CloseBody(res)
  4959. if err := googleapi.CheckResponse(res); err != nil {
  4960. return nil, err
  4961. }
  4962. ret := &PublishResponse{
  4963. ServerResponse: googleapi.ServerResponse{
  4964. Header: res.Header,
  4965. HTTPStatusCode: res.StatusCode,
  4966. },
  4967. }
  4968. target := &ret
  4969. if err := gensupport.DecodeResponse(target, res); err != nil {
  4970. return nil, err
  4971. }
  4972. return ret, nil
  4973. // {
  4974. // "description": "Adds one or more messages to the topic. Returns `NOT_FOUND` if the topic\ndoes not exist. The message payload must not be empty; it must contain\n either a non-empty data field, or at least one attribute.",
  4975. // "flatPath": "v1/projects/{projectsId}/topics/{topicsId}:publish",
  4976. // "httpMethod": "POST",
  4977. // "id": "pubsub.projects.topics.publish",
  4978. // "parameterOrder": [
  4979. // "topic"
  4980. // ],
  4981. // "parameters": {
  4982. // "topic": {
  4983. // "description": "The messages in the request will be published on this topic.\nFormat is `projects/{project}/topics/{topic}`.",
  4984. // "location": "path",
  4985. // "pattern": "^projects/[^/]+/topics/[^/]+$",
  4986. // "required": true,
  4987. // "type": "string"
  4988. // }
  4989. // },
  4990. // "path": "v1/{+topic}:publish",
  4991. // "request": {
  4992. // "$ref": "PublishRequest"
  4993. // },
  4994. // "response": {
  4995. // "$ref": "PublishResponse"
  4996. // },
  4997. // "scopes": [
  4998. // "https://www.googleapis.com/auth/cloud-platform",
  4999. // "https://www.googleapis.com/auth/pubsub"
  5000. // ]
  5001. // }
  5002. }
  5003. // method id "pubsub.projects.topics.setIamPolicy":
  5004. type ProjectsTopicsSetIamPolicyCall struct {
  5005. s *Service
  5006. resource string
  5007. setiampolicyrequest *SetIamPolicyRequest
  5008. urlParams_ gensupport.URLParams
  5009. ctx_ context.Context
  5010. header_ http.Header
  5011. }
  5012. // SetIamPolicy: Sets the access control policy on the specified
  5013. // resource. Replaces any
  5014. // existing policy.
  5015. func (r *ProjectsTopicsService) SetIamPolicy(resource string, setiampolicyrequest *SetIamPolicyRequest) *ProjectsTopicsSetIamPolicyCall {
  5016. c := &ProjectsTopicsSetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  5017. c.resource = resource
  5018. c.setiampolicyrequest = setiampolicyrequest
  5019. return c
  5020. }
  5021. // Fields allows partial responses to be retrieved. See
  5022. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  5023. // for more information.
  5024. func (c *ProjectsTopicsSetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsTopicsSetIamPolicyCall {
  5025. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  5026. return c
  5027. }
  5028. // Context sets the context to be used in this call's Do method. Any
  5029. // pending HTTP request will be aborted if the provided context is
  5030. // canceled.
  5031. func (c *ProjectsTopicsSetIamPolicyCall) Context(ctx context.Context) *ProjectsTopicsSetIamPolicyCall {
  5032. c.ctx_ = ctx
  5033. return c
  5034. }
  5035. // Header returns an http.Header that can be modified by the caller to
  5036. // add HTTP headers to the request.
  5037. func (c *ProjectsTopicsSetIamPolicyCall) Header() http.Header {
  5038. if c.header_ == nil {
  5039. c.header_ = make(http.Header)
  5040. }
  5041. return c.header_
  5042. }
  5043. func (c *ProjectsTopicsSetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  5044. reqHeaders := make(http.Header)
  5045. for k, v := range c.header_ {
  5046. reqHeaders[k] = v
  5047. }
  5048. reqHeaders.Set("User-Agent", c.s.userAgent())
  5049. var body io.Reader = nil
  5050. body, err := googleapi.WithoutDataWrapper.JSONReader(c.setiampolicyrequest)
  5051. if err != nil {
  5052. return nil, err
  5053. }
  5054. reqHeaders.Set("Content-Type", "application/json")
  5055. c.urlParams_.Set("alt", alt)
  5056. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+resource}:setIamPolicy")
  5057. urls += "?" + c.urlParams_.Encode()
  5058. req, _ := http.NewRequest("POST", urls, body)
  5059. req.Header = reqHeaders
  5060. googleapi.Expand(req.URL, map[string]string{
  5061. "resource": c.resource,
  5062. })
  5063. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  5064. }
  5065. // Do executes the "pubsub.projects.topics.setIamPolicy" call.
  5066. // Exactly one of *Policy or error will be non-nil. Any non-2xx status
  5067. // code is an error. Response headers are in either
  5068. // *Policy.ServerResponse.Header or (if a response was returned at all)
  5069. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  5070. // check whether the returned error was because http.StatusNotModified
  5071. // was returned.
  5072. func (c *ProjectsTopicsSetIamPolicyCall) Do(opts ...googleapi.CallOption) (*Policy, error) {
  5073. gensupport.SetOptions(c.urlParams_, opts...)
  5074. res, err := c.doRequest("json")
  5075. if res != nil && res.StatusCode == http.StatusNotModified {
  5076. if res.Body != nil {
  5077. res.Body.Close()
  5078. }
  5079. return nil, &googleapi.Error{
  5080. Code: res.StatusCode,
  5081. Header: res.Header,
  5082. }
  5083. }
  5084. if err != nil {
  5085. return nil, err
  5086. }
  5087. defer googleapi.CloseBody(res)
  5088. if err := googleapi.CheckResponse(res); err != nil {
  5089. return nil, err
  5090. }
  5091. ret := &Policy{
  5092. ServerResponse: googleapi.ServerResponse{
  5093. Header: res.Header,
  5094. HTTPStatusCode: res.StatusCode,
  5095. },
  5096. }
  5097. target := &ret
  5098. if err := gensupport.DecodeResponse(target, res); err != nil {
  5099. return nil, err
  5100. }
  5101. return ret, nil
  5102. // {
  5103. // "description": "Sets the access control policy on the specified resource. Replaces any\nexisting policy.",
  5104. // "flatPath": "v1/projects/{projectsId}/topics/{topicsId}:setIamPolicy",
  5105. // "httpMethod": "POST",
  5106. // "id": "pubsub.projects.topics.setIamPolicy",
  5107. // "parameterOrder": [
  5108. // "resource"
  5109. // ],
  5110. // "parameters": {
  5111. // "resource": {
  5112. // "description": "REQUIRED: The resource for which the policy is being specified.\nSee the operation documentation for the appropriate value for this field.",
  5113. // "location": "path",
  5114. // "pattern": "^projects/[^/]+/topics/[^/]+$",
  5115. // "required": true,
  5116. // "type": "string"
  5117. // }
  5118. // },
  5119. // "path": "v1/{+resource}:setIamPolicy",
  5120. // "request": {
  5121. // "$ref": "SetIamPolicyRequest"
  5122. // },
  5123. // "response": {
  5124. // "$ref": "Policy"
  5125. // },
  5126. // "scopes": [
  5127. // "https://www.googleapis.com/auth/cloud-platform",
  5128. // "https://www.googleapis.com/auth/pubsub"
  5129. // ]
  5130. // }
  5131. }
  5132. // method id "pubsub.projects.topics.testIamPermissions":
  5133. type ProjectsTopicsTestIamPermissionsCall struct {
  5134. s *Service
  5135. resource string
  5136. testiampermissionsrequest *TestIamPermissionsRequest
  5137. urlParams_ gensupport.URLParams
  5138. ctx_ context.Context
  5139. header_ http.Header
  5140. }
  5141. // TestIamPermissions: Returns permissions that a caller has on the
  5142. // specified resource.
  5143. // If the resource does not exist, this will return an empty set
  5144. // of
  5145. // permissions, not a NOT_FOUND error.
  5146. //
  5147. // Note: This operation is designed to be used for building
  5148. // permission-aware
  5149. // UIs and command-line tools, not for authorization checking. This
  5150. // operation
  5151. // may "fail open" without warning.
  5152. func (r *ProjectsTopicsService) TestIamPermissions(resource string, testiampermissionsrequest *TestIamPermissionsRequest) *ProjectsTopicsTestIamPermissionsCall {
  5153. c := &ProjectsTopicsTestIamPermissionsCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  5154. c.resource = resource
  5155. c.testiampermissionsrequest = testiampermissionsrequest
  5156. return c
  5157. }
  5158. // Fields allows partial responses to be retrieved. See
  5159. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  5160. // for more information.
  5161. func (c *ProjectsTopicsTestIamPermissionsCall) Fields(s ...googleapi.Field) *ProjectsTopicsTestIamPermissionsCall {
  5162. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  5163. return c
  5164. }
  5165. // Context sets the context to be used in this call's Do method. Any
  5166. // pending HTTP request will be aborted if the provided context is
  5167. // canceled.
  5168. func (c *ProjectsTopicsTestIamPermissionsCall) Context(ctx context.Context) *ProjectsTopicsTestIamPermissionsCall {
  5169. c.ctx_ = ctx
  5170. return c
  5171. }
  5172. // Header returns an http.Header that can be modified by the caller to
  5173. // add HTTP headers to the request.
  5174. func (c *ProjectsTopicsTestIamPermissionsCall) Header() http.Header {
  5175. if c.header_ == nil {
  5176. c.header_ = make(http.Header)
  5177. }
  5178. return c.header_
  5179. }
  5180. func (c *ProjectsTopicsTestIamPermissionsCall) doRequest(alt string) (*http.Response, error) {
  5181. reqHeaders := make(http.Header)
  5182. for k, v := range c.header_ {
  5183. reqHeaders[k] = v
  5184. }
  5185. reqHeaders.Set("User-Agent", c.s.userAgent())
  5186. var body io.Reader = nil
  5187. body, err := googleapi.WithoutDataWrapper.JSONReader(c.testiampermissionsrequest)
  5188. if err != nil {
  5189. return nil, err
  5190. }
  5191. reqHeaders.Set("Content-Type", "application/json")
  5192. c.urlParams_.Set("alt", alt)
  5193. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+resource}:testIamPermissions")
  5194. urls += "?" + c.urlParams_.Encode()
  5195. req, _ := http.NewRequest("POST", urls, body)
  5196. req.Header = reqHeaders
  5197. googleapi.Expand(req.URL, map[string]string{
  5198. "resource": c.resource,
  5199. })
  5200. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  5201. }
  5202. // Do executes the "pubsub.projects.topics.testIamPermissions" call.
  5203. // Exactly one of *TestIamPermissionsResponse or error will be non-nil.
  5204. // Any non-2xx status code is an error. Response headers are in either
  5205. // *TestIamPermissionsResponse.ServerResponse.Header or (if a response
  5206. // was returned at all) in error.(*googleapi.Error).Header. Use
  5207. // googleapi.IsNotModified to check whether the returned error was
  5208. // because http.StatusNotModified was returned.
  5209. func (c *ProjectsTopicsTestIamPermissionsCall) Do(opts ...googleapi.CallOption) (*TestIamPermissionsResponse, error) {
  5210. gensupport.SetOptions(c.urlParams_, opts...)
  5211. res, err := c.doRequest("json")
  5212. if res != nil && res.StatusCode == http.StatusNotModified {
  5213. if res.Body != nil {
  5214. res.Body.Close()
  5215. }
  5216. return nil, &googleapi.Error{
  5217. Code: res.StatusCode,
  5218. Header: res.Header,
  5219. }
  5220. }
  5221. if err != nil {
  5222. return nil, err
  5223. }
  5224. defer googleapi.CloseBody(res)
  5225. if err := googleapi.CheckResponse(res); err != nil {
  5226. return nil, err
  5227. }
  5228. ret := &TestIamPermissionsResponse{
  5229. ServerResponse: googleapi.ServerResponse{
  5230. Header: res.Header,
  5231. HTTPStatusCode: res.StatusCode,
  5232. },
  5233. }
  5234. target := &ret
  5235. if err := gensupport.DecodeResponse(target, res); err != nil {
  5236. return nil, err
  5237. }
  5238. return ret, nil
  5239. // {
  5240. // "description": "Returns permissions that a caller has on the specified resource.\nIf the resource does not exist, this will return an empty set of\npermissions, not a NOT_FOUND error.\n\nNote: This operation is designed to be used for building permission-aware\nUIs and command-line tools, not for authorization checking. This operation\nmay \"fail open\" without warning.",
  5241. // "flatPath": "v1/projects/{projectsId}/topics/{topicsId}:testIamPermissions",
  5242. // "httpMethod": "POST",
  5243. // "id": "pubsub.projects.topics.testIamPermissions",
  5244. // "parameterOrder": [
  5245. // "resource"
  5246. // ],
  5247. // "parameters": {
  5248. // "resource": {
  5249. // "description": "REQUIRED: The resource for which the policy detail is being requested.\nSee the operation documentation for the appropriate value for this field.",
  5250. // "location": "path",
  5251. // "pattern": "^projects/[^/]+/topics/[^/]+$",
  5252. // "required": true,
  5253. // "type": "string"
  5254. // }
  5255. // },
  5256. // "path": "v1/{+resource}:testIamPermissions",
  5257. // "request": {
  5258. // "$ref": "TestIamPermissionsRequest"
  5259. // },
  5260. // "response": {
  5261. // "$ref": "TestIamPermissionsResponse"
  5262. // },
  5263. // "scopes": [
  5264. // "https://www.googleapis.com/auth/cloud-platform",
  5265. // "https://www.googleapis.com/auth/pubsub"
  5266. // ]
  5267. // }
  5268. }
  5269. // method id "pubsub.projects.topics.snapshots.list":
  5270. type ProjectsTopicsSnapshotsListCall struct {
  5271. s *Service
  5272. topic string
  5273. urlParams_ gensupport.URLParams
  5274. ifNoneMatch_ string
  5275. ctx_ context.Context
  5276. header_ http.Header
  5277. }
  5278. // List: Lists the names of the snapshots on this
  5279. // topic.<br><br>
  5280. // <b>ALPHA:</b> This feature is part of an alpha release. This API
  5281. // might be
  5282. // changed in backward-incompatible ways and is not recommended for
  5283. // production
  5284. // use. It is not subject to any SLA or deprecation policy.
  5285. func (r *ProjectsTopicsSnapshotsService) List(topic string) *ProjectsTopicsSnapshotsListCall {
  5286. c := &ProjectsTopicsSnapshotsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  5287. c.topic = topic
  5288. return c
  5289. }
  5290. // PageSize sets the optional parameter "pageSize": Maximum number of
  5291. // snapshot names to return.
  5292. func (c *ProjectsTopicsSnapshotsListCall) PageSize(pageSize int64) *ProjectsTopicsSnapshotsListCall {
  5293. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  5294. return c
  5295. }
  5296. // PageToken sets the optional parameter "pageToken": The value returned
  5297. // by the last `ListTopicSnapshotsResponse`; indicates
  5298. // that this is a continuation of a prior `ListTopicSnapshots` call,
  5299. // and
  5300. // that the system should return the next page of data.
  5301. func (c *ProjectsTopicsSnapshotsListCall) PageToken(pageToken string) *ProjectsTopicsSnapshotsListCall {
  5302. c.urlParams_.Set("pageToken", pageToken)
  5303. return c
  5304. }
  5305. // Fields allows partial responses to be retrieved. See
  5306. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  5307. // for more information.
  5308. func (c *ProjectsTopicsSnapshotsListCall) Fields(s ...googleapi.Field) *ProjectsTopicsSnapshotsListCall {
  5309. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  5310. return c
  5311. }
  5312. // IfNoneMatch sets the optional parameter which makes the operation
  5313. // fail if the object's ETag matches the given value. This is useful for
  5314. // getting updates only after the object has changed since the last
  5315. // request. Use googleapi.IsNotModified to check whether the response
  5316. // error from Do is the result of In-None-Match.
  5317. func (c *ProjectsTopicsSnapshotsListCall) IfNoneMatch(entityTag string) *ProjectsTopicsSnapshotsListCall {
  5318. c.ifNoneMatch_ = entityTag
  5319. return c
  5320. }
  5321. // Context sets the context to be used in this call's Do method. Any
  5322. // pending HTTP request will be aborted if the provided context is
  5323. // canceled.
  5324. func (c *ProjectsTopicsSnapshotsListCall) Context(ctx context.Context) *ProjectsTopicsSnapshotsListCall {
  5325. c.ctx_ = ctx
  5326. return c
  5327. }
  5328. // Header returns an http.Header that can be modified by the caller to
  5329. // add HTTP headers to the request.
  5330. func (c *ProjectsTopicsSnapshotsListCall) Header() http.Header {
  5331. if c.header_ == nil {
  5332. c.header_ = make(http.Header)
  5333. }
  5334. return c.header_
  5335. }
  5336. func (c *ProjectsTopicsSnapshotsListCall) doRequest(alt string) (*http.Response, error) {
  5337. reqHeaders := make(http.Header)
  5338. for k, v := range c.header_ {
  5339. reqHeaders[k] = v
  5340. }
  5341. reqHeaders.Set("User-Agent", c.s.userAgent())
  5342. if c.ifNoneMatch_ != "" {
  5343. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  5344. }
  5345. var body io.Reader = nil
  5346. c.urlParams_.Set("alt", alt)
  5347. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+topic}/snapshots")
  5348. urls += "?" + c.urlParams_.Encode()
  5349. req, _ := http.NewRequest("GET", urls, body)
  5350. req.Header = reqHeaders
  5351. googleapi.Expand(req.URL, map[string]string{
  5352. "topic": c.topic,
  5353. })
  5354. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  5355. }
  5356. // Do executes the "pubsub.projects.topics.snapshots.list" call.
  5357. // Exactly one of *ListTopicSnapshotsResponse or error will be non-nil.
  5358. // Any non-2xx status code is an error. Response headers are in either
  5359. // *ListTopicSnapshotsResponse.ServerResponse.Header or (if a response
  5360. // was returned at all) in error.(*googleapi.Error).Header. Use
  5361. // googleapi.IsNotModified to check whether the returned error was
  5362. // because http.StatusNotModified was returned.
  5363. func (c *ProjectsTopicsSnapshotsListCall) Do(opts ...googleapi.CallOption) (*ListTopicSnapshotsResponse, error) {
  5364. gensupport.SetOptions(c.urlParams_, opts...)
  5365. res, err := c.doRequest("json")
  5366. if res != nil && res.StatusCode == http.StatusNotModified {
  5367. if res.Body != nil {
  5368. res.Body.Close()
  5369. }
  5370. return nil, &googleapi.Error{
  5371. Code: res.StatusCode,
  5372. Header: res.Header,
  5373. }
  5374. }
  5375. if err != nil {
  5376. return nil, err
  5377. }
  5378. defer googleapi.CloseBody(res)
  5379. if err := googleapi.CheckResponse(res); err != nil {
  5380. return nil, err
  5381. }
  5382. ret := &ListTopicSnapshotsResponse{
  5383. ServerResponse: googleapi.ServerResponse{
  5384. Header: res.Header,
  5385. HTTPStatusCode: res.StatusCode,
  5386. },
  5387. }
  5388. target := &ret
  5389. if err := gensupport.DecodeResponse(target, res); err != nil {
  5390. return nil, err
  5391. }
  5392. return ret, nil
  5393. // {
  5394. // "description": "Lists the names of the snapshots on this topic.\u003cbr\u003e\u003cbr\u003e\n\u003cb\u003eALPHA:\u003c/b\u003e This feature is part of an alpha release. This API might be\nchanged in backward-incompatible ways and is not recommended for production\nuse. It is not subject to any SLA or deprecation policy.",
  5395. // "flatPath": "v1/projects/{projectsId}/topics/{topicsId}/snapshots",
  5396. // "httpMethod": "GET",
  5397. // "id": "pubsub.projects.topics.snapshots.list",
  5398. // "parameterOrder": [
  5399. // "topic"
  5400. // ],
  5401. // "parameters": {
  5402. // "pageSize": {
  5403. // "description": "Maximum number of snapshot names to return.",
  5404. // "format": "int32",
  5405. // "location": "query",
  5406. // "type": "integer"
  5407. // },
  5408. // "pageToken": {
  5409. // "description": "The value returned by the last `ListTopicSnapshotsResponse`; indicates\nthat this is a continuation of a prior `ListTopicSnapshots` call, and\nthat the system should return the next page of data.",
  5410. // "location": "query",
  5411. // "type": "string"
  5412. // },
  5413. // "topic": {
  5414. // "description": "The name of the topic that snapshots are attached to.\nFormat is `projects/{project}/topics/{topic}`.",
  5415. // "location": "path",
  5416. // "pattern": "^projects/[^/]+/topics/[^/]+$",
  5417. // "required": true,
  5418. // "type": "string"
  5419. // }
  5420. // },
  5421. // "path": "v1/{+topic}/snapshots",
  5422. // "response": {
  5423. // "$ref": "ListTopicSnapshotsResponse"
  5424. // },
  5425. // "scopes": [
  5426. // "https://www.googleapis.com/auth/cloud-platform",
  5427. // "https://www.googleapis.com/auth/pubsub"
  5428. // ]
  5429. // }
  5430. }
  5431. // Pages invokes f for each page of results.
  5432. // A non-nil error returned from f will halt the iteration.
  5433. // The provided context supersedes any context provided to the Context method.
  5434. func (c *ProjectsTopicsSnapshotsListCall) Pages(ctx context.Context, f func(*ListTopicSnapshotsResponse) error) error {
  5435. c.ctx_ = ctx
  5436. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  5437. for {
  5438. x, err := c.Do()
  5439. if err != nil {
  5440. return err
  5441. }
  5442. if err := f(x); err != nil {
  5443. return err
  5444. }
  5445. if x.NextPageToken == "" {
  5446. return nil
  5447. }
  5448. c.PageToken(x.NextPageToken)
  5449. }
  5450. }
  5451. // method id "pubsub.projects.topics.subscriptions.list":
  5452. type ProjectsTopicsSubscriptionsListCall struct {
  5453. s *Service
  5454. topic string
  5455. urlParams_ gensupport.URLParams
  5456. ifNoneMatch_ string
  5457. ctx_ context.Context
  5458. header_ http.Header
  5459. }
  5460. // List: Lists the names of the subscriptions on this topic.
  5461. func (r *ProjectsTopicsSubscriptionsService) List(topic string) *ProjectsTopicsSubscriptionsListCall {
  5462. c := &ProjectsTopicsSubscriptionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  5463. c.topic = topic
  5464. return c
  5465. }
  5466. // PageSize sets the optional parameter "pageSize": Maximum number of
  5467. // subscription names to return.
  5468. func (c *ProjectsTopicsSubscriptionsListCall) PageSize(pageSize int64) *ProjectsTopicsSubscriptionsListCall {
  5469. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  5470. return c
  5471. }
  5472. // PageToken sets the optional parameter "pageToken": The value returned
  5473. // by the last `ListTopicSubscriptionsResponse`; indicates
  5474. // that this is a continuation of a prior `ListTopicSubscriptions` call,
  5475. // and
  5476. // that the system should return the next page of data.
  5477. func (c *ProjectsTopicsSubscriptionsListCall) PageToken(pageToken string) *ProjectsTopicsSubscriptionsListCall {
  5478. c.urlParams_.Set("pageToken", pageToken)
  5479. return c
  5480. }
  5481. // Fields allows partial responses to be retrieved. See
  5482. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  5483. // for more information.
  5484. func (c *ProjectsTopicsSubscriptionsListCall) Fields(s ...googleapi.Field) *ProjectsTopicsSubscriptionsListCall {
  5485. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  5486. return c
  5487. }
  5488. // IfNoneMatch sets the optional parameter which makes the operation
  5489. // fail if the object's ETag matches the given value. This is useful for
  5490. // getting updates only after the object has changed since the last
  5491. // request. Use googleapi.IsNotModified to check whether the response
  5492. // error from Do is the result of In-None-Match.
  5493. func (c *ProjectsTopicsSubscriptionsListCall) IfNoneMatch(entityTag string) *ProjectsTopicsSubscriptionsListCall {
  5494. c.ifNoneMatch_ = entityTag
  5495. return c
  5496. }
  5497. // Context sets the context to be used in this call's Do method. Any
  5498. // pending HTTP request will be aborted if the provided context is
  5499. // canceled.
  5500. func (c *ProjectsTopicsSubscriptionsListCall) Context(ctx context.Context) *ProjectsTopicsSubscriptionsListCall {
  5501. c.ctx_ = ctx
  5502. return c
  5503. }
  5504. // Header returns an http.Header that can be modified by the caller to
  5505. // add HTTP headers to the request.
  5506. func (c *ProjectsTopicsSubscriptionsListCall) Header() http.Header {
  5507. if c.header_ == nil {
  5508. c.header_ = make(http.Header)
  5509. }
  5510. return c.header_
  5511. }
  5512. func (c *ProjectsTopicsSubscriptionsListCall) doRequest(alt string) (*http.Response, error) {
  5513. reqHeaders := make(http.Header)
  5514. for k, v := range c.header_ {
  5515. reqHeaders[k] = v
  5516. }
  5517. reqHeaders.Set("User-Agent", c.s.userAgent())
  5518. if c.ifNoneMatch_ != "" {
  5519. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  5520. }
  5521. var body io.Reader = nil
  5522. c.urlParams_.Set("alt", alt)
  5523. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+topic}/subscriptions")
  5524. urls += "?" + c.urlParams_.Encode()
  5525. req, _ := http.NewRequest("GET", urls, body)
  5526. req.Header = reqHeaders
  5527. googleapi.Expand(req.URL, map[string]string{
  5528. "topic": c.topic,
  5529. })
  5530. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  5531. }
  5532. // Do executes the "pubsub.projects.topics.subscriptions.list" call.
  5533. // Exactly one of *ListTopicSubscriptionsResponse or error will be
  5534. // non-nil. Any non-2xx status code is an error. Response headers are in
  5535. // either *ListTopicSubscriptionsResponse.ServerResponse.Header or (if a
  5536. // response was returned at all) in error.(*googleapi.Error).Header. Use
  5537. // googleapi.IsNotModified to check whether the returned error was
  5538. // because http.StatusNotModified was returned.
  5539. func (c *ProjectsTopicsSubscriptionsListCall) Do(opts ...googleapi.CallOption) (*ListTopicSubscriptionsResponse, error) {
  5540. gensupport.SetOptions(c.urlParams_, opts...)
  5541. res, err := c.doRequest("json")
  5542. if res != nil && res.StatusCode == http.StatusNotModified {
  5543. if res.Body != nil {
  5544. res.Body.Close()
  5545. }
  5546. return nil, &googleapi.Error{
  5547. Code: res.StatusCode,
  5548. Header: res.Header,
  5549. }
  5550. }
  5551. if err != nil {
  5552. return nil, err
  5553. }
  5554. defer googleapi.CloseBody(res)
  5555. if err := googleapi.CheckResponse(res); err != nil {
  5556. return nil, err
  5557. }
  5558. ret := &ListTopicSubscriptionsResponse{
  5559. ServerResponse: googleapi.ServerResponse{
  5560. Header: res.Header,
  5561. HTTPStatusCode: res.StatusCode,
  5562. },
  5563. }
  5564. target := &ret
  5565. if err := gensupport.DecodeResponse(target, res); err != nil {
  5566. return nil, err
  5567. }
  5568. return ret, nil
  5569. // {
  5570. // "description": "Lists the names of the subscriptions on this topic.",
  5571. // "flatPath": "v1/projects/{projectsId}/topics/{topicsId}/subscriptions",
  5572. // "httpMethod": "GET",
  5573. // "id": "pubsub.projects.topics.subscriptions.list",
  5574. // "parameterOrder": [
  5575. // "topic"
  5576. // ],
  5577. // "parameters": {
  5578. // "pageSize": {
  5579. // "description": "Maximum number of subscription names to return.",
  5580. // "format": "int32",
  5581. // "location": "query",
  5582. // "type": "integer"
  5583. // },
  5584. // "pageToken": {
  5585. // "description": "The value returned by the last `ListTopicSubscriptionsResponse`; indicates\nthat this is a continuation of a prior `ListTopicSubscriptions` call, and\nthat the system should return the next page of data.",
  5586. // "location": "query",
  5587. // "type": "string"
  5588. // },
  5589. // "topic": {
  5590. // "description": "The name of the topic that subscriptions are attached to.\nFormat is `projects/{project}/topics/{topic}`.",
  5591. // "location": "path",
  5592. // "pattern": "^projects/[^/]+/topics/[^/]+$",
  5593. // "required": true,
  5594. // "type": "string"
  5595. // }
  5596. // },
  5597. // "path": "v1/{+topic}/subscriptions",
  5598. // "response": {
  5599. // "$ref": "ListTopicSubscriptionsResponse"
  5600. // },
  5601. // "scopes": [
  5602. // "https://www.googleapis.com/auth/cloud-platform",
  5603. // "https://www.googleapis.com/auth/pubsub"
  5604. // ]
  5605. // }
  5606. }
  5607. // Pages invokes f for each page of results.
  5608. // A non-nil error returned from f will halt the iteration.
  5609. // The provided context supersedes any context provided to the Context method.
  5610. func (c *ProjectsTopicsSubscriptionsListCall) Pages(ctx context.Context, f func(*ListTopicSubscriptionsResponse) error) error {
  5611. c.ctx_ = ctx
  5612. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  5613. for {
  5614. x, err := c.Do()
  5615. if err != nil {
  5616. return err
  5617. }
  5618. if err := f(x); err != nil {
  5619. return err
  5620. }
  5621. if x.NextPageToken == "" {
  5622. return nil
  5623. }
  5624. c.PageToken(x.NextPageToken)
  5625. }
  5626. }