選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

4233 行
146 KiB

  1. // Copyright 2019 Google LLC.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Code generated file. DO NOT EDIT.
  5. // Package pubsub provides access to the Cloud Pub/Sub API.
  6. //
  7. // This package is DEPRECATED. Use package cloud.google.com/go/pubsub instead.
  8. //
  9. // For product documentation, see: https://cloud.google.com/pubsub/docs
  10. //
  11. // Creating a client
  12. //
  13. // Usage example:
  14. //
  15. // import "google.golang.org/api/pubsub/v1beta2"
  16. // ...
  17. // ctx := context.Background()
  18. // pubsubService, err := pubsub.NewService(ctx)
  19. //
  20. // In this example, Google Application Default Credentials are used for authentication.
  21. //
  22. // For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
  23. //
  24. // Other authentication options
  25. //
  26. // By default, all available scopes (see "Constants") are used to authenticate. To restrict scopes, use option.WithScopes:
  27. //
  28. // pubsubService, err := pubsub.NewService(ctx, option.WithScopes(pubsub.PubsubScope))
  29. //
  30. // To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
  31. //
  32. // pubsubService, err := pubsub.NewService(ctx, option.WithAPIKey("AIza..."))
  33. //
  34. // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:
  35. //
  36. // config := &oauth2.Config{...}
  37. // // ...
  38. // token, err := config.Exchange(ctx, ...)
  39. // pubsubService, err := pubsub.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
  40. //
  41. // See https://godoc.org/google.golang.org/api/option/ for details on options.
  42. package pubsub // import "google.golang.org/api/pubsub/v1beta2"
  43. import (
  44. "bytes"
  45. "context"
  46. "encoding/json"
  47. "errors"
  48. "fmt"
  49. "io"
  50. "net/http"
  51. "net/url"
  52. "strconv"
  53. "strings"
  54. gensupport "google.golang.org/api/gensupport"
  55. googleapi "google.golang.org/api/googleapi"
  56. option "google.golang.org/api/option"
  57. htransport "google.golang.org/api/transport/http"
  58. )
  59. // Always reference these packages, just in case the auto-generated code
  60. // below doesn't.
  61. var _ = bytes.NewBuffer
  62. var _ = strconv.Itoa
  63. var _ = fmt.Sprintf
  64. var _ = json.NewDecoder
  65. var _ = io.Copy
  66. var _ = url.Parse
  67. var _ = gensupport.MarshalJSON
  68. var _ = googleapi.Version
  69. var _ = errors.New
  70. var _ = strings.Replace
  71. var _ = context.Canceled
  72. const apiId = "pubsub:v1beta2"
  73. const apiName = "pubsub"
  74. const apiVersion = "v1beta2"
  75. const basePath = "https://pubsub.googleapis.com/"
  76. // OAuth2 scopes used by this API.
  77. const (
  78. // View and manage your data across Google Cloud Platform services
  79. CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
  80. // View and manage Pub/Sub topics and subscriptions
  81. PubsubScope = "https://www.googleapis.com/auth/pubsub"
  82. )
  83. // NewService creates a new Service.
  84. func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
  85. scopesOption := option.WithScopes(
  86. "https://www.googleapis.com/auth/cloud-platform",
  87. "https://www.googleapis.com/auth/pubsub",
  88. )
  89. // NOTE: prepend, so we don't override user-specified scopes.
  90. opts = append([]option.ClientOption{scopesOption}, opts...)
  91. client, endpoint, err := htransport.NewClient(ctx, opts...)
  92. if err != nil {
  93. return nil, err
  94. }
  95. s, err := New(client)
  96. if err != nil {
  97. return nil, err
  98. }
  99. if endpoint != "" {
  100. s.BasePath = endpoint
  101. }
  102. return s, nil
  103. }
  104. // New creates a new Service. It uses the provided http.Client for requests.
  105. //
  106. // Deprecated: please use NewService instead.
  107. // To provide a custom HTTP client, use option.WithHTTPClient.
  108. // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
  109. func New(client *http.Client) (*Service, error) {
  110. if client == nil {
  111. return nil, errors.New("client is nil")
  112. }
  113. s := &Service{client: client, BasePath: basePath}
  114. s.Projects = NewProjectsService(s)
  115. return s, nil
  116. }
  117. type Service struct {
  118. client *http.Client
  119. BasePath string // API endpoint base URL
  120. UserAgent string // optional additional User-Agent fragment
  121. Projects *ProjectsService
  122. }
  123. func (s *Service) userAgent() string {
  124. if s.UserAgent == "" {
  125. return googleapi.UserAgent
  126. }
  127. return googleapi.UserAgent + " " + s.UserAgent
  128. }
  129. func NewProjectsService(s *Service) *ProjectsService {
  130. rs := &ProjectsService{s: s}
  131. rs.Subscriptions = NewProjectsSubscriptionsService(s)
  132. rs.Topics = NewProjectsTopicsService(s)
  133. return rs
  134. }
  135. type ProjectsService struct {
  136. s *Service
  137. Subscriptions *ProjectsSubscriptionsService
  138. Topics *ProjectsTopicsService
  139. }
  140. func NewProjectsSubscriptionsService(s *Service) *ProjectsSubscriptionsService {
  141. rs := &ProjectsSubscriptionsService{s: s}
  142. return rs
  143. }
  144. type ProjectsSubscriptionsService struct {
  145. s *Service
  146. }
  147. func NewProjectsTopicsService(s *Service) *ProjectsTopicsService {
  148. rs := &ProjectsTopicsService{s: s}
  149. rs.Subscriptions = NewProjectsTopicsSubscriptionsService(s)
  150. return rs
  151. }
  152. type ProjectsTopicsService struct {
  153. s *Service
  154. Subscriptions *ProjectsTopicsSubscriptionsService
  155. }
  156. func NewProjectsTopicsSubscriptionsService(s *Service) *ProjectsTopicsSubscriptionsService {
  157. rs := &ProjectsTopicsSubscriptionsService{s: s}
  158. return rs
  159. }
  160. type ProjectsTopicsSubscriptionsService struct {
  161. s *Service
  162. }
  163. // AcknowledgeRequest: Request for the Acknowledge method.
  164. type AcknowledgeRequest struct {
  165. // AckIds: The acknowledgment ID for the messages being acknowledged
  166. // that was returned
  167. // by the Pub/Sub system in the `Pull` response. Must not be empty.
  168. AckIds []string `json:"ackIds,omitempty"`
  169. // ForceSendFields is a list of field names (e.g. "AckIds") to
  170. // unconditionally include in API requests. By default, fields with
  171. // empty values are omitted from API requests. However, any non-pointer,
  172. // non-interface field appearing in ForceSendFields will be sent to the
  173. // server regardless of whether the field is empty or not. This may be
  174. // used to include empty fields in Patch requests.
  175. ForceSendFields []string `json:"-"`
  176. // NullFields is a list of field names (e.g. "AckIds") to include in API
  177. // requests with the JSON null value. By default, fields with empty
  178. // values are omitted from API requests. However, any field with an
  179. // empty value appearing in NullFields will be sent to the server as
  180. // null. It is an error if a field in this list has a non-empty value.
  181. // This may be used to include null fields in Patch requests.
  182. NullFields []string `json:"-"`
  183. }
  184. func (s *AcknowledgeRequest) MarshalJSON() ([]byte, error) {
  185. type NoMethod AcknowledgeRequest
  186. raw := NoMethod(*s)
  187. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  188. }
  189. // Binding: Associates `members` with a `role`.
  190. type Binding struct {
  191. // Condition: Unimplemented. The condition that is associated with this
  192. // binding.
  193. // NOTE: an unsatisfied condition will not allow user access via
  194. // current
  195. // binding. Different bindings, including their conditions, are
  196. // examined
  197. // independently.
  198. Condition *Expr `json:"condition,omitempty"`
  199. // Members: Specifies the identities requesting access for a Cloud
  200. // Platform resource.
  201. // `members` can have the following values:
  202. //
  203. // * `allUsers`: A special identifier that represents anyone who is
  204. // on the internet; with or without a Google account.
  205. //
  206. // * `allAuthenticatedUsers`: A special identifier that represents
  207. // anyone
  208. // who is authenticated with a Google account or a service
  209. // account.
  210. //
  211. // * `user:{emailid}`: An email address that represents a specific
  212. // Google
  213. // account. For example, `alice@gmail.com` .
  214. //
  215. //
  216. // * `serviceAccount:{emailid}`: An email address that represents a
  217. // service
  218. // account. For example,
  219. // `my-other-app@appspot.gserviceaccount.com`.
  220. //
  221. // * `group:{emailid}`: An email address that represents a Google
  222. // group.
  223. // For example, `admins@example.com`.
  224. //
  225. //
  226. // * `domain:{domain}`: The G Suite domain (primary) that represents all
  227. // the
  228. // users of that domain. For example, `google.com` or
  229. // `example.com`.
  230. //
  231. //
  232. Members []string `json:"members,omitempty"`
  233. // Role: Role that is assigned to `members`.
  234. // For example, `roles/viewer`, `roles/editor`, or `roles/owner`.
  235. Role string `json:"role,omitempty"`
  236. // ForceSendFields is a list of field names (e.g. "Condition") to
  237. // unconditionally include in API requests. By default, fields with
  238. // empty values are omitted from API requests. However, any non-pointer,
  239. // non-interface field appearing in ForceSendFields will be sent to the
  240. // server regardless of whether the field is empty or not. This may be
  241. // used to include empty fields in Patch requests.
  242. ForceSendFields []string `json:"-"`
  243. // NullFields is a list of field names (e.g. "Condition") to include in
  244. // API requests with the JSON null value. By default, fields with empty
  245. // values are omitted from API requests. However, any field with an
  246. // empty value appearing in NullFields will be sent to the server as
  247. // null. It is an error if a field in this list has a non-empty value.
  248. // This may be used to include null fields in Patch requests.
  249. NullFields []string `json:"-"`
  250. }
  251. func (s *Binding) MarshalJSON() ([]byte, error) {
  252. type NoMethod Binding
  253. raw := NoMethod(*s)
  254. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  255. }
  256. // Empty: A generic empty message that you can re-use to avoid defining
  257. // duplicated
  258. // empty messages in your APIs. A typical example is to use it as the
  259. // request
  260. // or the response type of an API method. For instance:
  261. //
  262. // service Foo {
  263. // rpc Bar(google.protobuf.Empty) returns
  264. // (google.protobuf.Empty);
  265. // }
  266. //
  267. // The JSON representation for `Empty` is empty JSON object `{}`.
  268. type Empty struct {
  269. // ServerResponse contains the HTTP response code and headers from the
  270. // server.
  271. googleapi.ServerResponse `json:"-"`
  272. }
  273. // Expr: Represents an expression text. Example:
  274. //
  275. // title: "User account presence"
  276. // description: "Determines whether the request has a user account"
  277. // expression: "size(request.user) > 0"
  278. type Expr struct {
  279. // Description: An optional description of the expression. This is a
  280. // longer text which
  281. // describes the expression, e.g. when hovered over it in a UI.
  282. Description string `json:"description,omitempty"`
  283. // Expression: Textual representation of an expression in
  284. // Common Expression Language syntax.
  285. //
  286. // The application context of the containing message determines
  287. // which
  288. // well-known feature set of CEL is supported.
  289. Expression string `json:"expression,omitempty"`
  290. // Location: An optional string indicating the location of the
  291. // expression for error
  292. // reporting, e.g. a file name and a position in the file.
  293. Location string `json:"location,omitempty"`
  294. // Title: An optional title for the expression, i.e. a short string
  295. // describing
  296. // its purpose. This can be used e.g. in UIs which allow to enter
  297. // the
  298. // expression.
  299. Title string `json:"title,omitempty"`
  300. // ForceSendFields is a list of field names (e.g. "Description") to
  301. // unconditionally include in API requests. By default, fields with
  302. // empty values are omitted from API requests. However, any non-pointer,
  303. // non-interface field appearing in ForceSendFields will be sent to the
  304. // server regardless of whether the field is empty or not. This may be
  305. // used to include empty fields in Patch requests.
  306. ForceSendFields []string `json:"-"`
  307. // NullFields is a list of field names (e.g. "Description") to include
  308. // in API requests with the JSON null value. By default, fields with
  309. // empty values are omitted from API requests. However, any field with
  310. // an empty value appearing in NullFields will be sent to the server as
  311. // null. It is an error if a field in this list has a non-empty value.
  312. // This may be used to include null fields in Patch requests.
  313. NullFields []string `json:"-"`
  314. }
  315. func (s *Expr) MarshalJSON() ([]byte, error) {
  316. type NoMethod Expr
  317. raw := NoMethod(*s)
  318. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  319. }
  320. // ListSubscriptionsResponse: Response for the `ListSubscriptions`
  321. // method.
  322. type ListSubscriptionsResponse struct {
  323. // NextPageToken: If not empty, indicates that there may be more
  324. // subscriptions that match
  325. // the request; this value should be passed in a
  326. // new
  327. // `ListSubscriptionsRequest` to get more subscriptions.
  328. NextPageToken string `json:"nextPageToken,omitempty"`
  329. // Subscriptions: The subscriptions that match the request.
  330. Subscriptions []*Subscription `json:"subscriptions,omitempty"`
  331. // ServerResponse contains the HTTP response code and headers from the
  332. // server.
  333. googleapi.ServerResponse `json:"-"`
  334. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  335. // unconditionally include in API requests. By default, fields with
  336. // empty values are omitted from API requests. However, any non-pointer,
  337. // non-interface field appearing in ForceSendFields will be sent to the
  338. // server regardless of whether the field is empty or not. This may be
  339. // used to include empty fields in Patch requests.
  340. ForceSendFields []string `json:"-"`
  341. // NullFields is a list of field names (e.g. "NextPageToken") to include
  342. // in API requests with the JSON null value. By default, fields with
  343. // empty values are omitted from API requests. However, any field with
  344. // an empty value appearing in NullFields will be sent to the server as
  345. // null. It is an error if a field in this list has a non-empty value.
  346. // This may be used to include null fields in Patch requests.
  347. NullFields []string `json:"-"`
  348. }
  349. func (s *ListSubscriptionsResponse) MarshalJSON() ([]byte, error) {
  350. type NoMethod ListSubscriptionsResponse
  351. raw := NoMethod(*s)
  352. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  353. }
  354. // ListTopicSubscriptionsResponse: Response for the
  355. // `ListTopicSubscriptions` method.
  356. type ListTopicSubscriptionsResponse struct {
  357. // NextPageToken: If not empty, indicates that there may be more
  358. // subscriptions that match
  359. // the request; this value should be passed in a
  360. // new
  361. // `ListTopicSubscriptionsRequest` to get more subscriptions.
  362. NextPageToken string `json:"nextPageToken,omitempty"`
  363. // Subscriptions: The names of the subscriptions that match the request.
  364. Subscriptions []string `json:"subscriptions,omitempty"`
  365. // ServerResponse contains the HTTP response code and headers from the
  366. // server.
  367. googleapi.ServerResponse `json:"-"`
  368. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  369. // unconditionally include in API requests. By default, fields with
  370. // empty values are omitted from API requests. However, any non-pointer,
  371. // non-interface field appearing in ForceSendFields will be sent to the
  372. // server regardless of whether the field is empty or not. This may be
  373. // used to include empty fields in Patch requests.
  374. ForceSendFields []string `json:"-"`
  375. // NullFields is a list of field names (e.g. "NextPageToken") to include
  376. // in API requests with the JSON null value. By default, fields with
  377. // empty values are omitted from API requests. However, any field with
  378. // an empty value appearing in NullFields will be sent to the server as
  379. // null. It is an error if a field in this list has a non-empty value.
  380. // This may be used to include null fields in Patch requests.
  381. NullFields []string `json:"-"`
  382. }
  383. func (s *ListTopicSubscriptionsResponse) MarshalJSON() ([]byte, error) {
  384. type NoMethod ListTopicSubscriptionsResponse
  385. raw := NoMethod(*s)
  386. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  387. }
  388. // ListTopicsResponse: Response for the `ListTopics` method.
  389. type ListTopicsResponse struct {
  390. // NextPageToken: If not empty, indicates that there may be more topics
  391. // that match the
  392. // request; this value should be passed in a new `ListTopicsRequest`.
  393. NextPageToken string `json:"nextPageToken,omitempty"`
  394. // Topics: The resulting topics.
  395. Topics []*Topic `json:"topics,omitempty"`
  396. // ServerResponse contains the HTTP response code and headers from the
  397. // server.
  398. googleapi.ServerResponse `json:"-"`
  399. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  400. // unconditionally include in API requests. By default, fields with
  401. // empty values are omitted from API requests. However, any non-pointer,
  402. // non-interface field appearing in ForceSendFields will be sent to the
  403. // server regardless of whether the field is empty or not. This may be
  404. // used to include empty fields in Patch requests.
  405. ForceSendFields []string `json:"-"`
  406. // NullFields is a list of field names (e.g. "NextPageToken") to include
  407. // in API requests with the JSON null value. By default, fields with
  408. // empty values are omitted from API requests. However, any field with
  409. // an empty value appearing in NullFields will be sent to the server as
  410. // null. It is an error if a field in this list has a non-empty value.
  411. // This may be used to include null fields in Patch requests.
  412. NullFields []string `json:"-"`
  413. }
  414. func (s *ListTopicsResponse) MarshalJSON() ([]byte, error) {
  415. type NoMethod ListTopicsResponse
  416. raw := NoMethod(*s)
  417. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  418. }
  419. // ModifyAckDeadlineRequest: Request for the ModifyAckDeadline method.
  420. type ModifyAckDeadlineRequest struct {
  421. // AckDeadlineSeconds: The new ack deadline with respect to the time
  422. // this request was sent to
  423. // the Pub/Sub system. Must be >= 0. For example, if the value is 10,
  424. // the new
  425. // ack deadline will expire 10 seconds after the `ModifyAckDeadline`
  426. // call
  427. // was made. Specifying zero may immediately make the message available
  428. // for
  429. // another pull request.
  430. AckDeadlineSeconds int64 `json:"ackDeadlineSeconds,omitempty"`
  431. // AckId: The acknowledgment ID. Either this or ack_ids must be
  432. // populated, but not
  433. // both.
  434. AckId string `json:"ackId,omitempty"`
  435. // AckIds: List of acknowledgment IDs.
  436. AckIds []string `json:"ackIds,omitempty"`
  437. // ForceSendFields is a list of field names (e.g. "AckDeadlineSeconds")
  438. // to unconditionally include in API requests. By default, fields with
  439. // empty values are omitted from API requests. However, any non-pointer,
  440. // non-interface field appearing in ForceSendFields will be sent to the
  441. // server regardless of whether the field is empty or not. This may be
  442. // used to include empty fields in Patch requests.
  443. ForceSendFields []string `json:"-"`
  444. // NullFields is a list of field names (e.g. "AckDeadlineSeconds") to
  445. // include in API requests with the JSON null value. By default, fields
  446. // with empty values are omitted from API requests. However, any field
  447. // with an empty value appearing in NullFields will be sent to the
  448. // server as null. It is an error if a field in this list has a
  449. // non-empty value. This may be used to include null fields in Patch
  450. // requests.
  451. NullFields []string `json:"-"`
  452. }
  453. func (s *ModifyAckDeadlineRequest) MarshalJSON() ([]byte, error) {
  454. type NoMethod ModifyAckDeadlineRequest
  455. raw := NoMethod(*s)
  456. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  457. }
  458. // ModifyPushConfigRequest: Request for the ModifyPushConfig method.
  459. type ModifyPushConfigRequest struct {
  460. // PushConfig: The push configuration for future deliveries.
  461. //
  462. // An empty `pushConfig` indicates that the Pub/Sub system should
  463. // stop pushing messages from the given subscription and allow
  464. // messages to be pulled and acknowledged - effectively pausing
  465. // the subscription if `Pull` is not called.
  466. PushConfig *PushConfig `json:"pushConfig,omitempty"`
  467. // ForceSendFields is a list of field names (e.g. "PushConfig") to
  468. // unconditionally include in API requests. By default, fields with
  469. // empty values are omitted from API requests. However, any non-pointer,
  470. // non-interface field appearing in ForceSendFields will be sent to the
  471. // server regardless of whether the field is empty or not. This may be
  472. // used to include empty fields in Patch requests.
  473. ForceSendFields []string `json:"-"`
  474. // NullFields is a list of field names (e.g. "PushConfig") to include in
  475. // API requests with the JSON null value. By default, fields with empty
  476. // values are omitted from API requests. However, any field with an
  477. // empty value appearing in NullFields will be sent to the server as
  478. // null. It is an error if a field in this list has a non-empty value.
  479. // This may be used to include null fields in Patch requests.
  480. NullFields []string `json:"-"`
  481. }
  482. func (s *ModifyPushConfigRequest) MarshalJSON() ([]byte, error) {
  483. type NoMethod ModifyPushConfigRequest
  484. raw := NoMethod(*s)
  485. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  486. }
  487. // Policy: Defines an Identity and Access Management (IAM) policy. It is
  488. // used to
  489. // specify access control policies for Cloud Platform resources.
  490. //
  491. //
  492. // A `Policy` consists of a list of `bindings`. A `binding` binds a list
  493. // of
  494. // `members` to a `role`, where the members can be user accounts, Google
  495. // groups,
  496. // Google domains, and service accounts. A `role` is a named list of
  497. // permissions
  498. // defined by IAM.
  499. //
  500. // **JSON Example**
  501. //
  502. // {
  503. // "bindings": [
  504. // {
  505. // "role": "roles/owner",
  506. // "members": [
  507. // "user:mike@example.com",
  508. // "group:admins@example.com",
  509. // "domain:google.com",
  510. //
  511. // "serviceAccount:my-other-app@appspot.gserviceaccount.com"
  512. // ]
  513. // },
  514. // {
  515. // "role": "roles/viewer",
  516. // "members": ["user:sean@example.com"]
  517. // }
  518. // ]
  519. // }
  520. //
  521. // **YAML Example**
  522. //
  523. // bindings:
  524. // - members:
  525. // - user:mike@example.com
  526. // - group:admins@example.com
  527. // - domain:google.com
  528. // - serviceAccount:my-other-app@appspot.gserviceaccount.com
  529. // role: roles/owner
  530. // - members:
  531. // - user:sean@example.com
  532. // role: roles/viewer
  533. //
  534. //
  535. // For a description of IAM and its features, see the
  536. // [IAM developer's guide](https://cloud.google.com/iam/docs).
  537. type Policy struct {
  538. // Bindings: Associates a list of `members` to a `role`.
  539. // `bindings` with no members will result in an error.
  540. Bindings []*Binding `json:"bindings,omitempty"`
  541. // Etag: `etag` is used for optimistic concurrency control as a way to
  542. // help
  543. // prevent simultaneous updates of a policy from overwriting each
  544. // other.
  545. // It is strongly suggested that systems make use of the `etag` in
  546. // the
  547. // read-modify-write cycle to perform policy updates in order to avoid
  548. // race
  549. // conditions: An `etag` is returned in the response to `getIamPolicy`,
  550. // and
  551. // systems are expected to put that etag in the request to
  552. // `setIamPolicy` to
  553. // ensure that their change will be applied to the same version of the
  554. // policy.
  555. //
  556. // If no `etag` is provided in the call to `setIamPolicy`, then the
  557. // existing
  558. // policy is overwritten blindly.
  559. Etag string `json:"etag,omitempty"`
  560. // Version: Deprecated.
  561. Version int64 `json:"version,omitempty"`
  562. // ServerResponse contains the HTTP response code and headers from the
  563. // server.
  564. googleapi.ServerResponse `json:"-"`
  565. // ForceSendFields is a list of field names (e.g. "Bindings") to
  566. // unconditionally include in API requests. By default, fields with
  567. // empty values are omitted from API requests. However, any non-pointer,
  568. // non-interface field appearing in ForceSendFields will be sent to the
  569. // server regardless of whether the field is empty or not. This may be
  570. // used to include empty fields in Patch requests.
  571. ForceSendFields []string `json:"-"`
  572. // NullFields is a list of field names (e.g. "Bindings") to include in
  573. // API requests with the JSON null value. By default, fields with empty
  574. // values are omitted from API requests. However, any field with an
  575. // empty value appearing in NullFields will be sent to the server as
  576. // null. It is an error if a field in this list has a non-empty value.
  577. // This may be used to include null fields in Patch requests.
  578. NullFields []string `json:"-"`
  579. }
  580. func (s *Policy) MarshalJSON() ([]byte, error) {
  581. type NoMethod Policy
  582. raw := NoMethod(*s)
  583. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  584. }
  585. // PublishRequest: Request for the Publish method.
  586. type PublishRequest struct {
  587. // Messages: The messages to publish.
  588. Messages []*PubsubMessage `json:"messages,omitempty"`
  589. // ForceSendFields is a list of field names (e.g. "Messages") to
  590. // unconditionally include in API requests. By default, fields with
  591. // empty values are omitted from API requests. However, any non-pointer,
  592. // non-interface field appearing in ForceSendFields will be sent to the
  593. // server regardless of whether the field is empty or not. This may be
  594. // used to include empty fields in Patch requests.
  595. ForceSendFields []string `json:"-"`
  596. // NullFields is a list of field names (e.g. "Messages") to include in
  597. // API requests with the JSON null value. By default, fields with empty
  598. // values are omitted from API requests. However, any field with an
  599. // empty value appearing in NullFields will be sent to the server as
  600. // null. It is an error if a field in this list has a non-empty value.
  601. // This may be used to include null fields in Patch requests.
  602. NullFields []string `json:"-"`
  603. }
  604. func (s *PublishRequest) MarshalJSON() ([]byte, error) {
  605. type NoMethod PublishRequest
  606. raw := NoMethod(*s)
  607. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  608. }
  609. // PublishResponse: Response for the `Publish` method.
  610. type PublishResponse struct {
  611. // MessageIds: The server-assigned ID of each published message, in the
  612. // same order as
  613. // the messages in the request. IDs are guaranteed to be unique
  614. // within
  615. // the topic.
  616. MessageIds []string `json:"messageIds,omitempty"`
  617. // ServerResponse contains the HTTP response code and headers from the
  618. // server.
  619. googleapi.ServerResponse `json:"-"`
  620. // ForceSendFields is a list of field names (e.g. "MessageIds") to
  621. // unconditionally include in API requests. By default, fields with
  622. // empty values are omitted from API requests. However, any non-pointer,
  623. // non-interface field appearing in ForceSendFields will be sent to the
  624. // server regardless of whether the field is empty or not. This may be
  625. // used to include empty fields in Patch requests.
  626. ForceSendFields []string `json:"-"`
  627. // NullFields is a list of field names (e.g. "MessageIds") to include in
  628. // API requests with the JSON null value. By default, fields with empty
  629. // values are omitted from API requests. However, any field with an
  630. // empty value appearing in NullFields will be sent to the server as
  631. // null. It is an error if a field in this list has a non-empty value.
  632. // This may be used to include null fields in Patch requests.
  633. NullFields []string `json:"-"`
  634. }
  635. func (s *PublishResponse) MarshalJSON() ([]byte, error) {
  636. type NoMethod PublishResponse
  637. raw := NoMethod(*s)
  638. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  639. }
  640. // PubsubMessage: A message data and its attributes. The message payload
  641. // must not be empty;
  642. // it must contain either a non-empty data field, or at least one
  643. // attribute.
  644. type PubsubMessage struct {
  645. // Attributes: Optional attributes for this message.
  646. Attributes map[string]string `json:"attributes,omitempty"`
  647. // Data: The message payload. For JSON requests, the value of this field
  648. // must be
  649. // [base64-encoded](https://tools.ietf.org/html/rfc4648).
  650. Data string `json:"data,omitempty"`
  651. // MessageId: ID of this message, assigned by the server when the
  652. // message is published.
  653. // Guaranteed to be unique within the topic. This value may be read by
  654. // a
  655. // subscriber that receives a `PubsubMessage` via a `Pull` call or a
  656. // push
  657. // delivery. It must not be populated by the publisher in a `Publish`
  658. // call.
  659. MessageId string `json:"messageId,omitempty"`
  660. // PublishTime: The time at which the message was published, populated
  661. // by the server when
  662. // it receives the `Publish` call. It must not be populated by
  663. // the
  664. // publisher in a `Publish` call.
  665. PublishTime string `json:"publishTime,omitempty"`
  666. // ForceSendFields is a list of field names (e.g. "Attributes") to
  667. // unconditionally include in API requests. By default, fields with
  668. // empty values are omitted from API requests. However, any non-pointer,
  669. // non-interface field appearing in ForceSendFields will be sent to the
  670. // server regardless of whether the field is empty or not. This may be
  671. // used to include empty fields in Patch requests.
  672. ForceSendFields []string `json:"-"`
  673. // NullFields is a list of field names (e.g. "Attributes") to include in
  674. // API requests with the JSON null value. By default, fields with empty
  675. // values are omitted from API requests. However, any field with an
  676. // empty value appearing in NullFields will be sent to the server as
  677. // null. It is an error if a field in this list has a non-empty value.
  678. // This may be used to include null fields in Patch requests.
  679. NullFields []string `json:"-"`
  680. }
  681. func (s *PubsubMessage) MarshalJSON() ([]byte, error) {
  682. type NoMethod PubsubMessage
  683. raw := NoMethod(*s)
  684. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  685. }
  686. // PullRequest: Request for the `Pull` method.
  687. type PullRequest struct {
  688. // MaxMessages: The maximum number of messages returned for this
  689. // request. The Pub/Sub
  690. // system may return fewer than the number specified.
  691. MaxMessages int64 `json:"maxMessages,omitempty"`
  692. // ReturnImmediately: If this is specified as true the system will
  693. // respond immediately even if
  694. // it is not able to return a message in the `Pull` response. Otherwise
  695. // the
  696. // system is allowed to wait until at least one message is available
  697. // rather
  698. // than returning no messages. The client may cancel the request if it
  699. // does
  700. // not wish to wait any longer for the response.
  701. ReturnImmediately bool `json:"returnImmediately,omitempty"`
  702. // ForceSendFields is a list of field names (e.g. "MaxMessages") to
  703. // unconditionally include in API requests. By default, fields with
  704. // empty values are omitted from API requests. However, any non-pointer,
  705. // non-interface field appearing in ForceSendFields will be sent to the
  706. // server regardless of whether the field is empty or not. This may be
  707. // used to include empty fields in Patch requests.
  708. ForceSendFields []string `json:"-"`
  709. // NullFields is a list of field names (e.g. "MaxMessages") to include
  710. // in API requests with the JSON null value. By default, fields with
  711. // empty values are omitted from API requests. However, any field with
  712. // an empty value appearing in NullFields will be sent to the server as
  713. // null. It is an error if a field in this list has a non-empty value.
  714. // This may be used to include null fields in Patch requests.
  715. NullFields []string `json:"-"`
  716. }
  717. func (s *PullRequest) MarshalJSON() ([]byte, error) {
  718. type NoMethod PullRequest
  719. raw := NoMethod(*s)
  720. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  721. }
  722. // PullResponse: Response for the `Pull` method.
  723. type PullResponse struct {
  724. // ReceivedMessages: Received Pub/Sub messages. The Pub/Sub system will
  725. // return zero messages if
  726. // there are no more available in the backlog. The Pub/Sub system may
  727. // return
  728. // fewer than the `maxMessages` requested even if there are more
  729. // messages
  730. // available in the backlog.
  731. ReceivedMessages []*ReceivedMessage `json:"receivedMessages,omitempty"`
  732. // ServerResponse contains the HTTP response code and headers from the
  733. // server.
  734. googleapi.ServerResponse `json:"-"`
  735. // ForceSendFields is a list of field names (e.g. "ReceivedMessages") to
  736. // unconditionally include in API requests. By default, fields with
  737. // empty values are omitted from API requests. However, any non-pointer,
  738. // non-interface field appearing in ForceSendFields will be sent to the
  739. // server regardless of whether the field is empty or not. This may be
  740. // used to include empty fields in Patch requests.
  741. ForceSendFields []string `json:"-"`
  742. // NullFields is a list of field names (e.g. "ReceivedMessages") to
  743. // include in API requests with the JSON null value. By default, fields
  744. // with empty values are omitted from API requests. However, any field
  745. // with an empty value appearing in NullFields will be sent to the
  746. // server as null. It is an error if a field in this list has a
  747. // non-empty value. This may be used to include null fields in Patch
  748. // requests.
  749. NullFields []string `json:"-"`
  750. }
  751. func (s *PullResponse) MarshalJSON() ([]byte, error) {
  752. type NoMethod PullResponse
  753. raw := NoMethod(*s)
  754. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  755. }
  756. // PushConfig: Configuration for a push delivery endpoint.
  757. type PushConfig struct {
  758. // Attributes: Endpoint configuration attributes.
  759. //
  760. // Every endpoint has a set of API supported attributes that can be used
  761. // to
  762. // control different aspects of the message delivery.
  763. //
  764. // The currently supported attribute is `x-goog-version`, which you
  765. // can
  766. // use to change the format of the push message. This
  767. // attribute
  768. // indicates the version of the data expected by the endpoint.
  769. // This
  770. // controls the shape of the envelope (i.e. its fields and
  771. // metadata).
  772. // The endpoint version is based on the version of the Pub/Sub
  773. // API.
  774. //
  775. // If not present during the `CreateSubscription` call, it will default
  776. // to
  777. // the version of the API used to make such call. If not present during
  778. // a
  779. // `ModifyPushConfig` call, its value will not be changed.
  780. // `GetSubscription`
  781. // calls will always return a valid version, even if the subscription
  782. // was
  783. // created without this attribute.
  784. //
  785. // The possible values for this attribute are:
  786. //
  787. // * `v1beta1`: uses the push format defined in the v1beta1 Pub/Sub
  788. // API.
  789. // * `v1` or `v1beta2`: uses the push format defined in the v1 Pub/Sub
  790. // API.
  791. Attributes map[string]string `json:"attributes,omitempty"`
  792. // PushEndpoint: A URL locating the endpoint to which messages should be
  793. // pushed.
  794. // For example, a Webhook endpoint might use "https://example.com/push".
  795. PushEndpoint string `json:"pushEndpoint,omitempty"`
  796. // ForceSendFields is a list of field names (e.g. "Attributes") to
  797. // unconditionally include in API requests. By default, fields with
  798. // empty values are omitted from API requests. However, any non-pointer,
  799. // non-interface field appearing in ForceSendFields will be sent to the
  800. // server regardless of whether the field is empty or not. This may be
  801. // used to include empty fields in Patch requests.
  802. ForceSendFields []string `json:"-"`
  803. // NullFields is a list of field names (e.g. "Attributes") to include in
  804. // API requests with the JSON null value. By default, fields with empty
  805. // values are omitted from API requests. However, any field with an
  806. // empty value appearing in NullFields will be sent to the server as
  807. // null. It is an error if a field in this list has a non-empty value.
  808. // This may be used to include null fields in Patch requests.
  809. NullFields []string `json:"-"`
  810. }
  811. func (s *PushConfig) MarshalJSON() ([]byte, error) {
  812. type NoMethod PushConfig
  813. raw := NoMethod(*s)
  814. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  815. }
  816. // ReceivedMessage: A message and its corresponding acknowledgment ID.
  817. type ReceivedMessage struct {
  818. // AckId: This ID can be used to acknowledge the received message.
  819. AckId string `json:"ackId,omitempty"`
  820. // Message: The message.
  821. Message *PubsubMessage `json:"message,omitempty"`
  822. // ForceSendFields is a list of field names (e.g. "AckId") to
  823. // unconditionally include in API requests. By default, fields with
  824. // empty values are omitted from API requests. However, any non-pointer,
  825. // non-interface field appearing in ForceSendFields will be sent to the
  826. // server regardless of whether the field is empty or not. This may be
  827. // used to include empty fields in Patch requests.
  828. ForceSendFields []string `json:"-"`
  829. // NullFields is a list of field names (e.g. "AckId") to include in API
  830. // requests with the JSON null value. By default, fields with empty
  831. // values are omitted from API requests. However, any field with an
  832. // empty value appearing in NullFields will be sent to the server as
  833. // null. It is an error if a field in this list has a non-empty value.
  834. // This may be used to include null fields in Patch requests.
  835. NullFields []string `json:"-"`
  836. }
  837. func (s *ReceivedMessage) MarshalJSON() ([]byte, error) {
  838. type NoMethod ReceivedMessage
  839. raw := NoMethod(*s)
  840. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  841. }
  842. // SetIamPolicyRequest: Request message for `SetIamPolicy` method.
  843. type SetIamPolicyRequest struct {
  844. // Policy: REQUIRED: The complete policy to be applied to the
  845. // `resource`. The size of
  846. // the policy is limited to a few 10s of KB. An empty policy is a
  847. // valid policy but certain Cloud Platform services (such as
  848. // Projects)
  849. // might reject them.
  850. Policy *Policy `json:"policy,omitempty"`
  851. // ForceSendFields is a list of field names (e.g. "Policy") to
  852. // unconditionally include in API requests. By default, fields with
  853. // empty values are omitted from API requests. However, any non-pointer,
  854. // non-interface field appearing in ForceSendFields will be sent to the
  855. // server regardless of whether the field is empty or not. This may be
  856. // used to include empty fields in Patch requests.
  857. ForceSendFields []string `json:"-"`
  858. // NullFields is a list of field names (e.g. "Policy") to include in API
  859. // requests with the JSON null value. By default, fields with empty
  860. // values are omitted from API requests. However, any field with an
  861. // empty value appearing in NullFields will be sent to the server as
  862. // null. It is an error if a field in this list has a non-empty value.
  863. // This may be used to include null fields in Patch requests.
  864. NullFields []string `json:"-"`
  865. }
  866. func (s *SetIamPolicyRequest) MarshalJSON() ([]byte, error) {
  867. type NoMethod SetIamPolicyRequest
  868. raw := NoMethod(*s)
  869. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  870. }
  871. // Subscription: A subscription resource.
  872. type Subscription struct {
  873. // AckDeadlineSeconds: This value is the maximum time after a subscriber
  874. // receives a message
  875. // before the subscriber should acknowledge the message. After
  876. // message
  877. // delivery but before the ack deadline expires and before the message
  878. // is
  879. // acknowledged, it is an outstanding message and will not be
  880. // delivered
  881. // again during that time (on a best-effort basis).
  882. //
  883. // For pull subscriptions, this value is used as the initial value for
  884. // the ack
  885. // deadline. To override this value for a given message,
  886. // call
  887. // `ModifyAckDeadline` with the corresponding `ack_id` if using
  888. // pull.
  889. // The maximum custom deadline you can specify is 600 seconds (10
  890. // minutes).
  891. //
  892. // For push delivery, this value is also used to set the request timeout
  893. // for
  894. // the call to the push endpoint.
  895. //
  896. // If the subscriber never acknowledges the message, the Pub/Sub
  897. // system will eventually redeliver the message.
  898. //
  899. // If this parameter is 0, a default value of 10 seconds is used.
  900. AckDeadlineSeconds int64 `json:"ackDeadlineSeconds,omitempty"`
  901. // Name: The name of the subscription. It must have the
  902. // format
  903. // "projects/{project}/subscriptions/{subscription}". `{subscription}`
  904. // must
  905. // start with a letter, and contain only letters (`[A-Za-z]`),
  906. // numbers
  907. // (`[0-9]`), dashes (`-`), underscores (`_`), periods (`.`), tildes
  908. // (`~`),
  909. // plus (`+`) or percent signs (`%`). It must be between 3 and 255
  910. // characters
  911. // in length, and it must not start with "goog".
  912. Name string `json:"name,omitempty"`
  913. // PushConfig: If push delivery is used with this subscription, this
  914. // field is
  915. // used to configure it. An empty `pushConfig` signifies that the
  916. // subscriber
  917. // will pull and ack messages using API methods.
  918. PushConfig *PushConfig `json:"pushConfig,omitempty"`
  919. // Topic: The name of the topic from which this subscription is
  920. // receiving messages.
  921. // The value of this field will be `_deleted-topic_` if the topic has
  922. // been
  923. // deleted.
  924. Topic string `json:"topic,omitempty"`
  925. // ServerResponse contains the HTTP response code and headers from the
  926. // server.
  927. googleapi.ServerResponse `json:"-"`
  928. // ForceSendFields is a list of field names (e.g. "AckDeadlineSeconds")
  929. // to 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. "AckDeadlineSeconds") to
  936. // include in API requests with the JSON null value. By default, fields
  937. // with empty values are omitted from API requests. However, any field
  938. // with an empty value appearing in NullFields will be sent to the
  939. // server as null. It is an error if a field in this list has a
  940. // non-empty value. This may be used to include null fields in Patch
  941. // requests.
  942. NullFields []string `json:"-"`
  943. }
  944. func (s *Subscription) MarshalJSON() ([]byte, error) {
  945. type NoMethod Subscription
  946. raw := NoMethod(*s)
  947. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  948. }
  949. // TestIamPermissionsRequest: Request message for `TestIamPermissions`
  950. // method.
  951. type TestIamPermissionsRequest struct {
  952. // Permissions: The set of permissions to check for the `resource`.
  953. // Permissions with
  954. // wildcards (such as '*' or 'storage.*') are not allowed. For
  955. // more
  956. // information see
  957. // [IAM
  958. // Overview](https://cloud.google.com/iam/docs/overview#permissions).
  959. Permissions []string `json:"permissions,omitempty"`
  960. // ForceSendFields is a list of field names (e.g. "Permissions") to
  961. // unconditionally include in API requests. By default, fields with
  962. // empty values are omitted from API requests. However, any non-pointer,
  963. // non-interface field appearing in ForceSendFields will be sent to the
  964. // server regardless of whether the field is empty or not. This may be
  965. // used to include empty fields in Patch requests.
  966. ForceSendFields []string `json:"-"`
  967. // NullFields is a list of field names (e.g. "Permissions") to include
  968. // in API requests with the JSON null value. By default, fields with
  969. // empty values are omitted from API requests. However, any field with
  970. // an empty value appearing in NullFields will be sent to the server as
  971. // null. It is an error if a field in this list has a non-empty value.
  972. // This may be used to include null fields in Patch requests.
  973. NullFields []string `json:"-"`
  974. }
  975. func (s *TestIamPermissionsRequest) MarshalJSON() ([]byte, error) {
  976. type NoMethod TestIamPermissionsRequest
  977. raw := NoMethod(*s)
  978. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  979. }
  980. // TestIamPermissionsResponse: Response message for `TestIamPermissions`
  981. // method.
  982. type TestIamPermissionsResponse struct {
  983. // Permissions: A subset of `TestPermissionsRequest.permissions` that
  984. // the caller is
  985. // allowed.
  986. Permissions []string `json:"permissions,omitempty"`
  987. // ServerResponse contains the HTTP response code and headers from the
  988. // server.
  989. googleapi.ServerResponse `json:"-"`
  990. // ForceSendFields is a list of field names (e.g. "Permissions") to
  991. // unconditionally include in API requests. By default, fields with
  992. // empty values are omitted from API requests. However, any non-pointer,
  993. // non-interface field appearing in ForceSendFields will be sent to the
  994. // server regardless of whether the field is empty or not. This may be
  995. // used to include empty fields in Patch requests.
  996. ForceSendFields []string `json:"-"`
  997. // NullFields is a list of field names (e.g. "Permissions") to include
  998. // in API requests with the JSON null value. By default, fields with
  999. // empty values are omitted from API requests. However, any field with
  1000. // an empty value appearing in NullFields will be sent to the server as
  1001. // null. It is an error if a field in this list has a non-empty value.
  1002. // This may be used to include null fields in Patch requests.
  1003. NullFields []string `json:"-"`
  1004. }
  1005. func (s *TestIamPermissionsResponse) MarshalJSON() ([]byte, error) {
  1006. type NoMethod TestIamPermissionsResponse
  1007. raw := NoMethod(*s)
  1008. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1009. }
  1010. // Topic: A topic resource.
  1011. type Topic struct {
  1012. // Name: The name of the topic. It must have the
  1013. // format
  1014. // "projects/{project}/topics/{topic}". `{topic}` must start with a
  1015. // letter,
  1016. // and contain only letters (`[A-Za-z]`), numbers (`[0-9]`), dashes
  1017. // (`-`),
  1018. // underscores (`_`), periods (`.`), tildes (`~`), plus (`+`) or
  1019. // percent
  1020. // signs (`%`). It must be between 3 and 255 characters in length, and
  1021. // it
  1022. // must not start with "goog".
  1023. Name string `json:"name,omitempty"`
  1024. // ServerResponse contains the HTTP response code and headers from the
  1025. // server.
  1026. googleapi.ServerResponse `json:"-"`
  1027. // ForceSendFields is a list of field names (e.g. "Name") to
  1028. // unconditionally include in API requests. By default, fields with
  1029. // empty values are omitted from API requests. However, any non-pointer,
  1030. // non-interface field appearing in ForceSendFields will be sent to the
  1031. // server regardless of whether the field is empty or not. This may be
  1032. // used to include empty fields in Patch requests.
  1033. ForceSendFields []string `json:"-"`
  1034. // NullFields is a list of field names (e.g. "Name") to include in API
  1035. // requests with the JSON null value. By default, fields with empty
  1036. // values are omitted from API requests. However, any field with an
  1037. // empty value appearing in NullFields will be sent to the server as
  1038. // null. It is an error if a field in this list has a non-empty value.
  1039. // This may be used to include null fields in Patch requests.
  1040. NullFields []string `json:"-"`
  1041. }
  1042. func (s *Topic) MarshalJSON() ([]byte, error) {
  1043. type NoMethod Topic
  1044. raw := NoMethod(*s)
  1045. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1046. }
  1047. // method id "pubsub.projects.subscriptions.acknowledge":
  1048. type ProjectsSubscriptionsAcknowledgeCall struct {
  1049. s *Service
  1050. subscription string
  1051. acknowledgerequest *AcknowledgeRequest
  1052. urlParams_ gensupport.URLParams
  1053. ctx_ context.Context
  1054. header_ http.Header
  1055. }
  1056. // Acknowledge: Acknowledges the messages associated with the `ack_ids`
  1057. // in the
  1058. // `AcknowledgeRequest`. The Pub/Sub system can remove the relevant
  1059. // messages
  1060. // from the subscription.
  1061. //
  1062. // Acknowledging a message whose ack deadline has expired may
  1063. // succeed,
  1064. // but such a message may be redelivered later. Acknowledging a message
  1065. // more
  1066. // than once will not result in an error.
  1067. func (r *ProjectsSubscriptionsService) Acknowledge(subscription string, acknowledgerequest *AcknowledgeRequest) *ProjectsSubscriptionsAcknowledgeCall {
  1068. c := &ProjectsSubscriptionsAcknowledgeCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1069. c.subscription = subscription
  1070. c.acknowledgerequest = acknowledgerequest
  1071. return c
  1072. }
  1073. // Fields allows partial responses to be retrieved. See
  1074. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1075. // for more information.
  1076. func (c *ProjectsSubscriptionsAcknowledgeCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsAcknowledgeCall {
  1077. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1078. return c
  1079. }
  1080. // Context sets the context to be used in this call's Do method. Any
  1081. // pending HTTP request will be aborted if the provided context is
  1082. // canceled.
  1083. func (c *ProjectsSubscriptionsAcknowledgeCall) Context(ctx context.Context) *ProjectsSubscriptionsAcknowledgeCall {
  1084. c.ctx_ = ctx
  1085. return c
  1086. }
  1087. // Header returns an http.Header that can be modified by the caller to
  1088. // add HTTP headers to the request.
  1089. func (c *ProjectsSubscriptionsAcknowledgeCall) Header() http.Header {
  1090. if c.header_ == nil {
  1091. c.header_ = make(http.Header)
  1092. }
  1093. return c.header_
  1094. }
  1095. func (c *ProjectsSubscriptionsAcknowledgeCall) doRequest(alt string) (*http.Response, error) {
  1096. reqHeaders := make(http.Header)
  1097. for k, v := range c.header_ {
  1098. reqHeaders[k] = v
  1099. }
  1100. reqHeaders.Set("User-Agent", c.s.userAgent())
  1101. var body io.Reader = nil
  1102. body, err := googleapi.WithoutDataWrapper.JSONReader(c.acknowledgerequest)
  1103. if err != nil {
  1104. return nil, err
  1105. }
  1106. reqHeaders.Set("Content-Type", "application/json")
  1107. c.urlParams_.Set("alt", alt)
  1108. c.urlParams_.Set("prettyPrint", "false")
  1109. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+subscription}:acknowledge")
  1110. urls += "?" + c.urlParams_.Encode()
  1111. req, err := http.NewRequest("POST", urls, body)
  1112. if err != nil {
  1113. return nil, err
  1114. }
  1115. req.Header = reqHeaders
  1116. googleapi.Expand(req.URL, map[string]string{
  1117. "subscription": c.subscription,
  1118. })
  1119. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1120. }
  1121. // Do executes the "pubsub.projects.subscriptions.acknowledge" call.
  1122. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  1123. // code is an error. Response headers are in either
  1124. // *Empty.ServerResponse.Header or (if a response was returned at all)
  1125. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1126. // check whether the returned error was because http.StatusNotModified
  1127. // was returned.
  1128. func (c *ProjectsSubscriptionsAcknowledgeCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  1129. gensupport.SetOptions(c.urlParams_, opts...)
  1130. res, err := c.doRequest("json")
  1131. if res != nil && res.StatusCode == http.StatusNotModified {
  1132. if res.Body != nil {
  1133. res.Body.Close()
  1134. }
  1135. return nil, &googleapi.Error{
  1136. Code: res.StatusCode,
  1137. Header: res.Header,
  1138. }
  1139. }
  1140. if err != nil {
  1141. return nil, err
  1142. }
  1143. defer googleapi.CloseBody(res)
  1144. if err := googleapi.CheckResponse(res); err != nil {
  1145. return nil, err
  1146. }
  1147. ret := &Empty{
  1148. ServerResponse: googleapi.ServerResponse{
  1149. Header: res.Header,
  1150. HTTPStatusCode: res.StatusCode,
  1151. },
  1152. }
  1153. target := &ret
  1154. if err := gensupport.DecodeResponse(target, res); err != nil {
  1155. return nil, err
  1156. }
  1157. return ret, nil
  1158. // {
  1159. // "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.",
  1160. // "flatPath": "v1beta2/projects/{projectsId}/subscriptions/{subscriptionsId}:acknowledge",
  1161. // "httpMethod": "POST",
  1162. // "id": "pubsub.projects.subscriptions.acknowledge",
  1163. // "parameterOrder": [
  1164. // "subscription"
  1165. // ],
  1166. // "parameters": {
  1167. // "subscription": {
  1168. // "description": "The subscription whose message is being acknowledged.",
  1169. // "location": "path",
  1170. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  1171. // "required": true,
  1172. // "type": "string"
  1173. // }
  1174. // },
  1175. // "path": "v1beta2/{+subscription}:acknowledge",
  1176. // "request": {
  1177. // "$ref": "AcknowledgeRequest"
  1178. // },
  1179. // "response": {
  1180. // "$ref": "Empty"
  1181. // },
  1182. // "scopes": [
  1183. // "https://www.googleapis.com/auth/cloud-platform",
  1184. // "https://www.googleapis.com/auth/pubsub"
  1185. // ]
  1186. // }
  1187. }
  1188. // method id "pubsub.projects.subscriptions.create":
  1189. type ProjectsSubscriptionsCreateCall struct {
  1190. s *Service
  1191. name string
  1192. subscription *Subscription
  1193. urlParams_ gensupport.URLParams
  1194. ctx_ context.Context
  1195. header_ http.Header
  1196. }
  1197. // Create: Creates a subscription to a given topic.
  1198. // If the subscription already exists, returns `ALREADY_EXISTS`.
  1199. // If the corresponding topic doesn't exist, returns `NOT_FOUND`.
  1200. //
  1201. // If the name is not provided in the request, the server will assign a
  1202. // random
  1203. // name for this subscription on the same project as the topic. Note
  1204. // that
  1205. // for REST API requests, you must specify a name.
  1206. func (r *ProjectsSubscriptionsService) Create(name string, subscription *Subscription) *ProjectsSubscriptionsCreateCall {
  1207. c := &ProjectsSubscriptionsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1208. c.name = name
  1209. c.subscription = subscription
  1210. return c
  1211. }
  1212. // Fields allows partial responses to be retrieved. See
  1213. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1214. // for more information.
  1215. func (c *ProjectsSubscriptionsCreateCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsCreateCall {
  1216. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1217. return c
  1218. }
  1219. // Context sets the context to be used in this call's Do method. Any
  1220. // pending HTTP request will be aborted if the provided context is
  1221. // canceled.
  1222. func (c *ProjectsSubscriptionsCreateCall) Context(ctx context.Context) *ProjectsSubscriptionsCreateCall {
  1223. c.ctx_ = ctx
  1224. return c
  1225. }
  1226. // Header returns an http.Header that can be modified by the caller to
  1227. // add HTTP headers to the request.
  1228. func (c *ProjectsSubscriptionsCreateCall) Header() http.Header {
  1229. if c.header_ == nil {
  1230. c.header_ = make(http.Header)
  1231. }
  1232. return c.header_
  1233. }
  1234. func (c *ProjectsSubscriptionsCreateCall) doRequest(alt string) (*http.Response, error) {
  1235. reqHeaders := make(http.Header)
  1236. for k, v := range c.header_ {
  1237. reqHeaders[k] = v
  1238. }
  1239. reqHeaders.Set("User-Agent", c.s.userAgent())
  1240. var body io.Reader = nil
  1241. body, err := googleapi.WithoutDataWrapper.JSONReader(c.subscription)
  1242. if err != nil {
  1243. return nil, err
  1244. }
  1245. reqHeaders.Set("Content-Type", "application/json")
  1246. c.urlParams_.Set("alt", alt)
  1247. c.urlParams_.Set("prettyPrint", "false")
  1248. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+name}")
  1249. urls += "?" + c.urlParams_.Encode()
  1250. req, err := http.NewRequest("PUT", urls, body)
  1251. if err != nil {
  1252. return nil, err
  1253. }
  1254. req.Header = reqHeaders
  1255. googleapi.Expand(req.URL, map[string]string{
  1256. "name": c.name,
  1257. })
  1258. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1259. }
  1260. // Do executes the "pubsub.projects.subscriptions.create" call.
  1261. // Exactly one of *Subscription or error will be non-nil. Any non-2xx
  1262. // status code is an error. Response headers are in either
  1263. // *Subscription.ServerResponse.Header or (if a response was returned at
  1264. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1265. // to check whether the returned error was because
  1266. // http.StatusNotModified was returned.
  1267. func (c *ProjectsSubscriptionsCreateCall) Do(opts ...googleapi.CallOption) (*Subscription, error) {
  1268. gensupport.SetOptions(c.urlParams_, opts...)
  1269. res, err := c.doRequest("json")
  1270. if res != nil && res.StatusCode == http.StatusNotModified {
  1271. if res.Body != nil {
  1272. res.Body.Close()
  1273. }
  1274. return nil, &googleapi.Error{
  1275. Code: res.StatusCode,
  1276. Header: res.Header,
  1277. }
  1278. }
  1279. if err != nil {
  1280. return nil, err
  1281. }
  1282. defer googleapi.CloseBody(res)
  1283. if err := googleapi.CheckResponse(res); err != nil {
  1284. return nil, err
  1285. }
  1286. ret := &Subscription{
  1287. ServerResponse: googleapi.ServerResponse{
  1288. Header: res.Header,
  1289. HTTPStatusCode: res.StatusCode,
  1290. },
  1291. }
  1292. target := &ret
  1293. if err := gensupport.DecodeResponse(target, res); err != nil {
  1294. return nil, err
  1295. }
  1296. return ret, nil
  1297. // {
  1298. // "description": "Creates a subscription to a given topic.\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. Note that\nfor REST API requests, you must specify a name.",
  1299. // "flatPath": "v1beta2/projects/{projectsId}/subscriptions/{subscriptionsId}",
  1300. // "httpMethod": "PUT",
  1301. // "id": "pubsub.projects.subscriptions.create",
  1302. // "parameterOrder": [
  1303. // "name"
  1304. // ],
  1305. // "parameters": {
  1306. // "name": {
  1307. // "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\"`.",
  1308. // "location": "path",
  1309. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  1310. // "required": true,
  1311. // "type": "string"
  1312. // }
  1313. // },
  1314. // "path": "v1beta2/{+name}",
  1315. // "request": {
  1316. // "$ref": "Subscription"
  1317. // },
  1318. // "response": {
  1319. // "$ref": "Subscription"
  1320. // },
  1321. // "scopes": [
  1322. // "https://www.googleapis.com/auth/cloud-platform",
  1323. // "https://www.googleapis.com/auth/pubsub"
  1324. // ]
  1325. // }
  1326. }
  1327. // method id "pubsub.projects.subscriptions.delete":
  1328. type ProjectsSubscriptionsDeleteCall struct {
  1329. s *Service
  1330. subscription string
  1331. urlParams_ gensupport.URLParams
  1332. ctx_ context.Context
  1333. header_ http.Header
  1334. }
  1335. // Delete: Deletes an existing subscription. All pending messages in the
  1336. // subscription
  1337. // are immediately dropped. Calls to `Pull` after deletion will
  1338. // return
  1339. // `NOT_FOUND`. After a subscription is deleted, a new one may be
  1340. // created with
  1341. // the same name, but the new one has no association with the
  1342. // old
  1343. // subscription, or its topic unless the same topic is specified.
  1344. func (r *ProjectsSubscriptionsService) Delete(subscription string) *ProjectsSubscriptionsDeleteCall {
  1345. c := &ProjectsSubscriptionsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1346. c.subscription = subscription
  1347. return c
  1348. }
  1349. // Fields allows partial responses to be retrieved. See
  1350. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1351. // for more information.
  1352. func (c *ProjectsSubscriptionsDeleteCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsDeleteCall {
  1353. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1354. return c
  1355. }
  1356. // Context sets the context to be used in this call's Do method. Any
  1357. // pending HTTP request will be aborted if the provided context is
  1358. // canceled.
  1359. func (c *ProjectsSubscriptionsDeleteCall) Context(ctx context.Context) *ProjectsSubscriptionsDeleteCall {
  1360. c.ctx_ = ctx
  1361. return c
  1362. }
  1363. // Header returns an http.Header that can be modified by the caller to
  1364. // add HTTP headers to the request.
  1365. func (c *ProjectsSubscriptionsDeleteCall) Header() http.Header {
  1366. if c.header_ == nil {
  1367. c.header_ = make(http.Header)
  1368. }
  1369. return c.header_
  1370. }
  1371. func (c *ProjectsSubscriptionsDeleteCall) doRequest(alt string) (*http.Response, error) {
  1372. reqHeaders := make(http.Header)
  1373. for k, v := range c.header_ {
  1374. reqHeaders[k] = v
  1375. }
  1376. reqHeaders.Set("User-Agent", c.s.userAgent())
  1377. var body io.Reader = nil
  1378. c.urlParams_.Set("alt", alt)
  1379. c.urlParams_.Set("prettyPrint", "false")
  1380. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+subscription}")
  1381. urls += "?" + c.urlParams_.Encode()
  1382. req, err := http.NewRequest("DELETE", urls, body)
  1383. if err != nil {
  1384. return nil, err
  1385. }
  1386. req.Header = reqHeaders
  1387. googleapi.Expand(req.URL, map[string]string{
  1388. "subscription": c.subscription,
  1389. })
  1390. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1391. }
  1392. // Do executes the "pubsub.projects.subscriptions.delete" call.
  1393. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  1394. // code is an error. Response headers are in either
  1395. // *Empty.ServerResponse.Header or (if a response was returned at all)
  1396. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1397. // check whether the returned error was because http.StatusNotModified
  1398. // was returned.
  1399. func (c *ProjectsSubscriptionsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  1400. gensupport.SetOptions(c.urlParams_, opts...)
  1401. res, err := c.doRequest("json")
  1402. if res != nil && res.StatusCode == http.StatusNotModified {
  1403. if res.Body != nil {
  1404. res.Body.Close()
  1405. }
  1406. return nil, &googleapi.Error{
  1407. Code: res.StatusCode,
  1408. Header: res.Header,
  1409. }
  1410. }
  1411. if err != nil {
  1412. return nil, err
  1413. }
  1414. defer googleapi.CloseBody(res)
  1415. if err := googleapi.CheckResponse(res); err != nil {
  1416. return nil, err
  1417. }
  1418. ret := &Empty{
  1419. ServerResponse: googleapi.ServerResponse{
  1420. Header: res.Header,
  1421. HTTPStatusCode: res.StatusCode,
  1422. },
  1423. }
  1424. target := &ret
  1425. if err := gensupport.DecodeResponse(target, res); err != nil {
  1426. return nil, err
  1427. }
  1428. return ret, nil
  1429. // {
  1430. // "description": "Deletes an existing subscription. All pending messages 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.",
  1431. // "flatPath": "v1beta2/projects/{projectsId}/subscriptions/{subscriptionsId}",
  1432. // "httpMethod": "DELETE",
  1433. // "id": "pubsub.projects.subscriptions.delete",
  1434. // "parameterOrder": [
  1435. // "subscription"
  1436. // ],
  1437. // "parameters": {
  1438. // "subscription": {
  1439. // "description": "The subscription to delete.",
  1440. // "location": "path",
  1441. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  1442. // "required": true,
  1443. // "type": "string"
  1444. // }
  1445. // },
  1446. // "path": "v1beta2/{+subscription}",
  1447. // "response": {
  1448. // "$ref": "Empty"
  1449. // },
  1450. // "scopes": [
  1451. // "https://www.googleapis.com/auth/cloud-platform",
  1452. // "https://www.googleapis.com/auth/pubsub"
  1453. // ]
  1454. // }
  1455. }
  1456. // method id "pubsub.projects.subscriptions.get":
  1457. type ProjectsSubscriptionsGetCall struct {
  1458. s *Service
  1459. subscription string
  1460. urlParams_ gensupport.URLParams
  1461. ifNoneMatch_ string
  1462. ctx_ context.Context
  1463. header_ http.Header
  1464. }
  1465. // Get: Gets the configuration details of a subscription.
  1466. func (r *ProjectsSubscriptionsService) Get(subscription string) *ProjectsSubscriptionsGetCall {
  1467. c := &ProjectsSubscriptionsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1468. c.subscription = subscription
  1469. return c
  1470. }
  1471. // Fields allows partial responses to be retrieved. See
  1472. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1473. // for more information.
  1474. func (c *ProjectsSubscriptionsGetCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsGetCall {
  1475. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1476. return c
  1477. }
  1478. // IfNoneMatch sets the optional parameter which makes the operation
  1479. // fail if the object's ETag matches the given value. This is useful for
  1480. // getting updates only after the object has changed since the last
  1481. // request. Use googleapi.IsNotModified to check whether the response
  1482. // error from Do is the result of In-None-Match.
  1483. func (c *ProjectsSubscriptionsGetCall) IfNoneMatch(entityTag string) *ProjectsSubscriptionsGetCall {
  1484. c.ifNoneMatch_ = entityTag
  1485. return c
  1486. }
  1487. // Context sets the context to be used in this call's Do method. Any
  1488. // pending HTTP request will be aborted if the provided context is
  1489. // canceled.
  1490. func (c *ProjectsSubscriptionsGetCall) Context(ctx context.Context) *ProjectsSubscriptionsGetCall {
  1491. c.ctx_ = ctx
  1492. return c
  1493. }
  1494. // Header returns an http.Header that can be modified by the caller to
  1495. // add HTTP headers to the request.
  1496. func (c *ProjectsSubscriptionsGetCall) Header() http.Header {
  1497. if c.header_ == nil {
  1498. c.header_ = make(http.Header)
  1499. }
  1500. return c.header_
  1501. }
  1502. func (c *ProjectsSubscriptionsGetCall) doRequest(alt string) (*http.Response, error) {
  1503. reqHeaders := make(http.Header)
  1504. for k, v := range c.header_ {
  1505. reqHeaders[k] = v
  1506. }
  1507. reqHeaders.Set("User-Agent", c.s.userAgent())
  1508. if c.ifNoneMatch_ != "" {
  1509. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1510. }
  1511. var body io.Reader = nil
  1512. c.urlParams_.Set("alt", alt)
  1513. c.urlParams_.Set("prettyPrint", "false")
  1514. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+subscription}")
  1515. urls += "?" + c.urlParams_.Encode()
  1516. req, err := http.NewRequest("GET", urls, body)
  1517. if err != nil {
  1518. return nil, err
  1519. }
  1520. req.Header = reqHeaders
  1521. googleapi.Expand(req.URL, map[string]string{
  1522. "subscription": c.subscription,
  1523. })
  1524. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1525. }
  1526. // Do executes the "pubsub.projects.subscriptions.get" call.
  1527. // Exactly one of *Subscription or error will be non-nil. Any non-2xx
  1528. // status code is an error. Response headers are in either
  1529. // *Subscription.ServerResponse.Header or (if a response was returned at
  1530. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1531. // to check whether the returned error was because
  1532. // http.StatusNotModified was returned.
  1533. func (c *ProjectsSubscriptionsGetCall) Do(opts ...googleapi.CallOption) (*Subscription, error) {
  1534. gensupport.SetOptions(c.urlParams_, opts...)
  1535. res, err := c.doRequest("json")
  1536. if res != nil && res.StatusCode == http.StatusNotModified {
  1537. if res.Body != nil {
  1538. res.Body.Close()
  1539. }
  1540. return nil, &googleapi.Error{
  1541. Code: res.StatusCode,
  1542. Header: res.Header,
  1543. }
  1544. }
  1545. if err != nil {
  1546. return nil, err
  1547. }
  1548. defer googleapi.CloseBody(res)
  1549. if err := googleapi.CheckResponse(res); err != nil {
  1550. return nil, err
  1551. }
  1552. ret := &Subscription{
  1553. ServerResponse: googleapi.ServerResponse{
  1554. Header: res.Header,
  1555. HTTPStatusCode: res.StatusCode,
  1556. },
  1557. }
  1558. target := &ret
  1559. if err := gensupport.DecodeResponse(target, res); err != nil {
  1560. return nil, err
  1561. }
  1562. return ret, nil
  1563. // {
  1564. // "description": "Gets the configuration details of a subscription.",
  1565. // "flatPath": "v1beta2/projects/{projectsId}/subscriptions/{subscriptionsId}",
  1566. // "httpMethod": "GET",
  1567. // "id": "pubsub.projects.subscriptions.get",
  1568. // "parameterOrder": [
  1569. // "subscription"
  1570. // ],
  1571. // "parameters": {
  1572. // "subscription": {
  1573. // "description": "The name of the subscription to get.",
  1574. // "location": "path",
  1575. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  1576. // "required": true,
  1577. // "type": "string"
  1578. // }
  1579. // },
  1580. // "path": "v1beta2/{+subscription}",
  1581. // "response": {
  1582. // "$ref": "Subscription"
  1583. // },
  1584. // "scopes": [
  1585. // "https://www.googleapis.com/auth/cloud-platform",
  1586. // "https://www.googleapis.com/auth/pubsub"
  1587. // ]
  1588. // }
  1589. }
  1590. // method id "pubsub.projects.subscriptions.getIamPolicy":
  1591. type ProjectsSubscriptionsGetIamPolicyCall struct {
  1592. s *Service
  1593. resource string
  1594. urlParams_ gensupport.URLParams
  1595. ifNoneMatch_ string
  1596. ctx_ context.Context
  1597. header_ http.Header
  1598. }
  1599. // GetIamPolicy: Gets the access control policy for a resource.
  1600. // Returns an empty policy if the resource exists and does not have a
  1601. // policy
  1602. // set.
  1603. func (r *ProjectsSubscriptionsService) GetIamPolicy(resource string) *ProjectsSubscriptionsGetIamPolicyCall {
  1604. c := &ProjectsSubscriptionsGetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1605. c.resource = resource
  1606. return c
  1607. }
  1608. // Fields allows partial responses to be retrieved. See
  1609. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1610. // for more information.
  1611. func (c *ProjectsSubscriptionsGetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsGetIamPolicyCall {
  1612. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1613. return c
  1614. }
  1615. // IfNoneMatch sets the optional parameter which makes the operation
  1616. // fail if the object's ETag matches the given value. This is useful for
  1617. // getting updates only after the object has changed since the last
  1618. // request. Use googleapi.IsNotModified to check whether the response
  1619. // error from Do is the result of In-None-Match.
  1620. func (c *ProjectsSubscriptionsGetIamPolicyCall) IfNoneMatch(entityTag string) *ProjectsSubscriptionsGetIamPolicyCall {
  1621. c.ifNoneMatch_ = entityTag
  1622. return c
  1623. }
  1624. // Context sets the context to be used in this call's Do method. Any
  1625. // pending HTTP request will be aborted if the provided context is
  1626. // canceled.
  1627. func (c *ProjectsSubscriptionsGetIamPolicyCall) Context(ctx context.Context) *ProjectsSubscriptionsGetIamPolicyCall {
  1628. c.ctx_ = ctx
  1629. return c
  1630. }
  1631. // Header returns an http.Header that can be modified by the caller to
  1632. // add HTTP headers to the request.
  1633. func (c *ProjectsSubscriptionsGetIamPolicyCall) Header() http.Header {
  1634. if c.header_ == nil {
  1635. c.header_ = make(http.Header)
  1636. }
  1637. return c.header_
  1638. }
  1639. func (c *ProjectsSubscriptionsGetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  1640. reqHeaders := make(http.Header)
  1641. for k, v := range c.header_ {
  1642. reqHeaders[k] = v
  1643. }
  1644. reqHeaders.Set("User-Agent", c.s.userAgent())
  1645. if c.ifNoneMatch_ != "" {
  1646. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1647. }
  1648. var body io.Reader = nil
  1649. c.urlParams_.Set("alt", alt)
  1650. c.urlParams_.Set("prettyPrint", "false")
  1651. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+resource}:getIamPolicy")
  1652. urls += "?" + c.urlParams_.Encode()
  1653. req, err := http.NewRequest("GET", urls, body)
  1654. if err != nil {
  1655. return nil, err
  1656. }
  1657. req.Header = reqHeaders
  1658. googleapi.Expand(req.URL, map[string]string{
  1659. "resource": c.resource,
  1660. })
  1661. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1662. }
  1663. // Do executes the "pubsub.projects.subscriptions.getIamPolicy" call.
  1664. // Exactly one of *Policy or error will be non-nil. Any non-2xx status
  1665. // code is an error. Response headers are in either
  1666. // *Policy.ServerResponse.Header or (if a response was returned at all)
  1667. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1668. // check whether the returned error was because http.StatusNotModified
  1669. // was returned.
  1670. func (c *ProjectsSubscriptionsGetIamPolicyCall) Do(opts ...googleapi.CallOption) (*Policy, error) {
  1671. gensupport.SetOptions(c.urlParams_, opts...)
  1672. res, err := c.doRequest("json")
  1673. if res != nil && res.StatusCode == http.StatusNotModified {
  1674. if res.Body != nil {
  1675. res.Body.Close()
  1676. }
  1677. return nil, &googleapi.Error{
  1678. Code: res.StatusCode,
  1679. Header: res.Header,
  1680. }
  1681. }
  1682. if err != nil {
  1683. return nil, err
  1684. }
  1685. defer googleapi.CloseBody(res)
  1686. if err := googleapi.CheckResponse(res); err != nil {
  1687. return nil, err
  1688. }
  1689. ret := &Policy{
  1690. ServerResponse: googleapi.ServerResponse{
  1691. Header: res.Header,
  1692. HTTPStatusCode: res.StatusCode,
  1693. },
  1694. }
  1695. target := &ret
  1696. if err := gensupport.DecodeResponse(target, res); err != nil {
  1697. return nil, err
  1698. }
  1699. return ret, nil
  1700. // {
  1701. // "description": "Gets the access control policy for a resource.\nReturns an empty policy if the resource exists and does not have a policy\nset.",
  1702. // "flatPath": "v1beta2/projects/{projectsId}/subscriptions/{subscriptionsId}:getIamPolicy",
  1703. // "httpMethod": "GET",
  1704. // "id": "pubsub.projects.subscriptions.getIamPolicy",
  1705. // "parameterOrder": [
  1706. // "resource"
  1707. // ],
  1708. // "parameters": {
  1709. // "resource": {
  1710. // "description": "REQUIRED: The resource for which the policy is being requested.\nSee the operation documentation for the appropriate value for this field.",
  1711. // "location": "path",
  1712. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  1713. // "required": true,
  1714. // "type": "string"
  1715. // }
  1716. // },
  1717. // "path": "v1beta2/{+resource}:getIamPolicy",
  1718. // "response": {
  1719. // "$ref": "Policy"
  1720. // },
  1721. // "scopes": [
  1722. // "https://www.googleapis.com/auth/cloud-platform",
  1723. // "https://www.googleapis.com/auth/pubsub"
  1724. // ]
  1725. // }
  1726. }
  1727. // method id "pubsub.projects.subscriptions.list":
  1728. type ProjectsSubscriptionsListCall struct {
  1729. s *Service
  1730. project string
  1731. urlParams_ gensupport.URLParams
  1732. ifNoneMatch_ string
  1733. ctx_ context.Context
  1734. header_ http.Header
  1735. }
  1736. // List: Lists matching subscriptions.
  1737. func (r *ProjectsSubscriptionsService) List(project string) *ProjectsSubscriptionsListCall {
  1738. c := &ProjectsSubscriptionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1739. c.project = project
  1740. return c
  1741. }
  1742. // PageSize sets the optional parameter "pageSize": Maximum number of
  1743. // subscriptions to return.
  1744. func (c *ProjectsSubscriptionsListCall) PageSize(pageSize int64) *ProjectsSubscriptionsListCall {
  1745. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  1746. return c
  1747. }
  1748. // PageToken sets the optional parameter "pageToken": The value returned
  1749. // by the last `ListSubscriptionsResponse`; indicates that
  1750. // this is a continuation of a prior `ListSubscriptions` call, and that
  1751. // the
  1752. // system should return the next page of data.
  1753. func (c *ProjectsSubscriptionsListCall) PageToken(pageToken string) *ProjectsSubscriptionsListCall {
  1754. c.urlParams_.Set("pageToken", pageToken)
  1755. return c
  1756. }
  1757. // Fields allows partial responses to be retrieved. See
  1758. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1759. // for more information.
  1760. func (c *ProjectsSubscriptionsListCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsListCall {
  1761. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1762. return c
  1763. }
  1764. // IfNoneMatch sets the optional parameter which makes the operation
  1765. // fail if the object's ETag matches the given value. This is useful for
  1766. // getting updates only after the object has changed since the last
  1767. // request. Use googleapi.IsNotModified to check whether the response
  1768. // error from Do is the result of In-None-Match.
  1769. func (c *ProjectsSubscriptionsListCall) IfNoneMatch(entityTag string) *ProjectsSubscriptionsListCall {
  1770. c.ifNoneMatch_ = entityTag
  1771. return c
  1772. }
  1773. // Context sets the context to be used in this call's Do method. Any
  1774. // pending HTTP request will be aborted if the provided context is
  1775. // canceled.
  1776. func (c *ProjectsSubscriptionsListCall) Context(ctx context.Context) *ProjectsSubscriptionsListCall {
  1777. c.ctx_ = ctx
  1778. return c
  1779. }
  1780. // Header returns an http.Header that can be modified by the caller to
  1781. // add HTTP headers to the request.
  1782. func (c *ProjectsSubscriptionsListCall) Header() http.Header {
  1783. if c.header_ == nil {
  1784. c.header_ = make(http.Header)
  1785. }
  1786. return c.header_
  1787. }
  1788. func (c *ProjectsSubscriptionsListCall) doRequest(alt string) (*http.Response, error) {
  1789. reqHeaders := make(http.Header)
  1790. for k, v := range c.header_ {
  1791. reqHeaders[k] = v
  1792. }
  1793. reqHeaders.Set("User-Agent", c.s.userAgent())
  1794. if c.ifNoneMatch_ != "" {
  1795. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1796. }
  1797. var body io.Reader = nil
  1798. c.urlParams_.Set("alt", alt)
  1799. c.urlParams_.Set("prettyPrint", "false")
  1800. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+project}/subscriptions")
  1801. urls += "?" + c.urlParams_.Encode()
  1802. req, err := http.NewRequest("GET", urls, body)
  1803. if err != nil {
  1804. return nil, err
  1805. }
  1806. req.Header = reqHeaders
  1807. googleapi.Expand(req.URL, map[string]string{
  1808. "project": c.project,
  1809. })
  1810. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1811. }
  1812. // Do executes the "pubsub.projects.subscriptions.list" call.
  1813. // Exactly one of *ListSubscriptionsResponse or error will be non-nil.
  1814. // Any non-2xx status code is an error. Response headers are in either
  1815. // *ListSubscriptionsResponse.ServerResponse.Header or (if a response
  1816. // was returned at all) in error.(*googleapi.Error).Header. Use
  1817. // googleapi.IsNotModified to check whether the returned error was
  1818. // because http.StatusNotModified was returned.
  1819. func (c *ProjectsSubscriptionsListCall) Do(opts ...googleapi.CallOption) (*ListSubscriptionsResponse, error) {
  1820. gensupport.SetOptions(c.urlParams_, opts...)
  1821. res, err := c.doRequest("json")
  1822. if res != nil && res.StatusCode == http.StatusNotModified {
  1823. if res.Body != nil {
  1824. res.Body.Close()
  1825. }
  1826. return nil, &googleapi.Error{
  1827. Code: res.StatusCode,
  1828. Header: res.Header,
  1829. }
  1830. }
  1831. if err != nil {
  1832. return nil, err
  1833. }
  1834. defer googleapi.CloseBody(res)
  1835. if err := googleapi.CheckResponse(res); err != nil {
  1836. return nil, err
  1837. }
  1838. ret := &ListSubscriptionsResponse{
  1839. ServerResponse: googleapi.ServerResponse{
  1840. Header: res.Header,
  1841. HTTPStatusCode: res.StatusCode,
  1842. },
  1843. }
  1844. target := &ret
  1845. if err := gensupport.DecodeResponse(target, res); err != nil {
  1846. return nil, err
  1847. }
  1848. return ret, nil
  1849. // {
  1850. // "description": "Lists matching subscriptions.",
  1851. // "flatPath": "v1beta2/projects/{projectsId}/subscriptions",
  1852. // "httpMethod": "GET",
  1853. // "id": "pubsub.projects.subscriptions.list",
  1854. // "parameterOrder": [
  1855. // "project"
  1856. // ],
  1857. // "parameters": {
  1858. // "pageSize": {
  1859. // "description": "Maximum number of subscriptions to return.",
  1860. // "format": "int32",
  1861. // "location": "query",
  1862. // "type": "integer"
  1863. // },
  1864. // "pageToken": {
  1865. // "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.",
  1866. // "location": "query",
  1867. // "type": "string"
  1868. // },
  1869. // "project": {
  1870. // "description": "The name of the cloud project that subscriptions belong to.",
  1871. // "location": "path",
  1872. // "pattern": "^projects/[^/]+$",
  1873. // "required": true,
  1874. // "type": "string"
  1875. // }
  1876. // },
  1877. // "path": "v1beta2/{+project}/subscriptions",
  1878. // "response": {
  1879. // "$ref": "ListSubscriptionsResponse"
  1880. // },
  1881. // "scopes": [
  1882. // "https://www.googleapis.com/auth/cloud-platform",
  1883. // "https://www.googleapis.com/auth/pubsub"
  1884. // ]
  1885. // }
  1886. }
  1887. // Pages invokes f for each page of results.
  1888. // A non-nil error returned from f will halt the iteration.
  1889. // The provided context supersedes any context provided to the Context method.
  1890. func (c *ProjectsSubscriptionsListCall) Pages(ctx context.Context, f func(*ListSubscriptionsResponse) error) error {
  1891. c.ctx_ = ctx
  1892. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1893. for {
  1894. x, err := c.Do()
  1895. if err != nil {
  1896. return err
  1897. }
  1898. if err := f(x); err != nil {
  1899. return err
  1900. }
  1901. if x.NextPageToken == "" {
  1902. return nil
  1903. }
  1904. c.PageToken(x.NextPageToken)
  1905. }
  1906. }
  1907. // method id "pubsub.projects.subscriptions.modifyAckDeadline":
  1908. type ProjectsSubscriptionsModifyAckDeadlineCall struct {
  1909. s *Service
  1910. subscription string
  1911. modifyackdeadlinerequest *ModifyAckDeadlineRequest
  1912. urlParams_ gensupport.URLParams
  1913. ctx_ context.Context
  1914. header_ http.Header
  1915. }
  1916. // ModifyAckDeadline: Modifies the ack deadline for a specific message.
  1917. // This method is useful
  1918. // to indicate that more time is needed to process a message by
  1919. // the
  1920. // subscriber, or to make the message available for redelivery if
  1921. // the
  1922. // processing was interrupted. Note that this does not modify
  1923. // the
  1924. // subscription-level `ackDeadlineSeconds` used for subsequent messages.
  1925. func (r *ProjectsSubscriptionsService) ModifyAckDeadline(subscription string, modifyackdeadlinerequest *ModifyAckDeadlineRequest) *ProjectsSubscriptionsModifyAckDeadlineCall {
  1926. c := &ProjectsSubscriptionsModifyAckDeadlineCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1927. c.subscription = subscription
  1928. c.modifyackdeadlinerequest = modifyackdeadlinerequest
  1929. return c
  1930. }
  1931. // Fields allows partial responses to be retrieved. See
  1932. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1933. // for more information.
  1934. func (c *ProjectsSubscriptionsModifyAckDeadlineCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsModifyAckDeadlineCall {
  1935. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1936. return c
  1937. }
  1938. // Context sets the context to be used in this call's Do method. Any
  1939. // pending HTTP request will be aborted if the provided context is
  1940. // canceled.
  1941. func (c *ProjectsSubscriptionsModifyAckDeadlineCall) Context(ctx context.Context) *ProjectsSubscriptionsModifyAckDeadlineCall {
  1942. c.ctx_ = ctx
  1943. return c
  1944. }
  1945. // Header returns an http.Header that can be modified by the caller to
  1946. // add HTTP headers to the request.
  1947. func (c *ProjectsSubscriptionsModifyAckDeadlineCall) Header() http.Header {
  1948. if c.header_ == nil {
  1949. c.header_ = make(http.Header)
  1950. }
  1951. return c.header_
  1952. }
  1953. func (c *ProjectsSubscriptionsModifyAckDeadlineCall) doRequest(alt string) (*http.Response, error) {
  1954. reqHeaders := make(http.Header)
  1955. for k, v := range c.header_ {
  1956. reqHeaders[k] = v
  1957. }
  1958. reqHeaders.Set("User-Agent", c.s.userAgent())
  1959. var body io.Reader = nil
  1960. body, err := googleapi.WithoutDataWrapper.JSONReader(c.modifyackdeadlinerequest)
  1961. if err != nil {
  1962. return nil, err
  1963. }
  1964. reqHeaders.Set("Content-Type", "application/json")
  1965. c.urlParams_.Set("alt", alt)
  1966. c.urlParams_.Set("prettyPrint", "false")
  1967. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+subscription}:modifyAckDeadline")
  1968. urls += "?" + c.urlParams_.Encode()
  1969. req, err := http.NewRequest("POST", urls, body)
  1970. if err != nil {
  1971. return nil, err
  1972. }
  1973. req.Header = reqHeaders
  1974. googleapi.Expand(req.URL, map[string]string{
  1975. "subscription": c.subscription,
  1976. })
  1977. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1978. }
  1979. // Do executes the "pubsub.projects.subscriptions.modifyAckDeadline" call.
  1980. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  1981. // code is an error. Response headers are in either
  1982. // *Empty.ServerResponse.Header or (if a response was returned at all)
  1983. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1984. // check whether the returned error was because http.StatusNotModified
  1985. // was returned.
  1986. func (c *ProjectsSubscriptionsModifyAckDeadlineCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  1987. gensupport.SetOptions(c.urlParams_, opts...)
  1988. res, err := c.doRequest("json")
  1989. if res != nil && res.StatusCode == http.StatusNotModified {
  1990. if res.Body != nil {
  1991. res.Body.Close()
  1992. }
  1993. return nil, &googleapi.Error{
  1994. Code: res.StatusCode,
  1995. Header: res.Header,
  1996. }
  1997. }
  1998. if err != nil {
  1999. return nil, err
  2000. }
  2001. defer googleapi.CloseBody(res)
  2002. if err := googleapi.CheckResponse(res); err != nil {
  2003. return nil, err
  2004. }
  2005. ret := &Empty{
  2006. ServerResponse: googleapi.ServerResponse{
  2007. Header: res.Header,
  2008. HTTPStatusCode: res.StatusCode,
  2009. },
  2010. }
  2011. target := &ret
  2012. if err := gensupport.DecodeResponse(target, res); err != nil {
  2013. return nil, err
  2014. }
  2015. return ret, nil
  2016. // {
  2017. // "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.",
  2018. // "flatPath": "v1beta2/projects/{projectsId}/subscriptions/{subscriptionsId}:modifyAckDeadline",
  2019. // "httpMethod": "POST",
  2020. // "id": "pubsub.projects.subscriptions.modifyAckDeadline",
  2021. // "parameterOrder": [
  2022. // "subscription"
  2023. // ],
  2024. // "parameters": {
  2025. // "subscription": {
  2026. // "description": "The name of the subscription.",
  2027. // "location": "path",
  2028. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  2029. // "required": true,
  2030. // "type": "string"
  2031. // }
  2032. // },
  2033. // "path": "v1beta2/{+subscription}:modifyAckDeadline",
  2034. // "request": {
  2035. // "$ref": "ModifyAckDeadlineRequest"
  2036. // },
  2037. // "response": {
  2038. // "$ref": "Empty"
  2039. // },
  2040. // "scopes": [
  2041. // "https://www.googleapis.com/auth/cloud-platform",
  2042. // "https://www.googleapis.com/auth/pubsub"
  2043. // ]
  2044. // }
  2045. }
  2046. // method id "pubsub.projects.subscriptions.modifyPushConfig":
  2047. type ProjectsSubscriptionsModifyPushConfigCall struct {
  2048. s *Service
  2049. subscription string
  2050. modifypushconfigrequest *ModifyPushConfigRequest
  2051. urlParams_ gensupport.URLParams
  2052. ctx_ context.Context
  2053. header_ http.Header
  2054. }
  2055. // ModifyPushConfig: Modifies the `PushConfig` for a specified
  2056. // subscription.
  2057. //
  2058. // This may be used to change a push subscription to a pull one
  2059. // (signified by
  2060. // an empty `PushConfig`) or vice versa, or change the endpoint URL and
  2061. // other
  2062. // attributes of a push subscription. Messages will accumulate for
  2063. // delivery
  2064. // continuously through the call regardless of changes to the
  2065. // `PushConfig`.
  2066. func (r *ProjectsSubscriptionsService) ModifyPushConfig(subscription string, modifypushconfigrequest *ModifyPushConfigRequest) *ProjectsSubscriptionsModifyPushConfigCall {
  2067. c := &ProjectsSubscriptionsModifyPushConfigCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2068. c.subscription = subscription
  2069. c.modifypushconfigrequest = modifypushconfigrequest
  2070. return c
  2071. }
  2072. // Fields allows partial responses to be retrieved. See
  2073. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2074. // for more information.
  2075. func (c *ProjectsSubscriptionsModifyPushConfigCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsModifyPushConfigCall {
  2076. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2077. return c
  2078. }
  2079. // Context sets the context to be used in this call's Do method. Any
  2080. // pending HTTP request will be aborted if the provided context is
  2081. // canceled.
  2082. func (c *ProjectsSubscriptionsModifyPushConfigCall) Context(ctx context.Context) *ProjectsSubscriptionsModifyPushConfigCall {
  2083. c.ctx_ = ctx
  2084. return c
  2085. }
  2086. // Header returns an http.Header that can be modified by the caller to
  2087. // add HTTP headers to the request.
  2088. func (c *ProjectsSubscriptionsModifyPushConfigCall) Header() http.Header {
  2089. if c.header_ == nil {
  2090. c.header_ = make(http.Header)
  2091. }
  2092. return c.header_
  2093. }
  2094. func (c *ProjectsSubscriptionsModifyPushConfigCall) doRequest(alt string) (*http.Response, error) {
  2095. reqHeaders := make(http.Header)
  2096. for k, v := range c.header_ {
  2097. reqHeaders[k] = v
  2098. }
  2099. reqHeaders.Set("User-Agent", c.s.userAgent())
  2100. var body io.Reader = nil
  2101. body, err := googleapi.WithoutDataWrapper.JSONReader(c.modifypushconfigrequest)
  2102. if err != nil {
  2103. return nil, err
  2104. }
  2105. reqHeaders.Set("Content-Type", "application/json")
  2106. c.urlParams_.Set("alt", alt)
  2107. c.urlParams_.Set("prettyPrint", "false")
  2108. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+subscription}:modifyPushConfig")
  2109. urls += "?" + c.urlParams_.Encode()
  2110. req, err := http.NewRequest("POST", urls, body)
  2111. if err != nil {
  2112. return nil, err
  2113. }
  2114. req.Header = reqHeaders
  2115. googleapi.Expand(req.URL, map[string]string{
  2116. "subscription": c.subscription,
  2117. })
  2118. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2119. }
  2120. // Do executes the "pubsub.projects.subscriptions.modifyPushConfig" call.
  2121. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  2122. // code is an error. Response headers are in either
  2123. // *Empty.ServerResponse.Header or (if a response was returned at all)
  2124. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2125. // check whether the returned error was because http.StatusNotModified
  2126. // was returned.
  2127. func (c *ProjectsSubscriptionsModifyPushConfigCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  2128. gensupport.SetOptions(c.urlParams_, opts...)
  2129. res, err := c.doRequest("json")
  2130. if res != nil && res.StatusCode == http.StatusNotModified {
  2131. if res.Body != nil {
  2132. res.Body.Close()
  2133. }
  2134. return nil, &googleapi.Error{
  2135. Code: res.StatusCode,
  2136. Header: res.Header,
  2137. }
  2138. }
  2139. if err != nil {
  2140. return nil, err
  2141. }
  2142. defer googleapi.CloseBody(res)
  2143. if err := googleapi.CheckResponse(res); err != nil {
  2144. return nil, err
  2145. }
  2146. ret := &Empty{
  2147. ServerResponse: googleapi.ServerResponse{
  2148. Header: res.Header,
  2149. HTTPStatusCode: res.StatusCode,
  2150. },
  2151. }
  2152. target := &ret
  2153. if err := gensupport.DecodeResponse(target, res); err != nil {
  2154. return nil, err
  2155. }
  2156. return ret, nil
  2157. // {
  2158. // "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`.",
  2159. // "flatPath": "v1beta2/projects/{projectsId}/subscriptions/{subscriptionsId}:modifyPushConfig",
  2160. // "httpMethod": "POST",
  2161. // "id": "pubsub.projects.subscriptions.modifyPushConfig",
  2162. // "parameterOrder": [
  2163. // "subscription"
  2164. // ],
  2165. // "parameters": {
  2166. // "subscription": {
  2167. // "description": "The name of the subscription.",
  2168. // "location": "path",
  2169. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  2170. // "required": true,
  2171. // "type": "string"
  2172. // }
  2173. // },
  2174. // "path": "v1beta2/{+subscription}:modifyPushConfig",
  2175. // "request": {
  2176. // "$ref": "ModifyPushConfigRequest"
  2177. // },
  2178. // "response": {
  2179. // "$ref": "Empty"
  2180. // },
  2181. // "scopes": [
  2182. // "https://www.googleapis.com/auth/cloud-platform",
  2183. // "https://www.googleapis.com/auth/pubsub"
  2184. // ]
  2185. // }
  2186. }
  2187. // method id "pubsub.projects.subscriptions.pull":
  2188. type ProjectsSubscriptionsPullCall struct {
  2189. s *Service
  2190. subscription string
  2191. pullrequest *PullRequest
  2192. urlParams_ gensupport.URLParams
  2193. ctx_ context.Context
  2194. header_ http.Header
  2195. }
  2196. // Pull: Pulls messages from the server. Returns an empty list if there
  2197. // are no
  2198. // messages available in the backlog. The server may return
  2199. // `UNAVAILABLE` if
  2200. // there are too many concurrent pull requests pending for the
  2201. // given
  2202. // subscription.
  2203. func (r *ProjectsSubscriptionsService) Pull(subscription string, pullrequest *PullRequest) *ProjectsSubscriptionsPullCall {
  2204. c := &ProjectsSubscriptionsPullCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2205. c.subscription = subscription
  2206. c.pullrequest = pullrequest
  2207. return c
  2208. }
  2209. // Fields allows partial responses to be retrieved. See
  2210. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2211. // for more information.
  2212. func (c *ProjectsSubscriptionsPullCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsPullCall {
  2213. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2214. return c
  2215. }
  2216. // Context sets the context to be used in this call's Do method. Any
  2217. // pending HTTP request will be aborted if the provided context is
  2218. // canceled.
  2219. func (c *ProjectsSubscriptionsPullCall) Context(ctx context.Context) *ProjectsSubscriptionsPullCall {
  2220. c.ctx_ = ctx
  2221. return c
  2222. }
  2223. // Header returns an http.Header that can be modified by the caller to
  2224. // add HTTP headers to the request.
  2225. func (c *ProjectsSubscriptionsPullCall) Header() http.Header {
  2226. if c.header_ == nil {
  2227. c.header_ = make(http.Header)
  2228. }
  2229. return c.header_
  2230. }
  2231. func (c *ProjectsSubscriptionsPullCall) doRequest(alt string) (*http.Response, error) {
  2232. reqHeaders := make(http.Header)
  2233. for k, v := range c.header_ {
  2234. reqHeaders[k] = v
  2235. }
  2236. reqHeaders.Set("User-Agent", c.s.userAgent())
  2237. var body io.Reader = nil
  2238. body, err := googleapi.WithoutDataWrapper.JSONReader(c.pullrequest)
  2239. if err != nil {
  2240. return nil, err
  2241. }
  2242. reqHeaders.Set("Content-Type", "application/json")
  2243. c.urlParams_.Set("alt", alt)
  2244. c.urlParams_.Set("prettyPrint", "false")
  2245. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+subscription}:pull")
  2246. urls += "?" + c.urlParams_.Encode()
  2247. req, err := http.NewRequest("POST", urls, body)
  2248. if err != nil {
  2249. return nil, err
  2250. }
  2251. req.Header = reqHeaders
  2252. googleapi.Expand(req.URL, map[string]string{
  2253. "subscription": c.subscription,
  2254. })
  2255. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2256. }
  2257. // Do executes the "pubsub.projects.subscriptions.pull" call.
  2258. // Exactly one of *PullResponse or error will be non-nil. Any non-2xx
  2259. // status code is an error. Response headers are in either
  2260. // *PullResponse.ServerResponse.Header or (if a response was returned at
  2261. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  2262. // to check whether the returned error was because
  2263. // http.StatusNotModified was returned.
  2264. func (c *ProjectsSubscriptionsPullCall) Do(opts ...googleapi.CallOption) (*PullResponse, error) {
  2265. gensupport.SetOptions(c.urlParams_, opts...)
  2266. res, err := c.doRequest("json")
  2267. if res != nil && res.StatusCode == http.StatusNotModified {
  2268. if res.Body != nil {
  2269. res.Body.Close()
  2270. }
  2271. return nil, &googleapi.Error{
  2272. Code: res.StatusCode,
  2273. Header: res.Header,
  2274. }
  2275. }
  2276. if err != nil {
  2277. return nil, err
  2278. }
  2279. defer googleapi.CloseBody(res)
  2280. if err := googleapi.CheckResponse(res); err != nil {
  2281. return nil, err
  2282. }
  2283. ret := &PullResponse{
  2284. ServerResponse: googleapi.ServerResponse{
  2285. Header: res.Header,
  2286. HTTPStatusCode: res.StatusCode,
  2287. },
  2288. }
  2289. target := &ret
  2290. if err := gensupport.DecodeResponse(target, res); err != nil {
  2291. return nil, err
  2292. }
  2293. return ret, nil
  2294. // {
  2295. // "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.",
  2296. // "flatPath": "v1beta2/projects/{projectsId}/subscriptions/{subscriptionsId}:pull",
  2297. // "httpMethod": "POST",
  2298. // "id": "pubsub.projects.subscriptions.pull",
  2299. // "parameterOrder": [
  2300. // "subscription"
  2301. // ],
  2302. // "parameters": {
  2303. // "subscription": {
  2304. // "description": "The subscription from which messages should be pulled.",
  2305. // "location": "path",
  2306. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  2307. // "required": true,
  2308. // "type": "string"
  2309. // }
  2310. // },
  2311. // "path": "v1beta2/{+subscription}:pull",
  2312. // "request": {
  2313. // "$ref": "PullRequest"
  2314. // },
  2315. // "response": {
  2316. // "$ref": "PullResponse"
  2317. // },
  2318. // "scopes": [
  2319. // "https://www.googleapis.com/auth/cloud-platform",
  2320. // "https://www.googleapis.com/auth/pubsub"
  2321. // ]
  2322. // }
  2323. }
  2324. // method id "pubsub.projects.subscriptions.setIamPolicy":
  2325. type ProjectsSubscriptionsSetIamPolicyCall struct {
  2326. s *Service
  2327. resource string
  2328. setiampolicyrequest *SetIamPolicyRequest
  2329. urlParams_ gensupport.URLParams
  2330. ctx_ context.Context
  2331. header_ http.Header
  2332. }
  2333. // SetIamPolicy: Sets the access control policy on the specified
  2334. // resource. Replaces any
  2335. // existing policy.
  2336. func (r *ProjectsSubscriptionsService) SetIamPolicy(resource string, setiampolicyrequest *SetIamPolicyRequest) *ProjectsSubscriptionsSetIamPolicyCall {
  2337. c := &ProjectsSubscriptionsSetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2338. c.resource = resource
  2339. c.setiampolicyrequest = setiampolicyrequest
  2340. return c
  2341. }
  2342. // Fields allows partial responses to be retrieved. See
  2343. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2344. // for more information.
  2345. func (c *ProjectsSubscriptionsSetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsSetIamPolicyCall {
  2346. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2347. return c
  2348. }
  2349. // Context sets the context to be used in this call's Do method. Any
  2350. // pending HTTP request will be aborted if the provided context is
  2351. // canceled.
  2352. func (c *ProjectsSubscriptionsSetIamPolicyCall) Context(ctx context.Context) *ProjectsSubscriptionsSetIamPolicyCall {
  2353. c.ctx_ = ctx
  2354. return c
  2355. }
  2356. // Header returns an http.Header that can be modified by the caller to
  2357. // add HTTP headers to the request.
  2358. func (c *ProjectsSubscriptionsSetIamPolicyCall) Header() http.Header {
  2359. if c.header_ == nil {
  2360. c.header_ = make(http.Header)
  2361. }
  2362. return c.header_
  2363. }
  2364. func (c *ProjectsSubscriptionsSetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  2365. reqHeaders := make(http.Header)
  2366. for k, v := range c.header_ {
  2367. reqHeaders[k] = v
  2368. }
  2369. reqHeaders.Set("User-Agent", c.s.userAgent())
  2370. var body io.Reader = nil
  2371. body, err := googleapi.WithoutDataWrapper.JSONReader(c.setiampolicyrequest)
  2372. if err != nil {
  2373. return nil, err
  2374. }
  2375. reqHeaders.Set("Content-Type", "application/json")
  2376. c.urlParams_.Set("alt", alt)
  2377. c.urlParams_.Set("prettyPrint", "false")
  2378. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+resource}:setIamPolicy")
  2379. urls += "?" + c.urlParams_.Encode()
  2380. req, err := http.NewRequest("POST", urls, body)
  2381. if err != nil {
  2382. return nil, err
  2383. }
  2384. req.Header = reqHeaders
  2385. googleapi.Expand(req.URL, map[string]string{
  2386. "resource": c.resource,
  2387. })
  2388. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2389. }
  2390. // Do executes the "pubsub.projects.subscriptions.setIamPolicy" call.
  2391. // Exactly one of *Policy or error will be non-nil. Any non-2xx status
  2392. // code is an error. Response headers are in either
  2393. // *Policy.ServerResponse.Header or (if a response was returned at all)
  2394. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2395. // check whether the returned error was because http.StatusNotModified
  2396. // was returned.
  2397. func (c *ProjectsSubscriptionsSetIamPolicyCall) Do(opts ...googleapi.CallOption) (*Policy, error) {
  2398. gensupport.SetOptions(c.urlParams_, opts...)
  2399. res, err := c.doRequest("json")
  2400. if res != nil && res.StatusCode == http.StatusNotModified {
  2401. if res.Body != nil {
  2402. res.Body.Close()
  2403. }
  2404. return nil, &googleapi.Error{
  2405. Code: res.StatusCode,
  2406. Header: res.Header,
  2407. }
  2408. }
  2409. if err != nil {
  2410. return nil, err
  2411. }
  2412. defer googleapi.CloseBody(res)
  2413. if err := googleapi.CheckResponse(res); err != nil {
  2414. return nil, err
  2415. }
  2416. ret := &Policy{
  2417. ServerResponse: googleapi.ServerResponse{
  2418. Header: res.Header,
  2419. HTTPStatusCode: res.StatusCode,
  2420. },
  2421. }
  2422. target := &ret
  2423. if err := gensupport.DecodeResponse(target, res); err != nil {
  2424. return nil, err
  2425. }
  2426. return ret, nil
  2427. // {
  2428. // "description": "Sets the access control policy on the specified resource. Replaces any\nexisting policy.",
  2429. // "flatPath": "v1beta2/projects/{projectsId}/subscriptions/{subscriptionsId}:setIamPolicy",
  2430. // "httpMethod": "POST",
  2431. // "id": "pubsub.projects.subscriptions.setIamPolicy",
  2432. // "parameterOrder": [
  2433. // "resource"
  2434. // ],
  2435. // "parameters": {
  2436. // "resource": {
  2437. // "description": "REQUIRED: The resource for which the policy is being specified.\nSee the operation documentation for the appropriate value for this field.",
  2438. // "location": "path",
  2439. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  2440. // "required": true,
  2441. // "type": "string"
  2442. // }
  2443. // },
  2444. // "path": "v1beta2/{+resource}:setIamPolicy",
  2445. // "request": {
  2446. // "$ref": "SetIamPolicyRequest"
  2447. // },
  2448. // "response": {
  2449. // "$ref": "Policy"
  2450. // },
  2451. // "scopes": [
  2452. // "https://www.googleapis.com/auth/cloud-platform",
  2453. // "https://www.googleapis.com/auth/pubsub"
  2454. // ]
  2455. // }
  2456. }
  2457. // method id "pubsub.projects.subscriptions.testIamPermissions":
  2458. type ProjectsSubscriptionsTestIamPermissionsCall struct {
  2459. s *Service
  2460. resource string
  2461. testiampermissionsrequest *TestIamPermissionsRequest
  2462. urlParams_ gensupport.URLParams
  2463. ctx_ context.Context
  2464. header_ http.Header
  2465. }
  2466. // TestIamPermissions: Returns permissions that a caller has on the
  2467. // specified resource.
  2468. // If the resource does not exist, this will return an empty set
  2469. // of
  2470. // permissions, not a NOT_FOUND error.
  2471. //
  2472. // Note: This operation is designed to be used for building
  2473. // permission-aware
  2474. // UIs and command-line tools, not for authorization checking. This
  2475. // operation
  2476. // may "fail open" without warning.
  2477. func (r *ProjectsSubscriptionsService) TestIamPermissions(resource string, testiampermissionsrequest *TestIamPermissionsRequest) *ProjectsSubscriptionsTestIamPermissionsCall {
  2478. c := &ProjectsSubscriptionsTestIamPermissionsCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2479. c.resource = resource
  2480. c.testiampermissionsrequest = testiampermissionsrequest
  2481. return c
  2482. }
  2483. // Fields allows partial responses to be retrieved. See
  2484. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2485. // for more information.
  2486. func (c *ProjectsSubscriptionsTestIamPermissionsCall) Fields(s ...googleapi.Field) *ProjectsSubscriptionsTestIamPermissionsCall {
  2487. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2488. return c
  2489. }
  2490. // Context sets the context to be used in this call's Do method. Any
  2491. // pending HTTP request will be aborted if the provided context is
  2492. // canceled.
  2493. func (c *ProjectsSubscriptionsTestIamPermissionsCall) Context(ctx context.Context) *ProjectsSubscriptionsTestIamPermissionsCall {
  2494. c.ctx_ = ctx
  2495. return c
  2496. }
  2497. // Header returns an http.Header that can be modified by the caller to
  2498. // add HTTP headers to the request.
  2499. func (c *ProjectsSubscriptionsTestIamPermissionsCall) Header() http.Header {
  2500. if c.header_ == nil {
  2501. c.header_ = make(http.Header)
  2502. }
  2503. return c.header_
  2504. }
  2505. func (c *ProjectsSubscriptionsTestIamPermissionsCall) doRequest(alt string) (*http.Response, error) {
  2506. reqHeaders := make(http.Header)
  2507. for k, v := range c.header_ {
  2508. reqHeaders[k] = v
  2509. }
  2510. reqHeaders.Set("User-Agent", c.s.userAgent())
  2511. var body io.Reader = nil
  2512. body, err := googleapi.WithoutDataWrapper.JSONReader(c.testiampermissionsrequest)
  2513. if err != nil {
  2514. return nil, err
  2515. }
  2516. reqHeaders.Set("Content-Type", "application/json")
  2517. c.urlParams_.Set("alt", alt)
  2518. c.urlParams_.Set("prettyPrint", "false")
  2519. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+resource}:testIamPermissions")
  2520. urls += "?" + c.urlParams_.Encode()
  2521. req, err := http.NewRequest("POST", urls, body)
  2522. if err != nil {
  2523. return nil, err
  2524. }
  2525. req.Header = reqHeaders
  2526. googleapi.Expand(req.URL, map[string]string{
  2527. "resource": c.resource,
  2528. })
  2529. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2530. }
  2531. // Do executes the "pubsub.projects.subscriptions.testIamPermissions" call.
  2532. // Exactly one of *TestIamPermissionsResponse or error will be non-nil.
  2533. // Any non-2xx status code is an error. Response headers are in either
  2534. // *TestIamPermissionsResponse.ServerResponse.Header or (if a response
  2535. // was returned at all) in error.(*googleapi.Error).Header. Use
  2536. // googleapi.IsNotModified to check whether the returned error was
  2537. // because http.StatusNotModified was returned.
  2538. func (c *ProjectsSubscriptionsTestIamPermissionsCall) Do(opts ...googleapi.CallOption) (*TestIamPermissionsResponse, error) {
  2539. gensupport.SetOptions(c.urlParams_, opts...)
  2540. res, err := c.doRequest("json")
  2541. if res != nil && res.StatusCode == http.StatusNotModified {
  2542. if res.Body != nil {
  2543. res.Body.Close()
  2544. }
  2545. return nil, &googleapi.Error{
  2546. Code: res.StatusCode,
  2547. Header: res.Header,
  2548. }
  2549. }
  2550. if err != nil {
  2551. return nil, err
  2552. }
  2553. defer googleapi.CloseBody(res)
  2554. if err := googleapi.CheckResponse(res); err != nil {
  2555. return nil, err
  2556. }
  2557. ret := &TestIamPermissionsResponse{
  2558. ServerResponse: googleapi.ServerResponse{
  2559. Header: res.Header,
  2560. HTTPStatusCode: res.StatusCode,
  2561. },
  2562. }
  2563. target := &ret
  2564. if err := gensupport.DecodeResponse(target, res); err != nil {
  2565. return nil, err
  2566. }
  2567. return ret, nil
  2568. // {
  2569. // "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.",
  2570. // "flatPath": "v1beta2/projects/{projectsId}/subscriptions/{subscriptionsId}:testIamPermissions",
  2571. // "httpMethod": "POST",
  2572. // "id": "pubsub.projects.subscriptions.testIamPermissions",
  2573. // "parameterOrder": [
  2574. // "resource"
  2575. // ],
  2576. // "parameters": {
  2577. // "resource": {
  2578. // "description": "REQUIRED: The resource for which the policy detail is being requested.\nSee the operation documentation for the appropriate value for this field.",
  2579. // "location": "path",
  2580. // "pattern": "^projects/[^/]+/subscriptions/[^/]+$",
  2581. // "required": true,
  2582. // "type": "string"
  2583. // }
  2584. // },
  2585. // "path": "v1beta2/{+resource}:testIamPermissions",
  2586. // "request": {
  2587. // "$ref": "TestIamPermissionsRequest"
  2588. // },
  2589. // "response": {
  2590. // "$ref": "TestIamPermissionsResponse"
  2591. // },
  2592. // "scopes": [
  2593. // "https://www.googleapis.com/auth/cloud-platform",
  2594. // "https://www.googleapis.com/auth/pubsub"
  2595. // ]
  2596. // }
  2597. }
  2598. // method id "pubsub.projects.topics.create":
  2599. type ProjectsTopicsCreateCall struct {
  2600. s *Service
  2601. name string
  2602. topic *Topic
  2603. urlParams_ gensupport.URLParams
  2604. ctx_ context.Context
  2605. header_ http.Header
  2606. }
  2607. // Create: Creates the given topic with the given name.
  2608. func (r *ProjectsTopicsService) Create(name string, topic *Topic) *ProjectsTopicsCreateCall {
  2609. c := &ProjectsTopicsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2610. c.name = name
  2611. c.topic = topic
  2612. return c
  2613. }
  2614. // Fields allows partial responses to be retrieved. See
  2615. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2616. // for more information.
  2617. func (c *ProjectsTopicsCreateCall) Fields(s ...googleapi.Field) *ProjectsTopicsCreateCall {
  2618. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2619. return c
  2620. }
  2621. // Context sets the context to be used in this call's Do method. Any
  2622. // pending HTTP request will be aborted if the provided context is
  2623. // canceled.
  2624. func (c *ProjectsTopicsCreateCall) Context(ctx context.Context) *ProjectsTopicsCreateCall {
  2625. c.ctx_ = ctx
  2626. return c
  2627. }
  2628. // Header returns an http.Header that can be modified by the caller to
  2629. // add HTTP headers to the request.
  2630. func (c *ProjectsTopicsCreateCall) Header() http.Header {
  2631. if c.header_ == nil {
  2632. c.header_ = make(http.Header)
  2633. }
  2634. return c.header_
  2635. }
  2636. func (c *ProjectsTopicsCreateCall) doRequest(alt string) (*http.Response, error) {
  2637. reqHeaders := make(http.Header)
  2638. for k, v := range c.header_ {
  2639. reqHeaders[k] = v
  2640. }
  2641. reqHeaders.Set("User-Agent", c.s.userAgent())
  2642. var body io.Reader = nil
  2643. body, err := googleapi.WithoutDataWrapper.JSONReader(c.topic)
  2644. if err != nil {
  2645. return nil, err
  2646. }
  2647. reqHeaders.Set("Content-Type", "application/json")
  2648. c.urlParams_.Set("alt", alt)
  2649. c.urlParams_.Set("prettyPrint", "false")
  2650. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+name}")
  2651. urls += "?" + c.urlParams_.Encode()
  2652. req, err := http.NewRequest("PUT", urls, body)
  2653. if err != nil {
  2654. return nil, err
  2655. }
  2656. req.Header = reqHeaders
  2657. googleapi.Expand(req.URL, map[string]string{
  2658. "name": c.name,
  2659. })
  2660. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2661. }
  2662. // Do executes the "pubsub.projects.topics.create" call.
  2663. // Exactly one of *Topic or error will be non-nil. Any non-2xx status
  2664. // code is an error. Response headers are in either
  2665. // *Topic.ServerResponse.Header or (if a response was returned at all)
  2666. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2667. // check whether the returned error was because http.StatusNotModified
  2668. // was returned.
  2669. func (c *ProjectsTopicsCreateCall) Do(opts ...googleapi.CallOption) (*Topic, error) {
  2670. gensupport.SetOptions(c.urlParams_, opts...)
  2671. res, err := c.doRequest("json")
  2672. if res != nil && res.StatusCode == http.StatusNotModified {
  2673. if res.Body != nil {
  2674. res.Body.Close()
  2675. }
  2676. return nil, &googleapi.Error{
  2677. Code: res.StatusCode,
  2678. Header: res.Header,
  2679. }
  2680. }
  2681. if err != nil {
  2682. return nil, err
  2683. }
  2684. defer googleapi.CloseBody(res)
  2685. if err := googleapi.CheckResponse(res); err != nil {
  2686. return nil, err
  2687. }
  2688. ret := &Topic{
  2689. ServerResponse: googleapi.ServerResponse{
  2690. Header: res.Header,
  2691. HTTPStatusCode: res.StatusCode,
  2692. },
  2693. }
  2694. target := &ret
  2695. if err := gensupport.DecodeResponse(target, res); err != nil {
  2696. return nil, err
  2697. }
  2698. return ret, nil
  2699. // {
  2700. // "description": "Creates the given topic with the given name.",
  2701. // "flatPath": "v1beta2/projects/{projectsId}/topics/{topicsId}",
  2702. // "httpMethod": "PUT",
  2703. // "id": "pubsub.projects.topics.create",
  2704. // "parameterOrder": [
  2705. // "name"
  2706. // ],
  2707. // "parameters": {
  2708. // "name": {
  2709. // "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\"`.",
  2710. // "location": "path",
  2711. // "pattern": "^projects/[^/]+/topics/[^/]+$",
  2712. // "required": true,
  2713. // "type": "string"
  2714. // }
  2715. // },
  2716. // "path": "v1beta2/{+name}",
  2717. // "request": {
  2718. // "$ref": "Topic"
  2719. // },
  2720. // "response": {
  2721. // "$ref": "Topic"
  2722. // },
  2723. // "scopes": [
  2724. // "https://www.googleapis.com/auth/cloud-platform",
  2725. // "https://www.googleapis.com/auth/pubsub"
  2726. // ]
  2727. // }
  2728. }
  2729. // method id "pubsub.projects.topics.delete":
  2730. type ProjectsTopicsDeleteCall struct {
  2731. s *Service
  2732. topic string
  2733. urlParams_ gensupport.URLParams
  2734. ctx_ context.Context
  2735. header_ http.Header
  2736. }
  2737. // Delete: Deletes the topic with the given name. Returns `NOT_FOUND` if
  2738. // the topic
  2739. // does not exist. After a topic is deleted, a new topic may be created
  2740. // with
  2741. // the same name; this is an entirely new topic with none of the
  2742. // old
  2743. // configuration or subscriptions. Existing subscriptions to this topic
  2744. // are
  2745. // not deleted, but their `topic` field is set to `_deleted-topic_`.
  2746. func (r *ProjectsTopicsService) Delete(topic string) *ProjectsTopicsDeleteCall {
  2747. c := &ProjectsTopicsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2748. c.topic = topic
  2749. return c
  2750. }
  2751. // Fields allows partial responses to be retrieved. See
  2752. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2753. // for more information.
  2754. func (c *ProjectsTopicsDeleteCall) Fields(s ...googleapi.Field) *ProjectsTopicsDeleteCall {
  2755. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2756. return c
  2757. }
  2758. // Context sets the context to be used in this call's Do method. Any
  2759. // pending HTTP request will be aborted if the provided context is
  2760. // canceled.
  2761. func (c *ProjectsTopicsDeleteCall) Context(ctx context.Context) *ProjectsTopicsDeleteCall {
  2762. c.ctx_ = ctx
  2763. return c
  2764. }
  2765. // Header returns an http.Header that can be modified by the caller to
  2766. // add HTTP headers to the request.
  2767. func (c *ProjectsTopicsDeleteCall) Header() http.Header {
  2768. if c.header_ == nil {
  2769. c.header_ = make(http.Header)
  2770. }
  2771. return c.header_
  2772. }
  2773. func (c *ProjectsTopicsDeleteCall) doRequest(alt string) (*http.Response, error) {
  2774. reqHeaders := make(http.Header)
  2775. for k, v := range c.header_ {
  2776. reqHeaders[k] = v
  2777. }
  2778. reqHeaders.Set("User-Agent", c.s.userAgent())
  2779. var body io.Reader = nil
  2780. c.urlParams_.Set("alt", alt)
  2781. c.urlParams_.Set("prettyPrint", "false")
  2782. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+topic}")
  2783. urls += "?" + c.urlParams_.Encode()
  2784. req, err := http.NewRequest("DELETE", urls, body)
  2785. if err != nil {
  2786. return nil, err
  2787. }
  2788. req.Header = reqHeaders
  2789. googleapi.Expand(req.URL, map[string]string{
  2790. "topic": c.topic,
  2791. })
  2792. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2793. }
  2794. // Do executes the "pubsub.projects.topics.delete" call.
  2795. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  2796. // code is an error. Response headers are in either
  2797. // *Empty.ServerResponse.Header or (if a response was returned at all)
  2798. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2799. // check whether the returned error was because http.StatusNotModified
  2800. // was returned.
  2801. func (c *ProjectsTopicsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  2802. gensupport.SetOptions(c.urlParams_, opts...)
  2803. res, err := c.doRequest("json")
  2804. if res != nil && res.StatusCode == http.StatusNotModified {
  2805. if res.Body != nil {
  2806. res.Body.Close()
  2807. }
  2808. return nil, &googleapi.Error{
  2809. Code: res.StatusCode,
  2810. Header: res.Header,
  2811. }
  2812. }
  2813. if err != nil {
  2814. return nil, err
  2815. }
  2816. defer googleapi.CloseBody(res)
  2817. if err := googleapi.CheckResponse(res); err != nil {
  2818. return nil, err
  2819. }
  2820. ret := &Empty{
  2821. ServerResponse: googleapi.ServerResponse{
  2822. Header: res.Header,
  2823. HTTPStatusCode: res.StatusCode,
  2824. },
  2825. }
  2826. target := &ret
  2827. if err := gensupport.DecodeResponse(target, res); err != nil {
  2828. return nil, err
  2829. }
  2830. return ret, nil
  2831. // {
  2832. // "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_`.",
  2833. // "flatPath": "v1beta2/projects/{projectsId}/topics/{topicsId}",
  2834. // "httpMethod": "DELETE",
  2835. // "id": "pubsub.projects.topics.delete",
  2836. // "parameterOrder": [
  2837. // "topic"
  2838. // ],
  2839. // "parameters": {
  2840. // "topic": {
  2841. // "description": "Name of the topic to delete.",
  2842. // "location": "path",
  2843. // "pattern": "^projects/[^/]+/topics/[^/]+$",
  2844. // "required": true,
  2845. // "type": "string"
  2846. // }
  2847. // },
  2848. // "path": "v1beta2/{+topic}",
  2849. // "response": {
  2850. // "$ref": "Empty"
  2851. // },
  2852. // "scopes": [
  2853. // "https://www.googleapis.com/auth/cloud-platform",
  2854. // "https://www.googleapis.com/auth/pubsub"
  2855. // ]
  2856. // }
  2857. }
  2858. // method id "pubsub.projects.topics.get":
  2859. type ProjectsTopicsGetCall struct {
  2860. s *Service
  2861. topic string
  2862. urlParams_ gensupport.URLParams
  2863. ifNoneMatch_ string
  2864. ctx_ context.Context
  2865. header_ http.Header
  2866. }
  2867. // Get: Gets the configuration of a topic.
  2868. func (r *ProjectsTopicsService) Get(topic string) *ProjectsTopicsGetCall {
  2869. c := &ProjectsTopicsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2870. c.topic = topic
  2871. return c
  2872. }
  2873. // Fields allows partial responses to be retrieved. See
  2874. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2875. // for more information.
  2876. func (c *ProjectsTopicsGetCall) Fields(s ...googleapi.Field) *ProjectsTopicsGetCall {
  2877. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2878. return c
  2879. }
  2880. // IfNoneMatch sets the optional parameter which makes the operation
  2881. // fail if the object's ETag matches the given value. This is useful for
  2882. // getting updates only after the object has changed since the last
  2883. // request. Use googleapi.IsNotModified to check whether the response
  2884. // error from Do is the result of In-None-Match.
  2885. func (c *ProjectsTopicsGetCall) IfNoneMatch(entityTag string) *ProjectsTopicsGetCall {
  2886. c.ifNoneMatch_ = entityTag
  2887. return c
  2888. }
  2889. // Context sets the context to be used in this call's Do method. Any
  2890. // pending HTTP request will be aborted if the provided context is
  2891. // canceled.
  2892. func (c *ProjectsTopicsGetCall) Context(ctx context.Context) *ProjectsTopicsGetCall {
  2893. c.ctx_ = ctx
  2894. return c
  2895. }
  2896. // Header returns an http.Header that can be modified by the caller to
  2897. // add HTTP headers to the request.
  2898. func (c *ProjectsTopicsGetCall) Header() http.Header {
  2899. if c.header_ == nil {
  2900. c.header_ = make(http.Header)
  2901. }
  2902. return c.header_
  2903. }
  2904. func (c *ProjectsTopicsGetCall) doRequest(alt string) (*http.Response, error) {
  2905. reqHeaders := make(http.Header)
  2906. for k, v := range c.header_ {
  2907. reqHeaders[k] = v
  2908. }
  2909. reqHeaders.Set("User-Agent", c.s.userAgent())
  2910. if c.ifNoneMatch_ != "" {
  2911. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  2912. }
  2913. var body io.Reader = nil
  2914. c.urlParams_.Set("alt", alt)
  2915. c.urlParams_.Set("prettyPrint", "false")
  2916. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+topic}")
  2917. urls += "?" + c.urlParams_.Encode()
  2918. req, err := http.NewRequest("GET", urls, body)
  2919. if err != nil {
  2920. return nil, err
  2921. }
  2922. req.Header = reqHeaders
  2923. googleapi.Expand(req.URL, map[string]string{
  2924. "topic": c.topic,
  2925. })
  2926. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2927. }
  2928. // Do executes the "pubsub.projects.topics.get" call.
  2929. // Exactly one of *Topic or error will be non-nil. Any non-2xx status
  2930. // code is an error. Response headers are in either
  2931. // *Topic.ServerResponse.Header or (if a response was returned at all)
  2932. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2933. // check whether the returned error was because http.StatusNotModified
  2934. // was returned.
  2935. func (c *ProjectsTopicsGetCall) Do(opts ...googleapi.CallOption) (*Topic, error) {
  2936. gensupport.SetOptions(c.urlParams_, opts...)
  2937. res, err := c.doRequest("json")
  2938. if res != nil && res.StatusCode == http.StatusNotModified {
  2939. if res.Body != nil {
  2940. res.Body.Close()
  2941. }
  2942. return nil, &googleapi.Error{
  2943. Code: res.StatusCode,
  2944. Header: res.Header,
  2945. }
  2946. }
  2947. if err != nil {
  2948. return nil, err
  2949. }
  2950. defer googleapi.CloseBody(res)
  2951. if err := googleapi.CheckResponse(res); err != nil {
  2952. return nil, err
  2953. }
  2954. ret := &Topic{
  2955. ServerResponse: googleapi.ServerResponse{
  2956. Header: res.Header,
  2957. HTTPStatusCode: res.StatusCode,
  2958. },
  2959. }
  2960. target := &ret
  2961. if err := gensupport.DecodeResponse(target, res); err != nil {
  2962. return nil, err
  2963. }
  2964. return ret, nil
  2965. // {
  2966. // "description": "Gets the configuration of a topic.",
  2967. // "flatPath": "v1beta2/projects/{projectsId}/topics/{topicsId}",
  2968. // "httpMethod": "GET",
  2969. // "id": "pubsub.projects.topics.get",
  2970. // "parameterOrder": [
  2971. // "topic"
  2972. // ],
  2973. // "parameters": {
  2974. // "topic": {
  2975. // "description": "The name of the topic to get.",
  2976. // "location": "path",
  2977. // "pattern": "^projects/[^/]+/topics/[^/]+$",
  2978. // "required": true,
  2979. // "type": "string"
  2980. // }
  2981. // },
  2982. // "path": "v1beta2/{+topic}",
  2983. // "response": {
  2984. // "$ref": "Topic"
  2985. // },
  2986. // "scopes": [
  2987. // "https://www.googleapis.com/auth/cloud-platform",
  2988. // "https://www.googleapis.com/auth/pubsub"
  2989. // ]
  2990. // }
  2991. }
  2992. // method id "pubsub.projects.topics.getIamPolicy":
  2993. type ProjectsTopicsGetIamPolicyCall struct {
  2994. s *Service
  2995. resource string
  2996. urlParams_ gensupport.URLParams
  2997. ifNoneMatch_ string
  2998. ctx_ context.Context
  2999. header_ http.Header
  3000. }
  3001. // GetIamPolicy: Gets the access control policy for a resource.
  3002. // Returns an empty policy if the resource exists and does not have a
  3003. // policy
  3004. // set.
  3005. func (r *ProjectsTopicsService) GetIamPolicy(resource string) *ProjectsTopicsGetIamPolicyCall {
  3006. c := &ProjectsTopicsGetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3007. c.resource = resource
  3008. return c
  3009. }
  3010. // Fields allows partial responses to be retrieved. See
  3011. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3012. // for more information.
  3013. func (c *ProjectsTopicsGetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsTopicsGetIamPolicyCall {
  3014. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3015. return c
  3016. }
  3017. // IfNoneMatch sets the optional parameter which makes the operation
  3018. // fail if the object's ETag matches the given value. This is useful for
  3019. // getting updates only after the object has changed since the last
  3020. // request. Use googleapi.IsNotModified to check whether the response
  3021. // error from Do is the result of In-None-Match.
  3022. func (c *ProjectsTopicsGetIamPolicyCall) IfNoneMatch(entityTag string) *ProjectsTopicsGetIamPolicyCall {
  3023. c.ifNoneMatch_ = entityTag
  3024. return c
  3025. }
  3026. // Context sets the context to be used in this call's Do method. Any
  3027. // pending HTTP request will be aborted if the provided context is
  3028. // canceled.
  3029. func (c *ProjectsTopicsGetIamPolicyCall) Context(ctx context.Context) *ProjectsTopicsGetIamPolicyCall {
  3030. c.ctx_ = ctx
  3031. return c
  3032. }
  3033. // Header returns an http.Header that can be modified by the caller to
  3034. // add HTTP headers to the request.
  3035. func (c *ProjectsTopicsGetIamPolicyCall) Header() http.Header {
  3036. if c.header_ == nil {
  3037. c.header_ = make(http.Header)
  3038. }
  3039. return c.header_
  3040. }
  3041. func (c *ProjectsTopicsGetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  3042. reqHeaders := make(http.Header)
  3043. for k, v := range c.header_ {
  3044. reqHeaders[k] = v
  3045. }
  3046. reqHeaders.Set("User-Agent", c.s.userAgent())
  3047. if c.ifNoneMatch_ != "" {
  3048. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  3049. }
  3050. var body io.Reader = nil
  3051. c.urlParams_.Set("alt", alt)
  3052. c.urlParams_.Set("prettyPrint", "false")
  3053. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+resource}:getIamPolicy")
  3054. urls += "?" + c.urlParams_.Encode()
  3055. req, err := http.NewRequest("GET", urls, body)
  3056. if err != nil {
  3057. return nil, err
  3058. }
  3059. req.Header = reqHeaders
  3060. googleapi.Expand(req.URL, map[string]string{
  3061. "resource": c.resource,
  3062. })
  3063. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3064. }
  3065. // Do executes the "pubsub.projects.topics.getIamPolicy" call.
  3066. // Exactly one of *Policy or error will be non-nil. Any non-2xx status
  3067. // code is an error. Response headers are in either
  3068. // *Policy.ServerResponse.Header or (if a response was returned at all)
  3069. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  3070. // check whether the returned error was because http.StatusNotModified
  3071. // was returned.
  3072. func (c *ProjectsTopicsGetIamPolicyCall) Do(opts ...googleapi.CallOption) (*Policy, error) {
  3073. gensupport.SetOptions(c.urlParams_, opts...)
  3074. res, err := c.doRequest("json")
  3075. if res != nil && res.StatusCode == http.StatusNotModified {
  3076. if res.Body != nil {
  3077. res.Body.Close()
  3078. }
  3079. return nil, &googleapi.Error{
  3080. Code: res.StatusCode,
  3081. Header: res.Header,
  3082. }
  3083. }
  3084. if err != nil {
  3085. return nil, err
  3086. }
  3087. defer googleapi.CloseBody(res)
  3088. if err := googleapi.CheckResponse(res); err != nil {
  3089. return nil, err
  3090. }
  3091. ret := &Policy{
  3092. ServerResponse: googleapi.ServerResponse{
  3093. Header: res.Header,
  3094. HTTPStatusCode: res.StatusCode,
  3095. },
  3096. }
  3097. target := &ret
  3098. if err := gensupport.DecodeResponse(target, res); err != nil {
  3099. return nil, err
  3100. }
  3101. return ret, nil
  3102. // {
  3103. // "description": "Gets the access control policy for a resource.\nReturns an empty policy if the resource exists and does not have a policy\nset.",
  3104. // "flatPath": "v1beta2/projects/{projectsId}/topics/{topicsId}:getIamPolicy",
  3105. // "httpMethod": "GET",
  3106. // "id": "pubsub.projects.topics.getIamPolicy",
  3107. // "parameterOrder": [
  3108. // "resource"
  3109. // ],
  3110. // "parameters": {
  3111. // "resource": {
  3112. // "description": "REQUIRED: The resource for which the policy is being requested.\nSee the operation documentation for the appropriate value for this field.",
  3113. // "location": "path",
  3114. // "pattern": "^projects/[^/]+/topics/[^/]+$",
  3115. // "required": true,
  3116. // "type": "string"
  3117. // }
  3118. // },
  3119. // "path": "v1beta2/{+resource}:getIamPolicy",
  3120. // "response": {
  3121. // "$ref": "Policy"
  3122. // },
  3123. // "scopes": [
  3124. // "https://www.googleapis.com/auth/cloud-platform",
  3125. // "https://www.googleapis.com/auth/pubsub"
  3126. // ]
  3127. // }
  3128. }
  3129. // method id "pubsub.projects.topics.list":
  3130. type ProjectsTopicsListCall struct {
  3131. s *Service
  3132. project string
  3133. urlParams_ gensupport.URLParams
  3134. ifNoneMatch_ string
  3135. ctx_ context.Context
  3136. header_ http.Header
  3137. }
  3138. // List: Lists matching topics.
  3139. func (r *ProjectsTopicsService) List(project string) *ProjectsTopicsListCall {
  3140. c := &ProjectsTopicsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3141. c.project = project
  3142. return c
  3143. }
  3144. // PageSize sets the optional parameter "pageSize": Maximum number of
  3145. // topics to return.
  3146. func (c *ProjectsTopicsListCall) PageSize(pageSize int64) *ProjectsTopicsListCall {
  3147. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  3148. return c
  3149. }
  3150. // PageToken sets the optional parameter "pageToken": The value returned
  3151. // by the last `ListTopicsResponse`; indicates that this is
  3152. // a continuation of a prior `ListTopics` call, and that the system
  3153. // should
  3154. // return the next page of data.
  3155. func (c *ProjectsTopicsListCall) PageToken(pageToken string) *ProjectsTopicsListCall {
  3156. c.urlParams_.Set("pageToken", pageToken)
  3157. return c
  3158. }
  3159. // Fields allows partial responses to be retrieved. See
  3160. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3161. // for more information.
  3162. func (c *ProjectsTopicsListCall) Fields(s ...googleapi.Field) *ProjectsTopicsListCall {
  3163. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3164. return c
  3165. }
  3166. // IfNoneMatch sets the optional parameter which makes the operation
  3167. // fail if the object's ETag matches the given value. This is useful for
  3168. // getting updates only after the object has changed since the last
  3169. // request. Use googleapi.IsNotModified to check whether the response
  3170. // error from Do is the result of In-None-Match.
  3171. func (c *ProjectsTopicsListCall) IfNoneMatch(entityTag string) *ProjectsTopicsListCall {
  3172. c.ifNoneMatch_ = entityTag
  3173. return c
  3174. }
  3175. // Context sets the context to be used in this call's Do method. Any
  3176. // pending HTTP request will be aborted if the provided context is
  3177. // canceled.
  3178. func (c *ProjectsTopicsListCall) Context(ctx context.Context) *ProjectsTopicsListCall {
  3179. c.ctx_ = ctx
  3180. return c
  3181. }
  3182. // Header returns an http.Header that can be modified by the caller to
  3183. // add HTTP headers to the request.
  3184. func (c *ProjectsTopicsListCall) Header() http.Header {
  3185. if c.header_ == nil {
  3186. c.header_ = make(http.Header)
  3187. }
  3188. return c.header_
  3189. }
  3190. func (c *ProjectsTopicsListCall) doRequest(alt string) (*http.Response, error) {
  3191. reqHeaders := make(http.Header)
  3192. for k, v := range c.header_ {
  3193. reqHeaders[k] = v
  3194. }
  3195. reqHeaders.Set("User-Agent", c.s.userAgent())
  3196. if c.ifNoneMatch_ != "" {
  3197. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  3198. }
  3199. var body io.Reader = nil
  3200. c.urlParams_.Set("alt", alt)
  3201. c.urlParams_.Set("prettyPrint", "false")
  3202. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+project}/topics")
  3203. urls += "?" + c.urlParams_.Encode()
  3204. req, err := http.NewRequest("GET", urls, body)
  3205. if err != nil {
  3206. return nil, err
  3207. }
  3208. req.Header = reqHeaders
  3209. googleapi.Expand(req.URL, map[string]string{
  3210. "project": c.project,
  3211. })
  3212. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3213. }
  3214. // Do executes the "pubsub.projects.topics.list" call.
  3215. // Exactly one of *ListTopicsResponse or error will be non-nil. Any
  3216. // non-2xx status code is an error. Response headers are in either
  3217. // *ListTopicsResponse.ServerResponse.Header or (if a response was
  3218. // returned at all) in error.(*googleapi.Error).Header. Use
  3219. // googleapi.IsNotModified to check whether the returned error was
  3220. // because http.StatusNotModified was returned.
  3221. func (c *ProjectsTopicsListCall) Do(opts ...googleapi.CallOption) (*ListTopicsResponse, error) {
  3222. gensupport.SetOptions(c.urlParams_, opts...)
  3223. res, err := c.doRequest("json")
  3224. if res != nil && res.StatusCode == http.StatusNotModified {
  3225. if res.Body != nil {
  3226. res.Body.Close()
  3227. }
  3228. return nil, &googleapi.Error{
  3229. Code: res.StatusCode,
  3230. Header: res.Header,
  3231. }
  3232. }
  3233. if err != nil {
  3234. return nil, err
  3235. }
  3236. defer googleapi.CloseBody(res)
  3237. if err := googleapi.CheckResponse(res); err != nil {
  3238. return nil, err
  3239. }
  3240. ret := &ListTopicsResponse{
  3241. ServerResponse: googleapi.ServerResponse{
  3242. Header: res.Header,
  3243. HTTPStatusCode: res.StatusCode,
  3244. },
  3245. }
  3246. target := &ret
  3247. if err := gensupport.DecodeResponse(target, res); err != nil {
  3248. return nil, err
  3249. }
  3250. return ret, nil
  3251. // {
  3252. // "description": "Lists matching topics.",
  3253. // "flatPath": "v1beta2/projects/{projectsId}/topics",
  3254. // "httpMethod": "GET",
  3255. // "id": "pubsub.projects.topics.list",
  3256. // "parameterOrder": [
  3257. // "project"
  3258. // ],
  3259. // "parameters": {
  3260. // "pageSize": {
  3261. // "description": "Maximum number of topics to return.",
  3262. // "format": "int32",
  3263. // "location": "query",
  3264. // "type": "integer"
  3265. // },
  3266. // "pageToken": {
  3267. // "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.",
  3268. // "location": "query",
  3269. // "type": "string"
  3270. // },
  3271. // "project": {
  3272. // "description": "The name of the cloud project that topics belong to.",
  3273. // "location": "path",
  3274. // "pattern": "^projects/[^/]+$",
  3275. // "required": true,
  3276. // "type": "string"
  3277. // }
  3278. // },
  3279. // "path": "v1beta2/{+project}/topics",
  3280. // "response": {
  3281. // "$ref": "ListTopicsResponse"
  3282. // },
  3283. // "scopes": [
  3284. // "https://www.googleapis.com/auth/cloud-platform",
  3285. // "https://www.googleapis.com/auth/pubsub"
  3286. // ]
  3287. // }
  3288. }
  3289. // Pages invokes f for each page of results.
  3290. // A non-nil error returned from f will halt the iteration.
  3291. // The provided context supersedes any context provided to the Context method.
  3292. func (c *ProjectsTopicsListCall) Pages(ctx context.Context, f func(*ListTopicsResponse) error) error {
  3293. c.ctx_ = ctx
  3294. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  3295. for {
  3296. x, err := c.Do()
  3297. if err != nil {
  3298. return err
  3299. }
  3300. if err := f(x); err != nil {
  3301. return err
  3302. }
  3303. if x.NextPageToken == "" {
  3304. return nil
  3305. }
  3306. c.PageToken(x.NextPageToken)
  3307. }
  3308. }
  3309. // method id "pubsub.projects.topics.publish":
  3310. type ProjectsTopicsPublishCall struct {
  3311. s *Service
  3312. topic string
  3313. publishrequest *PublishRequest
  3314. urlParams_ gensupport.URLParams
  3315. ctx_ context.Context
  3316. header_ http.Header
  3317. }
  3318. // Publish: Adds one or more messages to the topic. Returns `NOT_FOUND`
  3319. // if the topic
  3320. // does not exist. The message payload must not be empty; it must
  3321. // contain
  3322. // either a non-empty data field, or at least one attribute.
  3323. func (r *ProjectsTopicsService) Publish(topic string, publishrequest *PublishRequest) *ProjectsTopicsPublishCall {
  3324. c := &ProjectsTopicsPublishCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3325. c.topic = topic
  3326. c.publishrequest = publishrequest
  3327. return c
  3328. }
  3329. // Fields allows partial responses to be retrieved. See
  3330. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3331. // for more information.
  3332. func (c *ProjectsTopicsPublishCall) Fields(s ...googleapi.Field) *ProjectsTopicsPublishCall {
  3333. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3334. return c
  3335. }
  3336. // Context sets the context to be used in this call's Do method. Any
  3337. // pending HTTP request will be aborted if the provided context is
  3338. // canceled.
  3339. func (c *ProjectsTopicsPublishCall) Context(ctx context.Context) *ProjectsTopicsPublishCall {
  3340. c.ctx_ = ctx
  3341. return c
  3342. }
  3343. // Header returns an http.Header that can be modified by the caller to
  3344. // add HTTP headers to the request.
  3345. func (c *ProjectsTopicsPublishCall) Header() http.Header {
  3346. if c.header_ == nil {
  3347. c.header_ = make(http.Header)
  3348. }
  3349. return c.header_
  3350. }
  3351. func (c *ProjectsTopicsPublishCall) doRequest(alt string) (*http.Response, error) {
  3352. reqHeaders := make(http.Header)
  3353. for k, v := range c.header_ {
  3354. reqHeaders[k] = v
  3355. }
  3356. reqHeaders.Set("User-Agent", c.s.userAgent())
  3357. var body io.Reader = nil
  3358. body, err := googleapi.WithoutDataWrapper.JSONReader(c.publishrequest)
  3359. if err != nil {
  3360. return nil, err
  3361. }
  3362. reqHeaders.Set("Content-Type", "application/json")
  3363. c.urlParams_.Set("alt", alt)
  3364. c.urlParams_.Set("prettyPrint", "false")
  3365. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+topic}:publish")
  3366. urls += "?" + c.urlParams_.Encode()
  3367. req, err := http.NewRequest("POST", urls, body)
  3368. if err != nil {
  3369. return nil, err
  3370. }
  3371. req.Header = reqHeaders
  3372. googleapi.Expand(req.URL, map[string]string{
  3373. "topic": c.topic,
  3374. })
  3375. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3376. }
  3377. // Do executes the "pubsub.projects.topics.publish" call.
  3378. // Exactly one of *PublishResponse or error will be non-nil. Any non-2xx
  3379. // status code is an error. Response headers are in either
  3380. // *PublishResponse.ServerResponse.Header or (if a response was returned
  3381. // at all) in error.(*googleapi.Error).Header. Use
  3382. // googleapi.IsNotModified to check whether the returned error was
  3383. // because http.StatusNotModified was returned.
  3384. func (c *ProjectsTopicsPublishCall) Do(opts ...googleapi.CallOption) (*PublishResponse, error) {
  3385. gensupport.SetOptions(c.urlParams_, opts...)
  3386. res, err := c.doRequest("json")
  3387. if res != nil && res.StatusCode == http.StatusNotModified {
  3388. if res.Body != nil {
  3389. res.Body.Close()
  3390. }
  3391. return nil, &googleapi.Error{
  3392. Code: res.StatusCode,
  3393. Header: res.Header,
  3394. }
  3395. }
  3396. if err != nil {
  3397. return nil, err
  3398. }
  3399. defer googleapi.CloseBody(res)
  3400. if err := googleapi.CheckResponse(res); err != nil {
  3401. return nil, err
  3402. }
  3403. ret := &PublishResponse{
  3404. ServerResponse: googleapi.ServerResponse{
  3405. Header: res.Header,
  3406. HTTPStatusCode: res.StatusCode,
  3407. },
  3408. }
  3409. target := &ret
  3410. if err := gensupport.DecodeResponse(target, res); err != nil {
  3411. return nil, err
  3412. }
  3413. return ret, nil
  3414. // {
  3415. // "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.",
  3416. // "flatPath": "v1beta2/projects/{projectsId}/topics/{topicsId}:publish",
  3417. // "httpMethod": "POST",
  3418. // "id": "pubsub.projects.topics.publish",
  3419. // "parameterOrder": [
  3420. // "topic"
  3421. // ],
  3422. // "parameters": {
  3423. // "topic": {
  3424. // "description": "The messages in the request will be published on this topic.",
  3425. // "location": "path",
  3426. // "pattern": "^projects/[^/]+/topics/[^/]+$",
  3427. // "required": true,
  3428. // "type": "string"
  3429. // }
  3430. // },
  3431. // "path": "v1beta2/{+topic}:publish",
  3432. // "request": {
  3433. // "$ref": "PublishRequest"
  3434. // },
  3435. // "response": {
  3436. // "$ref": "PublishResponse"
  3437. // },
  3438. // "scopes": [
  3439. // "https://www.googleapis.com/auth/cloud-platform",
  3440. // "https://www.googleapis.com/auth/pubsub"
  3441. // ]
  3442. // }
  3443. }
  3444. // method id "pubsub.projects.topics.setIamPolicy":
  3445. type ProjectsTopicsSetIamPolicyCall struct {
  3446. s *Service
  3447. resource string
  3448. setiampolicyrequest *SetIamPolicyRequest
  3449. urlParams_ gensupport.URLParams
  3450. ctx_ context.Context
  3451. header_ http.Header
  3452. }
  3453. // SetIamPolicy: Sets the access control policy on the specified
  3454. // resource. Replaces any
  3455. // existing policy.
  3456. func (r *ProjectsTopicsService) SetIamPolicy(resource string, setiampolicyrequest *SetIamPolicyRequest) *ProjectsTopicsSetIamPolicyCall {
  3457. c := &ProjectsTopicsSetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3458. c.resource = resource
  3459. c.setiampolicyrequest = setiampolicyrequest
  3460. return c
  3461. }
  3462. // Fields allows partial responses to be retrieved. See
  3463. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3464. // for more information.
  3465. func (c *ProjectsTopicsSetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsTopicsSetIamPolicyCall {
  3466. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3467. return c
  3468. }
  3469. // Context sets the context to be used in this call's Do method. Any
  3470. // pending HTTP request will be aborted if the provided context is
  3471. // canceled.
  3472. func (c *ProjectsTopicsSetIamPolicyCall) Context(ctx context.Context) *ProjectsTopicsSetIamPolicyCall {
  3473. c.ctx_ = ctx
  3474. return c
  3475. }
  3476. // Header returns an http.Header that can be modified by the caller to
  3477. // add HTTP headers to the request.
  3478. func (c *ProjectsTopicsSetIamPolicyCall) Header() http.Header {
  3479. if c.header_ == nil {
  3480. c.header_ = make(http.Header)
  3481. }
  3482. return c.header_
  3483. }
  3484. func (c *ProjectsTopicsSetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  3485. reqHeaders := make(http.Header)
  3486. for k, v := range c.header_ {
  3487. reqHeaders[k] = v
  3488. }
  3489. reqHeaders.Set("User-Agent", c.s.userAgent())
  3490. var body io.Reader = nil
  3491. body, err := googleapi.WithoutDataWrapper.JSONReader(c.setiampolicyrequest)
  3492. if err != nil {
  3493. return nil, err
  3494. }
  3495. reqHeaders.Set("Content-Type", "application/json")
  3496. c.urlParams_.Set("alt", alt)
  3497. c.urlParams_.Set("prettyPrint", "false")
  3498. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+resource}:setIamPolicy")
  3499. urls += "?" + c.urlParams_.Encode()
  3500. req, err := http.NewRequest("POST", urls, body)
  3501. if err != nil {
  3502. return nil, err
  3503. }
  3504. req.Header = reqHeaders
  3505. googleapi.Expand(req.URL, map[string]string{
  3506. "resource": c.resource,
  3507. })
  3508. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3509. }
  3510. // Do executes the "pubsub.projects.topics.setIamPolicy" call.
  3511. // Exactly one of *Policy or error will be non-nil. Any non-2xx status
  3512. // code is an error. Response headers are in either
  3513. // *Policy.ServerResponse.Header or (if a response was returned at all)
  3514. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  3515. // check whether the returned error was because http.StatusNotModified
  3516. // was returned.
  3517. func (c *ProjectsTopicsSetIamPolicyCall) Do(opts ...googleapi.CallOption) (*Policy, error) {
  3518. gensupport.SetOptions(c.urlParams_, opts...)
  3519. res, err := c.doRequest("json")
  3520. if res != nil && res.StatusCode == http.StatusNotModified {
  3521. if res.Body != nil {
  3522. res.Body.Close()
  3523. }
  3524. return nil, &googleapi.Error{
  3525. Code: res.StatusCode,
  3526. Header: res.Header,
  3527. }
  3528. }
  3529. if err != nil {
  3530. return nil, err
  3531. }
  3532. defer googleapi.CloseBody(res)
  3533. if err := googleapi.CheckResponse(res); err != nil {
  3534. return nil, err
  3535. }
  3536. ret := &Policy{
  3537. ServerResponse: googleapi.ServerResponse{
  3538. Header: res.Header,
  3539. HTTPStatusCode: res.StatusCode,
  3540. },
  3541. }
  3542. target := &ret
  3543. if err := gensupport.DecodeResponse(target, res); err != nil {
  3544. return nil, err
  3545. }
  3546. return ret, nil
  3547. // {
  3548. // "description": "Sets the access control policy on the specified resource. Replaces any\nexisting policy.",
  3549. // "flatPath": "v1beta2/projects/{projectsId}/topics/{topicsId}:setIamPolicy",
  3550. // "httpMethod": "POST",
  3551. // "id": "pubsub.projects.topics.setIamPolicy",
  3552. // "parameterOrder": [
  3553. // "resource"
  3554. // ],
  3555. // "parameters": {
  3556. // "resource": {
  3557. // "description": "REQUIRED: The resource for which the policy is being specified.\nSee the operation documentation for the appropriate value for this field.",
  3558. // "location": "path",
  3559. // "pattern": "^projects/[^/]+/topics/[^/]+$",
  3560. // "required": true,
  3561. // "type": "string"
  3562. // }
  3563. // },
  3564. // "path": "v1beta2/{+resource}:setIamPolicy",
  3565. // "request": {
  3566. // "$ref": "SetIamPolicyRequest"
  3567. // },
  3568. // "response": {
  3569. // "$ref": "Policy"
  3570. // },
  3571. // "scopes": [
  3572. // "https://www.googleapis.com/auth/cloud-platform",
  3573. // "https://www.googleapis.com/auth/pubsub"
  3574. // ]
  3575. // }
  3576. }
  3577. // method id "pubsub.projects.topics.testIamPermissions":
  3578. type ProjectsTopicsTestIamPermissionsCall struct {
  3579. s *Service
  3580. resource string
  3581. testiampermissionsrequest *TestIamPermissionsRequest
  3582. urlParams_ gensupport.URLParams
  3583. ctx_ context.Context
  3584. header_ http.Header
  3585. }
  3586. // TestIamPermissions: Returns permissions that a caller has on the
  3587. // specified resource.
  3588. // If the resource does not exist, this will return an empty set
  3589. // of
  3590. // permissions, not a NOT_FOUND error.
  3591. //
  3592. // Note: This operation is designed to be used for building
  3593. // permission-aware
  3594. // UIs and command-line tools, not for authorization checking. This
  3595. // operation
  3596. // may "fail open" without warning.
  3597. func (r *ProjectsTopicsService) TestIamPermissions(resource string, testiampermissionsrequest *TestIamPermissionsRequest) *ProjectsTopicsTestIamPermissionsCall {
  3598. c := &ProjectsTopicsTestIamPermissionsCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3599. c.resource = resource
  3600. c.testiampermissionsrequest = testiampermissionsrequest
  3601. return c
  3602. }
  3603. // Fields allows partial responses to be retrieved. See
  3604. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3605. // for more information.
  3606. func (c *ProjectsTopicsTestIamPermissionsCall) Fields(s ...googleapi.Field) *ProjectsTopicsTestIamPermissionsCall {
  3607. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3608. return c
  3609. }
  3610. // Context sets the context to be used in this call's Do method. Any
  3611. // pending HTTP request will be aborted if the provided context is
  3612. // canceled.
  3613. func (c *ProjectsTopicsTestIamPermissionsCall) Context(ctx context.Context) *ProjectsTopicsTestIamPermissionsCall {
  3614. c.ctx_ = ctx
  3615. return c
  3616. }
  3617. // Header returns an http.Header that can be modified by the caller to
  3618. // add HTTP headers to the request.
  3619. func (c *ProjectsTopicsTestIamPermissionsCall) Header() http.Header {
  3620. if c.header_ == nil {
  3621. c.header_ = make(http.Header)
  3622. }
  3623. return c.header_
  3624. }
  3625. func (c *ProjectsTopicsTestIamPermissionsCall) doRequest(alt string) (*http.Response, error) {
  3626. reqHeaders := make(http.Header)
  3627. for k, v := range c.header_ {
  3628. reqHeaders[k] = v
  3629. }
  3630. reqHeaders.Set("User-Agent", c.s.userAgent())
  3631. var body io.Reader = nil
  3632. body, err := googleapi.WithoutDataWrapper.JSONReader(c.testiampermissionsrequest)
  3633. if err != nil {
  3634. return nil, err
  3635. }
  3636. reqHeaders.Set("Content-Type", "application/json")
  3637. c.urlParams_.Set("alt", alt)
  3638. c.urlParams_.Set("prettyPrint", "false")
  3639. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+resource}:testIamPermissions")
  3640. urls += "?" + c.urlParams_.Encode()
  3641. req, err := http.NewRequest("POST", urls, body)
  3642. if err != nil {
  3643. return nil, err
  3644. }
  3645. req.Header = reqHeaders
  3646. googleapi.Expand(req.URL, map[string]string{
  3647. "resource": c.resource,
  3648. })
  3649. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3650. }
  3651. // Do executes the "pubsub.projects.topics.testIamPermissions" call.
  3652. // Exactly one of *TestIamPermissionsResponse or error will be non-nil.
  3653. // Any non-2xx status code is an error. Response headers are in either
  3654. // *TestIamPermissionsResponse.ServerResponse.Header or (if a response
  3655. // was returned at all) in error.(*googleapi.Error).Header. Use
  3656. // googleapi.IsNotModified to check whether the returned error was
  3657. // because http.StatusNotModified was returned.
  3658. func (c *ProjectsTopicsTestIamPermissionsCall) Do(opts ...googleapi.CallOption) (*TestIamPermissionsResponse, error) {
  3659. gensupport.SetOptions(c.urlParams_, opts...)
  3660. res, err := c.doRequest("json")
  3661. if res != nil && res.StatusCode == http.StatusNotModified {
  3662. if res.Body != nil {
  3663. res.Body.Close()
  3664. }
  3665. return nil, &googleapi.Error{
  3666. Code: res.StatusCode,
  3667. Header: res.Header,
  3668. }
  3669. }
  3670. if err != nil {
  3671. return nil, err
  3672. }
  3673. defer googleapi.CloseBody(res)
  3674. if err := googleapi.CheckResponse(res); err != nil {
  3675. return nil, err
  3676. }
  3677. ret := &TestIamPermissionsResponse{
  3678. ServerResponse: googleapi.ServerResponse{
  3679. Header: res.Header,
  3680. HTTPStatusCode: res.StatusCode,
  3681. },
  3682. }
  3683. target := &ret
  3684. if err := gensupport.DecodeResponse(target, res); err != nil {
  3685. return nil, err
  3686. }
  3687. return ret, nil
  3688. // {
  3689. // "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.",
  3690. // "flatPath": "v1beta2/projects/{projectsId}/topics/{topicsId}:testIamPermissions",
  3691. // "httpMethod": "POST",
  3692. // "id": "pubsub.projects.topics.testIamPermissions",
  3693. // "parameterOrder": [
  3694. // "resource"
  3695. // ],
  3696. // "parameters": {
  3697. // "resource": {
  3698. // "description": "REQUIRED: The resource for which the policy detail is being requested.\nSee the operation documentation for the appropriate value for this field.",
  3699. // "location": "path",
  3700. // "pattern": "^projects/[^/]+/topics/[^/]+$",
  3701. // "required": true,
  3702. // "type": "string"
  3703. // }
  3704. // },
  3705. // "path": "v1beta2/{+resource}:testIamPermissions",
  3706. // "request": {
  3707. // "$ref": "TestIamPermissionsRequest"
  3708. // },
  3709. // "response": {
  3710. // "$ref": "TestIamPermissionsResponse"
  3711. // },
  3712. // "scopes": [
  3713. // "https://www.googleapis.com/auth/cloud-platform",
  3714. // "https://www.googleapis.com/auth/pubsub"
  3715. // ]
  3716. // }
  3717. }
  3718. // method id "pubsub.projects.topics.subscriptions.list":
  3719. type ProjectsTopicsSubscriptionsListCall struct {
  3720. s *Service
  3721. topic string
  3722. urlParams_ gensupport.URLParams
  3723. ifNoneMatch_ string
  3724. ctx_ context.Context
  3725. header_ http.Header
  3726. }
  3727. // List: Lists the name of the subscriptions for this topic.
  3728. func (r *ProjectsTopicsSubscriptionsService) List(topic string) *ProjectsTopicsSubscriptionsListCall {
  3729. c := &ProjectsTopicsSubscriptionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3730. c.topic = topic
  3731. return c
  3732. }
  3733. // PageSize sets the optional parameter "pageSize": Maximum number of
  3734. // subscription names to return.
  3735. func (c *ProjectsTopicsSubscriptionsListCall) PageSize(pageSize int64) *ProjectsTopicsSubscriptionsListCall {
  3736. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  3737. return c
  3738. }
  3739. // PageToken sets the optional parameter "pageToken": The value returned
  3740. // by the last `ListTopicSubscriptionsResponse`; indicates
  3741. // that this is a continuation of a prior `ListTopicSubscriptions` call,
  3742. // and
  3743. // that the system should return the next page of data.
  3744. func (c *ProjectsTopicsSubscriptionsListCall) PageToken(pageToken string) *ProjectsTopicsSubscriptionsListCall {
  3745. c.urlParams_.Set("pageToken", pageToken)
  3746. return c
  3747. }
  3748. // Fields allows partial responses to be retrieved. See
  3749. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3750. // for more information.
  3751. func (c *ProjectsTopicsSubscriptionsListCall) Fields(s ...googleapi.Field) *ProjectsTopicsSubscriptionsListCall {
  3752. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3753. return c
  3754. }
  3755. // IfNoneMatch sets the optional parameter which makes the operation
  3756. // fail if the object's ETag matches the given value. This is useful for
  3757. // getting updates only after the object has changed since the last
  3758. // request. Use googleapi.IsNotModified to check whether the response
  3759. // error from Do is the result of In-None-Match.
  3760. func (c *ProjectsTopicsSubscriptionsListCall) IfNoneMatch(entityTag string) *ProjectsTopicsSubscriptionsListCall {
  3761. c.ifNoneMatch_ = entityTag
  3762. return c
  3763. }
  3764. // Context sets the context to be used in this call's Do method. Any
  3765. // pending HTTP request will be aborted if the provided context is
  3766. // canceled.
  3767. func (c *ProjectsTopicsSubscriptionsListCall) Context(ctx context.Context) *ProjectsTopicsSubscriptionsListCall {
  3768. c.ctx_ = ctx
  3769. return c
  3770. }
  3771. // Header returns an http.Header that can be modified by the caller to
  3772. // add HTTP headers to the request.
  3773. func (c *ProjectsTopicsSubscriptionsListCall) Header() http.Header {
  3774. if c.header_ == nil {
  3775. c.header_ = make(http.Header)
  3776. }
  3777. return c.header_
  3778. }
  3779. func (c *ProjectsTopicsSubscriptionsListCall) doRequest(alt string) (*http.Response, error) {
  3780. reqHeaders := make(http.Header)
  3781. for k, v := range c.header_ {
  3782. reqHeaders[k] = v
  3783. }
  3784. reqHeaders.Set("User-Agent", c.s.userAgent())
  3785. if c.ifNoneMatch_ != "" {
  3786. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  3787. }
  3788. var body io.Reader = nil
  3789. c.urlParams_.Set("alt", alt)
  3790. c.urlParams_.Set("prettyPrint", "false")
  3791. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta2/{+topic}/subscriptions")
  3792. urls += "?" + c.urlParams_.Encode()
  3793. req, err := http.NewRequest("GET", urls, body)
  3794. if err != nil {
  3795. return nil, err
  3796. }
  3797. req.Header = reqHeaders
  3798. googleapi.Expand(req.URL, map[string]string{
  3799. "topic": c.topic,
  3800. })
  3801. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3802. }
  3803. // Do executes the "pubsub.projects.topics.subscriptions.list" call.
  3804. // Exactly one of *ListTopicSubscriptionsResponse or error will be
  3805. // non-nil. Any non-2xx status code is an error. Response headers are in
  3806. // either *ListTopicSubscriptionsResponse.ServerResponse.Header or (if a
  3807. // response was returned at all) in error.(*googleapi.Error).Header. Use
  3808. // googleapi.IsNotModified to check whether the returned error was
  3809. // because http.StatusNotModified was returned.
  3810. func (c *ProjectsTopicsSubscriptionsListCall) Do(opts ...googleapi.CallOption) (*ListTopicSubscriptionsResponse, error) {
  3811. gensupport.SetOptions(c.urlParams_, opts...)
  3812. res, err := c.doRequest("json")
  3813. if res != nil && res.StatusCode == http.StatusNotModified {
  3814. if res.Body != nil {
  3815. res.Body.Close()
  3816. }
  3817. return nil, &googleapi.Error{
  3818. Code: res.StatusCode,
  3819. Header: res.Header,
  3820. }
  3821. }
  3822. if err != nil {
  3823. return nil, err
  3824. }
  3825. defer googleapi.CloseBody(res)
  3826. if err := googleapi.CheckResponse(res); err != nil {
  3827. return nil, err
  3828. }
  3829. ret := &ListTopicSubscriptionsResponse{
  3830. ServerResponse: googleapi.ServerResponse{
  3831. Header: res.Header,
  3832. HTTPStatusCode: res.StatusCode,
  3833. },
  3834. }
  3835. target := &ret
  3836. if err := gensupport.DecodeResponse(target, res); err != nil {
  3837. return nil, err
  3838. }
  3839. return ret, nil
  3840. // {
  3841. // "description": "Lists the name of the subscriptions for this topic.",
  3842. // "flatPath": "v1beta2/projects/{projectsId}/topics/{topicsId}/subscriptions",
  3843. // "httpMethod": "GET",
  3844. // "id": "pubsub.projects.topics.subscriptions.list",
  3845. // "parameterOrder": [
  3846. // "topic"
  3847. // ],
  3848. // "parameters": {
  3849. // "pageSize": {
  3850. // "description": "Maximum number of subscription names to return.",
  3851. // "format": "int32",
  3852. // "location": "query",
  3853. // "type": "integer"
  3854. // },
  3855. // "pageToken": {
  3856. // "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.",
  3857. // "location": "query",
  3858. // "type": "string"
  3859. // },
  3860. // "topic": {
  3861. // "description": "The name of the topic that subscriptions are attached to.",
  3862. // "location": "path",
  3863. // "pattern": "^projects/[^/]+/topics/[^/]+$",
  3864. // "required": true,
  3865. // "type": "string"
  3866. // }
  3867. // },
  3868. // "path": "v1beta2/{+topic}/subscriptions",
  3869. // "response": {
  3870. // "$ref": "ListTopicSubscriptionsResponse"
  3871. // },
  3872. // "scopes": [
  3873. // "https://www.googleapis.com/auth/cloud-platform",
  3874. // "https://www.googleapis.com/auth/pubsub"
  3875. // ]
  3876. // }
  3877. }
  3878. // Pages invokes f for each page of results.
  3879. // A non-nil error returned from f will halt the iteration.
  3880. // The provided context supersedes any context provided to the Context method.
  3881. func (c *ProjectsTopicsSubscriptionsListCall) Pages(ctx context.Context, f func(*ListTopicSubscriptionsResponse) error) error {
  3882. c.ctx_ = ctx
  3883. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  3884. for {
  3885. x, err := c.Do()
  3886. if err != nil {
  3887. return err
  3888. }
  3889. if err := f(x); err != nil {
  3890. return err
  3891. }
  3892. if x.NextPageToken == "" {
  3893. return nil
  3894. }
  3895. c.PageToken(x.NextPageToken)
  3896. }
  3897. }