examples_test.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package kms_test
  3. import (
  4. "bytes"
  5. "fmt"
  6. "time"
  7. "github.com/aws/aws-sdk-go/aws"
  8. "github.com/aws/aws-sdk-go/aws/session"
  9. "github.com/aws/aws-sdk-go/service/kms"
  10. )
  11. var _ time.Duration
  12. var _ bytes.Buffer
  13. func ExampleKMS_CancelKeyDeletion() {
  14. sess, err := session.NewSession()
  15. if err != nil {
  16. fmt.Println("failed to create session,", err)
  17. return
  18. }
  19. svc := kms.New(sess)
  20. params := &kms.CancelKeyDeletionInput{
  21. KeyId: aws.String("KeyIdType"), // Required
  22. }
  23. resp, err := svc.CancelKeyDeletion(params)
  24. if err != nil {
  25. // Print the error, cast err to awserr.Error to get the Code and
  26. // Message from an error.
  27. fmt.Println(err.Error())
  28. return
  29. }
  30. // Pretty-print the response data.
  31. fmt.Println(resp)
  32. }
  33. func ExampleKMS_CreateAlias() {
  34. sess, err := session.NewSession()
  35. if err != nil {
  36. fmt.Println("failed to create session,", err)
  37. return
  38. }
  39. svc := kms.New(sess)
  40. params := &kms.CreateAliasInput{
  41. AliasName: aws.String("AliasNameType"), // Required
  42. TargetKeyId: aws.String("KeyIdType"), // Required
  43. }
  44. resp, err := svc.CreateAlias(params)
  45. if err != nil {
  46. // Print the error, cast err to awserr.Error to get the Code and
  47. // Message from an error.
  48. fmt.Println(err.Error())
  49. return
  50. }
  51. // Pretty-print the response data.
  52. fmt.Println(resp)
  53. }
  54. func ExampleKMS_CreateGrant() {
  55. sess, err := session.NewSession()
  56. if err != nil {
  57. fmt.Println("failed to create session,", err)
  58. return
  59. }
  60. svc := kms.New(sess)
  61. params := &kms.CreateGrantInput{
  62. GranteePrincipal: aws.String("PrincipalIdType"), // Required
  63. KeyId: aws.String("KeyIdType"), // Required
  64. Constraints: &kms.GrantConstraints{
  65. EncryptionContextEquals: map[string]*string{
  66. "Key": aws.String("EncryptionContextValue"), // Required
  67. // More values...
  68. },
  69. EncryptionContextSubset: map[string]*string{
  70. "Key": aws.String("EncryptionContextValue"), // Required
  71. // More values...
  72. },
  73. },
  74. GrantTokens: []*string{
  75. aws.String("GrantTokenType"), // Required
  76. // More values...
  77. },
  78. Name: aws.String("GrantNameType"),
  79. Operations: []*string{
  80. aws.String("GrantOperation"), // Required
  81. // More values...
  82. },
  83. RetiringPrincipal: aws.String("PrincipalIdType"),
  84. }
  85. resp, err := svc.CreateGrant(params)
  86. if err != nil {
  87. // Print the error, cast err to awserr.Error to get the Code and
  88. // Message from an error.
  89. fmt.Println(err.Error())
  90. return
  91. }
  92. // Pretty-print the response data.
  93. fmt.Println(resp)
  94. }
  95. func ExampleKMS_CreateKey() {
  96. sess, err := session.NewSession()
  97. if err != nil {
  98. fmt.Println("failed to create session,", err)
  99. return
  100. }
  101. svc := kms.New(sess)
  102. params := &kms.CreateKeyInput{
  103. BypassPolicyLockoutSafetyCheck: aws.Bool(true),
  104. Description: aws.String("DescriptionType"),
  105. KeyUsage: aws.String("KeyUsageType"),
  106. Origin: aws.String("OriginType"),
  107. Policy: aws.String("PolicyType"),
  108. }
  109. resp, err := svc.CreateKey(params)
  110. if err != nil {
  111. // Print the error, cast err to awserr.Error to get the Code and
  112. // Message from an error.
  113. fmt.Println(err.Error())
  114. return
  115. }
  116. // Pretty-print the response data.
  117. fmt.Println(resp)
  118. }
  119. func ExampleKMS_Decrypt() {
  120. sess, err := session.NewSession()
  121. if err != nil {
  122. fmt.Println("failed to create session,", err)
  123. return
  124. }
  125. svc := kms.New(sess)
  126. params := &kms.DecryptInput{
  127. CiphertextBlob: []byte("PAYLOAD"), // Required
  128. EncryptionContext: map[string]*string{
  129. "Key": aws.String("EncryptionContextValue"), // Required
  130. // More values...
  131. },
  132. GrantTokens: []*string{
  133. aws.String("GrantTokenType"), // Required
  134. // More values...
  135. },
  136. }
  137. resp, err := svc.Decrypt(params)
  138. if err != nil {
  139. // Print the error, cast err to awserr.Error to get the Code and
  140. // Message from an error.
  141. fmt.Println(err.Error())
  142. return
  143. }
  144. // Pretty-print the response data.
  145. fmt.Println(resp)
  146. }
  147. func ExampleKMS_DeleteAlias() {
  148. sess, err := session.NewSession()
  149. if err != nil {
  150. fmt.Println("failed to create session,", err)
  151. return
  152. }
  153. svc := kms.New(sess)
  154. params := &kms.DeleteAliasInput{
  155. AliasName: aws.String("AliasNameType"), // Required
  156. }
  157. resp, err := svc.DeleteAlias(params)
  158. if err != nil {
  159. // Print the error, cast err to awserr.Error to get the Code and
  160. // Message from an error.
  161. fmt.Println(err.Error())
  162. return
  163. }
  164. // Pretty-print the response data.
  165. fmt.Println(resp)
  166. }
  167. func ExampleKMS_DeleteImportedKeyMaterial() {
  168. sess, err := session.NewSession()
  169. if err != nil {
  170. fmt.Println("failed to create session,", err)
  171. return
  172. }
  173. svc := kms.New(sess)
  174. params := &kms.DeleteImportedKeyMaterialInput{
  175. KeyId: aws.String("KeyIdType"), // Required
  176. }
  177. resp, err := svc.DeleteImportedKeyMaterial(params)
  178. if err != nil {
  179. // Print the error, cast err to awserr.Error to get the Code and
  180. // Message from an error.
  181. fmt.Println(err.Error())
  182. return
  183. }
  184. // Pretty-print the response data.
  185. fmt.Println(resp)
  186. }
  187. func ExampleKMS_DescribeKey() {
  188. sess, err := session.NewSession()
  189. if err != nil {
  190. fmt.Println("failed to create session,", err)
  191. return
  192. }
  193. svc := kms.New(sess)
  194. params := &kms.DescribeKeyInput{
  195. KeyId: aws.String("KeyIdType"), // Required
  196. GrantTokens: []*string{
  197. aws.String("GrantTokenType"), // Required
  198. // More values...
  199. },
  200. }
  201. resp, err := svc.DescribeKey(params)
  202. if err != nil {
  203. // Print the error, cast err to awserr.Error to get the Code and
  204. // Message from an error.
  205. fmt.Println(err.Error())
  206. return
  207. }
  208. // Pretty-print the response data.
  209. fmt.Println(resp)
  210. }
  211. func ExampleKMS_DisableKey() {
  212. sess, err := session.NewSession()
  213. if err != nil {
  214. fmt.Println("failed to create session,", err)
  215. return
  216. }
  217. svc := kms.New(sess)
  218. params := &kms.DisableKeyInput{
  219. KeyId: aws.String("KeyIdType"), // Required
  220. }
  221. resp, err := svc.DisableKey(params)
  222. if err != nil {
  223. // Print the error, cast err to awserr.Error to get the Code and
  224. // Message from an error.
  225. fmt.Println(err.Error())
  226. return
  227. }
  228. // Pretty-print the response data.
  229. fmt.Println(resp)
  230. }
  231. func ExampleKMS_DisableKeyRotation() {
  232. sess, err := session.NewSession()
  233. if err != nil {
  234. fmt.Println("failed to create session,", err)
  235. return
  236. }
  237. svc := kms.New(sess)
  238. params := &kms.DisableKeyRotationInput{
  239. KeyId: aws.String("KeyIdType"), // Required
  240. }
  241. resp, err := svc.DisableKeyRotation(params)
  242. if err != nil {
  243. // Print the error, cast err to awserr.Error to get the Code and
  244. // Message from an error.
  245. fmt.Println(err.Error())
  246. return
  247. }
  248. // Pretty-print the response data.
  249. fmt.Println(resp)
  250. }
  251. func ExampleKMS_EnableKey() {
  252. sess, err := session.NewSession()
  253. if err != nil {
  254. fmt.Println("failed to create session,", err)
  255. return
  256. }
  257. svc := kms.New(sess)
  258. params := &kms.EnableKeyInput{
  259. KeyId: aws.String("KeyIdType"), // Required
  260. }
  261. resp, err := svc.EnableKey(params)
  262. if err != nil {
  263. // Print the error, cast err to awserr.Error to get the Code and
  264. // Message from an error.
  265. fmt.Println(err.Error())
  266. return
  267. }
  268. // Pretty-print the response data.
  269. fmt.Println(resp)
  270. }
  271. func ExampleKMS_EnableKeyRotation() {
  272. sess, err := session.NewSession()
  273. if err != nil {
  274. fmt.Println("failed to create session,", err)
  275. return
  276. }
  277. svc := kms.New(sess)
  278. params := &kms.EnableKeyRotationInput{
  279. KeyId: aws.String("KeyIdType"), // Required
  280. }
  281. resp, err := svc.EnableKeyRotation(params)
  282. if err != nil {
  283. // Print the error, cast err to awserr.Error to get the Code and
  284. // Message from an error.
  285. fmt.Println(err.Error())
  286. return
  287. }
  288. // Pretty-print the response data.
  289. fmt.Println(resp)
  290. }
  291. func ExampleKMS_Encrypt() {
  292. sess, err := session.NewSession()
  293. if err != nil {
  294. fmt.Println("failed to create session,", err)
  295. return
  296. }
  297. svc := kms.New(sess)
  298. params := &kms.EncryptInput{
  299. KeyId: aws.String("KeyIdType"), // Required
  300. Plaintext: []byte("PAYLOAD"), // Required
  301. EncryptionContext: map[string]*string{
  302. "Key": aws.String("EncryptionContextValue"), // Required
  303. // More values...
  304. },
  305. GrantTokens: []*string{
  306. aws.String("GrantTokenType"), // Required
  307. // More values...
  308. },
  309. }
  310. resp, err := svc.Encrypt(params)
  311. if err != nil {
  312. // Print the error, cast err to awserr.Error to get the Code and
  313. // Message from an error.
  314. fmt.Println(err.Error())
  315. return
  316. }
  317. // Pretty-print the response data.
  318. fmt.Println(resp)
  319. }
  320. func ExampleKMS_GenerateDataKey() {
  321. sess, err := session.NewSession()
  322. if err != nil {
  323. fmt.Println("failed to create session,", err)
  324. return
  325. }
  326. svc := kms.New(sess)
  327. params := &kms.GenerateDataKeyInput{
  328. KeyId: aws.String("KeyIdType"), // Required
  329. EncryptionContext: map[string]*string{
  330. "Key": aws.String("EncryptionContextValue"), // Required
  331. // More values...
  332. },
  333. GrantTokens: []*string{
  334. aws.String("GrantTokenType"), // Required
  335. // More values...
  336. },
  337. KeySpec: aws.String("DataKeySpec"),
  338. NumberOfBytes: aws.Int64(1),
  339. }
  340. resp, err := svc.GenerateDataKey(params)
  341. if err != nil {
  342. // Print the error, cast err to awserr.Error to get the Code and
  343. // Message from an error.
  344. fmt.Println(err.Error())
  345. return
  346. }
  347. // Pretty-print the response data.
  348. fmt.Println(resp)
  349. }
  350. func ExampleKMS_GenerateDataKeyWithoutPlaintext() {
  351. sess, err := session.NewSession()
  352. if err != nil {
  353. fmt.Println("failed to create session,", err)
  354. return
  355. }
  356. svc := kms.New(sess)
  357. params := &kms.GenerateDataKeyWithoutPlaintextInput{
  358. KeyId: aws.String("KeyIdType"), // Required
  359. EncryptionContext: map[string]*string{
  360. "Key": aws.String("EncryptionContextValue"), // Required
  361. // More values...
  362. },
  363. GrantTokens: []*string{
  364. aws.String("GrantTokenType"), // Required
  365. // More values...
  366. },
  367. KeySpec: aws.String("DataKeySpec"),
  368. NumberOfBytes: aws.Int64(1),
  369. }
  370. resp, err := svc.GenerateDataKeyWithoutPlaintext(params)
  371. if err != nil {
  372. // Print the error, cast err to awserr.Error to get the Code and
  373. // Message from an error.
  374. fmt.Println(err.Error())
  375. return
  376. }
  377. // Pretty-print the response data.
  378. fmt.Println(resp)
  379. }
  380. func ExampleKMS_GenerateRandom() {
  381. sess, err := session.NewSession()
  382. if err != nil {
  383. fmt.Println("failed to create session,", err)
  384. return
  385. }
  386. svc := kms.New(sess)
  387. params := &kms.GenerateRandomInput{
  388. NumberOfBytes: aws.Int64(1),
  389. }
  390. resp, err := svc.GenerateRandom(params)
  391. if err != nil {
  392. // Print the error, cast err to awserr.Error to get the Code and
  393. // Message from an error.
  394. fmt.Println(err.Error())
  395. return
  396. }
  397. // Pretty-print the response data.
  398. fmt.Println(resp)
  399. }
  400. func ExampleKMS_GetKeyPolicy() {
  401. sess, err := session.NewSession()
  402. if err != nil {
  403. fmt.Println("failed to create session,", err)
  404. return
  405. }
  406. svc := kms.New(sess)
  407. params := &kms.GetKeyPolicyInput{
  408. KeyId: aws.String("KeyIdType"), // Required
  409. PolicyName: aws.String("PolicyNameType"), // Required
  410. }
  411. resp, err := svc.GetKeyPolicy(params)
  412. if err != nil {
  413. // Print the error, cast err to awserr.Error to get the Code and
  414. // Message from an error.
  415. fmt.Println(err.Error())
  416. return
  417. }
  418. // Pretty-print the response data.
  419. fmt.Println(resp)
  420. }
  421. func ExampleKMS_GetKeyRotationStatus() {
  422. sess, err := session.NewSession()
  423. if err != nil {
  424. fmt.Println("failed to create session,", err)
  425. return
  426. }
  427. svc := kms.New(sess)
  428. params := &kms.GetKeyRotationStatusInput{
  429. KeyId: aws.String("KeyIdType"), // Required
  430. }
  431. resp, err := svc.GetKeyRotationStatus(params)
  432. if err != nil {
  433. // Print the error, cast err to awserr.Error to get the Code and
  434. // Message from an error.
  435. fmt.Println(err.Error())
  436. return
  437. }
  438. // Pretty-print the response data.
  439. fmt.Println(resp)
  440. }
  441. func ExampleKMS_GetParametersForImport() {
  442. sess, err := session.NewSession()
  443. if err != nil {
  444. fmt.Println("failed to create session,", err)
  445. return
  446. }
  447. svc := kms.New(sess)
  448. params := &kms.GetParametersForImportInput{
  449. KeyId: aws.String("KeyIdType"), // Required
  450. WrappingAlgorithm: aws.String("AlgorithmSpec"), // Required
  451. WrappingKeySpec: aws.String("WrappingKeySpec"), // Required
  452. }
  453. resp, err := svc.GetParametersForImport(params)
  454. if err != nil {
  455. // Print the error, cast err to awserr.Error to get the Code and
  456. // Message from an error.
  457. fmt.Println(err.Error())
  458. return
  459. }
  460. // Pretty-print the response data.
  461. fmt.Println(resp)
  462. }
  463. func ExampleKMS_ImportKeyMaterial() {
  464. sess, err := session.NewSession()
  465. if err != nil {
  466. fmt.Println("failed to create session,", err)
  467. return
  468. }
  469. svc := kms.New(sess)
  470. params := &kms.ImportKeyMaterialInput{
  471. EncryptedKeyMaterial: []byte("PAYLOAD"), // Required
  472. ImportToken: []byte("PAYLOAD"), // Required
  473. KeyId: aws.String("KeyIdType"), // Required
  474. ValidTo: aws.Time(time.Now()), // Required
  475. ExpirationModel: aws.String("ExpirationModelType"),
  476. }
  477. resp, err := svc.ImportKeyMaterial(params)
  478. if err != nil {
  479. // Print the error, cast err to awserr.Error to get the Code and
  480. // Message from an error.
  481. fmt.Println(err.Error())
  482. return
  483. }
  484. // Pretty-print the response data.
  485. fmt.Println(resp)
  486. }
  487. func ExampleKMS_ListAliases() {
  488. sess, err := session.NewSession()
  489. if err != nil {
  490. fmt.Println("failed to create session,", err)
  491. return
  492. }
  493. svc := kms.New(sess)
  494. params := &kms.ListAliasesInput{
  495. Limit: aws.Int64(1),
  496. Marker: aws.String("MarkerType"),
  497. }
  498. resp, err := svc.ListAliases(params)
  499. if err != nil {
  500. // Print the error, cast err to awserr.Error to get the Code and
  501. // Message from an error.
  502. fmt.Println(err.Error())
  503. return
  504. }
  505. // Pretty-print the response data.
  506. fmt.Println(resp)
  507. }
  508. func ExampleKMS_ListGrants() {
  509. sess, err := session.NewSession()
  510. if err != nil {
  511. fmt.Println("failed to create session,", err)
  512. return
  513. }
  514. svc := kms.New(sess)
  515. params := &kms.ListGrantsInput{
  516. KeyId: aws.String("KeyIdType"), // Required
  517. Limit: aws.Int64(1),
  518. Marker: aws.String("MarkerType"),
  519. }
  520. resp, err := svc.ListGrants(params)
  521. if err != nil {
  522. // Print the error, cast err to awserr.Error to get the Code and
  523. // Message from an error.
  524. fmt.Println(err.Error())
  525. return
  526. }
  527. // Pretty-print the response data.
  528. fmt.Println(resp)
  529. }
  530. func ExampleKMS_ListKeyPolicies() {
  531. sess, err := session.NewSession()
  532. if err != nil {
  533. fmt.Println("failed to create session,", err)
  534. return
  535. }
  536. svc := kms.New(sess)
  537. params := &kms.ListKeyPoliciesInput{
  538. KeyId: aws.String("KeyIdType"), // Required
  539. Limit: aws.Int64(1),
  540. Marker: aws.String("MarkerType"),
  541. }
  542. resp, err := svc.ListKeyPolicies(params)
  543. if err != nil {
  544. // Print the error, cast err to awserr.Error to get the Code and
  545. // Message from an error.
  546. fmt.Println(err.Error())
  547. return
  548. }
  549. // Pretty-print the response data.
  550. fmt.Println(resp)
  551. }
  552. func ExampleKMS_ListKeys() {
  553. sess, err := session.NewSession()
  554. if err != nil {
  555. fmt.Println("failed to create session,", err)
  556. return
  557. }
  558. svc := kms.New(sess)
  559. params := &kms.ListKeysInput{
  560. Limit: aws.Int64(1),
  561. Marker: aws.String("MarkerType"),
  562. }
  563. resp, err := svc.ListKeys(params)
  564. if err != nil {
  565. // Print the error, cast err to awserr.Error to get the Code and
  566. // Message from an error.
  567. fmt.Println(err.Error())
  568. return
  569. }
  570. // Pretty-print the response data.
  571. fmt.Println(resp)
  572. }
  573. func ExampleKMS_ListRetirableGrants() {
  574. sess, err := session.NewSession()
  575. if err != nil {
  576. fmt.Println("failed to create session,", err)
  577. return
  578. }
  579. svc := kms.New(sess)
  580. params := &kms.ListRetirableGrantsInput{
  581. RetiringPrincipal: aws.String("PrincipalIdType"), // Required
  582. Limit: aws.Int64(1),
  583. Marker: aws.String("MarkerType"),
  584. }
  585. resp, err := svc.ListRetirableGrants(params)
  586. if err != nil {
  587. // Print the error, cast err to awserr.Error to get the Code and
  588. // Message from an error.
  589. fmt.Println(err.Error())
  590. return
  591. }
  592. // Pretty-print the response data.
  593. fmt.Println(resp)
  594. }
  595. func ExampleKMS_PutKeyPolicy() {
  596. sess, err := session.NewSession()
  597. if err != nil {
  598. fmt.Println("failed to create session,", err)
  599. return
  600. }
  601. svc := kms.New(sess)
  602. params := &kms.PutKeyPolicyInput{
  603. KeyId: aws.String("KeyIdType"), // Required
  604. Policy: aws.String("PolicyType"), // Required
  605. PolicyName: aws.String("PolicyNameType"), // Required
  606. BypassPolicyLockoutSafetyCheck: aws.Bool(true),
  607. }
  608. resp, err := svc.PutKeyPolicy(params)
  609. if err != nil {
  610. // Print the error, cast err to awserr.Error to get the Code and
  611. // Message from an error.
  612. fmt.Println(err.Error())
  613. return
  614. }
  615. // Pretty-print the response data.
  616. fmt.Println(resp)
  617. }
  618. func ExampleKMS_ReEncrypt() {
  619. sess, err := session.NewSession()
  620. if err != nil {
  621. fmt.Println("failed to create session,", err)
  622. return
  623. }
  624. svc := kms.New(sess)
  625. params := &kms.ReEncryptInput{
  626. CiphertextBlob: []byte("PAYLOAD"), // Required
  627. DestinationKeyId: aws.String("KeyIdType"), // Required
  628. DestinationEncryptionContext: map[string]*string{
  629. "Key": aws.String("EncryptionContextValue"), // Required
  630. // More values...
  631. },
  632. GrantTokens: []*string{
  633. aws.String("GrantTokenType"), // Required
  634. // More values...
  635. },
  636. SourceEncryptionContext: map[string]*string{
  637. "Key": aws.String("EncryptionContextValue"), // Required
  638. // More values...
  639. },
  640. }
  641. resp, err := svc.ReEncrypt(params)
  642. if err != nil {
  643. // Print the error, cast err to awserr.Error to get the Code and
  644. // Message from an error.
  645. fmt.Println(err.Error())
  646. return
  647. }
  648. // Pretty-print the response data.
  649. fmt.Println(resp)
  650. }
  651. func ExampleKMS_RetireGrant() {
  652. sess, err := session.NewSession()
  653. if err != nil {
  654. fmt.Println("failed to create session,", err)
  655. return
  656. }
  657. svc := kms.New(sess)
  658. params := &kms.RetireGrantInput{
  659. GrantId: aws.String("GrantIdType"),
  660. GrantToken: aws.String("GrantTokenType"),
  661. KeyId: aws.String("KeyIdType"),
  662. }
  663. resp, err := svc.RetireGrant(params)
  664. if err != nil {
  665. // Print the error, cast err to awserr.Error to get the Code and
  666. // Message from an error.
  667. fmt.Println(err.Error())
  668. return
  669. }
  670. // Pretty-print the response data.
  671. fmt.Println(resp)
  672. }
  673. func ExampleKMS_RevokeGrant() {
  674. sess, err := session.NewSession()
  675. if err != nil {
  676. fmt.Println("failed to create session,", err)
  677. return
  678. }
  679. svc := kms.New(sess)
  680. params := &kms.RevokeGrantInput{
  681. GrantId: aws.String("GrantIdType"), // Required
  682. KeyId: aws.String("KeyIdType"), // Required
  683. }
  684. resp, err := svc.RevokeGrant(params)
  685. if err != nil {
  686. // Print the error, cast err to awserr.Error to get the Code and
  687. // Message from an error.
  688. fmt.Println(err.Error())
  689. return
  690. }
  691. // Pretty-print the response data.
  692. fmt.Println(resp)
  693. }
  694. func ExampleKMS_ScheduleKeyDeletion() {
  695. sess, err := session.NewSession()
  696. if err != nil {
  697. fmt.Println("failed to create session,", err)
  698. return
  699. }
  700. svc := kms.New(sess)
  701. params := &kms.ScheduleKeyDeletionInput{
  702. KeyId: aws.String("KeyIdType"), // Required
  703. PendingWindowInDays: aws.Int64(1),
  704. }
  705. resp, err := svc.ScheduleKeyDeletion(params)
  706. if err != nil {
  707. // Print the error, cast err to awserr.Error to get the Code and
  708. // Message from an error.
  709. fmt.Println(err.Error())
  710. return
  711. }
  712. // Pretty-print the response data.
  713. fmt.Println(resp)
  714. }
  715. func ExampleKMS_UpdateAlias() {
  716. sess, err := session.NewSession()
  717. if err != nil {
  718. fmt.Println("failed to create session,", err)
  719. return
  720. }
  721. svc := kms.New(sess)
  722. params := &kms.UpdateAliasInput{
  723. AliasName: aws.String("AliasNameType"), // Required
  724. TargetKeyId: aws.String("KeyIdType"), // Required
  725. }
  726. resp, err := svc.UpdateAlias(params)
  727. if err != nil {
  728. // Print the error, cast err to awserr.Error to get the Code and
  729. // Message from an error.
  730. fmt.Println(err.Error())
  731. return
  732. }
  733. // Pretty-print the response data.
  734. fmt.Println(resp)
  735. }
  736. func ExampleKMS_UpdateKeyDescription() {
  737. sess, err := session.NewSession()
  738. if err != nil {
  739. fmt.Println("failed to create session,", err)
  740. return
  741. }
  742. svc := kms.New(sess)
  743. params := &kms.UpdateKeyDescriptionInput{
  744. Description: aws.String("DescriptionType"), // Required
  745. KeyId: aws.String("KeyIdType"), // Required
  746. }
  747. resp, err := svc.UpdateKeyDescription(params)
  748. if err != nil {
  749. // Print the error, cast err to awserr.Error to get the Code and
  750. // Message from an error.
  751. fmt.Println(err.Error())
  752. return
  753. }
  754. // Pretty-print the response data.
  755. fmt.Println(resp)
  756. }