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

919 lines
31 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 iap provides access to the Cloud Identity-Aware Proxy API.
  6. //
  7. // For product documentation, see: https://cloud.google.com/iap
  8. //
  9. // Creating a client
  10. //
  11. // Usage example:
  12. //
  13. // import "google.golang.org/api/iap/v1beta1"
  14. // ...
  15. // ctx := context.Background()
  16. // iapService, err := iap.NewService(ctx)
  17. //
  18. // In this example, Google Application Default Credentials are used for authentication.
  19. //
  20. // For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
  21. //
  22. // Other authentication options
  23. //
  24. // To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
  25. //
  26. // iapService, err := iap.NewService(ctx, option.WithAPIKey("AIza..."))
  27. //
  28. // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:
  29. //
  30. // config := &oauth2.Config{...}
  31. // // ...
  32. // token, err := config.Exchange(ctx, ...)
  33. // iapService, err := iap.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
  34. //
  35. // See https://godoc.org/google.golang.org/api/option/ for details on options.
  36. package iap // import "google.golang.org/api/iap/v1beta1"
  37. import (
  38. "bytes"
  39. "context"
  40. "encoding/json"
  41. "errors"
  42. "fmt"
  43. "io"
  44. "net/http"
  45. "net/url"
  46. "strconv"
  47. "strings"
  48. gensupport "google.golang.org/api/gensupport"
  49. googleapi "google.golang.org/api/googleapi"
  50. option "google.golang.org/api/option"
  51. htransport "google.golang.org/api/transport/http"
  52. )
  53. // Always reference these packages, just in case the auto-generated code
  54. // below doesn't.
  55. var _ = bytes.NewBuffer
  56. var _ = strconv.Itoa
  57. var _ = fmt.Sprintf
  58. var _ = json.NewDecoder
  59. var _ = io.Copy
  60. var _ = url.Parse
  61. var _ = gensupport.MarshalJSON
  62. var _ = googleapi.Version
  63. var _ = errors.New
  64. var _ = strings.Replace
  65. var _ = context.Canceled
  66. const apiId = "iap:v1beta1"
  67. const apiName = "iap"
  68. const apiVersion = "v1beta1"
  69. const basePath = "https://iap.googleapis.com/"
  70. // OAuth2 scopes used by this API.
  71. const (
  72. // View and manage your data across Google Cloud Platform services
  73. CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
  74. )
  75. // NewService creates a new Service.
  76. func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
  77. scopesOption := option.WithScopes(
  78. "https://www.googleapis.com/auth/cloud-platform",
  79. )
  80. // NOTE: prepend, so we don't override user-specified scopes.
  81. opts = append([]option.ClientOption{scopesOption}, opts...)
  82. client, endpoint, err := htransport.NewClient(ctx, opts...)
  83. if err != nil {
  84. return nil, err
  85. }
  86. s, err := New(client)
  87. if err != nil {
  88. return nil, err
  89. }
  90. if endpoint != "" {
  91. s.BasePath = endpoint
  92. }
  93. return s, nil
  94. }
  95. // New creates a new Service. It uses the provided http.Client for requests.
  96. //
  97. // Deprecated: please use NewService instead.
  98. // To provide a custom HTTP client, use option.WithHTTPClient.
  99. // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
  100. func New(client *http.Client) (*Service, error) {
  101. if client == nil {
  102. return nil, errors.New("client is nil")
  103. }
  104. s := &Service{client: client, BasePath: basePath}
  105. s.V1beta1 = NewV1beta1Service(s)
  106. return s, nil
  107. }
  108. type Service struct {
  109. client *http.Client
  110. BasePath string // API endpoint base URL
  111. UserAgent string // optional additional User-Agent fragment
  112. V1beta1 *V1beta1Service
  113. }
  114. func (s *Service) userAgent() string {
  115. if s.UserAgent == "" {
  116. return googleapi.UserAgent
  117. }
  118. return googleapi.UserAgent + " " + s.UserAgent
  119. }
  120. func NewV1beta1Service(s *Service) *V1beta1Service {
  121. rs := &V1beta1Service{s: s}
  122. return rs
  123. }
  124. type V1beta1Service struct {
  125. s *Service
  126. }
  127. // Binding: Associates `members` with a `role`.
  128. type Binding struct {
  129. // Condition: Unimplemented. The condition that is associated with this
  130. // binding.
  131. // NOTE: an unsatisfied condition will not allow user access via
  132. // current
  133. // binding. Different bindings, including their conditions, are
  134. // examined
  135. // independently.
  136. Condition *Expr `json:"condition,omitempty"`
  137. // Members: Specifies the identities requesting access for a Cloud
  138. // Platform resource.
  139. // `members` can have the following values:
  140. //
  141. // * `allUsers`: A special identifier that represents anyone who is
  142. // on the internet; with or without a Google account.
  143. //
  144. // * `allAuthenticatedUsers`: A special identifier that represents
  145. // anyone
  146. // who is authenticated with a Google account or a service
  147. // account.
  148. //
  149. // * `user:{emailid}`: An email address that represents a specific
  150. // Google
  151. // account. For example, `alice@gmail.com` .
  152. //
  153. //
  154. // * `serviceAccount:{emailid}`: An email address that represents a
  155. // service
  156. // account. For example,
  157. // `my-other-app@appspot.gserviceaccount.com`.
  158. //
  159. // * `group:{emailid}`: An email address that represents a Google
  160. // group.
  161. // For example, `admins@example.com`.
  162. //
  163. //
  164. // * `domain:{domain}`: The G Suite domain (primary) that represents all
  165. // the
  166. // users of that domain. For example, `google.com` or
  167. // `example.com`.
  168. //
  169. //
  170. Members []string `json:"members,omitempty"`
  171. // Role: Role that is assigned to `members`.
  172. // For example, `roles/viewer`, `roles/editor`, or `roles/owner`.
  173. Role string `json:"role,omitempty"`
  174. // ForceSendFields is a list of field names (e.g. "Condition") to
  175. // unconditionally include in API requests. By default, fields with
  176. // empty values are omitted from API requests. However, any non-pointer,
  177. // non-interface field appearing in ForceSendFields will be sent to the
  178. // server regardless of whether the field is empty or not. This may be
  179. // used to include empty fields in Patch requests.
  180. ForceSendFields []string `json:"-"`
  181. // NullFields is a list of field names (e.g. "Condition") to include in
  182. // API requests with the JSON null value. By default, fields with empty
  183. // values are omitted from API requests. However, any field with an
  184. // empty value appearing in NullFields will be sent to the server as
  185. // null. It is an error if a field in this list has a non-empty value.
  186. // This may be used to include null fields in Patch requests.
  187. NullFields []string `json:"-"`
  188. }
  189. func (s *Binding) MarshalJSON() ([]byte, error) {
  190. type NoMethod Binding
  191. raw := NoMethod(*s)
  192. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  193. }
  194. // Expr: Represents an expression text. Example:
  195. //
  196. // title: "User account presence"
  197. // description: "Determines whether the request has a user account"
  198. // expression: "size(request.user) > 0"
  199. type Expr struct {
  200. // Description: An optional description of the expression. This is a
  201. // longer text which
  202. // describes the expression, e.g. when hovered over it in a UI.
  203. Description string `json:"description,omitempty"`
  204. // Expression: Textual representation of an expression in
  205. // Common Expression Language syntax.
  206. //
  207. // The application context of the containing message determines
  208. // which
  209. // well-known feature set of CEL is supported.
  210. Expression string `json:"expression,omitempty"`
  211. // Location: An optional string indicating the location of the
  212. // expression for error
  213. // reporting, e.g. a file name and a position in the file.
  214. Location string `json:"location,omitempty"`
  215. // Title: An optional title for the expression, i.e. a short string
  216. // describing
  217. // its purpose. This can be used e.g. in UIs which allow to enter
  218. // the
  219. // expression.
  220. Title string `json:"title,omitempty"`
  221. // ForceSendFields is a list of field names (e.g. "Description") to
  222. // unconditionally include in API requests. By default, fields with
  223. // empty values are omitted from API requests. However, any non-pointer,
  224. // non-interface field appearing in ForceSendFields will be sent to the
  225. // server regardless of whether the field is empty or not. This may be
  226. // used to include empty fields in Patch requests.
  227. ForceSendFields []string `json:"-"`
  228. // NullFields is a list of field names (e.g. "Description") to include
  229. // in API requests with the JSON null value. By default, fields with
  230. // empty values are omitted from API requests. However, any field with
  231. // an empty value appearing in NullFields will be sent to the server as
  232. // null. It is an error if a field in this list has a non-empty value.
  233. // This may be used to include null fields in Patch requests.
  234. NullFields []string `json:"-"`
  235. }
  236. func (s *Expr) MarshalJSON() ([]byte, error) {
  237. type NoMethod Expr
  238. raw := NoMethod(*s)
  239. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  240. }
  241. // GetIamPolicyRequest: Request message for `GetIamPolicy` method.
  242. type GetIamPolicyRequest struct {
  243. }
  244. // Policy: Defines an Identity and Access Management (IAM) policy. It is
  245. // used to
  246. // specify access control policies for Cloud Platform resources.
  247. //
  248. //
  249. // A `Policy` consists of a list of `bindings`. A `binding` binds a list
  250. // of
  251. // `members` to a `role`, where the members can be user accounts, Google
  252. // groups,
  253. // Google domains, and service accounts. A `role` is a named list of
  254. // permissions
  255. // defined by IAM.
  256. //
  257. // **JSON Example**
  258. //
  259. // {
  260. // "bindings": [
  261. // {
  262. // "role": "roles/owner",
  263. // "members": [
  264. // "user:mike@example.com",
  265. // "group:admins@example.com",
  266. // "domain:google.com",
  267. //
  268. // "serviceAccount:my-other-app@appspot.gserviceaccount.com"
  269. // ]
  270. // },
  271. // {
  272. // "role": "roles/viewer",
  273. // "members": ["user:sean@example.com"]
  274. // }
  275. // ]
  276. // }
  277. //
  278. // **YAML Example**
  279. //
  280. // bindings:
  281. // - members:
  282. // - user:mike@example.com
  283. // - group:admins@example.com
  284. // - domain:google.com
  285. // - serviceAccount:my-other-app@appspot.gserviceaccount.com
  286. // role: roles/owner
  287. // - members:
  288. // - user:sean@example.com
  289. // role: roles/viewer
  290. //
  291. //
  292. // For a description of IAM and its features, see the
  293. // [IAM developer's guide](https://cloud.google.com/iam/docs).
  294. type Policy struct {
  295. // Bindings: Associates a list of `members` to a `role`.
  296. // `bindings` with no members will result in an error.
  297. Bindings []*Binding `json:"bindings,omitempty"`
  298. // Etag: `etag` is used for optimistic concurrency control as a way to
  299. // help
  300. // prevent simultaneous updates of a policy from overwriting each
  301. // other.
  302. // It is strongly suggested that systems make use of the `etag` in
  303. // the
  304. // read-modify-write cycle to perform policy updates in order to avoid
  305. // race
  306. // conditions: An `etag` is returned in the response to `getIamPolicy`,
  307. // and
  308. // systems are expected to put that etag in the request to
  309. // `setIamPolicy` to
  310. // ensure that their change will be applied to the same version of the
  311. // policy.
  312. //
  313. // If no `etag` is provided in the call to `setIamPolicy`, then the
  314. // existing
  315. // policy is overwritten blindly.
  316. Etag string `json:"etag,omitempty"`
  317. // Version: Deprecated.
  318. Version int64 `json:"version,omitempty"`
  319. // ServerResponse contains the HTTP response code and headers from the
  320. // server.
  321. googleapi.ServerResponse `json:"-"`
  322. // ForceSendFields is a list of field names (e.g. "Bindings") to
  323. // unconditionally include in API requests. By default, fields with
  324. // empty values are omitted from API requests. However, any non-pointer,
  325. // non-interface field appearing in ForceSendFields will be sent to the
  326. // server regardless of whether the field is empty or not. This may be
  327. // used to include empty fields in Patch requests.
  328. ForceSendFields []string `json:"-"`
  329. // NullFields is a list of field names (e.g. "Bindings") to include in
  330. // API requests with the JSON null value. By default, fields with empty
  331. // values are omitted from API requests. However, any field with an
  332. // empty value appearing in NullFields will be sent to the server as
  333. // null. It is an error if a field in this list has a non-empty value.
  334. // This may be used to include null fields in Patch requests.
  335. NullFields []string `json:"-"`
  336. }
  337. func (s *Policy) MarshalJSON() ([]byte, error) {
  338. type NoMethod Policy
  339. raw := NoMethod(*s)
  340. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  341. }
  342. // SetIamPolicyRequest: Request message for `SetIamPolicy` method.
  343. type SetIamPolicyRequest struct {
  344. // Policy: REQUIRED: The complete policy to be applied to the
  345. // `resource`. The size of
  346. // the policy is limited to a few 10s of KB. An empty policy is a
  347. // valid policy but certain Cloud Platform services (such as
  348. // Projects)
  349. // might reject them.
  350. Policy *Policy `json:"policy,omitempty"`
  351. // ForceSendFields is a list of field names (e.g. "Policy") to
  352. // unconditionally include in API requests. By default, fields with
  353. // empty values are omitted from API requests. However, any non-pointer,
  354. // non-interface field appearing in ForceSendFields will be sent to the
  355. // server regardless of whether the field is empty or not. This may be
  356. // used to include empty fields in Patch requests.
  357. ForceSendFields []string `json:"-"`
  358. // NullFields is a list of field names (e.g. "Policy") to include in API
  359. // requests with the JSON null value. By default, fields with empty
  360. // values are omitted from API requests. However, any field with an
  361. // empty value appearing in NullFields will be sent to the server as
  362. // null. It is an error if a field in this list has a non-empty value.
  363. // This may be used to include null fields in Patch requests.
  364. NullFields []string `json:"-"`
  365. }
  366. func (s *SetIamPolicyRequest) MarshalJSON() ([]byte, error) {
  367. type NoMethod SetIamPolicyRequest
  368. raw := NoMethod(*s)
  369. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  370. }
  371. // TestIamPermissionsRequest: Request message for `TestIamPermissions`
  372. // method.
  373. type TestIamPermissionsRequest struct {
  374. // Permissions: The set of permissions to check for the `resource`.
  375. // Permissions with
  376. // wildcards (such as '*' or 'storage.*') are not allowed. For
  377. // more
  378. // information see
  379. // [IAM
  380. // Overview](https://cloud.google.com/iam/docs/overview#permissions).
  381. Permissions []string `json:"permissions,omitempty"`
  382. // ForceSendFields is a list of field names (e.g. "Permissions") to
  383. // unconditionally include in API requests. By default, fields with
  384. // empty values are omitted from API requests. However, any non-pointer,
  385. // non-interface field appearing in ForceSendFields will be sent to the
  386. // server regardless of whether the field is empty or not. This may be
  387. // used to include empty fields in Patch requests.
  388. ForceSendFields []string `json:"-"`
  389. // NullFields is a list of field names (e.g. "Permissions") to include
  390. // in API requests with the JSON null value. By default, fields with
  391. // empty values are omitted from API requests. However, any field with
  392. // an empty value appearing in NullFields will be sent to the server as
  393. // null. It is an error if a field in this list has a non-empty value.
  394. // This may be used to include null fields in Patch requests.
  395. NullFields []string `json:"-"`
  396. }
  397. func (s *TestIamPermissionsRequest) MarshalJSON() ([]byte, error) {
  398. type NoMethod TestIamPermissionsRequest
  399. raw := NoMethod(*s)
  400. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  401. }
  402. // TestIamPermissionsResponse: Response message for `TestIamPermissions`
  403. // method.
  404. type TestIamPermissionsResponse struct {
  405. // Permissions: A subset of `TestPermissionsRequest.permissions` that
  406. // the caller is
  407. // allowed.
  408. Permissions []string `json:"permissions,omitempty"`
  409. // ServerResponse contains the HTTP response code and headers from the
  410. // server.
  411. googleapi.ServerResponse `json:"-"`
  412. // ForceSendFields is a list of field names (e.g. "Permissions") to
  413. // unconditionally include in API requests. By default, fields with
  414. // empty values are omitted from API requests. However, any non-pointer,
  415. // non-interface field appearing in ForceSendFields will be sent to the
  416. // server regardless of whether the field is empty or not. This may be
  417. // used to include empty fields in Patch requests.
  418. ForceSendFields []string `json:"-"`
  419. // NullFields is a list of field names (e.g. "Permissions") to include
  420. // in API requests with the JSON null value. By default, fields with
  421. // empty values are omitted from API requests. However, any field with
  422. // an empty value appearing in NullFields will be sent to the server as
  423. // null. It is an error if a field in this list has a non-empty value.
  424. // This may be used to include null fields in Patch requests.
  425. NullFields []string `json:"-"`
  426. }
  427. func (s *TestIamPermissionsResponse) MarshalJSON() ([]byte, error) {
  428. type NoMethod TestIamPermissionsResponse
  429. raw := NoMethod(*s)
  430. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  431. }
  432. // method id "iap.getIamPolicy":
  433. type V1beta1GetIamPolicyCall struct {
  434. s *Service
  435. resource string
  436. getiampolicyrequest *GetIamPolicyRequest
  437. urlParams_ gensupport.URLParams
  438. ctx_ context.Context
  439. header_ http.Header
  440. }
  441. // GetIamPolicy: Gets the access control policy for an Identity-Aware
  442. // Proxy protected
  443. // resource.
  444. // More information about managing access via IAP can be found
  445. // at:
  446. // https://cloud.google.com/iap/docs/managing-access#managing_access_
  447. // via_the_api
  448. func (r *V1beta1Service) GetIamPolicy(resource string, getiampolicyrequest *GetIamPolicyRequest) *V1beta1GetIamPolicyCall {
  449. c := &V1beta1GetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  450. c.resource = resource
  451. c.getiampolicyrequest = getiampolicyrequest
  452. return c
  453. }
  454. // Fields allows partial responses to be retrieved. See
  455. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  456. // for more information.
  457. func (c *V1beta1GetIamPolicyCall) Fields(s ...googleapi.Field) *V1beta1GetIamPolicyCall {
  458. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  459. return c
  460. }
  461. // Context sets the context to be used in this call's Do method. Any
  462. // pending HTTP request will be aborted if the provided context is
  463. // canceled.
  464. func (c *V1beta1GetIamPolicyCall) Context(ctx context.Context) *V1beta1GetIamPolicyCall {
  465. c.ctx_ = ctx
  466. return c
  467. }
  468. // Header returns an http.Header that can be modified by the caller to
  469. // add HTTP headers to the request.
  470. func (c *V1beta1GetIamPolicyCall) Header() http.Header {
  471. if c.header_ == nil {
  472. c.header_ = make(http.Header)
  473. }
  474. return c.header_
  475. }
  476. func (c *V1beta1GetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  477. reqHeaders := make(http.Header)
  478. for k, v := range c.header_ {
  479. reqHeaders[k] = v
  480. }
  481. reqHeaders.Set("User-Agent", c.s.userAgent())
  482. var body io.Reader = nil
  483. body, err := googleapi.WithoutDataWrapper.JSONReader(c.getiampolicyrequest)
  484. if err != nil {
  485. return nil, err
  486. }
  487. reqHeaders.Set("Content-Type", "application/json")
  488. c.urlParams_.Set("alt", alt)
  489. c.urlParams_.Set("prettyPrint", "false")
  490. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+resource}:getIamPolicy")
  491. urls += "?" + c.urlParams_.Encode()
  492. req, err := http.NewRequest("POST", urls, body)
  493. if err != nil {
  494. return nil, err
  495. }
  496. req.Header = reqHeaders
  497. googleapi.Expand(req.URL, map[string]string{
  498. "resource": c.resource,
  499. })
  500. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  501. }
  502. // Do executes the "iap.getIamPolicy" call.
  503. // Exactly one of *Policy or error will be non-nil. Any non-2xx status
  504. // code is an error. Response headers are in either
  505. // *Policy.ServerResponse.Header or (if a response was returned at all)
  506. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  507. // check whether the returned error was because http.StatusNotModified
  508. // was returned.
  509. func (c *V1beta1GetIamPolicyCall) Do(opts ...googleapi.CallOption) (*Policy, error) {
  510. gensupport.SetOptions(c.urlParams_, opts...)
  511. res, err := c.doRequest("json")
  512. if res != nil && res.StatusCode == http.StatusNotModified {
  513. if res.Body != nil {
  514. res.Body.Close()
  515. }
  516. return nil, &googleapi.Error{
  517. Code: res.StatusCode,
  518. Header: res.Header,
  519. }
  520. }
  521. if err != nil {
  522. return nil, err
  523. }
  524. defer googleapi.CloseBody(res)
  525. if err := googleapi.CheckResponse(res); err != nil {
  526. return nil, err
  527. }
  528. ret := &Policy{
  529. ServerResponse: googleapi.ServerResponse{
  530. Header: res.Header,
  531. HTTPStatusCode: res.StatusCode,
  532. },
  533. }
  534. target := &ret
  535. if err := gensupport.DecodeResponse(target, res); err != nil {
  536. return nil, err
  537. }
  538. return ret, nil
  539. // {
  540. // "description": "Gets the access control policy for an Identity-Aware Proxy protected\nresource.\nMore information about managing access via IAP can be found at:\nhttps://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api",
  541. // "flatPath": "v1beta1/{v1beta1Id}:getIamPolicy",
  542. // "httpMethod": "POST",
  543. // "id": "iap.getIamPolicy",
  544. // "parameterOrder": [
  545. // "resource"
  546. // ],
  547. // "parameters": {
  548. // "resource": {
  549. // "description": "REQUIRED: The resource for which the policy is being requested.\nSee the operation documentation for the appropriate value for this field.",
  550. // "location": "path",
  551. // "pattern": "^.+$",
  552. // "required": true,
  553. // "type": "string"
  554. // }
  555. // },
  556. // "path": "v1beta1/{+resource}:getIamPolicy",
  557. // "request": {
  558. // "$ref": "GetIamPolicyRequest"
  559. // },
  560. // "response": {
  561. // "$ref": "Policy"
  562. // },
  563. // "scopes": [
  564. // "https://www.googleapis.com/auth/cloud-platform"
  565. // ]
  566. // }
  567. }
  568. // method id "iap.setIamPolicy":
  569. type V1beta1SetIamPolicyCall struct {
  570. s *Service
  571. resource string
  572. setiampolicyrequest *SetIamPolicyRequest
  573. urlParams_ gensupport.URLParams
  574. ctx_ context.Context
  575. header_ http.Header
  576. }
  577. // SetIamPolicy: Sets the access control policy for an Identity-Aware
  578. // Proxy protected
  579. // resource. Replaces any existing policy.
  580. // More information about managing access via IAP can be found
  581. // at:
  582. // https://cloud.google.com/iap/docs/managing-access#managing_access_
  583. // via_the_api
  584. func (r *V1beta1Service) SetIamPolicy(resource string, setiampolicyrequest *SetIamPolicyRequest) *V1beta1SetIamPolicyCall {
  585. c := &V1beta1SetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  586. c.resource = resource
  587. c.setiampolicyrequest = setiampolicyrequest
  588. return c
  589. }
  590. // Fields allows partial responses to be retrieved. See
  591. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  592. // for more information.
  593. func (c *V1beta1SetIamPolicyCall) Fields(s ...googleapi.Field) *V1beta1SetIamPolicyCall {
  594. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  595. return c
  596. }
  597. // Context sets the context to be used in this call's Do method. Any
  598. // pending HTTP request will be aborted if the provided context is
  599. // canceled.
  600. func (c *V1beta1SetIamPolicyCall) Context(ctx context.Context) *V1beta1SetIamPolicyCall {
  601. c.ctx_ = ctx
  602. return c
  603. }
  604. // Header returns an http.Header that can be modified by the caller to
  605. // add HTTP headers to the request.
  606. func (c *V1beta1SetIamPolicyCall) Header() http.Header {
  607. if c.header_ == nil {
  608. c.header_ = make(http.Header)
  609. }
  610. return c.header_
  611. }
  612. func (c *V1beta1SetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  613. reqHeaders := make(http.Header)
  614. for k, v := range c.header_ {
  615. reqHeaders[k] = v
  616. }
  617. reqHeaders.Set("User-Agent", c.s.userAgent())
  618. var body io.Reader = nil
  619. body, err := googleapi.WithoutDataWrapper.JSONReader(c.setiampolicyrequest)
  620. if err != nil {
  621. return nil, err
  622. }
  623. reqHeaders.Set("Content-Type", "application/json")
  624. c.urlParams_.Set("alt", alt)
  625. c.urlParams_.Set("prettyPrint", "false")
  626. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+resource}:setIamPolicy")
  627. urls += "?" + c.urlParams_.Encode()
  628. req, err := http.NewRequest("POST", urls, body)
  629. if err != nil {
  630. return nil, err
  631. }
  632. req.Header = reqHeaders
  633. googleapi.Expand(req.URL, map[string]string{
  634. "resource": c.resource,
  635. })
  636. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  637. }
  638. // Do executes the "iap.setIamPolicy" call.
  639. // Exactly one of *Policy or error will be non-nil. Any non-2xx status
  640. // code is an error. Response headers are in either
  641. // *Policy.ServerResponse.Header or (if a response was returned at all)
  642. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  643. // check whether the returned error was because http.StatusNotModified
  644. // was returned.
  645. func (c *V1beta1SetIamPolicyCall) Do(opts ...googleapi.CallOption) (*Policy, error) {
  646. gensupport.SetOptions(c.urlParams_, opts...)
  647. res, err := c.doRequest("json")
  648. if res != nil && res.StatusCode == http.StatusNotModified {
  649. if res.Body != nil {
  650. res.Body.Close()
  651. }
  652. return nil, &googleapi.Error{
  653. Code: res.StatusCode,
  654. Header: res.Header,
  655. }
  656. }
  657. if err != nil {
  658. return nil, err
  659. }
  660. defer googleapi.CloseBody(res)
  661. if err := googleapi.CheckResponse(res); err != nil {
  662. return nil, err
  663. }
  664. ret := &Policy{
  665. ServerResponse: googleapi.ServerResponse{
  666. Header: res.Header,
  667. HTTPStatusCode: res.StatusCode,
  668. },
  669. }
  670. target := &ret
  671. if err := gensupport.DecodeResponse(target, res); err != nil {
  672. return nil, err
  673. }
  674. return ret, nil
  675. // {
  676. // "description": "Sets the access control policy for an Identity-Aware Proxy protected\nresource. Replaces any existing policy.\nMore information about managing access via IAP can be found at:\nhttps://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api",
  677. // "flatPath": "v1beta1/{v1beta1Id}:setIamPolicy",
  678. // "httpMethod": "POST",
  679. // "id": "iap.setIamPolicy",
  680. // "parameterOrder": [
  681. // "resource"
  682. // ],
  683. // "parameters": {
  684. // "resource": {
  685. // "description": "REQUIRED: The resource for which the policy is being specified.\nSee the operation documentation for the appropriate value for this field.",
  686. // "location": "path",
  687. // "pattern": "^.+$",
  688. // "required": true,
  689. // "type": "string"
  690. // }
  691. // },
  692. // "path": "v1beta1/{+resource}:setIamPolicy",
  693. // "request": {
  694. // "$ref": "SetIamPolicyRequest"
  695. // },
  696. // "response": {
  697. // "$ref": "Policy"
  698. // },
  699. // "scopes": [
  700. // "https://www.googleapis.com/auth/cloud-platform"
  701. // ]
  702. // }
  703. }
  704. // method id "iap.testIamPermissions":
  705. type V1beta1TestIamPermissionsCall struct {
  706. s *Service
  707. resource string
  708. testiampermissionsrequest *TestIamPermissionsRequest
  709. urlParams_ gensupport.URLParams
  710. ctx_ context.Context
  711. header_ http.Header
  712. }
  713. // TestIamPermissions: Returns permissions that a caller has on the
  714. // Identity-Aware Proxy protected
  715. // resource. If the resource does not exist or the caller does not
  716. // have
  717. // Identity-Aware Proxy permissions a
  718. // [google.rpc.Code.PERMISSION_DENIED]
  719. // will be returned.
  720. // More information about managing access via IAP can be found
  721. // at:
  722. // https://cloud.google.com/iap/docs/managing-access#managing_access_
  723. // via_the_api
  724. func (r *V1beta1Service) TestIamPermissions(resource string, testiampermissionsrequest *TestIamPermissionsRequest) *V1beta1TestIamPermissionsCall {
  725. c := &V1beta1TestIamPermissionsCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  726. c.resource = resource
  727. c.testiampermissionsrequest = testiampermissionsrequest
  728. return c
  729. }
  730. // Fields allows partial responses to be retrieved. See
  731. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  732. // for more information.
  733. func (c *V1beta1TestIamPermissionsCall) Fields(s ...googleapi.Field) *V1beta1TestIamPermissionsCall {
  734. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  735. return c
  736. }
  737. // Context sets the context to be used in this call's Do method. Any
  738. // pending HTTP request will be aborted if the provided context is
  739. // canceled.
  740. func (c *V1beta1TestIamPermissionsCall) Context(ctx context.Context) *V1beta1TestIamPermissionsCall {
  741. c.ctx_ = ctx
  742. return c
  743. }
  744. // Header returns an http.Header that can be modified by the caller to
  745. // add HTTP headers to the request.
  746. func (c *V1beta1TestIamPermissionsCall) Header() http.Header {
  747. if c.header_ == nil {
  748. c.header_ = make(http.Header)
  749. }
  750. return c.header_
  751. }
  752. func (c *V1beta1TestIamPermissionsCall) doRequest(alt string) (*http.Response, error) {
  753. reqHeaders := make(http.Header)
  754. for k, v := range c.header_ {
  755. reqHeaders[k] = v
  756. }
  757. reqHeaders.Set("User-Agent", c.s.userAgent())
  758. var body io.Reader = nil
  759. body, err := googleapi.WithoutDataWrapper.JSONReader(c.testiampermissionsrequest)
  760. if err != nil {
  761. return nil, err
  762. }
  763. reqHeaders.Set("Content-Type", "application/json")
  764. c.urlParams_.Set("alt", alt)
  765. c.urlParams_.Set("prettyPrint", "false")
  766. urls := googleapi.ResolveRelative(c.s.BasePath, "v1beta1/{+resource}:testIamPermissions")
  767. urls += "?" + c.urlParams_.Encode()
  768. req, err := http.NewRequest("POST", urls, body)
  769. if err != nil {
  770. return nil, err
  771. }
  772. req.Header = reqHeaders
  773. googleapi.Expand(req.URL, map[string]string{
  774. "resource": c.resource,
  775. })
  776. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  777. }
  778. // Do executes the "iap.testIamPermissions" call.
  779. // Exactly one of *TestIamPermissionsResponse or error will be non-nil.
  780. // Any non-2xx status code is an error. Response headers are in either
  781. // *TestIamPermissionsResponse.ServerResponse.Header or (if a response
  782. // was returned at all) in error.(*googleapi.Error).Header. Use
  783. // googleapi.IsNotModified to check whether the returned error was
  784. // because http.StatusNotModified was returned.
  785. func (c *V1beta1TestIamPermissionsCall) Do(opts ...googleapi.CallOption) (*TestIamPermissionsResponse, error) {
  786. gensupport.SetOptions(c.urlParams_, opts...)
  787. res, err := c.doRequest("json")
  788. if res != nil && res.StatusCode == http.StatusNotModified {
  789. if res.Body != nil {
  790. res.Body.Close()
  791. }
  792. return nil, &googleapi.Error{
  793. Code: res.StatusCode,
  794. Header: res.Header,
  795. }
  796. }
  797. if err != nil {
  798. return nil, err
  799. }
  800. defer googleapi.CloseBody(res)
  801. if err := googleapi.CheckResponse(res); err != nil {
  802. return nil, err
  803. }
  804. ret := &TestIamPermissionsResponse{
  805. ServerResponse: googleapi.ServerResponse{
  806. Header: res.Header,
  807. HTTPStatusCode: res.StatusCode,
  808. },
  809. }
  810. target := &ret
  811. if err := gensupport.DecodeResponse(target, res); err != nil {
  812. return nil, err
  813. }
  814. return ret, nil
  815. // {
  816. // "description": "Returns permissions that a caller has on the Identity-Aware Proxy protected\nresource. If the resource does not exist or the caller does not have\nIdentity-Aware Proxy permissions a [google.rpc.Code.PERMISSION_DENIED]\nwill be returned.\nMore information about managing access via IAP can be found at:\nhttps://cloud.google.com/iap/docs/managing-access#managing_access_via_the_api",
  817. // "flatPath": "v1beta1/{v1beta1Id}:testIamPermissions",
  818. // "httpMethod": "POST",
  819. // "id": "iap.testIamPermissions",
  820. // "parameterOrder": [
  821. // "resource"
  822. // ],
  823. // "parameters": {
  824. // "resource": {
  825. // "description": "REQUIRED: The resource for which the policy detail is being requested.\nSee the operation documentation for the appropriate value for this field.",
  826. // "location": "path",
  827. // "pattern": "^.+$",
  828. // "required": true,
  829. // "type": "string"
  830. // }
  831. // },
  832. // "path": "v1beta1/{+resource}:testIamPermissions",
  833. // "request": {
  834. // "$ref": "TestIamPermissionsRequest"
  835. // },
  836. // "response": {
  837. // "$ref": "TestIamPermissionsResponse"
  838. // },
  839. // "scopes": [
  840. // "https://www.googleapis.com/auth/cloud-platform"
  841. // ]
  842. // }
  843. }