service.go 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package elasticsearchservice
  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/restjson"
  10. )
  11. // Use the Amazon Elasticsearch configuration API to create, configure, and
  12. // manage Elasticsearch domains.
  13. //
  14. // The endpoint for configuration service requests is region-specific: es.region.amazonaws.com.
  15. // For example, es.us-east-1.amazonaws.com. For a current list of supported
  16. // regions and endpoints, see Regions and Endpoints (http://docs.aws.amazon.com/general/latest/gr/rande.html#elasticsearch-service-regions"
  17. // target="_blank).
  18. //The service client's operations are safe to be used concurrently.
  19. // It is not safe to mutate any of the client's properties though.
  20. type ElasticsearchService struct {
  21. *client.Client
  22. }
  23. // Used for custom client initialization logic
  24. var initClient func(*client.Client)
  25. // Used for custom request initialization logic
  26. var initRequest func(*request.Request)
  27. // A ServiceName is the name of the service the client will make API calls to.
  28. const ServiceName = "es"
  29. // New creates a new instance of the ElasticsearchService client with a session.
  30. // If additional configuration is needed for the client instance use the optional
  31. // aws.Config parameter to add your extra config.
  32. //
  33. // Example:
  34. // // Create a ElasticsearchService client from just a session.
  35. // svc := elasticsearchservice.New(mySession)
  36. //
  37. // // Create a ElasticsearchService client with additional configuration
  38. // svc := elasticsearchservice.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  39. func New(p client.ConfigProvider, cfgs ...*aws.Config) *ElasticsearchService {
  40. c := p.ClientConfig(ServiceName, cfgs...)
  41. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  42. }
  43. // newClient creates, initializes and returns a new service client instance.
  44. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *ElasticsearchService {
  45. svc := &ElasticsearchService{
  46. Client: client.New(
  47. cfg,
  48. metadata.ClientInfo{
  49. ServiceName: ServiceName,
  50. SigningRegion: signingRegion,
  51. Endpoint: endpoint,
  52. APIVersion: "2015-01-01",
  53. },
  54. handlers,
  55. ),
  56. }
  57. // Handlers
  58. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  59. svc.Handlers.Build.PushBackNamed(restjson.BuildHandler)
  60. svc.Handlers.Unmarshal.PushBackNamed(restjson.UnmarshalHandler)
  61. svc.Handlers.UnmarshalMeta.PushBackNamed(restjson.UnmarshalMetaHandler)
  62. svc.Handlers.UnmarshalError.PushBackNamed(restjson.UnmarshalErrorHandler)
  63. // Run custom client initialization if present
  64. if initClient != nil {
  65. initClient(svc.Client)
  66. }
  67. return svc
  68. }
  69. // newRequest creates a new request for a ElasticsearchService operation and runs any
  70. // custom request initialization.
  71. func (c *ElasticsearchService) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  72. req := c.NewRequest(op, params, data)
  73. // Run custom request initialization if present
  74. if initRequest != nil {
  75. initRequest(req)
  76. }
  77. return req
  78. }