Documentation
¶
Overview ¶
Package aws provides the core SDK's utilities and shared types. Use this package's utilities to simplify setting and reading API operations parameters.
Value and Pointer Conversion Utilities ¶
This package includes a helper conversion utility for each scalar type the SDK's API use. These utilities make getting a pointer of the scalar, and dereferencing a pointer easier.
Each conversion utility comes in two forms. Value to Pointer and Pointer to Value. The Pointer to value will safely dereference the pointer and return its value. If the pointer was nil, the scalar's zero value will be returned.
The value to pointer functions will be named after the scalar type. So get a *string from a string value use the "String" function. This makes it easy to to get pointer of a literal string value, because getting the address of a literal requires assigning the value to a variable first.
var strPtr *string // Without the SDK's conversion functions str := "my string" strPtr = &str // With the SDK's conversion functions strPtr = aws.String("my string") // Convert *string to string value str = aws.StringValue(strPtr)
In addition to scalars the aws package also includes conversion utilities for map and slice for commonly types used in API parameters. The map and slice conversion functions use similar naming pattern as the scalar conversion functions.
var strPtrs []*string var strs []string = []string{"Go", "Gophers", "Go"} // Convert []string to []*string strPtrs = aws.StringSlice(strs) // Convert []*string to []string strs = aws.StringValueSlice(strPtrs)
SDK Default HTTP Client ¶
The SDK will use the http.DefaultClient if a HTTP client is not provided to the SDK's Session, or service client constructor. This means that if the http.DefaultClient is modified by other components of your application the modifications will be picked up by the SDK as well.
In some cases this might be intended, but it is a better practice to create a custom HTTP Client to share explicitly through your application. You can configure the SDK to use the custom HTTP Client by setting the HTTPClient value of the SDK's Config type when creating a Session or service client.
Package aws provides core functionality for making requests to AWS services.
Index ¶
- Constants
- Variables
- func AddToUserAgent(r *Request, s string)
- func Bool(v bool) *bool
- func BoolMap(src map[string]bool) map[string]*bool
- func BoolSlice(src []bool) []*bool
- func BoolValue(v *bool) bool
- func BoolValueMap(src map[string]*bool) map[string]bool
- func BoolValueSlice(src []*bool) []bool
- func Float32(v float32) *float32
- func Float32Map(src map[string]float32) map[string]*float32
- func Float32Slice(src []float32) []*float32
- func Float32Value(v *float32) float32
- func Float32ValueMap(src map[string]*float32) map[string]float32
- func Float32ValueSlice(src []*float32) []float32
- func Float64(v float64) *float64
- func Float64Map(src map[string]float64) map[string]*float64
- func Float64Slice(src []float64) []*float64
- func Float64Value(v *float64) float64
- func Float64ValueMap(src map[string]*float64) map[string]float64
- func Float64ValueSlice(src []*float64) []float64
- func HandlerListLogItem(item HandlerListRunItem) bool
- func HandlerListStopOnError(item HandlerListRunItem) bool
- func Int(v int) *int
- func Int16(v int16) *int16
- func Int16Map(src map[string]int16) map[string]*int16
- func Int16Slice(src []int16) []*int16
- func Int16Value(v *int16) int16
- func Int16ValueMap(src map[string]*int16) map[string]int16
- func Int16ValueSlice(src []*int16) []int16
- func Int32(v int32) *int32
- func Int32Map(src map[string]int32) map[string]*int32
- func Int32Slice(src []int32) []*int32
- func Int32Value(v *int32) int32
- func Int32ValueMap(src map[string]*int32) map[string]int32
- func Int32ValueSlice(src []*int32) []int32
- func Int64(v int64) *int64
- func Int64Map(src map[string]int64) map[string]*int64
- func Int64Slice(src []int64) []*int64
- func Int64Value(v *int64) int64
- func Int64ValueMap(src map[string]*int64) map[string]int64
- func Int64ValueSlice(src []*int64) []int64
- func Int8(v int8) *int8
- func Int8Map(src map[string]int8) map[string]*int8
- func Int8Slice(src []int8) []*int8
- func Int8Value(v *int8) int8
- func Int8ValueMap(src map[string]*int8) map[string]int8
- func Int8ValueSlice(src []*int8) []int8
- func IntMap(src map[string]int) map[string]*int
- func IntSlice(src []int) []*int
- func IntValue(v *int) int
- func IntValueMap(src map[string]*int) map[string]int
- func IntValueSlice(src []*int) []int
- func IsErrorExpiredCreds(err error) bool
- func IsErrorRetryable(err error) bool
- func IsErrorThrottle(err error) bool
- func IsReaderSeekable(r io.Reader) bool
- func MakeAddToUserAgentFreeFormHandler(s string) func(*Request)
- func MakeAddToUserAgentHandler(name, version string, extra ...string) func(*Request)
- func MillisecondsTimeValue(v *int64) time.Time
- func SanitizeHostForHeader(r *http.Request)
- func SecondsTimeValue(v *int64) time.Time
- func SeekerLen(s io.Seeker) (int64, error)
- func SleepWithContext(ctx context.Context, dur time.Duration) error
- func String(v string) *string
- func StringMap(src map[string]string) map[string]*string
- func StringSlice(src []string) []*string
- func StringValue(v *string) string
- func StringValueMap(src map[string]*string) map[string]string
- func StringValueSlice(src []*string) []string
- func Time(v time.Time) *time.Time
- func TimeMap(src map[string]time.Time) map[string]*time.Time
- func TimeSlice(src []time.Time) []*time.Time
- func TimeUnixMilli(t time.Time) int64
- func TimeValue(v *time.Time) time.Time
- func TimeValueMap(src map[string]*time.Time) map[string]time.Time
- func TimeValueSlice(src []*time.Time) []time.Time
- func Uint(v uint) *uint
- func Uint16(v uint16) *uint16
- func Uint16Map(src map[string]uint16) map[string]*uint16
- func Uint16Slice(src []uint16) []*uint16
- func Uint16Value(v *uint16) uint16
- func Uint16ValueMap(src map[string]*uint16) map[string]uint16
- func Uint16ValueSlice(src []*uint16) []uint16
- func Uint32(v uint32) *uint32
- func Uint32Map(src map[string]uint32) map[string]*uint32
- func Uint32Slice(src []uint32) []*uint32
- func Uint32Value(v *uint32) uint32
- func Uint32ValueMap(src map[string]*uint32) map[string]uint32
- func Uint32ValueSlice(src []*uint32) []uint32
- func Uint64(v uint64) *uint64
- func Uint64Map(src map[string]uint64) map[string]*uint64
- func Uint64Slice(src []uint64) []*uint64
- func Uint64Value(v *uint64) uint64
- func Uint64ValueMap(src map[string]*uint64) map[string]uint64
- func Uint64ValueSlice(src []*uint64) []uint64
- func Uint8(v uint8) *uint8
- func Uint8Map(src map[string]uint8) map[string]*uint8
- func Uint8Slice(src []uint8) []*uint8
- func Uint8Value(v *uint8) uint8
- func Uint8ValueMap(src map[string]*uint8) map[string]uint8
- func Uint8ValueSlice(src []*uint8) []uint8
- func UintMap(src map[string]uint) map[string]*uint
- func UintSlice(src []uint) []*uint
- func UintValue(v *uint) uint
- func UintValueMap(src map[string]*uint) map[string]uint
- func UintValueSlice(src []*uint) []uint
- type BuildableHTTPClient
- func (b *BuildableHTTPClient) Do(req *http.Request) (*http.Response, error)
- func (b BuildableHTTPClient) GetDialer() *net.Dialer
- func (b BuildableHTTPClient) GetTransport() *http.Transport
- func (b BuildableHTTPClient) WithDialerOptions(opts ...func(*net.Dialer)) HTTPClient
- func (b BuildableHTTPClient) WithTransportOptions(opts ...func(*http.Transport)) HTTPClient
- type ChainProvider
- type Client
- type Config
- type Credentials
- type CredentialsProvider
- type DefaultRetryer
- type Endpoint
- type EndpointResolver
- type EndpointResolverFunc
- 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 (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 (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 (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 (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 (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 Expiration
- type HTTPClient
- 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
- type JSONValue
- type LogLevel
- type Logger
- type LoggerFunc
- type Metadata
- type NamedHandler
- type NoOpRetryer
- type Operation
- type Option
- type Pager
- type Paginator
- type ReaderSeekerCloser
- func (r ReaderSeekerCloser) Close() error
- func (r ReaderSeekerCloser) GetLen() (int64, error)
- func (r ReaderSeekerCloser) HasLen() (int, bool)
- func (r ReaderSeekerCloser) IsSeeker() bool
- func (r ReaderSeekerCloser) Read(p []byte) (int, error)
- func (r ReaderSeekerCloser) Seek(offset int64, whence int) (int64, error)
- type Request
- func (r *Request) ApplyOptions(opts ...Option)
- func (r *Request) Build() error
- func (r *Request) Context() context.Context
- func (r *Request) GetBody() io.ReadSeeker
- func (r *Request) IsErrorExpired() bool
- func (r *Request) IsErrorRetryable() bool
- func (r *Request) IsErrorThrottle() bool
- func (r *Request) ParamsFilled() bool
- func (r *Request) Presign(expireTime time.Duration) (string, error)
- func (r *Request) PresignRequest(expireTime 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 context.Context)
- func (r *Request) SetReaderBody(reader io.ReadSeeker)
- func (r *Request) SetStringBody(s string)
- func (r *Request) Sign() error
- func (r *Request) WillRetry() bool
- type ResolveWithEndpoint
- type Response
- type Retryer
- type SafeCredentialsProvider
- type StaticCredentialsProvider
- type Validator
- type Waiter
- type WaiterAcceptor
- type WaiterDelay
- type WaiterMatchMode
- type WaiterOption
- type WaiterState
- type WriteAtBuffer
Examples ¶
Constants ¶
const ( // DefaultRetryerMaxNumRetries sets maximum number of retries DefaultRetryerMaxNumRetries = 3 // DefaultRetryerMinRetryDelay sets minimum retry delay DefaultRetryerMinRetryDelay = 30 * time.Millisecond // DefaultRetryerMinThrottleDelay sets minimum delay when throttled DefaultRetryerMinThrottleDelay = 500 * time.Millisecond // DefaultRetryerMaxRetryDelay sets maximum retry delay DefaultRetryerMaxRetryDelay = 300 * time.Second // DefaultRetryerMaxThrottleDelay sets maximum delay when throttled DefaultRetryerMaxThrottleDelay = 300 * time.Second )
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" // ErrCodeRequestCanceled is the error code that will be returned by an // API request that was canceled. Requests given a Context may // return this error when canceled. ErrCodeRequestCanceled = "RequestCanceled" )
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 SDKName = "aws-sdk-go"
SDKName is the name of this AWS SDK
const SDKVersion = "0.15.0"
SDKVersion is the version of this SDK
const StaticCredentialsProviderName = "StaticCredentialsProvider"
StaticCredentialsProviderName provides a name of Static provider
const WaiterResourceNotReadyErrorCode = "ResourceNotReady"
WaiterResourceNotReadyErrorCode is the error code returned by a waiter when the waiter's max attempts have been exhausted.
Variables ¶
var ( // ErrMissingRegion is an error that is returned if region configuration is // not found. // // @readonly ErrMissingRegion = awserr.New("MissingRegion", "could not find region configuration", nil) // ErrMissingEndpoint is an error that is returned if an endpoint cannot be // resolved for a service. // // @readonly ErrMissingEndpoint = awserr.New("MissingEndpoint", "'Endpoint' configuration is required for this service", nil) )
var ( DefaultHTTPTransportMaxIdleConns = 100 DefaultHTTPTransportMaxIdleConnsPerHost = 10 DefaultHTTPTransportIdleConnTimeout = 90 * time.Second DefaultHTTPTransportTLSHandleshakeTimeout = 10 * time.Second DefaultHTTPTransportExpectContinueTimeout = 1 * time.Second )
Defaults for the HTTPTransportBuilder.
var ( DefaultDialConnectTimeout = 30 * time.Second DefaultDialKeepAliveTimeout = 30 * time.Second )
Timeouts for net.Dialer's network connection.
var AnonymousCredentials = StaticCredentialsProvider{ Value: Credentials{Source: "AnonymousCredentials"}, }
AnonymousCredentials is an empty CredentialProvider that can be used as dummy placeholder credentials for requests that do not need signed.
This credentials can be used to configure a service to not sign requests when making service API calls. For example, when accessing public s3 buckets.
s3Cfg := cfg.Copy() s3cfg.Credentials = AnonymousCredentials svc := s3.New(s3Cfg)
var ( // ErrStaticCredentialsEmpty is emitted when static credentials are empty. ErrStaticCredentialsEmpty = awserr.New("EmptyStaticCreds", "static credentials are empty", nil) )
var NeverExpire = time.Unix(math.MaxInt64, 0)
NeverExpire is the time identifier used when a credential provider's credentials will not expire. This is used in cases where a non-expiring provider type cannot be used.
Functions ¶
func AddToUserAgent ¶
AddToUserAgent adds the string to the end of the request's current user agent.
func BoolValue ¶
BoolValue returns the value of the bool pointer passed in or false if the pointer is nil.
func BoolValueMap ¶
BoolValueMap converts a string map of bool pointers into a string map of bool values
func BoolValueSlice ¶
BoolValueSlice converts a slice of bool pointers into a slice of bool values
func Float32Map ¶ added in v0.13.0
Float32Map converts a string map of float32 values into a string map of float32 pointers
func Float32Slice ¶ added in v0.13.0
Float32Slice converts a slice of float32 values into a slice of float32 pointers
func Float32Value ¶ added in v0.13.0
Float32Value returns the value of the float32 pointer passed in or 0 if the pointer is nil.
func Float32ValueMap ¶ added in v0.13.0
Float32ValueMap converts a string map of float32 pointers into a string map of float32 values
func Float32ValueSlice ¶ added in v0.13.0
Float32ValueSlice converts a slice of float32 pointers into a slice of float32 values
func Float64Map ¶
Float64Map converts a string map of float64 values into a string map of float64 pointers
func Float64Slice ¶
Float64Slice converts a slice of float64 values into a slice of float64 pointers
func Float64Value ¶
Float64Value returns the value of the float64 pointer passed in or 0 if the pointer is nil.
func Float64ValueMap ¶
Float64ValueMap converts a string map of float64 pointers into a string map of float64 values
func Float64ValueSlice ¶
Float64ValueSlice converts a slice of float64 pointers into a slice of float64 values
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 Int16Map ¶ added in v0.13.0
Int16Map converts a string map of int16 values into a string map of int16 pointers
func Int16Slice ¶ added in v0.13.0
Int16Slice converts a slice of int16 values into a slice of int16 pointers
func Int16Value ¶ added in v0.13.0
Int16Value returns the value of the int16 pointer passed in or 0 if the pointer is nil.
func Int16ValueMap ¶ added in v0.13.0
Int16ValueMap converts a string map of int16 pointers into a string map of int16 values
func Int16ValueSlice ¶ added in v0.13.0
Int16ValueSlice converts a slice of int16 pointers into a slice of int16 values
func Int32Map ¶ added in v0.13.0
Int32Map converts a string map of int32 values into a string map of int32 pointers
func Int32Slice ¶ added in v0.13.0
Int32Slice converts a slice of int32 values into a slice of int32 pointers
func Int32Value ¶ added in v0.13.0
Int32Value returns the value of the int32 pointer passed in or 0 if the pointer is nil.
func Int32ValueMap ¶ added in v0.13.0
Int32ValueMap converts a string map of int32 pointers into a string map of int32 values
func Int32ValueSlice ¶ added in v0.13.0
Int32ValueSlice converts a slice of int32 pointers into a slice of int32 values
func Int64Slice ¶
Int64Slice converts a slice of int64 values into a slice of int64 pointers
func Int64Value ¶
Int64Value returns the value of the int64 pointer passed in or 0 if the pointer is nil.
func Int64ValueMap ¶
Int64ValueMap converts a string map of int64 pointers into a string map of int64 values
func Int64ValueSlice ¶
Int64ValueSlice converts a slice of int64 pointers into a slice of int64 values
func Int8Map ¶ added in v0.13.0
Int8Map converts a string map of int8 values into a string map of int8 pointers
func Int8Slice ¶ added in v0.13.0
Int8Slice converts a slice of int8 values into a slice of int8 pointers
func Int8Value ¶ added in v0.13.0
Int8Value returns the value of the int8 pointer passed in or 0 if the pointer is nil.
func Int8ValueMap ¶ added in v0.13.0
Int8ValueMap converts a string map of int8 pointers into a string map of int8 values
func Int8ValueSlice ¶ added in v0.13.0
Int8ValueSlice converts a slice of int8 pointers into a slice of int8 values
func IntValueMap ¶
IntValueMap converts a string map of int pointers into a string map of int values
func IntValueSlice ¶
IntValueSlice converts a slice of int pointers into a slice of int values
func IsErrorExpiredCreds ¶
IsErrorExpiredCreds returns whether the error code is a credential expiry error. Returns false if error is nil.
func IsErrorRetryable ¶
IsErrorRetryable returns whether the error is retryable, based on its Code. Returns false if error is nil.
func IsErrorThrottle ¶
IsErrorThrottle returns whether the error is to be throttled based on its code. Returns false if error is nil.
func IsReaderSeekable ¶ added in v0.12.0
IsReaderSeekable returns if the underlying reader type can be seeked. A io.Reader might not actually be seekable if it is the ReaderSeekerCloser type.
func MakeAddToUserAgentFreeFormHandler ¶
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 ¶
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 MillisecondsTimeValue ¶
MillisecondsTimeValue converts an int64 pointer to a time.Time value representing milliseconds sinch Epoch or time.Time{} if the pointer is nil.
func SanitizeHostForHeader ¶ added in v0.12.0
SanitizeHostForHeader removes default port from host and updates request.Host
func SecondsTimeValue ¶
SecondsTimeValue converts an int64 pointer to a time.Time value representing seconds since Epoch or time.Time{} if the pointer is nil.
func SeekerLen ¶ added in v0.12.0
SeekerLen attempts to get the number of bytes remaining at the seeker's current position. Returns the number of bytes remaining or error.
func SleepWithContext ¶
SleepWithContext will wait for the timer duration to expire, or the context is canceled. Which ever happens first. If the context is canceled the Context's error will be returned.
Expects Context to always return a non-nil error if the Done channel is closed.
func StringMap ¶
StringMap converts a string map of string values into a string map of string pointers
func StringSlice ¶
StringSlice converts a slice of string values into a slice of string pointers
func StringValue ¶
StringValue returns the value of the string pointer passed in or "" if the pointer is nil.
func StringValueMap ¶
StringValueMap converts a string map of string pointers into a string map of string values
func StringValueSlice ¶
StringValueSlice converts a slice of string pointers into a slice of string values
func TimeMap ¶
TimeMap converts a string map of time.Time values into a string map of time.Time pointers
func TimeUnixMilli ¶
TimeUnixMilli returns a Unix timestamp in milliseconds from "January 1, 1970 UTC". The result is undefined if the Unix time cannot be represented by an int64. Which includes calling TimeUnixMilli on a zero Time is undefined.
This utility is useful for service API's such as CloudWatch Logs which require their unix time values to be in milliseconds.
See Go stdlib https://golang.org/pkg/time/#Time.UnixNano for more information.
func TimeValue ¶
TimeValue returns the value of the time.Time pointer passed in or time.Time{} if the pointer is nil.
func TimeValueMap ¶
TimeValueMap converts a string map of time.Time pointers into a string map of time.Time values
func TimeValueSlice ¶
TimeValueSlice converts a slice of time.Time pointers into a slice of time.Time values
func Uint16Map ¶ added in v0.13.0
Uint16Map converts a string map of uint16 values into a string map of uint16 pointers
func Uint16Slice ¶ added in v0.13.0
Uint16Slice converts a slice of uint16 values into a slice of uint16 pointers
func Uint16Value ¶ added in v0.13.0
Uint16Value returns the value of the uint16 pointer passed in or 0 if the pointer is nil.
func Uint16ValueMap ¶ added in v0.13.0
Uint16ValueMap converts a string map of uint16 pointers into a string map of uint16 values
func Uint16ValueSlice ¶ added in v0.13.0
Uint16ValueSlice converts a slice of uint16 pointers into a slice of uint16 values
func Uint32Map ¶ added in v0.13.0
Uint32Map converts a string map of uint32 values into a string map of uint32 pointers
func Uint32Slice ¶ added in v0.13.0
Uint32Slice converts a slice of uint32 values into a slice of uint32 pointers
func Uint32Value ¶ added in v0.13.0
Uint32Value returns the value of the uint32 pointer passed in or 0 if the pointer is nil.
func Uint32ValueMap ¶ added in v0.13.0
Uint32ValueMap converts a string map of uint32 pointers into a string map of uint32 values
func Uint32ValueSlice ¶ added in v0.13.0
Uint32ValueSlice converts a slice of uint32 pointers into a slice of uint32 values
func Uint64Map ¶ added in v0.13.0
Uint64Map converts a string map of uint64 values into a string map of uint64 pointers
func Uint64Slice ¶ added in v0.13.0
Uint64Slice converts a slice of uint64 values into a slice of uint64 pointers
func Uint64Value ¶ added in v0.13.0
Uint64Value returns the value of the uint64 pointer passed in or 0 if the pointer is nil.
func Uint64ValueMap ¶ added in v0.13.0
Uint64ValueMap converts a string map of uint64 pointers into a string map of uint64 values
func Uint64ValueSlice ¶ added in v0.13.0
Uint64ValueSlice converts a slice of uint64 pointers into a slice of uint64 values
func Uint8Map ¶ added in v0.13.0
Uint8Map converts a string map of uint8 values into a string map of uint8 pointers
func Uint8Slice ¶ added in v0.13.0
Uint8Slice converts a slice of uint8 values into a slice of uint8 pointers
func Uint8Value ¶ added in v0.13.0
Uint8Value returns the value of the uint8 pointer passed in or 0 if the pointer is nil.
func Uint8ValueMap ¶ added in v0.13.0
Uint8ValueMap converts a string map of uint8 pointers into a string map of uint8 values
func Uint8ValueSlice ¶ added in v0.13.0
Uint8ValueSlice converts a slice of uint8 pointers into a slice of uint8 values
func UintMap ¶ added in v0.13.0
UintMap converts a string map of uint values uinto a string map of uint pointers
func UintSlice ¶ added in v0.13.0
UintSlice converts a slice of uint values uinto a slice of uint pointers
func UintValue ¶ added in v0.13.0
UintValue returns the value of the uint pointer passed in or 0 if the pointer is nil.
func UintValueMap ¶ added in v0.13.0
UintValueMap converts a string map of uint pointers uinto a string map of uint values
func UintValueSlice ¶ added in v0.13.0
UintValueSlice converts a slice of uint pointers uinto a slice of uint values
Types ¶
type BuildableHTTPClient ¶ added in v0.10.0
type BuildableHTTPClient struct {
// contains filtered or unexported fields
}
BuildableHTTPClient provides a HTTPClient implementation with options to create copies of the HTTPClient when additional configuration is provided.
The client's methods will not share the http.Transport value between copies of the BuildableHTTPClient. Only exported member values of the Transport and optional Dialer will be copied between copies of BuildableHTTPClient.
func NewBuildableHTTPClient ¶ added in v0.10.0
func NewBuildableHTTPClient() *BuildableHTTPClient
NewBuildableHTTPClient returns an initialized client for invoking HTTP requests.
func (*BuildableHTTPClient) Do ¶ added in v0.10.0
Do implements the HTTPClient interface's Do method to invoke a HTTP request, and receive the response. Uses the BuildableHTTPClient's current configuration to invoke the http.Request.
If connection pooling is enabled (aka HTTP KeepAlive) the client will only share pooled connections with its own instance. Copies of the BuildableHTTPClient will have their own connection pools.
Redirect (3xx) responses will not be followed, the HTTP response received will returned instead.
func (BuildableHTTPClient) GetDialer ¶ added in v0.10.0
func (b BuildableHTTPClient) GetDialer() *net.Dialer
GetDialer returns a copy of the client's network dialer.
func (BuildableHTTPClient) GetTransport ¶ added in v0.10.0
func (b BuildableHTTPClient) GetTransport() *http.Transport
GetTransport returns a copy of the client's HTTP Transport.
func (BuildableHTTPClient) WithDialerOptions ¶ added in v0.10.0
func (b BuildableHTTPClient) WithDialerOptions(opts ...func(*net.Dialer)) HTTPClient
WithDialerOptions copies the BuildableHTTPClient and returns it with the net.Dialer options applied. Will set the client's http.Transport DialContext member.
Example ¶
package main import ( "net" "time" "github.com/aws/aws-sdk-go-v2/aws" ) func main() { // Create a new client by calling the constructor. client := aws.NewBuildableHTTPClient(). WithDialerOptions(func(d *net.Dialer) { // Set the network (e.g. TCP) dial timeout to 10 seconds. d.Timeout = 10 * time.Second }) // Set the configured HTTP client to the SDK's Config, and use the // Config to create API clients with. cfg.HTTPClient = client } var cfg aws.Config
Output:
func (BuildableHTTPClient) WithTransportOptions ¶ added in v0.10.0
func (b BuildableHTTPClient) WithTransportOptions(opts ...func(*http.Transport)) HTTPClient
WithTransportOptions copies the BuildableHTTPClient and returns it with the http.Transport options applied.
If a non (*http.Transport) was set as the round tripper, the round tripper will be replaced with a default Transport value before invoking the option functions.
Example (ConnectionPool) ¶
package main import ( "fmt" "log" "net/http" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/external" ) func main() { cfg, err := external.LoadDefaultAWSConfig() if err != nil { log.Fatalf("failed to load config, %v", err) } // The SDK's HTTPClient implementation implements a WithTransportOptions // method for getting an HTTP client with custom transport options. type httpClientTransportOptions interface { WithTransportOptions(...func(*http.Transport)) aws.HTTPClient } // Unless cfg.HTTPClient is set to another custom implementation by the // application the SDK will use aws.BuildableHTTPClient as the // implementation for cfg.HTTPClient. client, ok := cfg.HTTPClient.(httpClientTransportOptions) if !ok { log.Fatalf("expected http client to be SDK's default but wasn't, %T", cfg.HTTPClient) } // Get a client with custom connection pooling options. The client's // options are immutable, and return copies of the client when options are // applied. cfg.HTTPClient = client.WithTransportOptions(func(tr *http.Transport) { tr.MaxIdleConnsPerHost = 150 // Experiment with 2 * MaxIdleConnsPerHost * number of services, and // regions used. Need to balance burst concurrency, with max open // connections. May need to adjust how long idle connections are keep // around for with IdleConnTimeout. tr.MaxIdleConns = tr.MaxIdleConnsPerHost * 2 * 1 }) fmt.Printf("Have client: %T, MaxIdleConnsPerHost: %v\n", cfg.HTTPClient, cfg.HTTPClient.(*aws.BuildableHTTPClient).GetTransport().MaxIdleConnsPerHost, ) // Create service API clients with cfg value to use the custom Transport options. }
Output: Have client: *aws.BuildableHTTPClient, MaxIdleConnsPerHost: 150
Example (ResponseTimeouts) ¶
package main import ( "net/http" "time" "github.com/aws/aws-sdk-go-v2/aws" ) func main() { // Create a new client by calling the constructor. // Add custom *http.Transport configuration to the client. The // modifications will be on the new client returned. client := aws.NewBuildableHTTPClient(). WithTransportOptions(func(tr *http.Transport) { // Only wait 10 seconds for the full response headers to be read. tr.ResponseHeaderTimeout = 10 * time.Second }) // Set the configured HTTP client to the SDK's Config, and use the // Config to create API clients with. cfg.HTTPClient = client } var cfg aws.Config
Output:
type ChainProvider ¶
type ChainProvider struct { SafeCredentialsProvider Providers []CredentialsProvider }
A ChainProvider will search for a provider which returns credentials and cache that provider until Retrieve is called again.
The ChainProvider provides a way of chaining multiple providers together which will pick the first available using priority order of the Providers in the list.
If none of the Providers retrieve valid credentials Credentials, ChainProvider's Retrieve() will return the error ErrNoValidProvidersFoundInChain.
If a CredentialsProvider is found which returns valid credentials Credentials ChainProvider will cache that CredentialsProvider for all calls to IsExpired(), until Retrieve is called again.
Example of ChainProvider to be used with an EnvProvider and EC2RoleProvider. In this example EnvProvider will first check if any credentials are available via the environment variables. If there are none ChainProvider will check the next CredentialsProvider in the list, EC2RoleProvider in this case. If EC2RoleProvider does not return any credentials ChainProvider will return the error ErrNoValidProvidersFoundInChain
creds := aws.NewChainCredentials( []aws.CredentialsProvider{ &credentials.EnvProvider{}, &ec2rolecreds.EC2RoleProvider{ Client: ec2metadata.New(cfg), }, }) // Usage of ChainCredentials with aws.Config cfg := cfg.Copy() cfg.Credentials = creds svc := ec2.New(cfg)
func NewChainProvider ¶
func NewChainProvider(providers []CredentialsProvider) *ChainProvider
NewChainProvider returns a pointer to a new ChainProvider value wrapping a chain of credentials providers.
type Client ¶
type Client struct { Metadata Metadata Config Config Region string Credentials CredentialsProvider EndpointResolver EndpointResolver Handlers Handlers Retryer Retryer LogLevel LogLevel Logger Logger HTTPClient HTTPClient }
A Client implements the base client request and response handling used by all service clients.
func (*Client) AddDebugHandlers ¶
func (c *Client) AddDebugHandlers()
AddDebugHandlers injects debug logging handlers into the service to log request debug information.
func (*Client) NewRequest ¶
NewRequest returns a new Request pointer for the service API operation and parameters.
type Config ¶
type Config struct { // The region to send requests to. This parameter is required and must // be configured globally or on a per-client basis unless otherwise // noted. A full list of regions is found in the "Regions and Endpoints" // document. // // See http://docs.aws.amazon.com/general/latest/gr/rande.html for // information on AWS regions. Region string // The credentials object to use when signing requests. Defaults to a // chain of credential providers to search for credentials in environment // variables, shared credential file, and EC2 Instance Roles. Credentials CredentialsProvider // The resolver to use for looking up endpoints for AWS service clients // to use based on region. EndpointResolver EndpointResolver // The HTTP Client the SDK's API clients will use to invoke HTTP requests. // The SDK defaults to a BuildableHTTPClient allowing API clients to create // copies of the HTTP Client for service specific customizations. // // Use a (*http.Client) for custom behavior. Using a custom http.Client // will prevent the SDK from modifying the HTTP client. HTTPClient HTTPClient // TODO document Handlers Handlers // Retryer guides how HTTP requests should be retried in case of // recoverable failures. // // When nil or the value does not implement the request.Retryer interface, // the client.DefaultRetryer will be used. // // When both Retryer and MaxRetries are non-nil, the former is used and // the latter ignored. // // To set the Retryer field in a type-safe manner and with chaining, use // the request.WithRetryer helper function: // // cfg := request.WithRetryer(aws.NewConfig(), myRetryer) Retryer Retryer // An integer value representing the logging level. The default log level // is zero (LogOff), which represents no logging. To enable logging set // to a LogLevel Value. LogLevel LogLevel // The logger writer interface to write logging messages to. Defaults to // standard out. Logger Logger // DisableRestProtocolURICleaning will not clean the URL path when making // rest protocol requests. Will default to false. This would only be used // for empty directory names in s3 requests. // // Example: // cfg, err := external.LoadDefaultAWSConfig() // cfg.DisableRestProtocolURICleaning = true // // svc := s3.New(cfg) // out, err := svc.GetObject(&s3.GetObjectInput { // Bucket: aws.String("bucketname"), // Key: aws.String("//foo//bar//moo"), // }) // // TODO need better way of representing support for this concept. Not on Config. DisableRestProtocolURICleaning bool // DisableEndpointHostPrefix will disable the SDK's behavior of prefixing // request endpoint hosts with modeled information. // // Disabling this feature is useful when you want to use local endpoints // for testing that do not support the modeled host prefix pattern. DisableEndpointHostPrefix bool }
A Config provides service configuration for service clients.
type Credentials ¶
type Credentials struct { // AWS Access key ID AccessKeyID string // AWS Secret Access Key SecretAccessKey string // AWS Session Token SessionToken string // Source of the credentials Source string // Time the credentials will expire. CanExpire bool Expires time.Time }
A Credentials is the AWS credentials value for individual credential fields.
func (Credentials) Expired ¶
func (v Credentials) Expired() bool
Expired returns if the credetials have expired.
func (Credentials) HasKeys ¶
func (v Credentials) HasKeys() bool
HasKeys returns if the credentials keys are set.
type CredentialsProvider ¶
type CredentialsProvider interface { // Retrieve returns nil if it successfully retrieved the value. // Error is returned if the value were not obtainable, or empty. Retrieve() (Credentials, error) }
A CredentialsProvider is the interface for any component which will provide credentials Credentials. A CredentialsProvider is required to manage its own Expired state, and what to be expired means.
The CredentialsProvider should not need to implement its own mutexes, because that will be managed by CredentialsLoader.
type DefaultRetryer ¶
type DefaultRetryer struct { NumMaxRetries int MinRetryDelay time.Duration MinThrottleDelay time.Duration MaxRetryDelay time.Duration MaxThrottleDelay time.Duration }
DefaultRetryer implements basic retry logic using exponential backoff for most services. You can implement your own custom retryer by implementing retryer interface.
func NewDefaultRetryer ¶ added in v0.12.0
func NewDefaultRetryer(opts ...func(d *DefaultRetryer)) DefaultRetryer
NewDefaultRetryer returns a retryer initialized with default values and optionally takes function to override values for default retryer.
func (DefaultRetryer) MaxRetries ¶
func (d DefaultRetryer) MaxRetries() int
MaxRetries returns the number of maximum returns the service will use to make an individual API
func (DefaultRetryer) RetryRules ¶
func (d DefaultRetryer) RetryRules(r *Request) time.Duration
RetryRules returns the delay duration before retrying this request again
Note: RetryRules method must be a value receiver so that the defaultRetryer is safe.
func (DefaultRetryer) ShouldRetry ¶
func (d DefaultRetryer) ShouldRetry(r *Request) bool
ShouldRetry returns true if the request should be retried.
type Endpoint ¶
type Endpoint struct { // The URL of the endpoint. URL string // The service name that should be used for signing the requests to the // endpoint. SigningName string // The region that should be used for signing the request to the endpoint. SigningRegion string // States that the signing name for this endpoint was derived from metadata // passed in, but was not explicitly modeled. SigningNameDerived bool // The signing method that should be used for signign the requests to the // endpoint. SigningMethod string }
Endpoint represents the endpoint a service client should make requests to.
type EndpointResolver ¶
EndpointResolver resolves an endpoint for a service endpoint id and region.
type EndpointResolverFunc ¶
EndpointResolverFunc is a helper utility that wraps a function so it satisfies the Resolver interface. This is useful when you want to add additional endpoint resolving logic, or stub out specific endpoints with custom values.
Example ¶
package main import ( "context" "fmt" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/defaults" "github.com/aws/aws-sdk-go-v2/aws/endpoints" "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/sqs" ) func main() { defaultResolver := endpoints.NewDefaultResolver() myCustomResolver := func(service, region string) (aws.Endpoint, error) { if service == s3.EndpointsID { return aws.Endpoint{ URL: "s3.custom.endpoint.com", SigningRegion: "custom-signing-region", }, nil } return defaultResolver.ResolveEndpoint(service, region) } cfg := defaults.Config() cfg.Region = endpoints.UsWest2RegionID cfg.EndpointResolver = aws.EndpointResolverFunc(myCustomResolver) // Create the S3 service client with the shared config. This will // automatically use the S3 custom endpoint configured in the custom // endpoint resolver wrapping the default endpoint resolver. s3Svc := s3.New(cfg) // Operation calls will be made to the custom endpoint. objReq := s3Svc.GetObjectRequest(&s3.GetObjectInput{ Bucket: aws.String("myBucket"), Key: aws.String("myObjectKey"), }) objResp, err := objReq.Send(context.Background()) if err != nil { panic("S3 Get Object error, " + err.Error()) } fmt.Println("S3 Get object", objResp) // Create the SQS service client with the shared cfg. This will // fallback to the default endpoint resolver because the customization // passes any non S3 service endpoint resolve to the default resolver. sqsSvc := sqs.New(cfg) // Operation calls will be made to the default endpoint for SQS for the // region configured. msgReq := sqsSvc.ReceiveMessageRequest(&sqs.ReceiveMessageInput{ QueueUrl: aws.String("my-queue-url"), }) msgResp, err := msgReq.Send(context.Background()) if err != nil { panic("SQS Receive Message error, " + err.Error()) } fmt.Println("SQS Receive Message", msgResp) }
Output:
func (EndpointResolverFunc) ResolveEndpoint ¶
func (fn EndpointResolverFunc) ResolveEndpoint(service, region string) (Endpoint, error)
ResolveEndpoint calls EndpointResolverFunc returning the endpoint, or error.
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 ¶ added in v0.6.0
type ErrParamFormat struct {
// contains filtered or unexported fields
}
An ErrParamFormat represents a invalid format parameter error.
func NewErrParamFormat ¶ added in v0.6.0
func NewErrParamFormat(field string, format, value string) *ErrParamFormat
NewErrParamFormat creates a new invalid format parameter error.
func (*ErrParamFormat) AddNestedContext ¶ added in v0.6.0
func (e *ErrParamFormat) AddNestedContext(ctx string)
AddNestedContext prepends a context to the field's path.
func (*ErrParamFormat) Code ¶ added in v0.6.0
func (e *ErrParamFormat) Code() string
Code returns the error code for the type of invalid parameter.
func (*ErrParamFormat) Error ¶ added in v0.6.0
func (e *ErrParamFormat) Error() string
Error returns the string version of the invalid parameter error.
func (*ErrParamFormat) Field ¶ added in v0.6.0
func (e *ErrParamFormat) Field() string
Field Returns the field and context the error occurred.
func (*ErrParamFormat) Format ¶ added in v0.6.0
func (e *ErrParamFormat) Format() string
Format returns the field's required format.
func (*ErrParamFormat) Message ¶ added in v0.6.0
func (e *ErrParamFormat) Message() string
Message returns the reason the parameter was invalid, and its context.
func (*ErrParamFormat) OrigErr ¶ added in v0.6.0
func (e *ErrParamFormat) OrigErr() error
OrigErr returns nil, Implemented for awserr.Error interface.
func (*ErrParamFormat) SetContext ¶ added in v0.6.0
func (e *ErrParamFormat) SetContext(ctx string)
SetContext updates the base context of the error.
type ErrParamMaxLen ¶ added in v0.6.0
type ErrParamMaxLen struct {
// contains filtered or unexported fields
}
An ErrParamMaxLen represents a maximum length parameter error.
func NewErrParamMaxLen ¶ added in v0.6.0
func NewErrParamMaxLen(field string, max int, value string) *ErrParamMaxLen
NewErrParamMaxLen creates a new maximum length parameter error.
func (*ErrParamMaxLen) AddNestedContext ¶ added in v0.6.0
func (e *ErrParamMaxLen) AddNestedContext(ctx string)
AddNestedContext prepends a context to the field's path.
func (*ErrParamMaxLen) Code ¶ added in v0.6.0
func (e *ErrParamMaxLen) Code() string
Code returns the error code for the type of invalid parameter.
func (*ErrParamMaxLen) Error ¶ added in v0.6.0
func (e *ErrParamMaxLen) Error() string
Error returns the string version of the invalid parameter error.
func (*ErrParamMaxLen) Field ¶ added in v0.6.0
func (e *ErrParamMaxLen) Field() string
Field Returns the field and context the error occurred.
func (*ErrParamMaxLen) MaxLen ¶ added in v0.6.0
func (e *ErrParamMaxLen) MaxLen() int
MaxLen returns the field's required minimum length.
func (*ErrParamMaxLen) Message ¶ added in v0.6.0
func (e *ErrParamMaxLen) Message() string
Message returns the reason the parameter was invalid, and its context.
func (*ErrParamMaxLen) OrigErr ¶ added in v0.6.0
func (e *ErrParamMaxLen) OrigErr() error
OrigErr returns nil, Implemented for awserr.Error interface.
func (*ErrParamMaxLen) SetContext ¶ added in v0.6.0
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 Expiration ¶
An Expiration provides wrapper around time with expiration related methods.
type HTTPClient ¶ added in v0.10.0
HTTPClient provides the interface to provide custom HTTPClients. Generally *http.Client is sufficient for most use cases. The HTTPClient should not follow redirects.
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) 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 ¶ added in v0.12.0
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 Sign HandlerList Send HandlerList ValidateResponse HandlerList Unmarshal 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.
type JSONValue ¶
type JSONValue map[string]interface{}
JSONValue is a representation of a grab bag type that will be marshaled into a json string. This type can be used just like any other map.
Example: values := aws.JSONValue{ "Foo": "Bar", } values["Baz"] = "Qux"
type LogLevel ¶
type LogLevel uint
A LogLevel defines the level logging should be performed at. Used to instruct the SDK which statements should be logged.
const ( // LogOff states that no logging should be performed by the SDK. This is the // default state of the SDK, and should be use to disable all logging. LogOff LogLevel = iota * 0x1000 // LogDebug state that debug output should be logged by the SDK. This should // be used to inspect request made and responses received. LogDebug )
const ( // LogDebugWithSigning states that the SDK should log request signing and // presigning events. This should be used to log the signing details of // requests for debugging. Will also enable LogDebug. LogDebugWithSigning LogLevel = LogDebug | (1 << iota) // LogDebugWithHTTPBody states the SDK should log HTTP request and response // HTTP bodys in addition to the headers and path. This should be used to // see the body content of requests and responses made while using the SDK // Will also enable LogDebug. LogDebugWithHTTPBody // LogDebugWithRequestRetries states the SDK should log when service requests will // be retried. This should be used to log when you want to log when service // requests are being retried. Will also enable LogDebug. LogDebugWithRequestRetries // LogDebugWithRequestErrors states the SDK should log when service requests fail // to build, send, validate, or unmarshal. LogDebugWithRequestErrors )
Debug Logging Sub Levels
type Logger ¶
type Logger interface {
Log(...interface{})
}
A Logger is a minimalistic interface for the SDK to log messages to. Should be used to provide custom logging writers for the SDK to use.
func NewDefaultLogger ¶
func NewDefaultLogger() Logger
NewDefaultLogger returns a Logger which will write log messages to stdout, and use same formatting runes as the stdlib log.Logger
TODO remove, moved to default pkg
type LoggerFunc ¶
type LoggerFunc func(...interface{})
A LoggerFunc is a convenience type to convert a function taking a variadic list of arguments and wrap it so the Logger interface can be used.
Example:
s3.New(sess, &aws.Config{Logger: aws.LoggerFunc(func(args ...interface{}) { fmt.Fprintln(os.Stdout, args...) })})
func (LoggerFunc) Log ¶
func (f LoggerFunc) Log(args ...interface{})
Log calls the wrapped function with the arguments provided
type Metadata ¶
type Metadata struct { ServiceName string ServiceID string EndpointsID string APIVersion string Endpoint string SigningName string SigningRegion string JSONVersion string TargetPrefix string }
Metadata wraps immutable data from the Client structure.
type NamedHandler ¶
A NamedHandler is a struct that contains a name and function callback.
type NoOpRetryer ¶ added in v0.12.0
type NoOpRetryer struct{}
NoOpRetryer provides a retryer that performs no retries. It should be used when we do not want retries to be performed.
func (NoOpRetryer) MaxRetries ¶ added in v0.12.0
func (d NoOpRetryer) MaxRetries() int
MaxRetries returns the number of maximum returns the service will use to make an individual API; For NoOpRetryer the MaxRetries will always be zero.
func (NoOpRetryer) RetryRules ¶ added in v0.12.0
func (d NoOpRetryer) RetryRules(_ *Request) time.Duration
RetryRules returns the delay duration before retrying this request again; since NoOpRetryer does not retry, RetryRules always returns 0.
func (NoOpRetryer) ShouldRetry ¶ added in v0.12.0
func (d NoOpRetryer) ShouldRetry(_ *Request) bool
ShouldRetry will always return false for NoOpRetryer, as it should never retry.
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 ¶
WithAppendUserAgent will add a string to the user agent prefixed with a single white space.
func WithGetResponseHeader ¶
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 ¶
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 ¶
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(LogDebugWithHTTPBody)
func WithResponseReadTimeout ¶
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)
type Pager ¶ added in v0.3.0
type Pager 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(context.Context) (*Request, error) // contains filtered or unexported fields }
A Pager 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.
Pagier 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.CurrentPage().(*s3.ListObjectsOutput) // process the page's data } return p.Err()
See service client API operation Pages methods for examples how the SDK will use the Pager type.
func (*Pager) CurrentPage ¶ added in v0.3.0
func (p *Pager) CurrentPage() interface{}
CurrentPage 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.
func (*Pager) Err ¶ added in v0.3.0
Err returns the error Pager encountered when retrieving the next page.
func (*Pager) Next ¶ added in v0.3.0
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.
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 Pager 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 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 ReaderSeekerCloser. Allows the SDK to accept an io.Reader that is not also an io.Seeker for unsigned streaming payload API operations.
A readSeekCloser wrapping an nonseekable io.Reader used in an API operation's input will prevent that operation being retried in the case of network errors, and cause operation requests to fail if yhe operation requires payload signing.
Note: If using with S3 PutObject to stream an object upload. The SDK's S3 Upload Manager(s3manager.Uploader) provides support for streaming with the ability to retry network errors.
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) GetLen ¶ added in v0.12.0
func (r ReaderSeekerCloser) GetLen() (int64, error)
GetLen returns the length of the bytes remaining in the underlying reader. Checks first for Len(), then io.Seeker to determine the size of the underlying reader.
Will return -1 if the length cannot be determined.
func (ReaderSeekerCloser) HasLen ¶ added in v0.12.0
func (r ReaderSeekerCloser) HasLen() (int, bool)
HasLen returns the length of the underlying reader if the value implements the Len() int method.
func (ReaderSeekerCloser) IsSeeker ¶
func (r ReaderSeekerCloser) IsSeeker() bool
IsSeeker returns if the underlying reader is also a seeker.
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 { Config Config Metadata Metadata Handlers Handlers Retryer Retryer AttemptTime time.Time Time time.Time ExpireTime time.Duration 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 // 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 // contains filtered or unexported fields }
A Request is the service request to be made.
func New ¶
func New(cfg Config, metadata Metadata, handlers Handlers, retryer Retryer, operation *Operation, params interface{}, data interface{}) *Request
New 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) ApplyOptions ¶
ApplyOptions will apply each option to the request calling them in the order the were provided.
func (*Request) Build ¶
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) Context ¶
Context will always returns a non-nil context. If Request does not have a context the context.Background will be returned.
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) IsErrorExpired ¶
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 ¶
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 ¶
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) ParamsFilled ¶
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 ¶
Presign returns the request's signed URL. Error will be returned if the signing fails.
func (*Request) PresignRequest ¶
PresignRequest behaves just like presign, with the addition of returning a set of headers that were signed.
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 set's 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.
func (*Request) Send ¶
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 ¶
SetBufferBody will set the request's body bytes that will be sent to the service API.
func (*Request) SetContext ¶
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.
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) SetStringBody ¶
SetStringBody sets the body of the request to be backed by a string.
type ResolveWithEndpoint ¶
type ResolveWithEndpoint Endpoint
ResolveWithEndpoint allows a static Resolved Endpoint to be used as an endpoint resolver
func ResolveWithEndpointURL ¶
func ResolveWithEndpointURL(url string) ResolveWithEndpoint
ResolveWithEndpointURL allows a static URL to be used as a endpoint resolver.
func (ResolveWithEndpoint) ResolveEndpoint ¶
func (v ResolveWithEndpoint) ResolveEndpoint(service, region string) (Endpoint, error)
ResolveEndpoint returns the static endpoint.
type Response ¶
type Response struct { // TODO these fields should be focused on response, not just embedded request value. // Need refactor of request for this to be better. Request *Request }
Response provides the response meta data for a SDK API request's response.
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 is an interface to control retry logic for a given service. The default implementation used by most services is the client.DefaultRetryer structure, which contains basic retry logic using exponential backoff.
type SafeCredentialsProvider ¶
type SafeCredentialsProvider struct { RetrieveFn func() (Credentials, error) // contains filtered or unexported fields }
SafeCredentialsProvider provides caching and concurrency safe credentials retrieval via the RetrieveFn.
func (*SafeCredentialsProvider) Invalidate ¶
func (p *SafeCredentialsProvider) Invalidate()
Invalidate will invalidate the cached credentials. The next call to Retrieve will cause RetrieveFn to be called.
func (*SafeCredentialsProvider) Retrieve ¶
func (p *SafeCredentialsProvider) Retrieve() (Credentials, error)
Retrieve returns the credentials. If the credentials have already been retrieved, and not expired the cached credentials will be returned. If the credentials have not been retrieved yet, or expired RetrieveFn will be called.
Returns and error if RetrieveFn returns an error.
type StaticCredentialsProvider ¶
type StaticCredentialsProvider struct {
Value Credentials
}
A StaticCredentialsProvider is a set of credentials which are set programmatically, and will never expire.
func NewStaticCredentialsProvider ¶
func NewStaticCredentialsProvider(key, secret, session string) StaticCredentialsProvider
NewStaticCredentialsProvider return a StaticCredentialsProvider initialized with the AWS credentials passed in.
func (StaticCredentialsProvider) IsExpired ¶
func (s StaticCredentialsProvider) IsExpired() bool
IsExpired returns if the credentials are expired.
For StaticCredentialsProvider, the credentials never expired.
func (StaticCredentialsProvider) Retrieve ¶
func (s StaticCredentialsProvider) Retrieve() (Credentials, error)
Retrieve returns the credentials or error if the credentials are invalid.
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 Logger MaxAttempts int Delay WaiterDelay RequestOptions []Option NewRequest func([]Option) (*Request, error) SleepWithContext func(context.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) Wait ¶ added in v0.8.0
Wait 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 context.Background or context.TODO 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 ¶
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 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.
type WriteAtBuffer ¶
type WriteAtBuffer struct { // GrowthCoeff defines the growth rate of the internal buffer. By // default, the growth rate is 1, where expanding the internal // buffer will allocate only enough capacity to fit the new expected // length. GrowthCoeff float64 // contains filtered or unexported fields }
A WriteAtBuffer provides a in memory buffer supporting the io.WriterAt interface Can be used with the s3manager.Downloader to download content to a buffer in memory. Safe to use concurrently.
func NewWriteAtBuffer ¶
func NewWriteAtBuffer(buf []byte) *WriteAtBuffer
NewWriteAtBuffer creates a WriteAtBuffer with an internal buffer provided by buf.
func (*WriteAtBuffer) Bytes ¶
func (b *WriteAtBuffer) Bytes() []byte
Bytes returns a slice of bytes written to the buffer.
func (*WriteAtBuffer) WriteAt ¶
func (b *WriteAtBuffer) WriteAt(p []byte, pos int64) (n int, err error)
WriteAt writes a slice of bytes to a buffer starting at the position provided The number of bytes written will be returned, or error. Can overwrite previous written slices if the write ats overlap.
Source Files
¶
- chain_provider.go
- client.go
- client_logger.go
- config.go
- connection_reset_error.go
- context.go
- convert_types.go
- credentials.go
- default_retryer.go
- doc.go
- endpoints.go
- errors.go
- handlers.go
- http_client.go
- http_request.go
- jsonvalue.go
- logger.go
- no_op_retryer.go
- offset_reader.go
- request.go
- request_context.go
- request_pagination.go
- response.go
- retryer.go
- static_provider.go
- timeout_read_closer.go
- types.go
- validation.go
- version.go
- waiter.go
Directories
¶
Path | Synopsis |
---|---|
Package arn provides a parser for interacting with Amazon Resource Names.
|
Package arn provides a parser for interacting with Amazon Resource Names. |
Package awserr represents API error interface accessors for the SDK.
|
Package awserr represents API error interface accessors for the SDK. |
Package defaults is a collection of helpers to retrieve the SDK's default configuration and handlers.
|
Package defaults is a collection of helpers to retrieve the SDK's default configuration and handlers. |
Package ec2metadata provides the client for making API calls to the EC2 Instance Metadata service.
|
Package ec2metadata provides the client for making API calls to the EC2 Instance Metadata service. |
Package endpointcreds provides support for retrieving credentials from an arbitrary HTTP endpoint.
|
Package endpointcreds provides support for retrieving credentials from an arbitrary HTTP endpoint. |
Package endpoints provides the types and functionality for defining regions and endpoints, as well as querying those definitions.
|
Package endpoints provides the types and functionality for defining regions and endpoints, as well as querying those definitions. |
protocol
|
|
eventstream
Module
|
|
signer
|
|
v4
Package v4 implements signing for AWS V4 signer Provides request signing for request that need to be signed with AWS V4 Signatures.
|
Package v4 implements signing for AWS V4 signer Provides request signing for request that need to be signed with AWS V4 Signatures. |
Package stscreds are credential Providers to retrieve STS AWS credentials.
|
Package stscreds are credential Providers to retrieve STS AWS credentials. |