iamcredentials-gen.go 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112
  1. // Copyright 2024 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. // # Library status
  10. //
  11. // These client libraries are officially supported by Google. However, this
  12. // library is considered complete and is in maintenance mode. This means
  13. // that we will address critical bugs and security issues but will not add
  14. // any new features.
  15. //
  16. // When possible, we recommend using our newer
  17. // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go)
  18. // that are still actively being worked and iterated on.
  19. //
  20. // # Creating a client
  21. //
  22. // Usage example:
  23. //
  24. // import "google.golang.org/api/iamcredentials/v1"
  25. // ...
  26. // ctx := context.Background()
  27. // iamcredentialsService, err := iamcredentials.NewService(ctx)
  28. //
  29. // In this example, Google Application Default Credentials are used for
  30. // authentication. For information on how to create and obtain Application
  31. // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
  32. //
  33. // # Other authentication options
  34. //
  35. // To use an API key for authentication (note: some APIs do not support API
  36. // keys), use [google.golang.org/api/option.WithAPIKey]:
  37. //
  38. // iamcredentialsService, err := iamcredentials.NewService(ctx, option.WithAPIKey("AIza..."))
  39. //
  40. // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
  41. // flow, use [google.golang.org/api/option.WithTokenSource]:
  42. //
  43. // config := &oauth2.Config{...}
  44. // // ...
  45. // token, err := config.Exchange(ctx, ...)
  46. // iamcredentialsService, err := iamcredentials.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
  47. //
  48. // See [google.golang.org/api/option.ClientOption] for details on options.
  49. package iamcredentials // import "google.golang.org/api/iamcredentials/v1"
  50. import (
  51. "bytes"
  52. "context"
  53. "encoding/json"
  54. "errors"
  55. "fmt"
  56. "io"
  57. "net/http"
  58. "net/url"
  59. "strconv"
  60. "strings"
  61. googleapi "google.golang.org/api/googleapi"
  62. internal "google.golang.org/api/internal"
  63. gensupport "google.golang.org/api/internal/gensupport"
  64. option "google.golang.org/api/option"
  65. internaloption "google.golang.org/api/option/internaloption"
  66. htransport "google.golang.org/api/transport/http"
  67. )
  68. // Always reference these packages, just in case the auto-generated code
  69. // below doesn't.
  70. var _ = bytes.NewBuffer
  71. var _ = strconv.Itoa
  72. var _ = fmt.Sprintf
  73. var _ = json.NewDecoder
  74. var _ = io.Copy
  75. var _ = url.Parse
  76. var _ = gensupport.MarshalJSON
  77. var _ = googleapi.Version
  78. var _ = errors.New
  79. var _ = strings.Replace
  80. var _ = context.Canceled
  81. var _ = internaloption.WithDefaultEndpoint
  82. var _ = internal.Version
  83. const apiId = "iamcredentials:v1"
  84. const apiName = "iamcredentials"
  85. const apiVersion = "v1"
  86. const basePath = "https://iamcredentials.googleapis.com/"
  87. const basePathTemplate = "https://iamcredentials.UNIVERSE_DOMAIN/"
  88. const mtlsBasePath = "https://iamcredentials.mtls.googleapis.com/"
  89. const defaultUniverseDomain = "googleapis.com"
  90. // OAuth2 scopes used by this API.
  91. const (
  92. // See, edit, configure, and delete your Google Cloud data and see the
  93. // email address for your Google Account.
  94. CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
  95. )
  96. // NewService creates a new Service.
  97. func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
  98. scopesOption := internaloption.WithDefaultScopes(
  99. "https://www.googleapis.com/auth/cloud-platform",
  100. )
  101. // NOTE: prepend, so we don't override user-specified scopes.
  102. opts = append([]option.ClientOption{scopesOption}, opts...)
  103. opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
  104. opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
  105. opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
  106. opts = append(opts, internaloption.WithDefaultUniverseDomain(defaultUniverseDomain))
  107. client, endpoint, err := htransport.NewClient(ctx, opts...)
  108. if err != nil {
  109. return nil, err
  110. }
  111. s, err := New(client)
  112. if err != nil {
  113. return nil, err
  114. }
  115. if endpoint != "" {
  116. s.BasePath = endpoint
  117. }
  118. return s, nil
  119. }
  120. // New creates a new Service. It uses the provided http.Client for requests.
  121. //
  122. // Deprecated: please use NewService instead.
  123. // To provide a custom HTTP client, use option.WithHTTPClient.
  124. // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
  125. func New(client *http.Client) (*Service, error) {
  126. if client == nil {
  127. return nil, errors.New("client is nil")
  128. }
  129. s := &Service{client: client, BasePath: basePath}
  130. s.Projects = NewProjectsService(s)
  131. return s, nil
  132. }
  133. type Service struct {
  134. client *http.Client
  135. BasePath string // API endpoint base URL
  136. UserAgent string // optional additional User-Agent fragment
  137. Projects *ProjectsService
  138. }
  139. func (s *Service) userAgent() string {
  140. if s.UserAgent == "" {
  141. return googleapi.UserAgent
  142. }
  143. return googleapi.UserAgent + " " + s.UserAgent
  144. }
  145. func NewProjectsService(s *Service) *ProjectsService {
  146. rs := &ProjectsService{s: s}
  147. rs.ServiceAccounts = NewProjectsServiceAccountsService(s)
  148. return rs
  149. }
  150. type ProjectsService struct {
  151. s *Service
  152. ServiceAccounts *ProjectsServiceAccountsService
  153. }
  154. func NewProjectsServiceAccountsService(s *Service) *ProjectsServiceAccountsService {
  155. rs := &ProjectsServiceAccountsService{s: s}
  156. return rs
  157. }
  158. type ProjectsServiceAccountsService struct {
  159. s *Service
  160. }
  161. type GenerateAccessTokenRequest struct {
  162. // Delegates: The sequence of service accounts in a delegation chain.
  163. // This field is required for delegated requests
  164. // (https://cloud.google.com/iam/help/credentials/delegated-request).
  165. // For direct requests
  166. // (https://cloud.google.com/iam/help/credentials/direct-request), which
  167. // are more common, do not specify this field. Each service account must
  168. // be granted the `roles/iam.serviceAccountTokenCreator` role on its
  169. // next service account in the chain. The last service account in the
  170. // chain must be granted the `roles/iam.serviceAccountTokenCreator` role
  171. // on the service account that is specified in the `name` field of the
  172. // request. The delegates must have the following format:
  173. // `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-`
  174. // wildcard character is required; replacing it with a project ID is
  175. // invalid.
  176. Delegates []string `json:"delegates,omitempty"`
  177. // Lifetime: The desired lifetime duration of the access token in
  178. // seconds. By default, the maximum allowed value is 1 hour. To set a
  179. // lifetime of up to 12 hours, you can add the service account as an
  180. // allowed value in an Organization Policy that enforces the
  181. // `constraints/iam.allowServiceAccountCredentialLifetimeExtension`
  182. // constraint. See detailed instructions at
  183. // https://cloud.google.com/iam/help/credentials/lifetime If a value is
  184. // not specified, the token's lifetime will be set to a default value of
  185. // 1 hour.
  186. Lifetime string `json:"lifetime,omitempty"`
  187. // Scope: Required. Code to identify the scopes to be included in the
  188. // OAuth 2.0 access token. See
  189. // https://developers.google.com/identity/protocols/googlescopes for
  190. // more information. At least one value required.
  191. Scope []string `json:"scope,omitempty"`
  192. // ForceSendFields is a list of field names (e.g. "Delegates") to
  193. // unconditionally include in API requests. By default, fields with
  194. // empty or default values are omitted from API requests. However, any
  195. // non-pointer, non-interface field appearing in ForceSendFields will be
  196. // sent to the server regardless of whether the field is empty or not.
  197. // This may be used to include empty fields in Patch requests.
  198. ForceSendFields []string `json:"-"`
  199. // NullFields is a list of field names (e.g. "Delegates") to include in
  200. // API requests with the JSON null value. By default, fields with empty
  201. // values are omitted from API requests. However, any field with an
  202. // empty value appearing in NullFields will be sent to the server as
  203. // null. It is an error if a field in this list has a non-empty value.
  204. // This may be used to include null fields in Patch requests.
  205. NullFields []string `json:"-"`
  206. }
  207. func (s *GenerateAccessTokenRequest) MarshalJSON() ([]byte, error) {
  208. type NoMethod GenerateAccessTokenRequest
  209. raw := NoMethod(*s)
  210. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  211. }
  212. type GenerateAccessTokenResponse struct {
  213. // AccessToken: The OAuth 2.0 access token.
  214. AccessToken string `json:"accessToken,omitempty"`
  215. // ExpireTime: Token expiration time. The expiration time is always set.
  216. ExpireTime string `json:"expireTime,omitempty"`
  217. // ServerResponse contains the HTTP response code and headers from the
  218. // server.
  219. googleapi.ServerResponse `json:"-"`
  220. // ForceSendFields is a list of field names (e.g. "AccessToken") to
  221. // unconditionally include in API requests. By default, fields with
  222. // empty or default values are omitted from API requests. However, any
  223. // non-pointer, non-interface field appearing in ForceSendFields will be
  224. // sent to the server regardless of whether the field is empty or not.
  225. // This may be used to include empty fields in Patch requests.
  226. ForceSendFields []string `json:"-"`
  227. // NullFields is a list of field names (e.g. "AccessToken") to include
  228. // in API requests with the JSON null value. By default, fields with
  229. // empty values are omitted from API requests. However, any field with
  230. // an empty value appearing in NullFields will be sent to the server as
  231. // null. It is an error if a field in this list has a non-empty value.
  232. // This may be used to include null fields in Patch requests.
  233. NullFields []string `json:"-"`
  234. }
  235. func (s *GenerateAccessTokenResponse) MarshalJSON() ([]byte, error) {
  236. type NoMethod GenerateAccessTokenResponse
  237. raw := NoMethod(*s)
  238. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  239. }
  240. type GenerateIdTokenRequest struct {
  241. // Audience: Required. The audience for the token, such as the API or
  242. // account that this token grants access to.
  243. Audience string `json:"audience,omitempty"`
  244. // Delegates: The sequence of service accounts in a delegation chain.
  245. // Each service account must be granted the
  246. // `roles/iam.serviceAccountTokenCreator` role on its next service
  247. // account in the chain. The last service account in the chain must be
  248. // granted the `roles/iam.serviceAccountTokenCreator` role on the
  249. // service account that is specified in the `name` field of the request.
  250. // The delegates must have the following format:
  251. // `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-`
  252. // wildcard character is required; replacing it with a project ID is
  253. // invalid.
  254. Delegates []string `json:"delegates,omitempty"`
  255. // IncludeEmail: Include the service account email in the token. If set
  256. // to `true`, the token will contain `email` and `email_verified`
  257. // claims.
  258. IncludeEmail bool `json:"includeEmail,omitempty"`
  259. // ForceSendFields is a list of field names (e.g. "Audience") to
  260. // unconditionally include in API requests. By default, fields with
  261. // empty or default values are omitted from API requests. However, any
  262. // non-pointer, non-interface field appearing in ForceSendFields will be
  263. // sent to the server regardless of whether the field is empty or not.
  264. // This may be used to include empty fields in Patch requests.
  265. ForceSendFields []string `json:"-"`
  266. // NullFields is a list of field names (e.g. "Audience") to include in
  267. // API requests with the JSON null value. By default, fields with empty
  268. // values are omitted from API requests. However, any field with an
  269. // empty value appearing in NullFields will be sent to the server as
  270. // null. It is an error if a field in this list has a non-empty value.
  271. // This may be used to include null fields in Patch requests.
  272. NullFields []string `json:"-"`
  273. }
  274. func (s *GenerateIdTokenRequest) MarshalJSON() ([]byte, error) {
  275. type NoMethod GenerateIdTokenRequest
  276. raw := NoMethod(*s)
  277. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  278. }
  279. type GenerateIdTokenResponse struct {
  280. // Token: The OpenId Connect ID token.
  281. Token string `json:"token,omitempty"`
  282. // ServerResponse contains the HTTP response code and headers from the
  283. // server.
  284. googleapi.ServerResponse `json:"-"`
  285. // ForceSendFields is a list of field names (e.g. "Token") to
  286. // unconditionally include in API requests. By default, fields with
  287. // empty or default values are omitted from API requests. However, any
  288. // non-pointer, non-interface field appearing in ForceSendFields will be
  289. // sent to the server regardless of whether the field is empty or not.
  290. // This may be used to include empty fields in Patch requests.
  291. ForceSendFields []string `json:"-"`
  292. // NullFields is a list of field names (e.g. "Token") to include in API
  293. // requests with the JSON null value. By default, fields with empty
  294. // values are omitted from API requests. However, any field with an
  295. // empty value appearing in NullFields will be sent to the server as
  296. // null. It is an error if a field in this list has a non-empty value.
  297. // This may be used to include null fields in Patch requests.
  298. NullFields []string `json:"-"`
  299. }
  300. func (s *GenerateIdTokenResponse) MarshalJSON() ([]byte, error) {
  301. type NoMethod GenerateIdTokenResponse
  302. raw := NoMethod(*s)
  303. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  304. }
  305. type SignBlobRequest struct {
  306. // Delegates: The sequence of service accounts in a delegation chain.
  307. // Each service account must be granted the
  308. // `roles/iam.serviceAccountTokenCreator` role on its next service
  309. // account in the chain. The last service account in the chain must be
  310. // granted the `roles/iam.serviceAccountTokenCreator` role on the
  311. // service account that is specified in the `name` field of the request.
  312. // The delegates must have the following format:
  313. // `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-`
  314. // wildcard character is required; replacing it with a project ID is
  315. // invalid.
  316. Delegates []string `json:"delegates,omitempty"`
  317. // Payload: Required. The bytes to sign.
  318. Payload string `json:"payload,omitempty"`
  319. // ForceSendFields is a list of field names (e.g. "Delegates") to
  320. // unconditionally include in API requests. By default, fields with
  321. // empty or default values are omitted from API requests. However, any
  322. // non-pointer, non-interface field appearing in ForceSendFields will be
  323. // sent to the server regardless of whether the field is empty or not.
  324. // This may be used to include empty fields in Patch requests.
  325. ForceSendFields []string `json:"-"`
  326. // NullFields is a list of field names (e.g. "Delegates") to include in
  327. // API requests with the JSON null value. By default, fields with empty
  328. // values are omitted from API requests. However, any field with an
  329. // empty value appearing in NullFields will be sent to the server as
  330. // null. It is an error if a field in this list has a non-empty value.
  331. // This may be used to include null fields in Patch requests.
  332. NullFields []string `json:"-"`
  333. }
  334. func (s *SignBlobRequest) MarshalJSON() ([]byte, error) {
  335. type NoMethod SignBlobRequest
  336. raw := NoMethod(*s)
  337. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  338. }
  339. type SignBlobResponse struct {
  340. // KeyId: The ID of the key used to sign the blob. The key used for
  341. // signing will remain valid for at least 12 hours after the blob is
  342. // signed. To verify the signature, you can retrieve the public key in
  343. // several formats from the following endpoints: - RSA public key
  344. // wrapped in an X.509 v3 certificate:
  345. // `https://www.googleapis.com/service_accounts/v1/metadata/x509/{ACCOUNT
  346. // _EMAIL}` - Raw key in JSON format:
  347. // `https://www.googleapis.com/service_accounts/v1/metadata/raw/{ACCOUNT_
  348. // EMAIL}` - JSON Web Key (JWK):
  349. // `https://www.googleapis.com/service_accounts/v1/metadata/jwk/{ACCOUNT_
  350. // EMAIL}`
  351. KeyId string `json:"keyId,omitempty"`
  352. // SignedBlob: The signature for the blob. Does not include the original
  353. // blob. After the key pair referenced by the `key_id` response field
  354. // expires, Google no longer exposes the public key that can be used to
  355. // verify the blob. As a result, the receiver can no longer verify the
  356. // signature.
  357. SignedBlob string `json:"signedBlob,omitempty"`
  358. // ServerResponse contains the HTTP response code and headers from the
  359. // server.
  360. googleapi.ServerResponse `json:"-"`
  361. // ForceSendFields is a list of field names (e.g. "KeyId") to
  362. // unconditionally include in API requests. By default, fields with
  363. // empty or default values are omitted from API requests. However, any
  364. // non-pointer, non-interface field appearing in ForceSendFields will be
  365. // sent to the server regardless of whether the field is empty or not.
  366. // This may be used to include empty fields in Patch requests.
  367. ForceSendFields []string `json:"-"`
  368. // NullFields is a list of field names (e.g. "KeyId") to include in API
  369. // requests with the JSON null value. By default, fields with empty
  370. // values are omitted from API requests. However, any field with an
  371. // empty value appearing in NullFields will be sent to the server as
  372. // null. It is an error if a field in this list has a non-empty value.
  373. // This may be used to include null fields in Patch requests.
  374. NullFields []string `json:"-"`
  375. }
  376. func (s *SignBlobResponse) MarshalJSON() ([]byte, error) {
  377. type NoMethod SignBlobResponse
  378. raw := NoMethod(*s)
  379. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  380. }
  381. type SignJwtRequest struct {
  382. // Delegates: The sequence of service accounts in a delegation chain.
  383. // Each service account must be granted the
  384. // `roles/iam.serviceAccountTokenCreator` role on its next service
  385. // account in the chain. The last service account in the chain must be
  386. // granted the `roles/iam.serviceAccountTokenCreator` role on the
  387. // service account that is specified in the `name` field of the request.
  388. // The delegates must have the following format:
  389. // `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-`
  390. // wildcard character is required; replacing it with a project ID is
  391. // invalid.
  392. Delegates []string `json:"delegates,omitempty"`
  393. // Payload: Required. The JWT payload to sign. Must be a serialized JSON
  394. // object that contains a JWT Claims Set. For example: `{"sub":
  395. // "user@example.com", "iat": 313435}` If the JWT Claims Set contains an
  396. // expiration time (`exp`) claim, it must be an integer timestamp that
  397. // is not in the past and no more than 12 hours in the future.
  398. Payload string `json:"payload,omitempty"`
  399. // ForceSendFields is a list of field names (e.g. "Delegates") to
  400. // unconditionally include in API requests. By default, fields with
  401. // empty or default values are omitted from API requests. However, any
  402. // non-pointer, non-interface field appearing in ForceSendFields will be
  403. // sent to the server regardless of whether the field is empty or not.
  404. // This may be used to include empty fields in Patch requests.
  405. ForceSendFields []string `json:"-"`
  406. // NullFields is a list of field names (e.g. "Delegates") to include in
  407. // API requests with the JSON null value. By default, fields with empty
  408. // values are omitted from API requests. However, any field with an
  409. // empty value appearing in NullFields will be sent to the server as
  410. // null. It is an error if a field in this list has a non-empty value.
  411. // This may be used to include null fields in Patch requests.
  412. NullFields []string `json:"-"`
  413. }
  414. func (s *SignJwtRequest) MarshalJSON() ([]byte, error) {
  415. type NoMethod SignJwtRequest
  416. raw := NoMethod(*s)
  417. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  418. }
  419. type SignJwtResponse struct {
  420. // KeyId: The ID of the key used to sign the JWT. The key used for
  421. // signing will remain valid for at least 12 hours after the JWT is
  422. // signed. To verify the signature, you can retrieve the public key in
  423. // several formats from the following endpoints: - RSA public key
  424. // wrapped in an X.509 v3 certificate:
  425. // `https://www.googleapis.com/service_accounts/v1/metadata/x509/{ACCOUNT
  426. // _EMAIL}` - Raw key in JSON format:
  427. // `https://www.googleapis.com/service_accounts/v1/metadata/raw/{ACCOUNT_
  428. // EMAIL}` - JSON Web Key (JWK):
  429. // `https://www.googleapis.com/service_accounts/v1/metadata/jwk/{ACCOUNT_
  430. // EMAIL}`
  431. KeyId string `json:"keyId,omitempty"`
  432. // SignedJwt: The signed JWT. Contains the automatically generated
  433. // header; the client-supplied payload; and the signature, which is
  434. // generated using the key referenced by the `kid` field in the header.
  435. // After the key pair referenced by the `key_id` response field expires,
  436. // Google no longer exposes the public key that can be used to verify
  437. // the JWT. As a result, the receiver can no longer verify the
  438. // signature.
  439. SignedJwt string `json:"signedJwt,omitempty"`
  440. // ServerResponse contains the HTTP response code and headers from the
  441. // server.
  442. googleapi.ServerResponse `json:"-"`
  443. // ForceSendFields is a list of field names (e.g. "KeyId") to
  444. // unconditionally include in API requests. By default, fields with
  445. // empty or default values are omitted from API requests. However, any
  446. // non-pointer, non-interface field appearing in ForceSendFields will be
  447. // sent to the server regardless of whether the field is empty or not.
  448. // This may be used to include empty fields in Patch requests.
  449. ForceSendFields []string `json:"-"`
  450. // NullFields is a list of field names (e.g. "KeyId") to include in API
  451. // requests with the JSON null value. By default, fields with empty
  452. // values are omitted from API requests. However, any field with an
  453. // empty value appearing in NullFields will be sent to the server as
  454. // null. It is an error if a field in this list has a non-empty value.
  455. // This may be used to include null fields in Patch requests.
  456. NullFields []string `json:"-"`
  457. }
  458. func (s *SignJwtResponse) MarshalJSON() ([]byte, error) {
  459. type NoMethod SignJwtResponse
  460. raw := NoMethod(*s)
  461. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  462. }
  463. // method id "iamcredentials.projects.serviceAccounts.generateAccessToken":
  464. type ProjectsServiceAccountsGenerateAccessTokenCall struct {
  465. s *Service
  466. name string
  467. generateaccesstokenrequest *GenerateAccessTokenRequest
  468. urlParams_ gensupport.URLParams
  469. ctx_ context.Context
  470. header_ http.Header
  471. }
  472. // GenerateAccessToken: Generates an OAuth 2.0 access token for a
  473. // service account.
  474. //
  475. // - name: The resource name of the service account for which the
  476. // credentials are requested, in the following format:
  477. // `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-`
  478. // wildcard character is required; replacing it with a project ID is
  479. // invalid.
  480. func (r *ProjectsServiceAccountsService) GenerateAccessToken(name string, generateaccesstokenrequest *GenerateAccessTokenRequest) *ProjectsServiceAccountsGenerateAccessTokenCall {
  481. c := &ProjectsServiceAccountsGenerateAccessTokenCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  482. c.name = name
  483. c.generateaccesstokenrequest = generateaccesstokenrequest
  484. return c
  485. }
  486. // Fields allows partial responses to be retrieved. See
  487. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  488. // for more information.
  489. func (c *ProjectsServiceAccountsGenerateAccessTokenCall) Fields(s ...googleapi.Field) *ProjectsServiceAccountsGenerateAccessTokenCall {
  490. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  491. return c
  492. }
  493. // Context sets the context to be used in this call's Do method. Any
  494. // pending HTTP request will be aborted if the provided context is
  495. // canceled.
  496. func (c *ProjectsServiceAccountsGenerateAccessTokenCall) Context(ctx context.Context) *ProjectsServiceAccountsGenerateAccessTokenCall {
  497. c.ctx_ = ctx
  498. return c
  499. }
  500. // Header returns an http.Header that can be modified by the caller to
  501. // add HTTP headers to the request.
  502. func (c *ProjectsServiceAccountsGenerateAccessTokenCall) Header() http.Header {
  503. if c.header_ == nil {
  504. c.header_ = make(http.Header)
  505. }
  506. return c.header_
  507. }
  508. func (c *ProjectsServiceAccountsGenerateAccessTokenCall) doRequest(alt string) (*http.Response, error) {
  509. reqHeaders := make(http.Header)
  510. reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/"+internal.Version)
  511. for k, v := range c.header_ {
  512. reqHeaders[k] = v
  513. }
  514. reqHeaders.Set("User-Agent", c.s.userAgent())
  515. var body io.Reader = nil
  516. body, err := googleapi.WithoutDataWrapper.JSONReader(c.generateaccesstokenrequest)
  517. if err != nil {
  518. return nil, err
  519. }
  520. reqHeaders.Set("Content-Type", "application/json")
  521. c.urlParams_.Set("alt", alt)
  522. c.urlParams_.Set("prettyPrint", "false")
  523. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:generateAccessToken")
  524. urls += "?" + c.urlParams_.Encode()
  525. req, err := http.NewRequest("POST", urls, body)
  526. if err != nil {
  527. return nil, err
  528. }
  529. req.Header = reqHeaders
  530. googleapi.Expand(req.URL, map[string]string{
  531. "name": c.name,
  532. })
  533. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  534. }
  535. // Do executes the "iamcredentials.projects.serviceAccounts.generateAccessToken" call.
  536. // Exactly one of *GenerateAccessTokenResponse or error will be non-nil.
  537. // Any non-2xx status code is an error. Response headers are in either
  538. // *GenerateAccessTokenResponse.ServerResponse.Header or (if a response
  539. // was returned at all) in error.(*googleapi.Error).Header. Use
  540. // googleapi.IsNotModified to check whether the returned error was
  541. // because http.StatusNotModified was returned.
  542. func (c *ProjectsServiceAccountsGenerateAccessTokenCall) Do(opts ...googleapi.CallOption) (*GenerateAccessTokenResponse, error) {
  543. gensupport.SetOptions(c.urlParams_, opts...)
  544. res, err := c.doRequest("json")
  545. if res != nil && res.StatusCode == http.StatusNotModified {
  546. if res.Body != nil {
  547. res.Body.Close()
  548. }
  549. return nil, gensupport.WrapError(&googleapi.Error{
  550. Code: res.StatusCode,
  551. Header: res.Header,
  552. })
  553. }
  554. if err != nil {
  555. return nil, err
  556. }
  557. defer googleapi.CloseBody(res)
  558. if err := googleapi.CheckResponse(res); err != nil {
  559. return nil, gensupport.WrapError(err)
  560. }
  561. ret := &GenerateAccessTokenResponse{
  562. ServerResponse: googleapi.ServerResponse{
  563. Header: res.Header,
  564. HTTPStatusCode: res.StatusCode,
  565. },
  566. }
  567. target := &ret
  568. if err := gensupport.DecodeResponse(target, res); err != nil {
  569. return nil, err
  570. }
  571. return ret, nil
  572. // {
  573. // "description": "Generates an OAuth 2.0 access token for a service account.",
  574. // "flatPath": "v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}:generateAccessToken",
  575. // "httpMethod": "POST",
  576. // "id": "iamcredentials.projects.serviceAccounts.generateAccessToken",
  577. // "parameterOrder": [
  578. // "name"
  579. // ],
  580. // "parameters": {
  581. // "name": {
  582. // "description": "Required. The resource name of the service account for which the credentials are requested, in the following format: `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is required; replacing it with a project ID is invalid.",
  583. // "location": "path",
  584. // "pattern": "^projects/[^/]+/serviceAccounts/[^/]+$",
  585. // "required": true,
  586. // "type": "string"
  587. // }
  588. // },
  589. // "path": "v1/{+name}:generateAccessToken",
  590. // "request": {
  591. // "$ref": "GenerateAccessTokenRequest"
  592. // },
  593. // "response": {
  594. // "$ref": "GenerateAccessTokenResponse"
  595. // },
  596. // "scopes": [
  597. // "https://www.googleapis.com/auth/cloud-platform"
  598. // ]
  599. // }
  600. }
  601. // method id "iamcredentials.projects.serviceAccounts.generateIdToken":
  602. type ProjectsServiceAccountsGenerateIdTokenCall struct {
  603. s *Service
  604. name string
  605. generateidtokenrequest *GenerateIdTokenRequest
  606. urlParams_ gensupport.URLParams
  607. ctx_ context.Context
  608. header_ http.Header
  609. }
  610. // GenerateIdToken: Generates an OpenID Connect ID token for a service
  611. // account.
  612. //
  613. // - name: The resource name of the service account for which the
  614. // credentials are requested, in the following format:
  615. // `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-`
  616. // wildcard character is required; replacing it with a project ID is
  617. // invalid.
  618. func (r *ProjectsServiceAccountsService) GenerateIdToken(name string, generateidtokenrequest *GenerateIdTokenRequest) *ProjectsServiceAccountsGenerateIdTokenCall {
  619. c := &ProjectsServiceAccountsGenerateIdTokenCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  620. c.name = name
  621. c.generateidtokenrequest = generateidtokenrequest
  622. return c
  623. }
  624. // Fields allows partial responses to be retrieved. See
  625. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  626. // for more information.
  627. func (c *ProjectsServiceAccountsGenerateIdTokenCall) Fields(s ...googleapi.Field) *ProjectsServiceAccountsGenerateIdTokenCall {
  628. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  629. return c
  630. }
  631. // Context sets the context to be used in this call's Do method. Any
  632. // pending HTTP request will be aborted if the provided context is
  633. // canceled.
  634. func (c *ProjectsServiceAccountsGenerateIdTokenCall) Context(ctx context.Context) *ProjectsServiceAccountsGenerateIdTokenCall {
  635. c.ctx_ = ctx
  636. return c
  637. }
  638. // Header returns an http.Header that can be modified by the caller to
  639. // add HTTP headers to the request.
  640. func (c *ProjectsServiceAccountsGenerateIdTokenCall) Header() http.Header {
  641. if c.header_ == nil {
  642. c.header_ = make(http.Header)
  643. }
  644. return c.header_
  645. }
  646. func (c *ProjectsServiceAccountsGenerateIdTokenCall) doRequest(alt string) (*http.Response, error) {
  647. reqHeaders := make(http.Header)
  648. reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/"+internal.Version)
  649. for k, v := range c.header_ {
  650. reqHeaders[k] = v
  651. }
  652. reqHeaders.Set("User-Agent", c.s.userAgent())
  653. var body io.Reader = nil
  654. body, err := googleapi.WithoutDataWrapper.JSONReader(c.generateidtokenrequest)
  655. if err != nil {
  656. return nil, err
  657. }
  658. reqHeaders.Set("Content-Type", "application/json")
  659. c.urlParams_.Set("alt", alt)
  660. c.urlParams_.Set("prettyPrint", "false")
  661. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:generateIdToken")
  662. urls += "?" + c.urlParams_.Encode()
  663. req, err := http.NewRequest("POST", urls, body)
  664. if err != nil {
  665. return nil, err
  666. }
  667. req.Header = reqHeaders
  668. googleapi.Expand(req.URL, map[string]string{
  669. "name": c.name,
  670. })
  671. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  672. }
  673. // Do executes the "iamcredentials.projects.serviceAccounts.generateIdToken" call.
  674. // Exactly one of *GenerateIdTokenResponse or error will be non-nil. Any
  675. // non-2xx status code is an error. Response headers are in either
  676. // *GenerateIdTokenResponse.ServerResponse.Header or (if a response was
  677. // returned at all) in error.(*googleapi.Error).Header. Use
  678. // googleapi.IsNotModified to check whether the returned error was
  679. // because http.StatusNotModified was returned.
  680. func (c *ProjectsServiceAccountsGenerateIdTokenCall) Do(opts ...googleapi.CallOption) (*GenerateIdTokenResponse, error) {
  681. gensupport.SetOptions(c.urlParams_, opts...)
  682. res, err := c.doRequest("json")
  683. if res != nil && res.StatusCode == http.StatusNotModified {
  684. if res.Body != nil {
  685. res.Body.Close()
  686. }
  687. return nil, gensupport.WrapError(&googleapi.Error{
  688. Code: res.StatusCode,
  689. Header: res.Header,
  690. })
  691. }
  692. if err != nil {
  693. return nil, err
  694. }
  695. defer googleapi.CloseBody(res)
  696. if err := googleapi.CheckResponse(res); err != nil {
  697. return nil, gensupport.WrapError(err)
  698. }
  699. ret := &GenerateIdTokenResponse{
  700. ServerResponse: googleapi.ServerResponse{
  701. Header: res.Header,
  702. HTTPStatusCode: res.StatusCode,
  703. },
  704. }
  705. target := &ret
  706. if err := gensupport.DecodeResponse(target, res); err != nil {
  707. return nil, err
  708. }
  709. return ret, nil
  710. // {
  711. // "description": "Generates an OpenID Connect ID token for a service account.",
  712. // "flatPath": "v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}:generateIdToken",
  713. // "httpMethod": "POST",
  714. // "id": "iamcredentials.projects.serviceAccounts.generateIdToken",
  715. // "parameterOrder": [
  716. // "name"
  717. // ],
  718. // "parameters": {
  719. // "name": {
  720. // "description": "Required. The resource name of the service account for which the credentials are requested, in the following format: `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is required; replacing it with a project ID is invalid.",
  721. // "location": "path",
  722. // "pattern": "^projects/[^/]+/serviceAccounts/[^/]+$",
  723. // "required": true,
  724. // "type": "string"
  725. // }
  726. // },
  727. // "path": "v1/{+name}:generateIdToken",
  728. // "request": {
  729. // "$ref": "GenerateIdTokenRequest"
  730. // },
  731. // "response": {
  732. // "$ref": "GenerateIdTokenResponse"
  733. // },
  734. // "scopes": [
  735. // "https://www.googleapis.com/auth/cloud-platform"
  736. // ]
  737. // }
  738. }
  739. // method id "iamcredentials.projects.serviceAccounts.signBlob":
  740. type ProjectsServiceAccountsSignBlobCall struct {
  741. s *Service
  742. name string
  743. signblobrequest *SignBlobRequest
  744. urlParams_ gensupport.URLParams
  745. ctx_ context.Context
  746. header_ http.Header
  747. }
  748. // SignBlob: Signs a blob using a service account's system-managed
  749. // private key.
  750. //
  751. // - name: The resource name of the service account for which the
  752. // credentials are requested, in the following format:
  753. // `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-`
  754. // wildcard character is required; replacing it with a project ID is
  755. // invalid.
  756. func (r *ProjectsServiceAccountsService) SignBlob(name string, signblobrequest *SignBlobRequest) *ProjectsServiceAccountsSignBlobCall {
  757. c := &ProjectsServiceAccountsSignBlobCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  758. c.name = name
  759. c.signblobrequest = signblobrequest
  760. return c
  761. }
  762. // Fields allows partial responses to be retrieved. See
  763. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  764. // for more information.
  765. func (c *ProjectsServiceAccountsSignBlobCall) Fields(s ...googleapi.Field) *ProjectsServiceAccountsSignBlobCall {
  766. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  767. return c
  768. }
  769. // Context sets the context to be used in this call's Do method. Any
  770. // pending HTTP request will be aborted if the provided context is
  771. // canceled.
  772. func (c *ProjectsServiceAccountsSignBlobCall) Context(ctx context.Context) *ProjectsServiceAccountsSignBlobCall {
  773. c.ctx_ = ctx
  774. return c
  775. }
  776. // Header returns an http.Header that can be modified by the caller to
  777. // add HTTP headers to the request.
  778. func (c *ProjectsServiceAccountsSignBlobCall) Header() http.Header {
  779. if c.header_ == nil {
  780. c.header_ = make(http.Header)
  781. }
  782. return c.header_
  783. }
  784. func (c *ProjectsServiceAccountsSignBlobCall) doRequest(alt string) (*http.Response, error) {
  785. reqHeaders := make(http.Header)
  786. reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/"+internal.Version)
  787. for k, v := range c.header_ {
  788. reqHeaders[k] = v
  789. }
  790. reqHeaders.Set("User-Agent", c.s.userAgent())
  791. var body io.Reader = nil
  792. body, err := googleapi.WithoutDataWrapper.JSONReader(c.signblobrequest)
  793. if err != nil {
  794. return nil, err
  795. }
  796. reqHeaders.Set("Content-Type", "application/json")
  797. c.urlParams_.Set("alt", alt)
  798. c.urlParams_.Set("prettyPrint", "false")
  799. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:signBlob")
  800. urls += "?" + c.urlParams_.Encode()
  801. req, err := http.NewRequest("POST", urls, body)
  802. if err != nil {
  803. return nil, err
  804. }
  805. req.Header = reqHeaders
  806. googleapi.Expand(req.URL, map[string]string{
  807. "name": c.name,
  808. })
  809. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  810. }
  811. // Do executes the "iamcredentials.projects.serviceAccounts.signBlob" call.
  812. // Exactly one of *SignBlobResponse or error will be non-nil. Any
  813. // non-2xx status code is an error. Response headers are in either
  814. // *SignBlobResponse.ServerResponse.Header or (if a response was
  815. // returned at all) in error.(*googleapi.Error).Header. Use
  816. // googleapi.IsNotModified to check whether the returned error was
  817. // because http.StatusNotModified was returned.
  818. func (c *ProjectsServiceAccountsSignBlobCall) Do(opts ...googleapi.CallOption) (*SignBlobResponse, error) {
  819. gensupport.SetOptions(c.urlParams_, opts...)
  820. res, err := c.doRequest("json")
  821. if res != nil && res.StatusCode == http.StatusNotModified {
  822. if res.Body != nil {
  823. res.Body.Close()
  824. }
  825. return nil, gensupport.WrapError(&googleapi.Error{
  826. Code: res.StatusCode,
  827. Header: res.Header,
  828. })
  829. }
  830. if err != nil {
  831. return nil, err
  832. }
  833. defer googleapi.CloseBody(res)
  834. if err := googleapi.CheckResponse(res); err != nil {
  835. return nil, gensupport.WrapError(err)
  836. }
  837. ret := &SignBlobResponse{
  838. ServerResponse: googleapi.ServerResponse{
  839. Header: res.Header,
  840. HTTPStatusCode: res.StatusCode,
  841. },
  842. }
  843. target := &ret
  844. if err := gensupport.DecodeResponse(target, res); err != nil {
  845. return nil, err
  846. }
  847. return ret, nil
  848. // {
  849. // "description": "Signs a blob using a service account's system-managed private key.",
  850. // "flatPath": "v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}:signBlob",
  851. // "httpMethod": "POST",
  852. // "id": "iamcredentials.projects.serviceAccounts.signBlob",
  853. // "parameterOrder": [
  854. // "name"
  855. // ],
  856. // "parameters": {
  857. // "name": {
  858. // "description": "Required. The resource name of the service account for which the credentials are requested, in the following format: `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is required; replacing it with a project ID is invalid.",
  859. // "location": "path",
  860. // "pattern": "^projects/[^/]+/serviceAccounts/[^/]+$",
  861. // "required": true,
  862. // "type": "string"
  863. // }
  864. // },
  865. // "path": "v1/{+name}:signBlob",
  866. // "request": {
  867. // "$ref": "SignBlobRequest"
  868. // },
  869. // "response": {
  870. // "$ref": "SignBlobResponse"
  871. // },
  872. // "scopes": [
  873. // "https://www.googleapis.com/auth/cloud-platform"
  874. // ]
  875. // }
  876. }
  877. // method id "iamcredentials.projects.serviceAccounts.signJwt":
  878. type ProjectsServiceAccountsSignJwtCall struct {
  879. s *Service
  880. name string
  881. signjwtrequest *SignJwtRequest
  882. urlParams_ gensupport.URLParams
  883. ctx_ context.Context
  884. header_ http.Header
  885. }
  886. // SignJwt: Signs a JWT using a service account's system-managed private
  887. // key.
  888. //
  889. // - name: The resource name of the service account for which the
  890. // credentials are requested, in the following format:
  891. // `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-`
  892. // wildcard character is required; replacing it with a project ID is
  893. // invalid.
  894. func (r *ProjectsServiceAccountsService) SignJwt(name string, signjwtrequest *SignJwtRequest) *ProjectsServiceAccountsSignJwtCall {
  895. c := &ProjectsServiceAccountsSignJwtCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  896. c.name = name
  897. c.signjwtrequest = signjwtrequest
  898. return c
  899. }
  900. // Fields allows partial responses to be retrieved. See
  901. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  902. // for more information.
  903. func (c *ProjectsServiceAccountsSignJwtCall) Fields(s ...googleapi.Field) *ProjectsServiceAccountsSignJwtCall {
  904. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  905. return c
  906. }
  907. // Context sets the context to be used in this call's Do method. Any
  908. // pending HTTP request will be aborted if the provided context is
  909. // canceled.
  910. func (c *ProjectsServiceAccountsSignJwtCall) Context(ctx context.Context) *ProjectsServiceAccountsSignJwtCall {
  911. c.ctx_ = ctx
  912. return c
  913. }
  914. // Header returns an http.Header that can be modified by the caller to
  915. // add HTTP headers to the request.
  916. func (c *ProjectsServiceAccountsSignJwtCall) Header() http.Header {
  917. if c.header_ == nil {
  918. c.header_ = make(http.Header)
  919. }
  920. return c.header_
  921. }
  922. func (c *ProjectsServiceAccountsSignJwtCall) doRequest(alt string) (*http.Response, error) {
  923. reqHeaders := make(http.Header)
  924. reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/"+internal.Version)
  925. for k, v := range c.header_ {
  926. reqHeaders[k] = v
  927. }
  928. reqHeaders.Set("User-Agent", c.s.userAgent())
  929. var body io.Reader = nil
  930. body, err := googleapi.WithoutDataWrapper.JSONReader(c.signjwtrequest)
  931. if err != nil {
  932. return nil, err
  933. }
  934. reqHeaders.Set("Content-Type", "application/json")
  935. c.urlParams_.Set("alt", alt)
  936. c.urlParams_.Set("prettyPrint", "false")
  937. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:signJwt")
  938. urls += "?" + c.urlParams_.Encode()
  939. req, err := http.NewRequest("POST", urls, body)
  940. if err != nil {
  941. return nil, err
  942. }
  943. req.Header = reqHeaders
  944. googleapi.Expand(req.URL, map[string]string{
  945. "name": c.name,
  946. })
  947. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  948. }
  949. // Do executes the "iamcredentials.projects.serviceAccounts.signJwt" call.
  950. // Exactly one of *SignJwtResponse or error will be non-nil. Any non-2xx
  951. // status code is an error. Response headers are in either
  952. // *SignJwtResponse.ServerResponse.Header or (if a response was returned
  953. // at all) in error.(*googleapi.Error).Header. Use
  954. // googleapi.IsNotModified to check whether the returned error was
  955. // because http.StatusNotModified was returned.
  956. func (c *ProjectsServiceAccountsSignJwtCall) Do(opts ...googleapi.CallOption) (*SignJwtResponse, error) {
  957. gensupport.SetOptions(c.urlParams_, opts...)
  958. res, err := c.doRequest("json")
  959. if res != nil && res.StatusCode == http.StatusNotModified {
  960. if res.Body != nil {
  961. res.Body.Close()
  962. }
  963. return nil, gensupport.WrapError(&googleapi.Error{
  964. Code: res.StatusCode,
  965. Header: res.Header,
  966. })
  967. }
  968. if err != nil {
  969. return nil, err
  970. }
  971. defer googleapi.CloseBody(res)
  972. if err := googleapi.CheckResponse(res); err != nil {
  973. return nil, gensupport.WrapError(err)
  974. }
  975. ret := &SignJwtResponse{
  976. ServerResponse: googleapi.ServerResponse{
  977. Header: res.Header,
  978. HTTPStatusCode: res.StatusCode,
  979. },
  980. }
  981. target := &ret
  982. if err := gensupport.DecodeResponse(target, res); err != nil {
  983. return nil, err
  984. }
  985. return ret, nil
  986. // {
  987. // "description": "Signs a JWT using a service account's system-managed private key.",
  988. // "flatPath": "v1/projects/{projectsId}/serviceAccounts/{serviceAccountsId}:signJwt",
  989. // "httpMethod": "POST",
  990. // "id": "iamcredentials.projects.serviceAccounts.signJwt",
  991. // "parameterOrder": [
  992. // "name"
  993. // ],
  994. // "parameters": {
  995. // "name": {
  996. // "description": "Required. The resource name of the service account for which the credentials are requested, in the following format: `projects/-/serviceAccounts/{ACCOUNT_EMAIL_OR_UNIQUEID}`. The `-` wildcard character is required; replacing it with a project ID is invalid.",
  997. // "location": "path",
  998. // "pattern": "^projects/[^/]+/serviceAccounts/[^/]+$",
  999. // "required": true,
  1000. // "type": "string"
  1001. // }
  1002. // },
  1003. // "path": "v1/{+name}:signJwt",
  1004. // "request": {
  1005. // "$ref": "SignJwtRequest"
  1006. // },
  1007. // "response": {
  1008. // "$ref": "SignJwtResponse"
  1009. // },
  1010. // "scopes": [
  1011. // "https://www.googleapis.com/auth/cloud-platform"
  1012. // ]
  1013. // }
  1014. }