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

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