// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. package glacier_test import ( "context" "fmt" "strings" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/awserr" "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/service/glacier" ) var _ aws.Config // 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 ExampleClient_AbortMultipartUploadRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.AbortMultipartUploadInput{ AccountId: aws.String("-"), UploadId: aws.String("19gaRezEXAMPLES6Ry5YYdqthHOC_kGRCT03L9yetr220UmPtBYKk-OssZtLqyFu7sY1_lR7vgFuJV6NtcV5zpsJ"), VaultName: aws.String("my-vault"), } req := svc.AbortMultipartUploadRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_AbortVaultLockRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.AbortVaultLockInput{ AccountId: aws.String("-"), VaultName: aws.String("examplevault"), } req := svc.AbortVaultLockRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_AddTagsToVaultRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.AddTagsToVaultInput{ Tags: map[string]string{ "examplekey1": "examplevalue1", "examplekey2": "examplevalue2", }, AccountId: aws.String("-"), VaultName: aws.String("my-vault"), } req := svc.AddTagsToVaultRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_CompleteMultipartUploadRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) 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"), } req := svc.CompleteMultipartUploadRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_CompleteVaultLockRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.CompleteVaultLockInput{ AccountId: aws.String("-"), LockId: aws.String("AE863rKkWZU53SLW5be4DUcW"), VaultName: aws.String("example-vault"), } req := svc.CompleteVaultLockRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_CreateVaultRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.CreateVaultInput{ AccountId: aws.String("-"), VaultName: aws.String("my-vault"), } req := svc.CreateVaultRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_DeleteArchiveRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.DeleteArchiveInput{ AccountId: aws.String("-"), ArchiveId: aws.String("NkbByEejwEggmBz2fTHgJrg0XBoDfjP4q6iu87-TjhqG6eGoOY9Z8i1_AUyUsuhPAdTqLHy8pTl5nfCFJmDl2yEZONi5L26Omw12vcs01MNGntHEQL8MBfGlqrEXAMPLEArchiveId"), VaultName: aws.String("examplevault"), } req := svc.DeleteArchiveRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_DeleteVaultRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.DeleteVaultInput{ AccountId: aws.String("-"), VaultName: aws.String("my-vault"), } req := svc.DeleteVaultRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_DeleteVaultAccessPolicyRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.DeleteVaultAccessPolicyInput{ AccountId: aws.String("-"), VaultName: aws.String("examplevault"), } req := svc.DeleteVaultAccessPolicyRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_DeleteVaultNotificationsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.DeleteVaultNotificationsInput{ AccountId: aws.String("-"), VaultName: aws.String("examplevault"), } req := svc.DeleteVaultNotificationsRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_DescribeJobRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.DescribeJobInput{ AccountId: aws.String("-"), JobId: aws.String("zbxcm3Z_3z5UkoroF7SuZKrxgGoDc3RloGduS7Eg-RO47Yc6FxsdGBgf_Q2DK5Ejh18CnTS5XW4_XqlNHS61dsO4Cn"), VaultName: aws.String("my-vault"), } req := svc.DescribeJobRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_DescribeVaultRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.DescribeVaultInput{ AccountId: aws.String("-"), VaultName: aws.String("my-vault"), } req := svc.DescribeVaultRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_GetDataRetrievalPolicyRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.GetDataRetrievalPolicyInput{ AccountId: aws.String("-"), } req := svc.GetDataRetrievalPolicyRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_GetJobOutputRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.GetJobOutputInput{ AccountId: aws.String("-"), JobId: aws.String("zbxcm3Z_3z5UkoroF7SuZKrxgGoDc3RloGduS7Eg-RO47Yc6FxsdGBgf_Q2DK5Ejh18CnTS5XW4_XqlNHS61dsO4CnMW"), Range: aws.String(""), VaultName: aws.String("my-vaul"), } req := svc.GetJobOutputRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_GetVaultAccessPolicyRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.GetVaultAccessPolicyInput{ AccountId: aws.String("-"), VaultName: aws.String("example-vault"), } req := svc.GetVaultAccessPolicyRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_GetVaultLockRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.GetVaultLockInput{ AccountId: aws.String("-"), VaultName: aws.String("examplevault"), } req := svc.GetVaultLockRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_GetVaultNotificationsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.GetVaultNotificationsInput{ AccountId: aws.String("-"), VaultName: aws.String("my-vault"), } req := svc.GetVaultNotificationsRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_InitiateJobRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) 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"), } req := svc.InitiateJobRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_InitiateMultipartUploadRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.InitiateMultipartUploadInput{ AccountId: aws.String("-"), PartSize: aws.String("1048576"), VaultName: aws.String("my-vault"), } req := svc.InitiateMultipartUploadRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_InitiateVaultLockRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) 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"), } req := svc.InitiateVaultLockRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_ListJobsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.ListJobsInput{ AccountId: aws.String("-"), VaultName: aws.String("my-vault"), } req := svc.ListJobsRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_ListMultipartUploadsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.ListMultipartUploadsInput{ AccountId: aws.String("-"), VaultName: aws.String("examplevault"), } req := svc.ListMultipartUploadsRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_ListPartsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.ListPartsInput{ AccountId: aws.String("-"), UploadId: aws.String("OW2fM5iVylEpFEMM9_HpKowRapC3vn5sSL39_396UW9zLFUWVrnRHaPjUJddQ5OxSHVXjYtrN47NBZ-khxOjyEXAMPLE"), VaultName: aws.String("examplevault"), } req := svc.ListPartsRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_ListProvisionedCapacityRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.ListProvisionedCapacityInput{ AccountId: aws.String("-"), } req := svc.ListProvisionedCapacityRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_ListTagsForVaultRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.ListTagsForVaultInput{ AccountId: aws.String("-"), VaultName: aws.String("examplevault"), } req := svc.ListTagsForVaultRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_ListVaultsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.ListVaultsInput{ AccountId: aws.String("-"), Limit: aws.String(""), Marker: aws.String(""), } req := svc.ListVaultsRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_PurchaseProvisionedCapacityRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.PurchaseProvisionedCapacityInput{ AccountId: aws.String("-"), } req := svc.PurchaseProvisionedCapacityRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_RemoveTagsFromVaultRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.RemoveTagsFromVaultInput{ TagKeys: []string{ "examplekey1", "examplekey2", }, AccountId: aws.String("-"), VaultName: aws.String("examplevault"), } req := svc.RemoveTagsFromVaultRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_SetDataRetrievalPolicyRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.SetDataRetrievalPolicyInput{ Policy: &glacier.DataRetrievalPolicy{ Rules: []glacier.DataRetrievalRule{ { BytesPerHour: aws.Int64(10737418240), Strategy: aws.String("BytesPerHour"), }, }, }, AccountId: aws.String("-"), } req := svc.SetDataRetrievalPolicyRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_SetVaultAccessPolicyRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) 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"), } req := svc.SetVaultAccessPolicyRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_SetVaultNotificationsRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) input := &glacier.SetVaultNotificationsInput{ AccountId: aws.String("-"), VaultName: aws.String("examplevault"), VaultNotificationConfig: &glacier.VaultNotificationConfig{ Events: []string{ "ArchiveRetrievalCompleted", "InventoryRetrievalCompleted", }, SNSTopic: aws.String("arn:aws:sns:us-west-2:012345678901:mytopic"), }, } req := svc.SetVaultNotificationsRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_UploadArchiveRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) 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"), } req := svc.UploadArchiveRequest(input) result, err := req.Send(context.Background()) 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 ExampleClient_UploadMultipartPartRequest_shared00() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { panic("failed to load config, " + err.Error()) } svc := glacier.New(cfg) 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"), } req := svc.UploadMultipartPartRequest(input) result, err := req.Send(context.Background()) 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) }