mirror of
https://github.com/Luzifer/cloudkeys-go.git
synced 2024-11-10 07:00:08 +00:00
1274 lines
42 KiB
Go
1274 lines
42 KiB
Go
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
|
|
|
package glacier_test
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/aws/aws-sdk-go/aws"
|
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
|
"github.com/aws/aws-sdk-go/aws/session"
|
|
"github.com/aws/aws-sdk-go/service/glacier"
|
|
)
|
|
|
|
var _ time.Duration
|
|
var _ strings.Reader
|
|
var _ aws.Config
|
|
|
|
func parseTime(layout, value string) *time.Time {
|
|
t, err := time.Parse(layout, value)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return &t
|
|
}
|
|
|
|
// To abort a multipart upload identified by the upload ID
|
|
//
|
|
// The example deletes an in-progress multipart upload to a vault named my-vault:
|
|
func ExampleGlacier_AbortMultipartUpload_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.AbortMultipartUploadInput{
|
|
AccountId: aws.String("-"),
|
|
UploadId: aws.String("19gaRezEXAMPLES6Ry5YYdqthHOC_kGRCT03L9yetr220UmPtBYKk-OssZtLqyFu7sY1_lR7vgFuJV6NtcV5zpsJ"),
|
|
VaultName: aws.String("my-vault"),
|
|
}
|
|
|
|
result, err := svc.AbortMultipartUpload(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To abort a vault lock
|
|
//
|
|
// The example aborts the vault locking process if the vault lock is not in the Locked
|
|
// state for the vault named examplevault.
|
|
func ExampleGlacier_AbortVaultLock_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.AbortVaultLockInput{
|
|
AccountId: aws.String("-"),
|
|
VaultName: aws.String("examplevault"),
|
|
}
|
|
|
|
result, err := svc.AbortVaultLock(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To add tags to a vault
|
|
//
|
|
// The example adds two tags to a my-vault.
|
|
func ExampleGlacier_AddTagsToVault_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.AddTagsToVaultInput{
|
|
Tags: map[string]*string{
|
|
"examplekey1": aws.String("examplevalue1"),
|
|
"examplekey2": aws.String("examplevalue2"),
|
|
},
|
|
AccountId: aws.String("-"),
|
|
VaultName: aws.String("my-vault"),
|
|
}
|
|
|
|
result, err := svc.AddTagsToVault(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeLimitExceededException:
|
|
fmt.Println(glacier.ErrCodeLimitExceededException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To complete a multipart upload
|
|
//
|
|
// The example completes a multipart upload for a 3 MiB archive.
|
|
func ExampleGlacier_CompleteMultipartUpload_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.CompleteMultipartUploadInput{
|
|
AccountId: aws.String("-"),
|
|
ArchiveSize: aws.String("3145728"),
|
|
Checksum: aws.String("9628195fcdbcbbe76cdde456d4646fa7de5f219fb39823836d81f0cc0e18aa67"),
|
|
UploadId: aws.String("19gaRezEXAMPLES6Ry5YYdqthHOC_kGRCT03L9yetr220UmPtBYKk-OssZtLqyFu7sY1_lR7vgFuJV6NtcV5zpsJ"),
|
|
VaultName: aws.String("my-vault"),
|
|
}
|
|
|
|
result, err := svc.CompleteMultipartUpload(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To complete a vault lock
|
|
//
|
|
// The example completes the vault locking process by transitioning the vault lock from
|
|
// the InProgress state to the Locked state.
|
|
func ExampleGlacier_CompleteVaultLock_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.CompleteVaultLockInput{
|
|
AccountId: aws.String("-"),
|
|
LockId: aws.String("AE863rKkWZU53SLW5be4DUcW"),
|
|
VaultName: aws.String("example-vault"),
|
|
}
|
|
|
|
result, err := svc.CompleteVaultLock(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To create a new vault
|
|
//
|
|
// The following example creates a new vault named my-vault.
|
|
func ExampleGlacier_CreateVault_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.CreateVaultInput{
|
|
AccountId: aws.String("-"),
|
|
VaultName: aws.String("my-vault"),
|
|
}
|
|
|
|
result, err := svc.CreateVault(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
case glacier.ErrCodeLimitExceededException:
|
|
fmt.Println(glacier.ErrCodeLimitExceededException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To delete an archive
|
|
//
|
|
// The example deletes the archive specified by the archive ID.
|
|
func ExampleGlacier_DeleteArchive_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.DeleteArchiveInput{
|
|
AccountId: aws.String("-"),
|
|
ArchiveId: aws.String("NkbByEejwEggmBz2fTHgJrg0XBoDfjP4q6iu87-TjhqG6eGoOY9Z8i1_AUyUsuhPAdTqLHy8pTl5nfCFJmDl2yEZONi5L26Omw12vcs01MNGntHEQL8MBfGlqrEXAMPLEArchiveId"),
|
|
VaultName: aws.String("examplevault"),
|
|
}
|
|
|
|
result, err := svc.DeleteArchive(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To delete a vault
|
|
//
|
|
// The example deletes a vault named my-vault:
|
|
func ExampleGlacier_DeleteVault_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.DeleteVaultInput{
|
|
AccountId: aws.String("-"),
|
|
VaultName: aws.String("my-vault"),
|
|
}
|
|
|
|
result, err := svc.DeleteVault(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To delete the vault access policy
|
|
//
|
|
// The example deletes the access policy associated with the vault named examplevault.
|
|
func ExampleGlacier_DeleteVaultAccessPolicy_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.DeleteVaultAccessPolicyInput{
|
|
AccountId: aws.String("-"),
|
|
VaultName: aws.String("examplevault"),
|
|
}
|
|
|
|
result, err := svc.DeleteVaultAccessPolicy(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To delete the notification configuration set for a vault
|
|
//
|
|
// The example deletes the notification configuration set for the vault named examplevault.
|
|
func ExampleGlacier_DeleteVaultNotifications_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.DeleteVaultNotificationsInput{
|
|
AccountId: aws.String("-"),
|
|
VaultName: aws.String("examplevault"),
|
|
}
|
|
|
|
result, err := svc.DeleteVaultNotifications(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To get information about a previously initiated job
|
|
//
|
|
// The example returns information about the previously initiated job specified by the
|
|
// job ID.
|
|
func ExampleGlacier_DescribeJob_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.DescribeJobInput{
|
|
AccountId: aws.String("-"),
|
|
JobId: aws.String("zbxcm3Z_3z5UkoroF7SuZKrxgGoDc3RloGduS7Eg-RO47Yc6FxsdGBgf_Q2DK5Ejh18CnTS5XW4_XqlNHS61dsO4Cn"),
|
|
VaultName: aws.String("my-vault"),
|
|
}
|
|
|
|
result, err := svc.DescribeJob(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To retrieve information about a vault
|
|
//
|
|
// The example retrieves data about a vault named my-vault.
|
|
func ExampleGlacier_DescribeVault_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.DescribeVaultInput{
|
|
AccountId: aws.String("-"),
|
|
VaultName: aws.String("my-vault"),
|
|
}
|
|
|
|
result, err := svc.DescribeVault(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To get the current data retrieval policy for an account
|
|
//
|
|
// The example returns the current data retrieval policy for the account.
|
|
func ExampleGlacier_GetDataRetrievalPolicy_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.GetDataRetrievalPolicyInput{
|
|
AccountId: aws.String("-"),
|
|
}
|
|
|
|
result, err := svc.GetDataRetrievalPolicy(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To get the output of a previously initiated job
|
|
//
|
|
// The example downloads the output of a previously initiated inventory retrieval job
|
|
// that is identified by the job ID.
|
|
func ExampleGlacier_GetJobOutput_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.GetJobOutputInput{
|
|
AccountId: aws.String("-"),
|
|
JobId: aws.String("zbxcm3Z_3z5UkoroF7SuZKrxgGoDc3RloGduS7Eg-RO47Yc6FxsdGBgf_Q2DK5Ejh18CnTS5XW4_XqlNHS61dsO4CnMW"),
|
|
Range: aws.String(""),
|
|
VaultName: aws.String("my-vaul"),
|
|
}
|
|
|
|
result, err := svc.GetJobOutput(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To get the access-policy set on the vault
|
|
//
|
|
// The example retrieves the access-policy set on the vault named example-vault.
|
|
func ExampleGlacier_GetVaultAccessPolicy_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.GetVaultAccessPolicyInput{
|
|
AccountId: aws.String("-"),
|
|
VaultName: aws.String("example-vault"),
|
|
}
|
|
|
|
result, err := svc.GetVaultAccessPolicy(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To retrieve vault lock-policy related attributes that are set on a vault
|
|
//
|
|
// The example retrieves the attributes from the lock-policy subresource set on the
|
|
// vault named examplevault.
|
|
func ExampleGlacier_GetVaultLock_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.GetVaultLockInput{
|
|
AccountId: aws.String("-"),
|
|
VaultName: aws.String("examplevault"),
|
|
}
|
|
|
|
result, err := svc.GetVaultLock(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To get the notification-configuration for the specified vault
|
|
//
|
|
// The example retrieves the notification-configuration for the vault named my-vault.
|
|
func ExampleGlacier_GetVaultNotifications_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.GetVaultNotificationsInput{
|
|
AccountId: aws.String("-"),
|
|
VaultName: aws.String("my-vault"),
|
|
}
|
|
|
|
result, err := svc.GetVaultNotifications(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To initiate an inventory-retrieval job
|
|
//
|
|
// The example initiates an inventory-retrieval job for the vault named examplevault.
|
|
func ExampleGlacier_InitiateJob_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.InitiateJobInput{
|
|
AccountId: aws.String("-"),
|
|
JobParameters: &glacier.JobParameters{
|
|
Description: aws.String("My inventory job"),
|
|
Format: aws.String("CSV"),
|
|
SNSTopic: aws.String("arn:aws:sns:us-west-2:111111111111:Glacier-InventoryRetrieval-topic-Example"),
|
|
Type: aws.String("inventory-retrieval"),
|
|
},
|
|
VaultName: aws.String("examplevault"),
|
|
}
|
|
|
|
result, err := svc.InitiateJob(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodePolicyEnforcedException:
|
|
fmt.Println(glacier.ErrCodePolicyEnforcedException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeInsufficientCapacityException:
|
|
fmt.Println(glacier.ErrCodeInsufficientCapacityException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To initiate a multipart upload
|
|
//
|
|
// The example initiates a multipart upload to a vault named my-vault with a part size
|
|
// of 1 MiB (1024 x 1024 bytes) per file.
|
|
func ExampleGlacier_InitiateMultipartUpload_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.InitiateMultipartUploadInput{
|
|
AccountId: aws.String("-"),
|
|
PartSize: aws.String("1048576"),
|
|
VaultName: aws.String("my-vault"),
|
|
}
|
|
|
|
result, err := svc.InitiateMultipartUpload(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To initiate the vault locking process
|
|
//
|
|
// The example initiates the vault locking process for the vault named my-vault.
|
|
func ExampleGlacier_InitiateVaultLock_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.InitiateVaultLockInput{
|
|
AccountId: aws.String("-"),
|
|
Policy: &glacier.VaultLockPolicy{
|
|
Policy: aws.String("{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"Define-vault-lock\",\"Effect\":\"Deny\",\"Principal\":{\"AWS\":\"arn:aws:iam::999999999999:root\"},\"Action\":\"glacier:DeleteArchive\",\"Resource\":\"arn:aws:glacier:us-west-2:999999999999:vaults/examplevault\",\"Condition\":{\"NumericLessThanEquals\":{\"glacier:ArchiveAgeinDays\":\"365\"}}}]}"),
|
|
},
|
|
VaultName: aws.String("my-vault"),
|
|
}
|
|
|
|
result, err := svc.InitiateVaultLock(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To list jobs for a vault
|
|
//
|
|
// The example lists jobs for the vault named my-vault.
|
|
func ExampleGlacier_ListJobs_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.ListJobsInput{
|
|
AccountId: aws.String("-"),
|
|
VaultName: aws.String("my-vault"),
|
|
}
|
|
|
|
result, err := svc.ListJobs(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To list all the in-progress multipart uploads for a vault
|
|
//
|
|
// The example lists all the in-progress multipart uploads for the vault named examplevault.
|
|
func ExampleGlacier_ListMultipartUploads_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.ListMultipartUploadsInput{
|
|
AccountId: aws.String("-"),
|
|
VaultName: aws.String("examplevault"),
|
|
}
|
|
|
|
result, err := svc.ListMultipartUploads(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To list the parts of an archive that have been uploaded in a multipart upload
|
|
//
|
|
// The example lists all the parts of a multipart upload.
|
|
func ExampleGlacier_ListParts_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.ListPartsInput{
|
|
AccountId: aws.String("-"),
|
|
UploadId: aws.String("OW2fM5iVylEpFEMM9_HpKowRapC3vn5sSL39_396UW9zLFUWVrnRHaPjUJddQ5OxSHVXjYtrN47NBZ-khxOjyEXAMPLE"),
|
|
VaultName: aws.String("examplevault"),
|
|
}
|
|
|
|
result, err := svc.ListParts(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To list the provisioned capacity units for an account
|
|
//
|
|
// The example lists the provisioned capacity units for an account.
|
|
func ExampleGlacier_ListProvisionedCapacity_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.ListProvisionedCapacityInput{
|
|
AccountId: aws.String("-"),
|
|
}
|
|
|
|
result, err := svc.ListProvisionedCapacity(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To list the tags for a vault
|
|
//
|
|
// The example lists all the tags attached to the vault examplevault.
|
|
func ExampleGlacier_ListTagsForVault_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.ListTagsForVaultInput{
|
|
AccountId: aws.String("-"),
|
|
VaultName: aws.String("examplevault"),
|
|
}
|
|
|
|
result, err := svc.ListTagsForVault(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To list all vaults owned by the calling user's account
|
|
//
|
|
// The example lists all vaults owned by the specified AWS account.
|
|
func ExampleGlacier_ListVaults_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.ListVaultsInput{
|
|
AccountId: aws.String("-"),
|
|
Limit: aws.String(""),
|
|
Marker: aws.String(""),
|
|
}
|
|
|
|
result, err := svc.ListVaults(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To purchases a provisioned capacity unit for an AWS account
|
|
//
|
|
// The example purchases provisioned capacity unit for an AWS account.
|
|
func ExampleGlacier_PurchaseProvisionedCapacity_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.PurchaseProvisionedCapacityInput{
|
|
AccountId: aws.String("-"),
|
|
}
|
|
|
|
result, err := svc.PurchaseProvisionedCapacity(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeLimitExceededException:
|
|
fmt.Println(glacier.ErrCodeLimitExceededException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To remove tags from a vault
|
|
//
|
|
// The example removes two tags from the vault named examplevault.
|
|
func ExampleGlacier_RemoveTagsFromVault_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.RemoveTagsFromVaultInput{
|
|
TagKeys: []*string{
|
|
aws.String("examplekey1"),
|
|
aws.String("examplekey2"),
|
|
},
|
|
AccountId: aws.String("-"),
|
|
VaultName: aws.String("examplevault"),
|
|
}
|
|
|
|
result, err := svc.RemoveTagsFromVault(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To set and then enact a data retrieval policy
|
|
//
|
|
// The example sets and then enacts a data retrieval policy.
|
|
func ExampleGlacier_SetDataRetrievalPolicy_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.SetDataRetrievalPolicyInput{
|
|
Policy: &glacier.DataRetrievalPolicy{
|
|
Rules: []*glacier.DataRetrievalRule{
|
|
{
|
|
BytesPerHour: aws.Int64(10737418240),
|
|
Strategy: aws.String("BytesPerHour"),
|
|
},
|
|
},
|
|
},
|
|
AccountId: aws.String("-"),
|
|
}
|
|
|
|
result, err := svc.SetDataRetrievalPolicy(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To set the access-policy on a vault
|
|
//
|
|
// The example configures an access policy for the vault named examplevault.
|
|
func ExampleGlacier_SetVaultAccessPolicy_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.SetVaultAccessPolicyInput{
|
|
AccountId: aws.String("-"),
|
|
Policy: &glacier.VaultAccessPolicy{
|
|
Policy: aws.String("{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"Define-owner-access-rights\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::999999999999:root\"},\"Action\":\"glacier:DeleteArchive\",\"Resource\":\"arn:aws:glacier:us-west-2:999999999999:vaults/examplevault\"}]}"),
|
|
},
|
|
VaultName: aws.String("examplevault"),
|
|
}
|
|
|
|
result, err := svc.SetVaultAccessPolicy(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To configure a vault to post a message to an Amazon SNS topic when jobs complete
|
|
//
|
|
// The example sets the examplevault notification configuration.
|
|
func ExampleGlacier_SetVaultNotifications_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.SetVaultNotificationsInput{
|
|
AccountId: aws.String("-"),
|
|
VaultName: aws.String("examplevault"),
|
|
VaultNotificationConfig: &glacier.VaultNotificationConfig{
|
|
Events: []*string{
|
|
aws.String("ArchiveRetrievalCompleted"),
|
|
aws.String("InventoryRetrievalCompleted"),
|
|
},
|
|
SNSTopic: aws.String("arn:aws:sns:us-west-2:012345678901:mytopic"),
|
|
},
|
|
}
|
|
|
|
result, err := svc.SetVaultNotifications(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To upload an archive
|
|
//
|
|
// The example adds an archive to a vault.
|
|
func ExampleGlacier_UploadArchive_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.UploadArchiveInput{
|
|
AccountId: aws.String("-"),
|
|
ArchiveDescription: aws.String(""),
|
|
Body: aws.ReadSeekCloser(strings.NewReader("example-data-to-upload")),
|
|
Checksum: aws.String(""),
|
|
VaultName: aws.String("my-vault"),
|
|
}
|
|
|
|
result, err := svc.UploadArchive(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeRequestTimeoutException:
|
|
fmt.Println(glacier.ErrCodeRequestTimeoutException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|
|
|
|
// To upload the first part of an archive
|
|
//
|
|
// The example uploads the first 1 MiB (1024 x 1024 bytes) part of an archive.
|
|
func ExampleGlacier_UploadMultipartPart_shared00() {
|
|
svc := glacier.New(session.New())
|
|
input := &glacier.UploadMultipartPartInput{
|
|
AccountId: aws.String("-"),
|
|
Body: aws.ReadSeekCloser(strings.NewReader("part1")),
|
|
Checksum: aws.String("c06f7cd4baacb087002a99a5f48bf953"),
|
|
Range: aws.String("bytes 0-1048575/*"),
|
|
UploadId: aws.String("19gaRezEXAMPLES6Ry5YYdqthHOC_kGRCT03L9yetr220UmPtBYKk-OssZtLqyFu7sY1_lR7vgFuJV6NtcV5zpsJ"),
|
|
VaultName: aws.String("examplevault"),
|
|
}
|
|
|
|
result, err := svc.UploadMultipartPart(input)
|
|
if err != nil {
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
switch aerr.Code() {
|
|
case glacier.ErrCodeResourceNotFoundException:
|
|
fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
|
|
case glacier.ErrCodeInvalidParameterValueException:
|
|
fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeMissingParameterValueException:
|
|
fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
|
|
case glacier.ErrCodeRequestTimeoutException:
|
|
fmt.Println(glacier.ErrCodeRequestTimeoutException, aerr.Error())
|
|
case glacier.ErrCodeServiceUnavailableException:
|
|
fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
|
|
default:
|
|
fmt.Println(aerr.Error())
|
|
}
|
|
} else {
|
|
// Print the error, cast err to awserr.Error to get the Code and
|
|
// Message from an error.
|
|
fmt.Println(err.Error())
|
|
}
|
|
return
|
|
}
|
|
|
|
fmt.Println(result)
|
|
}
|