github.com/aavshr/aws-sdk-go@v1.41.3/service/timestreamwrite/service.go (about) 1 // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. 2 3 package timestreamwrite 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 // TimestreamWrite provides the API operation methods for making requests to 17 // Amazon Timestream Write. See this package's package overview docs 18 // for details on the service. 19 // 20 // TimestreamWrite methods are safe to use concurrently. It is not safe to 21 // modify mutate any of the struct's properties though. 22 type TimestreamWrite 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 = "Timestream Write" // Name of service. 36 EndpointsID = "ingest.timestream" // ID to lookup a service endpoint with. 37 ServiceID = "Timestream Write" // ServiceID is a unique identifier of a specific service. 38 ) 39 40 // New creates a new instance of the TimestreamWrite 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 TimestreamWrite client from just a session. 48 // svc := timestreamwrite.New(mySession) 49 // 50 // // Create a TimestreamWrite client with additional configuration 51 // svc := timestreamwrite.New(mySession, aws.NewConfig().WithRegion("us-west-2")) 52 func New(p client.ConfigProvider, cfgs ...*aws.Config) *TimestreamWrite { 53 c := p.ClientConfig(EndpointsID, cfgs...) 54 if c.SigningNameDerived || len(c.SigningName) == 0 { 55 c.SigningName = "timestream" 56 } 57 return newClient(*c.Config, c.Handlers, c.PartitionID, c.Endpoint, c.SigningRegion, c.SigningName) 58 } 59 60 // newClient creates, initializes and returns a new service client instance. 61 func newClient(cfg aws.Config, handlers request.Handlers, partitionID, endpoint, signingRegion, signingName string) *TimestreamWrite { 62 svc := &TimestreamWrite{ 63 Client: client.New( 64 cfg, 65 metadata.ClientInfo{ 66 ServiceName: ServiceName, 67 ServiceID: ServiceID, 68 SigningName: signingName, 69 SigningRegion: signingRegion, 70 PartitionID: partitionID, 71 Endpoint: endpoint, 72 APIVersion: "2018-11-01", 73 JSONVersion: "1.0", 74 TargetPrefix: "Timestream_20181101", 75 }, 76 handlers, 77 ), 78 } 79 svc.endpointCache = crr.NewEndpointCache(10) 80 81 // Handlers 82 svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler) 83 svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler) 84 svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler) 85 svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler) 86 svc.Handlers.UnmarshalError.PushBackNamed( 87 protocol.NewUnmarshalErrorHandler(jsonrpc.NewUnmarshalTypedError(exceptionFromCode)).NamedHandler(), 88 ) 89 90 // Run custom client initialization if present 91 if initClient != nil { 92 initClient(svc.Client) 93 } 94 95 return svc 96 } 97 98 // newRequest creates a new request for a TimestreamWrite operation and runs any 99 // custom request initialization. 100 func (c *TimestreamWrite) newRequest(op *request.Operation, params, data interface{}) *request.Request { 101 req := c.NewRequest(op, params, data) 102 103 // Run custom request initialization if present 104 if initRequest != nil { 105 initRequest(req) 106 } 107 108 return req 109 }