examples_test.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package glacier_test
  3. import (
  4. "bytes"
  5. "fmt"
  6. "time"
  7. "github.com/aws/aws-sdk-go/aws"
  8. "github.com/aws/aws-sdk-go/service/glacier"
  9. )
  10. var _ time.Duration
  11. var _ bytes.Buffer
  12. func ExampleGlacier_AbortMultipartUpload() {
  13. svc := glacier.New(nil)
  14. params := &glacier.AbortMultipartUploadInput{
  15. AccountId: aws.String("string"), // Required
  16. UploadId: aws.String("string"), // Required
  17. VaultName: aws.String("string"), // Required
  18. }
  19. resp, err := svc.AbortMultipartUpload(params)
  20. if err != nil {
  21. // Print the error, cast err to awserr.Error to get the Code and
  22. // Message from an error.
  23. fmt.Println(err.Error())
  24. return
  25. }
  26. // Pretty-print the response data.
  27. fmt.Println(resp)
  28. }
  29. func ExampleGlacier_AbortVaultLock() {
  30. svc := glacier.New(nil)
  31. params := &glacier.AbortVaultLockInput{
  32. AccountId: aws.String("string"), // Required
  33. VaultName: aws.String("string"), // Required
  34. }
  35. resp, err := svc.AbortVaultLock(params)
  36. if err != nil {
  37. // Print the error, cast err to awserr.Error to get the Code and
  38. // Message from an error.
  39. fmt.Println(err.Error())
  40. return
  41. }
  42. // Pretty-print the response data.
  43. fmt.Println(resp)
  44. }
  45. func ExampleGlacier_AddTagsToVault() {
  46. svc := glacier.New(nil)
  47. params := &glacier.AddTagsToVaultInput{
  48. AccountId: aws.String("string"), // Required
  49. VaultName: aws.String("string"), // Required
  50. Tags: map[string]*string{
  51. "Key": aws.String("TagValue"), // Required
  52. // More values...
  53. },
  54. }
  55. resp, err := svc.AddTagsToVault(params)
  56. if err != nil {
  57. // Print the error, cast err to awserr.Error to get the Code and
  58. // Message from an error.
  59. fmt.Println(err.Error())
  60. return
  61. }
  62. // Pretty-print the response data.
  63. fmt.Println(resp)
  64. }
  65. func ExampleGlacier_CompleteMultipartUpload() {
  66. svc := glacier.New(nil)
  67. params := &glacier.CompleteMultipartUploadInput{
  68. AccountId: aws.String("string"), // Required
  69. UploadId: aws.String("string"), // Required
  70. VaultName: aws.String("string"), // Required
  71. ArchiveSize: aws.String("string"),
  72. Checksum: aws.String("string"),
  73. }
  74. resp, err := svc.CompleteMultipartUpload(params)
  75. if err != nil {
  76. // Print the error, cast err to awserr.Error to get the Code and
  77. // Message from an error.
  78. fmt.Println(err.Error())
  79. return
  80. }
  81. // Pretty-print the response data.
  82. fmt.Println(resp)
  83. }
  84. func ExampleGlacier_CompleteVaultLock() {
  85. svc := glacier.New(nil)
  86. params := &glacier.CompleteVaultLockInput{
  87. AccountId: aws.String("string"), // Required
  88. LockId: aws.String("string"), // Required
  89. VaultName: aws.String("string"), // Required
  90. }
  91. resp, err := svc.CompleteVaultLock(params)
  92. if err != nil {
  93. // Print the error, cast err to awserr.Error to get the Code and
  94. // Message from an error.
  95. fmt.Println(err.Error())
  96. return
  97. }
  98. // Pretty-print the response data.
  99. fmt.Println(resp)
  100. }
  101. func ExampleGlacier_CreateVault() {
  102. svc := glacier.New(nil)
  103. params := &glacier.CreateVaultInput{
  104. AccountId: aws.String("string"), // Required
  105. VaultName: aws.String("string"), // Required
  106. }
  107. resp, err := svc.CreateVault(params)
  108. if err != nil {
  109. // Print the error, cast err to awserr.Error to get the Code and
  110. // Message from an error.
  111. fmt.Println(err.Error())
  112. return
  113. }
  114. // Pretty-print the response data.
  115. fmt.Println(resp)
  116. }
  117. func ExampleGlacier_DeleteArchive() {
  118. svc := glacier.New(nil)
  119. params := &glacier.DeleteArchiveInput{
  120. AccountId: aws.String("string"), // Required
  121. ArchiveId: aws.String("string"), // Required
  122. VaultName: aws.String("string"), // Required
  123. }
  124. resp, err := svc.DeleteArchive(params)
  125. if err != nil {
  126. // Print the error, cast err to awserr.Error to get the Code and
  127. // Message from an error.
  128. fmt.Println(err.Error())
  129. return
  130. }
  131. // Pretty-print the response data.
  132. fmt.Println(resp)
  133. }
  134. func ExampleGlacier_DeleteVault() {
  135. svc := glacier.New(nil)
  136. params := &glacier.DeleteVaultInput{
  137. AccountId: aws.String("string"), // Required
  138. VaultName: aws.String("string"), // Required
  139. }
  140. resp, err := svc.DeleteVault(params)
  141. if err != nil {
  142. // Print the error, cast err to awserr.Error to get the Code and
  143. // Message from an error.
  144. fmt.Println(err.Error())
  145. return
  146. }
  147. // Pretty-print the response data.
  148. fmt.Println(resp)
  149. }
  150. func ExampleGlacier_DeleteVaultAccessPolicy() {
  151. svc := glacier.New(nil)
  152. params := &glacier.DeleteVaultAccessPolicyInput{
  153. AccountId: aws.String("string"), // Required
  154. VaultName: aws.String("string"), // Required
  155. }
  156. resp, err := svc.DeleteVaultAccessPolicy(params)
  157. if err != nil {
  158. // Print the error, cast err to awserr.Error to get the Code and
  159. // Message from an error.
  160. fmt.Println(err.Error())
  161. return
  162. }
  163. // Pretty-print the response data.
  164. fmt.Println(resp)
  165. }
  166. func ExampleGlacier_DeleteVaultNotifications() {
  167. svc := glacier.New(nil)
  168. params := &glacier.DeleteVaultNotificationsInput{
  169. AccountId: aws.String("string"), // Required
  170. VaultName: aws.String("string"), // Required
  171. }
  172. resp, err := svc.DeleteVaultNotifications(params)
  173. if err != nil {
  174. // Print the error, cast err to awserr.Error to get the Code and
  175. // Message from an error.
  176. fmt.Println(err.Error())
  177. return
  178. }
  179. // Pretty-print the response data.
  180. fmt.Println(resp)
  181. }
  182. func ExampleGlacier_DescribeJob() {
  183. svc := glacier.New(nil)
  184. params := &glacier.DescribeJobInput{
  185. AccountId: aws.String("string"), // Required
  186. JobId: aws.String("string"), // Required
  187. VaultName: aws.String("string"), // Required
  188. }
  189. resp, err := svc.DescribeJob(params)
  190. if err != nil {
  191. // Print the error, cast err to awserr.Error to get the Code and
  192. // Message from an error.
  193. fmt.Println(err.Error())
  194. return
  195. }
  196. // Pretty-print the response data.
  197. fmt.Println(resp)
  198. }
  199. func ExampleGlacier_DescribeVault() {
  200. svc := glacier.New(nil)
  201. params := &glacier.DescribeVaultInput{
  202. AccountId: aws.String("string"), // Required
  203. VaultName: aws.String("string"), // Required
  204. }
  205. resp, err := svc.DescribeVault(params)
  206. if err != nil {
  207. // Print the error, cast err to awserr.Error to get the Code and
  208. // Message from an error.
  209. fmt.Println(err.Error())
  210. return
  211. }
  212. // Pretty-print the response data.
  213. fmt.Println(resp)
  214. }
  215. func ExampleGlacier_GetDataRetrievalPolicy() {
  216. svc := glacier.New(nil)
  217. params := &glacier.GetDataRetrievalPolicyInput{
  218. AccountId: aws.String("string"), // Required
  219. }
  220. resp, err := svc.GetDataRetrievalPolicy(params)
  221. if err != nil {
  222. // Print the error, cast err to awserr.Error to get the Code and
  223. // Message from an error.
  224. fmt.Println(err.Error())
  225. return
  226. }
  227. // Pretty-print the response data.
  228. fmt.Println(resp)
  229. }
  230. func ExampleGlacier_GetJobOutput() {
  231. svc := glacier.New(nil)
  232. params := &glacier.GetJobOutputInput{
  233. AccountId: aws.String("string"), // Required
  234. JobId: aws.String("string"), // Required
  235. VaultName: aws.String("string"), // Required
  236. Range: aws.String("string"),
  237. }
  238. resp, err := svc.GetJobOutput(params)
  239. if err != nil {
  240. // Print the error, cast err to awserr.Error to get the Code and
  241. // Message from an error.
  242. fmt.Println(err.Error())
  243. return
  244. }
  245. // Pretty-print the response data.
  246. fmt.Println(resp)
  247. }
  248. func ExampleGlacier_GetVaultAccessPolicy() {
  249. svc := glacier.New(nil)
  250. params := &glacier.GetVaultAccessPolicyInput{
  251. AccountId: aws.String("string"), // Required
  252. VaultName: aws.String("string"), // Required
  253. }
  254. resp, err := svc.GetVaultAccessPolicy(params)
  255. if err != nil {
  256. // Print the error, cast err to awserr.Error to get the Code and
  257. // Message from an error.
  258. fmt.Println(err.Error())
  259. return
  260. }
  261. // Pretty-print the response data.
  262. fmt.Println(resp)
  263. }
  264. func ExampleGlacier_GetVaultLock() {
  265. svc := glacier.New(nil)
  266. params := &glacier.GetVaultLockInput{
  267. AccountId: aws.String("string"), // Required
  268. VaultName: aws.String("string"), // Required
  269. }
  270. resp, err := svc.GetVaultLock(params)
  271. if err != nil {
  272. // Print the error, cast err to awserr.Error to get the Code and
  273. // Message from an error.
  274. fmt.Println(err.Error())
  275. return
  276. }
  277. // Pretty-print the response data.
  278. fmt.Println(resp)
  279. }
  280. func ExampleGlacier_GetVaultNotifications() {
  281. svc := glacier.New(nil)
  282. params := &glacier.GetVaultNotificationsInput{
  283. AccountId: aws.String("string"), // Required
  284. VaultName: aws.String("string"), // Required
  285. }
  286. resp, err := svc.GetVaultNotifications(params)
  287. if err != nil {
  288. // Print the error, cast err to awserr.Error to get the Code and
  289. // Message from an error.
  290. fmt.Println(err.Error())
  291. return
  292. }
  293. // Pretty-print the response data.
  294. fmt.Println(resp)
  295. }
  296. func ExampleGlacier_InitiateJob() {
  297. svc := glacier.New(nil)
  298. params := &glacier.InitiateJobInput{
  299. AccountId: aws.String("string"), // Required
  300. VaultName: aws.String("string"), // Required
  301. JobParameters: &glacier.JobParameters{
  302. ArchiveId: aws.String("string"),
  303. Description: aws.String("string"),
  304. Format: aws.String("string"),
  305. InventoryRetrievalParameters: &glacier.InventoryRetrievalJobInput{
  306. EndDate: aws.String("string"),
  307. Limit: aws.String("string"),
  308. Marker: aws.String("string"),
  309. StartDate: aws.String("string"),
  310. },
  311. RetrievalByteRange: aws.String("string"),
  312. SNSTopic: aws.String("string"),
  313. Type: aws.String("string"),
  314. },
  315. }
  316. resp, err := svc.InitiateJob(params)
  317. if err != nil {
  318. // Print the error, cast err to awserr.Error to get the Code and
  319. // Message from an error.
  320. fmt.Println(err.Error())
  321. return
  322. }
  323. // Pretty-print the response data.
  324. fmt.Println(resp)
  325. }
  326. func ExampleGlacier_InitiateMultipartUpload() {
  327. svc := glacier.New(nil)
  328. params := &glacier.InitiateMultipartUploadInput{
  329. AccountId: aws.String("string"), // Required
  330. VaultName: aws.String("string"), // Required
  331. ArchiveDescription: aws.String("string"),
  332. PartSize: aws.String("string"),
  333. }
  334. resp, err := svc.InitiateMultipartUpload(params)
  335. if err != nil {
  336. // Print the error, cast err to awserr.Error to get the Code and
  337. // Message from an error.
  338. fmt.Println(err.Error())
  339. return
  340. }
  341. // Pretty-print the response data.
  342. fmt.Println(resp)
  343. }
  344. func ExampleGlacier_InitiateVaultLock() {
  345. svc := glacier.New(nil)
  346. params := &glacier.InitiateVaultLockInput{
  347. AccountId: aws.String("string"), // Required
  348. VaultName: aws.String("string"), // Required
  349. Policy: &glacier.VaultLockPolicy{
  350. Policy: aws.String("string"),
  351. },
  352. }
  353. resp, err := svc.InitiateVaultLock(params)
  354. if err != nil {
  355. // Print the error, cast err to awserr.Error to get the Code and
  356. // Message from an error.
  357. fmt.Println(err.Error())
  358. return
  359. }
  360. // Pretty-print the response data.
  361. fmt.Println(resp)
  362. }
  363. func ExampleGlacier_ListJobs() {
  364. svc := glacier.New(nil)
  365. params := &glacier.ListJobsInput{
  366. AccountId: aws.String("string"), // Required
  367. VaultName: aws.String("string"), // Required
  368. Completed: aws.String("string"),
  369. Limit: aws.String("string"),
  370. Marker: aws.String("string"),
  371. Statuscode: aws.String("string"),
  372. }
  373. resp, err := svc.ListJobs(params)
  374. if err != nil {
  375. // Print the error, cast err to awserr.Error to get the Code and
  376. // Message from an error.
  377. fmt.Println(err.Error())
  378. return
  379. }
  380. // Pretty-print the response data.
  381. fmt.Println(resp)
  382. }
  383. func ExampleGlacier_ListMultipartUploads() {
  384. svc := glacier.New(nil)
  385. params := &glacier.ListMultipartUploadsInput{
  386. AccountId: aws.String("string"), // Required
  387. VaultName: aws.String("string"), // Required
  388. Limit: aws.String("string"),
  389. Marker: aws.String("string"),
  390. }
  391. resp, err := svc.ListMultipartUploads(params)
  392. if err != nil {
  393. // Print the error, cast err to awserr.Error to get the Code and
  394. // Message from an error.
  395. fmt.Println(err.Error())
  396. return
  397. }
  398. // Pretty-print the response data.
  399. fmt.Println(resp)
  400. }
  401. func ExampleGlacier_ListParts() {
  402. svc := glacier.New(nil)
  403. params := &glacier.ListPartsInput{
  404. AccountId: aws.String("string"), // Required
  405. UploadId: aws.String("string"), // Required
  406. VaultName: aws.String("string"), // Required
  407. Limit: aws.String("string"),
  408. Marker: aws.String("string"),
  409. }
  410. resp, err := svc.ListParts(params)
  411. if err != nil {
  412. // Print the error, cast err to awserr.Error to get the Code and
  413. // Message from an error.
  414. fmt.Println(err.Error())
  415. return
  416. }
  417. // Pretty-print the response data.
  418. fmt.Println(resp)
  419. }
  420. func ExampleGlacier_ListTagsForVault() {
  421. svc := glacier.New(nil)
  422. params := &glacier.ListTagsForVaultInput{
  423. AccountId: aws.String("string"), // Required
  424. VaultName: aws.String("string"), // Required
  425. }
  426. resp, err := svc.ListTagsForVault(params)
  427. if err != nil {
  428. // Print the error, cast err to awserr.Error to get the Code and
  429. // Message from an error.
  430. fmt.Println(err.Error())
  431. return
  432. }
  433. // Pretty-print the response data.
  434. fmt.Println(resp)
  435. }
  436. func ExampleGlacier_ListVaults() {
  437. svc := glacier.New(nil)
  438. params := &glacier.ListVaultsInput{
  439. AccountId: aws.String("string"), // Required
  440. Limit: aws.String("string"),
  441. Marker: aws.String("string"),
  442. }
  443. resp, err := svc.ListVaults(params)
  444. if err != nil {
  445. // Print the error, cast err to awserr.Error to get the Code and
  446. // Message from an error.
  447. fmt.Println(err.Error())
  448. return
  449. }
  450. // Pretty-print the response data.
  451. fmt.Println(resp)
  452. }
  453. func ExampleGlacier_RemoveTagsFromVault() {
  454. svc := glacier.New(nil)
  455. params := &glacier.RemoveTagsFromVaultInput{
  456. AccountId: aws.String("string"), // Required
  457. VaultName: aws.String("string"), // Required
  458. TagKeys: []*string{
  459. aws.String("string"), // Required
  460. // More values...
  461. },
  462. }
  463. resp, err := svc.RemoveTagsFromVault(params)
  464. if err != nil {
  465. // Print the error, cast err to awserr.Error to get the Code and
  466. // Message from an error.
  467. fmt.Println(err.Error())
  468. return
  469. }
  470. // Pretty-print the response data.
  471. fmt.Println(resp)
  472. }
  473. func ExampleGlacier_SetDataRetrievalPolicy() {
  474. svc := glacier.New(nil)
  475. params := &glacier.SetDataRetrievalPolicyInput{
  476. AccountId: aws.String("string"), // Required
  477. Policy: &glacier.DataRetrievalPolicy{
  478. Rules: []*glacier.DataRetrievalRule{
  479. { // Required
  480. BytesPerHour: aws.Int64(1),
  481. Strategy: aws.String("string"),
  482. },
  483. // More values...
  484. },
  485. },
  486. }
  487. resp, err := svc.SetDataRetrievalPolicy(params)
  488. if err != nil {
  489. // Print the error, cast err to awserr.Error to get the Code and
  490. // Message from an error.
  491. fmt.Println(err.Error())
  492. return
  493. }
  494. // Pretty-print the response data.
  495. fmt.Println(resp)
  496. }
  497. func ExampleGlacier_SetVaultAccessPolicy() {
  498. svc := glacier.New(nil)
  499. params := &glacier.SetVaultAccessPolicyInput{
  500. AccountId: aws.String("string"), // Required
  501. VaultName: aws.String("string"), // Required
  502. Policy: &glacier.VaultAccessPolicy{
  503. Policy: aws.String("string"),
  504. },
  505. }
  506. resp, err := svc.SetVaultAccessPolicy(params)
  507. if err != nil {
  508. // Print the error, cast err to awserr.Error to get the Code and
  509. // Message from an error.
  510. fmt.Println(err.Error())
  511. return
  512. }
  513. // Pretty-print the response data.
  514. fmt.Println(resp)
  515. }
  516. func ExampleGlacier_SetVaultNotifications() {
  517. svc := glacier.New(nil)
  518. params := &glacier.SetVaultNotificationsInput{
  519. AccountId: aws.String("string"), // Required
  520. VaultName: aws.String("string"), // Required
  521. VaultNotificationConfig: &glacier.VaultNotificationConfig{
  522. Events: []*string{
  523. aws.String("string"), // Required
  524. // More values...
  525. },
  526. SNSTopic: aws.String("string"),
  527. },
  528. }
  529. resp, err := svc.SetVaultNotifications(params)
  530. if err != nil {
  531. // Print the error, cast err to awserr.Error to get the Code and
  532. // Message from an error.
  533. fmt.Println(err.Error())
  534. return
  535. }
  536. // Pretty-print the response data.
  537. fmt.Println(resp)
  538. }
  539. func ExampleGlacier_UploadArchive() {
  540. svc := glacier.New(nil)
  541. params := &glacier.UploadArchiveInput{
  542. AccountId: aws.String("string"), // Required
  543. VaultName: aws.String("string"), // Required
  544. ArchiveDescription: aws.String("string"),
  545. Body: bytes.NewReader([]byte("PAYLOAD")),
  546. Checksum: aws.String("string"),
  547. }
  548. resp, err := svc.UploadArchive(params)
  549. if err != nil {
  550. // Print the error, cast err to awserr.Error to get the Code and
  551. // Message from an error.
  552. fmt.Println(err.Error())
  553. return
  554. }
  555. // Pretty-print the response data.
  556. fmt.Println(resp)
  557. }
  558. func ExampleGlacier_UploadMultipartPart() {
  559. svc := glacier.New(nil)
  560. params := &glacier.UploadMultipartPartInput{
  561. AccountId: aws.String("string"), // Required
  562. UploadId: aws.String("string"), // Required
  563. VaultName: aws.String("string"), // Required
  564. Body: bytes.NewReader([]byte("PAYLOAD")),
  565. Checksum: aws.String("string"),
  566. Range: aws.String("string"),
  567. }
  568. resp, err := svc.UploadMultipartPart(params)
  569. if err != nil {
  570. // Print the error, cast err to awserr.Error to get the Code and
  571. // Message from an error.
  572. fmt.Println(err.Error())
  573. return
  574. }
  575. // Pretty-print the response data.
  576. fmt.Println(resp)
  577. }