Vendor aws-sdk-go (dep ensure) (#178)

This commit is contained in:
Onur Filiz
2018-04-27 18:18:36 -07:00
committed by Robbie Zhang
parent 228a1f7a5f
commit 8d67098d06
2785 changed files with 1973570 additions and 25 deletions

8377
vendor/github.com/aws/aws-sdk-go/service/glacier/api.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,54 @@
package glacier
import (
"encoding/hex"
"reflect"
"github.com/aws/aws-sdk-go/aws/awsutil"
"github.com/aws/aws-sdk-go/aws/request"
)
var (
defaultAccountID = "-"
)
func init() {
initRequest = func(r *request.Request) {
r.Handlers.Validate.PushFront(addAccountID)
r.Handlers.Validate.PushFront(copyParams) // this happens first
r.Handlers.Build.PushBack(addChecksum)
r.Handlers.Build.PushBack(addAPIVersion)
}
}
func copyParams(r *request.Request) {
r.Params = awsutil.CopyOf(r.Params)
}
func addAccountID(r *request.Request) {
if !r.ParamsFilled() {
return
}
v := reflect.Indirect(reflect.ValueOf(r.Params))
if f := v.FieldByName("AccountId"); f.IsNil() {
f.Set(reflect.ValueOf(&defaultAccountID))
}
}
func addChecksum(r *request.Request) {
if r.Body == nil || r.HTTPRequest.Header.Get("X-Amz-Sha256-Tree-Hash") != "" {
return
}
h := ComputeHashes(r.Body)
hstr := hex.EncodeToString(h.TreeHash)
r.HTTPRequest.Header.Set("X-Amz-Sha256-Tree-Hash", hstr)
hLstr := hex.EncodeToString(h.LinearHash)
r.HTTPRequest.Header.Set("X-Amz-Content-Sha256", hLstr)
}
func addAPIVersion(r *request.Request) {
r.HTTPRequest.Header.Set("X-Amz-Glacier-Version", r.ClientInfo.APIVersion)
}

View File

@@ -0,0 +1,114 @@
// +build !integration
package glacier_test
import (
"bytes"
"testing"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awsutil"
"github.com/aws/aws-sdk-go/awstesting/unit"
"github.com/aws/aws-sdk-go/service/glacier"
)
var (
payloadBuf = func() *bytes.Reader {
buf := make([]byte, 5767168) // 5.5MB buffer
for i := range buf {
buf[i] = '0' // Fill with zero characters
}
return bytes.NewReader(buf)
}()
svc = glacier.New(unit.Session)
)
func TestCustomizations(t *testing.T) {
req, _ := svc.UploadArchiveRequest(&glacier.UploadArchiveInput{
VaultName: aws.String("vault"),
Body: payloadBuf,
})
err := req.Build()
if err != nil {
t.Errorf("expect no err, got %v", err)
}
// Sets API version
if e, a := req.ClientInfo.APIVersion, req.HTTPRequest.Header.Get("x-amz-glacier-version"); e != a {
t.Errorf("expect %v, got %v", e, a)
}
// Sets Account ID
v, _ := awsutil.ValuesAtPath(req.Params, "AccountId")
if e, a := "-", *(v[0].(*string)); e != a {
t.Errorf("expect %v, got %v", e, a)
}
// Computes checksums
linear := "68aff0c5a91aa0491752bfb96e3fef33eb74953804f6a2f7b708d5bcefa8ff6b"
tree := "154e26c78fd74d0c2c9b3cc4644191619dc4f2cd539ae2a74d5fd07957a3ee6a"
if e, a := linear, req.HTTPRequest.Header.Get("x-amz-content-sha256"); e != a {
t.Errorf("expect %v, got %v", e, a)
}
if e, a := tree, req.HTTPRequest.Header.Get("x-amz-sha256-tree-hash"); e != a {
t.Errorf("expect %v, got %v", e, a)
}
}
func TestShortcircuitTreehash(t *testing.T) {
req, _ := svc.UploadArchiveRequest(&glacier.UploadArchiveInput{
VaultName: aws.String("vault"),
Body: payloadBuf,
Checksum: aws.String("000"),
})
err := req.Build()
if err != nil {
t.Errorf("expect no err, got %v", err)
}
if e, a := "000", req.HTTPRequest.Header.Get("x-amz-sha256-tree-hash"); e != a {
t.Errorf("expect %v, got %v", e, a)
}
}
func TestFillAccountIDWithNilStruct(t *testing.T) {
req, _ := svc.ListVaultsRequest(nil)
err := req.Build()
if err != nil {
t.Errorf("expect no err, got %v", err)
}
empty := "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
// Sets Account ID
v, _ := awsutil.ValuesAtPath(req.Params, "AccountId")
if e, a := "-", *(v[0].(*string)); e != a {
t.Errorf("expect %v, got %v", e, a)
}
// Does not set tree hash
if e, a := empty, req.HTTPRequest.Header.Get("x-amz-content-sha256"); e != a {
t.Errorf("expect %v, got %v", e, a)
}
if e, a := "", req.HTTPRequest.Header.Get("x-amz-sha256-tree-hash"); e != a {
t.Errorf("expect %v, got %v", e, a)
}
}
func TestHashOnce(t *testing.T) {
req, _ := svc.UploadArchiveRequest(&glacier.UploadArchiveInput{
VaultName: aws.String("vault"),
Body: payloadBuf,
})
req.HTTPRequest.Header.Set("X-Amz-Sha256-Tree-Hash", "0")
err := req.Build()
if err != nil {
t.Errorf("expect no err, got %v", err)
}
if e, a := "0", req.HTTPRequest.Header.Get("x-amz-sha256-tree-hash"); e != a {
t.Errorf("expect %v, got %v", e, a)
}
}

View File

@@ -0,0 +1,56 @@
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
// Package glacier provides the client and types for making API
// requests to Amazon Glacier.
//
// Amazon Glacier is a storage solution for "cold data."
//
// Amazon Glacier is an extremely low-cost storage service that provides secure,
// durable, and easy-to-use storage for data backup and archival. With Amazon
// Glacier, customers can store their data cost effectively for months, years,
// or decades. Amazon Glacier also enables customers to offload the administrative
// burdens of operating and scaling storage to AWS, so they don't have to worry
// about capacity planning, hardware provisioning, data replication, hardware
// failure and recovery, or time-consuming hardware migrations.
//
// Amazon Glacier is a great storage choice when low storage cost is paramount,
// your data is rarely retrieved, and retrieval latency of several hours is
// acceptable. If your application requires fast or frequent access to your
// data, consider using Amazon S3. For more information, see Amazon Simple Storage
// Service (Amazon S3) (http://aws.amazon.com/s3/).
//
// You can store any kind of data in any format. There is no maximum limit on
// the total amount of data you can store in Amazon Glacier.
//
// If you are a first-time user of Amazon Glacier, we recommend that you begin
// by reading the following sections in the Amazon Glacier Developer Guide:
//
// * What is Amazon Glacier (http://docs.aws.amazon.com/amazonglacier/latest/dev/introduction.html)
// - This section of the Developer Guide describes the underlying data model,
// the operations it supports, and the AWS SDKs that you can use to interact
// with the service.
//
// * Getting Started with Amazon Glacier (http://docs.aws.amazon.com/amazonglacier/latest/dev/amazon-glacier-getting-started.html)
// - The Getting Started section walks you through the process of creating
// a vault, uploading archives, creating jobs to download archives, retrieving
// the job output, and deleting archives.
//
// See glacier package documentation for more information.
// https://docs.aws.amazon.com/sdk-for-go/api/service/glacier/
//
// Using the Client
//
// To contact Amazon Glacier with the SDK use the New function to create
// a new service client. With that client you can make API requests to the service.
// These clients are safe to use concurrently.
//
// See the SDK's documentation for more information on how to use the SDK.
// https://docs.aws.amazon.com/sdk-for-go/api/
//
// See aws.Config documentation for more information on configuring SDK clients.
// https://docs.aws.amazon.com/sdk-for-go/api/aws/#Config
//
// See the Amazon Glacier client Glacier for more
// information on creating client for this service.
// https://docs.aws.amazon.com/sdk-for-go/api/service/glacier/#New
package glacier

View File

@@ -0,0 +1,59 @@
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package glacier
const (
// ErrCodeInsufficientCapacityException for service response error code
// "InsufficientCapacityException".
//
// Returned if there is insufficient capacity to process this expedited request.
// This error only applies to expedited retrievals and not to standard or bulk
// retrievals.
ErrCodeInsufficientCapacityException = "InsufficientCapacityException"
// ErrCodeInvalidParameterValueException for service response error code
// "InvalidParameterValueException".
//
// Returned if a parameter of the request is incorrectly specified.
ErrCodeInvalidParameterValueException = "InvalidParameterValueException"
// ErrCodeLimitExceededException for service response error code
// "LimitExceededException".
//
// Returned if the request results in a vault or account limit being exceeded.
ErrCodeLimitExceededException = "LimitExceededException"
// ErrCodeMissingParameterValueException for service response error code
// "MissingParameterValueException".
//
// Returned if a required header or parameter is missing from the request.
ErrCodeMissingParameterValueException = "MissingParameterValueException"
// ErrCodePolicyEnforcedException for service response error code
// "PolicyEnforcedException".
//
// Returned if a retrieval job would exceed the current data policy's retrieval
// rate limit. For more information about data retrieval policies,
ErrCodePolicyEnforcedException = "PolicyEnforcedException"
// ErrCodeRequestTimeoutException for service response error code
// "RequestTimeoutException".
//
// Returned if, when uploading an archive, Amazon Glacier times out while receiving
// the upload.
ErrCodeRequestTimeoutException = "RequestTimeoutException"
// ErrCodeResourceNotFoundException for service response error code
// "ResourceNotFoundException".
//
// Returned if the specified resource (such as a vault, upload ID, or job ID)
// doesn't exist.
ErrCodeResourceNotFoundException = "ResourceNotFoundException"
// ErrCodeServiceUnavailableException for service response error code
// "ServiceUnavailableException".
//
// Returned if the service cannot complete the request.
ErrCodeServiceUnavailableException = "ServiceUnavailableException"
)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,214 @@
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
// Package glacieriface provides an interface to enable mocking the Amazon Glacier service client
// for testing your code.
//
// It is important to note that this interface will have breaking changes
// when the service model is updated and adds new API operations, paginators,
// and waiters.
package glacieriface
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/glacier"
)
// GlacierAPI provides an interface to enable mocking the
// glacier.Glacier service client's API operation,
// paginators, and waiters. This make unit testing your code that calls out
// to the SDK's service client's calls easier.
//
// The best way to use this interface is so the SDK's service client's calls
// can be stubbed out for unit testing your code with the SDK without needing
// to inject custom request handlers into the SDK's request pipeline.
//
// // myFunc uses an SDK service client to make a request to
// // Amazon Glacier.
// func myFunc(svc glacieriface.GlacierAPI) bool {
// // Make svc.AbortMultipartUpload request
// }
//
// func main() {
// sess := session.New()
// svc := glacier.New(sess)
//
// myFunc(svc)
// }
//
// In your _test.go file:
//
// // Define a mock struct to be used in your unit tests of myFunc.
// type mockGlacierClient struct {
// glacieriface.GlacierAPI
// }
// func (m *mockGlacierClient) AbortMultipartUpload(input *glacier.AbortMultipartUploadInput) (*glacier.AbortMultipartUploadOutput, error) {
// // mock response/functionality
// }
//
// func TestMyFunc(t *testing.T) {
// // Setup Test
// mockSvc := &mockGlacierClient{}
//
// myfunc(mockSvc)
//
// // Verify myFunc's functionality
// }
//
// It is important to note that this interface will have breaking changes
// when the service model is updated and adds new API operations, paginators,
// and waiters. Its suggested to use the pattern above for testing, or using
// tooling to generate mocks to satisfy the interfaces.
type GlacierAPI interface {
AbortMultipartUpload(*glacier.AbortMultipartUploadInput) (*glacier.AbortMultipartUploadOutput, error)
AbortMultipartUploadWithContext(aws.Context, *glacier.AbortMultipartUploadInput, ...request.Option) (*glacier.AbortMultipartUploadOutput, error)
AbortMultipartUploadRequest(*glacier.AbortMultipartUploadInput) (*request.Request, *glacier.AbortMultipartUploadOutput)
AbortVaultLock(*glacier.AbortVaultLockInput) (*glacier.AbortVaultLockOutput, error)
AbortVaultLockWithContext(aws.Context, *glacier.AbortVaultLockInput, ...request.Option) (*glacier.AbortVaultLockOutput, error)
AbortVaultLockRequest(*glacier.AbortVaultLockInput) (*request.Request, *glacier.AbortVaultLockOutput)
AddTagsToVault(*glacier.AddTagsToVaultInput) (*glacier.AddTagsToVaultOutput, error)
AddTagsToVaultWithContext(aws.Context, *glacier.AddTagsToVaultInput, ...request.Option) (*glacier.AddTagsToVaultOutput, error)
AddTagsToVaultRequest(*glacier.AddTagsToVaultInput) (*request.Request, *glacier.AddTagsToVaultOutput)
CompleteMultipartUpload(*glacier.CompleteMultipartUploadInput) (*glacier.ArchiveCreationOutput, error)
CompleteMultipartUploadWithContext(aws.Context, *glacier.CompleteMultipartUploadInput, ...request.Option) (*glacier.ArchiveCreationOutput, error)
CompleteMultipartUploadRequest(*glacier.CompleteMultipartUploadInput) (*request.Request, *glacier.ArchiveCreationOutput)
CompleteVaultLock(*glacier.CompleteVaultLockInput) (*glacier.CompleteVaultLockOutput, error)
CompleteVaultLockWithContext(aws.Context, *glacier.CompleteVaultLockInput, ...request.Option) (*glacier.CompleteVaultLockOutput, error)
CompleteVaultLockRequest(*glacier.CompleteVaultLockInput) (*request.Request, *glacier.CompleteVaultLockOutput)
CreateVault(*glacier.CreateVaultInput) (*glacier.CreateVaultOutput, error)
CreateVaultWithContext(aws.Context, *glacier.CreateVaultInput, ...request.Option) (*glacier.CreateVaultOutput, error)
CreateVaultRequest(*glacier.CreateVaultInput) (*request.Request, *glacier.CreateVaultOutput)
DeleteArchive(*glacier.DeleteArchiveInput) (*glacier.DeleteArchiveOutput, error)
DeleteArchiveWithContext(aws.Context, *glacier.DeleteArchiveInput, ...request.Option) (*glacier.DeleteArchiveOutput, error)
DeleteArchiveRequest(*glacier.DeleteArchiveInput) (*request.Request, *glacier.DeleteArchiveOutput)
DeleteVault(*glacier.DeleteVaultInput) (*glacier.DeleteVaultOutput, error)
DeleteVaultWithContext(aws.Context, *glacier.DeleteVaultInput, ...request.Option) (*glacier.DeleteVaultOutput, error)
DeleteVaultRequest(*glacier.DeleteVaultInput) (*request.Request, *glacier.DeleteVaultOutput)
DeleteVaultAccessPolicy(*glacier.DeleteVaultAccessPolicyInput) (*glacier.DeleteVaultAccessPolicyOutput, error)
DeleteVaultAccessPolicyWithContext(aws.Context, *glacier.DeleteVaultAccessPolicyInput, ...request.Option) (*glacier.DeleteVaultAccessPolicyOutput, error)
DeleteVaultAccessPolicyRequest(*glacier.DeleteVaultAccessPolicyInput) (*request.Request, *glacier.DeleteVaultAccessPolicyOutput)
DeleteVaultNotifications(*glacier.DeleteVaultNotificationsInput) (*glacier.DeleteVaultNotificationsOutput, error)
DeleteVaultNotificationsWithContext(aws.Context, *glacier.DeleteVaultNotificationsInput, ...request.Option) (*glacier.DeleteVaultNotificationsOutput, error)
DeleteVaultNotificationsRequest(*glacier.DeleteVaultNotificationsInput) (*request.Request, *glacier.DeleteVaultNotificationsOutput)
DescribeJob(*glacier.DescribeJobInput) (*glacier.JobDescription, error)
DescribeJobWithContext(aws.Context, *glacier.DescribeJobInput, ...request.Option) (*glacier.JobDescription, error)
DescribeJobRequest(*glacier.DescribeJobInput) (*request.Request, *glacier.JobDescription)
DescribeVault(*glacier.DescribeVaultInput) (*glacier.DescribeVaultOutput, error)
DescribeVaultWithContext(aws.Context, *glacier.DescribeVaultInput, ...request.Option) (*glacier.DescribeVaultOutput, error)
DescribeVaultRequest(*glacier.DescribeVaultInput) (*request.Request, *glacier.DescribeVaultOutput)
GetDataRetrievalPolicy(*glacier.GetDataRetrievalPolicyInput) (*glacier.GetDataRetrievalPolicyOutput, error)
GetDataRetrievalPolicyWithContext(aws.Context, *glacier.GetDataRetrievalPolicyInput, ...request.Option) (*glacier.GetDataRetrievalPolicyOutput, error)
GetDataRetrievalPolicyRequest(*glacier.GetDataRetrievalPolicyInput) (*request.Request, *glacier.GetDataRetrievalPolicyOutput)
GetJobOutput(*glacier.GetJobOutputInput) (*glacier.GetJobOutputOutput, error)
GetJobOutputWithContext(aws.Context, *glacier.GetJobOutputInput, ...request.Option) (*glacier.GetJobOutputOutput, error)
GetJobOutputRequest(*glacier.GetJobOutputInput) (*request.Request, *glacier.GetJobOutputOutput)
GetVaultAccessPolicy(*glacier.GetVaultAccessPolicyInput) (*glacier.GetVaultAccessPolicyOutput, error)
GetVaultAccessPolicyWithContext(aws.Context, *glacier.GetVaultAccessPolicyInput, ...request.Option) (*glacier.GetVaultAccessPolicyOutput, error)
GetVaultAccessPolicyRequest(*glacier.GetVaultAccessPolicyInput) (*request.Request, *glacier.GetVaultAccessPolicyOutput)
GetVaultLock(*glacier.GetVaultLockInput) (*glacier.GetVaultLockOutput, error)
GetVaultLockWithContext(aws.Context, *glacier.GetVaultLockInput, ...request.Option) (*glacier.GetVaultLockOutput, error)
GetVaultLockRequest(*glacier.GetVaultLockInput) (*request.Request, *glacier.GetVaultLockOutput)
GetVaultNotifications(*glacier.GetVaultNotificationsInput) (*glacier.GetVaultNotificationsOutput, error)
GetVaultNotificationsWithContext(aws.Context, *glacier.GetVaultNotificationsInput, ...request.Option) (*glacier.GetVaultNotificationsOutput, error)
GetVaultNotificationsRequest(*glacier.GetVaultNotificationsInput) (*request.Request, *glacier.GetVaultNotificationsOutput)
InitiateJob(*glacier.InitiateJobInput) (*glacier.InitiateJobOutput, error)
InitiateJobWithContext(aws.Context, *glacier.InitiateJobInput, ...request.Option) (*glacier.InitiateJobOutput, error)
InitiateJobRequest(*glacier.InitiateJobInput) (*request.Request, *glacier.InitiateJobOutput)
InitiateMultipartUpload(*glacier.InitiateMultipartUploadInput) (*glacier.InitiateMultipartUploadOutput, error)
InitiateMultipartUploadWithContext(aws.Context, *glacier.InitiateMultipartUploadInput, ...request.Option) (*glacier.InitiateMultipartUploadOutput, error)
InitiateMultipartUploadRequest(*glacier.InitiateMultipartUploadInput) (*request.Request, *glacier.InitiateMultipartUploadOutput)
InitiateVaultLock(*glacier.InitiateVaultLockInput) (*glacier.InitiateVaultLockOutput, error)
InitiateVaultLockWithContext(aws.Context, *glacier.InitiateVaultLockInput, ...request.Option) (*glacier.InitiateVaultLockOutput, error)
InitiateVaultLockRequest(*glacier.InitiateVaultLockInput) (*request.Request, *glacier.InitiateVaultLockOutput)
ListJobs(*glacier.ListJobsInput) (*glacier.ListJobsOutput, error)
ListJobsWithContext(aws.Context, *glacier.ListJobsInput, ...request.Option) (*glacier.ListJobsOutput, error)
ListJobsRequest(*glacier.ListJobsInput) (*request.Request, *glacier.ListJobsOutput)
ListJobsPages(*glacier.ListJobsInput, func(*glacier.ListJobsOutput, bool) bool) error
ListJobsPagesWithContext(aws.Context, *glacier.ListJobsInput, func(*glacier.ListJobsOutput, bool) bool, ...request.Option) error
ListMultipartUploads(*glacier.ListMultipartUploadsInput) (*glacier.ListMultipartUploadsOutput, error)
ListMultipartUploadsWithContext(aws.Context, *glacier.ListMultipartUploadsInput, ...request.Option) (*glacier.ListMultipartUploadsOutput, error)
ListMultipartUploadsRequest(*glacier.ListMultipartUploadsInput) (*request.Request, *glacier.ListMultipartUploadsOutput)
ListMultipartUploadsPages(*glacier.ListMultipartUploadsInput, func(*glacier.ListMultipartUploadsOutput, bool) bool) error
ListMultipartUploadsPagesWithContext(aws.Context, *glacier.ListMultipartUploadsInput, func(*glacier.ListMultipartUploadsOutput, bool) bool, ...request.Option) error
ListParts(*glacier.ListPartsInput) (*glacier.ListPartsOutput, error)
ListPartsWithContext(aws.Context, *glacier.ListPartsInput, ...request.Option) (*glacier.ListPartsOutput, error)
ListPartsRequest(*glacier.ListPartsInput) (*request.Request, *glacier.ListPartsOutput)
ListPartsPages(*glacier.ListPartsInput, func(*glacier.ListPartsOutput, bool) bool) error
ListPartsPagesWithContext(aws.Context, *glacier.ListPartsInput, func(*glacier.ListPartsOutput, bool) bool, ...request.Option) error
ListProvisionedCapacity(*glacier.ListProvisionedCapacityInput) (*glacier.ListProvisionedCapacityOutput, error)
ListProvisionedCapacityWithContext(aws.Context, *glacier.ListProvisionedCapacityInput, ...request.Option) (*glacier.ListProvisionedCapacityOutput, error)
ListProvisionedCapacityRequest(*glacier.ListProvisionedCapacityInput) (*request.Request, *glacier.ListProvisionedCapacityOutput)
ListTagsForVault(*glacier.ListTagsForVaultInput) (*glacier.ListTagsForVaultOutput, error)
ListTagsForVaultWithContext(aws.Context, *glacier.ListTagsForVaultInput, ...request.Option) (*glacier.ListTagsForVaultOutput, error)
ListTagsForVaultRequest(*glacier.ListTagsForVaultInput) (*request.Request, *glacier.ListTagsForVaultOutput)
ListVaults(*glacier.ListVaultsInput) (*glacier.ListVaultsOutput, error)
ListVaultsWithContext(aws.Context, *glacier.ListVaultsInput, ...request.Option) (*glacier.ListVaultsOutput, error)
ListVaultsRequest(*glacier.ListVaultsInput) (*request.Request, *glacier.ListVaultsOutput)
ListVaultsPages(*glacier.ListVaultsInput, func(*glacier.ListVaultsOutput, bool) bool) error
ListVaultsPagesWithContext(aws.Context, *glacier.ListVaultsInput, func(*glacier.ListVaultsOutput, bool) bool, ...request.Option) error
PurchaseProvisionedCapacity(*glacier.PurchaseProvisionedCapacityInput) (*glacier.PurchaseProvisionedCapacityOutput, error)
PurchaseProvisionedCapacityWithContext(aws.Context, *glacier.PurchaseProvisionedCapacityInput, ...request.Option) (*glacier.PurchaseProvisionedCapacityOutput, error)
PurchaseProvisionedCapacityRequest(*glacier.PurchaseProvisionedCapacityInput) (*request.Request, *glacier.PurchaseProvisionedCapacityOutput)
RemoveTagsFromVault(*glacier.RemoveTagsFromVaultInput) (*glacier.RemoveTagsFromVaultOutput, error)
RemoveTagsFromVaultWithContext(aws.Context, *glacier.RemoveTagsFromVaultInput, ...request.Option) (*glacier.RemoveTagsFromVaultOutput, error)
RemoveTagsFromVaultRequest(*glacier.RemoveTagsFromVaultInput) (*request.Request, *glacier.RemoveTagsFromVaultOutput)
SetDataRetrievalPolicy(*glacier.SetDataRetrievalPolicyInput) (*glacier.SetDataRetrievalPolicyOutput, error)
SetDataRetrievalPolicyWithContext(aws.Context, *glacier.SetDataRetrievalPolicyInput, ...request.Option) (*glacier.SetDataRetrievalPolicyOutput, error)
SetDataRetrievalPolicyRequest(*glacier.SetDataRetrievalPolicyInput) (*request.Request, *glacier.SetDataRetrievalPolicyOutput)
SetVaultAccessPolicy(*glacier.SetVaultAccessPolicyInput) (*glacier.SetVaultAccessPolicyOutput, error)
SetVaultAccessPolicyWithContext(aws.Context, *glacier.SetVaultAccessPolicyInput, ...request.Option) (*glacier.SetVaultAccessPolicyOutput, error)
SetVaultAccessPolicyRequest(*glacier.SetVaultAccessPolicyInput) (*request.Request, *glacier.SetVaultAccessPolicyOutput)
SetVaultNotifications(*glacier.SetVaultNotificationsInput) (*glacier.SetVaultNotificationsOutput, error)
SetVaultNotificationsWithContext(aws.Context, *glacier.SetVaultNotificationsInput, ...request.Option) (*glacier.SetVaultNotificationsOutput, error)
SetVaultNotificationsRequest(*glacier.SetVaultNotificationsInput) (*request.Request, *glacier.SetVaultNotificationsOutput)
UploadArchive(*glacier.UploadArchiveInput) (*glacier.ArchiveCreationOutput, error)
UploadArchiveWithContext(aws.Context, *glacier.UploadArchiveInput, ...request.Option) (*glacier.ArchiveCreationOutput, error)
UploadArchiveRequest(*glacier.UploadArchiveInput) (*request.Request, *glacier.ArchiveCreationOutput)
UploadMultipartPart(*glacier.UploadMultipartPartInput) (*glacier.UploadMultipartPartOutput, error)
UploadMultipartPartWithContext(aws.Context, *glacier.UploadMultipartPartInput, ...request.Option) (*glacier.UploadMultipartPartOutput, error)
UploadMultipartPartRequest(*glacier.UploadMultipartPartInput) (*request.Request, *glacier.UploadMultipartPartOutput)
WaitUntilVaultExists(*glacier.DescribeVaultInput) error
WaitUntilVaultExistsWithContext(aws.Context, *glacier.DescribeVaultInput, ...request.WaiterOption) error
WaitUntilVaultNotExists(*glacier.DescribeVaultInput) error
WaitUntilVaultNotExistsWithContext(aws.Context, *glacier.DescribeVaultInput, ...request.WaiterOption) error
}
var _ GlacierAPI = (*glacier.Glacier)(nil)

View File

@@ -0,0 +1,93 @@
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package glacier
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/client"
"github.com/aws/aws-sdk-go/aws/client/metadata"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/aws/signer/v4"
"github.com/aws/aws-sdk-go/private/protocol/restjson"
)
// Glacier provides the API operation methods for making requests to
// Amazon Glacier. See this package's package overview docs
// for details on the service.
//
// Glacier methods are safe to use concurrently. It is not safe to
// modify mutate any of the struct's properties though.
type Glacier struct {
*client.Client
}
// Used for custom client initialization logic
var initClient func(*client.Client)
// Used for custom request initialization logic
var initRequest func(*request.Request)
// Service information constants
const (
ServiceName = "glacier" // Service endpoint prefix API calls made to.
EndpointsID = ServiceName // Service ID for Regions and Endpoints metadata.
)
// New creates a new instance of the Glacier client with a session.
// If additional configuration is needed for the client instance use the optional
// aws.Config parameter to add your extra config.
//
// Example:
// // Create a Glacier client from just a session.
// svc := glacier.New(mySession)
//
// // Create a Glacier client with additional configuration
// svc := glacier.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
func New(p client.ConfigProvider, cfgs ...*aws.Config) *Glacier {
c := p.ClientConfig(EndpointsID, cfgs...)
return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion, c.SigningName)
}
// newClient creates, initializes and returns a new service client instance.
func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion, signingName string) *Glacier {
svc := &Glacier{
Client: client.New(
cfg,
metadata.ClientInfo{
ServiceName: ServiceName,
SigningName: signingName,
SigningRegion: signingRegion,
Endpoint: endpoint,
APIVersion: "2012-06-01",
},
handlers,
),
}
// Handlers
svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
svc.Handlers.Build.PushBackNamed(restjson.BuildHandler)
svc.Handlers.Unmarshal.PushBackNamed(restjson.UnmarshalHandler)
svc.Handlers.UnmarshalMeta.PushBackNamed(restjson.UnmarshalMetaHandler)
svc.Handlers.UnmarshalError.PushBackNamed(restjson.UnmarshalErrorHandler)
// Run custom client initialization if present
if initClient != nil {
initClient(svc.Client)
}
return svc
}
// newRequest creates a new request for a Glacier operation and runs any
// custom request initialization.
func (c *Glacier) newRequest(op *request.Operation, params, data interface{}) *request.Request {
req := c.NewRequest(op, params, data)
// Run custom request initialization if present
if initRequest != nil {
initRequest(req)
}
return req
}

View File

@@ -0,0 +1,79 @@
package glacier
import (
"crypto/sha256"
"io"
"github.com/aws/aws-sdk-go/internal/sdkio"
)
const bufsize = 1024 * 1024
// Hash contains information about the tree-hash and linear hash of a
// Glacier payload. This structure is generated by ComputeHashes().
type Hash struct {
TreeHash []byte
LinearHash []byte
}
// ComputeHashes computes the tree-hash and linear hash of a seekable reader r.
//
// See http://docs.aws.amazon.com/amazonglacier/latest/dev/checksum-calculations.html for more information.
func ComputeHashes(r io.ReadSeeker) Hash {
start, _ := r.Seek(0, sdkio.SeekCurrent) // Read the whole stream
defer r.Seek(start, sdkio.SeekStart) // Rewind stream at end
buf := make([]byte, bufsize)
hashes := [][]byte{}
hsh := sha256.New()
for {
// Build leaf nodes in 1MB chunks
n, err := io.ReadAtLeast(r, buf, bufsize)
if n == 0 {
break
}
tmpHash := sha256.Sum256(buf[:n])
hashes = append(hashes, tmpHash[:])
hsh.Write(buf[:n]) // Track linear hash while we're at it
if err != nil {
break // This is the last chunk
}
}
return Hash{
LinearHash: hsh.Sum(nil),
TreeHash: ComputeTreeHash(hashes),
}
}
// ComputeTreeHash builds a tree hash root node given a slice of
// hashes. Glacier tree hash to be derived from SHA256 hashes of 1MB
// chucks of the data.
//
// See http://docs.aws.amazon.com/amazonglacier/latest/dev/checksum-calculations.html for more information.
func ComputeTreeHash(hashes [][]byte) []byte {
if hashes == nil || len(hashes) == 0 {
return nil
}
for len(hashes) > 1 {
tmpHashes := [][]byte{}
for i := 0; i < len(hashes); i += 2 {
if i+1 <= len(hashes)-1 {
tmpHash := append(append([]byte{}, hashes[i]...), hashes[i+1]...)
tmpSum := sha256.Sum256(tmpHash)
tmpHashes = append(tmpHashes, tmpSum[:])
} else {
tmpHashes = append(tmpHashes, hashes[i])
}
}
hashes = tmpHashes
}
return hashes[0]
}

View File

@@ -0,0 +1,63 @@
package glacier_test
import (
"bytes"
"crypto/sha256"
"fmt"
"io"
"github.com/aws/aws-sdk-go/service/glacier"
)
func ExampleComputeHashes() {
r := testCreateReader()
h := glacier.ComputeHashes(r)
n, _ := r.Seek(0, 1) // Check position after checksumming
fmt.Printf("linear: %x\n", h.LinearHash)
fmt.Printf("tree: %x\n", h.TreeHash)
fmt.Printf("pos: %d\n", n)
// Output:
// linear: 68aff0c5a91aa0491752bfb96e3fef33eb74953804f6a2f7b708d5bcefa8ff6b
// tree: 154e26c78fd74d0c2c9b3cc4644191619dc4f2cd539ae2a74d5fd07957a3ee6a
// pos: 0
}
func testCreateReader() io.ReadSeeker {
buf := make([]byte, 5767168) // 5.5MB buffer
for i := range buf {
buf[i] = '0' // Fill with zero characters
}
return bytes.NewReader(buf)
}
func ExampleComputeTreeHash() {
r := testCreateReader()
const chunkSize = 1024 * 1024 // 1MB
buf := make([]byte, chunkSize)
hashes := [][]byte{}
for {
// Reach 1MB chunks from reader to generate hashes from
n, err := io.ReadAtLeast(r, buf, chunkSize)
if n == 0 {
break
}
tmpHash := sha256.Sum256(buf[:n])
hashes = append(hashes, tmpHash[:])
if err != nil {
break // last chunk
}
}
treeHash := glacier.ComputeTreeHash(hashes)
fmt.Printf("TreeHash: %x\n", treeHash)
// Output:
// TreeHash: 154e26c78fd74d0c2c9b3cc4644191619dc4f2cd539ae2a74d5fd07957a3ee6a
}

View File

@@ -0,0 +1,112 @@
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package glacier
import (
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/request"
)
// WaitUntilVaultExists uses the Amazon Glacier API operation
// DescribeVault to wait for a condition to be met before returning.
// If the condition is not met within the max attempt window, an error will
// be returned.
func (c *Glacier) WaitUntilVaultExists(input *DescribeVaultInput) error {
return c.WaitUntilVaultExistsWithContext(aws.BackgroundContext(), input)
}
// WaitUntilVaultExistsWithContext is an extended version of WaitUntilVaultExists.
// With the support for passing in a context and options to configure the
// Waiter and the underlying request options.
//
// The context must be non-nil and will be used for request cancellation. If
// the context is nil a panic will occur. In the future the SDK may create
// sub-contexts for http.Requests. See https://golang.org/pkg/context/
// for more information on using Contexts.
func (c *Glacier) WaitUntilVaultExistsWithContext(ctx aws.Context, input *DescribeVaultInput, opts ...request.WaiterOption) error {
w := request.Waiter{
Name: "WaitUntilVaultExists",
MaxAttempts: 15,
Delay: request.ConstantWaiterDelay(3 * time.Second),
Acceptors: []request.WaiterAcceptor{
{
State: request.SuccessWaiterState,
Matcher: request.StatusWaiterMatch,
Expected: 200,
},
{
State: request.RetryWaiterState,
Matcher: request.ErrorWaiterMatch,
Expected: "ResourceNotFoundException",
},
},
Logger: c.Config.Logger,
NewRequest: func(opts []request.Option) (*request.Request, error) {
var inCpy *DescribeVaultInput
if input != nil {
tmp := *input
inCpy = &tmp
}
req, _ := c.DescribeVaultRequest(inCpy)
req.SetContext(ctx)
req.ApplyOptions(opts...)
return req, nil
},
}
w.ApplyOptions(opts...)
return w.WaitWithContext(ctx)
}
// WaitUntilVaultNotExists uses the Amazon Glacier API operation
// DescribeVault to wait for a condition to be met before returning.
// If the condition is not met within the max attempt window, an error will
// be returned.
func (c *Glacier) WaitUntilVaultNotExists(input *DescribeVaultInput) error {
return c.WaitUntilVaultNotExistsWithContext(aws.BackgroundContext(), input)
}
// WaitUntilVaultNotExistsWithContext is an extended version of WaitUntilVaultNotExists.
// With the support for passing in a context and options to configure the
// Waiter and the underlying request options.
//
// The context must be non-nil and will be used for request cancellation. If
// the context is nil a panic will occur. In the future the SDK may create
// sub-contexts for http.Requests. See https://golang.org/pkg/context/
// for more information on using Contexts.
func (c *Glacier) WaitUntilVaultNotExistsWithContext(ctx aws.Context, input *DescribeVaultInput, opts ...request.WaiterOption) error {
w := request.Waiter{
Name: "WaitUntilVaultNotExists",
MaxAttempts: 15,
Delay: request.ConstantWaiterDelay(3 * time.Second),
Acceptors: []request.WaiterAcceptor{
{
State: request.RetryWaiterState,
Matcher: request.StatusWaiterMatch,
Expected: 200,
},
{
State: request.SuccessWaiterState,
Matcher: request.ErrorWaiterMatch,
Expected: "ResourceNotFoundException",
},
},
Logger: c.Config.Logger,
NewRequest: func(opts []request.Option) (*request.Request, error) {
var inCpy *DescribeVaultInput
if input != nil {
tmp := *input
inCpy = &tmp
}
req, _ := c.DescribeVaultRequest(inCpy)
req.SetContext(ctx)
req.ApplyOptions(opts...)
return req, nil
},
}
w.ApplyOptions(opts...)
return w.WaitWithContext(ctx)
}