github.com/aavshr/aws-sdk-go@v1.41.3/service/simpledb/service.go (about)

     1  // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
     2  
     3  package simpledb
     4  
     5  import (
     6  	"github.com/aavshr/aws-sdk-go/aws"
     7  	"github.com/aavshr/aws-sdk-go/aws/client"
     8  	"github.com/aavshr/aws-sdk-go/aws/client/metadata"
     9  	"github.com/aavshr/aws-sdk-go/aws/corehandlers"
    10  	"github.com/aavshr/aws-sdk-go/aws/request"
    11  	"github.com/aavshr/aws-sdk-go/private/protocol/query"
    12  	"github.com/aavshr/aws-sdk-go/private/signer/v2"
    13  )
    14  
    15  // SimpleDB provides the API operation methods for making requests to
    16  // Amazon SimpleDB. See this package's package overview docs
    17  // for details on the service.
    18  //
    19  // SimpleDB methods are safe to use concurrently. It is not safe to
    20  // modify mutate any of the struct's properties though.
    21  type SimpleDB struct {
    22  	*client.Client
    23  }
    24  
    25  // Used for custom client initialization logic
    26  var initClient func(*client.Client)
    27  
    28  // Used for custom request initialization logic
    29  var initRequest func(*request.Request)
    30  
    31  // Service information constants
    32  const (
    33  	ServiceName = "sdb"       // Name of service.
    34  	EndpointsID = ServiceName // ID to lookup a service endpoint with.
    35  	ServiceID   = "SimpleDB"  // ServiceID is a unique identifier of a specific service.
    36  )
    37  
    38  // New creates a new instance of the SimpleDB client with a session.
    39  // If additional configuration is needed for the client instance use the optional
    40  // aws.Config parameter to add your extra config.
    41  //
    42  // Example:
    43  //     mySession := session.Must(session.NewSession())
    44  //
    45  //     // Create a SimpleDB client from just a session.
    46  //     svc := simpledb.New(mySession)
    47  //
    48  //     // Create a SimpleDB client with additional configuration
    49  //     svc := simpledb.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
    50  func New(p client.ConfigProvider, cfgs ...*aws.Config) *SimpleDB {
    51  	c := p.ClientConfig(EndpointsID, cfgs...)
    52  	return newClient(*c.Config, c.Handlers, c.PartitionID, c.Endpoint, c.SigningRegion, c.SigningName)
    53  }
    54  
    55  // newClient creates, initializes and returns a new service client instance.
    56  func newClient(cfg aws.Config, handlers request.Handlers, partitionID, endpoint, signingRegion, signingName string) *SimpleDB {
    57  	svc := &SimpleDB{
    58  		Client: client.New(
    59  			cfg,
    60  			metadata.ClientInfo{
    61  				ServiceName:   ServiceName,
    62  				ServiceID:     ServiceID,
    63  				SigningName:   signingName,
    64  				SigningRegion: signingRegion,
    65  				PartitionID:   partitionID,
    66  				Endpoint:      endpoint,
    67  				APIVersion:    "2009-04-15",
    68  			},
    69  			handlers,
    70  		),
    71  	}
    72  
    73  	// Handlers
    74  	svc.Handlers.Sign.PushBackNamed(v2.SignRequestHandler)
    75  	svc.Handlers.Sign.PushBackNamed(corehandlers.BuildContentLengthHandler)
    76  	svc.Handlers.Build.PushBackNamed(query.BuildHandler)
    77  	svc.Handlers.Unmarshal.PushBackNamed(query.UnmarshalHandler)
    78  	svc.Handlers.UnmarshalMeta.PushBackNamed(query.UnmarshalMetaHandler)
    79  	svc.Handlers.UnmarshalError.PushBackNamed(query.UnmarshalErrorHandler)
    80  
    81  	// Run custom client initialization if present
    82  	if initClient != nil {
    83  		initClient(svc.Client)
    84  	}
    85  
    86  	return svc
    87  }
    88  
    89  // newRequest creates a new request for a SimpleDB operation and runs any
    90  // custom request initialization.
    91  func (c *SimpleDB) newRequest(op *request.Operation, params, data interface{}) *request.Request {
    92  	req := c.NewRequest(op, params, data)
    93  
    94  	// Run custom request initialization if present
    95  	if initRequest != nil {
    96  		initRequest(req)
    97  	}
    98  
    99  	return req
   100  }