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.
 
 
 

786 lines
26 KiB

  1. // Package servicebroker provides access to the Service Broker API.
  2. //
  3. // See https://cloud.google.com/kubernetes-engine/docs/concepts/add-on/service-broker
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/servicebroker/v1"
  8. // ...
  9. // servicebrokerService, err := servicebroker.New(oauthHttpClient)
  10. package servicebroker // import "google.golang.org/api/servicebroker/v1"
  11. import (
  12. "bytes"
  13. "encoding/json"
  14. "errors"
  15. "fmt"
  16. context "golang.org/x/net/context"
  17. ctxhttp "golang.org/x/net/context/ctxhttp"
  18. gensupport "google.golang.org/api/gensupport"
  19. googleapi "google.golang.org/api/googleapi"
  20. "io"
  21. "net/http"
  22. "net/url"
  23. "strconv"
  24. "strings"
  25. )
  26. // Always reference these packages, just in case the auto-generated code
  27. // below doesn't.
  28. var _ = bytes.NewBuffer
  29. var _ = strconv.Itoa
  30. var _ = fmt.Sprintf
  31. var _ = json.NewDecoder
  32. var _ = io.Copy
  33. var _ = url.Parse
  34. var _ = gensupport.MarshalJSON
  35. var _ = googleapi.Version
  36. var _ = errors.New
  37. var _ = strings.Replace
  38. var _ = context.Canceled
  39. var _ = ctxhttp.Do
  40. const apiId = "servicebroker:v1"
  41. const apiName = "servicebroker"
  42. const apiVersion = "v1"
  43. const basePath = "https://servicebroker.googleapis.com/"
  44. // OAuth2 scopes used by this API.
  45. const (
  46. // View and manage your data across Google Cloud Platform services
  47. CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
  48. )
  49. func New(client *http.Client) (*Service, error) {
  50. if client == nil {
  51. return nil, errors.New("client is nil")
  52. }
  53. s := &Service{client: client, BasePath: basePath}
  54. s.V1 = NewV1Service(s)
  55. return s, nil
  56. }
  57. type Service struct {
  58. client *http.Client
  59. BasePath string // API endpoint base URL
  60. UserAgent string // optional additional User-Agent fragment
  61. V1 *V1Service
  62. }
  63. func (s *Service) userAgent() string {
  64. if s.UserAgent == "" {
  65. return googleapi.UserAgent
  66. }
  67. return googleapi.UserAgent + " " + s.UserAgent
  68. }
  69. func NewV1Service(s *Service) *V1Service {
  70. rs := &V1Service{s: s}
  71. return rs
  72. }
  73. type V1Service struct {
  74. s *Service
  75. }
  76. // GoogleIamV1__Binding: Associates `members` with a `role`.
  77. type GoogleIamV1__Binding struct {
  78. // Members: Specifies the identities requesting access for a Cloud
  79. // Platform resource.
  80. // `members` can have the following values:
  81. //
  82. // * `allUsers`: A special identifier that represents anyone who is
  83. // on the internet; with or without a Google account.
  84. //
  85. // * `allAuthenticatedUsers`: A special identifier that represents
  86. // anyone
  87. // who is authenticated with a Google account or a service
  88. // account.
  89. //
  90. // * `user:{emailid}`: An email address that represents a specific
  91. // Google
  92. // account. For example, `alice@gmail.com` .
  93. //
  94. //
  95. // * `serviceAccount:{emailid}`: An email address that represents a
  96. // service
  97. // account. For example,
  98. // `my-other-app@appspot.gserviceaccount.com`.
  99. //
  100. // * `group:{emailid}`: An email address that represents a Google
  101. // group.
  102. // For example, `admins@example.com`.
  103. //
  104. //
  105. // * `domain:{domain}`: A Google Apps domain name that represents all
  106. // the
  107. // users of that domain. For example, `google.com` or
  108. // `example.com`.
  109. //
  110. //
  111. Members []string `json:"members,omitempty"`
  112. // Role: Role that is assigned to `members`.
  113. // For example, `roles/viewer`, `roles/editor`, or
  114. // `roles/owner`.
  115. // Required
  116. Role string `json:"role,omitempty"`
  117. // ForceSendFields is a list of field names (e.g. "Members") to
  118. // unconditionally include in API requests. By default, fields with
  119. // empty values are omitted from API requests. However, any non-pointer,
  120. // non-interface field appearing in ForceSendFields will be sent to the
  121. // server regardless of whether the field is empty or not. This may be
  122. // used to include empty fields in Patch requests.
  123. ForceSendFields []string `json:"-"`
  124. // NullFields is a list of field names (e.g. "Members") to include in
  125. // API requests with the JSON null value. By default, fields with empty
  126. // values are omitted from API requests. However, any field with an
  127. // empty value appearing in NullFields will be sent to the server as
  128. // null. It is an error if a field in this list has a non-empty value.
  129. // This may be used to include null fields in Patch requests.
  130. NullFields []string `json:"-"`
  131. }
  132. func (s *GoogleIamV1__Binding) MarshalJSON() ([]byte, error) {
  133. type NoMethod GoogleIamV1__Binding
  134. raw := NoMethod(*s)
  135. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  136. }
  137. // GoogleIamV1__Policy: Defines an Identity and Access Management (IAM)
  138. // policy. It is used to
  139. // specify access control policies for Cloud Platform resources.
  140. //
  141. //
  142. // A `Policy` consists of a list of `bindings`. A `binding` binds a list
  143. // of
  144. // `members` to a `role`, where the members can be user accounts, Google
  145. // groups,
  146. // Google domains, and service accounts. A `role` is a named list of
  147. // permissions
  148. // defined by IAM.
  149. //
  150. // **JSON Example**
  151. //
  152. // {
  153. // "bindings": [
  154. // {
  155. // "role": "roles/owner",
  156. // "members": [
  157. // "user:mike@example.com",
  158. // "group:admins@example.com",
  159. // "domain:google.com",
  160. //
  161. // "serviceAccount:my-other-app@appspot.gserviceaccount.com"
  162. // ]
  163. // },
  164. // {
  165. // "role": "roles/viewer",
  166. // "members": ["user:sean@example.com"]
  167. // }
  168. // ]
  169. // }
  170. //
  171. // **YAML Example**
  172. //
  173. // bindings:
  174. // - members:
  175. // - user:mike@example.com
  176. // - group:admins@example.com
  177. // - domain:google.com
  178. // - serviceAccount:my-other-app@appspot.gserviceaccount.com
  179. // role: roles/owner
  180. // - members:
  181. // - user:sean@example.com
  182. // role: roles/viewer
  183. //
  184. //
  185. // For a description of IAM and its features, see the
  186. // [IAM developer's guide](https://cloud.google.com/iam/docs).
  187. type GoogleIamV1__Policy struct {
  188. // Bindings: Associates a list of `members` to a `role`.
  189. // `bindings` with no members will result in an error.
  190. Bindings []*GoogleIamV1__Binding `json:"bindings,omitempty"`
  191. // Etag: `etag` is used for optimistic concurrency control as a way to
  192. // help
  193. // prevent simultaneous updates of a policy from overwriting each
  194. // other.
  195. // It is strongly suggested that systems make use of the `etag` in
  196. // the
  197. // read-modify-write cycle to perform policy updates in order to avoid
  198. // race
  199. // conditions: An `etag` is returned in the response to `getIamPolicy`,
  200. // and
  201. // systems are expected to put that etag in the request to
  202. // `setIamPolicy` to
  203. // ensure that their change will be applied to the same version of the
  204. // policy.
  205. //
  206. // If no `etag` is provided in the call to `setIamPolicy`, then the
  207. // existing
  208. // policy is overwritten blindly.
  209. Etag string `json:"etag,omitempty"`
  210. // Version: Deprecated.
  211. Version int64 `json:"version,omitempty"`
  212. // ServerResponse contains the HTTP response code and headers from the
  213. // server.
  214. googleapi.ServerResponse `json:"-"`
  215. // ForceSendFields is a list of field names (e.g. "Bindings") to
  216. // unconditionally include in API requests. By default, fields with
  217. // empty values are omitted from API requests. However, any non-pointer,
  218. // non-interface field appearing in ForceSendFields will be sent to the
  219. // server regardless of whether the field is empty or not. This may be
  220. // used to include empty fields in Patch requests.
  221. ForceSendFields []string `json:"-"`
  222. // NullFields is a list of field names (e.g. "Bindings") to include in
  223. // API requests with the JSON null value. By default, fields with empty
  224. // values are omitted from API requests. However, any field with an
  225. // empty value appearing in NullFields will be sent to the server as
  226. // null. It is an error if a field in this list has a non-empty value.
  227. // This may be used to include null fields in Patch requests.
  228. NullFields []string `json:"-"`
  229. }
  230. func (s *GoogleIamV1__Policy) MarshalJSON() ([]byte, error) {
  231. type NoMethod GoogleIamV1__Policy
  232. raw := NoMethod(*s)
  233. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  234. }
  235. // GoogleIamV1__SetIamPolicyRequest: Request message for `SetIamPolicy`
  236. // method.
  237. type GoogleIamV1__SetIamPolicyRequest struct {
  238. // Policy: REQUIRED: The complete policy to be applied to the
  239. // `resource`. The size of
  240. // the policy is limited to a few 10s of KB. An empty policy is a
  241. // valid policy but certain Cloud Platform services (such as
  242. // Projects)
  243. // might reject them.
  244. Policy *GoogleIamV1__Policy `json:"policy,omitempty"`
  245. // ForceSendFields is a list of field names (e.g. "Policy") to
  246. // unconditionally include in API requests. By default, fields with
  247. // empty values are omitted from API requests. However, any non-pointer,
  248. // non-interface field appearing in ForceSendFields will be sent to the
  249. // server regardless of whether the field is empty or not. This may be
  250. // used to include empty fields in Patch requests.
  251. ForceSendFields []string `json:"-"`
  252. // NullFields is a list of field names (e.g. "Policy") to include in API
  253. // requests with the JSON null value. By default, fields with empty
  254. // values are omitted from API requests. However, any field with an
  255. // empty value appearing in NullFields will be sent to the server as
  256. // null. It is an error if a field in this list has a non-empty value.
  257. // This may be used to include null fields in Patch requests.
  258. NullFields []string `json:"-"`
  259. }
  260. func (s *GoogleIamV1__SetIamPolicyRequest) MarshalJSON() ([]byte, error) {
  261. type NoMethod GoogleIamV1__SetIamPolicyRequest
  262. raw := NoMethod(*s)
  263. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  264. }
  265. // GoogleIamV1__TestIamPermissionsRequest: Request message for
  266. // `TestIamPermissions` method.
  267. type GoogleIamV1__TestIamPermissionsRequest struct {
  268. // Permissions: The set of permissions to check for the `resource`.
  269. // Permissions with
  270. // wildcards (such as '*' or 'storage.*') are not allowed. For
  271. // more
  272. // information see
  273. // [IAM
  274. // Overview](https://cloud.google.com/iam/docs/overview#permissions).
  275. Permissions []string `json:"permissions,omitempty"`
  276. // ForceSendFields is a list of field names (e.g. "Permissions") to
  277. // unconditionally include in API requests. By default, fields with
  278. // empty values are omitted from API requests. However, any non-pointer,
  279. // non-interface field appearing in ForceSendFields will be sent to the
  280. // server regardless of whether the field is empty or not. This may be
  281. // used to include empty fields in Patch requests.
  282. ForceSendFields []string `json:"-"`
  283. // NullFields is a list of field names (e.g. "Permissions") to include
  284. // in API requests with the JSON null value. By default, fields with
  285. // empty values are omitted from API requests. However, any field with
  286. // an empty value appearing in NullFields will be sent to the server as
  287. // null. It is an error if a field in this list has a non-empty value.
  288. // This may be used to include null fields in Patch requests.
  289. NullFields []string `json:"-"`
  290. }
  291. func (s *GoogleIamV1__TestIamPermissionsRequest) MarshalJSON() ([]byte, error) {
  292. type NoMethod GoogleIamV1__TestIamPermissionsRequest
  293. raw := NoMethod(*s)
  294. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  295. }
  296. // GoogleIamV1__TestIamPermissionsResponse: Response message for
  297. // `TestIamPermissions` method.
  298. type GoogleIamV1__TestIamPermissionsResponse struct {
  299. // Permissions: A subset of `TestPermissionsRequest.permissions` that
  300. // the caller is
  301. // allowed.
  302. Permissions []string `json:"permissions,omitempty"`
  303. // ServerResponse contains the HTTP response code and headers from the
  304. // server.
  305. googleapi.ServerResponse `json:"-"`
  306. // ForceSendFields is a list of field names (e.g. "Permissions") to
  307. // unconditionally include in API requests. By default, fields with
  308. // empty values are omitted from API requests. However, any non-pointer,
  309. // non-interface field appearing in ForceSendFields will be sent to the
  310. // server regardless of whether the field is empty or not. This may be
  311. // used to include empty fields in Patch requests.
  312. ForceSendFields []string `json:"-"`
  313. // NullFields is a list of field names (e.g. "Permissions") to include
  314. // in API requests with the JSON null value. By default, fields with
  315. // empty values are omitted from API requests. However, any field with
  316. // an empty value appearing in NullFields will be sent to the server as
  317. // null. It is an error if a field in this list has a non-empty value.
  318. // This may be used to include null fields in Patch requests.
  319. NullFields []string `json:"-"`
  320. }
  321. func (s *GoogleIamV1__TestIamPermissionsResponse) MarshalJSON() ([]byte, error) {
  322. type NoMethod GoogleIamV1__TestIamPermissionsResponse
  323. raw := NoMethod(*s)
  324. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  325. }
  326. // method id "servicebroker.getIamPolicy":
  327. type V1GetIamPolicyCall struct {
  328. s *Service
  329. resource string
  330. urlParams_ gensupport.URLParams
  331. ifNoneMatch_ string
  332. ctx_ context.Context
  333. header_ http.Header
  334. }
  335. // GetIamPolicy: Gets the access control policy for a resource.
  336. // Returns an empty policy if the resource exists and does not have a
  337. // policy
  338. // set.
  339. func (r *V1Service) GetIamPolicy(resource string) *V1GetIamPolicyCall {
  340. c := &V1GetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  341. c.resource = resource
  342. return c
  343. }
  344. // Fields allows partial responses to be retrieved. See
  345. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  346. // for more information.
  347. func (c *V1GetIamPolicyCall) Fields(s ...googleapi.Field) *V1GetIamPolicyCall {
  348. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  349. return c
  350. }
  351. // IfNoneMatch sets the optional parameter which makes the operation
  352. // fail if the object's ETag matches the given value. This is useful for
  353. // getting updates only after the object has changed since the last
  354. // request. Use googleapi.IsNotModified to check whether the response
  355. // error from Do is the result of In-None-Match.
  356. func (c *V1GetIamPolicyCall) IfNoneMatch(entityTag string) *V1GetIamPolicyCall {
  357. c.ifNoneMatch_ = entityTag
  358. return c
  359. }
  360. // Context sets the context to be used in this call's Do method. Any
  361. // pending HTTP request will be aborted if the provided context is
  362. // canceled.
  363. func (c *V1GetIamPolicyCall) Context(ctx context.Context) *V1GetIamPolicyCall {
  364. c.ctx_ = ctx
  365. return c
  366. }
  367. // Header returns an http.Header that can be modified by the caller to
  368. // add HTTP headers to the request.
  369. func (c *V1GetIamPolicyCall) Header() http.Header {
  370. if c.header_ == nil {
  371. c.header_ = make(http.Header)
  372. }
  373. return c.header_
  374. }
  375. func (c *V1GetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  376. reqHeaders := make(http.Header)
  377. for k, v := range c.header_ {
  378. reqHeaders[k] = v
  379. }
  380. reqHeaders.Set("User-Agent", c.s.userAgent())
  381. if c.ifNoneMatch_ != "" {
  382. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  383. }
  384. var body io.Reader = nil
  385. c.urlParams_.Set("alt", alt)
  386. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+resource}:getIamPolicy")
  387. urls += "?" + c.urlParams_.Encode()
  388. req, _ := http.NewRequest("GET", urls, body)
  389. req.Header = reqHeaders
  390. googleapi.Expand(req.URL, map[string]string{
  391. "resource": c.resource,
  392. })
  393. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  394. }
  395. // Do executes the "servicebroker.getIamPolicy" call.
  396. // Exactly one of *GoogleIamV1__Policy or error will be non-nil. Any
  397. // non-2xx status code is an error. Response headers are in either
  398. // *GoogleIamV1__Policy.ServerResponse.Header or (if a response was
  399. // returned at all) in error.(*googleapi.Error).Header. Use
  400. // googleapi.IsNotModified to check whether the returned error was
  401. // because http.StatusNotModified was returned.
  402. func (c *V1GetIamPolicyCall) Do(opts ...googleapi.CallOption) (*GoogleIamV1__Policy, error) {
  403. gensupport.SetOptions(c.urlParams_, opts...)
  404. res, err := c.doRequest("json")
  405. if res != nil && res.StatusCode == http.StatusNotModified {
  406. if res.Body != nil {
  407. res.Body.Close()
  408. }
  409. return nil, &googleapi.Error{
  410. Code: res.StatusCode,
  411. Header: res.Header,
  412. }
  413. }
  414. if err != nil {
  415. return nil, err
  416. }
  417. defer googleapi.CloseBody(res)
  418. if err := googleapi.CheckResponse(res); err != nil {
  419. return nil, err
  420. }
  421. ret := &GoogleIamV1__Policy{
  422. ServerResponse: googleapi.ServerResponse{
  423. Header: res.Header,
  424. HTTPStatusCode: res.StatusCode,
  425. },
  426. }
  427. target := &ret
  428. if err := gensupport.DecodeResponse(target, res); err != nil {
  429. return nil, err
  430. }
  431. return ret, nil
  432. // {
  433. // "description": "Gets the access control policy for a resource.\nReturns an empty policy if the resource exists and does not have a policy\nset.",
  434. // "flatPath": "v1/{v1Id}:getIamPolicy",
  435. // "httpMethod": "GET",
  436. // "id": "servicebroker.getIamPolicy",
  437. // "parameterOrder": [
  438. // "resource"
  439. // ],
  440. // "parameters": {
  441. // "resource": {
  442. // "description": "REQUIRED: The resource for which the policy is being requested.\nSee the operation documentation for the appropriate value for this field.",
  443. // "location": "path",
  444. // "pattern": "^.+$",
  445. // "required": true,
  446. // "type": "string"
  447. // }
  448. // },
  449. // "path": "v1/{+resource}:getIamPolicy",
  450. // "response": {
  451. // "$ref": "GoogleIamV1__Policy"
  452. // },
  453. // "scopes": [
  454. // "https://www.googleapis.com/auth/cloud-platform"
  455. // ]
  456. // }
  457. }
  458. // method id "servicebroker.setIamPolicy":
  459. type V1SetIamPolicyCall struct {
  460. s *Service
  461. resource string
  462. googleiamv1__setiampolicyrequest *GoogleIamV1__SetIamPolicyRequest
  463. urlParams_ gensupport.URLParams
  464. ctx_ context.Context
  465. header_ http.Header
  466. }
  467. // SetIamPolicy: Sets the access control policy on the specified
  468. // resource. Replaces any
  469. // existing policy.
  470. func (r *V1Service) SetIamPolicy(resource string, googleiamv1__setiampolicyrequest *GoogleIamV1__SetIamPolicyRequest) *V1SetIamPolicyCall {
  471. c := &V1SetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  472. c.resource = resource
  473. c.googleiamv1__setiampolicyrequest = googleiamv1__setiampolicyrequest
  474. return c
  475. }
  476. // Fields allows partial responses to be retrieved. See
  477. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  478. // for more information.
  479. func (c *V1SetIamPolicyCall) Fields(s ...googleapi.Field) *V1SetIamPolicyCall {
  480. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  481. return c
  482. }
  483. // Context sets the context to be used in this call's Do method. Any
  484. // pending HTTP request will be aborted if the provided context is
  485. // canceled.
  486. func (c *V1SetIamPolicyCall) Context(ctx context.Context) *V1SetIamPolicyCall {
  487. c.ctx_ = ctx
  488. return c
  489. }
  490. // Header returns an http.Header that can be modified by the caller to
  491. // add HTTP headers to the request.
  492. func (c *V1SetIamPolicyCall) Header() http.Header {
  493. if c.header_ == nil {
  494. c.header_ = make(http.Header)
  495. }
  496. return c.header_
  497. }
  498. func (c *V1SetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  499. reqHeaders := make(http.Header)
  500. for k, v := range c.header_ {
  501. reqHeaders[k] = v
  502. }
  503. reqHeaders.Set("User-Agent", c.s.userAgent())
  504. var body io.Reader = nil
  505. body, err := googleapi.WithoutDataWrapper.JSONReader(c.googleiamv1__setiampolicyrequest)
  506. if err != nil {
  507. return nil, err
  508. }
  509. reqHeaders.Set("Content-Type", "application/json")
  510. c.urlParams_.Set("alt", alt)
  511. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+resource}:setIamPolicy")
  512. urls += "?" + c.urlParams_.Encode()
  513. req, _ := http.NewRequest("POST", urls, body)
  514. req.Header = reqHeaders
  515. googleapi.Expand(req.URL, map[string]string{
  516. "resource": c.resource,
  517. })
  518. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  519. }
  520. // Do executes the "servicebroker.setIamPolicy" call.
  521. // Exactly one of *GoogleIamV1__Policy or error will be non-nil. Any
  522. // non-2xx status code is an error. Response headers are in either
  523. // *GoogleIamV1__Policy.ServerResponse.Header or (if a response was
  524. // returned at all) in error.(*googleapi.Error).Header. Use
  525. // googleapi.IsNotModified to check whether the returned error was
  526. // because http.StatusNotModified was returned.
  527. func (c *V1SetIamPolicyCall) Do(opts ...googleapi.CallOption) (*GoogleIamV1__Policy, error) {
  528. gensupport.SetOptions(c.urlParams_, opts...)
  529. res, err := c.doRequest("json")
  530. if res != nil && res.StatusCode == http.StatusNotModified {
  531. if res.Body != nil {
  532. res.Body.Close()
  533. }
  534. return nil, &googleapi.Error{
  535. Code: res.StatusCode,
  536. Header: res.Header,
  537. }
  538. }
  539. if err != nil {
  540. return nil, err
  541. }
  542. defer googleapi.CloseBody(res)
  543. if err := googleapi.CheckResponse(res); err != nil {
  544. return nil, err
  545. }
  546. ret := &GoogleIamV1__Policy{
  547. ServerResponse: googleapi.ServerResponse{
  548. Header: res.Header,
  549. HTTPStatusCode: res.StatusCode,
  550. },
  551. }
  552. target := &ret
  553. if err := gensupport.DecodeResponse(target, res); err != nil {
  554. return nil, err
  555. }
  556. return ret, nil
  557. // {
  558. // "description": "Sets the access control policy on the specified resource. Replaces any\nexisting policy.",
  559. // "flatPath": "v1/{v1Id}:setIamPolicy",
  560. // "httpMethod": "POST",
  561. // "id": "servicebroker.setIamPolicy",
  562. // "parameterOrder": [
  563. // "resource"
  564. // ],
  565. // "parameters": {
  566. // "resource": {
  567. // "description": "REQUIRED: The resource for which the policy is being specified.\nSee the operation documentation for the appropriate value for this field.",
  568. // "location": "path",
  569. // "pattern": "^.+$",
  570. // "required": true,
  571. // "type": "string"
  572. // }
  573. // },
  574. // "path": "v1/{+resource}:setIamPolicy",
  575. // "request": {
  576. // "$ref": "GoogleIamV1__SetIamPolicyRequest"
  577. // },
  578. // "response": {
  579. // "$ref": "GoogleIamV1__Policy"
  580. // },
  581. // "scopes": [
  582. // "https://www.googleapis.com/auth/cloud-platform"
  583. // ]
  584. // }
  585. }
  586. // method id "servicebroker.testIamPermissions":
  587. type V1TestIamPermissionsCall struct {
  588. s *Service
  589. resource string
  590. googleiamv1__testiampermissionsrequest *GoogleIamV1__TestIamPermissionsRequest
  591. urlParams_ gensupport.URLParams
  592. ctx_ context.Context
  593. header_ http.Header
  594. }
  595. // TestIamPermissions: Returns permissions that a caller has on the
  596. // specified resource.
  597. // If the resource does not exist, this will return an empty set
  598. // of
  599. // permissions, not a NOT_FOUND error.
  600. //
  601. // Note: This operation is designed to be used for building
  602. // permission-aware
  603. // UIs and command-line tools, not for authorization checking. This
  604. // operation
  605. // may "fail open" without warning.
  606. func (r *V1Service) TestIamPermissions(resource string, googleiamv1__testiampermissionsrequest *GoogleIamV1__TestIamPermissionsRequest) *V1TestIamPermissionsCall {
  607. c := &V1TestIamPermissionsCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  608. c.resource = resource
  609. c.googleiamv1__testiampermissionsrequest = googleiamv1__testiampermissionsrequest
  610. return c
  611. }
  612. // Fields allows partial responses to be retrieved. See
  613. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  614. // for more information.
  615. func (c *V1TestIamPermissionsCall) Fields(s ...googleapi.Field) *V1TestIamPermissionsCall {
  616. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  617. return c
  618. }
  619. // Context sets the context to be used in this call's Do method. Any
  620. // pending HTTP request will be aborted if the provided context is
  621. // canceled.
  622. func (c *V1TestIamPermissionsCall) Context(ctx context.Context) *V1TestIamPermissionsCall {
  623. c.ctx_ = ctx
  624. return c
  625. }
  626. // Header returns an http.Header that can be modified by the caller to
  627. // add HTTP headers to the request.
  628. func (c *V1TestIamPermissionsCall) Header() http.Header {
  629. if c.header_ == nil {
  630. c.header_ = make(http.Header)
  631. }
  632. return c.header_
  633. }
  634. func (c *V1TestIamPermissionsCall) doRequest(alt string) (*http.Response, error) {
  635. reqHeaders := make(http.Header)
  636. for k, v := range c.header_ {
  637. reqHeaders[k] = v
  638. }
  639. reqHeaders.Set("User-Agent", c.s.userAgent())
  640. var body io.Reader = nil
  641. body, err := googleapi.WithoutDataWrapper.JSONReader(c.googleiamv1__testiampermissionsrequest)
  642. if err != nil {
  643. return nil, err
  644. }
  645. reqHeaders.Set("Content-Type", "application/json")
  646. c.urlParams_.Set("alt", alt)
  647. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+resource}:testIamPermissions")
  648. urls += "?" + c.urlParams_.Encode()
  649. req, _ := http.NewRequest("POST", urls, body)
  650. req.Header = reqHeaders
  651. googleapi.Expand(req.URL, map[string]string{
  652. "resource": c.resource,
  653. })
  654. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  655. }
  656. // Do executes the "servicebroker.testIamPermissions" call.
  657. // Exactly one of *GoogleIamV1__TestIamPermissionsResponse or error will
  658. // be non-nil. Any non-2xx status code is an error. Response headers are
  659. // in either
  660. // *GoogleIamV1__TestIamPermissionsResponse.ServerResponse.Header or (if
  661. // a response was returned at all) in error.(*googleapi.Error).Header.
  662. // Use googleapi.IsNotModified to check whether the returned error was
  663. // because http.StatusNotModified was returned.
  664. func (c *V1TestIamPermissionsCall) Do(opts ...googleapi.CallOption) (*GoogleIamV1__TestIamPermissionsResponse, error) {
  665. gensupport.SetOptions(c.urlParams_, opts...)
  666. res, err := c.doRequest("json")
  667. if res != nil && res.StatusCode == http.StatusNotModified {
  668. if res.Body != nil {
  669. res.Body.Close()
  670. }
  671. return nil, &googleapi.Error{
  672. Code: res.StatusCode,
  673. Header: res.Header,
  674. }
  675. }
  676. if err != nil {
  677. return nil, err
  678. }
  679. defer googleapi.CloseBody(res)
  680. if err := googleapi.CheckResponse(res); err != nil {
  681. return nil, err
  682. }
  683. ret := &GoogleIamV1__TestIamPermissionsResponse{
  684. ServerResponse: googleapi.ServerResponse{
  685. Header: res.Header,
  686. HTTPStatusCode: res.StatusCode,
  687. },
  688. }
  689. target := &ret
  690. if err := gensupport.DecodeResponse(target, res); err != nil {
  691. return nil, err
  692. }
  693. return ret, nil
  694. // {
  695. // "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.",
  696. // "flatPath": "v1/{v1Id}:testIamPermissions",
  697. // "httpMethod": "POST",
  698. // "id": "servicebroker.testIamPermissions",
  699. // "parameterOrder": [
  700. // "resource"
  701. // ],
  702. // "parameters": {
  703. // "resource": {
  704. // "description": "REQUIRED: The resource for which the policy detail is being requested.\nSee the operation documentation for the appropriate value for this field.",
  705. // "location": "path",
  706. // "pattern": "^.+$",
  707. // "required": true,
  708. // "type": "string"
  709. // }
  710. // },
  711. // "path": "v1/{+resource}:testIamPermissions",
  712. // "request": {
  713. // "$ref": "GoogleIamV1__TestIamPermissionsRequest"
  714. // },
  715. // "response": {
  716. // "$ref": "GoogleIamV1__TestIamPermissionsResponse"
  717. // },
  718. // "scopes": [
  719. // "https://www.googleapis.com/auth/cloud-platform"
  720. // ]
  721. // }
  722. }