aws

package module
v0.0.0-...-54608bb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2015 License: MIT Imports: 15 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ISO8601BasicFormat      = "20060102T150405Z"
	ISO8601BasicFormatShort = "20060102"
)

Variables

View Source
var (
	USEast1 = &Region{
		"US East (Northern Virginia)",
		"us-east-1",
		"glacier.us-east-1.amazonaws.com"}
	USWest1 = &Region{
		"US West (Northern California)",
		"us-west-1",
		"glacier.us-west-1.amazonaws.com"}
	USWest2 = &Region{
		"US West (Oregon)",
		"us-west-2",
		"glacier.us-west-2.amazonaws.com"}
	EU1 = &Region{
		"EU (Ireland)",
		"eu-west-1",
		"glacier.eu-west-1.amazonaws.com"}
	EU2 = &Region{
		"EU (Frankfurt)",
		"eu-central-1",
		"glacier.eu-central-1.amazonaws.com"}
	AsiaPacific1 = &Region{
		"Asia Pacific (Tokyo)",
		"ap-northeast-1",
		"glacier.ap-northeast-1.amazonaws.com"}
	AsiaPacific2 = &Region{
		"Asia Pacific (Sydney)",
		"ap-southeast-2",
		"glacier.ap-southeast-2.amazonaws.com",
	}
)

http://docs.amazonwebservices.com/general/latest/gr/rande.html

Functions

func KeysFromEnviroment

func KeysFromEnviroment() (string, string)

Get secret and access ID keys (in that order) from environment variables AWS_SECRET_KEY and AWS_ACCESS_KEY.

func KeysFromFile

func KeysFromFile(name string) (string, string, error)

Get secret and access ID keys (in that order) from a file.

func ParseError

func ParseError(response *http.Response) error

Attempts to parse an AWS error out of a http response, it is still the caller's responsibility to close the body. See http://docs.aws.amazon.com/amazonglacier/latest/dev/api-error-responses.html

Types

type Error

type Error struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Type    string `json:"type"`
}

func (*Error) Error

func (e *Error) Error() string

type Payload

type Payload interface {
	Payload() (io.ReadCloser, []byte, error)
}

Provides control over how the payload hash is calculated. If a payload is supplied to Sign the returned ReadCloser (if one is returned) is the new requests body.

The payload of an AWS request must be hashed and the http requests body is only a reader, there is no way to rewind it.

func HashedPayload

func HashedPayload(h []byte) Payload

Returns a payload that just returns the precomputed hash. The requests body is untouched.

func MemoryPayload

func MemoryPayload(m []byte) Payload

Returns a payload that hashes the memory and then uses it as the requests body.

func ReadSeekerPayload

func ReadSeekerPayload(rs io.ReadSeeker) Payload

Returns a payload that reads the ReadSeeker to hash it and then reads it again when sending the request.

type Region

type Region struct {
	Region  string // Human readable name.
	Name    string // Canonical name.
	Glacier string // Glacier host address/endpoint.
}

Collection of host address/endpoint for services offered in the region.

type Signature

type Signature struct {
	AccessID   string
	Date       string
	Region     *Region
	Service    string
	SigningKey [sha256.Size]byte
	NewKeys    func() (string, string) // function to get keys if date changes
}

Signature contains the access ID key, UTC date in YYYYMMDD format, region, service name, and the signing key.

func NewSignature

func NewSignature(secret, access string, r *Region, service string) *Signature

NewSignature creates a new signature from the secret key, access key, region, and service with the date set to UTC now.

func (*Signature) Sign

func (s *Signature) Sign(r *http.Request, payload Payload) error

Sign uses signature s to sign the HTTP request. It sets the Authorization header and sets / overwrites the Date header for now. If the signature was created on a different UTC day the signing will be invalid. The optional payload allows for various methods to hash the request's body. If no payload is supplied the body is copyed into memory to be hashed.

Possible errors are an invalid URL query parameters (url.EscapeError), if the date header isn't in time.RFC1123 format (*time.ParseError), or an error when calculating the payload's hash.

Directories

Path Synopsis
Package glacier is a client library for the Amazon Glacier service.
Package glacier is a client library for the Amazon Glacier service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL