No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

1321 líneas
47 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 iamcredentials provides access to the IAM Service Account Credentials API.
  6. //
  7. // For product documentation, see: https://cloud.google.com/iam/docs/creating-short-lived-service-account-credentials
  8. //
  9. // Creating a client
  10. //
  11. // Usage example:
  12. //
  13. // import "google.golang.org/api/iamcredentials/v1"
  14. // ...
  15. // ctx := context.Background()
  16. // iamcredentialsService, err := iamcredentials.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. // iamcredentialsService, err := iamcredentials.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. // iamcredentialsService, err := iamcredentials.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 iamcredentials // import "google.golang.org/api/iamcredentials/v1"
  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 = "iamcredentials:v1"
  67. const apiName = "iamcredentials"
  68. const apiVersion = "v1"
  69. const basePath = "https://iamcredentials.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.Projects = NewProjectsService(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. Projects *ProjectsService
  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 NewProjectsService(s *Service) *ProjectsService {
  121. rs := &ProjectsService{s: s}
  122. rs.ServiceAccounts = NewProjectsServiceAccountsService(s)
  123. return rs
  124. }
  125. type ProjectsService struct {
  126. s *Service
  127. ServiceAccounts *ProjectsServiceAccountsService
  128. }
  129. func NewProjectsServiceAccountsService(s *Service) *ProjectsServiceAccountsService {
  130. rs := &ProjectsServiceAccountsService{s: s}
  131. return rs
  132. }
  133. type ProjectsServiceAccountsService struct {
  134. s *Service
  135. }
  136. type GenerateAccessTokenRequest struct {
  137. // Delegates: The sequence of service accounts in a delegation chain.
  138. // Each service
  139. // account must be granted the `roles/iam.serviceAccountTokenCreator`
  140. // role
  141. // on its next service account in the chain. The last service account in
  142. // the
  143. // chain must be granted the `roles/iam.serviceAccountTokenCreator`
  144. // role
  145. // on the service account that is specified in the `name` field of
  146. // the
  147. // request.
  148. //
  149. // The delegates must have the following
  150. // format:
  151. // `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-`
  152. // wildcard
  153. // character is required; replacing it with a project ID is invalid.
  154. Delegates []string `json:"delegates,omitempty"`
  155. // Lifetime: The desired lifetime duration of the access token in
  156. // seconds.
  157. // Must be set to a value less than or equal to 3600 (1 hour). If a
  158. // value is
  159. // not specified, the token's lifetime will be set to a default value of
  160. // one
  161. // hour.
  162. Lifetime string `json:"lifetime,omitempty"`
  163. // Scope: Code to identify the scopes to be included in the OAuth 2.0
  164. // access token.
  165. // See https://developers.google.com/identity/protocols/googlescopes for
  166. // more
  167. // information.
  168. // At least one value required.
  169. Scope []string `json:"scope,omitempty"`
  170. // ForceSendFields is a list of field names (e.g. "Delegates") to
  171. // unconditionally include in API requests. By default, fields with
  172. // empty values are omitted from API requests. However, any non-pointer,
  173. // non-interface field appearing in ForceSendFields will be sent to the
  174. // server regardless of whether the field is empty or not. This may be
  175. // used to include empty fields in Patch requests.
  176. ForceSendFields []string `json:"-"`
  177. // NullFields is a list of field names (e.g. "Delegates") to include in
  178. // API requests with the JSON null value. By default, fields with empty
  179. // values are omitted from API requests. However, any field with an
  180. // empty value appearing in NullFields will be sent to the server as
  181. // null. It is an error if a field in this list has a non-empty value.
  182. // This may be used to include null fields in Patch requests.
  183. NullFields []string `json:"-"`
  184. }
  185. func (s *GenerateAccessTokenRequest) MarshalJSON() ([]byte, error) {
  186. type NoMethod GenerateAccessTokenRequest
  187. raw := NoMethod(*s)
  188. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  189. }
  190. type GenerateAccessTokenResponse struct {
  191. // AccessToken: The OAuth 2.0 access token.
  192. AccessToken string `json:"accessToken,omitempty"`
  193. // ExpireTime: Token expiration time.
  194. // The expiration time is always set.
  195. ExpireTime string `json:"expireTime,omitempty"`
  196. // ServerResponse contains the HTTP response code and headers from the
  197. // server.
  198. googleapi.ServerResponse `json:"-"`
  199. // ForceSendFields is a list of field names (e.g. "AccessToken") to
  200. // unconditionally include in API requests. By default, fields with
  201. // empty values are omitted from API requests. However, any non-pointer,
  202. // non-interface field appearing in ForceSendFields will be sent to the
  203. // server regardless of whether the field is empty or not. This may be
  204. // used to include empty fields in Patch requests.
  205. ForceSendFields []string `json:"-"`
  206. // NullFields is a list of field names (e.g. "AccessToken") to include
  207. // in API requests with the JSON null value. By default, fields with
  208. // empty values are omitted from API requests. However, any field with
  209. // an empty value appearing in NullFields will be sent to the server as
  210. // null. It is an error if a field in this list has a non-empty value.
  211. // This may be used to include null fields in Patch requests.
  212. NullFields []string `json:"-"`
  213. }
  214. func (s *GenerateAccessTokenResponse) MarshalJSON() ([]byte, error) {
  215. type NoMethod GenerateAccessTokenResponse
  216. raw := NoMethod(*s)
  217. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  218. }
  219. type GenerateIdTokenRequest struct {
  220. // Audience: The audience for the token, such as the API or account that
  221. // this token
  222. // grants access to.
  223. Audience string `json:"audience,omitempty"`
  224. // Delegates: The sequence of service accounts in a delegation chain.
  225. // Each service
  226. // account must be granted the `roles/iam.serviceAccountTokenCreator`
  227. // role
  228. // on its next service account in the chain. The last service account in
  229. // the
  230. // chain must be granted the `roles/iam.serviceAccountTokenCreator`
  231. // role
  232. // on the service account that is specified in the `name` field of
  233. // the
  234. // request.
  235. //
  236. // The delegates must have the following
  237. // format:
  238. // `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-`
  239. // wildcard
  240. // character is required; replacing it with a project ID is invalid.
  241. Delegates []string `json:"delegates,omitempty"`
  242. // IncludeEmail: Include the service account email in the token. If set
  243. // to `true`, the
  244. // token will contain `email` and `email_verified` claims.
  245. IncludeEmail bool `json:"includeEmail,omitempty"`
  246. // ForceSendFields is a list of field names (e.g. "Audience") to
  247. // unconditionally include in API requests. By default, fields with
  248. // empty values are omitted from API requests. However, any non-pointer,
  249. // non-interface field appearing in ForceSendFields will be sent to the
  250. // server regardless of whether the field is empty or not. This may be
  251. // used to include empty fields in Patch requests.
  252. ForceSendFields []string `json:"-"`
  253. // NullFields is a list of field names (e.g. "Audience") to include in
  254. // API requests with the JSON null value. By default, fields with empty
  255. // values are omitted from API requests. However, any field with an
  256. // empty value appearing in NullFields will be sent to the server as
  257. // null. It is an error if a field in this list has a non-empty value.
  258. // This may be used to include null fields in Patch requests.
  259. NullFields []string `json:"-"`
  260. }
  261. func (s *GenerateIdTokenRequest) MarshalJSON() ([]byte, error) {
  262. type NoMethod GenerateIdTokenRequest
  263. raw := NoMethod(*s)
  264. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  265. }
  266. type GenerateIdTokenResponse struct {
  267. // Token: The OpenId Connect ID token.
  268. Token string `json:"token,omitempty"`
  269. // ServerResponse contains the HTTP response code and headers from the
  270. // server.
  271. googleapi.ServerResponse `json:"-"`
  272. // ForceSendFields is a list of field names (e.g. "Token") to
  273. // unconditionally include in API requests. By default, fields with
  274. // empty values are omitted from API requests. However, any non-pointer,
  275. // non-interface field appearing in ForceSendFields will be sent to the
  276. // server regardless of whether the field is empty or not. This may be
  277. // used to include empty fields in Patch requests.
  278. ForceSendFields []string `json:"-"`
  279. // NullFields is a list of field names (e.g. "Token") to include in API
  280. // requests with the JSON null value. By default, fields with empty
  281. // values are omitted from API requests. However, any field with an
  282. // empty value appearing in NullFields will be sent to the server as
  283. // null. It is an error if a field in this list has a non-empty value.
  284. // This may be used to include null fields in Patch requests.
  285. NullFields []string `json:"-"`
  286. }
  287. func (s *GenerateIdTokenResponse) MarshalJSON() ([]byte, error) {
  288. type NoMethod GenerateIdTokenResponse
  289. raw := NoMethod(*s)
  290. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  291. }
  292. type GenerateIdentityBindingAccessTokenRequest struct {
  293. // Jwt: Required. Input token.
  294. // Must be in JWT format according to
  295. // RFC7523 (https://tools.ietf.org/html/rfc7523)
  296. // and must have 'kid' field in the header.
  297. // Supported signing algorithms: RS256 (RS512, ES256, ES512 coming
  298. // soon).
  299. // Mandatory payload fields (along the lines of RFC 7523, section 3):
  300. // - iss: issuer of the token. Must provide a discovery document at
  301. // $iss/.well-known/openid-configuration . The document needs to
  302. // be
  303. // formatted according to section 4.2 of the OpenID Connect
  304. // Discovery
  305. // 1.0 specification.
  306. // - iat: Issue time in seconds since epoch. Must be in the past.
  307. // - exp: Expiration time in seconds since epoch. Must be less than 48
  308. // hours
  309. // after iat. We recommend to create tokens that last shorter
  310. // than 6
  311. // hours to improve security unless business reasons mandate
  312. // longer
  313. // expiration times. Shorter token lifetimes are generally more
  314. // secure
  315. // since tokens that have been exfiltrated by attackers can be
  316. // used for
  317. // a shorter time. you can configure the maximum lifetime of the
  318. // incoming token in the configuration of the mapper.
  319. // The resulting Google token will expire within an hour or at
  320. // "exp",
  321. // whichever is earlier.
  322. // - sub: JWT subject, identity asserted in the JWT.
  323. // - aud: Configured in the mapper policy. By default the service
  324. // account
  325. // email.
  326. //
  327. // Claims from the incoming token can be transferred into the output
  328. // token
  329. // accoding to the mapper configuration. The outgoing claim size is
  330. // limited.
  331. // Outgoing claims size must be less than 4kB serialized as JSON
  332. // without
  333. // whitespace.
  334. //
  335. // Example header:
  336. // {
  337. // "alg": "RS256",
  338. // "kid": "92a4265e14ab04d4d228a48d10d4ca31610936f8"
  339. // }
  340. // Example payload:
  341. // {
  342. // "iss": "https://accounts.google.com",
  343. // "iat": 1517963104,
  344. // "exp": 1517966704,
  345. // "aud":
  346. //
  347. // "https://iamcredentials.googleapis.com/google.iam.credentials.v1.Cloud
  348. // Gaia",
  349. // "sub": "113475438248934895348",
  350. // "my_claims": {
  351. // "additional_claim": "value"
  352. // }
  353. // }
  354. Jwt string `json:"jwt,omitempty"`
  355. // Scope: Code to identify the scopes to be included in the OAuth 2.0
  356. // access token.
  357. // See https://developers.google.com/identity/protocols/googlescopes for
  358. // more
  359. // information.
  360. // At least one value required.
  361. Scope []string `json:"scope,omitempty"`
  362. // ForceSendFields is a list of field names (e.g. "Jwt") to
  363. // unconditionally include in API requests. By default, fields with
  364. // empty values are omitted from API requests. However, any non-pointer,
  365. // non-interface field appearing in ForceSendFields will be sent to the
  366. // server regardless of whether the field is empty or not. This may be
  367. // used to include empty fields in Patch requests.
  368. ForceSendFields []string `json:"-"`
  369. // NullFields is a list of field names (e.g. "Jwt") to include in API
  370. // requests with the JSON null value. By default, fields with empty
  371. // values are omitted from API requests. However, any field with an
  372. // empty value appearing in NullFields will be sent to the server as
  373. // null. It is an error if a field in this list has a non-empty value.
  374. // This may be used to include null fields in Patch requests.
  375. NullFields []string `json:"-"`
  376. }
  377. func (s *GenerateIdentityBindingAccessTokenRequest) MarshalJSON() ([]byte, error) {
  378. type NoMethod GenerateIdentityBindingAccessTokenRequest
  379. raw := NoMethod(*s)
  380. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  381. }
  382. type GenerateIdentityBindingAccessTokenResponse struct {
  383. // AccessToken: The OAuth 2.0 access token.
  384. AccessToken string `json:"accessToken,omitempty"`
  385. // ExpireTime: Token expiration time.
  386. // The expiration time is always set.
  387. ExpireTime string `json:"expireTime,omitempty"`
  388. // ServerResponse contains the HTTP response code and headers from the
  389. // server.
  390. googleapi.ServerResponse `json:"-"`
  391. // ForceSendFields is a list of field names (e.g. "AccessToken") to
  392. // unconditionally include in API requests. By default, fields with
  393. // empty values are omitted from API requests. However, any non-pointer,
  394. // non-interface field appearing in ForceSendFields will be sent to the
  395. // server regardless of whether the field is empty or not. This may be
  396. // used to include empty fields in Patch requests.
  397. ForceSendFields []string `json:"-"`
  398. // NullFields is a list of field names (e.g. "AccessToken") to include
  399. // in API requests with the JSON null value. By default, fields with
  400. // empty values are omitted from API requests. However, any field with
  401. // an empty value appearing in NullFields will be sent to the server as
  402. // null. It is an error if a field in this list has a non-empty value.
  403. // This may be used to include null fields in Patch requests.
  404. NullFields []string `json:"-"`
  405. }
  406. func (s *GenerateIdentityBindingAccessTokenResponse) MarshalJSON() ([]byte, error) {
  407. type NoMethod GenerateIdentityBindingAccessTokenResponse
  408. raw := NoMethod(*s)
  409. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  410. }
  411. type SignBlobRequest struct {
  412. // Delegates: The sequence of service accounts in a delegation chain.
  413. // Each service
  414. // account must be granted the `roles/iam.serviceAccountTokenCreator`
  415. // role
  416. // on its next service account in the chain. The last service account in
  417. // the
  418. // chain must be granted the `roles/iam.serviceAccountTokenCreator`
  419. // role
  420. // on the service account that is specified in the `name` field of
  421. // the
  422. // request.
  423. //
  424. // The delegates must have the following
  425. // format:
  426. // `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-`
  427. // wildcard
  428. // character is required; replacing it with a project ID is invalid.
  429. Delegates []string `json:"delegates,omitempty"`
  430. // Payload: The bytes to sign.
  431. Payload string `json:"payload,omitempty"`
  432. // ForceSendFields is a list of field names (e.g. "Delegates") to
  433. // unconditionally include in API requests. By default, fields with
  434. // empty values are omitted from API requests. However, any non-pointer,
  435. // non-interface field appearing in ForceSendFields will be sent to the
  436. // server regardless of whether the field is empty or not. This may be
  437. // used to include empty fields in Patch requests.
  438. ForceSendFields []string `json:"-"`
  439. // NullFields is a list of field names (e.g. "Delegates") to include in
  440. // API requests with the JSON null value. By default, fields with empty
  441. // values are omitted from API requests. However, any field with an
  442. // empty value appearing in NullFields will be sent to the server as
  443. // null. It is an error if a field in this list has a non-empty value.
  444. // This may be used to include null fields in Patch requests.
  445. NullFields []string `json:"-"`
  446. }
  447. func (s *SignBlobRequest) MarshalJSON() ([]byte, error) {
  448. type NoMethod SignBlobRequest
  449. raw := NoMethod(*s)
  450. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  451. }
  452. type SignBlobResponse struct {
  453. // KeyId: The ID of the key used to sign the blob.
  454. KeyId string `json:"keyId,omitempty"`
  455. // SignedBlob: The signed blob.
  456. SignedBlob string `json:"signedBlob,omitempty"`
  457. // ServerResponse contains the HTTP response code and headers from the
  458. // server.
  459. googleapi.ServerResponse `json:"-"`
  460. // ForceSendFields is a list of field names (e.g. "KeyId") to
  461. // unconditionally include in API requests. By default, fields with
  462. // empty values are omitted from API requests. However, any non-pointer,
  463. // non-interface field appearing in ForceSendFields will be sent to the
  464. // server regardless of whether the field is empty or not. This may be
  465. // used to include empty fields in Patch requests.
  466. ForceSendFields []string `json:"-"`
  467. // NullFields is a list of field names (e.g. "KeyId") to include in API
  468. // requests with the JSON null value. By default, fields with empty
  469. // values are omitted from API requests. However, any field with an
  470. // empty value appearing in NullFields will be sent to the server as
  471. // null. It is an error if a field in this list has a non-empty value.
  472. // This may be used to include null fields in Patch requests.
  473. NullFields []string `json:"-"`
  474. }
  475. func (s *SignBlobResponse) MarshalJSON() ([]byte, error) {
  476. type NoMethod SignBlobResponse
  477. raw := NoMethod(*s)
  478. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  479. }
  480. type SignJwtRequest struct {
  481. // Delegates: The sequence of service accounts in a delegation chain.
  482. // Each service
  483. // account must be granted the `roles/iam.serviceAccountTokenCreator`
  484. // role
  485. // on its next service account in the chain. The last service account in
  486. // the
  487. // chain must be granted the `roles/iam.serviceAccountTokenCreator`
  488. // role
  489. // on the service account that is specified in the `name` field of
  490. // the
  491. // request.
  492. //
  493. // The delegates must have the following
  494. // format:
  495. // `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-`
  496. // wildcard
  497. // character is required; replacing it with a project ID is invalid.
  498. Delegates []string `json:"delegates,omitempty"`
  499. // Payload: The JWT payload to sign: a JSON object that contains a JWT
  500. // Claims Set.
  501. Payload string `json:"payload,omitempty"`
  502. // ForceSendFields is a list of field names (e.g. "Delegates") to
  503. // unconditionally include in API requests. By default, fields with
  504. // empty values are omitted from API requests. However, any non-pointer,
  505. // non-interface field appearing in ForceSendFields will be sent to the
  506. // server regardless of whether the field is empty or not. This may be
  507. // used to include empty fields in Patch requests.
  508. ForceSendFields []string `json:"-"`
  509. // NullFields is a list of field names (e.g. "Delegates") to include in
  510. // API requests with the JSON null value. By default, fields with empty
  511. // values are omitted from API requests. However, any field with an
  512. // empty value appearing in NullFields will be sent to the server as
  513. // null. It is an error if a field in this list has a non-empty value.
  514. // This may be used to include null fields in Patch requests.
  515. NullFields []string `json:"-"`
  516. }
  517. func (s *SignJwtRequest) MarshalJSON() ([]byte, error) {
  518. type NoMethod SignJwtRequest
  519. raw := NoMethod(*s)
  520. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  521. }
  522. type SignJwtResponse struct {
  523. // KeyId: The ID of the key used to sign the JWT.
  524. KeyId string `json:"keyId,omitempty"`
  525. // SignedJwt: The signed JWT.
  526. SignedJwt string `json:"signedJwt,omitempty"`
  527. // ServerResponse contains the HTTP response code and headers from the
  528. // server.
  529. googleapi.ServerResponse `json:"-"`
  530. // ForceSendFields is a list of field names (e.g. "KeyId") to
  531. // unconditionally include in API requests. By default, fields with
  532. // empty values are omitted from API requests. However, any non-pointer,
  533. // non-interface field appearing in ForceSendFields will be sent to the
  534. // server regardless of whether the field is empty or not. This may be
  535. // used to include empty fields in Patch requests.
  536. ForceSendFields []string `json:"-"`
  537. // NullFields is a list of field names (e.g. "KeyId") to include in API
  538. // requests with the JSON null value. By default, fields with empty
  539. // values are omitted from API requests. However, any field with an
  540. // empty value appearing in NullFields will be sent to the server as
  541. // null. It is an error if a field in this list has a non-empty value.
  542. // This may be used to include null fields in Patch requests.
  543. NullFields []string `json:"-"`
  544. }
  545. func (s *SignJwtResponse) MarshalJSON() ([]byte, error) {
  546. type NoMethod SignJwtResponse
  547. raw := NoMethod(*s)
  548. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  549. }
  550. // method id "iamcredentials.projects.serviceAccounts.generateAccessToken":
  551. type ProjectsServiceAccountsGenerateAccessTokenCall struct {
  552. s *Service
  553. name string
  554. generateaccesstokenrequest *GenerateAccessTokenRequest
  555. urlParams_ gensupport.URLParams
  556. ctx_ context.Context
  557. header_ http.Header
  558. }
  559. // GenerateAccessToken: Generates an OAuth 2.0 access token for a
  560. // service account.
  561. func (r *ProjectsServiceAccountsService) GenerateAccessToken(name string, generateaccesstokenrequest *GenerateAccessTokenRequest) *ProjectsServiceAccountsGenerateAccessTokenCall {
  562. c := &ProjectsServiceAccountsGenerateAccessTokenCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  563. c.name = name
  564. c.generateaccesstokenrequest = generateaccesstokenrequest
  565. return c
  566. }
  567. // Fields allows partial responses to be retrieved. See
  568. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  569. // for more information.
  570. func (c *ProjectsServiceAccountsGenerateAccessTokenCall) Fields(s ...googleapi.Field) *ProjectsServiceAccountsGenerateAccessTokenCall {
  571. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  572. return c
  573. }
  574. // Context sets the context to be used in this call's Do method. Any
  575. // pending HTTP request will be aborted if the provided context is
  576. // canceled.
  577. func (c *ProjectsServiceAccountsGenerateAccessTokenCall) Context(ctx context.Context) *ProjectsServiceAccountsGenerateAccessTokenCall {
  578. c.ctx_ = ctx
  579. return c
  580. }
  581. // Header returns an http.Header that can be modified by the caller to
  582. // add HTTP headers to the request.
  583. func (c *ProjectsServiceAccountsGenerateAccessTokenCall) Header() http.Header {
  584. if c.header_ == nil {
  585. c.header_ = make(http.Header)
  586. }
  587. return c.header_
  588. }
  589. func (c *ProjectsServiceAccountsGenerateAccessTokenCall) doRequest(alt string) (*http.Response, error) {
  590. reqHeaders := make(http.Header)
  591. for k, v := range c.header_ {
  592. reqHeaders[k] = v
  593. }
  594. reqHeaders.Set("User-Agent", c.s.userAgent())
  595. var body io.Reader = nil
  596. body, err := googleapi.WithoutDataWrapper.JSONReader(c.generateaccesstokenrequest)
  597. if err != nil {
  598. return nil, err
  599. }
  600. reqHeaders.Set("Content-Type", "application/json")
  601. c.urlParams_.Set("alt", alt)
  602. c.urlParams_.Set("prettyPrint", "false")
  603. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:generateAccessToken")
  604. urls += "?" + c.urlParams_.Encode()
  605. req, err := http.NewRequest("POST", urls, body)
  606. if err != nil {
  607. return nil, err
  608. }
  609. req.Header = reqHeaders
  610. googleapi.Expand(req.URL, map[string]string{
  611. "name": c.name,
  612. })
  613. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  614. }
  615. // Do executes the "iamcredentials.projects.serviceAccounts.generateAccessToken" call.
  616. // Exactly one of *GenerateAccessTokenResponse or error will be non-nil.
  617. // Any non-2xx status code is an error. Response headers are in either
  618. // *GenerateAccessTokenResponse.ServerResponse.Header or (if a response
  619. // was returned at all) in error.(*googleapi.Error).Header. Use
  620. // googleapi.IsNotModified to check whether the returned error was
  621. // because http.StatusNotModified was returned.
  622. func (c *ProjectsServiceAccountsGenerateAccessTokenCall) Do(opts ...googleapi.CallOption) (*GenerateAccessTokenResponse, error) {
  623. gensupport.SetOptions(c.urlParams_, opts...)
  624. res, err := c.doRequest("json")
  625. if res != nil && res.StatusCode == http.StatusNotModified {
  626. if res.Body != nil {
  627. res.Body.Close()
  628. }
  629. return nil, &googleapi.Error{
  630. Code: res.StatusCode,
  631. Header: res.Header,
  632. }
  633. }
  634. if err != nil {
  635. return nil, err
  636. }
  637. defer googleapi.CloseBody(res)
  638. if err := googleapi.CheckResponse(res); err != nil {
  639. return nil, err
  640. }
  641. ret := &GenerateAccessTokenResponse{
  642. ServerResponse: googleapi.ServerResponse{
  643. Header: res.Header,
  644. HTTPStatusCode: res.StatusCode,
  645. },
  646. }
  647. target := &ret
  648. if err := gensupport.DecodeResponse(target, res); err != nil {
  649. return nil, err
  650. }
  651. return ret, nil
  652. // {
  653. // "description": "Generates an OAuth 2.0 access token for a service account.",
  654. // "flatPath": "v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}:generateAccessToken",
  655. // "httpMethod": "POST",
  656. // "id": "iamcredentials.projects.serviceAccounts.generateAccessToken",
  657. // "parameterOrder": [
  658. // "name"
  659. // ],
  660. // "parameters": {
  661. // "name": {
  662. // "description": "The resource name of the service account for which the credentials\nare requested, in the following format:\n`projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard\ncharacter is required; replacing it with a project ID is invalid.",
  663. // "location": "path",
  664. // "pattern": "^projects/[^/]+/serviceAccounts/[^/]+$",
  665. // "required": true,
  666. // "type": "string"
  667. // }
  668. // },
  669. // "path": "v1/{+name}:generateAccessToken",
  670. // "request": {
  671. // "$ref": "GenerateAccessTokenRequest"
  672. // },
  673. // "response": {
  674. // "$ref": "GenerateAccessTokenResponse"
  675. // },
  676. // "scopes": [
  677. // "https://www.googleapis.com/auth/cloud-platform"
  678. // ]
  679. // }
  680. }
  681. // method id "iamcredentials.projects.serviceAccounts.generateIdToken":
  682. type ProjectsServiceAccountsGenerateIdTokenCall struct {
  683. s *Service
  684. name string
  685. generateidtokenrequest *GenerateIdTokenRequest
  686. urlParams_ gensupport.URLParams
  687. ctx_ context.Context
  688. header_ http.Header
  689. }
  690. // GenerateIdToken: Generates an OpenID Connect ID token for a service
  691. // account.
  692. func (r *ProjectsServiceAccountsService) GenerateIdToken(name string, generateidtokenrequest *GenerateIdTokenRequest) *ProjectsServiceAccountsGenerateIdTokenCall {
  693. c := &ProjectsServiceAccountsGenerateIdTokenCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  694. c.name = name
  695. c.generateidtokenrequest = generateidtokenrequest
  696. return c
  697. }
  698. // Fields allows partial responses to be retrieved. See
  699. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  700. // for more information.
  701. func (c *ProjectsServiceAccountsGenerateIdTokenCall) Fields(s ...googleapi.Field) *ProjectsServiceAccountsGenerateIdTokenCall {
  702. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  703. return c
  704. }
  705. // Context sets the context to be used in this call's Do method. Any
  706. // pending HTTP request will be aborted if the provided context is
  707. // canceled.
  708. func (c *ProjectsServiceAccountsGenerateIdTokenCall) Context(ctx context.Context) *ProjectsServiceAccountsGenerateIdTokenCall {
  709. c.ctx_ = ctx
  710. return c
  711. }
  712. // Header returns an http.Header that can be modified by the caller to
  713. // add HTTP headers to the request.
  714. func (c *ProjectsServiceAccountsGenerateIdTokenCall) Header() http.Header {
  715. if c.header_ == nil {
  716. c.header_ = make(http.Header)
  717. }
  718. return c.header_
  719. }
  720. func (c *ProjectsServiceAccountsGenerateIdTokenCall) doRequest(alt string) (*http.Response, error) {
  721. reqHeaders := make(http.Header)
  722. for k, v := range c.header_ {
  723. reqHeaders[k] = v
  724. }
  725. reqHeaders.Set("User-Agent", c.s.userAgent())
  726. var body io.Reader = nil
  727. body, err := googleapi.WithoutDataWrapper.JSONReader(c.generateidtokenrequest)
  728. if err != nil {
  729. return nil, err
  730. }
  731. reqHeaders.Set("Content-Type", "application/json")
  732. c.urlParams_.Set("alt", alt)
  733. c.urlParams_.Set("prettyPrint", "false")
  734. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:generateIdToken")
  735. urls += "?" + c.urlParams_.Encode()
  736. req, err := http.NewRequest("POST", urls, body)
  737. if err != nil {
  738. return nil, err
  739. }
  740. req.Header = reqHeaders
  741. googleapi.Expand(req.URL, map[string]string{
  742. "name": c.name,
  743. })
  744. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  745. }
  746. // Do executes the "iamcredentials.projects.serviceAccounts.generateIdToken" call.
  747. // Exactly one of *GenerateIdTokenResponse or error will be non-nil. Any
  748. // non-2xx status code is an error. Response headers are in either
  749. // *GenerateIdTokenResponse.ServerResponse.Header or (if a response was
  750. // returned at all) in error.(*googleapi.Error).Header. Use
  751. // googleapi.IsNotModified to check whether the returned error was
  752. // because http.StatusNotModified was returned.
  753. func (c *ProjectsServiceAccountsGenerateIdTokenCall) Do(opts ...googleapi.CallOption) (*GenerateIdTokenResponse, error) {
  754. gensupport.SetOptions(c.urlParams_, opts...)
  755. res, err := c.doRequest("json")
  756. if res != nil && res.StatusCode == http.StatusNotModified {
  757. if res.Body != nil {
  758. res.Body.Close()
  759. }
  760. return nil, &googleapi.Error{
  761. Code: res.StatusCode,
  762. Header: res.Header,
  763. }
  764. }
  765. if err != nil {
  766. return nil, err
  767. }
  768. defer googleapi.CloseBody(res)
  769. if err := googleapi.CheckResponse(res); err != nil {
  770. return nil, err
  771. }
  772. ret := &GenerateIdTokenResponse{
  773. ServerResponse: googleapi.ServerResponse{
  774. Header: res.Header,
  775. HTTPStatusCode: res.StatusCode,
  776. },
  777. }
  778. target := &ret
  779. if err := gensupport.DecodeResponse(target, res); err != nil {
  780. return nil, err
  781. }
  782. return ret, nil
  783. // {
  784. // "description": "Generates an OpenID Connect ID token for a service account.",
  785. // "flatPath": "v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}:generateIdToken",
  786. // "httpMethod": "POST",
  787. // "id": "iamcredentials.projects.serviceAccounts.generateIdToken",
  788. // "parameterOrder": [
  789. // "name"
  790. // ],
  791. // "parameters": {
  792. // "name": {
  793. // "description": "The resource name of the service account for which the credentials\nare requested, in the following format:\n`projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard\ncharacter is required; replacing it with a project ID is invalid.",
  794. // "location": "path",
  795. // "pattern": "^projects/[^/]+/serviceAccounts/[^/]+$",
  796. // "required": true,
  797. // "type": "string"
  798. // }
  799. // },
  800. // "path": "v1/{+name}:generateIdToken",
  801. // "request": {
  802. // "$ref": "GenerateIdTokenRequest"
  803. // },
  804. // "response": {
  805. // "$ref": "GenerateIdTokenResponse"
  806. // },
  807. // "scopes": [
  808. // "https://www.googleapis.com/auth/cloud-platform"
  809. // ]
  810. // }
  811. }
  812. // method id "iamcredentials.projects.serviceAccounts.generateIdentityBindingAccessToken":
  813. type ProjectsServiceAccountsGenerateIdentityBindingAccessTokenCall struct {
  814. s *Service
  815. name string
  816. generateidentitybindingaccesstokenrequest *GenerateIdentityBindingAccessTokenRequest
  817. urlParams_ gensupport.URLParams
  818. ctx_ context.Context
  819. header_ http.Header
  820. }
  821. // GenerateIdentityBindingAccessToken:
  822. func (r *ProjectsServiceAccountsService) GenerateIdentityBindingAccessToken(name string, generateidentitybindingaccesstokenrequest *GenerateIdentityBindingAccessTokenRequest) *ProjectsServiceAccountsGenerateIdentityBindingAccessTokenCall {
  823. c := &ProjectsServiceAccountsGenerateIdentityBindingAccessTokenCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  824. c.name = name
  825. c.generateidentitybindingaccesstokenrequest = generateidentitybindingaccesstokenrequest
  826. return c
  827. }
  828. // Fields allows partial responses to be retrieved. See
  829. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  830. // for more information.
  831. func (c *ProjectsServiceAccountsGenerateIdentityBindingAccessTokenCall) Fields(s ...googleapi.Field) *ProjectsServiceAccountsGenerateIdentityBindingAccessTokenCall {
  832. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  833. return c
  834. }
  835. // Context sets the context to be used in this call's Do method. Any
  836. // pending HTTP request will be aborted if the provided context is
  837. // canceled.
  838. func (c *ProjectsServiceAccountsGenerateIdentityBindingAccessTokenCall) Context(ctx context.Context) *ProjectsServiceAccountsGenerateIdentityBindingAccessTokenCall {
  839. c.ctx_ = ctx
  840. return c
  841. }
  842. // Header returns an http.Header that can be modified by the caller to
  843. // add HTTP headers to the request.
  844. func (c *ProjectsServiceAccountsGenerateIdentityBindingAccessTokenCall) Header() http.Header {
  845. if c.header_ == nil {
  846. c.header_ = make(http.Header)
  847. }
  848. return c.header_
  849. }
  850. func (c *ProjectsServiceAccountsGenerateIdentityBindingAccessTokenCall) doRequest(alt string) (*http.Response, error) {
  851. reqHeaders := make(http.Header)
  852. for k, v := range c.header_ {
  853. reqHeaders[k] = v
  854. }
  855. reqHeaders.Set("User-Agent", c.s.userAgent())
  856. var body io.Reader = nil
  857. body, err := googleapi.WithoutDataWrapper.JSONReader(c.generateidentitybindingaccesstokenrequest)
  858. if err != nil {
  859. return nil, err
  860. }
  861. reqHeaders.Set("Content-Type", "application/json")
  862. c.urlParams_.Set("alt", alt)
  863. c.urlParams_.Set("prettyPrint", "false")
  864. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:generateIdentityBindingAccessToken")
  865. urls += "?" + c.urlParams_.Encode()
  866. req, err := http.NewRequest("POST", urls, body)
  867. if err != nil {
  868. return nil, err
  869. }
  870. req.Header = reqHeaders
  871. googleapi.Expand(req.URL, map[string]string{
  872. "name": c.name,
  873. })
  874. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  875. }
  876. // Do executes the "iamcredentials.projects.serviceAccounts.generateIdentityBindingAccessToken" call.
  877. // Exactly one of *GenerateIdentityBindingAccessTokenResponse or error
  878. // will be non-nil. Any non-2xx status code is an error. Response
  879. // headers are in either
  880. // *GenerateIdentityBindingAccessTokenResponse.ServerResponse.Header or
  881. // (if a response was returned at all) in
  882. // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  883. // whether the returned error was because http.StatusNotModified was
  884. // returned.
  885. func (c *ProjectsServiceAccountsGenerateIdentityBindingAccessTokenCall) Do(opts ...googleapi.CallOption) (*GenerateIdentityBindingAccessTokenResponse, error) {
  886. gensupport.SetOptions(c.urlParams_, opts...)
  887. res, err := c.doRequest("json")
  888. if res != nil && res.StatusCode == http.StatusNotModified {
  889. if res.Body != nil {
  890. res.Body.Close()
  891. }
  892. return nil, &googleapi.Error{
  893. Code: res.StatusCode,
  894. Header: res.Header,
  895. }
  896. }
  897. if err != nil {
  898. return nil, err
  899. }
  900. defer googleapi.CloseBody(res)
  901. if err := googleapi.CheckResponse(res); err != nil {
  902. return nil, err
  903. }
  904. ret := &GenerateIdentityBindingAccessTokenResponse{
  905. ServerResponse: googleapi.ServerResponse{
  906. Header: res.Header,
  907. HTTPStatusCode: res.StatusCode,
  908. },
  909. }
  910. target := &ret
  911. if err := gensupport.DecodeResponse(target, res); err != nil {
  912. return nil, err
  913. }
  914. return ret, nil
  915. // {
  916. // "description": "",
  917. // "flatPath": "v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}:generateIdentityBindingAccessToken",
  918. // "httpMethod": "POST",
  919. // "id": "iamcredentials.projects.serviceAccounts.generateIdentityBindingAccessToken",
  920. // "parameterOrder": [
  921. // "name"
  922. // ],
  923. // "parameters": {
  924. // "name": {
  925. // "description": "The resource name of the service account for which the credentials\nare requested, in the following format:\n`projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard\ncharacter is required; replacing it with a project ID is invalid.",
  926. // "location": "path",
  927. // "pattern": "^projects/[^/]+/serviceAccounts/[^/]+$",
  928. // "required": true,
  929. // "type": "string"
  930. // }
  931. // },
  932. // "path": "v1/{+name}:generateIdentityBindingAccessToken",
  933. // "request": {
  934. // "$ref": "GenerateIdentityBindingAccessTokenRequest"
  935. // },
  936. // "response": {
  937. // "$ref": "GenerateIdentityBindingAccessTokenResponse"
  938. // }
  939. // }
  940. }
  941. // method id "iamcredentials.projects.serviceAccounts.signBlob":
  942. type ProjectsServiceAccountsSignBlobCall struct {
  943. s *Service
  944. name string
  945. signblobrequest *SignBlobRequest
  946. urlParams_ gensupport.URLParams
  947. ctx_ context.Context
  948. header_ http.Header
  949. }
  950. // SignBlob: Signs a blob using a service account's system-managed
  951. // private key.
  952. func (r *ProjectsServiceAccountsService) SignBlob(name string, signblobrequest *SignBlobRequest) *ProjectsServiceAccountsSignBlobCall {
  953. c := &ProjectsServiceAccountsSignBlobCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  954. c.name = name
  955. c.signblobrequest = signblobrequest
  956. return c
  957. }
  958. // Fields allows partial responses to be retrieved. See
  959. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  960. // for more information.
  961. func (c *ProjectsServiceAccountsSignBlobCall) Fields(s ...googleapi.Field) *ProjectsServiceAccountsSignBlobCall {
  962. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  963. return c
  964. }
  965. // Context sets the context to be used in this call's Do method. Any
  966. // pending HTTP request will be aborted if the provided context is
  967. // canceled.
  968. func (c *ProjectsServiceAccountsSignBlobCall) Context(ctx context.Context) *ProjectsServiceAccountsSignBlobCall {
  969. c.ctx_ = ctx
  970. return c
  971. }
  972. // Header returns an http.Header that can be modified by the caller to
  973. // add HTTP headers to the request.
  974. func (c *ProjectsServiceAccountsSignBlobCall) Header() http.Header {
  975. if c.header_ == nil {
  976. c.header_ = make(http.Header)
  977. }
  978. return c.header_
  979. }
  980. func (c *ProjectsServiceAccountsSignBlobCall) doRequest(alt string) (*http.Response, error) {
  981. reqHeaders := make(http.Header)
  982. for k, v := range c.header_ {
  983. reqHeaders[k] = v
  984. }
  985. reqHeaders.Set("User-Agent", c.s.userAgent())
  986. var body io.Reader = nil
  987. body, err := googleapi.WithoutDataWrapper.JSONReader(c.signblobrequest)
  988. if err != nil {
  989. return nil, err
  990. }
  991. reqHeaders.Set("Content-Type", "application/json")
  992. c.urlParams_.Set("alt", alt)
  993. c.urlParams_.Set("prettyPrint", "false")
  994. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:signBlob")
  995. urls += "?" + c.urlParams_.Encode()
  996. req, err := http.NewRequest("POST", urls, body)
  997. if err != nil {
  998. return nil, err
  999. }
  1000. req.Header = reqHeaders
  1001. googleapi.Expand(req.URL, map[string]string{
  1002. "name": c.name,
  1003. })
  1004. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1005. }
  1006. // Do executes the "iamcredentials.projects.serviceAccounts.signBlob" call.
  1007. // Exactly one of *SignBlobResponse or error will be non-nil. Any
  1008. // non-2xx status code is an error. Response headers are in either
  1009. // *SignBlobResponse.ServerResponse.Header or (if a response was
  1010. // returned at all) in error.(*googleapi.Error).Header. Use
  1011. // googleapi.IsNotModified to check whether the returned error was
  1012. // because http.StatusNotModified was returned.
  1013. func (c *ProjectsServiceAccountsSignBlobCall) Do(opts ...googleapi.CallOption) (*SignBlobResponse, error) {
  1014. gensupport.SetOptions(c.urlParams_, opts...)
  1015. res, err := c.doRequest("json")
  1016. if res != nil && res.StatusCode == http.StatusNotModified {
  1017. if res.Body != nil {
  1018. res.Body.Close()
  1019. }
  1020. return nil, &googleapi.Error{
  1021. Code: res.StatusCode,
  1022. Header: res.Header,
  1023. }
  1024. }
  1025. if err != nil {
  1026. return nil, err
  1027. }
  1028. defer googleapi.CloseBody(res)
  1029. if err := googleapi.CheckResponse(res); err != nil {
  1030. return nil, err
  1031. }
  1032. ret := &SignBlobResponse{
  1033. ServerResponse: googleapi.ServerResponse{
  1034. Header: res.Header,
  1035. HTTPStatusCode: res.StatusCode,
  1036. },
  1037. }
  1038. target := &ret
  1039. if err := gensupport.DecodeResponse(target, res); err != nil {
  1040. return nil, err
  1041. }
  1042. return ret, nil
  1043. // {
  1044. // "description": "Signs a blob using a service account's system-managed private key.",
  1045. // "flatPath": "v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}:signBlob",
  1046. // "httpMethod": "POST",
  1047. // "id": "iamcredentials.projects.serviceAccounts.signBlob",
  1048. // "parameterOrder": [
  1049. // "name"
  1050. // ],
  1051. // "parameters": {
  1052. // "name": {
  1053. // "description": "The resource name of the service account for which the credentials\nare requested, in the following format:\n`projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard\ncharacter is required; replacing it with a project ID is invalid.",
  1054. // "location": "path",
  1055. // "pattern": "^projects/[^/]+/serviceAccounts/[^/]+$",
  1056. // "required": true,
  1057. // "type": "string"
  1058. // }
  1059. // },
  1060. // "path": "v1/{+name}:signBlob",
  1061. // "request": {
  1062. // "$ref": "SignBlobRequest"
  1063. // },
  1064. // "response": {
  1065. // "$ref": "SignBlobResponse"
  1066. // },
  1067. // "scopes": [
  1068. // "https://www.googleapis.com/auth/cloud-platform"
  1069. // ]
  1070. // }
  1071. }
  1072. // method id "iamcredentials.projects.serviceAccounts.signJwt":
  1073. type ProjectsServiceAccountsSignJwtCall struct {
  1074. s *Service
  1075. name string
  1076. signjwtrequest *SignJwtRequest
  1077. urlParams_ gensupport.URLParams
  1078. ctx_ context.Context
  1079. header_ http.Header
  1080. }
  1081. // SignJwt: Signs a JWT using a service account's system-managed private
  1082. // key.
  1083. func (r *ProjectsServiceAccountsService) SignJwt(name string, signjwtrequest *SignJwtRequest) *ProjectsServiceAccountsSignJwtCall {
  1084. c := &ProjectsServiceAccountsSignJwtCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1085. c.name = name
  1086. c.signjwtrequest = signjwtrequest
  1087. return c
  1088. }
  1089. // Fields allows partial responses to be retrieved. See
  1090. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1091. // for more information.
  1092. func (c *ProjectsServiceAccountsSignJwtCall) Fields(s ...googleapi.Field) *ProjectsServiceAccountsSignJwtCall {
  1093. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1094. return c
  1095. }
  1096. // Context sets the context to be used in this call's Do method. Any
  1097. // pending HTTP request will be aborted if the provided context is
  1098. // canceled.
  1099. func (c *ProjectsServiceAccountsSignJwtCall) Context(ctx context.Context) *ProjectsServiceAccountsSignJwtCall {
  1100. c.ctx_ = ctx
  1101. return c
  1102. }
  1103. // Header returns an http.Header that can be modified by the caller to
  1104. // add HTTP headers to the request.
  1105. func (c *ProjectsServiceAccountsSignJwtCall) Header() http.Header {
  1106. if c.header_ == nil {
  1107. c.header_ = make(http.Header)
  1108. }
  1109. return c.header_
  1110. }
  1111. func (c *ProjectsServiceAccountsSignJwtCall) doRequest(alt string) (*http.Response, error) {
  1112. reqHeaders := make(http.Header)
  1113. for k, v := range c.header_ {
  1114. reqHeaders[k] = v
  1115. }
  1116. reqHeaders.Set("User-Agent", c.s.userAgent())
  1117. var body io.Reader = nil
  1118. body, err := googleapi.WithoutDataWrapper.JSONReader(c.signjwtrequest)
  1119. if err != nil {
  1120. return nil, err
  1121. }
  1122. reqHeaders.Set("Content-Type", "application/json")
  1123. c.urlParams_.Set("alt", alt)
  1124. c.urlParams_.Set("prettyPrint", "false")
  1125. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:signJwt")
  1126. urls += "?" + c.urlParams_.Encode()
  1127. req, err := http.NewRequest("POST", urls, body)
  1128. if err != nil {
  1129. return nil, err
  1130. }
  1131. req.Header = reqHeaders
  1132. googleapi.Expand(req.URL, map[string]string{
  1133. "name": c.name,
  1134. })
  1135. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1136. }
  1137. // Do executes the "iamcredentials.projects.serviceAccounts.signJwt" call.
  1138. // Exactly one of *SignJwtResponse or error will be non-nil. Any non-2xx
  1139. // status code is an error. Response headers are in either
  1140. // *SignJwtResponse.ServerResponse.Header or (if a response was returned
  1141. // at all) in error.(*googleapi.Error).Header. Use
  1142. // googleapi.IsNotModified to check whether the returned error was
  1143. // because http.StatusNotModified was returned.
  1144. func (c *ProjectsServiceAccountsSignJwtCall) Do(opts ...googleapi.CallOption) (*SignJwtResponse, error) {
  1145. gensupport.SetOptions(c.urlParams_, opts...)
  1146. res, err := c.doRequest("json")
  1147. if res != nil && res.StatusCode == http.StatusNotModified {
  1148. if res.Body != nil {
  1149. res.Body.Close()
  1150. }
  1151. return nil, &googleapi.Error{
  1152. Code: res.StatusCode,
  1153. Header: res.Header,
  1154. }
  1155. }
  1156. if err != nil {
  1157. return nil, err
  1158. }
  1159. defer googleapi.CloseBody(res)
  1160. if err := googleapi.CheckResponse(res); err != nil {
  1161. return nil, err
  1162. }
  1163. ret := &SignJwtResponse{
  1164. ServerResponse: googleapi.ServerResponse{
  1165. Header: res.Header,
  1166. HTTPStatusCode: res.StatusCode,
  1167. },
  1168. }
  1169. target := &ret
  1170. if err := gensupport.DecodeResponse(target, res); err != nil {
  1171. return nil, err
  1172. }
  1173. return ret, nil
  1174. // {
  1175. // "description": "Signs a JWT using a service account's system-managed private key.",
  1176. // "flatPath": "v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}:signJwt",
  1177. // "httpMethod": "POST",
  1178. // "id": "iamcredentials.projects.serviceAccounts.signJwt",
  1179. // "parameterOrder": [
  1180. // "name"
  1181. // ],
  1182. // "parameters": {
  1183. // "name": {
  1184. // "description": "The resource name of the service account for which the credentials\nare requested, in the following format:\n`projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard\ncharacter is required; replacing it with a project ID is invalid.",
  1185. // "location": "path",
  1186. // "pattern": "^projects/[^/]+/serviceAccounts/[^/]+$",
  1187. // "required": true,
  1188. // "type": "string"
  1189. // }
  1190. // },
  1191. // "path": "v1/{+name}:signJwt",
  1192. // "request": {
  1193. // "$ref": "SignJwtRequest"
  1194. // },
  1195. // "response": {
  1196. // "$ref": "SignJwtResponse"
  1197. // },
  1198. // "scopes": [
  1199. // "https://www.googleapis.com/auth/cloud-platform"
  1200. // ]
  1201. // }
  1202. }