...
AWS SDK for Go API Reference
We announced the upcoming end-of-support for AWS SDK for Go (v1). We recommend that you migrate to AWS SDK for Go v2. For dates, additional details, and information on how to migrate, please refer to the linked announcement.
import "github.com/aws/aws-sdk-go/aws/request"
Overview
Index

Overview ▾

Index ▾

Constants
Variables
func AddToUserAgent(r *Request, s string)
func HandlerListLogItem(item HandlerListRunItem) bool
func HandlerListStopOnError(item HandlerListRunItem) bool
func IsErrorExpiredCreds(err error) bool
func IsErrorRetryable(err error) bool
func IsErrorThrottle(err error) bool
func MakeAddToUserAgentFreeFormHandler(s string) func(*Request)
func MakeAddToUserAgentHandler(name, version string, extra ...string) func(*Request)
func SanitizeHostForHeader(r *http.Request)
func WithRetryer(cfg *aws.Config, retryer Retryer) *aws.Config
type ErrInvalidParam
type ErrInvalidParams
    func (e *ErrInvalidParams) Add(err ErrInvalidParam)
    func (e *ErrInvalidParams) AddNested(nestedCtx string, nested ErrInvalidParams)
    func (e ErrInvalidParams) Code() string
    func (e ErrInvalidParams) Error() string
    func (e ErrInvalidParams) Len() int
    func (e ErrInvalidParams) Message() string
    func (e ErrInvalidParams) OrigErr() error
    func (e ErrInvalidParams) OrigErrs() []error
type ErrParamFormat
    func NewErrParamFormat(field string, format, value string) *ErrParamFormat
    func (e *ErrParamFormat) AddNestedContext(ctx string)
    func (e *ErrParamFormat) Code() string
    func (e *ErrParamFormat) Error() string
    func (e *ErrParamFormat) Field() string
    func (e *ErrParamFormat) Format() string
    func (e *ErrParamFormat) Message() string
    func (e *ErrParamFormat) OrigErr() error
    func (e *ErrParamFormat) SetContext(ctx string)
type ErrParamMaxLen
    func NewErrParamMaxLen(field string, max int, value string) *ErrParamMaxLen
    func (e *ErrParamMaxLen) AddNestedContext(ctx string)
    func (e *ErrParamMaxLen) Code() string
    func (e *ErrParamMaxLen) Error() string
    func (e *ErrParamMaxLen) Field() string
    func (e *ErrParamMaxLen) MaxLen() int
    func (e *ErrParamMaxLen) Message() string
    func (e *ErrParamMaxLen) OrigErr() error
    func (e *ErrParamMaxLen) SetContext(ctx string)
type ErrParamMinLen
    func NewErrParamMinLen(field string, min int) *ErrParamMinLen
    func (e *ErrParamMinLen) AddNestedContext(ctx string)
    func (e *ErrParamMinLen) Code() string
    func (e *ErrParamMinLen) Error() string
    func (e *ErrParamMinLen) Field() string
    func (e *ErrParamMinLen) Message() string
    func (e *ErrParamMinLen) MinLen() int
    func (e *ErrParamMinLen) OrigErr() error
    func (e *ErrParamMinLen) SetContext(ctx string)
type ErrParamMinValue
    func NewErrParamMinValue(field string, min float64) *ErrParamMinValue
    func (e *ErrParamMinValue) AddNestedContext(ctx string)
    func (e *ErrParamMinValue) Code() string
    func (e *ErrParamMinValue) Error() string
    func (e *ErrParamMinValue) Field() string
    func (e *ErrParamMinValue) Message() string
    func (e *ErrParamMinValue) MinValue() float64
    func (e *ErrParamMinValue) OrigErr() error
    func (e *ErrParamMinValue) SetContext(ctx string)
type ErrParamRequired
    func NewErrParamRequired(field string) *ErrParamRequired
    func (e *ErrParamRequired) AddNestedContext(ctx string)
    func (e *ErrParamRequired) Code() string
    func (e *ErrParamRequired) Error() string
    func (e *ErrParamRequired) Field() string
    func (e *ErrParamRequired) Message() string
    func (e *ErrParamRequired) OrigErr() error
    func (e *ErrParamRequired) SetContext(ctx string)
type HandlerList
    func (l *HandlerList) Clear()
    func (l *HandlerList) Len() int
    func (l *HandlerList) PushBack(f func(*Request))
    func (l *HandlerList) PushBackNamed(n NamedHandler)
    func (l *HandlerList) PushFront(f func(*Request))
    func (l *HandlerList) PushFrontNamed(n NamedHandler)
    func (l *HandlerList) Remove(n NamedHandler)
    func (l *HandlerList) RemoveByName(name string)
    func (l *HandlerList) Run(r *Request)
    func (l *HandlerList) SetBackNamed(n NamedHandler)
    func (l *HandlerList) SetFrontNamed(n NamedHandler)
    func (l *HandlerList) Swap(name string, replace NamedHandler) bool
    func (l *HandlerList) SwapNamed(n NamedHandler) (swapped bool)
type HandlerListRunItem
type Handlers
    func (h *Handlers) Clear()
    func (h *Handlers) Copy() Handlers
    func (h *Handlers) IsEmpty() bool
type NamedHandler
type Operation
type Option
    func WithAppendUserAgent(s string) Option
    func WithGetResponseHeader(key string, val *string) Option
    func WithGetResponseHeaders(headers *http.Header) Option
    func WithLogLevel(l aws.LogLevelType) Option
    func WithResponseReadTimeout(duration time.Duration) Option
    func WithSetRequestHeaders(h map[string]string) Option
type Pagination
    func (p *Pagination) Err() error
    func (p *Pagination) HasNextPage() bool
    func (p *Pagination) Next() bool
    func (p *Pagination) Page() interface{}
type Paginator
type Request
    func New(cfg aws.Config, clientInfo metadata.ClientInfo, handlers Handlers, retryer Retryer, operation *Operation, params interface{}, data interface{}) *Request
    func (r *Request) ApplyOptions(opts ...Option)
    func (r *Request) Build() error
    func (r *Request) Context() aws.Context
    func (r *Request) DataFilled() bool
    func (r *Request) EachPage(fn func(data interface{}, isLastPage bool) (shouldContinue bool)) error
    func (r *Request) GetBody() io.ReadSeeker
    func (r *Request) HasNextPage() bool
    func (r *Request) IsErrorExpired() bool
    func (r *Request) IsErrorRetryable() bool
    func (r *Request) IsErrorThrottle() bool
    func (r *Request) IsPresigned() bool
    func (r *Request) NextPage() *Request
    func (r *Request) ParamsFilled() bool
    func (r *Request) Presign(expire time.Duration) (string, error)
    func (r *Request) PresignRequest(expire time.Duration) (string, http.Header, error)
    func (r *Request) ResetBody()
    func (r *Request) Send() error
    func (r *Request) SetBufferBody(buf []byte)
    func (r *Request) SetContext(ctx aws.Context)
    func (r *Request) SetReaderBody(reader io.ReadSeeker)
    func (r *Request) SetStreamingBody(reader io.ReadCloser)
    func (r *Request) SetStringBody(s string)
    func (r *Request) Sign() error
    func (r *Request) WillRetry() bool
type Retryer
type Validator
type Waiter
    func (w *Waiter) ApplyOptions(opts ...WaiterOption)
    func (w Waiter) WaitWithContext(ctx aws.Context) error
type WaiterAcceptor
type WaiterDelay
    func ConstantWaiterDelay(delay time.Duration) WaiterDelay
type WaiterMatchMode
    func (m WaiterMatchMode) String() string
type WaiterOption
    func WithWaiterDelay(delayer WaiterDelay) WaiterOption
    func WithWaiterLogger(logger aws.Logger) WaiterOption
    func WithWaiterMaxAttempts(max int) WaiterOption
    func WithWaiterRequestOptions(opts ...Option) WaiterOption
type WaiterState
    func (s WaiterState) String() string

Package files

connection_reset_error.go handlers.go http_request.go offset_reader.go request.go request_1_8.go request_context.go request_pagination.go retryer.go timeout_read_closer.go validation.go waiter.go

Constants

const (
    // ErrCodeSerialization is the serialization error code that is received
    // during protocol unmarshaling.
    ErrCodeSerialization = "SerializationError"

    // ErrCodeRead is an error that is returned during HTTP reads.
    ErrCodeRead = "ReadError"

    // ErrCodeResponseTimeout is the connection timeout error that is received
    // during body reads.
    ErrCodeResponseTimeout = "ResponseTimeout"

    // ErrCodeInvalidPresignExpire is returned when the expire time provided to
    // presign is invalid
    ErrCodeInvalidPresignExpire = "InvalidPresignExpireError"

    // CanceledErrorCode is the error code that will be returned by an
    // API request that was canceled. Requests given a aws.Context may
    // return this error when canceled.
    CanceledErrorCode = "RequestCanceled"

    // ErrCodeRequestError is an error preventing the SDK from continuing to
    // process the request.
    ErrCodeRequestError = "RequestError"
)
const (
    // InvalidParameterErrCode is the error code for invalid parameters errors
    InvalidParameterErrCode = "InvalidParameter"
    // ParamRequiredErrCode is the error code for required parameter errors
    ParamRequiredErrCode = "ParamRequiredError"
    // ParamMinValueErrCode is the error code for fields with too low of a
    // number value.
    ParamMinValueErrCode = "ParamMinValueError"
    // ParamMinLenErrCode is the error code for fields without enough elements.
    ParamMinLenErrCode = "ParamMinLenError"
    // ParamMaxLenErrCode is the error code for value being too long.
    ParamMaxLenErrCode = "ParamMaxLenError"

    // ParamFormatErrCode is the error code for a field with invalid
    // format or characters.
    ParamFormatErrCode = "ParamFormatInvalidError"
)
const (
    // HandlerResponseTimeout is what we use to signify the name of the
    // response timeout handler.
    HandlerResponseTimeout = "ResponseTimeoutHandler"
)
const WaiterResourceNotReadyErrorCode = "ResourceNotReady"

WaiterResourceNotReadyErrorCode is the error code returned by a waiter when the waiter's max attempts have been exhausted.

Variables

var NoBody = http.NoBody

NoBody is a http.NoBody reader instructing Go HTTP client to not include and body in the HTTP request.

func AddToUserAgent

func AddToUserAgent(r *Request, s string)

AddToUserAgent adds the string to the end of the request's current user agent.

func HandlerListLogItem

func HandlerListLogItem(item HandlerListRunItem) bool

HandlerListLogItem logs the request handler and the state of the request's Error value. Always returns true to continue iterating request handlers in a HandlerList.

func HandlerListStopOnError

func HandlerListStopOnError(item HandlerListRunItem) bool

HandlerListStopOnError returns false to stop the HandlerList iterating over request handlers if Request.Error is not nil. True otherwise to continue iterating.

func IsErrorExpiredCreds

func IsErrorExpiredCreds(err error) bool

IsErrorExpiredCreds returns whether the error code is a credential expiry error. Returns false if error is nil.

func IsErrorRetryable

func IsErrorRetryable(err error) bool

IsErrorRetryable returns whether the error is retryable, based on its Code. Returns false if error is nil.

func IsErrorThrottle

func IsErrorThrottle(err error) bool

IsErrorThrottle returns whether the error is to be throttled based on its code. Returns false if error is nil.

func MakeAddToUserAgentFreeFormHandler

func MakeAddToUserAgentFreeFormHandler(s string) func(*Request)

MakeAddToUserAgentFreeFormHandler adds the input to the User-Agent request header. The input string will be concatenated with the current request's user agent string.

func MakeAddToUserAgentHandler

func MakeAddToUserAgentHandler(name, version string, extra ...string) func(*Request)

MakeAddToUserAgentHandler will add the name/version pair to the User-Agent request header. If the extra parameters are provided they will be added as metadata to the name/version pair resulting in the following format. "name/version (extra0; extra1; ...)" The user agent part will be concatenated with this current request's user agent string.

func SanitizeHostForHeader

func SanitizeHostForHeader(r *http.Request)

SanitizeHostForHeader removes default port from host and updates request.Host

func WithRetryer

func WithRetryer(cfg *aws.Config, retryer Retryer) *aws.Config

WithRetryer sets a Retryer value to the given Config returning the Config value for chaining. The value must not be nil.

type ErrInvalidParam

type ErrInvalidParam interface {
    awserr.Error

    // Field name the error occurred on.
    Field() string

    // SetContext updates the context of the error.
    SetContext(string)

    // AddNestedContext updates the error's context to include a nested level.
    AddNestedContext(string)
}

An ErrInvalidParam represents an invalid parameter error type.

type ErrInvalidParams

type ErrInvalidParams struct {
    // Context is the base context of the invalid parameter group.
    Context string
    // contains filtered or unexported fields
}

An ErrInvalidParams provides wrapping of invalid parameter errors found when validating API operation input parameters.

func (*ErrInvalidParams) Add

func (e *ErrInvalidParams) Add(err ErrInvalidParam)

Add adds a new invalid parameter error to the collection of invalid parameters. The context of the invalid parameter will be updated to reflect this collection.

func (*ErrInvalidParams) AddNested

func (e *ErrInvalidParams) AddNested(nestedCtx string, nested ErrInvalidParams)

AddNested adds the invalid parameter errors from another ErrInvalidParams value into this collection. The nested errors will have their nested context updated and base context to reflect the merging.

Use for nested validations errors.

func (ErrInvalidParams) Code

func (e ErrInvalidParams) Code() string

Code returns the code of the error

func (ErrInvalidParams) Error

func (e ErrInvalidParams) Error() string

Error returns the string formatted form of the invalid parameters.

func (ErrInvalidParams) Len

func (e ErrInvalidParams) Len() int

Len returns the number of invalid parameter errors

func (ErrInvalidParams) Message

func (e ErrInvalidParams) Message() string

Message returns the message of the error

func (ErrInvalidParams) OrigErr

func (e ErrInvalidParams) OrigErr() error

OrigErr returns the invalid parameters as a awserr.BatchedErrors value

func (ErrInvalidParams) OrigErrs

func (e ErrInvalidParams) OrigErrs() []error

OrigErrs returns a slice of the invalid parameters

type ErrParamFormat

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

An ErrParamFormat represents a invalid format parameter error.

func NewErrParamFormat

func NewErrParamFormat(field string, format, value string) *ErrParamFormat

NewErrParamFormat creates a new invalid format parameter error.

func (*ErrParamFormat) AddNestedContext

func (e *ErrParamFormat) AddNestedContext(ctx string)

AddNestedContext prepends a context to the field's path.

func (*ErrParamFormat) Code

func (e *ErrParamFormat) Code() string

Code returns the error code for the type of invalid parameter.

func (*ErrParamFormat) Error

func (e *ErrParamFormat) Error() string

Error returns the string version of the invalid parameter error.

func (*ErrParamFormat) Field

func (e *ErrParamFormat) Field() string

Field Returns the field and context the error occurred.

func (*ErrParamFormat) Format

func (e *ErrParamFormat) Format() string

Format returns the field's required format.

func (*ErrParamFormat) Message

func (e *ErrParamFormat) Message() string

Message returns the reason the parameter was invalid, and its context.

func (*ErrParamFormat) OrigErr

func (e *ErrParamFormat) OrigErr() error

OrigErr returns nil, Implemented for awserr.Error interface.

func (*ErrParamFormat) SetContext

func (e *ErrParamFormat) SetContext(ctx string)

SetContext updates the base context of the error.

type ErrParamMaxLen

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

An ErrParamMaxLen represents a maximum length parameter error.

func NewErrParamMaxLen

func NewErrParamMaxLen(field string, max int, value string) *ErrParamMaxLen

NewErrParamMaxLen creates a new maximum length parameter error.

func (*ErrParamMaxLen) AddNestedContext

func (e *ErrParamMaxLen) AddNestedContext(ctx string)

AddNestedContext prepends a context to the field's path.

func (*ErrParamMaxLen) Code

func (e *ErrParamMaxLen) Code() string

Code returns the error code for the type of invalid parameter.

func (*ErrParamMaxLen) Error

func (e *ErrParamMaxLen) Error() string

Error returns the string version of the invalid parameter error.

func (*ErrParamMaxLen) Field

func (e *ErrParamMaxLen) Field() string

Field Returns the field and context the error occurred.

func (*ErrParamMaxLen) MaxLen

func (e *ErrParamMaxLen) MaxLen() int

MaxLen returns the field's required minimum length.

func (*ErrParamMaxLen) Message

func (e *ErrParamMaxLen) Message() string

Message returns the reason the parameter was invalid, and its context.

func (*ErrParamMaxLen) OrigErr

func (e *ErrParamMaxLen) OrigErr() error

OrigErr returns nil, Implemented for awserr.Error interface.

func (*ErrParamMaxLen) SetContext

func (e *ErrParamMaxLen) SetContext(ctx string)

SetContext updates the base context of the error.

type ErrParamMinLen

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

An ErrParamMinLen represents a minimum length parameter error.

func NewErrParamMinLen

func NewErrParamMinLen(field string, min int) *ErrParamMinLen

NewErrParamMinLen creates a new minimum length parameter error.

func (*ErrParamMinLen) AddNestedContext

func (e *ErrParamMinLen) AddNestedContext(ctx string)

AddNestedContext prepends a context to the field's path.

func (*ErrParamMinLen) Code

func (e *ErrParamMinLen) Code() string

Code returns the error code for the type of invalid parameter.

func (*ErrParamMinLen) Error

func (e *ErrParamMinLen) Error() string

Error returns the string version of the invalid parameter error.

func (*ErrParamMinLen) Field

func (e *ErrParamMinLen) Field() string

Field Returns the field and context the error occurred.

func (*ErrParamMinLen) Message

func (e *ErrParamMinLen) Message() string

Message returns the reason the parameter was invalid, and its context.

func (*ErrParamMinLen) MinLen

func (e *ErrParamMinLen) MinLen() int

MinLen returns the field's required minimum length.

func (*ErrParamMinLen) OrigErr

func (e *ErrParamMinLen) OrigErr() error

OrigErr returns nil, Implemented for awserr.Error interface.

func (*ErrParamMinLen) SetContext

func (e *ErrParamMinLen) SetContext(ctx string)

SetContext updates the base context of the error.

type ErrParamMinValue

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

An ErrParamMinValue represents a minimum value parameter error.

func NewErrParamMinValue

func NewErrParamMinValue(field string, min float64) *ErrParamMinValue

NewErrParamMinValue creates a new minimum value parameter error.

func (*ErrParamMinValue) AddNestedContext

func (e *ErrParamMinValue) AddNestedContext(ctx string)

AddNestedContext prepends a context to the field's path.

func (*ErrParamMinValue) Code

func (e *ErrParamMinValue) Code() string

Code returns the error code for the type of invalid parameter.

func (*ErrParamMinValue) Error

func (e *ErrParamMinValue) Error() string

Error returns the string version of the invalid parameter error.

func (*ErrParamMinValue) Field

func (e *ErrParamMinValue) Field() string

Field Returns the field and context the error occurred.

func (*ErrParamMinValue) Message

func (e *ErrParamMinValue) Message() string

Message returns the reason the parameter was invalid, and its context.

func (*ErrParamMinValue) MinValue

func (e *ErrParamMinValue) MinValue() float64

MinValue returns the field's require minimum value.

float64 is returned for both int and float min values.

func (*ErrParamMinValue) OrigErr

func (e *ErrParamMinValue) OrigErr() error

OrigErr returns nil, Implemented for awserr.Error interface.

func (*ErrParamMinValue) SetContext

func (e *ErrParamMinValue) SetContext(ctx string)

SetContext updates the base context of the error.

type ErrParamRequired

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

An ErrParamRequired represents an required parameter error.

func NewErrParamRequired

func NewErrParamRequired(field string) *ErrParamRequired

NewErrParamRequired creates a new required parameter error.

func (*ErrParamRequired) AddNestedContext

func (e *ErrParamRequired) AddNestedContext(ctx string)

AddNestedContext prepends a context to the field's path.

func (*ErrParamRequired) Code

func (e *ErrParamRequired) Code() string

Code returns the error code for the type of invalid parameter.

func (*ErrParamRequired) Error

func (e *ErrParamRequired) Error() string

Error returns the string version of the invalid parameter error.

func (*ErrParamRequired) Field

func (e *ErrParamRequired) Field() string

Field Returns the field and context the error occurred.

func (*ErrParamRequired) Message

func (e *ErrParamRequired) Message() string

Message returns the reason the parameter was invalid, and its context.

func (*ErrParamRequired) OrigErr

func (e *ErrParamRequired) OrigErr() error

OrigErr returns nil, Implemented for awserr.Error interface.

func (*ErrParamRequired) SetContext

func (e *ErrParamRequired) SetContext(ctx string)

SetContext updates the base context of the error.

type HandlerList

type HandlerList struct {

    // Called after each request handler in the list is called. If set
    // and the func returns true the HandlerList will continue to iterate
    // over the request handlers. If false is returned the HandlerList
    // will stop iterating.
    //
    // Should be used if extra logic to be performed between each handler
    // in the list. This can be used to terminate a list's iteration
    // based on a condition such as error like, HandlerListStopOnError.
    // Or for logging like HandlerListLogItem.
    AfterEachFn func(item HandlerListRunItem) bool
    // 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 handler f to the back of the handler list.

func (*HandlerList) PushBackNamed

func (l *HandlerList) PushBackNamed(n NamedHandler)

PushBackNamed pushes named handler f to the back of the handler list.

func (*HandlerList) PushFront

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

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

func (*HandlerList) PushFrontNamed

func (l *HandlerList) PushFrontNamed(n NamedHandler)

PushFrontNamed pushes named handler f to the front of the handler list.

func (*HandlerList) Remove

func (l *HandlerList) Remove(n NamedHandler)

Remove removes a NamedHandler n

func (*HandlerList) RemoveByName

func (l *HandlerList) RemoveByName(name string)

RemoveByName removes a NamedHandler by name.

func (*HandlerList) Run

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

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

func (*HandlerList) SetBackNamed

func (l *HandlerList) SetBackNamed(n NamedHandler)

SetBackNamed will replace the named handler if it exists in the handler list. If the handler does not exist the handler will be added to the end of the list.

func (*HandlerList) SetFrontNamed

func (l *HandlerList) SetFrontNamed(n NamedHandler)

SetFrontNamed will replace the named handler if it exists in the handler list. If the handler does not exist the handler will be added to the beginning of the list.

func (*HandlerList) Swap

func (l *HandlerList) Swap(name string, replace NamedHandler) bool

Swap will swap out all handlers matching the name passed in. The matched handlers will be swapped in. True is returned if the handlers were swapped.

func (*HandlerList) SwapNamed

func (l *HandlerList) SwapNamed(n NamedHandler) (swapped bool)

SwapNamed will swap out any existing handlers with the same name as the passed in NamedHandler returning true if handlers were swapped. False is returned otherwise.

type HandlerListRunItem

type HandlerListRunItem struct {
    Index   int
    Handler NamedHandler
    Request *Request
}

A HandlerListRunItem represents an entry in the HandlerList which is being run.

type Handlers

type Handlers struct {
    Validate         HandlerList
    Build            HandlerList
    BuildStream      HandlerList
    Sign             HandlerList
    Send             HandlerList
    ValidateResponse HandlerList
    Unmarshal        HandlerList
    UnmarshalStream  HandlerList
    UnmarshalMeta    HandlerList
    UnmarshalError   HandlerList
    Retry            HandlerList
    AfterRetry       HandlerList
    CompleteAttempt  HandlerList
    Complete         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.

func (*Handlers) Copy

func (h *Handlers) Copy() Handlers

Copy returns a copy of this handler's lists.

func (*Handlers) IsEmpty

func (h *Handlers) IsEmpty() bool

IsEmpty returns if there are no handlers in any of the handlerlists.

type NamedHandler

type NamedHandler struct {
    Name string
    Fn   func(*Request)
}

A NamedHandler is a struct that contains a name and function callback.

type Operation

type Operation struct {
    Name       string
    HTTPMethod string
    HTTPPath   string
    *Paginator

    BeforePresignFn func(r *Request) error
}

An Operation is the service API operation to be made.

type Option

type Option func(*Request)

A Option is a functional option that can augment or modify a request when using a WithContext API operation method.

func WithAppendUserAgent

func WithAppendUserAgent(s string) Option

WithAppendUserAgent will add a string to the user agent prefixed with a single white space.

func WithGetResponseHeader

func WithGetResponseHeader(key string, val *string) Option

WithGetResponseHeader builds a request Option which will retrieve a single header value from the HTTP Response. If there are multiple values for the header key use WithGetResponseHeaders instead to access the http.Header map directly. The passed in val pointer must be non-nil.

This Option can be used multiple times with a single API operation.

var id2, versionID string
svc.PutObjectWithContext(ctx, params,
    request.WithGetResponseHeader("x-amz-id-2", &id2),
    request.WithGetResponseHeader("x-amz-version-id", &versionID),
)

func WithGetResponseHeaders

func WithGetResponseHeaders(headers *http.Header) Option

WithGetResponseHeaders builds a request Option which will retrieve the headers from the HTTP response and assign them to the passed in headers variable. The passed in headers pointer must be non-nil.

var headers http.Header
svc.PutObjectWithContext(ctx, params, request.WithGetResponseHeaders(&headers))

func WithLogLevel

func WithLogLevel(l aws.LogLevelType) Option

WithLogLevel is a request option that will set the request to use a specific log level when the request is made.

svc.PutObjectWithContext(ctx, params, request.WithLogLevel(aws.LogDebugWithHTTPBody)

func WithResponseReadTimeout

func WithResponseReadTimeout(duration time.Duration) Option

WithResponseReadTimeout is a request option that will wrap the body in a timeout read closer. This will allow for per read timeouts. If a timeout occurred, we will return the ErrCodeResponseTimeout.

svc.PutObjectWithContext(ctx, params, request.WithTimeoutReadCloser(30 * time.Second)

func WithSetRequestHeaders

func WithSetRequestHeaders(h map[string]string) Option

WithSetRequestHeaders updates the operation request's HTTP header to contain the header key value pairs provided. If the header key already exists in the request's HTTP header set, the existing value(s) will be replaced.

Header keys added will be added as canonical format with title casing applied via http.Header.Set method.

type Pagination

type Pagination struct {
    // Function to return a Request value for each pagination request.
    // Any configuration or handlers that need to be applied to the request
    // prior to getting the next page should be done here before the request
    // returned.
    //
    // NewRequest should always be built from the same API operations. It is
    // undefined if different API operations are returned on subsequent calls.
    NewRequest func() (*Request, error)
    // EndPageOnSameToken, when enabled, will allow the paginator to stop on
    // token that are the same as its previous tokens.
    EndPageOnSameToken bool
    // contains filtered or unexported fields
}

A Pagination provides paginating of SDK API operations which are paginatable. Generally you should not use this type directly, but use the "Pages" API operations method to automatically perform pagination for you. Such as, "S3.ListObjectsPages", and "S3.ListObjectsPagesWithContext" methods.

Pagination differs from a Paginator type in that pagination is the type that does the pagination between API operations, and Paginator defines the configuration that will be used per page request.

for p.Next() {
    data := p.Page().(*s3.ListObjectsOutput)
    // process the page's data
    // ...
    // break out of loop to stop fetching additional pages
}

return p.Err()

See service client API operation Pages methods for examples how the SDK will use the Pagination type.

func (*Pagination) Err

func (p *Pagination) Err() error

Err returns the error Pagination encountered when retrieving the next page.

func (*Pagination) HasNextPage

func (p *Pagination) HasNextPage() bool

HasNextPage will return true if Pagination is able to determine that the API operation has additional pages. False will be returned if there are no more pages remaining.

Will always return true if Next has not been called yet.

func (*Pagination) Next

func (p *Pagination) Next() bool

Next will attempt to retrieve the next page for the API operation. When a page is retrieved true will be returned. If the page cannot be retrieved, or there are no more pages false will be returned.

Use the Page method to retrieve the current page data. The data will need to be cast to the API operation's output type.

Use the Err method to determine if an error occurred if Page returns false.

func (*Pagination) Page

func (p *Pagination) Page() interface{}

Page returns the current page. Page should only be called after a successful call to Next. It is undefined what Page will return if Page is called after Next returns false.

type Paginator

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

A Paginator is the configuration data that defines how an API operation should be paginated. This type is used by the API service models to define the generated pagination config for service APIs.

The Pagination type is what provides iterating between pages of an API. It is only used to store the token metadata the SDK should use for performing pagination.

type Request

type Request struct {
    Config     aws.Config
    ClientInfo metadata.ClientInfo
    Handlers   Handlers

    Retryer
    AttemptTime  time.Time
    Time         time.Time
    Operation    *Operation
    HTTPRequest  *http.Request
    HTTPResponse *http.Response
    Body         io.ReadSeeker

    BodyStart              int64 // offset from beginning of Body that the request body starts
    Params                 interface{}
    Error                  error
    Data                   interface{}
    RequestID              string
    RetryCount             int
    Retryable              *bool
    RetryDelay             time.Duration
    NotHoist               bool
    SignedHeaderVals       http.Header
    LastSignedAt           time.Time
    DisableFollowRedirects bool

    // Additional API error codes that should be retried. IsErrorRetryable
    // will consider these codes in addition to its built in cases.
    RetryErrorCodes []string

    // Additional API error codes that should be retried with throttle backoff
    // delay. IsErrorThrottle will consider these codes in addition to its
    // built in cases.
    ThrottleErrorCodes []string

    // A value greater than 0 instructs the request to be signed as Presigned URL
    // You should not set this field directly. Instead use Request's
    // Presign or PresignRequest methods.
    ExpireTime time.Duration
    // contains filtered or unexported fields
}

A Request is the service request to be made.

func New

func New(cfg aws.Config, clientInfo metadata.ClientInfo, handlers Handlers,
    retryer Retryer, operation *Operation, params interface{}, data interface{}) *Request

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

A Retryer should be provided to direct how the request is retried. If Retryer is nil, a default no retry value will be used. You can use NoOpRetryer in the Client package to disable retry behavior directly.

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) ApplyOptions

func (r *Request) ApplyOptions(opts ...Option)

ApplyOptions will apply each option to the request calling them in the order the were provided.

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. Any 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) Context

func (r *Request) Context() aws.Context

Context will always returns a non-nil context. If Request does not have a context aws.BackgroundContext 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.

Deprecated Use Pagination type for configurable pagination of API operations

func (*Request) GetBody

func (r *Request) GetBody() io.ReadSeeker

GetBody will return an io.ReadSeeker of the Request's underlying input body with a concurrency safe wrapper.

func (*Request) HasNextPage

func (r *Request) HasNextPage() bool

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

Deprecated Use Pagination type for configurable pagination of API operations

func (*Request) IsErrorExpired

func (r *Request) IsErrorExpired() bool

IsErrorExpired returns whether the error code is a credential expiry error. Returns false if the request has no Error set.

Alias for the utility function IsErrorExpiredCreds

func (*Request) IsErrorRetryable

func (r *Request) IsErrorRetryable() bool

IsErrorRetryable returns whether the error is retryable, based on its Code. Returns false if the request has no Error set.

Alias for the utility function IsErrorRetryable

func (*Request) IsErrorThrottle

func (r *Request) IsErrorThrottle() bool

IsErrorThrottle returns whether the error is to be throttled based on its code. Returns false if the request has no Error set.

Alias for the utility function IsErrorThrottle

func (*Request) IsPresigned

func (r *Request) IsPresigned() bool

IsPresigned returns true if the request represents a presigned API url.

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.

Deprecated Use Pagination type for configurable pagination of API operations

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(expire time.Duration) (string, error)

Presign returns the request's signed URL. Error will be returned if the signing fails. The expire parameter is only used for presigned Amazon S3 API requests. All other AWS services will use a fixed expiration time of 15 minutes.

It is invalid to create a presigned URL with a expire duration 0 or less. An error is returned if expire duration is 0 or less.

func (*Request) PresignRequest

func (r *Request) PresignRequest(expire time.Duration) (string, http.Header, error)

PresignRequest behaves just like presign, with the addition of returning a set of headers that were signed. The expire parameter is only used for presigned Amazon S3 API requests. All other AWS services will use a fixed expiration time of 15 minutes.

It is invalid to create a presigned URL with a expire duration 0 or less. An error is returned if expire duration is 0 or less.

Returns the URL string for the API operation with signature in the query string, and the HTTP headers that were included in the signature. These headers must be included in any HTTP request made with the presigned URL.

To prevent hoisting any headers to the query string set NotHoist to true on this Request value prior to calling PresignRequest.

func (*Request) ResetBody

func (r *Request) ResetBody()

ResetBody rewinds the request body back to its starting position, and sets the HTTP Request body reference. When the body is read prior to being sent in the HTTP request it will need to be rewound.

ResetBody will automatically be called by the SDK's build handler, but if the request is being used directly ResetBody must be called before the request is Sent. SetStringBody, SetBufferBody, and SetReaderBody will automatically call ResetBody.

Will also set the Go 1.8's http.Request.GetBody member to allow retrying PUT/POST redirects.

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.

Canceling a request is non-deterministic. If a request has been canceled, then the transport will choose, randomly, one of the state channels during reads or getting the connection.

readLoop() and getConn(req *Request, cm connectMethod) https://github.com/golang/go/blob/master/src/net/http/transport.go

Send will not close the request.Request's body.

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) SetContext

func (r *Request) SetContext(ctx aws.Context)

SetContext adds a Context to the current request that can be used to cancel a in-flight request. The Context value must not be nil, or this method will panic.

Unlike http.Request.WithContext, SetContext does not return a copy of the Request. It is not safe to use use a single Request value for multiple requests. A new Request should be created for each API operation request.

Go 1.6 and below: The http.Request's Cancel field will be set to the Done() value of the context. This will overwrite the Cancel field's value.

Go 1.7 and above: The http.Request.WithContext will be used to set the context on the underlying http.Request. This will create a shallow copy of the http.Request. The SDK may create sub contexts in the future for nested requests such as retries.

func (*Request) SetReaderBody

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

SetReaderBody will set the request's body reader.

func (*Request) SetStreamingBody

func (r *Request) SetStreamingBody(reader io.ReadCloser)

SetStreamingBody set the reader to be used for the request that will stream bytes to the server. Request's Body must not be set to any 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, returning error if errors are encountered.

Sign 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 Retryer

type Retryer interface {
    // RetryRules return the retry delay that should be used by the SDK before
    // making another request attempt for the failed request.
    RetryRules(*Request) time.Duration

    // ShouldRetry returns if the failed request is retryable.
    //
    // Implementations may consider request attempt count when determining if a
    // request is retryable, but the SDK will use MaxRetries to limit the
    // number of attempts a request are made.
    ShouldRetry(*Request) bool

    // MaxRetries is the number of times a request may be retried before
    // failing.
    MaxRetries() int
}

Retryer provides the interface drive the SDK's request retry behavior. The Retryer implementation is responsible for implementing exponential backoff, and determine if a request API error should be retried.

client.DefaultRetryer is the SDK's default implementation of the Retryer. It uses the Request.IsErrorRetryable and Request.IsErrorThrottle methods to determine if the request is retried.

type Validator

type Validator interface {
    Validate() error
}

Validator provides a way for types to perform validation logic on their input values that external code can use to determine if a type's values are valid.

type Waiter

type Waiter struct {
    Name      string
    Acceptors []WaiterAcceptor
    Logger    aws.Logger

    MaxAttempts int
    Delay       WaiterDelay

    RequestOptions   []Option
    NewRequest       func([]Option) (*Request, error)
    SleepWithContext func(aws.Context, time.Duration) error
}

A Waiter provides the functionality to perform a blocking call which will wait for a resource state to be satisfied by a service.

This type should not be used directly. The API operations provided in the service packages prefixed with "WaitUntil" should be used instead.

func (*Waiter) ApplyOptions

func (w *Waiter) ApplyOptions(opts ...WaiterOption)

ApplyOptions updates the waiter with the list of waiter options provided.

func (Waiter) WaitWithContext

func (w Waiter) WaitWithContext(ctx aws.Context) error

WaitWithContext will make requests for the API operation using NewRequest to build API requests. The request's response will be compared against the Waiter's Acceptors to determine the successful state of the resource the waiter is inspecting.

The passed in context must not be nil. If it is nil a panic will occur. The Context will be used to cancel the waiter's pending requests and retry delays. Use aws.BackgroundContext if no context is available.

The waiter will continue until the target state defined by the Acceptors, or the max attempts expires.

Will return the WaiterResourceNotReadyErrorCode error code if the waiter's retryer ShouldRetry returns false. This normally will happen when the max wait attempts expires.

type WaiterAcceptor

type WaiterAcceptor struct {
    State    WaiterState
    Matcher  WaiterMatchMode
    Argument string
    Expected interface{}
}

A WaiterAcceptor provides the information needed to wait for an API operation to complete.

type WaiterDelay

type WaiterDelay func(attempt int) time.Duration

WaiterDelay will return a delay the waiter should pause between attempts to check the resource state. The passed in attempt is the number of times the Waiter has checked the resource state.

Attempt is the number of attempts the Waiter has made checking the resource state.

func ConstantWaiterDelay

func ConstantWaiterDelay(delay time.Duration) WaiterDelay

ConstantWaiterDelay returns a WaiterDelay that will always return a constant delay the waiter should use between attempts. It ignores the number of attempts made.

type WaiterMatchMode

type WaiterMatchMode int

WaiterMatchMode is the mode that the waiter will use to match the WaiterAcceptor definition's Expected attribute.

const (
    PathAllWaiterMatch  WaiterMatchMode = iota // match on all paths
    PathWaiterMatch                            // match on specific path
    PathAnyWaiterMatch                         // match on any path
    PathListWaiterMatch                        // match on list of paths
    StatusWaiterMatch                          // match on status code
    ErrorWaiterMatch                           // match on error
)

Modes the waiter will use when inspecting API response to identify target resource states.

func (WaiterMatchMode) String

func (m WaiterMatchMode) String() string

String returns the string representation of the waiter match mode.

type WaiterOption

type WaiterOption func(*Waiter)

A WaiterOption is a function that will update the Waiter value's fields to configure the waiter.

func WithWaiterDelay

func WithWaiterDelay(delayer WaiterDelay) WaiterOption

WithWaiterDelay will set the Waiter to use the WaiterDelay passed in.

func WithWaiterLogger

func WithWaiterLogger(logger aws.Logger) WaiterOption

WithWaiterLogger returns a waiter option to set the logger a waiter should use to log warnings and errors to.

func WithWaiterMaxAttempts

func WithWaiterMaxAttempts(max int) WaiterOption

WithWaiterMaxAttempts returns the maximum number of times the waiter should attempt to check the resource for the target state.

func WithWaiterRequestOptions

func WithWaiterRequestOptions(opts ...Option) WaiterOption

WithWaiterRequestOptions returns a waiter option setting the request options for each request the waiter makes. Appends to waiter's request options already set.

type WaiterState

type WaiterState int

WaiterState are states the waiter uses based on WaiterAcceptor definitions to identify if the resource state the waiter is waiting on has occurred.

const (
    SuccessWaiterState WaiterState = iota // waiter successful
    FailureWaiterState                    // waiter failed
    RetryWaiterState                      // waiter needs to be retried
)

States the waiter acceptors will use to identify target resource states.

func (WaiterState) String

func (s WaiterState) String() string

String returns the string representation of the waiter state.