Documentation ¶
Index ¶
Constants ¶
const ( ISO8601BasicFormat = "20060102T150405Z" ISO8601BasicFormatShort = "20060102" )
Variables ¶
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
var Regions = []*Region{USEast1, USWest1, USWest2, EU1, EU2, AsiaPacific1, AsiaPacific2}
Functions ¶
func KeysFromEnviroment ¶
Get secret and access ID keys (in that order) from environment variables AWS_SECRET_KEY and AWS_ACCESS_KEY.
func KeysFromFile ¶
Get secret and access ID keys (in that order) from a file.
func ParseError ¶
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 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 ¶
Returns a payload that just returns the precomputed hash. The requests body is untouched.
func MemoryPayload ¶
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 ¶
NewSignature creates a new signature from the secret key, access key, region, and service with the date set to UTC now.
func (*Signature) Sign ¶
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.