6 "github.com/aws/aws-sdk-go/aws"
7 "github.com/aws/aws-sdk-go/aws/client/metadata"
8 "github.com/aws/aws-sdk-go/aws/request"
11 // A Config provides configuration to a service client instance.
14 Handlers request.Handlers
19 // States that the signing name did not come from a modeled source but
20 // was derived based on other data. Used by service client constructors
21 // to determine if the signin name can be overriden based on metadata the
23 SigningNameDerived bool
26 // ConfigProvider provides a generic way for a service client to receive
27 // the ClientConfig without circular dependencies.
28 type ConfigProvider interface {
29 ClientConfig(serviceName string, cfgs ...*aws.Config) Config
32 // ConfigNoResolveEndpointProvider same as ConfigProvider except it will not
33 // resolve the endpoint automatically. The service client's endpoint must be
34 // provided via the aws.Config.Endpoint field.
35 type ConfigNoResolveEndpointProvider interface {
36 ClientConfigNoResolveEndpoint(cfgs ...*aws.Config) Config
39 // A Client implements the base client request and response handling
40 // used by all service clients.
46 Handlers request.Handlers
49 // New will return a pointer to a new initialized service client.
50 func New(cfg aws.Config, info metadata.ClientInfo, handlers request.Handlers, options ...func(*Client)) *Client {
54 Handlers: handlers.Copy(),
57 switch retryer, ok := cfg.Retryer.(request.Retryer); {
60 case cfg.Retryer != nil && cfg.Logger != nil:
61 s := fmt.Sprintf("WARNING: %T does not implement request.Retryer; using DefaultRetryer instead", cfg.Retryer)
65 maxRetries := aws.IntValue(cfg.MaxRetries)
66 if cfg.MaxRetries == nil || maxRetries == aws.UseServiceDefaultRetries {
69 svc.Retryer = DefaultRetryer{NumMaxRetries: maxRetries}
72 svc.AddDebugHandlers()
74 for _, option := range options {
81 // NewRequest returns a new Request pointer for the service API
82 // operation and parameters.
83 func (c *Client) NewRequest(operation *request.Operation, params interface{}, data interface{}) *request.Request {
84 return request.New(c.Config, c.ClientInfo, c.Handlers, c.Retryer, operation, params, data)
87 // AddDebugHandlers injects debug logging handlers into the service to log request
89 func (c *Client) AddDebugHandlers() {
90 if !c.Config.LogLevel.AtLeast(aws.LogDebug) {
94 c.Handlers.Send.PushFrontNamed(LogHTTPRequestHandler)
95 c.Handlers.Send.PushBackNamed(LogHTTPResponseHandler)