aws

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2015 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 1 more Imports: 21 Imported by: 0

Documentation

Overview

Package aws provides core functionality for making requests to AWS services.

Index

Constants

View Source
const DEFAULT_RETRIES = -1
View Source
const SDKName = "aws-sdk-go"
View Source
const SDKVersion = "0.5.0"

Variables

View Source
var (
	// ErrAccessKeyIDNotFound is returned when the AWS Access Key ID can't be
	// found in the process's environment.
	ErrAccessKeyIDNotFound = fmt.Errorf("AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY not found in environment")
	// ErrSecretAccessKeyNotFound is returned when the AWS Secret Access Key
	// can't be found in the process's environment.
	ErrSecretAccessKeyNotFound = fmt.Errorf("AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY not found in environment")
)
View Source
var (
	ErrMissingRegion      = fmt.Errorf("could not find region configuration.")
	ErrMissingCredentials = fmt.Errorf("could not find credentials configuration.")
)
View Source
var DefaultConfig = &Config{
	Credentials:             DefaultCreds(),
	Endpoint:                "",
	Region:                  os.Getenv("AWS_REGION"),
	DisableSSL:              false,
	ManualSend:              false,
	HTTPClient:              http.DefaultClient,
	LogLevel:                0,
	Logger:                  os.Stdout,
	MaxRetries:              DEFAULT_RETRIES,
	DisableParamValidation:  false,
	DisableComputeChecksums: false,
}
View Source
var IAMClient = http.Client{
	Timeout: 1 * time.Second,
}

IAMClient is the HTTP client used to query the metadata endpoint for IAM credentials.

Functions

func AfterRetryHandler

func AfterRetryHandler(r *Request)

func Boolean

func Boolean(v bool) *bool

Boolean converts a Go bool into a boolean pointer.

func BuildContentLength

func BuildContentLength(r *Request)

func Double

func Double(v float64) *float64

Double converts a Go float64 into a double pointer.

func Long

func Long(v int64) *int64

Long converts a Go int64 into a long pointer.

func SendHandler

func SendHandler(r *Request)

func String

func String(v string) *string

String converts a Go string into a string pointer.

func Time

func Time(t time.Time) *time.Time

Time converts a Go Time into a Time pointer

func UserAgentHandler

func UserAgentHandler(r *Request)

func ValidateCredentialsHandler

func ValidateCredentialsHandler(r *Request)

func ValidateEndpointHandler

func ValidateEndpointHandler(r *Request)

func ValidateParameters

func ValidateParameters(r *Request)

func ValidateResponseHandler

func ValidateResponseHandler(r *Request)

Types

type APIError

type APIError struct {
	StatusCode int // HTTP status code e.g. 200
	Code       string
	Message    string
	RequestID  string
}

An APIError is an error returned by an AWS API.

func Error

func Error(e error) *APIError

func (APIError) Error

func (e APIError) Error() string

type Config

type Config struct {
	Credentials             CredentialsProvider
	Endpoint                string
	Region                  string
	DisableSSL              bool
	ManualSend              bool
	HTTPClient              *http.Client
	LogLevel                uint
	Logger                  io.Writer
	MaxRetries              int
	DisableParamValidation  bool
	DisableComputeChecksums bool
}

func (Config) Merge

func (c Config) Merge(newcfg *Config) *Config

type Credentials

type Credentials struct {
	AccessKeyID     string
	SecretAccessKey string
	SessionToken    string
}

Credentials are used to authenticate and authorize calls that you make to AWS.

type CredentialsProvider

type CredentialsProvider interface {
	// Credentials returns a set of credentials (or an error if no credentials
	// could be provided).
	Credentials() (*Credentials, error)
}

A CredentialsProvider is a provider of credentials.

func Creds

func Creds(accessKeyID, secretAccessKey, sessionToken string) CredentialsProvider

Creds returns a static provider of credentials.

func DefaultCreds

func DefaultCreds() CredentialsProvider

func DetectCreds

func DetectCreds(accessKeyID, secretAccessKey, sessionToken string) CredentialsProvider

DetectCreds returns a CredentialsProvider based on the available information.

If the access key ID and secret access key are provided, it returns a basic provider.

If credentials are available via environment variables, it returns an environment provider.

If a profile configuration file is available in the default location and has a default profile configured, it returns a profile provider.

Otherwise, it returns an IAM instance provider.

func EnvCreds

func EnvCreds() (CredentialsProvider, error)

EnvCreds returns a static provider of AWS credentials from the process's environment, or an error if none are found.

func IAMCreds

func IAMCreds() CredentialsProvider

IAMCreds returns a provider which pulls credentials from the local EC2 instance's IAM roles.

func ProfileCreds

func ProfileCreds(filename, profile string, expiry time.Duration) (CredentialsProvider, error)

ProfileCreds returns a provider which pulls credentials from the profile configuration file.

type DefaultCredentialsProvider

type DefaultCredentialsProvider struct {
}

func (*DefaultCredentialsProvider) Credentials

func (p *DefaultCredentialsProvider) Credentials() (*Credentials, error)

type HandlerList

type HandlerList struct {
	// contains filtered or unexported fields
}

A handler list manages zero or more handlers in a list.

func (*HandlerList) Clear

func (l *HandlerList) Clear()

Clear clears the handler list.

func (*HandlerList) Len

func (l *HandlerList) Len() int

Len returns the number of handlers in the list.

func (*HandlerList) PushBack

func (l *HandlerList) PushBack(f ...func(*Request))

PushBack pushes handlers f to the back of the handler list.

func (*HandlerList) PushFront

func (l *HandlerList) PushFront(f ...func(*Request))

PushFront pushes handlers f to the front of the handler list.

func (*HandlerList) Run

func (l *HandlerList) Run(r *Request)

Run executes all handlers in the list with a given request object.

type Handlers

type Handlers struct {
	Validate         HandlerList
	Build            HandlerList
	Sign             HandlerList
	Send             HandlerList
	ValidateResponse HandlerList
	Unmarshal        HandlerList
	UnmarshalMeta    HandlerList
	UnmarshalError   HandlerList
	Retry            HandlerList
	AfterRetry       HandlerList
}

func (*Handlers) Clear

func (h *Handlers) Clear()

Clear removes callback functions for all handlers

type Operation

type Operation struct {
	Name       string
	HTTPMethod string
	HTTPPath   string
}

type ReaderSeekerCloser

type ReaderSeekerCloser struct {
	// contains filtered or unexported fields
}

func ReadSeekCloser

func ReadSeekCloser(r io.Reader) ReaderSeekerCloser

func (ReaderSeekerCloser) Close

func (r ReaderSeekerCloser) Close() error

func (ReaderSeekerCloser) Read

func (r ReaderSeekerCloser) Read(p []byte) (int, error)

func (ReaderSeekerCloser) Seek

func (r ReaderSeekerCloser) Seek(offset int64, whence int) (int64, error)

type Request

type Request struct {
	*Service
	Handlers     Handlers
	Time         time.Time
	ExpireTime   time.Duration
	Operation    *Operation
	HTTPRequest  *http.Request
	HTTPResponse *http.Response
	Body         io.ReadSeeker
	Params       interface{}
	Error        error
	Data         interface{}
	RequestID    string
	RetryCount   uint
	Retryable    bool
	RetryDelay   time.Duration
	// contains filtered or unexported fields
}

func NewRequest

func NewRequest(service *Service, operation *Operation, params interface{}, data interface{}) *Request

func (*Request) Build

func (r *Request) Build() error

func (*Request) DataFilled

func (r *Request) DataFilled() bool

func (*Request) ParamsFilled

func (r *Request) ParamsFilled() bool

func (*Request) Presign

func (r *Request) Presign(expireTime time.Duration) (string, error)

func (*Request) Send

func (r *Request) Send() error

func (*Request) SetBufferBody

func (r *Request) SetBufferBody(buf []byte)

func (*Request) SetReaderBody

func (r *Request) SetReaderBody(reader io.ReadSeeker)

func (*Request) Sign

func (r *Request) Sign() error

func (*Request) WillRetry

func (r *Request) WillRetry() bool

type Service

type Service struct {
	Config            *Config
	Handlers          Handlers
	ManualSend        bool
	ServiceName       string
	APIVersion        string
	Endpoint          string
	SigningRegion     string
	JSONVersion       string
	TargetPrefix      string
	RetryRules        func(*Request) time.Duration
	ShouldRetry       func(*Request) bool
	DefaultMaxRetries uint
}

func NewService

func NewService(config *Config) *Service

func (*Service) AddDebugHandlers

func (s *Service) AddDebugHandlers()

func (*Service) Initialize

func (s *Service) Initialize()

func (*Service) MaxRetries

func (s *Service) MaxRetries() uint

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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