service.go 3.0 KB

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