Documentation

Overview

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

    Index

    Constants

    View Source
    const DefaultRetries = -1

      The default number of retries for a service. The value of -1 indicates that the service specific retry default will be used.

      View Source
      const SDKName = "aws-sdk-go"

        SDKName is the name of this AWS SDK

        View Source
        const SDKVersion = "0.6.0"

          SDKVersion is the version of this SDK

          Variables

          View Source
          var (
          	// ErrMissingRegion is an error that is returned if region configuration is
          	// not found.
          	ErrMissingRegion error = apierr.New("MissingRegion", "could not find region configuration", nil)
          
          	// ErrMissingEndpoint is an error that is returned if an endpoint cannot be
          	// resolved for a service.
          	ErrMissingEndpoint error = apierr.New("MissingEndpoint", "'Endpoint' configuration is required for this service", nil)
          )
          View Source
          var DefaultChainCredentials = credentials.NewChainCredentials(
          	[]credentials.Provider{
          		&credentials.EnvProvider{},
          		&credentials.SharedCredentialsProvider{Filename: "", Profile: ""},
          		&credentials.EC2RoleProvider{ExpiryWindow: 5 * time.Minute},
          	})

            DefaultChainCredentials is a Credentials which will find the first available credentials Value from the list of Providers.

            This should be used in the default case. Once the type of credentials are known switching to the specific Credentials will be more efficient.

            View Source
            var DefaultConfig = &Config{
            	Credentials:             DefaultChainCredentials,
            	Endpoint:                "",
            	Region:                  os.Getenv("AWS_REGION"),
            	DisableSSL:              false,
            	ManualSend:              false,
            	HTTPClient:              http.DefaultClient,
            	LogHTTPBody:             false,
            	LogLevel:                0,
            	Logger:                  os.Stdout,
            	MaxRetries:              DefaultRetries,
            	DisableParamValidation:  false,
            	DisableComputeChecksums: false,
            	S3ForcePathStyle:        false,
            }

              DefaultConfig is the default all service configuration will be based off of.

              Functions

              func AfterRetryHandler

              func AfterRetryHandler(r *Request)

                AfterRetryHandler performs final checks to determine if the request should be retried and how long to delay.

                func Boolean

                func Boolean(v bool) *bool

                  Boolean converts a Go bool into a boolean pointer.

                  func BuildContentLength

                  func BuildContentLength(r *Request)

                    BuildContentLength builds the content length of a request based on the body, or will use the HTTPRequest.Header's "Content-Length" if defined. If unable to determine request body length and no "Content-Length" was specified it will panic.

                    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)

                          SendHandler is a request handler to send service request using HTTP client.

                          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)

                                UserAgentHandler is a request handler for injecting User agent into requests.

                                func ValidateEndpointHandler

                                func ValidateEndpointHandler(r *Request)

                                  ValidateEndpointHandler is a request handler to validate a request had the appropriate Region and Endpoint set. Will set r.Error if the endpoint or region is not valid.

                                  func ValidateParameters

                                  func ValidateParameters(r *Request)

                                    ValidateParameters is a request handler to validate the input parameters. Validating parameters only has meaning if done prior to the request being sent.

                                    func ValidateResponseHandler

                                    func ValidateResponseHandler(r *Request)

                                      ValidateResponseHandler is a request handler to validate service response.

                                      Types

                                      type Config

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

                                        A Config provides service configuration

                                        func (Config) Copy

                                        func (c Config) Copy() Config

                                          Copy will return a shallow copy of the Config object.

                                          func (Config) Merge

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

                                            Merge merges the newcfg attribute values into this Config. Each attribute will be merged into this config if the newcfg attribute's value is non-zero. Due to this, newcfg attributes with zero values cannot be merged in. For example bool attributes cannot be cleared using Merge, and must be explicitly set on the Config structure.

                                            type HandlerList

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

                                              A HandlerList 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
                                                        }

                                                          A Handlers provides a collection of request handlers for various stages of handling requests.

                                                          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
                                                            	*Paginator
                                                            }

                                                              An Operation is the service API operation to be made.

                                                              type Paginator

                                                              type Paginator struct {
                                                              	InputTokens     []string
                                                              	OutputTokens    []string
                                                              	LimitToken      string
                                                              	TruncationToken string
                                                              }

                                                                Paginator keeps track of pagination configuration for an API operation.

                                                                type ReaderSeekerCloser

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

                                                                  ReaderSeekerCloser represents a reader that can also delegate io.Seeker and io.Closer interfaces to the underlying object if they are available.

                                                                  func ReadSeekCloser

                                                                  func ReadSeekCloser(r io.Reader) ReaderSeekerCloser

                                                                    ReadSeekCloser wraps a io.Reader returning a ReaderSeakerCloser

                                                                    func (ReaderSeekerCloser) Close

                                                                    func (r ReaderSeekerCloser) Close() error

                                                                      Close closes the ReaderSeekerCloser.

                                                                      If the ReaderSeekerCloser is not an io.Closer nothing will be done.

                                                                      func (ReaderSeekerCloser) Read

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

                                                                        Read reads from the reader up to size of p. The number of bytes read, and error if it occurred will be returned.

                                                                        If the reader is not an io.Reader zero bytes read, and nil error will be returned.

                                                                        Performs the same functionality as io.Reader Read

                                                                        func (ReaderSeekerCloser) Seek

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

                                                                          Seek sets the offset for the next Read to offset, interpreted according to whence: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 means relative to the end. Seek returns the new offset and an error, if any.

                                                                          If the ReaderSeekerCloser is not an io.Seeker nothing will be done.

                                                                          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  SettableBool
                                                                          	RetryDelay time.Duration
                                                                          	// contains filtered or unexported fields
                                                                          }

                                                                            A Request is the service request to be made.

                                                                            func NewRequest

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

                                                                              NewRequest returns a new Request pointer for the service API operation and parameters.

                                                                              Params is any value of input parameters to be the request payload. Data is pointer value to an object which the request's response payload will be deserialized to.

                                                                              func (*Request) Build

                                                                              func (r *Request) Build() error

                                                                                Build will build the request's object so it can be signed and sent to the service. Build will also validate all the request's parameters. Anny additional build Handlers set on this request will be run in the order they were set.

                                                                                The request will only be built once. Multiple calls to build will have no effect.

                                                                                If any Validate or Build errors occur the build will stop and the error which occurred will be returned.

                                                                                func (*Request) DataFilled

                                                                                func (r *Request) DataFilled() bool

                                                                                  DataFilled returns true if the request's data for response deserialization target has been set and is a valid. False is returned if data is not set, or is invalid.

                                                                                  func (*Request) EachPage

                                                                                  func (r *Request) EachPage(fn func(data interface{}, isLastPage bool) (shouldContinue bool)) error

                                                                                    EachPage iterates over each page of a paginated request object. The fn parameter should be a function with the following sample signature:

                                                                                    func(page *T, lastPage bool) bool {
                                                                                        return true // return false to stop iterating
                                                                                    }
                                                                                    

                                                                                    Where "T" is the structure type matching the output structure of the given operation. For example, a request object generated by DynamoDB.ListTablesRequest() would expect to see dynamodb.ListTablesOutput as the structure "T". The lastPage value represents whether the page is the last page of data or not. The return value of this function should return true to keep iterating or false to stop.

                                                                                    func (*Request) HasNextPage

                                                                                    func (r *Request) HasNextPage() bool

                                                                                      HasNextPage returns true if this request has more pages of data available.

                                                                                      func (*Request) NextPage

                                                                                      func (r *Request) NextPage() *Request

                                                                                        NextPage returns a new Request that can be executed to return the next page of result data. Call .Send() on this request to execute it.

                                                                                        func (*Request) ParamsFilled

                                                                                        func (r *Request) ParamsFilled() bool

                                                                                          ParamsFilled returns if the request's parameters have been populated and the parameters are valid. False is returned if no parameters are provided or invalid.

                                                                                          func (*Request) Presign

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

                                                                                            Presign returns the request's signed URL. Error will be returned if the signing fails.

                                                                                            func (*Request) Send

                                                                                            func (r *Request) Send() error

                                                                                              Send will send the request returning error if errors are encountered.

                                                                                              Send will sign the request prior to sending. All Send Handlers will be executed in the order they were set.

                                                                                              func (*Request) SetBufferBody

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

                                                                                                SetBufferBody will set the request's body bytes that will be sent to the service API.

                                                                                                func (*Request) SetReaderBody

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

                                                                                                  SetReaderBody will set the request's body reader.

                                                                                                  func (*Request) SetStringBody

                                                                                                  func (r *Request) SetStringBody(s string)

                                                                                                    SetStringBody sets the body of the request to be backed by a string.

                                                                                                    func (*Request) Sign

                                                                                                    func (r *Request) Sign() error

                                                                                                      Sign will sign the request retuning error if errors are encountered.

                                                                                                      Send will build the request prior to signing. All Sign Handlers will be executed in the order they were set.

                                                                                                      func (*Request) WillRetry

                                                                                                      func (r *Request) WillRetry() bool

                                                                                                        WillRetry returns if the request's can be retried.

                                                                                                        type Service

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

                                                                                                          A Service implements the base service request and response handling used by all services.

                                                                                                          func NewService

                                                                                                          func NewService(config *Config) *Service

                                                                                                            NewService will return a pointer to a new Server object initialized.

                                                                                                            func (*Service) AddDebugHandlers

                                                                                                            func (s *Service) AddDebugHandlers()

                                                                                                              AddDebugHandlers injects debug logging handlers into the service to log request debug information.

                                                                                                              func (*Service) Initialize

                                                                                                              func (s *Service) Initialize()

                                                                                                                Initialize initializes the service.

                                                                                                                func (*Service) MaxRetries

                                                                                                                func (s *Service) MaxRetries() uint

                                                                                                                  MaxRetries returns the number of maximum returns the service will use to make an individual API request.

                                                                                                                  type SettableBool

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

                                                                                                                    A SettableBool provides a boolean value which includes the state if the value was set or unset. The set state is in addition to the value's value(true|false)

                                                                                                                    func SetBool

                                                                                                                    func SetBool(value bool) SettableBool

                                                                                                                      SetBool returns a SettableBool with a value set

                                                                                                                      func (*SettableBool) Get

                                                                                                                      func (b *SettableBool) Get() bool

                                                                                                                        Get returns the value. Will always be false if the SettableBool was not set.

                                                                                                                        func (*SettableBool) GoString

                                                                                                                        func (b *SettableBool) GoString() string

                                                                                                                          GoString returns the string representation of the SettableBool value and state

                                                                                                                          func (*SettableBool) IsSet

                                                                                                                          func (b *SettableBool) IsSet() bool

                                                                                                                            IsSet returns if the value has been set

                                                                                                                            func (*SettableBool) Reset

                                                                                                                            func (b *SettableBool) Reset()

                                                                                                                              Reset resets the state and value of the SettableBool to its initial default state of not set and zero value.

                                                                                                                              func (*SettableBool) Set

                                                                                                                              func (b *SettableBool) Set(value bool)

                                                                                                                                Set sets the value and updates the state that the value has been set.

                                                                                                                                func (*SettableBool) String

                                                                                                                                func (b *SettableBool) String() string

                                                                                                                                  String returns the string representation of the value if set. Zero if not set.

                                                                                                                                  Directories

                                                                                                                                  Path Synopsis
                                                                                                                                  Package awserr represents API error interface accessors for the SDK.
                                                                                                                                  Package awserr represents API error interface accessors for the SDK.
                                                                                                                                  Package credentials provides credential retrieval and management The Credentials is the primary method of getting access to and managing credentials Values.
                                                                                                                                  Package credentials provides credential retrieval and management The Credentials is the primary method of getting access to and managing credentials Values.