github.com/aavshr/aws-sdk-go@v1.41.3/service/glacier/examples_test.go (about)

     1  // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
     2  
     3  package glacier_test
     4  
     5  import (
     6  	"fmt"
     7  	"strings"
     8  	"time"
     9  
    10  	"github.com/aavshr/aws-sdk-go/aws"
    11  	"github.com/aavshr/aws-sdk-go/aws/awserr"
    12  	"github.com/aavshr/aws-sdk-go/aws/session"
    13  	"github.com/aavshr/aws-sdk-go/service/glacier"
    14  )
    15  
    16  var _ time.Duration
    17  var _ strings.Reader
    18  var _ aws.Config
    19  
    20  func parseTime(layout, value string) *time.Time {
    21  	t, err := time.Parse(layout, value)
    22  	if err != nil {
    23  		panic(err)
    24  	}
    25  	return &t
    26  }
    27  
    28  // To abort a multipart upload identified by the upload ID
    29  //
    30  // The example deletes an in-progress multipart upload to a vault named my-vault:
    31  func ExampleGlacier_AbortMultipartUpload_shared00() {
    32  	svc := glacier.New(session.New())
    33  	input := &glacier.AbortMultipartUploadInput{
    34  		AccountId: aws.String("-"),
    35  		UploadId:  aws.String("19gaRezEXAMPLES6Ry5YYdqthHOC_kGRCT03L9yetr220UmPtBYKk-OssZtLqyFu7sY1_lR7vgFuJV6NtcV5zpsJ"),
    36  		VaultName: aws.String("my-vault"),
    37  	}
    38  
    39  	result, err := svc.AbortMultipartUpload(input)
    40  	if err != nil {
    41  		if aerr, ok := err.(awserr.Error); ok {
    42  			switch aerr.Code() {
    43  			case glacier.ErrCodeResourceNotFoundException:
    44  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
    45  			case glacier.ErrCodeInvalidParameterValueException:
    46  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
    47  			case glacier.ErrCodeMissingParameterValueException:
    48  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
    49  			case glacier.ErrCodeServiceUnavailableException:
    50  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
    51  			default:
    52  				fmt.Println(aerr.Error())
    53  			}
    54  		} else {
    55  			// Print the error, cast err to awserr.Error to get the Code and
    56  			// Message from an error.
    57  			fmt.Println(err.Error())
    58  		}
    59  		return
    60  	}
    61  
    62  	fmt.Println(result)
    63  }
    64  
    65  // To abort a vault lock
    66  //
    67  // The example aborts the vault locking process if the vault lock is not in the Locked
    68  // state for the vault named examplevault.
    69  func ExampleGlacier_AbortVaultLock_shared00() {
    70  	svc := glacier.New(session.New())
    71  	input := &glacier.AbortVaultLockInput{
    72  		AccountId: aws.String("-"),
    73  		VaultName: aws.String("examplevault"),
    74  	}
    75  
    76  	result, err := svc.AbortVaultLock(input)
    77  	if err != nil {
    78  		if aerr, ok := err.(awserr.Error); ok {
    79  			switch aerr.Code() {
    80  			case glacier.ErrCodeResourceNotFoundException:
    81  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
    82  			case glacier.ErrCodeInvalidParameterValueException:
    83  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
    84  			case glacier.ErrCodeMissingParameterValueException:
    85  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
    86  			case glacier.ErrCodeServiceUnavailableException:
    87  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
    88  			default:
    89  				fmt.Println(aerr.Error())
    90  			}
    91  		} else {
    92  			// Print the error, cast err to awserr.Error to get the Code and
    93  			// Message from an error.
    94  			fmt.Println(err.Error())
    95  		}
    96  		return
    97  	}
    98  
    99  	fmt.Println(result)
   100  }
   101  
   102  // To add tags to a vault
   103  //
   104  // The example adds two tags to a my-vault.
   105  func ExampleGlacier_AddTagsToVault_shared00() {
   106  	svc := glacier.New(session.New())
   107  	input := &glacier.AddTagsToVaultInput{
   108  		Tags: map[string]*string{
   109  			"examplekey1": aws.String("examplevalue1"),
   110  			"examplekey2": aws.String("examplevalue2"),
   111  		},
   112  		AccountId: aws.String("-"),
   113  		VaultName: aws.String("my-vault"),
   114  	}
   115  
   116  	result, err := svc.AddTagsToVault(input)
   117  	if err != nil {
   118  		if aerr, ok := err.(awserr.Error); ok {
   119  			switch aerr.Code() {
   120  			case glacier.ErrCodeInvalidParameterValueException:
   121  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   122  			case glacier.ErrCodeMissingParameterValueException:
   123  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   124  			case glacier.ErrCodeResourceNotFoundException:
   125  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   126  			case glacier.ErrCodeLimitExceededException:
   127  				fmt.Println(glacier.ErrCodeLimitExceededException, aerr.Error())
   128  			case glacier.ErrCodeServiceUnavailableException:
   129  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   130  			default:
   131  				fmt.Println(aerr.Error())
   132  			}
   133  		} else {
   134  			// Print the error, cast err to awserr.Error to get the Code and
   135  			// Message from an error.
   136  			fmt.Println(err.Error())
   137  		}
   138  		return
   139  	}
   140  
   141  	fmt.Println(result)
   142  }
   143  
   144  // To complete a multipart upload
   145  //
   146  // The example completes a multipart upload for a 3 MiB archive.
   147  func ExampleGlacier_CompleteMultipartUpload_shared00() {
   148  	svc := glacier.New(session.New())
   149  	input := &glacier.CompleteMultipartUploadInput{
   150  		AccountId:   aws.String("-"),
   151  		ArchiveSize: aws.String("3145728"),
   152  		Checksum:    aws.String("9628195fcdbcbbe76cdde456d4646fa7de5f219fb39823836d81f0cc0e18aa67"),
   153  		UploadId:    aws.String("19gaRezEXAMPLES6Ry5YYdqthHOC_kGRCT03L9yetr220UmPtBYKk-OssZtLqyFu7sY1_lR7vgFuJV6NtcV5zpsJ"),
   154  		VaultName:   aws.String("my-vault"),
   155  	}
   156  
   157  	result, err := svc.CompleteMultipartUpload(input)
   158  	if err != nil {
   159  		if aerr, ok := err.(awserr.Error); ok {
   160  			switch aerr.Code() {
   161  			case glacier.ErrCodeResourceNotFoundException:
   162  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   163  			case glacier.ErrCodeInvalidParameterValueException:
   164  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   165  			case glacier.ErrCodeMissingParameterValueException:
   166  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   167  			case glacier.ErrCodeServiceUnavailableException:
   168  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   169  			default:
   170  				fmt.Println(aerr.Error())
   171  			}
   172  		} else {
   173  			// Print the error, cast err to awserr.Error to get the Code and
   174  			// Message from an error.
   175  			fmt.Println(err.Error())
   176  		}
   177  		return
   178  	}
   179  
   180  	fmt.Println(result)
   181  }
   182  
   183  // To complete a vault lock
   184  //
   185  // The example completes the vault locking process by transitioning the vault lock from
   186  // the InProgress state to the Locked state.
   187  func ExampleGlacier_CompleteVaultLock_shared00() {
   188  	svc := glacier.New(session.New())
   189  	input := &glacier.CompleteVaultLockInput{
   190  		AccountId: aws.String("-"),
   191  		LockId:    aws.String("AE863rKkWZU53SLW5be4DUcW"),
   192  		VaultName: aws.String("example-vault"),
   193  	}
   194  
   195  	result, err := svc.CompleteVaultLock(input)
   196  	if err != nil {
   197  		if aerr, ok := err.(awserr.Error); ok {
   198  			switch aerr.Code() {
   199  			case glacier.ErrCodeResourceNotFoundException:
   200  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   201  			case glacier.ErrCodeInvalidParameterValueException:
   202  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   203  			case glacier.ErrCodeMissingParameterValueException:
   204  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   205  			case glacier.ErrCodeServiceUnavailableException:
   206  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   207  			default:
   208  				fmt.Println(aerr.Error())
   209  			}
   210  		} else {
   211  			// Print the error, cast err to awserr.Error to get the Code and
   212  			// Message from an error.
   213  			fmt.Println(err.Error())
   214  		}
   215  		return
   216  	}
   217  
   218  	fmt.Println(result)
   219  }
   220  
   221  // To create a new vault
   222  //
   223  // The following example creates a new vault named my-vault.
   224  func ExampleGlacier_CreateVault_shared00() {
   225  	svc := glacier.New(session.New())
   226  	input := &glacier.CreateVaultInput{
   227  		AccountId: aws.String("-"),
   228  		VaultName: aws.String("my-vault"),
   229  	}
   230  
   231  	result, err := svc.CreateVault(input)
   232  	if err != nil {
   233  		if aerr, ok := err.(awserr.Error); ok {
   234  			switch aerr.Code() {
   235  			case glacier.ErrCodeInvalidParameterValueException:
   236  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   237  			case glacier.ErrCodeMissingParameterValueException:
   238  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   239  			case glacier.ErrCodeServiceUnavailableException:
   240  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   241  			case glacier.ErrCodeLimitExceededException:
   242  				fmt.Println(glacier.ErrCodeLimitExceededException, aerr.Error())
   243  			default:
   244  				fmt.Println(aerr.Error())
   245  			}
   246  		} else {
   247  			// Print the error, cast err to awserr.Error to get the Code and
   248  			// Message from an error.
   249  			fmt.Println(err.Error())
   250  		}
   251  		return
   252  	}
   253  
   254  	fmt.Println(result)
   255  }
   256  
   257  // To delete an archive
   258  //
   259  // The example deletes the archive specified by the archive ID.
   260  func ExampleGlacier_DeleteArchive_shared00() {
   261  	svc := glacier.New(session.New())
   262  	input := &glacier.DeleteArchiveInput{
   263  		AccountId: aws.String("-"),
   264  		ArchiveId: aws.String("NkbByEejwEggmBz2fTHgJrg0XBoDfjP4q6iu87-TjhqG6eGoOY9Z8i1_AUyUsuhPAdTqLHy8pTl5nfCFJmDl2yEZONi5L26Omw12vcs01MNGntHEQL8MBfGlqrEXAMPLEArchiveId"),
   265  		VaultName: aws.String("examplevault"),
   266  	}
   267  
   268  	result, err := svc.DeleteArchive(input)
   269  	if err != nil {
   270  		if aerr, ok := err.(awserr.Error); ok {
   271  			switch aerr.Code() {
   272  			case glacier.ErrCodeResourceNotFoundException:
   273  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   274  			case glacier.ErrCodeInvalidParameterValueException:
   275  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   276  			case glacier.ErrCodeMissingParameterValueException:
   277  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   278  			case glacier.ErrCodeServiceUnavailableException:
   279  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   280  			default:
   281  				fmt.Println(aerr.Error())
   282  			}
   283  		} else {
   284  			// Print the error, cast err to awserr.Error to get the Code and
   285  			// Message from an error.
   286  			fmt.Println(err.Error())
   287  		}
   288  		return
   289  	}
   290  
   291  	fmt.Println(result)
   292  }
   293  
   294  // To delete a vault
   295  //
   296  // The example deletes a vault named my-vault:
   297  func ExampleGlacier_DeleteVault_shared00() {
   298  	svc := glacier.New(session.New())
   299  	input := &glacier.DeleteVaultInput{
   300  		AccountId: aws.String("-"),
   301  		VaultName: aws.String("my-vault"),
   302  	}
   303  
   304  	result, err := svc.DeleteVault(input)
   305  	if err != nil {
   306  		if aerr, ok := err.(awserr.Error); ok {
   307  			switch aerr.Code() {
   308  			case glacier.ErrCodeResourceNotFoundException:
   309  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   310  			case glacier.ErrCodeInvalidParameterValueException:
   311  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   312  			case glacier.ErrCodeMissingParameterValueException:
   313  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   314  			case glacier.ErrCodeServiceUnavailableException:
   315  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   316  			default:
   317  				fmt.Println(aerr.Error())
   318  			}
   319  		} else {
   320  			// Print the error, cast err to awserr.Error to get the Code and
   321  			// Message from an error.
   322  			fmt.Println(err.Error())
   323  		}
   324  		return
   325  	}
   326  
   327  	fmt.Println(result)
   328  }
   329  
   330  // To delete the vault access policy
   331  //
   332  // The example deletes the access policy associated with the vault named examplevault.
   333  func ExampleGlacier_DeleteVaultAccessPolicy_shared00() {
   334  	svc := glacier.New(session.New())
   335  	input := &glacier.DeleteVaultAccessPolicyInput{
   336  		AccountId: aws.String("-"),
   337  		VaultName: aws.String("examplevault"),
   338  	}
   339  
   340  	result, err := svc.DeleteVaultAccessPolicy(input)
   341  	if err != nil {
   342  		if aerr, ok := err.(awserr.Error); ok {
   343  			switch aerr.Code() {
   344  			case glacier.ErrCodeResourceNotFoundException:
   345  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   346  			case glacier.ErrCodeInvalidParameterValueException:
   347  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   348  			case glacier.ErrCodeMissingParameterValueException:
   349  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   350  			case glacier.ErrCodeServiceUnavailableException:
   351  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   352  			default:
   353  				fmt.Println(aerr.Error())
   354  			}
   355  		} else {
   356  			// Print the error, cast err to awserr.Error to get the Code and
   357  			// Message from an error.
   358  			fmt.Println(err.Error())
   359  		}
   360  		return
   361  	}
   362  
   363  	fmt.Println(result)
   364  }
   365  
   366  // To delete the notification configuration set for a vault
   367  //
   368  // The example deletes the notification configuration set for the vault named examplevault.
   369  func ExampleGlacier_DeleteVaultNotifications_shared00() {
   370  	svc := glacier.New(session.New())
   371  	input := &glacier.DeleteVaultNotificationsInput{
   372  		AccountId: aws.String("-"),
   373  		VaultName: aws.String("examplevault"),
   374  	}
   375  
   376  	result, err := svc.DeleteVaultNotifications(input)
   377  	if err != nil {
   378  		if aerr, ok := err.(awserr.Error); ok {
   379  			switch aerr.Code() {
   380  			case glacier.ErrCodeResourceNotFoundException:
   381  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   382  			case glacier.ErrCodeInvalidParameterValueException:
   383  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   384  			case glacier.ErrCodeMissingParameterValueException:
   385  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   386  			case glacier.ErrCodeServiceUnavailableException:
   387  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   388  			default:
   389  				fmt.Println(aerr.Error())
   390  			}
   391  		} else {
   392  			// Print the error, cast err to awserr.Error to get the Code and
   393  			// Message from an error.
   394  			fmt.Println(err.Error())
   395  		}
   396  		return
   397  	}
   398  
   399  	fmt.Println(result)
   400  }
   401  
   402  // To get information about a previously initiated job
   403  //
   404  // The example returns information about the previously initiated job specified by the
   405  // job ID.
   406  func ExampleGlacier_DescribeJob_shared00() {
   407  	svc := glacier.New(session.New())
   408  	input := &glacier.DescribeJobInput{
   409  		AccountId: aws.String("-"),
   410  		JobId:     aws.String("zbxcm3Z_3z5UkoroF7SuZKrxgGoDc3RloGduS7Eg-RO47Yc6FxsdGBgf_Q2DK5Ejh18CnTS5XW4_XqlNHS61dsO4Cn"),
   411  		VaultName: aws.String("my-vault"),
   412  	}
   413  
   414  	result, err := svc.DescribeJob(input)
   415  	if err != nil {
   416  		if aerr, ok := err.(awserr.Error); ok {
   417  			switch aerr.Code() {
   418  			case glacier.ErrCodeResourceNotFoundException:
   419  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   420  			case glacier.ErrCodeInvalidParameterValueException:
   421  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   422  			case glacier.ErrCodeMissingParameterValueException:
   423  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   424  			case glacier.ErrCodeServiceUnavailableException:
   425  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   426  			default:
   427  				fmt.Println(aerr.Error())
   428  			}
   429  		} else {
   430  			// Print the error, cast err to awserr.Error to get the Code and
   431  			// Message from an error.
   432  			fmt.Println(err.Error())
   433  		}
   434  		return
   435  	}
   436  
   437  	fmt.Println(result)
   438  }
   439  
   440  // To retrieve information about a vault
   441  //
   442  // The example retrieves data about a vault named my-vault.
   443  func ExampleGlacier_DescribeVault_shared00() {
   444  	svc := glacier.New(session.New())
   445  	input := &glacier.DescribeVaultInput{
   446  		AccountId: aws.String("-"),
   447  		VaultName: aws.String("my-vault"),
   448  	}
   449  
   450  	result, err := svc.DescribeVault(input)
   451  	if err != nil {
   452  		if aerr, ok := err.(awserr.Error); ok {
   453  			switch aerr.Code() {
   454  			case glacier.ErrCodeResourceNotFoundException:
   455  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   456  			case glacier.ErrCodeInvalidParameterValueException:
   457  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   458  			case glacier.ErrCodeMissingParameterValueException:
   459  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   460  			case glacier.ErrCodeServiceUnavailableException:
   461  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   462  			default:
   463  				fmt.Println(aerr.Error())
   464  			}
   465  		} else {
   466  			// Print the error, cast err to awserr.Error to get the Code and
   467  			// Message from an error.
   468  			fmt.Println(err.Error())
   469  		}
   470  		return
   471  	}
   472  
   473  	fmt.Println(result)
   474  }
   475  
   476  // To get the current data retrieval policy for an account
   477  //
   478  // The example returns the current data retrieval policy for the account.
   479  func ExampleGlacier_GetDataRetrievalPolicy_shared00() {
   480  	svc := glacier.New(session.New())
   481  	input := &glacier.GetDataRetrievalPolicyInput{
   482  		AccountId: aws.String("-"),
   483  	}
   484  
   485  	result, err := svc.GetDataRetrievalPolicy(input)
   486  	if err != nil {
   487  		if aerr, ok := err.(awserr.Error); ok {
   488  			switch aerr.Code() {
   489  			case glacier.ErrCodeInvalidParameterValueException:
   490  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   491  			case glacier.ErrCodeMissingParameterValueException:
   492  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   493  			case glacier.ErrCodeServiceUnavailableException:
   494  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   495  			default:
   496  				fmt.Println(aerr.Error())
   497  			}
   498  		} else {
   499  			// Print the error, cast err to awserr.Error to get the Code and
   500  			// Message from an error.
   501  			fmt.Println(err.Error())
   502  		}
   503  		return
   504  	}
   505  
   506  	fmt.Println(result)
   507  }
   508  
   509  // To get the output of a previously initiated job
   510  //
   511  // The example downloads the output of a previously initiated inventory retrieval job
   512  // that is identified by the job ID.
   513  func ExampleGlacier_GetJobOutput_shared00() {
   514  	svc := glacier.New(session.New())
   515  	input := &glacier.GetJobOutputInput{
   516  		AccountId: aws.String("-"),
   517  		JobId:     aws.String("zbxcm3Z_3z5UkoroF7SuZKrxgGoDc3RloGduS7Eg-RO47Yc6FxsdGBgf_Q2DK5Ejh18CnTS5XW4_XqlNHS61dsO4CnMW"),
   518  		Range:     aws.String(""),
   519  		VaultName: aws.String("my-vaul"),
   520  	}
   521  
   522  	result, err := svc.GetJobOutput(input)
   523  	if err != nil {
   524  		if aerr, ok := err.(awserr.Error); ok {
   525  			switch aerr.Code() {
   526  			case glacier.ErrCodeResourceNotFoundException:
   527  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   528  			case glacier.ErrCodeInvalidParameterValueException:
   529  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   530  			case glacier.ErrCodeMissingParameterValueException:
   531  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   532  			case glacier.ErrCodeServiceUnavailableException:
   533  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   534  			default:
   535  				fmt.Println(aerr.Error())
   536  			}
   537  		} else {
   538  			// Print the error, cast err to awserr.Error to get the Code and
   539  			// Message from an error.
   540  			fmt.Println(err.Error())
   541  		}
   542  		return
   543  	}
   544  
   545  	fmt.Println(result)
   546  }
   547  
   548  // To get the access-policy set on the vault
   549  //
   550  // The example retrieves the access-policy set on the vault named example-vault.
   551  func ExampleGlacier_GetVaultAccessPolicy_shared00() {
   552  	svc := glacier.New(session.New())
   553  	input := &glacier.GetVaultAccessPolicyInput{
   554  		AccountId: aws.String("-"),
   555  		VaultName: aws.String("example-vault"),
   556  	}
   557  
   558  	result, err := svc.GetVaultAccessPolicy(input)
   559  	if err != nil {
   560  		if aerr, ok := err.(awserr.Error); ok {
   561  			switch aerr.Code() {
   562  			case glacier.ErrCodeResourceNotFoundException:
   563  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   564  			case glacier.ErrCodeInvalidParameterValueException:
   565  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   566  			case glacier.ErrCodeMissingParameterValueException:
   567  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   568  			case glacier.ErrCodeServiceUnavailableException:
   569  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   570  			default:
   571  				fmt.Println(aerr.Error())
   572  			}
   573  		} else {
   574  			// Print the error, cast err to awserr.Error to get the Code and
   575  			// Message from an error.
   576  			fmt.Println(err.Error())
   577  		}
   578  		return
   579  	}
   580  
   581  	fmt.Println(result)
   582  }
   583  
   584  // To retrieve vault lock-policy related attributes that are set on a vault
   585  //
   586  // The example retrieves the attributes from the lock-policy subresource set on the
   587  // vault named examplevault.
   588  func ExampleGlacier_GetVaultLock_shared00() {
   589  	svc := glacier.New(session.New())
   590  	input := &glacier.GetVaultLockInput{
   591  		AccountId: aws.String("-"),
   592  		VaultName: aws.String("examplevault"),
   593  	}
   594  
   595  	result, err := svc.GetVaultLock(input)
   596  	if err != nil {
   597  		if aerr, ok := err.(awserr.Error); ok {
   598  			switch aerr.Code() {
   599  			case glacier.ErrCodeResourceNotFoundException:
   600  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   601  			case glacier.ErrCodeInvalidParameterValueException:
   602  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   603  			case glacier.ErrCodeMissingParameterValueException:
   604  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   605  			case glacier.ErrCodeServiceUnavailableException:
   606  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   607  			default:
   608  				fmt.Println(aerr.Error())
   609  			}
   610  		} else {
   611  			// Print the error, cast err to awserr.Error to get the Code and
   612  			// Message from an error.
   613  			fmt.Println(err.Error())
   614  		}
   615  		return
   616  	}
   617  
   618  	fmt.Println(result)
   619  }
   620  
   621  // To get the notification-configuration for the specified vault
   622  //
   623  // The example retrieves the notification-configuration for the vault named my-vault.
   624  func ExampleGlacier_GetVaultNotifications_shared00() {
   625  	svc := glacier.New(session.New())
   626  	input := &glacier.GetVaultNotificationsInput{
   627  		AccountId: aws.String("-"),
   628  		VaultName: aws.String("my-vault"),
   629  	}
   630  
   631  	result, err := svc.GetVaultNotifications(input)
   632  	if err != nil {
   633  		if aerr, ok := err.(awserr.Error); ok {
   634  			switch aerr.Code() {
   635  			case glacier.ErrCodeResourceNotFoundException:
   636  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   637  			case glacier.ErrCodeInvalidParameterValueException:
   638  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   639  			case glacier.ErrCodeMissingParameterValueException:
   640  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   641  			case glacier.ErrCodeServiceUnavailableException:
   642  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   643  			default:
   644  				fmt.Println(aerr.Error())
   645  			}
   646  		} else {
   647  			// Print the error, cast err to awserr.Error to get the Code and
   648  			// Message from an error.
   649  			fmt.Println(err.Error())
   650  		}
   651  		return
   652  	}
   653  
   654  	fmt.Println(result)
   655  }
   656  
   657  // To initiate an inventory-retrieval job
   658  //
   659  // The example initiates an inventory-retrieval job for the vault named examplevault.
   660  func ExampleGlacier_InitiateJob_shared00() {
   661  	svc := glacier.New(session.New())
   662  	input := &glacier.InitiateJobInput{
   663  		AccountId: aws.String("-"),
   664  		JobParameters: &glacier.JobParameters{
   665  			Description: aws.String("My inventory job"),
   666  			Format:      aws.String("CSV"),
   667  			SNSTopic:    aws.String("arn:aws:sns:us-west-2:111111111111:Glacier-InventoryRetrieval-topic-Example"),
   668  			Type:        aws.String("inventory-retrieval"),
   669  		},
   670  		VaultName: aws.String("examplevault"),
   671  	}
   672  
   673  	result, err := svc.InitiateJob(input)
   674  	if err != nil {
   675  		if aerr, ok := err.(awserr.Error); ok {
   676  			switch aerr.Code() {
   677  			case glacier.ErrCodeResourceNotFoundException:
   678  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   679  			case glacier.ErrCodePolicyEnforcedException:
   680  				fmt.Println(glacier.ErrCodePolicyEnforcedException, aerr.Error())
   681  			case glacier.ErrCodeInvalidParameterValueException:
   682  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   683  			case glacier.ErrCodeMissingParameterValueException:
   684  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   685  			case glacier.ErrCodeInsufficientCapacityException:
   686  				fmt.Println(glacier.ErrCodeInsufficientCapacityException, aerr.Error())
   687  			case glacier.ErrCodeServiceUnavailableException:
   688  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   689  			default:
   690  				fmt.Println(aerr.Error())
   691  			}
   692  		} else {
   693  			// Print the error, cast err to awserr.Error to get the Code and
   694  			// Message from an error.
   695  			fmt.Println(err.Error())
   696  		}
   697  		return
   698  	}
   699  
   700  	fmt.Println(result)
   701  }
   702  
   703  // To initiate a multipart upload
   704  //
   705  // The example initiates a multipart upload to a vault named my-vault with a part size
   706  // of 1 MiB (1024 x 1024 bytes) per file.
   707  func ExampleGlacier_InitiateMultipartUpload_shared00() {
   708  	svc := glacier.New(session.New())
   709  	input := &glacier.InitiateMultipartUploadInput{
   710  		AccountId: aws.String("-"),
   711  		PartSize:  aws.String("1048576"),
   712  		VaultName: aws.String("my-vault"),
   713  	}
   714  
   715  	result, err := svc.InitiateMultipartUpload(input)
   716  	if err != nil {
   717  		if aerr, ok := err.(awserr.Error); ok {
   718  			switch aerr.Code() {
   719  			case glacier.ErrCodeResourceNotFoundException:
   720  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   721  			case glacier.ErrCodeInvalidParameterValueException:
   722  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   723  			case glacier.ErrCodeMissingParameterValueException:
   724  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   725  			case glacier.ErrCodeServiceUnavailableException:
   726  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   727  			default:
   728  				fmt.Println(aerr.Error())
   729  			}
   730  		} else {
   731  			// Print the error, cast err to awserr.Error to get the Code and
   732  			// Message from an error.
   733  			fmt.Println(err.Error())
   734  		}
   735  		return
   736  	}
   737  
   738  	fmt.Println(result)
   739  }
   740  
   741  // To initiate the vault locking process
   742  //
   743  // The example initiates the vault locking process for the vault named my-vault.
   744  func ExampleGlacier_InitiateVaultLock_shared00() {
   745  	svc := glacier.New(session.New())
   746  	input := &glacier.InitiateVaultLockInput{
   747  		AccountId: aws.String("-"),
   748  		Policy: &glacier.VaultLockPolicy{
   749  			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\"}}}]}"),
   750  		},
   751  		VaultName: aws.String("my-vault"),
   752  	}
   753  
   754  	result, err := svc.InitiateVaultLock(input)
   755  	if err != nil {
   756  		if aerr, ok := err.(awserr.Error); ok {
   757  			switch aerr.Code() {
   758  			case glacier.ErrCodeResourceNotFoundException:
   759  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   760  			case glacier.ErrCodeInvalidParameterValueException:
   761  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   762  			case glacier.ErrCodeMissingParameterValueException:
   763  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   764  			case glacier.ErrCodeServiceUnavailableException:
   765  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   766  			default:
   767  				fmt.Println(aerr.Error())
   768  			}
   769  		} else {
   770  			// Print the error, cast err to awserr.Error to get the Code and
   771  			// Message from an error.
   772  			fmt.Println(err.Error())
   773  		}
   774  		return
   775  	}
   776  
   777  	fmt.Println(result)
   778  }
   779  
   780  // To list jobs for a vault
   781  //
   782  // The example lists jobs for the vault named my-vault.
   783  func ExampleGlacier_ListJobs_shared00() {
   784  	svc := glacier.New(session.New())
   785  	input := &glacier.ListJobsInput{
   786  		AccountId: aws.String("-"),
   787  		VaultName: aws.String("my-vault"),
   788  	}
   789  
   790  	result, err := svc.ListJobs(input)
   791  	if err != nil {
   792  		if aerr, ok := err.(awserr.Error); ok {
   793  			switch aerr.Code() {
   794  			case glacier.ErrCodeResourceNotFoundException:
   795  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   796  			case glacier.ErrCodeInvalidParameterValueException:
   797  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   798  			case glacier.ErrCodeMissingParameterValueException:
   799  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   800  			case glacier.ErrCodeServiceUnavailableException:
   801  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   802  			default:
   803  				fmt.Println(aerr.Error())
   804  			}
   805  		} else {
   806  			// Print the error, cast err to awserr.Error to get the Code and
   807  			// Message from an error.
   808  			fmt.Println(err.Error())
   809  		}
   810  		return
   811  	}
   812  
   813  	fmt.Println(result)
   814  }
   815  
   816  // To list all the in-progress multipart uploads for a vault
   817  //
   818  // The example lists all the in-progress multipart uploads for the vault named examplevault.
   819  func ExampleGlacier_ListMultipartUploads_shared00() {
   820  	svc := glacier.New(session.New())
   821  	input := &glacier.ListMultipartUploadsInput{
   822  		AccountId: aws.String("-"),
   823  		VaultName: aws.String("examplevault"),
   824  	}
   825  
   826  	result, err := svc.ListMultipartUploads(input)
   827  	if err != nil {
   828  		if aerr, ok := err.(awserr.Error); ok {
   829  			switch aerr.Code() {
   830  			case glacier.ErrCodeResourceNotFoundException:
   831  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   832  			case glacier.ErrCodeInvalidParameterValueException:
   833  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   834  			case glacier.ErrCodeMissingParameterValueException:
   835  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   836  			case glacier.ErrCodeServiceUnavailableException:
   837  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   838  			default:
   839  				fmt.Println(aerr.Error())
   840  			}
   841  		} else {
   842  			// Print the error, cast err to awserr.Error to get the Code and
   843  			// Message from an error.
   844  			fmt.Println(err.Error())
   845  		}
   846  		return
   847  	}
   848  
   849  	fmt.Println(result)
   850  }
   851  
   852  // To list the parts of an archive that have been uploaded in a multipart upload
   853  //
   854  // The example lists all the parts of a multipart upload.
   855  func ExampleGlacier_ListParts_shared00() {
   856  	svc := glacier.New(session.New())
   857  	input := &glacier.ListPartsInput{
   858  		AccountId: aws.String("-"),
   859  		UploadId:  aws.String("OW2fM5iVylEpFEMM9_HpKowRapC3vn5sSL39_396UW9zLFUWVrnRHaPjUJddQ5OxSHVXjYtrN47NBZ-khxOjyEXAMPLE"),
   860  		VaultName: aws.String("examplevault"),
   861  	}
   862  
   863  	result, err := svc.ListParts(input)
   864  	if err != nil {
   865  		if aerr, ok := err.(awserr.Error); ok {
   866  			switch aerr.Code() {
   867  			case glacier.ErrCodeResourceNotFoundException:
   868  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   869  			case glacier.ErrCodeInvalidParameterValueException:
   870  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   871  			case glacier.ErrCodeMissingParameterValueException:
   872  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   873  			case glacier.ErrCodeServiceUnavailableException:
   874  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   875  			default:
   876  				fmt.Println(aerr.Error())
   877  			}
   878  		} else {
   879  			// Print the error, cast err to awserr.Error to get the Code and
   880  			// Message from an error.
   881  			fmt.Println(err.Error())
   882  		}
   883  		return
   884  	}
   885  
   886  	fmt.Println(result)
   887  }
   888  
   889  // To list the provisioned capacity units for an account
   890  //
   891  // The example lists the provisioned capacity units for an account.
   892  func ExampleGlacier_ListProvisionedCapacity_shared00() {
   893  	svc := glacier.New(session.New())
   894  	input := &glacier.ListProvisionedCapacityInput{
   895  		AccountId: aws.String("-"),
   896  	}
   897  
   898  	result, err := svc.ListProvisionedCapacity(input)
   899  	if err != nil {
   900  		if aerr, ok := err.(awserr.Error); ok {
   901  			switch aerr.Code() {
   902  			case glacier.ErrCodeInvalidParameterValueException:
   903  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   904  			case glacier.ErrCodeMissingParameterValueException:
   905  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   906  			case glacier.ErrCodeServiceUnavailableException:
   907  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   908  			default:
   909  				fmt.Println(aerr.Error())
   910  			}
   911  		} else {
   912  			// Print the error, cast err to awserr.Error to get the Code and
   913  			// Message from an error.
   914  			fmt.Println(err.Error())
   915  		}
   916  		return
   917  	}
   918  
   919  	fmt.Println(result)
   920  }
   921  
   922  // To list the tags for a vault
   923  //
   924  // The example lists all the tags attached to the vault examplevault.
   925  func ExampleGlacier_ListTagsForVault_shared00() {
   926  	svc := glacier.New(session.New())
   927  	input := &glacier.ListTagsForVaultInput{
   928  		AccountId: aws.String("-"),
   929  		VaultName: aws.String("examplevault"),
   930  	}
   931  
   932  	result, err := svc.ListTagsForVault(input)
   933  	if err != nil {
   934  		if aerr, ok := err.(awserr.Error); ok {
   935  			switch aerr.Code() {
   936  			case glacier.ErrCodeInvalidParameterValueException:
   937  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   938  			case glacier.ErrCodeMissingParameterValueException:
   939  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   940  			case glacier.ErrCodeResourceNotFoundException:
   941  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   942  			case glacier.ErrCodeServiceUnavailableException:
   943  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   944  			default:
   945  				fmt.Println(aerr.Error())
   946  			}
   947  		} else {
   948  			// Print the error, cast err to awserr.Error to get the Code and
   949  			// Message from an error.
   950  			fmt.Println(err.Error())
   951  		}
   952  		return
   953  	}
   954  
   955  	fmt.Println(result)
   956  }
   957  
   958  // To list all vaults owned by the calling user's account
   959  //
   960  // The example lists all vaults owned by the specified AWS account.
   961  func ExampleGlacier_ListVaults_shared00() {
   962  	svc := glacier.New(session.New())
   963  	input := &glacier.ListVaultsInput{
   964  		AccountId: aws.String("-"),
   965  		Limit:     aws.String(""),
   966  		Marker:    aws.String(""),
   967  	}
   968  
   969  	result, err := svc.ListVaults(input)
   970  	if err != nil {
   971  		if aerr, ok := err.(awserr.Error); ok {
   972  			switch aerr.Code() {
   973  			case glacier.ErrCodeResourceNotFoundException:
   974  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
   975  			case glacier.ErrCodeInvalidParameterValueException:
   976  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
   977  			case glacier.ErrCodeMissingParameterValueException:
   978  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
   979  			case glacier.ErrCodeServiceUnavailableException:
   980  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
   981  			default:
   982  				fmt.Println(aerr.Error())
   983  			}
   984  		} else {
   985  			// Print the error, cast err to awserr.Error to get the Code and
   986  			// Message from an error.
   987  			fmt.Println(err.Error())
   988  		}
   989  		return
   990  	}
   991  
   992  	fmt.Println(result)
   993  }
   994  
   995  // To purchases a provisioned capacity unit for an AWS account
   996  //
   997  // The example purchases provisioned capacity unit for an AWS account.
   998  func ExampleGlacier_PurchaseProvisionedCapacity_shared00() {
   999  	svc := glacier.New(session.New())
  1000  	input := &glacier.PurchaseProvisionedCapacityInput{
  1001  		AccountId: aws.String("-"),
  1002  	}
  1003  
  1004  	result, err := svc.PurchaseProvisionedCapacity(input)
  1005  	if err != nil {
  1006  		if aerr, ok := err.(awserr.Error); ok {
  1007  			switch aerr.Code() {
  1008  			case glacier.ErrCodeInvalidParameterValueException:
  1009  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
  1010  			case glacier.ErrCodeMissingParameterValueException:
  1011  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
  1012  			case glacier.ErrCodeLimitExceededException:
  1013  				fmt.Println(glacier.ErrCodeLimitExceededException, aerr.Error())
  1014  			case glacier.ErrCodeServiceUnavailableException:
  1015  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
  1016  			default:
  1017  				fmt.Println(aerr.Error())
  1018  			}
  1019  		} else {
  1020  			// Print the error, cast err to awserr.Error to get the Code and
  1021  			// Message from an error.
  1022  			fmt.Println(err.Error())
  1023  		}
  1024  		return
  1025  	}
  1026  
  1027  	fmt.Println(result)
  1028  }
  1029  
  1030  // To remove tags from a vault
  1031  //
  1032  // The example removes two tags from the vault named examplevault.
  1033  func ExampleGlacier_RemoveTagsFromVault_shared00() {
  1034  	svc := glacier.New(session.New())
  1035  	input := &glacier.RemoveTagsFromVaultInput{
  1036  		TagKeys: []*string{
  1037  			aws.String("examplekey1"),
  1038  			aws.String("examplekey2"),
  1039  		},
  1040  		AccountId: aws.String("-"),
  1041  		VaultName: aws.String("examplevault"),
  1042  	}
  1043  
  1044  	result, err := svc.RemoveTagsFromVault(input)
  1045  	if err != nil {
  1046  		if aerr, ok := err.(awserr.Error); ok {
  1047  			switch aerr.Code() {
  1048  			case glacier.ErrCodeInvalidParameterValueException:
  1049  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
  1050  			case glacier.ErrCodeMissingParameterValueException:
  1051  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
  1052  			case glacier.ErrCodeResourceNotFoundException:
  1053  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
  1054  			case glacier.ErrCodeServiceUnavailableException:
  1055  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
  1056  			default:
  1057  				fmt.Println(aerr.Error())
  1058  			}
  1059  		} else {
  1060  			// Print the error, cast err to awserr.Error to get the Code and
  1061  			// Message from an error.
  1062  			fmt.Println(err.Error())
  1063  		}
  1064  		return
  1065  	}
  1066  
  1067  	fmt.Println(result)
  1068  }
  1069  
  1070  // To set and then enact a data retrieval policy
  1071  //
  1072  // The example sets and then enacts a data retrieval policy.
  1073  func ExampleGlacier_SetDataRetrievalPolicy_shared00() {
  1074  	svc := glacier.New(session.New())
  1075  	input := &glacier.SetDataRetrievalPolicyInput{
  1076  		Policy: &glacier.DataRetrievalPolicy{
  1077  			Rules: []*glacier.DataRetrievalRule{
  1078  				{
  1079  					BytesPerHour: aws.Int64(10737418240),
  1080  					Strategy:     aws.String("BytesPerHour"),
  1081  				},
  1082  			},
  1083  		},
  1084  		AccountId: aws.String("-"),
  1085  	}
  1086  
  1087  	result, err := svc.SetDataRetrievalPolicy(input)
  1088  	if err != nil {
  1089  		if aerr, ok := err.(awserr.Error); ok {
  1090  			switch aerr.Code() {
  1091  			case glacier.ErrCodeInvalidParameterValueException:
  1092  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
  1093  			case glacier.ErrCodeMissingParameterValueException:
  1094  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
  1095  			case glacier.ErrCodeServiceUnavailableException:
  1096  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
  1097  			default:
  1098  				fmt.Println(aerr.Error())
  1099  			}
  1100  		} else {
  1101  			// Print the error, cast err to awserr.Error to get the Code and
  1102  			// Message from an error.
  1103  			fmt.Println(err.Error())
  1104  		}
  1105  		return
  1106  	}
  1107  
  1108  	fmt.Println(result)
  1109  }
  1110  
  1111  // To set the access-policy on a vault
  1112  //
  1113  // The example configures an access policy for the vault named examplevault.
  1114  func ExampleGlacier_SetVaultAccessPolicy_shared00() {
  1115  	svc := glacier.New(session.New())
  1116  	input := &glacier.SetVaultAccessPolicyInput{
  1117  		AccountId: aws.String("-"),
  1118  		Policy: &glacier.VaultAccessPolicy{
  1119  			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\"}]}"),
  1120  		},
  1121  		VaultName: aws.String("examplevault"),
  1122  	}
  1123  
  1124  	result, err := svc.SetVaultAccessPolicy(input)
  1125  	if err != nil {
  1126  		if aerr, ok := err.(awserr.Error); ok {
  1127  			switch aerr.Code() {
  1128  			case glacier.ErrCodeResourceNotFoundException:
  1129  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
  1130  			case glacier.ErrCodeInvalidParameterValueException:
  1131  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
  1132  			case glacier.ErrCodeMissingParameterValueException:
  1133  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
  1134  			case glacier.ErrCodeServiceUnavailableException:
  1135  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
  1136  			default:
  1137  				fmt.Println(aerr.Error())
  1138  			}
  1139  		} else {
  1140  			// Print the error, cast err to awserr.Error to get the Code and
  1141  			// Message from an error.
  1142  			fmt.Println(err.Error())
  1143  		}
  1144  		return
  1145  	}
  1146  
  1147  	fmt.Println(result)
  1148  }
  1149  
  1150  // To configure a vault to post a message to an Amazon SNS topic when jobs complete
  1151  //
  1152  // The example sets the examplevault notification configuration.
  1153  func ExampleGlacier_SetVaultNotifications_shared00() {
  1154  	svc := glacier.New(session.New())
  1155  	input := &glacier.SetVaultNotificationsInput{
  1156  		AccountId: aws.String("-"),
  1157  		VaultName: aws.String("examplevault"),
  1158  		VaultNotificationConfig: &glacier.VaultNotificationConfig{
  1159  			Events: []*string{
  1160  				aws.String("ArchiveRetrievalCompleted"),
  1161  				aws.String("InventoryRetrievalCompleted"),
  1162  			},
  1163  			SNSTopic: aws.String("arn:aws:sns:us-west-2:012345678901:mytopic"),
  1164  		},
  1165  	}
  1166  
  1167  	result, err := svc.SetVaultNotifications(input)
  1168  	if err != nil {
  1169  		if aerr, ok := err.(awserr.Error); ok {
  1170  			switch aerr.Code() {
  1171  			case glacier.ErrCodeResourceNotFoundException:
  1172  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
  1173  			case glacier.ErrCodeInvalidParameterValueException:
  1174  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
  1175  			case glacier.ErrCodeMissingParameterValueException:
  1176  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
  1177  			case glacier.ErrCodeServiceUnavailableException:
  1178  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
  1179  			default:
  1180  				fmt.Println(aerr.Error())
  1181  			}
  1182  		} else {
  1183  			// Print the error, cast err to awserr.Error to get the Code and
  1184  			// Message from an error.
  1185  			fmt.Println(err.Error())
  1186  		}
  1187  		return
  1188  	}
  1189  
  1190  	fmt.Println(result)
  1191  }
  1192  
  1193  // To upload an archive
  1194  //
  1195  // The example adds an archive to a vault.
  1196  func ExampleGlacier_UploadArchive_shared00() {
  1197  	svc := glacier.New(session.New())
  1198  	input := &glacier.UploadArchiveInput{
  1199  		AccountId:          aws.String("-"),
  1200  		ArchiveDescription: aws.String(""),
  1201  		Body:               aws.ReadSeekCloser(strings.NewReader("example-data-to-upload")),
  1202  		Checksum:           aws.String(""),
  1203  		VaultName:          aws.String("my-vault"),
  1204  	}
  1205  
  1206  	result, err := svc.UploadArchive(input)
  1207  	if err != nil {
  1208  		if aerr, ok := err.(awserr.Error); ok {
  1209  			switch aerr.Code() {
  1210  			case glacier.ErrCodeResourceNotFoundException:
  1211  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
  1212  			case glacier.ErrCodeInvalidParameterValueException:
  1213  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
  1214  			case glacier.ErrCodeMissingParameterValueException:
  1215  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
  1216  			case glacier.ErrCodeRequestTimeoutException:
  1217  				fmt.Println(glacier.ErrCodeRequestTimeoutException, aerr.Error())
  1218  			case glacier.ErrCodeServiceUnavailableException:
  1219  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
  1220  			default:
  1221  				fmt.Println(aerr.Error())
  1222  			}
  1223  		} else {
  1224  			// Print the error, cast err to awserr.Error to get the Code and
  1225  			// Message from an error.
  1226  			fmt.Println(err.Error())
  1227  		}
  1228  		return
  1229  	}
  1230  
  1231  	fmt.Println(result)
  1232  }
  1233  
  1234  // To upload the first part of an archive
  1235  //
  1236  // The example uploads the first 1 MiB (1024 x 1024 bytes) part of an archive.
  1237  func ExampleGlacier_UploadMultipartPart_shared00() {
  1238  	svc := glacier.New(session.New())
  1239  	input := &glacier.UploadMultipartPartInput{
  1240  		AccountId: aws.String("-"),
  1241  		Body:      aws.ReadSeekCloser(strings.NewReader("part1")),
  1242  		Checksum:  aws.String("c06f7cd4baacb087002a99a5f48bf953"),
  1243  		Range:     aws.String("bytes 0-1048575/*"),
  1244  		UploadId:  aws.String("19gaRezEXAMPLES6Ry5YYdqthHOC_kGRCT03L9yetr220UmPtBYKk-OssZtLqyFu7sY1_lR7vgFuJV6NtcV5zpsJ"),
  1245  		VaultName: aws.String("examplevault"),
  1246  	}
  1247  
  1248  	result, err := svc.UploadMultipartPart(input)
  1249  	if err != nil {
  1250  		if aerr, ok := err.(awserr.Error); ok {
  1251  			switch aerr.Code() {
  1252  			case glacier.ErrCodeResourceNotFoundException:
  1253  				fmt.Println(glacier.ErrCodeResourceNotFoundException, aerr.Error())
  1254  			case glacier.ErrCodeInvalidParameterValueException:
  1255  				fmt.Println(glacier.ErrCodeInvalidParameterValueException, aerr.Error())
  1256  			case glacier.ErrCodeMissingParameterValueException:
  1257  				fmt.Println(glacier.ErrCodeMissingParameterValueException, aerr.Error())
  1258  			case glacier.ErrCodeRequestTimeoutException:
  1259  				fmt.Println(glacier.ErrCodeRequestTimeoutException, aerr.Error())
  1260  			case glacier.ErrCodeServiceUnavailableException:
  1261  				fmt.Println(glacier.ErrCodeServiceUnavailableException, aerr.Error())
  1262  			default:
  1263  				fmt.Println(aerr.Error())
  1264  			}
  1265  		} else {
  1266  			// Print the error, cast err to awserr.Error to get the Code and
  1267  			// Message from an error.
  1268  			fmt.Println(err.Error())
  1269  		}
  1270  		return
  1271  	}
  1272  
  1273  	fmt.Println(result)
  1274  }