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

4808 lines
169 KiB

  1. // Package cloudkms provides access to the Cloud Key Management Service (KMS) API.
  2. //
  3. // See https://cloud.google.com/kms/
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/cloudkms/v1"
  8. // ...
  9. // cloudkmsService, err := cloudkms.New(oauthHttpClient)
  10. package cloudkms // import "google.golang.org/api/cloudkms/v1"
  11. import (
  12. "bytes"
  13. "encoding/json"
  14. "errors"
  15. "fmt"
  16. context "golang.org/x/net/context"
  17. ctxhttp "golang.org/x/net/context/ctxhttp"
  18. gensupport "google.golang.org/api/gensupport"
  19. googleapi "google.golang.org/api/googleapi"
  20. "io"
  21. "net/http"
  22. "net/url"
  23. "strconv"
  24. "strings"
  25. )
  26. // Always reference these packages, just in case the auto-generated code
  27. // below doesn't.
  28. var _ = bytes.NewBuffer
  29. var _ = strconv.Itoa
  30. var _ = fmt.Sprintf
  31. var _ = json.NewDecoder
  32. var _ = io.Copy
  33. var _ = url.Parse
  34. var _ = gensupport.MarshalJSON
  35. var _ = googleapi.Version
  36. var _ = errors.New
  37. var _ = strings.Replace
  38. var _ = context.Canceled
  39. var _ = ctxhttp.Do
  40. const apiId = "cloudkms:v1"
  41. const apiName = "cloudkms"
  42. const apiVersion = "v1"
  43. const basePath = "https://cloudkms.googleapis.com/"
  44. // OAuth2 scopes used by this API.
  45. const (
  46. // View and manage your data across Google Cloud Platform services
  47. CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
  48. )
  49. func New(client *http.Client) (*Service, error) {
  50. if client == nil {
  51. return nil, errors.New("client is nil")
  52. }
  53. s := &Service{client: client, BasePath: basePath}
  54. s.Projects = NewProjectsService(s)
  55. return s, nil
  56. }
  57. type Service struct {
  58. client *http.Client
  59. BasePath string // API endpoint base URL
  60. UserAgent string // optional additional User-Agent fragment
  61. Projects *ProjectsService
  62. }
  63. func (s *Service) userAgent() string {
  64. if s.UserAgent == "" {
  65. return googleapi.UserAgent
  66. }
  67. return googleapi.UserAgent + " " + s.UserAgent
  68. }
  69. func NewProjectsService(s *Service) *ProjectsService {
  70. rs := &ProjectsService{s: s}
  71. rs.Locations = NewProjectsLocationsService(s)
  72. return rs
  73. }
  74. type ProjectsService struct {
  75. s *Service
  76. Locations *ProjectsLocationsService
  77. }
  78. func NewProjectsLocationsService(s *Service) *ProjectsLocationsService {
  79. rs := &ProjectsLocationsService{s: s}
  80. rs.KeyRings = NewProjectsLocationsKeyRingsService(s)
  81. return rs
  82. }
  83. type ProjectsLocationsService struct {
  84. s *Service
  85. KeyRings *ProjectsLocationsKeyRingsService
  86. }
  87. func NewProjectsLocationsKeyRingsService(s *Service) *ProjectsLocationsKeyRingsService {
  88. rs := &ProjectsLocationsKeyRingsService{s: s}
  89. rs.CryptoKeys = NewProjectsLocationsKeyRingsCryptoKeysService(s)
  90. return rs
  91. }
  92. type ProjectsLocationsKeyRingsService struct {
  93. s *Service
  94. CryptoKeys *ProjectsLocationsKeyRingsCryptoKeysService
  95. }
  96. func NewProjectsLocationsKeyRingsCryptoKeysService(s *Service) *ProjectsLocationsKeyRingsCryptoKeysService {
  97. rs := &ProjectsLocationsKeyRingsCryptoKeysService{s: s}
  98. rs.CryptoKeyVersions = NewProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsService(s)
  99. return rs
  100. }
  101. type ProjectsLocationsKeyRingsCryptoKeysService struct {
  102. s *Service
  103. CryptoKeyVersions *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsService
  104. }
  105. func NewProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsService(s *Service) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsService {
  106. rs := &ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsService{s: s}
  107. return rs
  108. }
  109. type ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsService struct {
  110. s *Service
  111. }
  112. // AuditConfig: Specifies the audit configuration for a service.
  113. // The configuration determines which permission types are logged, and
  114. // what
  115. // identities, if any, are exempted from logging.
  116. // An AuditConfig must have one or more AuditLogConfigs.
  117. //
  118. // If there are AuditConfigs for both `allServices` and a specific
  119. // service,
  120. // the union of the two AuditConfigs is used for that service: the
  121. // log_types
  122. // specified in each AuditConfig are enabled, and the exempted_members
  123. // in each
  124. // AuditLogConfig are exempted.
  125. //
  126. // Example Policy with multiple AuditConfigs:
  127. //
  128. // {
  129. // "audit_configs": [
  130. // {
  131. // "service": "allServices"
  132. // "audit_log_configs": [
  133. // {
  134. // "log_type": "DATA_READ",
  135. // "exempted_members": [
  136. // "user:foo@gmail.com"
  137. // ]
  138. // },
  139. // {
  140. // "log_type": "DATA_WRITE",
  141. // },
  142. // {
  143. // "log_type": "ADMIN_READ",
  144. // }
  145. // ]
  146. // },
  147. // {
  148. // "service": "fooservice.googleapis.com"
  149. // "audit_log_configs": [
  150. // {
  151. // "log_type": "DATA_READ",
  152. // },
  153. // {
  154. // "log_type": "DATA_WRITE",
  155. // "exempted_members": [
  156. // "user:bar@gmail.com"
  157. // ]
  158. // }
  159. // ]
  160. // }
  161. // ]
  162. // }
  163. //
  164. // For fooservice, this policy enables DATA_READ, DATA_WRITE and
  165. // ADMIN_READ
  166. // logging. It also exempts foo@gmail.com from DATA_READ logging,
  167. // and
  168. // bar@gmail.com from DATA_WRITE logging.
  169. type AuditConfig struct {
  170. // AuditLogConfigs: The configuration for logging of each type of
  171. // permission.
  172. AuditLogConfigs []*AuditLogConfig `json:"auditLogConfigs,omitempty"`
  173. // Service: Specifies a service that will be enabled for audit
  174. // logging.
  175. // For example, `storage.googleapis.com`,
  176. // `cloudsql.googleapis.com`.
  177. // `allServices` is a special value that covers all services.
  178. Service string `json:"service,omitempty"`
  179. // ForceSendFields is a list of field names (e.g. "AuditLogConfigs") to
  180. // unconditionally include in API requests. By default, fields with
  181. // empty values are omitted from API requests. However, any non-pointer,
  182. // non-interface field appearing in ForceSendFields will be sent to the
  183. // server regardless of whether the field is empty or not. This may be
  184. // used to include empty fields in Patch requests.
  185. ForceSendFields []string `json:"-"`
  186. // NullFields is a list of field names (e.g. "AuditLogConfigs") to
  187. // include in API requests with the JSON null value. By default, fields
  188. // with empty values are omitted from API requests. However, any field
  189. // with an empty value appearing in NullFields will be sent to the
  190. // server as null. It is an error if a field in this list has a
  191. // non-empty value. This may be used to include null fields in Patch
  192. // requests.
  193. NullFields []string `json:"-"`
  194. }
  195. func (s *AuditConfig) MarshalJSON() ([]byte, error) {
  196. type NoMethod AuditConfig
  197. raw := NoMethod(*s)
  198. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  199. }
  200. // AuditLogConfig: Provides the configuration for logging a type of
  201. // permissions.
  202. // Example:
  203. //
  204. // {
  205. // "audit_log_configs": [
  206. // {
  207. // "log_type": "DATA_READ",
  208. // "exempted_members": [
  209. // "user:foo@gmail.com"
  210. // ]
  211. // },
  212. // {
  213. // "log_type": "DATA_WRITE",
  214. // }
  215. // ]
  216. // }
  217. //
  218. // This enables 'DATA_READ' and 'DATA_WRITE' logging, while
  219. // exempting
  220. // foo@gmail.com from DATA_READ logging.
  221. type AuditLogConfig struct {
  222. // ExemptedMembers: Specifies the identities that do not cause logging
  223. // for this type of
  224. // permission.
  225. // Follows the same format of Binding.members.
  226. ExemptedMembers []string `json:"exemptedMembers,omitempty"`
  227. // LogType: The log type that this config enables.
  228. //
  229. // Possible values:
  230. // "LOG_TYPE_UNSPECIFIED" - Default case. Should never be this.
  231. // "ADMIN_READ" - Admin reads. Example: CloudIAM getIamPolicy
  232. // "DATA_WRITE" - Data writes. Example: CloudSQL Users create
  233. // "DATA_READ" - Data reads. Example: CloudSQL Users list
  234. LogType string `json:"logType,omitempty"`
  235. // ForceSendFields is a list of field names (e.g. "ExemptedMembers") to
  236. // unconditionally include in API requests. By default, fields with
  237. // empty values are omitted from API requests. However, any non-pointer,
  238. // non-interface field appearing in ForceSendFields will be sent to the
  239. // server regardless of whether the field is empty or not. This may be
  240. // used to include empty fields in Patch requests.
  241. ForceSendFields []string `json:"-"`
  242. // NullFields is a list of field names (e.g. "ExemptedMembers") to
  243. // include in API requests with the JSON null value. By default, fields
  244. // with empty values are omitted from API requests. However, any field
  245. // with an empty value appearing in NullFields will be sent to the
  246. // server as null. It is an error if a field in this list has a
  247. // non-empty value. This may be used to include null fields in Patch
  248. // requests.
  249. NullFields []string `json:"-"`
  250. }
  251. func (s *AuditLogConfig) MarshalJSON() ([]byte, error) {
  252. type NoMethod AuditLogConfig
  253. raw := NoMethod(*s)
  254. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  255. }
  256. // Binding: Associates `members` with a `role`.
  257. type Binding struct {
  258. // Members: Specifies the identities requesting access for a Cloud
  259. // Platform resource.
  260. // `members` can have the following values:
  261. //
  262. // * `allUsers`: A special identifier that represents anyone who is
  263. // on the internet; with or without a Google account.
  264. //
  265. // * `allAuthenticatedUsers`: A special identifier that represents
  266. // anyone
  267. // who is authenticated with a Google account or a service
  268. // account.
  269. //
  270. // * `user:{emailid}`: An email address that represents a specific
  271. // Google
  272. // account. For example, `alice@gmail.com` .
  273. //
  274. //
  275. // * `serviceAccount:{emailid}`: An email address that represents a
  276. // service
  277. // account. For example,
  278. // `my-other-app@appspot.gserviceaccount.com`.
  279. //
  280. // * `group:{emailid}`: An email address that represents a Google
  281. // group.
  282. // For example, `admins@example.com`.
  283. //
  284. //
  285. // * `domain:{domain}`: A Google Apps domain name that represents all
  286. // the
  287. // users of that domain. For example, `google.com` or
  288. // `example.com`.
  289. //
  290. //
  291. Members []string `json:"members,omitempty"`
  292. // Role: Role that is assigned to `members`.
  293. // For example, `roles/viewer`, `roles/editor`, or
  294. // `roles/owner`.
  295. // Required
  296. Role string `json:"role,omitempty"`
  297. // ForceSendFields is a list of field names (e.g. "Members") to
  298. // unconditionally include in API requests. By default, fields with
  299. // empty values are omitted from API requests. However, any non-pointer,
  300. // non-interface field appearing in ForceSendFields will be sent to the
  301. // server regardless of whether the field is empty or not. This may be
  302. // used to include empty fields in Patch requests.
  303. ForceSendFields []string `json:"-"`
  304. // NullFields is a list of field names (e.g. "Members") to include in
  305. // API requests with the JSON null value. By default, fields with empty
  306. // values are omitted from API requests. However, any field with an
  307. // empty value appearing in NullFields will be sent to the server as
  308. // null. It is an error if a field in this list has a non-empty value.
  309. // This may be used to include null fields in Patch requests.
  310. NullFields []string `json:"-"`
  311. }
  312. func (s *Binding) MarshalJSON() ([]byte, error) {
  313. type NoMethod Binding
  314. raw := NoMethod(*s)
  315. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  316. }
  317. // CryptoKey: A CryptoKey represents a logical key that can be used for
  318. // cryptographic
  319. // operations.
  320. //
  321. // A CryptoKey is made up of one or more versions, which
  322. // represent the actual key material used in cryptographic operations.
  323. type CryptoKey struct {
  324. // CreateTime: Output only. The time at which this CryptoKey was
  325. // created.
  326. CreateTime string `json:"createTime,omitempty"`
  327. // Labels: Labels with user-defined metadata. For more information,
  328. // see
  329. // [Labeling Keys](/kms/docs/labeling-keys).
  330. Labels map[string]string `json:"labels,omitempty"`
  331. // Name: Output only. The resource name for this CryptoKey in the
  332. // format
  333. // `projects/*/locations/*/keyRings/*/cryptoKeys/*`.
  334. Name string `json:"name,omitempty"`
  335. // NextRotationTime: At next_rotation_time, the Key Management Service
  336. // will automatically:
  337. //
  338. // 1. Create a new version of this CryptoKey.
  339. // 2. Mark the new version as primary.
  340. //
  341. // Key rotations performed manually via
  342. // CreateCryptoKeyVersion and
  343. // UpdateCryptoKeyPrimaryVersion
  344. // do not affect next_rotation_time.
  345. NextRotationTime string `json:"nextRotationTime,omitempty"`
  346. // Primary: Output only. A copy of the "primary" CryptoKeyVersion that
  347. // will be used
  348. // by Encrypt when this CryptoKey is given
  349. // in EncryptRequest.name.
  350. //
  351. // The CryptoKey's primary version can be updated
  352. // via
  353. // UpdateCryptoKeyPrimaryVersion.
  354. //
  355. Primary *CryptoKeyVersion `json:"primary,omitempty"`
  356. // Purpose: The immutable purpose of this CryptoKey. Currently, the only
  357. // acceptable
  358. // purpose is ENCRYPT_DECRYPT.
  359. //
  360. // Possible values:
  361. // "CRYPTO_KEY_PURPOSE_UNSPECIFIED" - Not specified.
  362. // "ENCRYPT_DECRYPT" - CryptoKeys with this purpose may be used
  363. // with
  364. // Encrypt and
  365. // Decrypt.
  366. Purpose string `json:"purpose,omitempty"`
  367. // RotationPeriod: next_rotation_time will be advanced by this period
  368. // when the service
  369. // automatically rotates a key. Must be at least one day.
  370. //
  371. // If rotation_period is set, next_rotation_time must also be set.
  372. RotationPeriod string `json:"rotationPeriod,omitempty"`
  373. // ServerResponse contains the HTTP response code and headers from the
  374. // server.
  375. googleapi.ServerResponse `json:"-"`
  376. // ForceSendFields is a list of field names (e.g. "CreateTime") to
  377. // unconditionally include in API requests. By default, fields with
  378. // empty values are omitted from API requests. However, any non-pointer,
  379. // non-interface field appearing in ForceSendFields will be sent to the
  380. // server regardless of whether the field is empty or not. This may be
  381. // used to include empty fields in Patch requests.
  382. ForceSendFields []string `json:"-"`
  383. // NullFields is a list of field names (e.g. "CreateTime") to include in
  384. // API requests with the JSON null value. By default, fields with empty
  385. // values are omitted from API requests. However, any field with an
  386. // empty value appearing in NullFields will be sent to the server as
  387. // null. It is an error if a field in this list has a non-empty value.
  388. // This may be used to include null fields in Patch requests.
  389. NullFields []string `json:"-"`
  390. }
  391. func (s *CryptoKey) MarshalJSON() ([]byte, error) {
  392. type NoMethod CryptoKey
  393. raw := NoMethod(*s)
  394. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  395. }
  396. // CryptoKeyVersion: A CryptoKeyVersion represents an individual
  397. // cryptographic key, and the
  398. // associated key material.
  399. //
  400. // It can be used for cryptographic operations either directly, or via
  401. // its
  402. // parent CryptoKey, in which case the server will choose the
  403. // appropriate
  404. // version for the operation.
  405. //
  406. // For security reasons, the raw cryptographic key material represented
  407. // by a
  408. // CryptoKeyVersion can never be viewed or exported. It can only be used
  409. // to
  410. // encrypt or decrypt data when an authorized user or application
  411. // invokes Cloud
  412. // KMS.
  413. type CryptoKeyVersion struct {
  414. // CreateTime: Output only. The time at which this CryptoKeyVersion was
  415. // created.
  416. CreateTime string `json:"createTime,omitempty"`
  417. // DestroyEventTime: Output only. The time this CryptoKeyVersion's key
  418. // material was
  419. // destroyed. Only present if state is
  420. // DESTROYED.
  421. DestroyEventTime string `json:"destroyEventTime,omitempty"`
  422. // DestroyTime: Output only. The time this CryptoKeyVersion's key
  423. // material is scheduled
  424. // for destruction. Only present if state is
  425. // DESTROY_SCHEDULED.
  426. DestroyTime string `json:"destroyTime,omitempty"`
  427. // Name: Output only. The resource name for this CryptoKeyVersion in the
  428. // format
  429. // `projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersio
  430. // ns/*`.
  431. Name string `json:"name,omitempty"`
  432. // State: The current state of the CryptoKeyVersion.
  433. //
  434. // Possible values:
  435. // "CRYPTO_KEY_VERSION_STATE_UNSPECIFIED" - Not specified.
  436. // "ENABLED" - This version may be used in Encrypt and
  437. // Decrypt requests.
  438. // "DISABLED" - This version may not be used, but the key material is
  439. // still available,
  440. // and the version can be placed back into the ENABLED state.
  441. // "DESTROYED" - This version is destroyed, and the key material is no
  442. // longer stored.
  443. // A version may not leave this state once entered.
  444. // "DESTROY_SCHEDULED" - This version is scheduled for destruction,
  445. // and will be destroyed soon.
  446. // Call
  447. // RestoreCryptoKeyVersion
  448. // to put it back into the DISABLED state.
  449. State string `json:"state,omitempty"`
  450. // ServerResponse contains the HTTP response code and headers from the
  451. // server.
  452. googleapi.ServerResponse `json:"-"`
  453. // ForceSendFields is a list of field names (e.g. "CreateTime") to
  454. // unconditionally include in API requests. By default, fields with
  455. // empty values are omitted from API requests. However, any non-pointer,
  456. // non-interface field appearing in ForceSendFields will be sent to the
  457. // server regardless of whether the field is empty or not. This may be
  458. // used to include empty fields in Patch requests.
  459. ForceSendFields []string `json:"-"`
  460. // NullFields is a list of field names (e.g. "CreateTime") to include in
  461. // API requests with the JSON null value. By default, fields with empty
  462. // values are omitted from API requests. However, any field with an
  463. // empty value appearing in NullFields will be sent to the server as
  464. // null. It is an error if a field in this list has a non-empty value.
  465. // This may be used to include null fields in Patch requests.
  466. NullFields []string `json:"-"`
  467. }
  468. func (s *CryptoKeyVersion) MarshalJSON() ([]byte, error) {
  469. type NoMethod CryptoKeyVersion
  470. raw := NoMethod(*s)
  471. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  472. }
  473. // DecryptRequest: Request message for KeyManagementService.Decrypt.
  474. type DecryptRequest struct {
  475. // AdditionalAuthenticatedData: Optional data that must match the data
  476. // originally supplied in
  477. // EncryptRequest.additional_authenticated_data.
  478. AdditionalAuthenticatedData string `json:"additionalAuthenticatedData,omitempty"`
  479. // Ciphertext: Required. The encrypted data originally returned
  480. // in
  481. // EncryptResponse.ciphertext.
  482. Ciphertext string `json:"ciphertext,omitempty"`
  483. // ForceSendFields is a list of field names (e.g.
  484. // "AdditionalAuthenticatedData") to unconditionally include in API
  485. // requests. By default, fields with empty values are omitted from API
  486. // requests. However, any non-pointer, non-interface field appearing in
  487. // ForceSendFields will be sent to the server regardless of whether the
  488. // field is empty or not. This may be used to include empty fields in
  489. // Patch requests.
  490. ForceSendFields []string `json:"-"`
  491. // NullFields is a list of field names (e.g.
  492. // "AdditionalAuthenticatedData") to include in API requests with the
  493. // JSON null value. By default, fields with empty values are omitted
  494. // from API requests. However, any field with an empty value appearing
  495. // in NullFields will be sent to the server as null. It is an error if a
  496. // field in this list has a non-empty value. This may be used to include
  497. // null fields in Patch requests.
  498. NullFields []string `json:"-"`
  499. }
  500. func (s *DecryptRequest) MarshalJSON() ([]byte, error) {
  501. type NoMethod DecryptRequest
  502. raw := NoMethod(*s)
  503. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  504. }
  505. // DecryptResponse: Response message for KeyManagementService.Decrypt.
  506. type DecryptResponse struct {
  507. // Plaintext: The decrypted data originally supplied in
  508. // EncryptRequest.plaintext.
  509. Plaintext string `json:"plaintext,omitempty"`
  510. // ServerResponse contains the HTTP response code and headers from the
  511. // server.
  512. googleapi.ServerResponse `json:"-"`
  513. // ForceSendFields is a list of field names (e.g. "Plaintext") to
  514. // unconditionally include in API requests. By default, fields with
  515. // empty values are omitted from API requests. However, any non-pointer,
  516. // non-interface field appearing in ForceSendFields will be sent to the
  517. // server regardless of whether the field is empty or not. This may be
  518. // used to include empty fields in Patch requests.
  519. ForceSendFields []string `json:"-"`
  520. // NullFields is a list of field names (e.g. "Plaintext") to include in
  521. // API requests with the JSON null value. By default, fields with empty
  522. // values are omitted from API requests. However, any field with an
  523. // empty value appearing in NullFields will be sent to the server as
  524. // null. It is an error if a field in this list has a non-empty value.
  525. // This may be used to include null fields in Patch requests.
  526. NullFields []string `json:"-"`
  527. }
  528. func (s *DecryptResponse) MarshalJSON() ([]byte, error) {
  529. type NoMethod DecryptResponse
  530. raw := NoMethod(*s)
  531. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  532. }
  533. // DestroyCryptoKeyVersionRequest: Request message for
  534. // KeyManagementService.DestroyCryptoKeyVersion.
  535. type DestroyCryptoKeyVersionRequest struct {
  536. }
  537. // EncryptRequest: Request message for KeyManagementService.Encrypt.
  538. type EncryptRequest struct {
  539. // AdditionalAuthenticatedData: Optional data that, if specified, must
  540. // also be provided during decryption
  541. // through DecryptRequest.additional_authenticated_data. Must be
  542. // no
  543. // larger than 64KiB.
  544. AdditionalAuthenticatedData string `json:"additionalAuthenticatedData,omitempty"`
  545. // Plaintext: Required. The data to encrypt. Must be no larger than
  546. // 64KiB.
  547. Plaintext string `json:"plaintext,omitempty"`
  548. // ForceSendFields is a list of field names (e.g.
  549. // "AdditionalAuthenticatedData") to unconditionally include in API
  550. // requests. By default, fields with empty values are omitted from API
  551. // requests. However, any non-pointer, non-interface field appearing in
  552. // ForceSendFields will be sent to the server regardless of whether the
  553. // field is empty or not. This may be used to include empty fields in
  554. // Patch requests.
  555. ForceSendFields []string `json:"-"`
  556. // NullFields is a list of field names (e.g.
  557. // "AdditionalAuthenticatedData") to include in API requests with the
  558. // JSON null value. By default, fields with empty values are omitted
  559. // from API requests. However, any field with an empty value appearing
  560. // in NullFields will be sent to the server as null. It is an error if a
  561. // field in this list has a non-empty value. This may be used to include
  562. // null fields in Patch requests.
  563. NullFields []string `json:"-"`
  564. }
  565. func (s *EncryptRequest) MarshalJSON() ([]byte, error) {
  566. type NoMethod EncryptRequest
  567. raw := NoMethod(*s)
  568. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  569. }
  570. // EncryptResponse: Response message for KeyManagementService.Encrypt.
  571. type EncryptResponse struct {
  572. // Ciphertext: The encrypted data.
  573. Ciphertext string `json:"ciphertext,omitempty"`
  574. // Name: The resource name of the CryptoKeyVersion used in encryption.
  575. Name string `json:"name,omitempty"`
  576. // ServerResponse contains the HTTP response code and headers from the
  577. // server.
  578. googleapi.ServerResponse `json:"-"`
  579. // ForceSendFields is a list of field names (e.g. "Ciphertext") to
  580. // unconditionally include in API requests. By default, fields with
  581. // empty values are omitted from API requests. However, any non-pointer,
  582. // non-interface field appearing in ForceSendFields will be sent to the
  583. // server regardless of whether the field is empty or not. This may be
  584. // used to include empty fields in Patch requests.
  585. ForceSendFields []string `json:"-"`
  586. // NullFields is a list of field names (e.g. "Ciphertext") to include in
  587. // API requests with the JSON null value. By default, fields with empty
  588. // values are omitted from API requests. However, any field with an
  589. // empty value appearing in NullFields will be sent to the server as
  590. // null. It is an error if a field in this list has a non-empty value.
  591. // This may be used to include null fields in Patch requests.
  592. NullFields []string `json:"-"`
  593. }
  594. func (s *EncryptResponse) MarshalJSON() ([]byte, error) {
  595. type NoMethod EncryptResponse
  596. raw := NoMethod(*s)
  597. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  598. }
  599. // KeyRing: A KeyRing is a toplevel logical grouping of CryptoKeys.
  600. type KeyRing struct {
  601. // CreateTime: Output only. The time at which this KeyRing was created.
  602. CreateTime string `json:"createTime,omitempty"`
  603. // Name: Output only. The resource name for the KeyRing in the
  604. // format
  605. // `projects/*/locations/*/keyRings/*`.
  606. Name string `json:"name,omitempty"`
  607. // ServerResponse contains the HTTP response code and headers from the
  608. // server.
  609. googleapi.ServerResponse `json:"-"`
  610. // ForceSendFields is a list of field names (e.g. "CreateTime") to
  611. // unconditionally include in API requests. By default, fields with
  612. // empty values are omitted from API requests. However, any non-pointer,
  613. // non-interface field appearing in ForceSendFields will be sent to the
  614. // server regardless of whether the field is empty or not. This may be
  615. // used to include empty fields in Patch requests.
  616. ForceSendFields []string `json:"-"`
  617. // NullFields is a list of field names (e.g. "CreateTime") to include in
  618. // API requests with the JSON null value. By default, fields with empty
  619. // values are omitted from API requests. However, any field with an
  620. // empty value appearing in NullFields will be sent to the server as
  621. // null. It is an error if a field in this list has a non-empty value.
  622. // This may be used to include null fields in Patch requests.
  623. NullFields []string `json:"-"`
  624. }
  625. func (s *KeyRing) MarshalJSON() ([]byte, error) {
  626. type NoMethod KeyRing
  627. raw := NoMethod(*s)
  628. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  629. }
  630. // ListCryptoKeyVersionsResponse: Response message for
  631. // KeyManagementService.ListCryptoKeyVersions.
  632. type ListCryptoKeyVersionsResponse struct {
  633. // CryptoKeyVersions: The list of CryptoKeyVersions.
  634. CryptoKeyVersions []*CryptoKeyVersion `json:"cryptoKeyVersions,omitempty"`
  635. // NextPageToken: A token to retrieve next page of results. Pass this
  636. // value in
  637. // ListCryptoKeyVersionsRequest.page_token to retrieve the next page
  638. // of
  639. // results.
  640. NextPageToken string `json:"nextPageToken,omitempty"`
  641. // TotalSize: The total number of CryptoKeyVersions that matched
  642. // the
  643. // query.
  644. TotalSize int64 `json:"totalSize,omitempty"`
  645. // ServerResponse contains the HTTP response code and headers from the
  646. // server.
  647. googleapi.ServerResponse `json:"-"`
  648. // ForceSendFields is a list of field names (e.g. "CryptoKeyVersions")
  649. // to unconditionally include in API requests. By default, fields with
  650. // empty values are omitted from API requests. However, any non-pointer,
  651. // non-interface field appearing in ForceSendFields will be sent to the
  652. // server regardless of whether the field is empty or not. This may be
  653. // used to include empty fields in Patch requests.
  654. ForceSendFields []string `json:"-"`
  655. // NullFields is a list of field names (e.g. "CryptoKeyVersions") to
  656. // include in API requests with the JSON null value. By default, fields
  657. // with empty values are omitted from API requests. However, any field
  658. // with an empty value appearing in NullFields will be sent to the
  659. // server as null. It is an error if a field in this list has a
  660. // non-empty value. This may be used to include null fields in Patch
  661. // requests.
  662. NullFields []string `json:"-"`
  663. }
  664. func (s *ListCryptoKeyVersionsResponse) MarshalJSON() ([]byte, error) {
  665. type NoMethod ListCryptoKeyVersionsResponse
  666. raw := NoMethod(*s)
  667. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  668. }
  669. // ListCryptoKeysResponse: Response message for
  670. // KeyManagementService.ListCryptoKeys.
  671. type ListCryptoKeysResponse struct {
  672. // CryptoKeys: The list of CryptoKeys.
  673. CryptoKeys []*CryptoKey `json:"cryptoKeys,omitempty"`
  674. // NextPageToken: A token to retrieve next page of results. Pass this
  675. // value in
  676. // ListCryptoKeysRequest.page_token to retrieve the next page of
  677. // results.
  678. NextPageToken string `json:"nextPageToken,omitempty"`
  679. // TotalSize: The total number of CryptoKeys that matched the query.
  680. TotalSize int64 `json:"totalSize,omitempty"`
  681. // ServerResponse contains the HTTP response code and headers from the
  682. // server.
  683. googleapi.ServerResponse `json:"-"`
  684. // ForceSendFields is a list of field names (e.g. "CryptoKeys") to
  685. // unconditionally include in API requests. By default, fields with
  686. // empty values are omitted from API requests. However, any non-pointer,
  687. // non-interface field appearing in ForceSendFields will be sent to the
  688. // server regardless of whether the field is empty or not. This may be
  689. // used to include empty fields in Patch requests.
  690. ForceSendFields []string `json:"-"`
  691. // NullFields is a list of field names (e.g. "CryptoKeys") to include in
  692. // API requests with the JSON null value. By default, fields with empty
  693. // values are omitted from API requests. However, any field with an
  694. // empty value appearing in NullFields will be sent to the server as
  695. // null. It is an error if a field in this list has a non-empty value.
  696. // This may be used to include null fields in Patch requests.
  697. NullFields []string `json:"-"`
  698. }
  699. func (s *ListCryptoKeysResponse) MarshalJSON() ([]byte, error) {
  700. type NoMethod ListCryptoKeysResponse
  701. raw := NoMethod(*s)
  702. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  703. }
  704. // ListKeyRingsResponse: Response message for
  705. // KeyManagementService.ListKeyRings.
  706. type ListKeyRingsResponse struct {
  707. // KeyRings: The list of KeyRings.
  708. KeyRings []*KeyRing `json:"keyRings,omitempty"`
  709. // NextPageToken: A token to retrieve next page of results. Pass this
  710. // value in
  711. // ListKeyRingsRequest.page_token to retrieve the next page of results.
  712. NextPageToken string `json:"nextPageToken,omitempty"`
  713. // TotalSize: The total number of KeyRings that matched the query.
  714. TotalSize int64 `json:"totalSize,omitempty"`
  715. // ServerResponse contains the HTTP response code and headers from the
  716. // server.
  717. googleapi.ServerResponse `json:"-"`
  718. // ForceSendFields is a list of field names (e.g. "KeyRings") to
  719. // unconditionally include in API requests. By default, fields with
  720. // empty values are omitted from API requests. However, any non-pointer,
  721. // non-interface field appearing in ForceSendFields will be sent to the
  722. // server regardless of whether the field is empty or not. This may be
  723. // used to include empty fields in Patch requests.
  724. ForceSendFields []string `json:"-"`
  725. // NullFields is a list of field names (e.g. "KeyRings") to include in
  726. // API requests with the JSON null value. By default, fields with empty
  727. // values are omitted from API requests. However, any field with an
  728. // empty value appearing in NullFields will be sent to the server as
  729. // null. It is an error if a field in this list has a non-empty value.
  730. // This may be used to include null fields in Patch requests.
  731. NullFields []string `json:"-"`
  732. }
  733. func (s *ListKeyRingsResponse) MarshalJSON() ([]byte, error) {
  734. type NoMethod ListKeyRingsResponse
  735. raw := NoMethod(*s)
  736. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  737. }
  738. // ListLocationsResponse: The response message for
  739. // Locations.ListLocations.
  740. type ListLocationsResponse struct {
  741. // Locations: A list of locations that matches the specified filter in
  742. // the request.
  743. Locations []*Location `json:"locations,omitempty"`
  744. // NextPageToken: The standard List next-page token.
  745. NextPageToken string `json:"nextPageToken,omitempty"`
  746. // ServerResponse contains the HTTP response code and headers from the
  747. // server.
  748. googleapi.ServerResponse `json:"-"`
  749. // ForceSendFields is a list of field names (e.g. "Locations") to
  750. // unconditionally include in API requests. By default, fields with
  751. // empty values are omitted from API requests. However, any non-pointer,
  752. // non-interface field appearing in ForceSendFields will be sent to the
  753. // server regardless of whether the field is empty or not. This may be
  754. // used to include empty fields in Patch requests.
  755. ForceSendFields []string `json:"-"`
  756. // NullFields is a list of field names (e.g. "Locations") to include in
  757. // API requests with the JSON null value. By default, fields with empty
  758. // values are omitted from API requests. However, any field with an
  759. // empty value appearing in NullFields will be sent to the server as
  760. // null. It is an error if a field in this list has a non-empty value.
  761. // This may be used to include null fields in Patch requests.
  762. NullFields []string `json:"-"`
  763. }
  764. func (s *ListLocationsResponse) MarshalJSON() ([]byte, error) {
  765. type NoMethod ListLocationsResponse
  766. raw := NoMethod(*s)
  767. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  768. }
  769. // Location: A resource that represents Google Cloud Platform location.
  770. type Location struct {
  771. // DisplayName: The friendly name for this location, typically a nearby
  772. // city name.
  773. // For example, "Tokyo".
  774. DisplayName string `json:"displayName,omitempty"`
  775. // Labels: Cross-service attributes for the location. For example
  776. //
  777. // {"cloud.googleapis.com/region": "us-east1"}
  778. Labels map[string]string `json:"labels,omitempty"`
  779. // LocationId: The canonical id for this location. For example:
  780. // "us-east1".
  781. LocationId string `json:"locationId,omitempty"`
  782. // Metadata: Service-specific metadata. For example the available
  783. // capacity at the given
  784. // location.
  785. Metadata googleapi.RawMessage `json:"metadata,omitempty"`
  786. // Name: Resource name for the location, which may vary between
  787. // implementations.
  788. // For example: "projects/example-project/locations/us-east1"
  789. Name string `json:"name,omitempty"`
  790. // ServerResponse contains the HTTP response code and headers from the
  791. // server.
  792. googleapi.ServerResponse `json:"-"`
  793. // ForceSendFields is a list of field names (e.g. "DisplayName") to
  794. // unconditionally include in API requests. By default, fields with
  795. // empty values are omitted from API requests. However, any non-pointer,
  796. // non-interface field appearing in ForceSendFields will be sent to the
  797. // server regardless of whether the field is empty or not. This may be
  798. // used to include empty fields in Patch requests.
  799. ForceSendFields []string `json:"-"`
  800. // NullFields is a list of field names (e.g. "DisplayName") to include
  801. // in API requests with the JSON null value. By default, fields with
  802. // empty values are omitted from API requests. However, any field with
  803. // an empty value appearing in NullFields will be sent to the server as
  804. // null. It is an error if a field in this list has a non-empty value.
  805. // This may be used to include null fields in Patch requests.
  806. NullFields []string `json:"-"`
  807. }
  808. func (s *Location) MarshalJSON() ([]byte, error) {
  809. type NoMethod Location
  810. raw := NoMethod(*s)
  811. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  812. }
  813. // Policy: Defines an Identity and Access Management (IAM) policy. It is
  814. // used to
  815. // specify access control policies for Cloud Platform resources.
  816. //
  817. //
  818. // A `Policy` consists of a list of `bindings`. A `binding` binds a list
  819. // of
  820. // `members` to a `role`, where the members can be user accounts, Google
  821. // groups,
  822. // Google domains, and service accounts. A `role` is a named list of
  823. // permissions
  824. // defined by IAM.
  825. //
  826. // **JSON Example**
  827. //
  828. // {
  829. // "bindings": [
  830. // {
  831. // "role": "roles/owner",
  832. // "members": [
  833. // "user:mike@example.com",
  834. // "group:admins@example.com",
  835. // "domain:google.com",
  836. //
  837. // "serviceAccount:my-other-app@appspot.gserviceaccount.com"
  838. // ]
  839. // },
  840. // {
  841. // "role": "roles/viewer",
  842. // "members": ["user:sean@example.com"]
  843. // }
  844. // ]
  845. // }
  846. //
  847. // **YAML Example**
  848. //
  849. // bindings:
  850. // - members:
  851. // - user:mike@example.com
  852. // - group:admins@example.com
  853. // - domain:google.com
  854. // - serviceAccount:my-other-app@appspot.gserviceaccount.com
  855. // role: roles/owner
  856. // - members:
  857. // - user:sean@example.com
  858. // role: roles/viewer
  859. //
  860. //
  861. // For a description of IAM and its features, see the
  862. // [IAM developer's guide](https://cloud.google.com/iam/docs).
  863. type Policy struct {
  864. // AuditConfigs: Specifies cloud audit logging configuration for this
  865. // policy.
  866. AuditConfigs []*AuditConfig `json:"auditConfigs,omitempty"`
  867. // Bindings: Associates a list of `members` to a `role`.
  868. // `bindings` with no members will result in an error.
  869. Bindings []*Binding `json:"bindings,omitempty"`
  870. // Etag: `etag` is used for optimistic concurrency control as a way to
  871. // help
  872. // prevent simultaneous updates of a policy from overwriting each
  873. // other.
  874. // It is strongly suggested that systems make use of the `etag` in
  875. // the
  876. // read-modify-write cycle to perform policy updates in order to avoid
  877. // race
  878. // conditions: An `etag` is returned in the response to `getIamPolicy`,
  879. // and
  880. // systems are expected to put that etag in the request to
  881. // `setIamPolicy` to
  882. // ensure that their change will be applied to the same version of the
  883. // policy.
  884. //
  885. // If no `etag` is provided in the call to `setIamPolicy`, then the
  886. // existing
  887. // policy is overwritten blindly.
  888. Etag string `json:"etag,omitempty"`
  889. // Version: Deprecated.
  890. Version int64 `json:"version,omitempty"`
  891. // ServerResponse contains the HTTP response code and headers from the
  892. // server.
  893. googleapi.ServerResponse `json:"-"`
  894. // ForceSendFields is a list of field names (e.g. "AuditConfigs") to
  895. // unconditionally include in API requests. By default, fields with
  896. // empty values are omitted from API requests. However, any non-pointer,
  897. // non-interface field appearing in ForceSendFields will be sent to the
  898. // server regardless of whether the field is empty or not. This may be
  899. // used to include empty fields in Patch requests.
  900. ForceSendFields []string `json:"-"`
  901. // NullFields is a list of field names (e.g. "AuditConfigs") to include
  902. // in API requests with the JSON null value. By default, fields with
  903. // empty values are omitted from API requests. However, any field with
  904. // an empty value appearing in NullFields will be sent to the server as
  905. // null. It is an error if a field in this list has a non-empty value.
  906. // This may be used to include null fields in Patch requests.
  907. NullFields []string `json:"-"`
  908. }
  909. func (s *Policy) MarshalJSON() ([]byte, error) {
  910. type NoMethod Policy
  911. raw := NoMethod(*s)
  912. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  913. }
  914. // RestoreCryptoKeyVersionRequest: Request message for
  915. // KeyManagementService.RestoreCryptoKeyVersion.
  916. type RestoreCryptoKeyVersionRequest struct {
  917. }
  918. // SetIamPolicyRequest: Request message for `SetIamPolicy` method.
  919. type SetIamPolicyRequest struct {
  920. // Policy: REQUIRED: The complete policy to be applied to the
  921. // `resource`. The size of
  922. // the policy is limited to a few 10s of KB. An empty policy is a
  923. // valid policy but certain Cloud Platform services (such as
  924. // Projects)
  925. // might reject them.
  926. Policy *Policy `json:"policy,omitempty"`
  927. // UpdateMask: OPTIONAL: A FieldMask specifying which fields of the
  928. // policy to modify. Only
  929. // the fields in the mask will be modified. If no mask is provided,
  930. // the
  931. // following default mask is used:
  932. // paths: "bindings, etag"
  933. // This field is only used by Cloud IAM.
  934. UpdateMask string `json:"updateMask,omitempty"`
  935. // ForceSendFields is a list of field names (e.g. "Policy") to
  936. // unconditionally include in API requests. By default, fields with
  937. // empty values are omitted from API requests. However, any non-pointer,
  938. // non-interface field appearing in ForceSendFields will be sent to the
  939. // server regardless of whether the field is empty or not. This may be
  940. // used to include empty fields in Patch requests.
  941. ForceSendFields []string `json:"-"`
  942. // NullFields is a list of field names (e.g. "Policy") to include in API
  943. // requests with the JSON null value. By default, fields with empty
  944. // values are omitted from API requests. However, any field with an
  945. // empty value appearing in NullFields will be sent to the server as
  946. // null. It is an error if a field in this list has a non-empty value.
  947. // This may be used to include null fields in Patch requests.
  948. NullFields []string `json:"-"`
  949. }
  950. func (s *SetIamPolicyRequest) MarshalJSON() ([]byte, error) {
  951. type NoMethod SetIamPolicyRequest
  952. raw := NoMethod(*s)
  953. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  954. }
  955. // TestIamPermissionsRequest: Request message for `TestIamPermissions`
  956. // method.
  957. type TestIamPermissionsRequest struct {
  958. // Permissions: The set of permissions to check for the `resource`.
  959. // Permissions with
  960. // wildcards (such as '*' or 'storage.*') are not allowed. For
  961. // more
  962. // information see
  963. // [IAM
  964. // Overview](https://cloud.google.com/iam/docs/overview#permissions).
  965. Permissions []string `json:"permissions,omitempty"`
  966. // ForceSendFields is a list of field names (e.g. "Permissions") to
  967. // unconditionally include in API requests. By default, fields with
  968. // empty values are omitted from API requests. However, any non-pointer,
  969. // non-interface field appearing in ForceSendFields will be sent to the
  970. // server regardless of whether the field is empty or not. This may be
  971. // used to include empty fields in Patch requests.
  972. ForceSendFields []string `json:"-"`
  973. // NullFields is a list of field names (e.g. "Permissions") to include
  974. // in API requests with the JSON null value. By default, fields with
  975. // empty values are omitted from API requests. However, any field with
  976. // an empty value appearing in NullFields will be sent to the server as
  977. // null. It is an error if a field in this list has a non-empty value.
  978. // This may be used to include null fields in Patch requests.
  979. NullFields []string `json:"-"`
  980. }
  981. func (s *TestIamPermissionsRequest) MarshalJSON() ([]byte, error) {
  982. type NoMethod TestIamPermissionsRequest
  983. raw := NoMethod(*s)
  984. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  985. }
  986. // TestIamPermissionsResponse: Response message for `TestIamPermissions`
  987. // method.
  988. type TestIamPermissionsResponse struct {
  989. // Permissions: A subset of `TestPermissionsRequest.permissions` that
  990. // the caller is
  991. // allowed.
  992. Permissions []string `json:"permissions,omitempty"`
  993. // ServerResponse contains the HTTP response code and headers from the
  994. // server.
  995. googleapi.ServerResponse `json:"-"`
  996. // ForceSendFields is a list of field names (e.g. "Permissions") to
  997. // unconditionally include in API requests. By default, fields with
  998. // empty values are omitted from API requests. However, any non-pointer,
  999. // non-interface field appearing in ForceSendFields will be sent to the
  1000. // server regardless of whether the field is empty or not. This may be
  1001. // used to include empty fields in Patch requests.
  1002. ForceSendFields []string `json:"-"`
  1003. // NullFields is a list of field names (e.g. "Permissions") to include
  1004. // in API requests with the JSON null value. By default, fields with
  1005. // empty values are omitted from API requests. However, any field with
  1006. // an empty value appearing in NullFields will be sent to the server as
  1007. // null. It is an error if a field in this list has a non-empty value.
  1008. // This may be used to include null fields in Patch requests.
  1009. NullFields []string `json:"-"`
  1010. }
  1011. func (s *TestIamPermissionsResponse) MarshalJSON() ([]byte, error) {
  1012. type NoMethod TestIamPermissionsResponse
  1013. raw := NoMethod(*s)
  1014. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1015. }
  1016. // UpdateCryptoKeyPrimaryVersionRequest: Request message for
  1017. // KeyManagementService.UpdateCryptoKeyPrimaryVersion.
  1018. type UpdateCryptoKeyPrimaryVersionRequest struct {
  1019. // CryptoKeyVersionId: The id of the child CryptoKeyVersion to use as
  1020. // primary.
  1021. CryptoKeyVersionId string `json:"cryptoKeyVersionId,omitempty"`
  1022. // ForceSendFields is a list of field names (e.g. "CryptoKeyVersionId")
  1023. // to unconditionally include in API requests. By default, fields with
  1024. // empty values are omitted from API requests. However, any non-pointer,
  1025. // non-interface field appearing in ForceSendFields will be sent to the
  1026. // server regardless of whether the field is empty or not. This may be
  1027. // used to include empty fields in Patch requests.
  1028. ForceSendFields []string `json:"-"`
  1029. // NullFields is a list of field names (e.g. "CryptoKeyVersionId") to
  1030. // include in API requests with the JSON null value. By default, fields
  1031. // with empty values are omitted from API requests. However, any field
  1032. // with an empty value appearing in NullFields will be sent to the
  1033. // server as null. It is an error if a field in this list has a
  1034. // non-empty value. This may be used to include null fields in Patch
  1035. // requests.
  1036. NullFields []string `json:"-"`
  1037. }
  1038. func (s *UpdateCryptoKeyPrimaryVersionRequest) MarshalJSON() ([]byte, error) {
  1039. type NoMethod UpdateCryptoKeyPrimaryVersionRequest
  1040. raw := NoMethod(*s)
  1041. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  1042. }
  1043. // method id "cloudkms.projects.locations.get":
  1044. type ProjectsLocationsGetCall struct {
  1045. s *Service
  1046. name string
  1047. urlParams_ gensupport.URLParams
  1048. ifNoneMatch_ string
  1049. ctx_ context.Context
  1050. header_ http.Header
  1051. }
  1052. // Get: Gets information about a location.
  1053. func (r *ProjectsLocationsService) Get(name string) *ProjectsLocationsGetCall {
  1054. c := &ProjectsLocationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1055. c.name = name
  1056. return c
  1057. }
  1058. // Fields allows partial responses to be retrieved. See
  1059. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1060. // for more information.
  1061. func (c *ProjectsLocationsGetCall) Fields(s ...googleapi.Field) *ProjectsLocationsGetCall {
  1062. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1063. return c
  1064. }
  1065. // IfNoneMatch sets the optional parameter which makes the operation
  1066. // fail if the object's ETag matches the given value. This is useful for
  1067. // getting updates only after the object has changed since the last
  1068. // request. Use googleapi.IsNotModified to check whether the response
  1069. // error from Do is the result of In-None-Match.
  1070. func (c *ProjectsLocationsGetCall) IfNoneMatch(entityTag string) *ProjectsLocationsGetCall {
  1071. c.ifNoneMatch_ = entityTag
  1072. return c
  1073. }
  1074. // Context sets the context to be used in this call's Do method. Any
  1075. // pending HTTP request will be aborted if the provided context is
  1076. // canceled.
  1077. func (c *ProjectsLocationsGetCall) Context(ctx context.Context) *ProjectsLocationsGetCall {
  1078. c.ctx_ = ctx
  1079. return c
  1080. }
  1081. // Header returns an http.Header that can be modified by the caller to
  1082. // add HTTP headers to the request.
  1083. func (c *ProjectsLocationsGetCall) Header() http.Header {
  1084. if c.header_ == nil {
  1085. c.header_ = make(http.Header)
  1086. }
  1087. return c.header_
  1088. }
  1089. func (c *ProjectsLocationsGetCall) doRequest(alt string) (*http.Response, error) {
  1090. reqHeaders := make(http.Header)
  1091. for k, v := range c.header_ {
  1092. reqHeaders[k] = v
  1093. }
  1094. reqHeaders.Set("User-Agent", c.s.userAgent())
  1095. if c.ifNoneMatch_ != "" {
  1096. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1097. }
  1098. var body io.Reader = nil
  1099. c.urlParams_.Set("alt", alt)
  1100. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  1101. urls += "?" + c.urlParams_.Encode()
  1102. req, _ := http.NewRequest("GET", urls, body)
  1103. req.Header = reqHeaders
  1104. googleapi.Expand(req.URL, map[string]string{
  1105. "name": c.name,
  1106. })
  1107. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1108. }
  1109. // Do executes the "cloudkms.projects.locations.get" call.
  1110. // Exactly one of *Location or error will be non-nil. Any non-2xx status
  1111. // code is an error. Response headers are in either
  1112. // *Location.ServerResponse.Header or (if a response was returned at
  1113. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1114. // to check whether the returned error was because
  1115. // http.StatusNotModified was returned.
  1116. func (c *ProjectsLocationsGetCall) Do(opts ...googleapi.CallOption) (*Location, error) {
  1117. gensupport.SetOptions(c.urlParams_, opts...)
  1118. res, err := c.doRequest("json")
  1119. if res != nil && res.StatusCode == http.StatusNotModified {
  1120. if res.Body != nil {
  1121. res.Body.Close()
  1122. }
  1123. return nil, &googleapi.Error{
  1124. Code: res.StatusCode,
  1125. Header: res.Header,
  1126. }
  1127. }
  1128. if err != nil {
  1129. return nil, err
  1130. }
  1131. defer googleapi.CloseBody(res)
  1132. if err := googleapi.CheckResponse(res); err != nil {
  1133. return nil, err
  1134. }
  1135. ret := &Location{
  1136. ServerResponse: googleapi.ServerResponse{
  1137. Header: res.Header,
  1138. HTTPStatusCode: res.StatusCode,
  1139. },
  1140. }
  1141. target := &ret
  1142. if err := gensupport.DecodeResponse(target, res); err != nil {
  1143. return nil, err
  1144. }
  1145. return ret, nil
  1146. // {
  1147. // "description": "Gets information about a location.",
  1148. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}",
  1149. // "httpMethod": "GET",
  1150. // "id": "cloudkms.projects.locations.get",
  1151. // "parameterOrder": [
  1152. // "name"
  1153. // ],
  1154. // "parameters": {
  1155. // "name": {
  1156. // "description": "Resource name for the location.",
  1157. // "location": "path",
  1158. // "pattern": "^projects/[^/]+/locations/[^/]+$",
  1159. // "required": true,
  1160. // "type": "string"
  1161. // }
  1162. // },
  1163. // "path": "v1/{+name}",
  1164. // "response": {
  1165. // "$ref": "Location"
  1166. // },
  1167. // "scopes": [
  1168. // "https://www.googleapis.com/auth/cloud-platform"
  1169. // ]
  1170. // }
  1171. }
  1172. // method id "cloudkms.projects.locations.list":
  1173. type ProjectsLocationsListCall struct {
  1174. s *Service
  1175. name string
  1176. urlParams_ gensupport.URLParams
  1177. ifNoneMatch_ string
  1178. ctx_ context.Context
  1179. header_ http.Header
  1180. }
  1181. // List: Lists information about the supported locations for this
  1182. // service.
  1183. func (r *ProjectsLocationsService) List(name string) *ProjectsLocationsListCall {
  1184. c := &ProjectsLocationsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1185. c.name = name
  1186. return c
  1187. }
  1188. // Filter sets the optional parameter "filter": The standard list
  1189. // filter.
  1190. func (c *ProjectsLocationsListCall) Filter(filter string) *ProjectsLocationsListCall {
  1191. c.urlParams_.Set("filter", filter)
  1192. return c
  1193. }
  1194. // PageSize sets the optional parameter "pageSize": The standard list
  1195. // page size.
  1196. func (c *ProjectsLocationsListCall) PageSize(pageSize int64) *ProjectsLocationsListCall {
  1197. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  1198. return c
  1199. }
  1200. // PageToken sets the optional parameter "pageToken": The standard list
  1201. // page token.
  1202. func (c *ProjectsLocationsListCall) PageToken(pageToken string) *ProjectsLocationsListCall {
  1203. c.urlParams_.Set("pageToken", pageToken)
  1204. return c
  1205. }
  1206. // Fields allows partial responses to be retrieved. See
  1207. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1208. // for more information.
  1209. func (c *ProjectsLocationsListCall) Fields(s ...googleapi.Field) *ProjectsLocationsListCall {
  1210. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1211. return c
  1212. }
  1213. // IfNoneMatch sets the optional parameter which makes the operation
  1214. // fail if the object's ETag matches the given value. This is useful for
  1215. // getting updates only after the object has changed since the last
  1216. // request. Use googleapi.IsNotModified to check whether the response
  1217. // error from Do is the result of In-None-Match.
  1218. func (c *ProjectsLocationsListCall) IfNoneMatch(entityTag string) *ProjectsLocationsListCall {
  1219. c.ifNoneMatch_ = entityTag
  1220. return c
  1221. }
  1222. // Context sets the context to be used in this call's Do method. Any
  1223. // pending HTTP request will be aborted if the provided context is
  1224. // canceled.
  1225. func (c *ProjectsLocationsListCall) Context(ctx context.Context) *ProjectsLocationsListCall {
  1226. c.ctx_ = ctx
  1227. return c
  1228. }
  1229. // Header returns an http.Header that can be modified by the caller to
  1230. // add HTTP headers to the request.
  1231. func (c *ProjectsLocationsListCall) Header() http.Header {
  1232. if c.header_ == nil {
  1233. c.header_ = make(http.Header)
  1234. }
  1235. return c.header_
  1236. }
  1237. func (c *ProjectsLocationsListCall) doRequest(alt string) (*http.Response, error) {
  1238. reqHeaders := make(http.Header)
  1239. for k, v := range c.header_ {
  1240. reqHeaders[k] = v
  1241. }
  1242. reqHeaders.Set("User-Agent", c.s.userAgent())
  1243. if c.ifNoneMatch_ != "" {
  1244. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1245. }
  1246. var body io.Reader = nil
  1247. c.urlParams_.Set("alt", alt)
  1248. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}/locations")
  1249. urls += "?" + c.urlParams_.Encode()
  1250. req, _ := http.NewRequest("GET", urls, body)
  1251. req.Header = reqHeaders
  1252. googleapi.Expand(req.URL, map[string]string{
  1253. "name": c.name,
  1254. })
  1255. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1256. }
  1257. // Do executes the "cloudkms.projects.locations.list" call.
  1258. // Exactly one of *ListLocationsResponse or error will be non-nil. Any
  1259. // non-2xx status code is an error. Response headers are in either
  1260. // *ListLocationsResponse.ServerResponse.Header or (if a response was
  1261. // returned at all) in error.(*googleapi.Error).Header. Use
  1262. // googleapi.IsNotModified to check whether the returned error was
  1263. // because http.StatusNotModified was returned.
  1264. func (c *ProjectsLocationsListCall) Do(opts ...googleapi.CallOption) (*ListLocationsResponse, error) {
  1265. gensupport.SetOptions(c.urlParams_, opts...)
  1266. res, err := c.doRequest("json")
  1267. if res != nil && res.StatusCode == http.StatusNotModified {
  1268. if res.Body != nil {
  1269. res.Body.Close()
  1270. }
  1271. return nil, &googleapi.Error{
  1272. Code: res.StatusCode,
  1273. Header: res.Header,
  1274. }
  1275. }
  1276. if err != nil {
  1277. return nil, err
  1278. }
  1279. defer googleapi.CloseBody(res)
  1280. if err := googleapi.CheckResponse(res); err != nil {
  1281. return nil, err
  1282. }
  1283. ret := &ListLocationsResponse{
  1284. ServerResponse: googleapi.ServerResponse{
  1285. Header: res.Header,
  1286. HTTPStatusCode: res.StatusCode,
  1287. },
  1288. }
  1289. target := &ret
  1290. if err := gensupport.DecodeResponse(target, res); err != nil {
  1291. return nil, err
  1292. }
  1293. return ret, nil
  1294. // {
  1295. // "description": "Lists information about the supported locations for this service.",
  1296. // "flatPath": "v1/projects/{projectsId}/locations",
  1297. // "httpMethod": "GET",
  1298. // "id": "cloudkms.projects.locations.list",
  1299. // "parameterOrder": [
  1300. // "name"
  1301. // ],
  1302. // "parameters": {
  1303. // "filter": {
  1304. // "description": "The standard list filter.",
  1305. // "location": "query",
  1306. // "type": "string"
  1307. // },
  1308. // "name": {
  1309. // "description": "The resource that owns the locations collection, if applicable.",
  1310. // "location": "path",
  1311. // "pattern": "^projects/[^/]+$",
  1312. // "required": true,
  1313. // "type": "string"
  1314. // },
  1315. // "pageSize": {
  1316. // "description": "The standard list page size.",
  1317. // "format": "int32",
  1318. // "location": "query",
  1319. // "type": "integer"
  1320. // },
  1321. // "pageToken": {
  1322. // "description": "The standard list page token.",
  1323. // "location": "query",
  1324. // "type": "string"
  1325. // }
  1326. // },
  1327. // "path": "v1/{+name}/locations",
  1328. // "response": {
  1329. // "$ref": "ListLocationsResponse"
  1330. // },
  1331. // "scopes": [
  1332. // "https://www.googleapis.com/auth/cloud-platform"
  1333. // ]
  1334. // }
  1335. }
  1336. // Pages invokes f for each page of results.
  1337. // A non-nil error returned from f will halt the iteration.
  1338. // The provided context supersedes any context provided to the Context method.
  1339. func (c *ProjectsLocationsListCall) Pages(ctx context.Context, f func(*ListLocationsResponse) error) error {
  1340. c.ctx_ = ctx
  1341. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1342. for {
  1343. x, err := c.Do()
  1344. if err != nil {
  1345. return err
  1346. }
  1347. if err := f(x); err != nil {
  1348. return err
  1349. }
  1350. if x.NextPageToken == "" {
  1351. return nil
  1352. }
  1353. c.PageToken(x.NextPageToken)
  1354. }
  1355. }
  1356. // method id "cloudkms.projects.locations.keyRings.create":
  1357. type ProjectsLocationsKeyRingsCreateCall struct {
  1358. s *Service
  1359. parent string
  1360. keyring *KeyRing
  1361. urlParams_ gensupport.URLParams
  1362. ctx_ context.Context
  1363. header_ http.Header
  1364. }
  1365. // Create: Create a new KeyRing in a given Project and Location.
  1366. func (r *ProjectsLocationsKeyRingsService) Create(parent string, keyring *KeyRing) *ProjectsLocationsKeyRingsCreateCall {
  1367. c := &ProjectsLocationsKeyRingsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1368. c.parent = parent
  1369. c.keyring = keyring
  1370. return c
  1371. }
  1372. // KeyRingId sets the optional parameter "keyRingId": Required. It must
  1373. // be unique within a location and match the regular
  1374. // expression `[a-zA-Z0-9_-]{1,63}`
  1375. func (c *ProjectsLocationsKeyRingsCreateCall) KeyRingId(keyRingId string) *ProjectsLocationsKeyRingsCreateCall {
  1376. c.urlParams_.Set("keyRingId", keyRingId)
  1377. return c
  1378. }
  1379. // Fields allows partial responses to be retrieved. See
  1380. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1381. // for more information.
  1382. func (c *ProjectsLocationsKeyRingsCreateCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsCreateCall {
  1383. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1384. return c
  1385. }
  1386. // Context sets the context to be used in this call's Do method. Any
  1387. // pending HTTP request will be aborted if the provided context is
  1388. // canceled.
  1389. func (c *ProjectsLocationsKeyRingsCreateCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsCreateCall {
  1390. c.ctx_ = ctx
  1391. return c
  1392. }
  1393. // Header returns an http.Header that can be modified by the caller to
  1394. // add HTTP headers to the request.
  1395. func (c *ProjectsLocationsKeyRingsCreateCall) Header() http.Header {
  1396. if c.header_ == nil {
  1397. c.header_ = make(http.Header)
  1398. }
  1399. return c.header_
  1400. }
  1401. func (c *ProjectsLocationsKeyRingsCreateCall) doRequest(alt string) (*http.Response, error) {
  1402. reqHeaders := make(http.Header)
  1403. for k, v := range c.header_ {
  1404. reqHeaders[k] = v
  1405. }
  1406. reqHeaders.Set("User-Agent", c.s.userAgent())
  1407. var body io.Reader = nil
  1408. body, err := googleapi.WithoutDataWrapper.JSONReader(c.keyring)
  1409. if err != nil {
  1410. return nil, err
  1411. }
  1412. reqHeaders.Set("Content-Type", "application/json")
  1413. c.urlParams_.Set("alt", alt)
  1414. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/keyRings")
  1415. urls += "?" + c.urlParams_.Encode()
  1416. req, _ := http.NewRequest("POST", urls, body)
  1417. req.Header = reqHeaders
  1418. googleapi.Expand(req.URL, map[string]string{
  1419. "parent": c.parent,
  1420. })
  1421. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1422. }
  1423. // Do executes the "cloudkms.projects.locations.keyRings.create" call.
  1424. // Exactly one of *KeyRing or error will be non-nil. Any non-2xx status
  1425. // code is an error. Response headers are in either
  1426. // *KeyRing.ServerResponse.Header or (if a response was returned at all)
  1427. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1428. // check whether the returned error was because http.StatusNotModified
  1429. // was returned.
  1430. func (c *ProjectsLocationsKeyRingsCreateCall) Do(opts ...googleapi.CallOption) (*KeyRing, error) {
  1431. gensupport.SetOptions(c.urlParams_, opts...)
  1432. res, err := c.doRequest("json")
  1433. if res != nil && res.StatusCode == http.StatusNotModified {
  1434. if res.Body != nil {
  1435. res.Body.Close()
  1436. }
  1437. return nil, &googleapi.Error{
  1438. Code: res.StatusCode,
  1439. Header: res.Header,
  1440. }
  1441. }
  1442. if err != nil {
  1443. return nil, err
  1444. }
  1445. defer googleapi.CloseBody(res)
  1446. if err := googleapi.CheckResponse(res); err != nil {
  1447. return nil, err
  1448. }
  1449. ret := &KeyRing{
  1450. ServerResponse: googleapi.ServerResponse{
  1451. Header: res.Header,
  1452. HTTPStatusCode: res.StatusCode,
  1453. },
  1454. }
  1455. target := &ret
  1456. if err := gensupport.DecodeResponse(target, res); err != nil {
  1457. return nil, err
  1458. }
  1459. return ret, nil
  1460. // {
  1461. // "description": "Create a new KeyRing in a given Project and Location.",
  1462. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings",
  1463. // "httpMethod": "POST",
  1464. // "id": "cloudkms.projects.locations.keyRings.create",
  1465. // "parameterOrder": [
  1466. // "parent"
  1467. // ],
  1468. // "parameters": {
  1469. // "keyRingId": {
  1470. // "description": "Required. It must be unique within a location and match the regular\nexpression `[a-zA-Z0-9_-]{1,63}`",
  1471. // "location": "query",
  1472. // "type": "string"
  1473. // },
  1474. // "parent": {
  1475. // "description": "Required. The resource name of the location associated with the\nKeyRings, in the format `projects/*/locations/*`.",
  1476. // "location": "path",
  1477. // "pattern": "^projects/[^/]+/locations/[^/]+$",
  1478. // "required": true,
  1479. // "type": "string"
  1480. // }
  1481. // },
  1482. // "path": "v1/{+parent}/keyRings",
  1483. // "request": {
  1484. // "$ref": "KeyRing"
  1485. // },
  1486. // "response": {
  1487. // "$ref": "KeyRing"
  1488. // },
  1489. // "scopes": [
  1490. // "https://www.googleapis.com/auth/cloud-platform"
  1491. // ]
  1492. // }
  1493. }
  1494. // method id "cloudkms.projects.locations.keyRings.get":
  1495. type ProjectsLocationsKeyRingsGetCall struct {
  1496. s *Service
  1497. name string
  1498. urlParams_ gensupport.URLParams
  1499. ifNoneMatch_ string
  1500. ctx_ context.Context
  1501. header_ http.Header
  1502. }
  1503. // Get: Returns metadata for a given KeyRing.
  1504. func (r *ProjectsLocationsKeyRingsService) Get(name string) *ProjectsLocationsKeyRingsGetCall {
  1505. c := &ProjectsLocationsKeyRingsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1506. c.name = name
  1507. return c
  1508. }
  1509. // Fields allows partial responses to be retrieved. See
  1510. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1511. // for more information.
  1512. func (c *ProjectsLocationsKeyRingsGetCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsGetCall {
  1513. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1514. return c
  1515. }
  1516. // IfNoneMatch sets the optional parameter which makes the operation
  1517. // fail if the object's ETag matches the given value. This is useful for
  1518. // getting updates only after the object has changed since the last
  1519. // request. Use googleapi.IsNotModified to check whether the response
  1520. // error from Do is the result of In-None-Match.
  1521. func (c *ProjectsLocationsKeyRingsGetCall) IfNoneMatch(entityTag string) *ProjectsLocationsKeyRingsGetCall {
  1522. c.ifNoneMatch_ = entityTag
  1523. return c
  1524. }
  1525. // Context sets the context to be used in this call's Do method. Any
  1526. // pending HTTP request will be aborted if the provided context is
  1527. // canceled.
  1528. func (c *ProjectsLocationsKeyRingsGetCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsGetCall {
  1529. c.ctx_ = ctx
  1530. return c
  1531. }
  1532. // Header returns an http.Header that can be modified by the caller to
  1533. // add HTTP headers to the request.
  1534. func (c *ProjectsLocationsKeyRingsGetCall) Header() http.Header {
  1535. if c.header_ == nil {
  1536. c.header_ = make(http.Header)
  1537. }
  1538. return c.header_
  1539. }
  1540. func (c *ProjectsLocationsKeyRingsGetCall) doRequest(alt string) (*http.Response, error) {
  1541. reqHeaders := make(http.Header)
  1542. for k, v := range c.header_ {
  1543. reqHeaders[k] = v
  1544. }
  1545. reqHeaders.Set("User-Agent", c.s.userAgent())
  1546. if c.ifNoneMatch_ != "" {
  1547. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1548. }
  1549. var body io.Reader = nil
  1550. c.urlParams_.Set("alt", alt)
  1551. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  1552. urls += "?" + c.urlParams_.Encode()
  1553. req, _ := http.NewRequest("GET", urls, body)
  1554. req.Header = reqHeaders
  1555. googleapi.Expand(req.URL, map[string]string{
  1556. "name": c.name,
  1557. })
  1558. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1559. }
  1560. // Do executes the "cloudkms.projects.locations.keyRings.get" call.
  1561. // Exactly one of *KeyRing or error will be non-nil. Any non-2xx status
  1562. // code is an error. Response headers are in either
  1563. // *KeyRing.ServerResponse.Header or (if a response was returned at all)
  1564. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1565. // check whether the returned error was because http.StatusNotModified
  1566. // was returned.
  1567. func (c *ProjectsLocationsKeyRingsGetCall) Do(opts ...googleapi.CallOption) (*KeyRing, error) {
  1568. gensupport.SetOptions(c.urlParams_, opts...)
  1569. res, err := c.doRequest("json")
  1570. if res != nil && res.StatusCode == http.StatusNotModified {
  1571. if res.Body != nil {
  1572. res.Body.Close()
  1573. }
  1574. return nil, &googleapi.Error{
  1575. Code: res.StatusCode,
  1576. Header: res.Header,
  1577. }
  1578. }
  1579. if err != nil {
  1580. return nil, err
  1581. }
  1582. defer googleapi.CloseBody(res)
  1583. if err := googleapi.CheckResponse(res); err != nil {
  1584. return nil, err
  1585. }
  1586. ret := &KeyRing{
  1587. ServerResponse: googleapi.ServerResponse{
  1588. Header: res.Header,
  1589. HTTPStatusCode: res.StatusCode,
  1590. },
  1591. }
  1592. target := &ret
  1593. if err := gensupport.DecodeResponse(target, res); err != nil {
  1594. return nil, err
  1595. }
  1596. return ret, nil
  1597. // {
  1598. // "description": "Returns metadata for a given KeyRing.",
  1599. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings/{keyRingsId}",
  1600. // "httpMethod": "GET",
  1601. // "id": "cloudkms.projects.locations.keyRings.get",
  1602. // "parameterOrder": [
  1603. // "name"
  1604. // ],
  1605. // "parameters": {
  1606. // "name": {
  1607. // "description": "The name of the KeyRing to get.",
  1608. // "location": "path",
  1609. // "pattern": "^projects/[^/]+/locations/[^/]+/keyRings/[^/]+$",
  1610. // "required": true,
  1611. // "type": "string"
  1612. // }
  1613. // },
  1614. // "path": "v1/{+name}",
  1615. // "response": {
  1616. // "$ref": "KeyRing"
  1617. // },
  1618. // "scopes": [
  1619. // "https://www.googleapis.com/auth/cloud-platform"
  1620. // ]
  1621. // }
  1622. }
  1623. // method id "cloudkms.projects.locations.keyRings.getIamPolicy":
  1624. type ProjectsLocationsKeyRingsGetIamPolicyCall struct {
  1625. s *Service
  1626. resource string
  1627. urlParams_ gensupport.URLParams
  1628. ifNoneMatch_ string
  1629. ctx_ context.Context
  1630. header_ http.Header
  1631. }
  1632. // GetIamPolicy: Gets the access control policy for a resource.
  1633. // Returns an empty policy if the resource exists and does not have a
  1634. // policy
  1635. // set.
  1636. func (r *ProjectsLocationsKeyRingsService) GetIamPolicy(resource string) *ProjectsLocationsKeyRingsGetIamPolicyCall {
  1637. c := &ProjectsLocationsKeyRingsGetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1638. c.resource = resource
  1639. return c
  1640. }
  1641. // Fields allows partial responses to be retrieved. See
  1642. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1643. // for more information.
  1644. func (c *ProjectsLocationsKeyRingsGetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsGetIamPolicyCall {
  1645. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1646. return c
  1647. }
  1648. // IfNoneMatch sets the optional parameter which makes the operation
  1649. // fail if the object's ETag matches the given value. This is useful for
  1650. // getting updates only after the object has changed since the last
  1651. // request. Use googleapi.IsNotModified to check whether the response
  1652. // error from Do is the result of In-None-Match.
  1653. func (c *ProjectsLocationsKeyRingsGetIamPolicyCall) IfNoneMatch(entityTag string) *ProjectsLocationsKeyRingsGetIamPolicyCall {
  1654. c.ifNoneMatch_ = entityTag
  1655. return c
  1656. }
  1657. // Context sets the context to be used in this call's Do method. Any
  1658. // pending HTTP request will be aborted if the provided context is
  1659. // canceled.
  1660. func (c *ProjectsLocationsKeyRingsGetIamPolicyCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsGetIamPolicyCall {
  1661. c.ctx_ = ctx
  1662. return c
  1663. }
  1664. // Header returns an http.Header that can be modified by the caller to
  1665. // add HTTP headers to the request.
  1666. func (c *ProjectsLocationsKeyRingsGetIamPolicyCall) Header() http.Header {
  1667. if c.header_ == nil {
  1668. c.header_ = make(http.Header)
  1669. }
  1670. return c.header_
  1671. }
  1672. func (c *ProjectsLocationsKeyRingsGetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  1673. reqHeaders := make(http.Header)
  1674. for k, v := range c.header_ {
  1675. reqHeaders[k] = v
  1676. }
  1677. reqHeaders.Set("User-Agent", c.s.userAgent())
  1678. if c.ifNoneMatch_ != "" {
  1679. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1680. }
  1681. var body io.Reader = nil
  1682. c.urlParams_.Set("alt", alt)
  1683. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+resource}:getIamPolicy")
  1684. urls += "?" + c.urlParams_.Encode()
  1685. req, _ := http.NewRequest("GET", urls, body)
  1686. req.Header = reqHeaders
  1687. googleapi.Expand(req.URL, map[string]string{
  1688. "resource": c.resource,
  1689. })
  1690. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1691. }
  1692. // Do executes the "cloudkms.projects.locations.keyRings.getIamPolicy" call.
  1693. // Exactly one of *Policy or error will be non-nil. Any non-2xx status
  1694. // code is an error. Response headers are in either
  1695. // *Policy.ServerResponse.Header or (if a response was returned at all)
  1696. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1697. // check whether the returned error was because http.StatusNotModified
  1698. // was returned.
  1699. func (c *ProjectsLocationsKeyRingsGetIamPolicyCall) Do(opts ...googleapi.CallOption) (*Policy, error) {
  1700. gensupport.SetOptions(c.urlParams_, opts...)
  1701. res, err := c.doRequest("json")
  1702. if res != nil && res.StatusCode == http.StatusNotModified {
  1703. if res.Body != nil {
  1704. res.Body.Close()
  1705. }
  1706. return nil, &googleapi.Error{
  1707. Code: res.StatusCode,
  1708. Header: res.Header,
  1709. }
  1710. }
  1711. if err != nil {
  1712. return nil, err
  1713. }
  1714. defer googleapi.CloseBody(res)
  1715. if err := googleapi.CheckResponse(res); err != nil {
  1716. return nil, err
  1717. }
  1718. ret := &Policy{
  1719. ServerResponse: googleapi.ServerResponse{
  1720. Header: res.Header,
  1721. HTTPStatusCode: res.StatusCode,
  1722. },
  1723. }
  1724. target := &ret
  1725. if err := gensupport.DecodeResponse(target, res); err != nil {
  1726. return nil, err
  1727. }
  1728. return ret, nil
  1729. // {
  1730. // "description": "Gets the access control policy for a resource.\nReturns an empty policy if the resource exists and does not have a policy\nset.",
  1731. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings/{keyRingsId}:getIamPolicy",
  1732. // "httpMethod": "GET",
  1733. // "id": "cloudkms.projects.locations.keyRings.getIamPolicy",
  1734. // "parameterOrder": [
  1735. // "resource"
  1736. // ],
  1737. // "parameters": {
  1738. // "resource": {
  1739. // "description": "REQUIRED: The resource for which the policy is being requested.\nSee the operation documentation for the appropriate value for this field.",
  1740. // "location": "path",
  1741. // "pattern": "^projects/[^/]+/locations/[^/]+/keyRings/[^/]+$",
  1742. // "required": true,
  1743. // "type": "string"
  1744. // }
  1745. // },
  1746. // "path": "v1/{+resource}:getIamPolicy",
  1747. // "response": {
  1748. // "$ref": "Policy"
  1749. // },
  1750. // "scopes": [
  1751. // "https://www.googleapis.com/auth/cloud-platform"
  1752. // ]
  1753. // }
  1754. }
  1755. // method id "cloudkms.projects.locations.keyRings.list":
  1756. type ProjectsLocationsKeyRingsListCall struct {
  1757. s *Service
  1758. parent string
  1759. urlParams_ gensupport.URLParams
  1760. ifNoneMatch_ string
  1761. ctx_ context.Context
  1762. header_ http.Header
  1763. }
  1764. // List: Lists KeyRings.
  1765. func (r *ProjectsLocationsKeyRingsService) List(parent string) *ProjectsLocationsKeyRingsListCall {
  1766. c := &ProjectsLocationsKeyRingsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1767. c.parent = parent
  1768. return c
  1769. }
  1770. // PageSize sets the optional parameter "pageSize": Optional limit on
  1771. // the number of KeyRings to include in the
  1772. // response. Further KeyRings can subsequently be obtained by
  1773. // including the ListKeyRingsResponse.next_page_token in a
  1774. // subsequent
  1775. // request. If unspecified, the server will pick an appropriate
  1776. // default.
  1777. func (c *ProjectsLocationsKeyRingsListCall) PageSize(pageSize int64) *ProjectsLocationsKeyRingsListCall {
  1778. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  1779. return c
  1780. }
  1781. // PageToken sets the optional parameter "pageToken": Optional
  1782. // pagination token, returned earlier
  1783. // via
  1784. // ListKeyRingsResponse.next_page_token.
  1785. func (c *ProjectsLocationsKeyRingsListCall) PageToken(pageToken string) *ProjectsLocationsKeyRingsListCall {
  1786. c.urlParams_.Set("pageToken", pageToken)
  1787. return c
  1788. }
  1789. // Fields allows partial responses to be retrieved. See
  1790. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1791. // for more information.
  1792. func (c *ProjectsLocationsKeyRingsListCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsListCall {
  1793. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1794. return c
  1795. }
  1796. // IfNoneMatch sets the optional parameter which makes the operation
  1797. // fail if the object's ETag matches the given value. This is useful for
  1798. // getting updates only after the object has changed since the last
  1799. // request. Use googleapi.IsNotModified to check whether the response
  1800. // error from Do is the result of In-None-Match.
  1801. func (c *ProjectsLocationsKeyRingsListCall) IfNoneMatch(entityTag string) *ProjectsLocationsKeyRingsListCall {
  1802. c.ifNoneMatch_ = entityTag
  1803. return c
  1804. }
  1805. // Context sets the context to be used in this call's Do method. Any
  1806. // pending HTTP request will be aborted if the provided context is
  1807. // canceled.
  1808. func (c *ProjectsLocationsKeyRingsListCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsListCall {
  1809. c.ctx_ = ctx
  1810. return c
  1811. }
  1812. // Header returns an http.Header that can be modified by the caller to
  1813. // add HTTP headers to the request.
  1814. func (c *ProjectsLocationsKeyRingsListCall) Header() http.Header {
  1815. if c.header_ == nil {
  1816. c.header_ = make(http.Header)
  1817. }
  1818. return c.header_
  1819. }
  1820. func (c *ProjectsLocationsKeyRingsListCall) doRequest(alt string) (*http.Response, error) {
  1821. reqHeaders := make(http.Header)
  1822. for k, v := range c.header_ {
  1823. reqHeaders[k] = v
  1824. }
  1825. reqHeaders.Set("User-Agent", c.s.userAgent())
  1826. if c.ifNoneMatch_ != "" {
  1827. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1828. }
  1829. var body io.Reader = nil
  1830. c.urlParams_.Set("alt", alt)
  1831. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/keyRings")
  1832. urls += "?" + c.urlParams_.Encode()
  1833. req, _ := http.NewRequest("GET", urls, body)
  1834. req.Header = reqHeaders
  1835. googleapi.Expand(req.URL, map[string]string{
  1836. "parent": c.parent,
  1837. })
  1838. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1839. }
  1840. // Do executes the "cloudkms.projects.locations.keyRings.list" call.
  1841. // Exactly one of *ListKeyRingsResponse or error will be non-nil. Any
  1842. // non-2xx status code is an error. Response headers are in either
  1843. // *ListKeyRingsResponse.ServerResponse.Header or (if a response was
  1844. // returned at all) in error.(*googleapi.Error).Header. Use
  1845. // googleapi.IsNotModified to check whether the returned error was
  1846. // because http.StatusNotModified was returned.
  1847. func (c *ProjectsLocationsKeyRingsListCall) Do(opts ...googleapi.CallOption) (*ListKeyRingsResponse, error) {
  1848. gensupport.SetOptions(c.urlParams_, opts...)
  1849. res, err := c.doRequest("json")
  1850. if res != nil && res.StatusCode == http.StatusNotModified {
  1851. if res.Body != nil {
  1852. res.Body.Close()
  1853. }
  1854. return nil, &googleapi.Error{
  1855. Code: res.StatusCode,
  1856. Header: res.Header,
  1857. }
  1858. }
  1859. if err != nil {
  1860. return nil, err
  1861. }
  1862. defer googleapi.CloseBody(res)
  1863. if err := googleapi.CheckResponse(res); err != nil {
  1864. return nil, err
  1865. }
  1866. ret := &ListKeyRingsResponse{
  1867. ServerResponse: googleapi.ServerResponse{
  1868. Header: res.Header,
  1869. HTTPStatusCode: res.StatusCode,
  1870. },
  1871. }
  1872. target := &ret
  1873. if err := gensupport.DecodeResponse(target, res); err != nil {
  1874. return nil, err
  1875. }
  1876. return ret, nil
  1877. // {
  1878. // "description": "Lists KeyRings.",
  1879. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings",
  1880. // "httpMethod": "GET",
  1881. // "id": "cloudkms.projects.locations.keyRings.list",
  1882. // "parameterOrder": [
  1883. // "parent"
  1884. // ],
  1885. // "parameters": {
  1886. // "pageSize": {
  1887. // "description": "Optional limit on the number of KeyRings to include in the\nresponse. Further KeyRings can subsequently be obtained by\nincluding the ListKeyRingsResponse.next_page_token in a subsequent\nrequest. If unspecified, the server will pick an appropriate default.",
  1888. // "format": "int32",
  1889. // "location": "query",
  1890. // "type": "integer"
  1891. // },
  1892. // "pageToken": {
  1893. // "description": "Optional pagination token, returned earlier via\nListKeyRingsResponse.next_page_token.",
  1894. // "location": "query",
  1895. // "type": "string"
  1896. // },
  1897. // "parent": {
  1898. // "description": "Required. The resource name of the location associated with the\nKeyRings, in the format `projects/*/locations/*`.",
  1899. // "location": "path",
  1900. // "pattern": "^projects/[^/]+/locations/[^/]+$",
  1901. // "required": true,
  1902. // "type": "string"
  1903. // }
  1904. // },
  1905. // "path": "v1/{+parent}/keyRings",
  1906. // "response": {
  1907. // "$ref": "ListKeyRingsResponse"
  1908. // },
  1909. // "scopes": [
  1910. // "https://www.googleapis.com/auth/cloud-platform"
  1911. // ]
  1912. // }
  1913. }
  1914. // Pages invokes f for each page of results.
  1915. // A non-nil error returned from f will halt the iteration.
  1916. // The provided context supersedes any context provided to the Context method.
  1917. func (c *ProjectsLocationsKeyRingsListCall) Pages(ctx context.Context, f func(*ListKeyRingsResponse) error) error {
  1918. c.ctx_ = ctx
  1919. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1920. for {
  1921. x, err := c.Do()
  1922. if err != nil {
  1923. return err
  1924. }
  1925. if err := f(x); err != nil {
  1926. return err
  1927. }
  1928. if x.NextPageToken == "" {
  1929. return nil
  1930. }
  1931. c.PageToken(x.NextPageToken)
  1932. }
  1933. }
  1934. // method id "cloudkms.projects.locations.keyRings.setIamPolicy":
  1935. type ProjectsLocationsKeyRingsSetIamPolicyCall struct {
  1936. s *Service
  1937. resource string
  1938. setiampolicyrequest *SetIamPolicyRequest
  1939. urlParams_ gensupport.URLParams
  1940. ctx_ context.Context
  1941. header_ http.Header
  1942. }
  1943. // SetIamPolicy: Sets the access control policy on the specified
  1944. // resource. Replaces any
  1945. // existing policy.
  1946. func (r *ProjectsLocationsKeyRingsService) SetIamPolicy(resource string, setiampolicyrequest *SetIamPolicyRequest) *ProjectsLocationsKeyRingsSetIamPolicyCall {
  1947. c := &ProjectsLocationsKeyRingsSetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1948. c.resource = resource
  1949. c.setiampolicyrequest = setiampolicyrequest
  1950. return c
  1951. }
  1952. // Fields allows partial responses to be retrieved. See
  1953. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1954. // for more information.
  1955. func (c *ProjectsLocationsKeyRingsSetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsSetIamPolicyCall {
  1956. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1957. return c
  1958. }
  1959. // Context sets the context to be used in this call's Do method. Any
  1960. // pending HTTP request will be aborted if the provided context is
  1961. // canceled.
  1962. func (c *ProjectsLocationsKeyRingsSetIamPolicyCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsSetIamPolicyCall {
  1963. c.ctx_ = ctx
  1964. return c
  1965. }
  1966. // Header returns an http.Header that can be modified by the caller to
  1967. // add HTTP headers to the request.
  1968. func (c *ProjectsLocationsKeyRingsSetIamPolicyCall) Header() http.Header {
  1969. if c.header_ == nil {
  1970. c.header_ = make(http.Header)
  1971. }
  1972. return c.header_
  1973. }
  1974. func (c *ProjectsLocationsKeyRingsSetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  1975. reqHeaders := make(http.Header)
  1976. for k, v := range c.header_ {
  1977. reqHeaders[k] = v
  1978. }
  1979. reqHeaders.Set("User-Agent", c.s.userAgent())
  1980. var body io.Reader = nil
  1981. body, err := googleapi.WithoutDataWrapper.JSONReader(c.setiampolicyrequest)
  1982. if err != nil {
  1983. return nil, err
  1984. }
  1985. reqHeaders.Set("Content-Type", "application/json")
  1986. c.urlParams_.Set("alt", alt)
  1987. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+resource}:setIamPolicy")
  1988. urls += "?" + c.urlParams_.Encode()
  1989. req, _ := http.NewRequest("POST", urls, body)
  1990. req.Header = reqHeaders
  1991. googleapi.Expand(req.URL, map[string]string{
  1992. "resource": c.resource,
  1993. })
  1994. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1995. }
  1996. // Do executes the "cloudkms.projects.locations.keyRings.setIamPolicy" call.
  1997. // Exactly one of *Policy or error will be non-nil. Any non-2xx status
  1998. // code is an error. Response headers are in either
  1999. // *Policy.ServerResponse.Header or (if a response was returned at all)
  2000. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2001. // check whether the returned error was because http.StatusNotModified
  2002. // was returned.
  2003. func (c *ProjectsLocationsKeyRingsSetIamPolicyCall) Do(opts ...googleapi.CallOption) (*Policy, error) {
  2004. gensupport.SetOptions(c.urlParams_, opts...)
  2005. res, err := c.doRequest("json")
  2006. if res != nil && res.StatusCode == http.StatusNotModified {
  2007. if res.Body != nil {
  2008. res.Body.Close()
  2009. }
  2010. return nil, &googleapi.Error{
  2011. Code: res.StatusCode,
  2012. Header: res.Header,
  2013. }
  2014. }
  2015. if err != nil {
  2016. return nil, err
  2017. }
  2018. defer googleapi.CloseBody(res)
  2019. if err := googleapi.CheckResponse(res); err != nil {
  2020. return nil, err
  2021. }
  2022. ret := &Policy{
  2023. ServerResponse: googleapi.ServerResponse{
  2024. Header: res.Header,
  2025. HTTPStatusCode: res.StatusCode,
  2026. },
  2027. }
  2028. target := &ret
  2029. if err := gensupport.DecodeResponse(target, res); err != nil {
  2030. return nil, err
  2031. }
  2032. return ret, nil
  2033. // {
  2034. // "description": "Sets the access control policy on the specified resource. Replaces any\nexisting policy.",
  2035. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings/{keyRingsId}:setIamPolicy",
  2036. // "httpMethod": "POST",
  2037. // "id": "cloudkms.projects.locations.keyRings.setIamPolicy",
  2038. // "parameterOrder": [
  2039. // "resource"
  2040. // ],
  2041. // "parameters": {
  2042. // "resource": {
  2043. // "description": "REQUIRED: The resource for which the policy is being specified.\nSee the operation documentation for the appropriate value for this field.",
  2044. // "location": "path",
  2045. // "pattern": "^projects/[^/]+/locations/[^/]+/keyRings/[^/]+$",
  2046. // "required": true,
  2047. // "type": "string"
  2048. // }
  2049. // },
  2050. // "path": "v1/{+resource}:setIamPolicy",
  2051. // "request": {
  2052. // "$ref": "SetIamPolicyRequest"
  2053. // },
  2054. // "response": {
  2055. // "$ref": "Policy"
  2056. // },
  2057. // "scopes": [
  2058. // "https://www.googleapis.com/auth/cloud-platform"
  2059. // ]
  2060. // }
  2061. }
  2062. // method id "cloudkms.projects.locations.keyRings.testIamPermissions":
  2063. type ProjectsLocationsKeyRingsTestIamPermissionsCall struct {
  2064. s *Service
  2065. resource string
  2066. testiampermissionsrequest *TestIamPermissionsRequest
  2067. urlParams_ gensupport.URLParams
  2068. ctx_ context.Context
  2069. header_ http.Header
  2070. }
  2071. // TestIamPermissions: Returns permissions that a caller has on the
  2072. // specified resource.
  2073. // If the resource does not exist, this will return an empty set
  2074. // of
  2075. // permissions, not a NOT_FOUND error.
  2076. //
  2077. // Note: This operation is designed to be used for building
  2078. // permission-aware
  2079. // UIs and command-line tools, not for authorization checking. This
  2080. // operation
  2081. // may "fail open" without warning.
  2082. func (r *ProjectsLocationsKeyRingsService) TestIamPermissions(resource string, testiampermissionsrequest *TestIamPermissionsRequest) *ProjectsLocationsKeyRingsTestIamPermissionsCall {
  2083. c := &ProjectsLocationsKeyRingsTestIamPermissionsCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2084. c.resource = resource
  2085. c.testiampermissionsrequest = testiampermissionsrequest
  2086. return c
  2087. }
  2088. // Fields allows partial responses to be retrieved. See
  2089. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2090. // for more information.
  2091. func (c *ProjectsLocationsKeyRingsTestIamPermissionsCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsTestIamPermissionsCall {
  2092. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2093. return c
  2094. }
  2095. // Context sets the context to be used in this call's Do method. Any
  2096. // pending HTTP request will be aborted if the provided context is
  2097. // canceled.
  2098. func (c *ProjectsLocationsKeyRingsTestIamPermissionsCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsTestIamPermissionsCall {
  2099. c.ctx_ = ctx
  2100. return c
  2101. }
  2102. // Header returns an http.Header that can be modified by the caller to
  2103. // add HTTP headers to the request.
  2104. func (c *ProjectsLocationsKeyRingsTestIamPermissionsCall) Header() http.Header {
  2105. if c.header_ == nil {
  2106. c.header_ = make(http.Header)
  2107. }
  2108. return c.header_
  2109. }
  2110. func (c *ProjectsLocationsKeyRingsTestIamPermissionsCall) doRequest(alt string) (*http.Response, error) {
  2111. reqHeaders := make(http.Header)
  2112. for k, v := range c.header_ {
  2113. reqHeaders[k] = v
  2114. }
  2115. reqHeaders.Set("User-Agent", c.s.userAgent())
  2116. var body io.Reader = nil
  2117. body, err := googleapi.WithoutDataWrapper.JSONReader(c.testiampermissionsrequest)
  2118. if err != nil {
  2119. return nil, err
  2120. }
  2121. reqHeaders.Set("Content-Type", "application/json")
  2122. c.urlParams_.Set("alt", alt)
  2123. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+resource}:testIamPermissions")
  2124. urls += "?" + c.urlParams_.Encode()
  2125. req, _ := http.NewRequest("POST", urls, body)
  2126. req.Header = reqHeaders
  2127. googleapi.Expand(req.URL, map[string]string{
  2128. "resource": c.resource,
  2129. })
  2130. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2131. }
  2132. // Do executes the "cloudkms.projects.locations.keyRings.testIamPermissions" call.
  2133. // Exactly one of *TestIamPermissionsResponse or error will be non-nil.
  2134. // Any non-2xx status code is an error. Response headers are in either
  2135. // *TestIamPermissionsResponse.ServerResponse.Header or (if a response
  2136. // was returned at all) in error.(*googleapi.Error).Header. Use
  2137. // googleapi.IsNotModified to check whether the returned error was
  2138. // because http.StatusNotModified was returned.
  2139. func (c *ProjectsLocationsKeyRingsTestIamPermissionsCall) Do(opts ...googleapi.CallOption) (*TestIamPermissionsResponse, error) {
  2140. gensupport.SetOptions(c.urlParams_, opts...)
  2141. res, err := c.doRequest("json")
  2142. if res != nil && res.StatusCode == http.StatusNotModified {
  2143. if res.Body != nil {
  2144. res.Body.Close()
  2145. }
  2146. return nil, &googleapi.Error{
  2147. Code: res.StatusCode,
  2148. Header: res.Header,
  2149. }
  2150. }
  2151. if err != nil {
  2152. return nil, err
  2153. }
  2154. defer googleapi.CloseBody(res)
  2155. if err := googleapi.CheckResponse(res); err != nil {
  2156. return nil, err
  2157. }
  2158. ret := &TestIamPermissionsResponse{
  2159. ServerResponse: googleapi.ServerResponse{
  2160. Header: res.Header,
  2161. HTTPStatusCode: res.StatusCode,
  2162. },
  2163. }
  2164. target := &ret
  2165. if err := gensupport.DecodeResponse(target, res); err != nil {
  2166. return nil, err
  2167. }
  2168. return ret, nil
  2169. // {
  2170. // "description": "Returns permissions that a caller has on the specified resource.\nIf the resource does not exist, this will return an empty set of\npermissions, not a NOT_FOUND error.\n\nNote: This operation is designed to be used for building permission-aware\nUIs and command-line tools, not for authorization checking. This operation\nmay \"fail open\" without warning.",
  2171. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings/{keyRingsId}:testIamPermissions",
  2172. // "httpMethod": "POST",
  2173. // "id": "cloudkms.projects.locations.keyRings.testIamPermissions",
  2174. // "parameterOrder": [
  2175. // "resource"
  2176. // ],
  2177. // "parameters": {
  2178. // "resource": {
  2179. // "description": "REQUIRED: The resource for which the policy detail is being requested.\nSee the operation documentation for the appropriate value for this field.",
  2180. // "location": "path",
  2181. // "pattern": "^projects/[^/]+/locations/[^/]+/keyRings/[^/]+$",
  2182. // "required": true,
  2183. // "type": "string"
  2184. // }
  2185. // },
  2186. // "path": "v1/{+resource}:testIamPermissions",
  2187. // "request": {
  2188. // "$ref": "TestIamPermissionsRequest"
  2189. // },
  2190. // "response": {
  2191. // "$ref": "TestIamPermissionsResponse"
  2192. // },
  2193. // "scopes": [
  2194. // "https://www.googleapis.com/auth/cloud-platform"
  2195. // ]
  2196. // }
  2197. }
  2198. // method id "cloudkms.projects.locations.keyRings.cryptoKeys.create":
  2199. type ProjectsLocationsKeyRingsCryptoKeysCreateCall struct {
  2200. s *Service
  2201. parent string
  2202. cryptokey *CryptoKey
  2203. urlParams_ gensupport.URLParams
  2204. ctx_ context.Context
  2205. header_ http.Header
  2206. }
  2207. // Create: Create a new CryptoKey within a KeyRing.
  2208. //
  2209. // CryptoKey.purpose is required.
  2210. func (r *ProjectsLocationsKeyRingsCryptoKeysService) Create(parent string, cryptokey *CryptoKey) *ProjectsLocationsKeyRingsCryptoKeysCreateCall {
  2211. c := &ProjectsLocationsKeyRingsCryptoKeysCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2212. c.parent = parent
  2213. c.cryptokey = cryptokey
  2214. return c
  2215. }
  2216. // CryptoKeyId sets the optional parameter "cryptoKeyId": Required. It
  2217. // must be unique within a KeyRing and match the regular
  2218. // expression `[a-zA-Z0-9_-]{1,63}`
  2219. func (c *ProjectsLocationsKeyRingsCryptoKeysCreateCall) CryptoKeyId(cryptoKeyId string) *ProjectsLocationsKeyRingsCryptoKeysCreateCall {
  2220. c.urlParams_.Set("cryptoKeyId", cryptoKeyId)
  2221. return c
  2222. }
  2223. // Fields allows partial responses to be retrieved. See
  2224. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2225. // for more information.
  2226. func (c *ProjectsLocationsKeyRingsCryptoKeysCreateCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsCryptoKeysCreateCall {
  2227. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2228. return c
  2229. }
  2230. // Context sets the context to be used in this call's Do method. Any
  2231. // pending HTTP request will be aborted if the provided context is
  2232. // canceled.
  2233. func (c *ProjectsLocationsKeyRingsCryptoKeysCreateCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsCryptoKeysCreateCall {
  2234. c.ctx_ = ctx
  2235. return c
  2236. }
  2237. // Header returns an http.Header that can be modified by the caller to
  2238. // add HTTP headers to the request.
  2239. func (c *ProjectsLocationsKeyRingsCryptoKeysCreateCall) Header() http.Header {
  2240. if c.header_ == nil {
  2241. c.header_ = make(http.Header)
  2242. }
  2243. return c.header_
  2244. }
  2245. func (c *ProjectsLocationsKeyRingsCryptoKeysCreateCall) doRequest(alt string) (*http.Response, error) {
  2246. reqHeaders := make(http.Header)
  2247. for k, v := range c.header_ {
  2248. reqHeaders[k] = v
  2249. }
  2250. reqHeaders.Set("User-Agent", c.s.userAgent())
  2251. var body io.Reader = nil
  2252. body, err := googleapi.WithoutDataWrapper.JSONReader(c.cryptokey)
  2253. if err != nil {
  2254. return nil, err
  2255. }
  2256. reqHeaders.Set("Content-Type", "application/json")
  2257. c.urlParams_.Set("alt", alt)
  2258. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/cryptoKeys")
  2259. urls += "?" + c.urlParams_.Encode()
  2260. req, _ := http.NewRequest("POST", urls, body)
  2261. req.Header = reqHeaders
  2262. googleapi.Expand(req.URL, map[string]string{
  2263. "parent": c.parent,
  2264. })
  2265. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2266. }
  2267. // Do executes the "cloudkms.projects.locations.keyRings.cryptoKeys.create" call.
  2268. // Exactly one of *CryptoKey or error will be non-nil. Any non-2xx
  2269. // status code is an error. Response headers are in either
  2270. // *CryptoKey.ServerResponse.Header or (if a response was returned at
  2271. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  2272. // to check whether the returned error was because
  2273. // http.StatusNotModified was returned.
  2274. func (c *ProjectsLocationsKeyRingsCryptoKeysCreateCall) Do(opts ...googleapi.CallOption) (*CryptoKey, error) {
  2275. gensupport.SetOptions(c.urlParams_, opts...)
  2276. res, err := c.doRequest("json")
  2277. if res != nil && res.StatusCode == http.StatusNotModified {
  2278. if res.Body != nil {
  2279. res.Body.Close()
  2280. }
  2281. return nil, &googleapi.Error{
  2282. Code: res.StatusCode,
  2283. Header: res.Header,
  2284. }
  2285. }
  2286. if err != nil {
  2287. return nil, err
  2288. }
  2289. defer googleapi.CloseBody(res)
  2290. if err := googleapi.CheckResponse(res); err != nil {
  2291. return nil, err
  2292. }
  2293. ret := &CryptoKey{
  2294. ServerResponse: googleapi.ServerResponse{
  2295. Header: res.Header,
  2296. HTTPStatusCode: res.StatusCode,
  2297. },
  2298. }
  2299. target := &ret
  2300. if err := gensupport.DecodeResponse(target, res); err != nil {
  2301. return nil, err
  2302. }
  2303. return ret, nil
  2304. // {
  2305. // "description": "Create a new CryptoKey within a KeyRing.\n\nCryptoKey.purpose is required.",
  2306. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings/{keyRingsId}/cryptoKeys",
  2307. // "httpMethod": "POST",
  2308. // "id": "cloudkms.projects.locations.keyRings.cryptoKeys.create",
  2309. // "parameterOrder": [
  2310. // "parent"
  2311. // ],
  2312. // "parameters": {
  2313. // "cryptoKeyId": {
  2314. // "description": "Required. It must be unique within a KeyRing and match the regular\nexpression `[a-zA-Z0-9_-]{1,63}`",
  2315. // "location": "query",
  2316. // "type": "string"
  2317. // },
  2318. // "parent": {
  2319. // "description": "Required. The name of the KeyRing associated with the\nCryptoKeys.",
  2320. // "location": "path",
  2321. // "pattern": "^projects/[^/]+/locations/[^/]+/keyRings/[^/]+$",
  2322. // "required": true,
  2323. // "type": "string"
  2324. // }
  2325. // },
  2326. // "path": "v1/{+parent}/cryptoKeys",
  2327. // "request": {
  2328. // "$ref": "CryptoKey"
  2329. // },
  2330. // "response": {
  2331. // "$ref": "CryptoKey"
  2332. // },
  2333. // "scopes": [
  2334. // "https://www.googleapis.com/auth/cloud-platform"
  2335. // ]
  2336. // }
  2337. }
  2338. // method id "cloudkms.projects.locations.keyRings.cryptoKeys.decrypt":
  2339. type ProjectsLocationsKeyRingsCryptoKeysDecryptCall struct {
  2340. s *Service
  2341. name string
  2342. decryptrequest *DecryptRequest
  2343. urlParams_ gensupport.URLParams
  2344. ctx_ context.Context
  2345. header_ http.Header
  2346. }
  2347. // Decrypt: Decrypts data that was protected by Encrypt.
  2348. func (r *ProjectsLocationsKeyRingsCryptoKeysService) Decrypt(name string, decryptrequest *DecryptRequest) *ProjectsLocationsKeyRingsCryptoKeysDecryptCall {
  2349. c := &ProjectsLocationsKeyRingsCryptoKeysDecryptCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2350. c.name = name
  2351. c.decryptrequest = decryptrequest
  2352. return c
  2353. }
  2354. // Fields allows partial responses to be retrieved. See
  2355. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2356. // for more information.
  2357. func (c *ProjectsLocationsKeyRingsCryptoKeysDecryptCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsCryptoKeysDecryptCall {
  2358. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2359. return c
  2360. }
  2361. // Context sets the context to be used in this call's Do method. Any
  2362. // pending HTTP request will be aborted if the provided context is
  2363. // canceled.
  2364. func (c *ProjectsLocationsKeyRingsCryptoKeysDecryptCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsCryptoKeysDecryptCall {
  2365. c.ctx_ = ctx
  2366. return c
  2367. }
  2368. // Header returns an http.Header that can be modified by the caller to
  2369. // add HTTP headers to the request.
  2370. func (c *ProjectsLocationsKeyRingsCryptoKeysDecryptCall) Header() http.Header {
  2371. if c.header_ == nil {
  2372. c.header_ = make(http.Header)
  2373. }
  2374. return c.header_
  2375. }
  2376. func (c *ProjectsLocationsKeyRingsCryptoKeysDecryptCall) doRequest(alt string) (*http.Response, error) {
  2377. reqHeaders := make(http.Header)
  2378. for k, v := range c.header_ {
  2379. reqHeaders[k] = v
  2380. }
  2381. reqHeaders.Set("User-Agent", c.s.userAgent())
  2382. var body io.Reader = nil
  2383. body, err := googleapi.WithoutDataWrapper.JSONReader(c.decryptrequest)
  2384. if err != nil {
  2385. return nil, err
  2386. }
  2387. reqHeaders.Set("Content-Type", "application/json")
  2388. c.urlParams_.Set("alt", alt)
  2389. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:decrypt")
  2390. urls += "?" + c.urlParams_.Encode()
  2391. req, _ := http.NewRequest("POST", urls, body)
  2392. req.Header = reqHeaders
  2393. googleapi.Expand(req.URL, map[string]string{
  2394. "name": c.name,
  2395. })
  2396. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2397. }
  2398. // Do executes the "cloudkms.projects.locations.keyRings.cryptoKeys.decrypt" call.
  2399. // Exactly one of *DecryptResponse or error will be non-nil. Any non-2xx
  2400. // status code is an error. Response headers are in either
  2401. // *DecryptResponse.ServerResponse.Header or (if a response was returned
  2402. // at all) in error.(*googleapi.Error).Header. Use
  2403. // googleapi.IsNotModified to check whether the returned error was
  2404. // because http.StatusNotModified was returned.
  2405. func (c *ProjectsLocationsKeyRingsCryptoKeysDecryptCall) Do(opts ...googleapi.CallOption) (*DecryptResponse, error) {
  2406. gensupport.SetOptions(c.urlParams_, opts...)
  2407. res, err := c.doRequest("json")
  2408. if res != nil && res.StatusCode == http.StatusNotModified {
  2409. if res.Body != nil {
  2410. res.Body.Close()
  2411. }
  2412. return nil, &googleapi.Error{
  2413. Code: res.StatusCode,
  2414. Header: res.Header,
  2415. }
  2416. }
  2417. if err != nil {
  2418. return nil, err
  2419. }
  2420. defer googleapi.CloseBody(res)
  2421. if err := googleapi.CheckResponse(res); err != nil {
  2422. return nil, err
  2423. }
  2424. ret := &DecryptResponse{
  2425. ServerResponse: googleapi.ServerResponse{
  2426. Header: res.Header,
  2427. HTTPStatusCode: res.StatusCode,
  2428. },
  2429. }
  2430. target := &ret
  2431. if err := gensupport.DecodeResponse(target, res); err != nil {
  2432. return nil, err
  2433. }
  2434. return ret, nil
  2435. // {
  2436. // "description": "Decrypts data that was protected by Encrypt.",
  2437. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings/{keyRingsId}/cryptoKeys/{cryptoKeysId}:decrypt",
  2438. // "httpMethod": "POST",
  2439. // "id": "cloudkms.projects.locations.keyRings.cryptoKeys.decrypt",
  2440. // "parameterOrder": [
  2441. // "name"
  2442. // ],
  2443. // "parameters": {
  2444. // "name": {
  2445. // "description": "Required. The resource name of the CryptoKey to use for decryption.\nThe server will choose the appropriate version.",
  2446. // "location": "path",
  2447. // "pattern": "^projects/[^/]+/locations/[^/]+/keyRings/[^/]+/cryptoKeys/[^/]+$",
  2448. // "required": true,
  2449. // "type": "string"
  2450. // }
  2451. // },
  2452. // "path": "v1/{+name}:decrypt",
  2453. // "request": {
  2454. // "$ref": "DecryptRequest"
  2455. // },
  2456. // "response": {
  2457. // "$ref": "DecryptResponse"
  2458. // },
  2459. // "scopes": [
  2460. // "https://www.googleapis.com/auth/cloud-platform"
  2461. // ]
  2462. // }
  2463. }
  2464. // method id "cloudkms.projects.locations.keyRings.cryptoKeys.encrypt":
  2465. type ProjectsLocationsKeyRingsCryptoKeysEncryptCall struct {
  2466. s *Service
  2467. name string
  2468. encryptrequest *EncryptRequest
  2469. urlParams_ gensupport.URLParams
  2470. ctx_ context.Context
  2471. header_ http.Header
  2472. }
  2473. // Encrypt: Encrypts data, so that it can only be recovered by a call to
  2474. // Decrypt.
  2475. func (r *ProjectsLocationsKeyRingsCryptoKeysService) Encrypt(name string, encryptrequest *EncryptRequest) *ProjectsLocationsKeyRingsCryptoKeysEncryptCall {
  2476. c := &ProjectsLocationsKeyRingsCryptoKeysEncryptCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2477. c.name = name
  2478. c.encryptrequest = encryptrequest
  2479. return c
  2480. }
  2481. // Fields allows partial responses to be retrieved. See
  2482. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2483. // for more information.
  2484. func (c *ProjectsLocationsKeyRingsCryptoKeysEncryptCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsCryptoKeysEncryptCall {
  2485. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2486. return c
  2487. }
  2488. // Context sets the context to be used in this call's Do method. Any
  2489. // pending HTTP request will be aborted if the provided context is
  2490. // canceled.
  2491. func (c *ProjectsLocationsKeyRingsCryptoKeysEncryptCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsCryptoKeysEncryptCall {
  2492. c.ctx_ = ctx
  2493. return c
  2494. }
  2495. // Header returns an http.Header that can be modified by the caller to
  2496. // add HTTP headers to the request.
  2497. func (c *ProjectsLocationsKeyRingsCryptoKeysEncryptCall) Header() http.Header {
  2498. if c.header_ == nil {
  2499. c.header_ = make(http.Header)
  2500. }
  2501. return c.header_
  2502. }
  2503. func (c *ProjectsLocationsKeyRingsCryptoKeysEncryptCall) doRequest(alt string) (*http.Response, error) {
  2504. reqHeaders := make(http.Header)
  2505. for k, v := range c.header_ {
  2506. reqHeaders[k] = v
  2507. }
  2508. reqHeaders.Set("User-Agent", c.s.userAgent())
  2509. var body io.Reader = nil
  2510. body, err := googleapi.WithoutDataWrapper.JSONReader(c.encryptrequest)
  2511. if err != nil {
  2512. return nil, err
  2513. }
  2514. reqHeaders.Set("Content-Type", "application/json")
  2515. c.urlParams_.Set("alt", alt)
  2516. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:encrypt")
  2517. urls += "?" + c.urlParams_.Encode()
  2518. req, _ := http.NewRequest("POST", urls, body)
  2519. req.Header = reqHeaders
  2520. googleapi.Expand(req.URL, map[string]string{
  2521. "name": c.name,
  2522. })
  2523. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2524. }
  2525. // Do executes the "cloudkms.projects.locations.keyRings.cryptoKeys.encrypt" call.
  2526. // Exactly one of *EncryptResponse or error will be non-nil. Any non-2xx
  2527. // status code is an error. Response headers are in either
  2528. // *EncryptResponse.ServerResponse.Header or (if a response was returned
  2529. // at all) in error.(*googleapi.Error).Header. Use
  2530. // googleapi.IsNotModified to check whether the returned error was
  2531. // because http.StatusNotModified was returned.
  2532. func (c *ProjectsLocationsKeyRingsCryptoKeysEncryptCall) Do(opts ...googleapi.CallOption) (*EncryptResponse, error) {
  2533. gensupport.SetOptions(c.urlParams_, opts...)
  2534. res, err := c.doRequest("json")
  2535. if res != nil && res.StatusCode == http.StatusNotModified {
  2536. if res.Body != nil {
  2537. res.Body.Close()
  2538. }
  2539. return nil, &googleapi.Error{
  2540. Code: res.StatusCode,
  2541. Header: res.Header,
  2542. }
  2543. }
  2544. if err != nil {
  2545. return nil, err
  2546. }
  2547. defer googleapi.CloseBody(res)
  2548. if err := googleapi.CheckResponse(res); err != nil {
  2549. return nil, err
  2550. }
  2551. ret := &EncryptResponse{
  2552. ServerResponse: googleapi.ServerResponse{
  2553. Header: res.Header,
  2554. HTTPStatusCode: res.StatusCode,
  2555. },
  2556. }
  2557. target := &ret
  2558. if err := gensupport.DecodeResponse(target, res); err != nil {
  2559. return nil, err
  2560. }
  2561. return ret, nil
  2562. // {
  2563. // "description": "Encrypts data, so that it can only be recovered by a call to Decrypt.",
  2564. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings/{keyRingsId}/cryptoKeys/{cryptoKeysId}:encrypt",
  2565. // "httpMethod": "POST",
  2566. // "id": "cloudkms.projects.locations.keyRings.cryptoKeys.encrypt",
  2567. // "parameterOrder": [
  2568. // "name"
  2569. // ],
  2570. // "parameters": {
  2571. // "name": {
  2572. // "description": "Required. The resource name of the CryptoKey or CryptoKeyVersion\nto use for encryption.\n\nIf a CryptoKey is specified, the server will use its\nprimary version.",
  2573. // "location": "path",
  2574. // "pattern": "^projects/[^/]+/locations/[^/]+/keyRings/[^/]+/cryptoKeys/.+$",
  2575. // "required": true,
  2576. // "type": "string"
  2577. // }
  2578. // },
  2579. // "path": "v1/{+name}:encrypt",
  2580. // "request": {
  2581. // "$ref": "EncryptRequest"
  2582. // },
  2583. // "response": {
  2584. // "$ref": "EncryptResponse"
  2585. // },
  2586. // "scopes": [
  2587. // "https://www.googleapis.com/auth/cloud-platform"
  2588. // ]
  2589. // }
  2590. }
  2591. // method id "cloudkms.projects.locations.keyRings.cryptoKeys.get":
  2592. type ProjectsLocationsKeyRingsCryptoKeysGetCall struct {
  2593. s *Service
  2594. name string
  2595. urlParams_ gensupport.URLParams
  2596. ifNoneMatch_ string
  2597. ctx_ context.Context
  2598. header_ http.Header
  2599. }
  2600. // Get: Returns metadata for a given CryptoKey, as well as its
  2601. // primary CryptoKeyVersion.
  2602. func (r *ProjectsLocationsKeyRingsCryptoKeysService) Get(name string) *ProjectsLocationsKeyRingsCryptoKeysGetCall {
  2603. c := &ProjectsLocationsKeyRingsCryptoKeysGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2604. c.name = name
  2605. return c
  2606. }
  2607. // Fields allows partial responses to be retrieved. See
  2608. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2609. // for more information.
  2610. func (c *ProjectsLocationsKeyRingsCryptoKeysGetCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsCryptoKeysGetCall {
  2611. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2612. return c
  2613. }
  2614. // IfNoneMatch sets the optional parameter which makes the operation
  2615. // fail if the object's ETag matches the given value. This is useful for
  2616. // getting updates only after the object has changed since the last
  2617. // request. Use googleapi.IsNotModified to check whether the response
  2618. // error from Do is the result of In-None-Match.
  2619. func (c *ProjectsLocationsKeyRingsCryptoKeysGetCall) IfNoneMatch(entityTag string) *ProjectsLocationsKeyRingsCryptoKeysGetCall {
  2620. c.ifNoneMatch_ = entityTag
  2621. return c
  2622. }
  2623. // Context sets the context to be used in this call's Do method. Any
  2624. // pending HTTP request will be aborted if the provided context is
  2625. // canceled.
  2626. func (c *ProjectsLocationsKeyRingsCryptoKeysGetCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsCryptoKeysGetCall {
  2627. c.ctx_ = ctx
  2628. return c
  2629. }
  2630. // Header returns an http.Header that can be modified by the caller to
  2631. // add HTTP headers to the request.
  2632. func (c *ProjectsLocationsKeyRingsCryptoKeysGetCall) Header() http.Header {
  2633. if c.header_ == nil {
  2634. c.header_ = make(http.Header)
  2635. }
  2636. return c.header_
  2637. }
  2638. func (c *ProjectsLocationsKeyRingsCryptoKeysGetCall) doRequest(alt string) (*http.Response, error) {
  2639. reqHeaders := make(http.Header)
  2640. for k, v := range c.header_ {
  2641. reqHeaders[k] = v
  2642. }
  2643. reqHeaders.Set("User-Agent", c.s.userAgent())
  2644. if c.ifNoneMatch_ != "" {
  2645. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  2646. }
  2647. var body io.Reader = nil
  2648. c.urlParams_.Set("alt", alt)
  2649. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  2650. urls += "?" + c.urlParams_.Encode()
  2651. req, _ := http.NewRequest("GET", urls, body)
  2652. req.Header = reqHeaders
  2653. googleapi.Expand(req.URL, map[string]string{
  2654. "name": c.name,
  2655. })
  2656. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2657. }
  2658. // Do executes the "cloudkms.projects.locations.keyRings.cryptoKeys.get" call.
  2659. // Exactly one of *CryptoKey or error will be non-nil. Any non-2xx
  2660. // status code is an error. Response headers are in either
  2661. // *CryptoKey.ServerResponse.Header or (if a response was returned at
  2662. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  2663. // to check whether the returned error was because
  2664. // http.StatusNotModified was returned.
  2665. func (c *ProjectsLocationsKeyRingsCryptoKeysGetCall) Do(opts ...googleapi.CallOption) (*CryptoKey, error) {
  2666. gensupport.SetOptions(c.urlParams_, opts...)
  2667. res, err := c.doRequest("json")
  2668. if res != nil && res.StatusCode == http.StatusNotModified {
  2669. if res.Body != nil {
  2670. res.Body.Close()
  2671. }
  2672. return nil, &googleapi.Error{
  2673. Code: res.StatusCode,
  2674. Header: res.Header,
  2675. }
  2676. }
  2677. if err != nil {
  2678. return nil, err
  2679. }
  2680. defer googleapi.CloseBody(res)
  2681. if err := googleapi.CheckResponse(res); err != nil {
  2682. return nil, err
  2683. }
  2684. ret := &CryptoKey{
  2685. ServerResponse: googleapi.ServerResponse{
  2686. Header: res.Header,
  2687. HTTPStatusCode: res.StatusCode,
  2688. },
  2689. }
  2690. target := &ret
  2691. if err := gensupport.DecodeResponse(target, res); err != nil {
  2692. return nil, err
  2693. }
  2694. return ret, nil
  2695. // {
  2696. // "description": "Returns metadata for a given CryptoKey, as well as its\nprimary CryptoKeyVersion.",
  2697. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings/{keyRingsId}/cryptoKeys/{cryptoKeysId}",
  2698. // "httpMethod": "GET",
  2699. // "id": "cloudkms.projects.locations.keyRings.cryptoKeys.get",
  2700. // "parameterOrder": [
  2701. // "name"
  2702. // ],
  2703. // "parameters": {
  2704. // "name": {
  2705. // "description": "The name of the CryptoKey to get.",
  2706. // "location": "path",
  2707. // "pattern": "^projects/[^/]+/locations/[^/]+/keyRings/[^/]+/cryptoKeys/[^/]+$",
  2708. // "required": true,
  2709. // "type": "string"
  2710. // }
  2711. // },
  2712. // "path": "v1/{+name}",
  2713. // "response": {
  2714. // "$ref": "CryptoKey"
  2715. // },
  2716. // "scopes": [
  2717. // "https://www.googleapis.com/auth/cloud-platform"
  2718. // ]
  2719. // }
  2720. }
  2721. // method id "cloudkms.projects.locations.keyRings.cryptoKeys.getIamPolicy":
  2722. type ProjectsLocationsKeyRingsCryptoKeysGetIamPolicyCall struct {
  2723. s *Service
  2724. resource string
  2725. urlParams_ gensupport.URLParams
  2726. ifNoneMatch_ string
  2727. ctx_ context.Context
  2728. header_ http.Header
  2729. }
  2730. // GetIamPolicy: Gets the access control policy for a resource.
  2731. // Returns an empty policy if the resource exists and does not have a
  2732. // policy
  2733. // set.
  2734. func (r *ProjectsLocationsKeyRingsCryptoKeysService) GetIamPolicy(resource string) *ProjectsLocationsKeyRingsCryptoKeysGetIamPolicyCall {
  2735. c := &ProjectsLocationsKeyRingsCryptoKeysGetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2736. c.resource = resource
  2737. return c
  2738. }
  2739. // Fields allows partial responses to be retrieved. See
  2740. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2741. // for more information.
  2742. func (c *ProjectsLocationsKeyRingsCryptoKeysGetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsCryptoKeysGetIamPolicyCall {
  2743. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2744. return c
  2745. }
  2746. // IfNoneMatch sets the optional parameter which makes the operation
  2747. // fail if the object's ETag matches the given value. This is useful for
  2748. // getting updates only after the object has changed since the last
  2749. // request. Use googleapi.IsNotModified to check whether the response
  2750. // error from Do is the result of In-None-Match.
  2751. func (c *ProjectsLocationsKeyRingsCryptoKeysGetIamPolicyCall) IfNoneMatch(entityTag string) *ProjectsLocationsKeyRingsCryptoKeysGetIamPolicyCall {
  2752. c.ifNoneMatch_ = entityTag
  2753. return c
  2754. }
  2755. // Context sets the context to be used in this call's Do method. Any
  2756. // pending HTTP request will be aborted if the provided context is
  2757. // canceled.
  2758. func (c *ProjectsLocationsKeyRingsCryptoKeysGetIamPolicyCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsCryptoKeysGetIamPolicyCall {
  2759. c.ctx_ = ctx
  2760. return c
  2761. }
  2762. // Header returns an http.Header that can be modified by the caller to
  2763. // add HTTP headers to the request.
  2764. func (c *ProjectsLocationsKeyRingsCryptoKeysGetIamPolicyCall) Header() http.Header {
  2765. if c.header_ == nil {
  2766. c.header_ = make(http.Header)
  2767. }
  2768. return c.header_
  2769. }
  2770. func (c *ProjectsLocationsKeyRingsCryptoKeysGetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  2771. reqHeaders := make(http.Header)
  2772. for k, v := range c.header_ {
  2773. reqHeaders[k] = v
  2774. }
  2775. reqHeaders.Set("User-Agent", c.s.userAgent())
  2776. if c.ifNoneMatch_ != "" {
  2777. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  2778. }
  2779. var body io.Reader = nil
  2780. c.urlParams_.Set("alt", alt)
  2781. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+resource}:getIamPolicy")
  2782. urls += "?" + c.urlParams_.Encode()
  2783. req, _ := http.NewRequest("GET", urls, body)
  2784. req.Header = reqHeaders
  2785. googleapi.Expand(req.URL, map[string]string{
  2786. "resource": c.resource,
  2787. })
  2788. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2789. }
  2790. // Do executes the "cloudkms.projects.locations.keyRings.cryptoKeys.getIamPolicy" call.
  2791. // Exactly one of *Policy or error will be non-nil. Any non-2xx status
  2792. // code is an error. Response headers are in either
  2793. // *Policy.ServerResponse.Header or (if a response was returned at all)
  2794. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2795. // check whether the returned error was because http.StatusNotModified
  2796. // was returned.
  2797. func (c *ProjectsLocationsKeyRingsCryptoKeysGetIamPolicyCall) Do(opts ...googleapi.CallOption) (*Policy, error) {
  2798. gensupport.SetOptions(c.urlParams_, opts...)
  2799. res, err := c.doRequest("json")
  2800. if res != nil && res.StatusCode == http.StatusNotModified {
  2801. if res.Body != nil {
  2802. res.Body.Close()
  2803. }
  2804. return nil, &googleapi.Error{
  2805. Code: res.StatusCode,
  2806. Header: res.Header,
  2807. }
  2808. }
  2809. if err != nil {
  2810. return nil, err
  2811. }
  2812. defer googleapi.CloseBody(res)
  2813. if err := googleapi.CheckResponse(res); err != nil {
  2814. return nil, err
  2815. }
  2816. ret := &Policy{
  2817. ServerResponse: googleapi.ServerResponse{
  2818. Header: res.Header,
  2819. HTTPStatusCode: res.StatusCode,
  2820. },
  2821. }
  2822. target := &ret
  2823. if err := gensupport.DecodeResponse(target, res); err != nil {
  2824. return nil, err
  2825. }
  2826. return ret, nil
  2827. // {
  2828. // "description": "Gets the access control policy for a resource.\nReturns an empty policy if the resource exists and does not have a policy\nset.",
  2829. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings/{keyRingsId}/cryptoKeys/{cryptoKeysId}:getIamPolicy",
  2830. // "httpMethod": "GET",
  2831. // "id": "cloudkms.projects.locations.keyRings.cryptoKeys.getIamPolicy",
  2832. // "parameterOrder": [
  2833. // "resource"
  2834. // ],
  2835. // "parameters": {
  2836. // "resource": {
  2837. // "description": "REQUIRED: The resource for which the policy is being requested.\nSee the operation documentation for the appropriate value for this field.",
  2838. // "location": "path",
  2839. // "pattern": "^projects/[^/]+/locations/[^/]+/keyRings/[^/]+/cryptoKeys/[^/]+$",
  2840. // "required": true,
  2841. // "type": "string"
  2842. // }
  2843. // },
  2844. // "path": "v1/{+resource}:getIamPolicy",
  2845. // "response": {
  2846. // "$ref": "Policy"
  2847. // },
  2848. // "scopes": [
  2849. // "https://www.googleapis.com/auth/cloud-platform"
  2850. // ]
  2851. // }
  2852. }
  2853. // method id "cloudkms.projects.locations.keyRings.cryptoKeys.list":
  2854. type ProjectsLocationsKeyRingsCryptoKeysListCall struct {
  2855. s *Service
  2856. parent string
  2857. urlParams_ gensupport.URLParams
  2858. ifNoneMatch_ string
  2859. ctx_ context.Context
  2860. header_ http.Header
  2861. }
  2862. // List: Lists CryptoKeys.
  2863. func (r *ProjectsLocationsKeyRingsCryptoKeysService) List(parent string) *ProjectsLocationsKeyRingsCryptoKeysListCall {
  2864. c := &ProjectsLocationsKeyRingsCryptoKeysListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2865. c.parent = parent
  2866. return c
  2867. }
  2868. // PageSize sets the optional parameter "pageSize": Optional limit on
  2869. // the number of CryptoKeys to include in the
  2870. // response. Further CryptoKeys can subsequently be obtained
  2871. // by
  2872. // including the ListCryptoKeysResponse.next_page_token in a
  2873. // subsequent
  2874. // request. If unspecified, the server will pick an appropriate
  2875. // default.
  2876. func (c *ProjectsLocationsKeyRingsCryptoKeysListCall) PageSize(pageSize int64) *ProjectsLocationsKeyRingsCryptoKeysListCall {
  2877. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  2878. return c
  2879. }
  2880. // PageToken sets the optional parameter "pageToken": Optional
  2881. // pagination token, returned earlier
  2882. // via
  2883. // ListCryptoKeysResponse.next_page_token.
  2884. func (c *ProjectsLocationsKeyRingsCryptoKeysListCall) PageToken(pageToken string) *ProjectsLocationsKeyRingsCryptoKeysListCall {
  2885. c.urlParams_.Set("pageToken", pageToken)
  2886. return c
  2887. }
  2888. // Fields allows partial responses to be retrieved. See
  2889. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2890. // for more information.
  2891. func (c *ProjectsLocationsKeyRingsCryptoKeysListCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsCryptoKeysListCall {
  2892. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2893. return c
  2894. }
  2895. // IfNoneMatch sets the optional parameter which makes the operation
  2896. // fail if the object's ETag matches the given value. This is useful for
  2897. // getting updates only after the object has changed since the last
  2898. // request. Use googleapi.IsNotModified to check whether the response
  2899. // error from Do is the result of In-None-Match.
  2900. func (c *ProjectsLocationsKeyRingsCryptoKeysListCall) IfNoneMatch(entityTag string) *ProjectsLocationsKeyRingsCryptoKeysListCall {
  2901. c.ifNoneMatch_ = entityTag
  2902. return c
  2903. }
  2904. // Context sets the context to be used in this call's Do method. Any
  2905. // pending HTTP request will be aborted if the provided context is
  2906. // canceled.
  2907. func (c *ProjectsLocationsKeyRingsCryptoKeysListCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsCryptoKeysListCall {
  2908. c.ctx_ = ctx
  2909. return c
  2910. }
  2911. // Header returns an http.Header that can be modified by the caller to
  2912. // add HTTP headers to the request.
  2913. func (c *ProjectsLocationsKeyRingsCryptoKeysListCall) Header() http.Header {
  2914. if c.header_ == nil {
  2915. c.header_ = make(http.Header)
  2916. }
  2917. return c.header_
  2918. }
  2919. func (c *ProjectsLocationsKeyRingsCryptoKeysListCall) doRequest(alt string) (*http.Response, error) {
  2920. reqHeaders := make(http.Header)
  2921. for k, v := range c.header_ {
  2922. reqHeaders[k] = v
  2923. }
  2924. reqHeaders.Set("User-Agent", c.s.userAgent())
  2925. if c.ifNoneMatch_ != "" {
  2926. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  2927. }
  2928. var body io.Reader = nil
  2929. c.urlParams_.Set("alt", alt)
  2930. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/cryptoKeys")
  2931. urls += "?" + c.urlParams_.Encode()
  2932. req, _ := http.NewRequest("GET", urls, body)
  2933. req.Header = reqHeaders
  2934. googleapi.Expand(req.URL, map[string]string{
  2935. "parent": c.parent,
  2936. })
  2937. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  2938. }
  2939. // Do executes the "cloudkms.projects.locations.keyRings.cryptoKeys.list" call.
  2940. // Exactly one of *ListCryptoKeysResponse or error will be non-nil. Any
  2941. // non-2xx status code is an error. Response headers are in either
  2942. // *ListCryptoKeysResponse.ServerResponse.Header or (if a response was
  2943. // returned at all) in error.(*googleapi.Error).Header. Use
  2944. // googleapi.IsNotModified to check whether the returned error was
  2945. // because http.StatusNotModified was returned.
  2946. func (c *ProjectsLocationsKeyRingsCryptoKeysListCall) Do(opts ...googleapi.CallOption) (*ListCryptoKeysResponse, error) {
  2947. gensupport.SetOptions(c.urlParams_, opts...)
  2948. res, err := c.doRequest("json")
  2949. if res != nil && res.StatusCode == http.StatusNotModified {
  2950. if res.Body != nil {
  2951. res.Body.Close()
  2952. }
  2953. return nil, &googleapi.Error{
  2954. Code: res.StatusCode,
  2955. Header: res.Header,
  2956. }
  2957. }
  2958. if err != nil {
  2959. return nil, err
  2960. }
  2961. defer googleapi.CloseBody(res)
  2962. if err := googleapi.CheckResponse(res); err != nil {
  2963. return nil, err
  2964. }
  2965. ret := &ListCryptoKeysResponse{
  2966. ServerResponse: googleapi.ServerResponse{
  2967. Header: res.Header,
  2968. HTTPStatusCode: res.StatusCode,
  2969. },
  2970. }
  2971. target := &ret
  2972. if err := gensupport.DecodeResponse(target, res); err != nil {
  2973. return nil, err
  2974. }
  2975. return ret, nil
  2976. // {
  2977. // "description": "Lists CryptoKeys.",
  2978. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings/{keyRingsId}/cryptoKeys",
  2979. // "httpMethod": "GET",
  2980. // "id": "cloudkms.projects.locations.keyRings.cryptoKeys.list",
  2981. // "parameterOrder": [
  2982. // "parent"
  2983. // ],
  2984. // "parameters": {
  2985. // "pageSize": {
  2986. // "description": "Optional limit on the number of CryptoKeys to include in the\nresponse. Further CryptoKeys can subsequently be obtained by\nincluding the ListCryptoKeysResponse.next_page_token in a subsequent\nrequest. If unspecified, the server will pick an appropriate default.",
  2987. // "format": "int32",
  2988. // "location": "query",
  2989. // "type": "integer"
  2990. // },
  2991. // "pageToken": {
  2992. // "description": "Optional pagination token, returned earlier via\nListCryptoKeysResponse.next_page_token.",
  2993. // "location": "query",
  2994. // "type": "string"
  2995. // },
  2996. // "parent": {
  2997. // "description": "Required. The resource name of the KeyRing to list, in the format\n`projects/*/locations/*/keyRings/*`.",
  2998. // "location": "path",
  2999. // "pattern": "^projects/[^/]+/locations/[^/]+/keyRings/[^/]+$",
  3000. // "required": true,
  3001. // "type": "string"
  3002. // }
  3003. // },
  3004. // "path": "v1/{+parent}/cryptoKeys",
  3005. // "response": {
  3006. // "$ref": "ListCryptoKeysResponse"
  3007. // },
  3008. // "scopes": [
  3009. // "https://www.googleapis.com/auth/cloud-platform"
  3010. // ]
  3011. // }
  3012. }
  3013. // Pages invokes f for each page of results.
  3014. // A non-nil error returned from f will halt the iteration.
  3015. // The provided context supersedes any context provided to the Context method.
  3016. func (c *ProjectsLocationsKeyRingsCryptoKeysListCall) Pages(ctx context.Context, f func(*ListCryptoKeysResponse) error) error {
  3017. c.ctx_ = ctx
  3018. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  3019. for {
  3020. x, err := c.Do()
  3021. if err != nil {
  3022. return err
  3023. }
  3024. if err := f(x); err != nil {
  3025. return err
  3026. }
  3027. if x.NextPageToken == "" {
  3028. return nil
  3029. }
  3030. c.PageToken(x.NextPageToken)
  3031. }
  3032. }
  3033. // method id "cloudkms.projects.locations.keyRings.cryptoKeys.patch":
  3034. type ProjectsLocationsKeyRingsCryptoKeysPatchCall struct {
  3035. s *Service
  3036. name string
  3037. cryptokey *CryptoKey
  3038. urlParams_ gensupport.URLParams
  3039. ctx_ context.Context
  3040. header_ http.Header
  3041. }
  3042. // Patch: Update a CryptoKey.
  3043. func (r *ProjectsLocationsKeyRingsCryptoKeysService) Patch(name string, cryptokey *CryptoKey) *ProjectsLocationsKeyRingsCryptoKeysPatchCall {
  3044. c := &ProjectsLocationsKeyRingsCryptoKeysPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3045. c.name = name
  3046. c.cryptokey = cryptokey
  3047. return c
  3048. }
  3049. // UpdateMask sets the optional parameter "updateMask": Required list of
  3050. // fields to be updated in this request.
  3051. func (c *ProjectsLocationsKeyRingsCryptoKeysPatchCall) UpdateMask(updateMask string) *ProjectsLocationsKeyRingsCryptoKeysPatchCall {
  3052. c.urlParams_.Set("updateMask", updateMask)
  3053. return c
  3054. }
  3055. // Fields allows partial responses to be retrieved. See
  3056. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3057. // for more information.
  3058. func (c *ProjectsLocationsKeyRingsCryptoKeysPatchCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsCryptoKeysPatchCall {
  3059. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3060. return c
  3061. }
  3062. // Context sets the context to be used in this call's Do method. Any
  3063. // pending HTTP request will be aborted if the provided context is
  3064. // canceled.
  3065. func (c *ProjectsLocationsKeyRingsCryptoKeysPatchCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsCryptoKeysPatchCall {
  3066. c.ctx_ = ctx
  3067. return c
  3068. }
  3069. // Header returns an http.Header that can be modified by the caller to
  3070. // add HTTP headers to the request.
  3071. func (c *ProjectsLocationsKeyRingsCryptoKeysPatchCall) Header() http.Header {
  3072. if c.header_ == nil {
  3073. c.header_ = make(http.Header)
  3074. }
  3075. return c.header_
  3076. }
  3077. func (c *ProjectsLocationsKeyRingsCryptoKeysPatchCall) doRequest(alt string) (*http.Response, error) {
  3078. reqHeaders := make(http.Header)
  3079. for k, v := range c.header_ {
  3080. reqHeaders[k] = v
  3081. }
  3082. reqHeaders.Set("User-Agent", c.s.userAgent())
  3083. var body io.Reader = nil
  3084. body, err := googleapi.WithoutDataWrapper.JSONReader(c.cryptokey)
  3085. if err != nil {
  3086. return nil, err
  3087. }
  3088. reqHeaders.Set("Content-Type", "application/json")
  3089. c.urlParams_.Set("alt", alt)
  3090. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  3091. urls += "?" + c.urlParams_.Encode()
  3092. req, _ := http.NewRequest("PATCH", urls, body)
  3093. req.Header = reqHeaders
  3094. googleapi.Expand(req.URL, map[string]string{
  3095. "name": c.name,
  3096. })
  3097. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3098. }
  3099. // Do executes the "cloudkms.projects.locations.keyRings.cryptoKeys.patch" call.
  3100. // Exactly one of *CryptoKey or error will be non-nil. Any non-2xx
  3101. // status code is an error. Response headers are in either
  3102. // *CryptoKey.ServerResponse.Header or (if a response was returned at
  3103. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  3104. // to check whether the returned error was because
  3105. // http.StatusNotModified was returned.
  3106. func (c *ProjectsLocationsKeyRingsCryptoKeysPatchCall) Do(opts ...googleapi.CallOption) (*CryptoKey, error) {
  3107. gensupport.SetOptions(c.urlParams_, opts...)
  3108. res, err := c.doRequest("json")
  3109. if res != nil && res.StatusCode == http.StatusNotModified {
  3110. if res.Body != nil {
  3111. res.Body.Close()
  3112. }
  3113. return nil, &googleapi.Error{
  3114. Code: res.StatusCode,
  3115. Header: res.Header,
  3116. }
  3117. }
  3118. if err != nil {
  3119. return nil, err
  3120. }
  3121. defer googleapi.CloseBody(res)
  3122. if err := googleapi.CheckResponse(res); err != nil {
  3123. return nil, err
  3124. }
  3125. ret := &CryptoKey{
  3126. ServerResponse: googleapi.ServerResponse{
  3127. Header: res.Header,
  3128. HTTPStatusCode: res.StatusCode,
  3129. },
  3130. }
  3131. target := &ret
  3132. if err := gensupport.DecodeResponse(target, res); err != nil {
  3133. return nil, err
  3134. }
  3135. return ret, nil
  3136. // {
  3137. // "description": "Update a CryptoKey.",
  3138. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings/{keyRingsId}/cryptoKeys/{cryptoKeysId}",
  3139. // "httpMethod": "PATCH",
  3140. // "id": "cloudkms.projects.locations.keyRings.cryptoKeys.patch",
  3141. // "parameterOrder": [
  3142. // "name"
  3143. // ],
  3144. // "parameters": {
  3145. // "name": {
  3146. // "description": "Output only. The resource name for this CryptoKey in the format\n`projects/*/locations/*/keyRings/*/cryptoKeys/*`.",
  3147. // "location": "path",
  3148. // "pattern": "^projects/[^/]+/locations/[^/]+/keyRings/[^/]+/cryptoKeys/[^/]+$",
  3149. // "required": true,
  3150. // "type": "string"
  3151. // },
  3152. // "updateMask": {
  3153. // "description": "Required list of fields to be updated in this request.",
  3154. // "format": "google-fieldmask",
  3155. // "location": "query",
  3156. // "type": "string"
  3157. // }
  3158. // },
  3159. // "path": "v1/{+name}",
  3160. // "request": {
  3161. // "$ref": "CryptoKey"
  3162. // },
  3163. // "response": {
  3164. // "$ref": "CryptoKey"
  3165. // },
  3166. // "scopes": [
  3167. // "https://www.googleapis.com/auth/cloud-platform"
  3168. // ]
  3169. // }
  3170. }
  3171. // method id "cloudkms.projects.locations.keyRings.cryptoKeys.setIamPolicy":
  3172. type ProjectsLocationsKeyRingsCryptoKeysSetIamPolicyCall struct {
  3173. s *Service
  3174. resource string
  3175. setiampolicyrequest *SetIamPolicyRequest
  3176. urlParams_ gensupport.URLParams
  3177. ctx_ context.Context
  3178. header_ http.Header
  3179. }
  3180. // SetIamPolicy: Sets the access control policy on the specified
  3181. // resource. Replaces any
  3182. // existing policy.
  3183. func (r *ProjectsLocationsKeyRingsCryptoKeysService) SetIamPolicy(resource string, setiampolicyrequest *SetIamPolicyRequest) *ProjectsLocationsKeyRingsCryptoKeysSetIamPolicyCall {
  3184. c := &ProjectsLocationsKeyRingsCryptoKeysSetIamPolicyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3185. c.resource = resource
  3186. c.setiampolicyrequest = setiampolicyrequest
  3187. return c
  3188. }
  3189. // Fields allows partial responses to be retrieved. See
  3190. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3191. // for more information.
  3192. func (c *ProjectsLocationsKeyRingsCryptoKeysSetIamPolicyCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsCryptoKeysSetIamPolicyCall {
  3193. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3194. return c
  3195. }
  3196. // Context sets the context to be used in this call's Do method. Any
  3197. // pending HTTP request will be aborted if the provided context is
  3198. // canceled.
  3199. func (c *ProjectsLocationsKeyRingsCryptoKeysSetIamPolicyCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsCryptoKeysSetIamPolicyCall {
  3200. c.ctx_ = ctx
  3201. return c
  3202. }
  3203. // Header returns an http.Header that can be modified by the caller to
  3204. // add HTTP headers to the request.
  3205. func (c *ProjectsLocationsKeyRingsCryptoKeysSetIamPolicyCall) Header() http.Header {
  3206. if c.header_ == nil {
  3207. c.header_ = make(http.Header)
  3208. }
  3209. return c.header_
  3210. }
  3211. func (c *ProjectsLocationsKeyRingsCryptoKeysSetIamPolicyCall) doRequest(alt string) (*http.Response, error) {
  3212. reqHeaders := make(http.Header)
  3213. for k, v := range c.header_ {
  3214. reqHeaders[k] = v
  3215. }
  3216. reqHeaders.Set("User-Agent", c.s.userAgent())
  3217. var body io.Reader = nil
  3218. body, err := googleapi.WithoutDataWrapper.JSONReader(c.setiampolicyrequest)
  3219. if err != nil {
  3220. return nil, err
  3221. }
  3222. reqHeaders.Set("Content-Type", "application/json")
  3223. c.urlParams_.Set("alt", alt)
  3224. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+resource}:setIamPolicy")
  3225. urls += "?" + c.urlParams_.Encode()
  3226. req, _ := http.NewRequest("POST", urls, body)
  3227. req.Header = reqHeaders
  3228. googleapi.Expand(req.URL, map[string]string{
  3229. "resource": c.resource,
  3230. })
  3231. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3232. }
  3233. // Do executes the "cloudkms.projects.locations.keyRings.cryptoKeys.setIamPolicy" call.
  3234. // Exactly one of *Policy or error will be non-nil. Any non-2xx status
  3235. // code is an error. Response headers are in either
  3236. // *Policy.ServerResponse.Header or (if a response was returned at all)
  3237. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  3238. // check whether the returned error was because http.StatusNotModified
  3239. // was returned.
  3240. func (c *ProjectsLocationsKeyRingsCryptoKeysSetIamPolicyCall) Do(opts ...googleapi.CallOption) (*Policy, error) {
  3241. gensupport.SetOptions(c.urlParams_, opts...)
  3242. res, err := c.doRequest("json")
  3243. if res != nil && res.StatusCode == http.StatusNotModified {
  3244. if res.Body != nil {
  3245. res.Body.Close()
  3246. }
  3247. return nil, &googleapi.Error{
  3248. Code: res.StatusCode,
  3249. Header: res.Header,
  3250. }
  3251. }
  3252. if err != nil {
  3253. return nil, err
  3254. }
  3255. defer googleapi.CloseBody(res)
  3256. if err := googleapi.CheckResponse(res); err != nil {
  3257. return nil, err
  3258. }
  3259. ret := &Policy{
  3260. ServerResponse: googleapi.ServerResponse{
  3261. Header: res.Header,
  3262. HTTPStatusCode: res.StatusCode,
  3263. },
  3264. }
  3265. target := &ret
  3266. if err := gensupport.DecodeResponse(target, res); err != nil {
  3267. return nil, err
  3268. }
  3269. return ret, nil
  3270. // {
  3271. // "description": "Sets the access control policy on the specified resource. Replaces any\nexisting policy.",
  3272. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings/{keyRingsId}/cryptoKeys/{cryptoKeysId}:setIamPolicy",
  3273. // "httpMethod": "POST",
  3274. // "id": "cloudkms.projects.locations.keyRings.cryptoKeys.setIamPolicy",
  3275. // "parameterOrder": [
  3276. // "resource"
  3277. // ],
  3278. // "parameters": {
  3279. // "resource": {
  3280. // "description": "REQUIRED: The resource for which the policy is being specified.\nSee the operation documentation for the appropriate value for this field.",
  3281. // "location": "path",
  3282. // "pattern": "^projects/[^/]+/locations/[^/]+/keyRings/[^/]+/cryptoKeys/[^/]+$",
  3283. // "required": true,
  3284. // "type": "string"
  3285. // }
  3286. // },
  3287. // "path": "v1/{+resource}:setIamPolicy",
  3288. // "request": {
  3289. // "$ref": "SetIamPolicyRequest"
  3290. // },
  3291. // "response": {
  3292. // "$ref": "Policy"
  3293. // },
  3294. // "scopes": [
  3295. // "https://www.googleapis.com/auth/cloud-platform"
  3296. // ]
  3297. // }
  3298. }
  3299. // method id "cloudkms.projects.locations.keyRings.cryptoKeys.testIamPermissions":
  3300. type ProjectsLocationsKeyRingsCryptoKeysTestIamPermissionsCall struct {
  3301. s *Service
  3302. resource string
  3303. testiampermissionsrequest *TestIamPermissionsRequest
  3304. urlParams_ gensupport.URLParams
  3305. ctx_ context.Context
  3306. header_ http.Header
  3307. }
  3308. // TestIamPermissions: Returns permissions that a caller has on the
  3309. // specified resource.
  3310. // If the resource does not exist, this will return an empty set
  3311. // of
  3312. // permissions, not a NOT_FOUND error.
  3313. //
  3314. // Note: This operation is designed to be used for building
  3315. // permission-aware
  3316. // UIs and command-line tools, not for authorization checking. This
  3317. // operation
  3318. // may "fail open" without warning.
  3319. func (r *ProjectsLocationsKeyRingsCryptoKeysService) TestIamPermissions(resource string, testiampermissionsrequest *TestIamPermissionsRequest) *ProjectsLocationsKeyRingsCryptoKeysTestIamPermissionsCall {
  3320. c := &ProjectsLocationsKeyRingsCryptoKeysTestIamPermissionsCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3321. c.resource = resource
  3322. c.testiampermissionsrequest = testiampermissionsrequest
  3323. return c
  3324. }
  3325. // Fields allows partial responses to be retrieved. See
  3326. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3327. // for more information.
  3328. func (c *ProjectsLocationsKeyRingsCryptoKeysTestIamPermissionsCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsCryptoKeysTestIamPermissionsCall {
  3329. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3330. return c
  3331. }
  3332. // Context sets the context to be used in this call's Do method. Any
  3333. // pending HTTP request will be aborted if the provided context is
  3334. // canceled.
  3335. func (c *ProjectsLocationsKeyRingsCryptoKeysTestIamPermissionsCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsCryptoKeysTestIamPermissionsCall {
  3336. c.ctx_ = ctx
  3337. return c
  3338. }
  3339. // Header returns an http.Header that can be modified by the caller to
  3340. // add HTTP headers to the request.
  3341. func (c *ProjectsLocationsKeyRingsCryptoKeysTestIamPermissionsCall) Header() http.Header {
  3342. if c.header_ == nil {
  3343. c.header_ = make(http.Header)
  3344. }
  3345. return c.header_
  3346. }
  3347. func (c *ProjectsLocationsKeyRingsCryptoKeysTestIamPermissionsCall) doRequest(alt string) (*http.Response, error) {
  3348. reqHeaders := make(http.Header)
  3349. for k, v := range c.header_ {
  3350. reqHeaders[k] = v
  3351. }
  3352. reqHeaders.Set("User-Agent", c.s.userAgent())
  3353. var body io.Reader = nil
  3354. body, err := googleapi.WithoutDataWrapper.JSONReader(c.testiampermissionsrequest)
  3355. if err != nil {
  3356. return nil, err
  3357. }
  3358. reqHeaders.Set("Content-Type", "application/json")
  3359. c.urlParams_.Set("alt", alt)
  3360. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+resource}:testIamPermissions")
  3361. urls += "?" + c.urlParams_.Encode()
  3362. req, _ := http.NewRequest("POST", urls, body)
  3363. req.Header = reqHeaders
  3364. googleapi.Expand(req.URL, map[string]string{
  3365. "resource": c.resource,
  3366. })
  3367. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3368. }
  3369. // Do executes the "cloudkms.projects.locations.keyRings.cryptoKeys.testIamPermissions" call.
  3370. // Exactly one of *TestIamPermissionsResponse or error will be non-nil.
  3371. // Any non-2xx status code is an error. Response headers are in either
  3372. // *TestIamPermissionsResponse.ServerResponse.Header or (if a response
  3373. // was returned at all) in error.(*googleapi.Error).Header. Use
  3374. // googleapi.IsNotModified to check whether the returned error was
  3375. // because http.StatusNotModified was returned.
  3376. func (c *ProjectsLocationsKeyRingsCryptoKeysTestIamPermissionsCall) Do(opts ...googleapi.CallOption) (*TestIamPermissionsResponse, error) {
  3377. gensupport.SetOptions(c.urlParams_, opts...)
  3378. res, err := c.doRequest("json")
  3379. if res != nil && res.StatusCode == http.StatusNotModified {
  3380. if res.Body != nil {
  3381. res.Body.Close()
  3382. }
  3383. return nil, &googleapi.Error{
  3384. Code: res.StatusCode,
  3385. Header: res.Header,
  3386. }
  3387. }
  3388. if err != nil {
  3389. return nil, err
  3390. }
  3391. defer googleapi.CloseBody(res)
  3392. if err := googleapi.CheckResponse(res); err != nil {
  3393. return nil, err
  3394. }
  3395. ret := &TestIamPermissionsResponse{
  3396. ServerResponse: googleapi.ServerResponse{
  3397. Header: res.Header,
  3398. HTTPStatusCode: res.StatusCode,
  3399. },
  3400. }
  3401. target := &ret
  3402. if err := gensupport.DecodeResponse(target, res); err != nil {
  3403. return nil, err
  3404. }
  3405. return ret, nil
  3406. // {
  3407. // "description": "Returns permissions that a caller has on the specified resource.\nIf the resource does not exist, this will return an empty set of\npermissions, not a NOT_FOUND error.\n\nNote: This operation is designed to be used for building permission-aware\nUIs and command-line tools, not for authorization checking. This operation\nmay \"fail open\" without warning.",
  3408. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings/{keyRingsId}/cryptoKeys/{cryptoKeysId}:testIamPermissions",
  3409. // "httpMethod": "POST",
  3410. // "id": "cloudkms.projects.locations.keyRings.cryptoKeys.testIamPermissions",
  3411. // "parameterOrder": [
  3412. // "resource"
  3413. // ],
  3414. // "parameters": {
  3415. // "resource": {
  3416. // "description": "REQUIRED: The resource for which the policy detail is being requested.\nSee the operation documentation for the appropriate value for this field.",
  3417. // "location": "path",
  3418. // "pattern": "^projects/[^/]+/locations/[^/]+/keyRings/[^/]+/cryptoKeys/[^/]+$",
  3419. // "required": true,
  3420. // "type": "string"
  3421. // }
  3422. // },
  3423. // "path": "v1/{+resource}:testIamPermissions",
  3424. // "request": {
  3425. // "$ref": "TestIamPermissionsRequest"
  3426. // },
  3427. // "response": {
  3428. // "$ref": "TestIamPermissionsResponse"
  3429. // },
  3430. // "scopes": [
  3431. // "https://www.googleapis.com/auth/cloud-platform"
  3432. // ]
  3433. // }
  3434. }
  3435. // method id "cloudkms.projects.locations.keyRings.cryptoKeys.updatePrimaryVersion":
  3436. type ProjectsLocationsKeyRingsCryptoKeysUpdatePrimaryVersionCall struct {
  3437. s *Service
  3438. name string
  3439. updatecryptokeyprimaryversionrequest *UpdateCryptoKeyPrimaryVersionRequest
  3440. urlParams_ gensupport.URLParams
  3441. ctx_ context.Context
  3442. header_ http.Header
  3443. }
  3444. // UpdatePrimaryVersion: Update the version of a CryptoKey that will be
  3445. // used in Encrypt
  3446. func (r *ProjectsLocationsKeyRingsCryptoKeysService) UpdatePrimaryVersion(name string, updatecryptokeyprimaryversionrequest *UpdateCryptoKeyPrimaryVersionRequest) *ProjectsLocationsKeyRingsCryptoKeysUpdatePrimaryVersionCall {
  3447. c := &ProjectsLocationsKeyRingsCryptoKeysUpdatePrimaryVersionCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3448. c.name = name
  3449. c.updatecryptokeyprimaryversionrequest = updatecryptokeyprimaryversionrequest
  3450. return c
  3451. }
  3452. // Fields allows partial responses to be retrieved. See
  3453. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3454. // for more information.
  3455. func (c *ProjectsLocationsKeyRingsCryptoKeysUpdatePrimaryVersionCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsCryptoKeysUpdatePrimaryVersionCall {
  3456. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3457. return c
  3458. }
  3459. // Context sets the context to be used in this call's Do method. Any
  3460. // pending HTTP request will be aborted if the provided context is
  3461. // canceled.
  3462. func (c *ProjectsLocationsKeyRingsCryptoKeysUpdatePrimaryVersionCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsCryptoKeysUpdatePrimaryVersionCall {
  3463. c.ctx_ = ctx
  3464. return c
  3465. }
  3466. // Header returns an http.Header that can be modified by the caller to
  3467. // add HTTP headers to the request.
  3468. func (c *ProjectsLocationsKeyRingsCryptoKeysUpdatePrimaryVersionCall) Header() http.Header {
  3469. if c.header_ == nil {
  3470. c.header_ = make(http.Header)
  3471. }
  3472. return c.header_
  3473. }
  3474. func (c *ProjectsLocationsKeyRingsCryptoKeysUpdatePrimaryVersionCall) doRequest(alt string) (*http.Response, error) {
  3475. reqHeaders := make(http.Header)
  3476. for k, v := range c.header_ {
  3477. reqHeaders[k] = v
  3478. }
  3479. reqHeaders.Set("User-Agent", c.s.userAgent())
  3480. var body io.Reader = nil
  3481. body, err := googleapi.WithoutDataWrapper.JSONReader(c.updatecryptokeyprimaryversionrequest)
  3482. if err != nil {
  3483. return nil, err
  3484. }
  3485. reqHeaders.Set("Content-Type", "application/json")
  3486. c.urlParams_.Set("alt", alt)
  3487. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:updatePrimaryVersion")
  3488. urls += "?" + c.urlParams_.Encode()
  3489. req, _ := http.NewRequest("POST", urls, body)
  3490. req.Header = reqHeaders
  3491. googleapi.Expand(req.URL, map[string]string{
  3492. "name": c.name,
  3493. })
  3494. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3495. }
  3496. // Do executes the "cloudkms.projects.locations.keyRings.cryptoKeys.updatePrimaryVersion" call.
  3497. // Exactly one of *CryptoKey or error will be non-nil. Any non-2xx
  3498. // status code is an error. Response headers are in either
  3499. // *CryptoKey.ServerResponse.Header or (if a response was returned at
  3500. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  3501. // to check whether the returned error was because
  3502. // http.StatusNotModified was returned.
  3503. func (c *ProjectsLocationsKeyRingsCryptoKeysUpdatePrimaryVersionCall) Do(opts ...googleapi.CallOption) (*CryptoKey, error) {
  3504. gensupport.SetOptions(c.urlParams_, opts...)
  3505. res, err := c.doRequest("json")
  3506. if res != nil && res.StatusCode == http.StatusNotModified {
  3507. if res.Body != nil {
  3508. res.Body.Close()
  3509. }
  3510. return nil, &googleapi.Error{
  3511. Code: res.StatusCode,
  3512. Header: res.Header,
  3513. }
  3514. }
  3515. if err != nil {
  3516. return nil, err
  3517. }
  3518. defer googleapi.CloseBody(res)
  3519. if err := googleapi.CheckResponse(res); err != nil {
  3520. return nil, err
  3521. }
  3522. ret := &CryptoKey{
  3523. ServerResponse: googleapi.ServerResponse{
  3524. Header: res.Header,
  3525. HTTPStatusCode: res.StatusCode,
  3526. },
  3527. }
  3528. target := &ret
  3529. if err := gensupport.DecodeResponse(target, res); err != nil {
  3530. return nil, err
  3531. }
  3532. return ret, nil
  3533. // {
  3534. // "description": "Update the version of a CryptoKey that will be used in Encrypt",
  3535. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings/{keyRingsId}/cryptoKeys/{cryptoKeysId}:updatePrimaryVersion",
  3536. // "httpMethod": "POST",
  3537. // "id": "cloudkms.projects.locations.keyRings.cryptoKeys.updatePrimaryVersion",
  3538. // "parameterOrder": [
  3539. // "name"
  3540. // ],
  3541. // "parameters": {
  3542. // "name": {
  3543. // "description": "The resource name of the CryptoKey to update.",
  3544. // "location": "path",
  3545. // "pattern": "^projects/[^/]+/locations/[^/]+/keyRings/[^/]+/cryptoKeys/[^/]+$",
  3546. // "required": true,
  3547. // "type": "string"
  3548. // }
  3549. // },
  3550. // "path": "v1/{+name}:updatePrimaryVersion",
  3551. // "request": {
  3552. // "$ref": "UpdateCryptoKeyPrimaryVersionRequest"
  3553. // },
  3554. // "response": {
  3555. // "$ref": "CryptoKey"
  3556. // },
  3557. // "scopes": [
  3558. // "https://www.googleapis.com/auth/cloud-platform"
  3559. // ]
  3560. // }
  3561. }
  3562. // method id "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.create":
  3563. type ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsCreateCall struct {
  3564. s *Service
  3565. parent string
  3566. cryptokeyversion *CryptoKeyVersion
  3567. urlParams_ gensupport.URLParams
  3568. ctx_ context.Context
  3569. header_ http.Header
  3570. }
  3571. // Create: Create a new CryptoKeyVersion in a CryptoKey.
  3572. //
  3573. // The server will assign the next sequential id. If unset,
  3574. // state will be set to
  3575. // ENABLED.
  3576. func (r *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsService) Create(parent string, cryptokeyversion *CryptoKeyVersion) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsCreateCall {
  3577. c := &ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3578. c.parent = parent
  3579. c.cryptokeyversion = cryptokeyversion
  3580. return c
  3581. }
  3582. // Fields allows partial responses to be retrieved. See
  3583. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3584. // for more information.
  3585. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsCreateCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsCreateCall {
  3586. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3587. return c
  3588. }
  3589. // Context sets the context to be used in this call's Do method. Any
  3590. // pending HTTP request will be aborted if the provided context is
  3591. // canceled.
  3592. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsCreateCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsCreateCall {
  3593. c.ctx_ = ctx
  3594. return c
  3595. }
  3596. // Header returns an http.Header that can be modified by the caller to
  3597. // add HTTP headers to the request.
  3598. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsCreateCall) Header() http.Header {
  3599. if c.header_ == nil {
  3600. c.header_ = make(http.Header)
  3601. }
  3602. return c.header_
  3603. }
  3604. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsCreateCall) doRequest(alt string) (*http.Response, error) {
  3605. reqHeaders := make(http.Header)
  3606. for k, v := range c.header_ {
  3607. reqHeaders[k] = v
  3608. }
  3609. reqHeaders.Set("User-Agent", c.s.userAgent())
  3610. var body io.Reader = nil
  3611. body, err := googleapi.WithoutDataWrapper.JSONReader(c.cryptokeyversion)
  3612. if err != nil {
  3613. return nil, err
  3614. }
  3615. reqHeaders.Set("Content-Type", "application/json")
  3616. c.urlParams_.Set("alt", alt)
  3617. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/cryptoKeyVersions")
  3618. urls += "?" + c.urlParams_.Encode()
  3619. req, _ := http.NewRequest("POST", urls, body)
  3620. req.Header = reqHeaders
  3621. googleapi.Expand(req.URL, map[string]string{
  3622. "parent": c.parent,
  3623. })
  3624. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3625. }
  3626. // Do executes the "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.create" call.
  3627. // Exactly one of *CryptoKeyVersion or error will be non-nil. Any
  3628. // non-2xx status code is an error. Response headers are in either
  3629. // *CryptoKeyVersion.ServerResponse.Header or (if a response was
  3630. // returned at all) in error.(*googleapi.Error).Header. Use
  3631. // googleapi.IsNotModified to check whether the returned error was
  3632. // because http.StatusNotModified was returned.
  3633. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsCreateCall) Do(opts ...googleapi.CallOption) (*CryptoKeyVersion, error) {
  3634. gensupport.SetOptions(c.urlParams_, opts...)
  3635. res, err := c.doRequest("json")
  3636. if res != nil && res.StatusCode == http.StatusNotModified {
  3637. if res.Body != nil {
  3638. res.Body.Close()
  3639. }
  3640. return nil, &googleapi.Error{
  3641. Code: res.StatusCode,
  3642. Header: res.Header,
  3643. }
  3644. }
  3645. if err != nil {
  3646. return nil, err
  3647. }
  3648. defer googleapi.CloseBody(res)
  3649. if err := googleapi.CheckResponse(res); err != nil {
  3650. return nil, err
  3651. }
  3652. ret := &CryptoKeyVersion{
  3653. ServerResponse: googleapi.ServerResponse{
  3654. Header: res.Header,
  3655. HTTPStatusCode: res.StatusCode,
  3656. },
  3657. }
  3658. target := &ret
  3659. if err := gensupport.DecodeResponse(target, res); err != nil {
  3660. return nil, err
  3661. }
  3662. return ret, nil
  3663. // {
  3664. // "description": "Create a new CryptoKeyVersion in a CryptoKey.\n\nThe server will assign the next sequential id. If unset,\nstate will be set to\nENABLED.",
  3665. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings/{keyRingsId}/cryptoKeys/{cryptoKeysId}/cryptoKeyVersions",
  3666. // "httpMethod": "POST",
  3667. // "id": "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.create",
  3668. // "parameterOrder": [
  3669. // "parent"
  3670. // ],
  3671. // "parameters": {
  3672. // "parent": {
  3673. // "description": "Required. The name of the CryptoKey associated with\nthe CryptoKeyVersions.",
  3674. // "location": "path",
  3675. // "pattern": "^projects/[^/]+/locations/[^/]+/keyRings/[^/]+/cryptoKeys/[^/]+$",
  3676. // "required": true,
  3677. // "type": "string"
  3678. // }
  3679. // },
  3680. // "path": "v1/{+parent}/cryptoKeyVersions",
  3681. // "request": {
  3682. // "$ref": "CryptoKeyVersion"
  3683. // },
  3684. // "response": {
  3685. // "$ref": "CryptoKeyVersion"
  3686. // },
  3687. // "scopes": [
  3688. // "https://www.googleapis.com/auth/cloud-platform"
  3689. // ]
  3690. // }
  3691. }
  3692. // method id "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.destroy":
  3693. type ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsDestroyCall struct {
  3694. s *Service
  3695. name string
  3696. destroycryptokeyversionrequest *DestroyCryptoKeyVersionRequest
  3697. urlParams_ gensupport.URLParams
  3698. ctx_ context.Context
  3699. header_ http.Header
  3700. }
  3701. // Destroy: Schedule a CryptoKeyVersion for destruction.
  3702. //
  3703. // Upon calling this method, CryptoKeyVersion.state will be set
  3704. // to
  3705. // DESTROY_SCHEDULED
  3706. // and destroy_time will be set to a time 24
  3707. // hours in the future, at which point the state
  3708. // will be changed to
  3709. // DESTROYED, and the key
  3710. // material will be irrevocably destroyed.
  3711. //
  3712. // Before the destroy_time is reached,
  3713. // RestoreCryptoKeyVersion may be called to reverse the process.
  3714. func (r *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsService) Destroy(name string, destroycryptokeyversionrequest *DestroyCryptoKeyVersionRequest) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsDestroyCall {
  3715. c := &ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsDestroyCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3716. c.name = name
  3717. c.destroycryptokeyversionrequest = destroycryptokeyversionrequest
  3718. return c
  3719. }
  3720. // Fields allows partial responses to be retrieved. See
  3721. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3722. // for more information.
  3723. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsDestroyCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsDestroyCall {
  3724. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3725. return c
  3726. }
  3727. // Context sets the context to be used in this call's Do method. Any
  3728. // pending HTTP request will be aborted if the provided context is
  3729. // canceled.
  3730. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsDestroyCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsDestroyCall {
  3731. c.ctx_ = ctx
  3732. return c
  3733. }
  3734. // Header returns an http.Header that can be modified by the caller to
  3735. // add HTTP headers to the request.
  3736. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsDestroyCall) Header() http.Header {
  3737. if c.header_ == nil {
  3738. c.header_ = make(http.Header)
  3739. }
  3740. return c.header_
  3741. }
  3742. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsDestroyCall) doRequest(alt string) (*http.Response, error) {
  3743. reqHeaders := make(http.Header)
  3744. for k, v := range c.header_ {
  3745. reqHeaders[k] = v
  3746. }
  3747. reqHeaders.Set("User-Agent", c.s.userAgent())
  3748. var body io.Reader = nil
  3749. body, err := googleapi.WithoutDataWrapper.JSONReader(c.destroycryptokeyversionrequest)
  3750. if err != nil {
  3751. return nil, err
  3752. }
  3753. reqHeaders.Set("Content-Type", "application/json")
  3754. c.urlParams_.Set("alt", alt)
  3755. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:destroy")
  3756. urls += "?" + c.urlParams_.Encode()
  3757. req, _ := http.NewRequest("POST", urls, body)
  3758. req.Header = reqHeaders
  3759. googleapi.Expand(req.URL, map[string]string{
  3760. "name": c.name,
  3761. })
  3762. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3763. }
  3764. // Do executes the "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.destroy" call.
  3765. // Exactly one of *CryptoKeyVersion or error will be non-nil. Any
  3766. // non-2xx status code is an error. Response headers are in either
  3767. // *CryptoKeyVersion.ServerResponse.Header or (if a response was
  3768. // returned at all) in error.(*googleapi.Error).Header. Use
  3769. // googleapi.IsNotModified to check whether the returned error was
  3770. // because http.StatusNotModified was returned.
  3771. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsDestroyCall) Do(opts ...googleapi.CallOption) (*CryptoKeyVersion, error) {
  3772. gensupport.SetOptions(c.urlParams_, opts...)
  3773. res, err := c.doRequest("json")
  3774. if res != nil && res.StatusCode == http.StatusNotModified {
  3775. if res.Body != nil {
  3776. res.Body.Close()
  3777. }
  3778. return nil, &googleapi.Error{
  3779. Code: res.StatusCode,
  3780. Header: res.Header,
  3781. }
  3782. }
  3783. if err != nil {
  3784. return nil, err
  3785. }
  3786. defer googleapi.CloseBody(res)
  3787. if err := googleapi.CheckResponse(res); err != nil {
  3788. return nil, err
  3789. }
  3790. ret := &CryptoKeyVersion{
  3791. ServerResponse: googleapi.ServerResponse{
  3792. Header: res.Header,
  3793. HTTPStatusCode: res.StatusCode,
  3794. },
  3795. }
  3796. target := &ret
  3797. if err := gensupport.DecodeResponse(target, res); err != nil {
  3798. return nil, err
  3799. }
  3800. return ret, nil
  3801. // {
  3802. // "description": "Schedule a CryptoKeyVersion for destruction.\n\nUpon calling this method, CryptoKeyVersion.state will be set to\nDESTROY_SCHEDULED\nand destroy_time will be set to a time 24\nhours in the future, at which point the state\nwill be changed to\nDESTROYED, and the key\nmaterial will be irrevocably destroyed.\n\nBefore the destroy_time is reached,\nRestoreCryptoKeyVersion may be called to reverse the process.",
  3803. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings/{keyRingsId}/cryptoKeys/{cryptoKeysId}/cryptoKeyVersions/{cryptoKeyVersionsId}:destroy",
  3804. // "httpMethod": "POST",
  3805. // "id": "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.destroy",
  3806. // "parameterOrder": [
  3807. // "name"
  3808. // ],
  3809. // "parameters": {
  3810. // "name": {
  3811. // "description": "The resource name of the CryptoKeyVersion to destroy.",
  3812. // "location": "path",
  3813. // "pattern": "^projects/[^/]+/locations/[^/]+/keyRings/[^/]+/cryptoKeys/[^/]+/cryptoKeyVersions/[^/]+$",
  3814. // "required": true,
  3815. // "type": "string"
  3816. // }
  3817. // },
  3818. // "path": "v1/{+name}:destroy",
  3819. // "request": {
  3820. // "$ref": "DestroyCryptoKeyVersionRequest"
  3821. // },
  3822. // "response": {
  3823. // "$ref": "CryptoKeyVersion"
  3824. // },
  3825. // "scopes": [
  3826. // "https://www.googleapis.com/auth/cloud-platform"
  3827. // ]
  3828. // }
  3829. }
  3830. // method id "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.get":
  3831. type ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsGetCall struct {
  3832. s *Service
  3833. name string
  3834. urlParams_ gensupport.URLParams
  3835. ifNoneMatch_ string
  3836. ctx_ context.Context
  3837. header_ http.Header
  3838. }
  3839. // Get: Returns metadata for a given CryptoKeyVersion.
  3840. func (r *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsService) Get(name string) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsGetCall {
  3841. c := &ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3842. c.name = name
  3843. return c
  3844. }
  3845. // Fields allows partial responses to be retrieved. See
  3846. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3847. // for more information.
  3848. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsGetCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsGetCall {
  3849. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3850. return c
  3851. }
  3852. // IfNoneMatch sets the optional parameter which makes the operation
  3853. // fail if the object's ETag matches the given value. This is useful for
  3854. // getting updates only after the object has changed since the last
  3855. // request. Use googleapi.IsNotModified to check whether the response
  3856. // error from Do is the result of In-None-Match.
  3857. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsGetCall) IfNoneMatch(entityTag string) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsGetCall {
  3858. c.ifNoneMatch_ = entityTag
  3859. return c
  3860. }
  3861. // Context sets the context to be used in this call's Do method. Any
  3862. // pending HTTP request will be aborted if the provided context is
  3863. // canceled.
  3864. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsGetCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsGetCall {
  3865. c.ctx_ = ctx
  3866. return c
  3867. }
  3868. // Header returns an http.Header that can be modified by the caller to
  3869. // add HTTP headers to the request.
  3870. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsGetCall) Header() http.Header {
  3871. if c.header_ == nil {
  3872. c.header_ = make(http.Header)
  3873. }
  3874. return c.header_
  3875. }
  3876. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsGetCall) doRequest(alt string) (*http.Response, error) {
  3877. reqHeaders := make(http.Header)
  3878. for k, v := range c.header_ {
  3879. reqHeaders[k] = v
  3880. }
  3881. reqHeaders.Set("User-Agent", c.s.userAgent())
  3882. if c.ifNoneMatch_ != "" {
  3883. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  3884. }
  3885. var body io.Reader = nil
  3886. c.urlParams_.Set("alt", alt)
  3887. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  3888. urls += "?" + c.urlParams_.Encode()
  3889. req, _ := http.NewRequest("GET", urls, body)
  3890. req.Header = reqHeaders
  3891. googleapi.Expand(req.URL, map[string]string{
  3892. "name": c.name,
  3893. })
  3894. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  3895. }
  3896. // Do executes the "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.get" call.
  3897. // Exactly one of *CryptoKeyVersion or error will be non-nil. Any
  3898. // non-2xx status code is an error. Response headers are in either
  3899. // *CryptoKeyVersion.ServerResponse.Header or (if a response was
  3900. // returned at all) in error.(*googleapi.Error).Header. Use
  3901. // googleapi.IsNotModified to check whether the returned error was
  3902. // because http.StatusNotModified was returned.
  3903. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsGetCall) Do(opts ...googleapi.CallOption) (*CryptoKeyVersion, error) {
  3904. gensupport.SetOptions(c.urlParams_, opts...)
  3905. res, err := c.doRequest("json")
  3906. if res != nil && res.StatusCode == http.StatusNotModified {
  3907. if res.Body != nil {
  3908. res.Body.Close()
  3909. }
  3910. return nil, &googleapi.Error{
  3911. Code: res.StatusCode,
  3912. Header: res.Header,
  3913. }
  3914. }
  3915. if err != nil {
  3916. return nil, err
  3917. }
  3918. defer googleapi.CloseBody(res)
  3919. if err := googleapi.CheckResponse(res); err != nil {
  3920. return nil, err
  3921. }
  3922. ret := &CryptoKeyVersion{
  3923. ServerResponse: googleapi.ServerResponse{
  3924. Header: res.Header,
  3925. HTTPStatusCode: res.StatusCode,
  3926. },
  3927. }
  3928. target := &ret
  3929. if err := gensupport.DecodeResponse(target, res); err != nil {
  3930. return nil, err
  3931. }
  3932. return ret, nil
  3933. // {
  3934. // "description": "Returns metadata for a given CryptoKeyVersion.",
  3935. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings/{keyRingsId}/cryptoKeys/{cryptoKeysId}/cryptoKeyVersions/{cryptoKeyVersionsId}",
  3936. // "httpMethod": "GET",
  3937. // "id": "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.get",
  3938. // "parameterOrder": [
  3939. // "name"
  3940. // ],
  3941. // "parameters": {
  3942. // "name": {
  3943. // "description": "The name of the CryptoKeyVersion to get.",
  3944. // "location": "path",
  3945. // "pattern": "^projects/[^/]+/locations/[^/]+/keyRings/[^/]+/cryptoKeys/[^/]+/cryptoKeyVersions/[^/]+$",
  3946. // "required": true,
  3947. // "type": "string"
  3948. // }
  3949. // },
  3950. // "path": "v1/{+name}",
  3951. // "response": {
  3952. // "$ref": "CryptoKeyVersion"
  3953. // },
  3954. // "scopes": [
  3955. // "https://www.googleapis.com/auth/cloud-platform"
  3956. // ]
  3957. // }
  3958. }
  3959. // method id "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.list":
  3960. type ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsListCall struct {
  3961. s *Service
  3962. parent string
  3963. urlParams_ gensupport.URLParams
  3964. ifNoneMatch_ string
  3965. ctx_ context.Context
  3966. header_ http.Header
  3967. }
  3968. // List: Lists CryptoKeyVersions.
  3969. func (r *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsService) List(parent string) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsListCall {
  3970. c := &ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  3971. c.parent = parent
  3972. return c
  3973. }
  3974. // PageSize sets the optional parameter "pageSize": Optional limit on
  3975. // the number of CryptoKeyVersions to
  3976. // include in the response. Further CryptoKeyVersions can
  3977. // subsequently be obtained by including
  3978. // the
  3979. // ListCryptoKeyVersionsResponse.next_page_token in a subsequent
  3980. // request.
  3981. // If unspecified, the server will pick an appropriate default.
  3982. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsListCall) PageSize(pageSize int64) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsListCall {
  3983. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  3984. return c
  3985. }
  3986. // PageToken sets the optional parameter "pageToken": Optional
  3987. // pagination token, returned earlier
  3988. // via
  3989. // ListCryptoKeyVersionsResponse.next_page_token.
  3990. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsListCall) PageToken(pageToken string) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsListCall {
  3991. c.urlParams_.Set("pageToken", pageToken)
  3992. return c
  3993. }
  3994. // Fields allows partial responses to be retrieved. See
  3995. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  3996. // for more information.
  3997. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsListCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsListCall {
  3998. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  3999. return c
  4000. }
  4001. // IfNoneMatch sets the optional parameter which makes the operation
  4002. // fail if the object's ETag matches the given value. This is useful for
  4003. // getting updates only after the object has changed since the last
  4004. // request. Use googleapi.IsNotModified to check whether the response
  4005. // error from Do is the result of In-None-Match.
  4006. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsListCall) IfNoneMatch(entityTag string) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsListCall {
  4007. c.ifNoneMatch_ = entityTag
  4008. return c
  4009. }
  4010. // Context sets the context to be used in this call's Do method. Any
  4011. // pending HTTP request will be aborted if the provided context is
  4012. // canceled.
  4013. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsListCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsListCall {
  4014. c.ctx_ = ctx
  4015. return c
  4016. }
  4017. // Header returns an http.Header that can be modified by the caller to
  4018. // add HTTP headers to the request.
  4019. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsListCall) Header() http.Header {
  4020. if c.header_ == nil {
  4021. c.header_ = make(http.Header)
  4022. }
  4023. return c.header_
  4024. }
  4025. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsListCall) doRequest(alt string) (*http.Response, error) {
  4026. reqHeaders := make(http.Header)
  4027. for k, v := range c.header_ {
  4028. reqHeaders[k] = v
  4029. }
  4030. reqHeaders.Set("User-Agent", c.s.userAgent())
  4031. if c.ifNoneMatch_ != "" {
  4032. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  4033. }
  4034. var body io.Reader = nil
  4035. c.urlParams_.Set("alt", alt)
  4036. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/cryptoKeyVersions")
  4037. urls += "?" + c.urlParams_.Encode()
  4038. req, _ := http.NewRequest("GET", urls, body)
  4039. req.Header = reqHeaders
  4040. googleapi.Expand(req.URL, map[string]string{
  4041. "parent": c.parent,
  4042. })
  4043. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4044. }
  4045. // Do executes the "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.list" call.
  4046. // Exactly one of *ListCryptoKeyVersionsResponse or error will be
  4047. // non-nil. Any non-2xx status code is an error. Response headers are in
  4048. // either *ListCryptoKeyVersionsResponse.ServerResponse.Header or (if a
  4049. // response was returned at all) in error.(*googleapi.Error).Header. Use
  4050. // googleapi.IsNotModified to check whether the returned error was
  4051. // because http.StatusNotModified was returned.
  4052. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsListCall) Do(opts ...googleapi.CallOption) (*ListCryptoKeyVersionsResponse, error) {
  4053. gensupport.SetOptions(c.urlParams_, opts...)
  4054. res, err := c.doRequest("json")
  4055. if res != nil && res.StatusCode == http.StatusNotModified {
  4056. if res.Body != nil {
  4057. res.Body.Close()
  4058. }
  4059. return nil, &googleapi.Error{
  4060. Code: res.StatusCode,
  4061. Header: res.Header,
  4062. }
  4063. }
  4064. if err != nil {
  4065. return nil, err
  4066. }
  4067. defer googleapi.CloseBody(res)
  4068. if err := googleapi.CheckResponse(res); err != nil {
  4069. return nil, err
  4070. }
  4071. ret := &ListCryptoKeyVersionsResponse{
  4072. ServerResponse: googleapi.ServerResponse{
  4073. Header: res.Header,
  4074. HTTPStatusCode: res.StatusCode,
  4075. },
  4076. }
  4077. target := &ret
  4078. if err := gensupport.DecodeResponse(target, res); err != nil {
  4079. return nil, err
  4080. }
  4081. return ret, nil
  4082. // {
  4083. // "description": "Lists CryptoKeyVersions.",
  4084. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings/{keyRingsId}/cryptoKeys/{cryptoKeysId}/cryptoKeyVersions",
  4085. // "httpMethod": "GET",
  4086. // "id": "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.list",
  4087. // "parameterOrder": [
  4088. // "parent"
  4089. // ],
  4090. // "parameters": {
  4091. // "pageSize": {
  4092. // "description": "Optional limit on the number of CryptoKeyVersions to\ninclude in the response. Further CryptoKeyVersions can\nsubsequently be obtained by including the\nListCryptoKeyVersionsResponse.next_page_token in a subsequent request.\nIf unspecified, the server will pick an appropriate default.",
  4093. // "format": "int32",
  4094. // "location": "query",
  4095. // "type": "integer"
  4096. // },
  4097. // "pageToken": {
  4098. // "description": "Optional pagination token, returned earlier via\nListCryptoKeyVersionsResponse.next_page_token.",
  4099. // "location": "query",
  4100. // "type": "string"
  4101. // },
  4102. // "parent": {
  4103. // "description": "Required. The resource name of the CryptoKey to list, in the format\n`projects/*/locations/*/keyRings/*/cryptoKeys/*`.",
  4104. // "location": "path",
  4105. // "pattern": "^projects/[^/]+/locations/[^/]+/keyRings/[^/]+/cryptoKeys/[^/]+$",
  4106. // "required": true,
  4107. // "type": "string"
  4108. // }
  4109. // },
  4110. // "path": "v1/{+parent}/cryptoKeyVersions",
  4111. // "response": {
  4112. // "$ref": "ListCryptoKeyVersionsResponse"
  4113. // },
  4114. // "scopes": [
  4115. // "https://www.googleapis.com/auth/cloud-platform"
  4116. // ]
  4117. // }
  4118. }
  4119. // Pages invokes f for each page of results.
  4120. // A non-nil error returned from f will halt the iteration.
  4121. // The provided context supersedes any context provided to the Context method.
  4122. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsListCall) Pages(ctx context.Context, f func(*ListCryptoKeyVersionsResponse) error) error {
  4123. c.ctx_ = ctx
  4124. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  4125. for {
  4126. x, err := c.Do()
  4127. if err != nil {
  4128. return err
  4129. }
  4130. if err := f(x); err != nil {
  4131. return err
  4132. }
  4133. if x.NextPageToken == "" {
  4134. return nil
  4135. }
  4136. c.PageToken(x.NextPageToken)
  4137. }
  4138. }
  4139. // method id "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.patch":
  4140. type ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsPatchCall struct {
  4141. s *Service
  4142. name string
  4143. cryptokeyversion *CryptoKeyVersion
  4144. urlParams_ gensupport.URLParams
  4145. ctx_ context.Context
  4146. header_ http.Header
  4147. }
  4148. // Patch: Update a CryptoKeyVersion's metadata.
  4149. //
  4150. // state may be changed between
  4151. // ENABLED and
  4152. // DISABLED using this
  4153. // method. See DestroyCryptoKeyVersion and RestoreCryptoKeyVersion
  4154. // to
  4155. // move between other states.
  4156. func (r *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsService) Patch(name string, cryptokeyversion *CryptoKeyVersion) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsPatchCall {
  4157. c := &ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4158. c.name = name
  4159. c.cryptokeyversion = cryptokeyversion
  4160. return c
  4161. }
  4162. // UpdateMask sets the optional parameter "updateMask": Required list of
  4163. // fields to be updated in this request.
  4164. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsPatchCall) UpdateMask(updateMask string) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsPatchCall {
  4165. c.urlParams_.Set("updateMask", updateMask)
  4166. return c
  4167. }
  4168. // Fields allows partial responses to be retrieved. See
  4169. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4170. // for more information.
  4171. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsPatchCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsPatchCall {
  4172. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4173. return c
  4174. }
  4175. // Context sets the context to be used in this call's Do method. Any
  4176. // pending HTTP request will be aborted if the provided context is
  4177. // canceled.
  4178. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsPatchCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsPatchCall {
  4179. c.ctx_ = ctx
  4180. return c
  4181. }
  4182. // Header returns an http.Header that can be modified by the caller to
  4183. // add HTTP headers to the request.
  4184. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsPatchCall) Header() http.Header {
  4185. if c.header_ == nil {
  4186. c.header_ = make(http.Header)
  4187. }
  4188. return c.header_
  4189. }
  4190. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsPatchCall) doRequest(alt string) (*http.Response, error) {
  4191. reqHeaders := make(http.Header)
  4192. for k, v := range c.header_ {
  4193. reqHeaders[k] = v
  4194. }
  4195. reqHeaders.Set("User-Agent", c.s.userAgent())
  4196. var body io.Reader = nil
  4197. body, err := googleapi.WithoutDataWrapper.JSONReader(c.cryptokeyversion)
  4198. if err != nil {
  4199. return nil, err
  4200. }
  4201. reqHeaders.Set("Content-Type", "application/json")
  4202. c.urlParams_.Set("alt", alt)
  4203. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}")
  4204. urls += "?" + c.urlParams_.Encode()
  4205. req, _ := http.NewRequest("PATCH", urls, body)
  4206. req.Header = reqHeaders
  4207. googleapi.Expand(req.URL, map[string]string{
  4208. "name": c.name,
  4209. })
  4210. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4211. }
  4212. // Do executes the "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.patch" call.
  4213. // Exactly one of *CryptoKeyVersion or error will be non-nil. Any
  4214. // non-2xx status code is an error. Response headers are in either
  4215. // *CryptoKeyVersion.ServerResponse.Header or (if a response was
  4216. // returned at all) in error.(*googleapi.Error).Header. Use
  4217. // googleapi.IsNotModified to check whether the returned error was
  4218. // because http.StatusNotModified was returned.
  4219. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsPatchCall) Do(opts ...googleapi.CallOption) (*CryptoKeyVersion, error) {
  4220. gensupport.SetOptions(c.urlParams_, opts...)
  4221. res, err := c.doRequest("json")
  4222. if res != nil && res.StatusCode == http.StatusNotModified {
  4223. if res.Body != nil {
  4224. res.Body.Close()
  4225. }
  4226. return nil, &googleapi.Error{
  4227. Code: res.StatusCode,
  4228. Header: res.Header,
  4229. }
  4230. }
  4231. if err != nil {
  4232. return nil, err
  4233. }
  4234. defer googleapi.CloseBody(res)
  4235. if err := googleapi.CheckResponse(res); err != nil {
  4236. return nil, err
  4237. }
  4238. ret := &CryptoKeyVersion{
  4239. ServerResponse: googleapi.ServerResponse{
  4240. Header: res.Header,
  4241. HTTPStatusCode: res.StatusCode,
  4242. },
  4243. }
  4244. target := &ret
  4245. if err := gensupport.DecodeResponse(target, res); err != nil {
  4246. return nil, err
  4247. }
  4248. return ret, nil
  4249. // {
  4250. // "description": "Update a CryptoKeyVersion's metadata.\n\nstate may be changed between\nENABLED and\nDISABLED using this\nmethod. See DestroyCryptoKeyVersion and RestoreCryptoKeyVersion to\nmove between other states.",
  4251. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings/{keyRingsId}/cryptoKeys/{cryptoKeysId}/cryptoKeyVersions/{cryptoKeyVersionsId}",
  4252. // "httpMethod": "PATCH",
  4253. // "id": "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.patch",
  4254. // "parameterOrder": [
  4255. // "name"
  4256. // ],
  4257. // "parameters": {
  4258. // "name": {
  4259. // "description": "Output only. The resource name for this CryptoKeyVersion in the format\n`projects/*/locations/*/keyRings/*/cryptoKeys/*/cryptoKeyVersions/*`.",
  4260. // "location": "path",
  4261. // "pattern": "^projects/[^/]+/locations/[^/]+/keyRings/[^/]+/cryptoKeys/[^/]+/cryptoKeyVersions/[^/]+$",
  4262. // "required": true,
  4263. // "type": "string"
  4264. // },
  4265. // "updateMask": {
  4266. // "description": "Required list of fields to be updated in this request.",
  4267. // "format": "google-fieldmask",
  4268. // "location": "query",
  4269. // "type": "string"
  4270. // }
  4271. // },
  4272. // "path": "v1/{+name}",
  4273. // "request": {
  4274. // "$ref": "CryptoKeyVersion"
  4275. // },
  4276. // "response": {
  4277. // "$ref": "CryptoKeyVersion"
  4278. // },
  4279. // "scopes": [
  4280. // "https://www.googleapis.com/auth/cloud-platform"
  4281. // ]
  4282. // }
  4283. }
  4284. // method id "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.restore":
  4285. type ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsRestoreCall struct {
  4286. s *Service
  4287. name string
  4288. restorecryptokeyversionrequest *RestoreCryptoKeyVersionRequest
  4289. urlParams_ gensupport.URLParams
  4290. ctx_ context.Context
  4291. header_ http.Header
  4292. }
  4293. // Restore: Restore a CryptoKeyVersion in
  4294. // the
  4295. // DESTROY_SCHEDULED
  4296. // state.
  4297. //
  4298. // Upon restoration of the CryptoKeyVersion, state
  4299. // will be set to DISABLED,
  4300. // and destroy_time will be cleared.
  4301. func (r *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsService) Restore(name string, restorecryptokeyversionrequest *RestoreCryptoKeyVersionRequest) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsRestoreCall {
  4302. c := &ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsRestoreCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  4303. c.name = name
  4304. c.restorecryptokeyversionrequest = restorecryptokeyversionrequest
  4305. return c
  4306. }
  4307. // Fields allows partial responses to be retrieved. See
  4308. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  4309. // for more information.
  4310. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsRestoreCall) Fields(s ...googleapi.Field) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsRestoreCall {
  4311. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  4312. return c
  4313. }
  4314. // Context sets the context to be used in this call's Do method. Any
  4315. // pending HTTP request will be aborted if the provided context is
  4316. // canceled.
  4317. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsRestoreCall) Context(ctx context.Context) *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsRestoreCall {
  4318. c.ctx_ = ctx
  4319. return c
  4320. }
  4321. // Header returns an http.Header that can be modified by the caller to
  4322. // add HTTP headers to the request.
  4323. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsRestoreCall) Header() http.Header {
  4324. if c.header_ == nil {
  4325. c.header_ = make(http.Header)
  4326. }
  4327. return c.header_
  4328. }
  4329. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsRestoreCall) doRequest(alt string) (*http.Response, error) {
  4330. reqHeaders := make(http.Header)
  4331. for k, v := range c.header_ {
  4332. reqHeaders[k] = v
  4333. }
  4334. reqHeaders.Set("User-Agent", c.s.userAgent())
  4335. var body io.Reader = nil
  4336. body, err := googleapi.WithoutDataWrapper.JSONReader(c.restorecryptokeyversionrequest)
  4337. if err != nil {
  4338. return nil, err
  4339. }
  4340. reqHeaders.Set("Content-Type", "application/json")
  4341. c.urlParams_.Set("alt", alt)
  4342. urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}:restore")
  4343. urls += "?" + c.urlParams_.Encode()
  4344. req, _ := http.NewRequest("POST", urls, body)
  4345. req.Header = reqHeaders
  4346. googleapi.Expand(req.URL, map[string]string{
  4347. "name": c.name,
  4348. })
  4349. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  4350. }
  4351. // Do executes the "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.restore" call.
  4352. // Exactly one of *CryptoKeyVersion or error will be non-nil. Any
  4353. // non-2xx status code is an error. Response headers are in either
  4354. // *CryptoKeyVersion.ServerResponse.Header or (if a response was
  4355. // returned at all) in error.(*googleapi.Error).Header. Use
  4356. // googleapi.IsNotModified to check whether the returned error was
  4357. // because http.StatusNotModified was returned.
  4358. func (c *ProjectsLocationsKeyRingsCryptoKeysCryptoKeyVersionsRestoreCall) Do(opts ...googleapi.CallOption) (*CryptoKeyVersion, error) {
  4359. gensupport.SetOptions(c.urlParams_, opts...)
  4360. res, err := c.doRequest("json")
  4361. if res != nil && res.StatusCode == http.StatusNotModified {
  4362. if res.Body != nil {
  4363. res.Body.Close()
  4364. }
  4365. return nil, &googleapi.Error{
  4366. Code: res.StatusCode,
  4367. Header: res.Header,
  4368. }
  4369. }
  4370. if err != nil {
  4371. return nil, err
  4372. }
  4373. defer googleapi.CloseBody(res)
  4374. if err := googleapi.CheckResponse(res); err != nil {
  4375. return nil, err
  4376. }
  4377. ret := &CryptoKeyVersion{
  4378. ServerResponse: googleapi.ServerResponse{
  4379. Header: res.Header,
  4380. HTTPStatusCode: res.StatusCode,
  4381. },
  4382. }
  4383. target := &ret
  4384. if err := gensupport.DecodeResponse(target, res); err != nil {
  4385. return nil, err
  4386. }
  4387. return ret, nil
  4388. // {
  4389. // "description": "Restore a CryptoKeyVersion in the\nDESTROY_SCHEDULED\nstate.\n\nUpon restoration of the CryptoKeyVersion, state\nwill be set to DISABLED,\nand destroy_time will be cleared.",
  4390. // "flatPath": "v1/projects/{projectsId}/locations/{locationsId}/keyRings/{keyRingsId}/cryptoKeys/{cryptoKeysId}/cryptoKeyVersions/{cryptoKeyVersionsId}:restore",
  4391. // "httpMethod": "POST",
  4392. // "id": "cloudkms.projects.locations.keyRings.cryptoKeys.cryptoKeyVersions.restore",
  4393. // "parameterOrder": [
  4394. // "name"
  4395. // ],
  4396. // "parameters": {
  4397. // "name": {
  4398. // "description": "The resource name of the CryptoKeyVersion to restore.",
  4399. // "location": "path",
  4400. // "pattern": "^projects/[^/]+/locations/[^/]+/keyRings/[^/]+/cryptoKeys/[^/]+/cryptoKeyVersions/[^/]+$",
  4401. // "required": true,
  4402. // "type": "string"
  4403. // }
  4404. // },
  4405. // "path": "v1/{+name}:restore",
  4406. // "request": {
  4407. // "$ref": "RestoreCryptoKeyVersionRequest"
  4408. // },
  4409. // "response": {
  4410. // "$ref": "CryptoKeyVersion"
  4411. // },
  4412. // "scopes": [
  4413. // "https://www.googleapis.com/auth/cloud-platform"
  4414. // ]
  4415. // }
  4416. }