Documentation ¶
Overview ¶
Package aws provides core functionality for making requests to AWS services.
Index ¶
- Constants
- Variables
- func AfterRetryHandler(r *Request)
- 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 BuildContentLength(r *Request)
- 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 Int(v int) *int
- 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 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 SendHandler(r *Request)
- 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 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 UserAgentHandler(r *Request)
- func ValidateEndpointHandler(r *Request)
- func ValidateParameters(r *Request)
- func ValidateResponseHandler(r *Request)
- type Config
- func (c Config) Copy() *Config
- func (c Config) Merge(other *Config) *Config
- func (c *Config) WithCredentials(creds *credentials.Credentials) *Config
- func (c *Config) WithDisableComputeChecksums(disable bool) *Config
- func (c *Config) WithDisableParamValidation(disable bool) *Config
- func (c *Config) WithDisableSSL(disable bool) *Config
- func (c *Config) WithEndpoint(endpoint string) *Config
- func (c *Config) WithHTTPClient(client *http.Client) *Config
- func (c *Config) WithLogLevel(level LogLevelType) *Config
- func (c *Config) WithLogger(logger Logger) *Config
- func (c *Config) WithMaxRetries(max int) *Config
- func (c *Config) WithRegion(region string) *Config
- func (c *Config) WithS3ForcePathStyle(force bool) *Config
- type HandlerList
- type Handlers
- type LogLevelType
- type Logger
- type Operation
- type Paginator
- type ReaderSeekerCloser
- type Request
- func (r *Request) Build() error
- func (r *Request) DataFilled() bool
- func (r *Request) EachPage(fn func(data interface{}, isLastPage bool) (shouldContinue bool)) error
- func (r *Request) HasNextPage() bool
- func (r *Request) NextPage() *Request
- func (r *Request) ParamsFilled() bool
- func (r *Request) Presign(expireTime time.Duration) (string, error)
- func (r *Request) Send() error
- func (r *Request) SetBufferBody(buf []byte)
- func (r *Request) SetReaderBody(reader io.ReadSeeker)
- func (r *Request) SetStringBody(s string)
- func (r *Request) Sign() error
- func (r *Request) WillRetry() bool
- type Service
Constants ¶
const DefaultRetries = -1
The default number of retries for a service. The value of -1 indicates that the service specific retry default will be used.
const SDKName = "aws-sdk-go"
SDKName is the name of this AWS SDK
const SDKVersion = "0.7.0"
SDKVersion is the version of this SDK
Variables ¶
var ( // ErrMissingRegion is an error that is returned if region configuration is // not found. // // @readonly ErrMissingRegion error = 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 error = awserr.New("MissingEndpoint", "'Endpoint' configuration is required for this service", nil) )
var DefaultChainCredentials = credentials.NewChainCredentials( []credentials.Provider{ &credentials.EnvProvider{}, &credentials.SharedCredentialsProvider{Filename: "", Profile: ""}, &credentials.EC2RoleProvider{ExpiryWindow: 5 * time.Minute}, })
DefaultChainCredentials is a Credentials which will find the first available credentials Value from the list of Providers.
This should be used in the default case. Once the type of credentials are known switching to the specific Credentials will be more efficient.
var DefaultConfig = NewConfig(). WithCredentials(DefaultChainCredentials). WithRegion(os.Getenv("AWS_REGION")). WithHTTPClient(http.DefaultClient). WithMaxRetries(DefaultRetries). WithLogger(NewDefaultLogger()). WithLogLevel(LogOff)
DefaultConfig is the default all service configuration will be based off of. By default, all clients use this structure for initialization options unless a custom configuration object is passed in.
You may modify this global structure to change all default configuration in the SDK. Note that configuration options are copied by value, so any modifications must happen before constructing a client.
Functions ¶
func AfterRetryHandler ¶
func AfterRetryHandler(r *Request)
AfterRetryHandler performs final checks to determine if the request should be retried and how long to delay.
func BoolMap ¶ added in v0.7.0
BoolMap converts a string map of bool values into a string map of bool pointers
func BoolSlice ¶ added in v0.7.0
BoolSlice converts a slice of bool values into a slice of bool pointers
func BoolValue ¶ added in v0.7.0
BoolValue returns the value of the bool pointer passed in or false if the pointer is nil.
func BoolValueMap ¶ added in v0.7.0
BoolValueMap converts a string map of bool pointers into a string map of bool values
func BoolValueSlice ¶ added in v0.7.0
BoolValueSlice converts a slice of bool pointers into a slice of bool values
func BuildContentLength ¶
func BuildContentLength(r *Request)
BuildContentLength builds the content length of a request based on the body, or will use the HTTPRequest.Header's "Content-Length" if defined. If unable to determine request body length and no "Content-Length" was specified it will panic.
func Float64Map ¶ added in v0.7.0
Float64Map converts a string map of float64 values into a string map of float64 pointers
func Float64Slice ¶ added in v0.7.0
Float64Slice converts a slice of float64 values into a slice of float64 pointers
func Float64Value ¶ added in v0.7.0
Float64Value returns the value of the float64 pointer passed in or 0 if the pointer is nil.
func Float64ValueMap ¶ added in v0.7.0
Float64ValueMap converts a string map of float64 pointers into a string map of float64 values
func Float64ValueSlice ¶ added in v0.7.0
Float64ValueSlice converts a slice of float64 pointers into a slice of float64 values
func Int64Map ¶ added in v0.7.0
Int64Map converts a string map of int64 values into a string map of int64 pointers
func Int64Slice ¶ added in v0.7.0
Int64Slice converts a slice of int64 values into a slice of int64 pointers
func Int64Value ¶ added in v0.7.0
Int64Value returns the value of the int64 pointer passed in or 0 if the pointer is nil.
func Int64ValueMap ¶ added in v0.7.0
Int64ValueMap converts a string map of int64 pointers into a string map of int64 values
func Int64ValueSlice ¶ added in v0.7.0
Int64ValueSlice converts a slice of int64 pointers into a slice of int64 values
func IntMap ¶ added in v0.7.0
IntMap converts a string map of int values into a string map of int pointers
func IntSlice ¶ added in v0.7.0
IntSlice converts a slice of int values into a slice of int pointers
func IntValue ¶ added in v0.7.0
IntValue returns the value of the int pointer passed in or 0 if the pointer is nil.
func IntValueMap ¶ added in v0.7.0
IntValueMap converts a string map of int pointers into a string map of int values
func IntValueSlice ¶ added in v0.7.0
IntValueSlice converts a slice of int pointers into a slice of int values
func SendHandler ¶
func SendHandler(r *Request)
SendHandler is a request handler to send service request using HTTP client.
func StringMap ¶ added in v0.7.0
StringMap converts a string map of string values into a string map of string pointers
func StringSlice ¶ added in v0.7.0
StringSlice converts a slice of string values into a slice of string pointers
func StringValue ¶ added in v0.7.0
StringValue returns the value of the string pointer passed in or "" if the pointer is nil.
func StringValueMap ¶ added in v0.7.0
StringValueMap converts a string map of string pointers into a string map of string values
func StringValueSlice ¶ added in v0.7.0
StringValueSlice converts a slice of string pointers into a slice of string values
func TimeMap ¶ added in v0.7.0
TimeMap converts a string map of time.Time values into a string map of time.Time pointers
func TimeSlice ¶ added in v0.7.0
TimeSlice converts a slice of time.Time values into a slice of time.Time pointers
func TimeValue ¶ added in v0.7.0
TimeValue returns the value of the time.Time pointer passed in or time.Time{} if the pointer is nil.
func TimeValueMap ¶ added in v0.7.0
TimeValueMap converts a string map of time.Time pointers into a string map of time.Time values
func TimeValueSlice ¶ added in v0.7.0
TimeValueSlice converts a slice of time.Time pointers into a slice of time.Time values
func UserAgentHandler ¶
func UserAgentHandler(r *Request)
UserAgentHandler is a request handler for injecting User agent into requests.
func ValidateEndpointHandler ¶
func ValidateEndpointHandler(r *Request)
ValidateEndpointHandler is a request handler to validate a request had the appropriate Region and Endpoint set. Will set r.Error if the endpoint or region is not valid.
func ValidateParameters ¶
func ValidateParameters(r *Request)
ValidateParameters is a request handler to validate the input parameters. Validating parameters only has meaning if done prior to the request being sent.
func ValidateResponseHandler ¶
func ValidateResponseHandler(r *Request)
ValidateResponseHandler is a request handler to validate service response.
Types ¶
type Config ¶
type Config struct { // The credentials object to use when signing requests. Defaults to // {DefaultChainCredentials}. Credentials *credentials.Credentials // An optional endpoint URL (hostname only or fully qualified URI) // that overrides the default generated endpoint for a client. Set this // to `""` to use the default generated endpoint. // // @note You must still provide a `Region` value when specifying an // endpoint for a client. Endpoint *string // 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 // AWS Regions and Endpoints Region *string // Set this to `true` to disable SSL when sending requests. Defaults // to `false`. DisableSSL *bool // The HTTP client to use when sending requests. Defaults to // `http.DefaultClient`. HTTPClient *http.Client // 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 *LogLevelType // The logger writer interface to write logging messages to. Defaults to // standard out. Logger Logger // The maximum number of times that a request will be retried for failures. // Defaults to -1, which defers the max retry setting to the service specific // configuration. MaxRetries *int // Disables semantic parameter validation, which validates input for missing // required fields and/or other semantic request input errors. DisableParamValidation *bool // Disables the computation of request and response checksums, e.g., // CRC32 checksums in Amazon DynamoDB. DisableComputeChecksums *bool // Set this to `true` to force the request to use path-style addressing, // i.e., `http://s3.amazonaws.com/BUCKET/KEY`. By default, the S3 client will // use virtual hosted bucket addressing when possible // (`http://BUCKET.s3.amazonaws.com/KEY`). // // @note This configuration option is specific to the Amazon S3 service. // @see http://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html // Amazon S3: Virtual Hosting of Buckets S3ForcePathStyle *bool }
A Config provides service configuration for service clients. By default, all clients will use the {DefaultConfig} structure.
func NewConfig ¶ added in v0.7.0
func NewConfig() *Config
NewConfig returns a new Config pointer that can be chained with builder methods to set multiple configuration values inline without using pointers.
svc := s3.New(aws.NewConfig().WithRegion("us-west-2").WithMaxRetries(10))
func (Config) Merge ¶
Merge returns a new Config with the other Config's attribute values merged into this Config. If the other Config's attribute is nil it will not be merged into the new Config to be returned.
func (*Config) WithCredentials ¶ added in v0.7.0
func (c *Config) WithCredentials(creds *credentials.Credentials) *Config
WithCredentials sets a config Credentials value returning a Config pointer for chaining.
func (*Config) WithDisableComputeChecksums ¶ added in v0.7.0
WithDisableComputeChecksums sets a config DisableComputeChecksums value returning a Config pointer for chaining.
func (*Config) WithDisableParamValidation ¶ added in v0.7.0
WithDisableParamValidation sets a config DisableParamValidation value returning a Config pointer for chaining.
func (*Config) WithDisableSSL ¶ added in v0.7.0
WithDisableSSL sets a config DisableSSL value returning a Config pointer for chaining.
func (*Config) WithEndpoint ¶ added in v0.7.0
WithEndpoint sets a config Endpoint value returning a Config pointer for chaining.
func (*Config) WithHTTPClient ¶ added in v0.7.0
WithHTTPClient sets a config HTTPClient value returning a Config pointer for chaining.
func (*Config) WithLogLevel ¶ added in v0.7.0
func (c *Config) WithLogLevel(level LogLevelType) *Config
WithLogLevel sets a config LogLevel value returning a Config pointer for chaining.
func (*Config) WithLogger ¶ added in v0.7.0
WithLogger sets a config Logger value returning a Config pointer for chaining.
func (*Config) WithMaxRetries ¶ added in v0.7.0
WithMaxRetries sets a config MaxRetries value returning a Config pointer for chaining.
func (*Config) WithRegion ¶ added in v0.7.0
WithRegion sets a config Region value returning a Config pointer for chaining.
func (*Config) WithS3ForcePathStyle ¶ added in v0.7.0
WithS3ForcePathStyle sets a config S3ForcePathStyle value returning a Config pointer for chaining.
type HandlerList ¶
type HandlerList struct {
// 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 handlers f to the back of the handler list.
func (*HandlerList) PushFront ¶
func (l *HandlerList) PushFront(f ...func(*Request))
PushFront pushes handlers f to the front of the handler list.
func (*HandlerList) Run ¶
func (l *HandlerList) Run(r *Request)
Run executes all handlers in the list with a given request object.
type Handlers ¶
type Handlers struct { Validate HandlerList Build HandlerList Sign HandlerList Send HandlerList ValidateResponse HandlerList Unmarshal HandlerList UnmarshalMeta HandlerList UnmarshalError HandlerList Retry HandlerList AfterRetry HandlerList }
A Handlers provides a collection of request handlers for various stages of handling requests.
type LogLevelType ¶ added in v0.7.0
type LogLevelType uint
A LogLevelType 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 LogLevelType = 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 LogLevelType = 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 )
Debug Logging Sub Levels
func LogLevel ¶ added in v0.7.0
func LogLevel(l LogLevelType) *LogLevelType
LogLevel returns the pointer to a LogLevel. Should be used to workaround not being able to take the address of a non-composite literal.
func (*LogLevelType) AtLeast ¶ added in v0.7.0
func (l *LogLevelType) AtLeast(v LogLevelType) bool
AtLeast returns true if this LogLevel is at least high enough to satisfies v. Is safe to use on nil value LogLevelTypes. If LogLevel is nill, will default to LogOff comparison.
func (*LogLevelType) Matches ¶ added in v0.7.0
func (l *LogLevelType) Matches(v LogLevelType) bool
Matches returns true if the v LogLevel is enabled by this LogLevel. Should be used with logging sub levels. Is safe to use on nil value LogLevelTypes. If LogLevel is nill, will default to LogOff comparison.
func (*LogLevelType) Value ¶ added in v0.7.0
func (l *LogLevelType) Value() LogLevelType
Value returns the LogLevel value or the default value LogOff if the LogLevel is nil. Safe to use on nil value LogLevelTypes.
type Logger ¶ added in v0.7.0
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 ¶ added in v0.7.0
func NewDefaultLogger() Logger
NewDefaultLogger returns a Logger which will write log messages to stdout, and use same formatting runes as the stdlib log.Logger
type Paginator ¶
type Paginator struct { InputTokens []string OutputTokens []string LimitToken string TruncationToken string }
Paginator keeps track of pagination configuration for an API operation.
type ReaderSeekerCloser ¶
type ReaderSeekerCloser struct {
// contains filtered or unexported fields
}
ReaderSeekerCloser represents a reader that can also delegate io.Seeker and io.Closer interfaces to the underlying object if they are available.
func ReadSeekCloser ¶
func ReadSeekCloser(r io.Reader) ReaderSeekerCloser
ReadSeekCloser wraps a io.Reader returning a ReaderSeakerCloser
func (ReaderSeekerCloser) Close ¶
func (r ReaderSeekerCloser) Close() error
Close closes the ReaderSeekerCloser.
If the ReaderSeekerCloser is not an io.Closer nothing will be done.
func (ReaderSeekerCloser) Read ¶
func (r ReaderSeekerCloser) Read(p []byte) (int, error)
Read reads from the reader up to size of p. The number of bytes read, and error if it occurred will be returned.
If the reader is not an io.Reader zero bytes read, and nil error will be returned.
Performs the same functionality as io.Reader Read
func (ReaderSeekerCloser) Seek ¶
func (r ReaderSeekerCloser) Seek(offset int64, whence int) (int64, error)
Seek sets the offset for the next Read to offset, interpreted according to whence: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 means relative to the end. Seek returns the new offset and an error, if any.
If the ReaderSeekerCloser is not an io.Seeker nothing will be done.
type Request ¶
type Request struct { *Service Handlers Handlers Time time.Time ExpireTime time.Duration Operation *Operation HTTPRequest *http.Request HTTPResponse *http.Response Body io.ReadSeeker Params interface{} Error error Data interface{} RequestID string RetryCount uint Retryable *bool RetryDelay time.Duration // contains filtered or unexported fields }
A Request is the service request to be made.
func NewRequest ¶
func NewRequest(service *Service, operation *Operation, params interface{}, data interface{}) *Request
NewRequest returns a new Request pointer for the service API operation and parameters.
Params is any value of input parameters to be the request payload. Data is pointer value to an object which the request's response payload will be deserialized to.
func (*Request) Build ¶
Build will build the request's object so it can be signed and sent to the service. Build will also validate all the request's parameters. Anny additional build Handlers set on this request will be run in the order they were set.
The request will only be built once. Multiple calls to build will have no effect.
If any Validate or Build errors occur the build will stop and the error which occurred will be returned.
func (*Request) DataFilled ¶
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 ¶
EachPage iterates over each page of a paginated request object. The fn parameter should be a function with the following sample signature:
func(page *T, lastPage bool) bool { return true // return false to stop iterating }
Where "T" is the structure type matching the output structure of the given operation. For example, a request object generated by DynamoDB.ListTablesRequest() would expect to see dynamodb.ListTablesOutput as the structure "T". The lastPage value represents whether the page is the last page of data or not. The return value of this function should return true to keep iterating or false to stop.
func (*Request) HasNextPage ¶
HasNextPage returns true if this request has more pages of data available.
func (*Request) NextPage ¶
NextPage returns a new Request that can be executed to return the next page of result data. Call .Send() on this request to execute it.
func (*Request) ParamsFilled ¶
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) 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.
func (*Request) SetBufferBody ¶
SetBufferBody will set the request's body bytes that will be sent to the service API.
func (*Request) SetReaderBody ¶
func (r *Request) SetReaderBody(reader io.ReadSeeker)
SetReaderBody will set the request's body reader.
func (*Request) SetStringBody ¶
SetStringBody sets the body of the request to be backed by a string.
type Service ¶
type Service struct { Config *Config Handlers Handlers ServiceName string APIVersion string Endpoint string SigningName string SigningRegion string JSONVersion string TargetPrefix string RetryRules func(*Request) time.Duration ShouldRetry func(*Request) bool DefaultMaxRetries uint }
A Service implements the base service request and response handling used by all services.
func NewService ¶
NewService will return a pointer to a new Server object initialized.
func (*Service) AddDebugHandlers ¶
func (s *Service) AddDebugHandlers()
AddDebugHandlers injects debug logging handlers into the service to log request debug information.
func (*Service) MaxRetries ¶
MaxRetries returns the number of maximum returns the service will use to make an individual API request.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package awserr represents API error interface accessors for the SDK.
|
Package awserr represents API error interface accessors for the SDK. |
Package credentials provides credential retrieval and management The Credentials is the primary method of getting access to and managing credentials Values.
|
Package credentials provides credential retrieval and management The Credentials is the primary method of getting access to and managing credentials Values. |
stscreds
Package stscreds are credential Providers to retrieve STS AWS credentials.
|
Package stscreds are credential Providers to retrieve STS AWS credentials. |