service.go 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. //The service client's operations are safe to be used concurrently.
  18. // It is not safe to mutate any of the client's properties though.
  19. type ElasticsearchService struct {
  20. *client.Client
  21. }
  22. // Used for custom client initialization logic
  23. var initClient func(*client.Client)
  24. // Used for custom request initialization logic
  25. var initRequest func(*request.Request)
  26. // A ServiceName is the name of the service the client will make API calls to.
  27. const ServiceName = "es"
  28. // New creates a new instance of the ElasticsearchService client with a session.
  29. // If additional configuration is needed for the client instance use the optional
  30. // aws.Config parameter to add your extra config.
  31. //
  32. // Example:
  33. // // Create a ElasticsearchService client from just a session.
  34. // svc := elasticsearchservice.New(mySession)
  35. //
  36. // // Create a ElasticsearchService client with additional configuration
  37. // svc := elasticsearchservice.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  38. func New(p client.ConfigProvider, cfgs ...*aws.Config) *ElasticsearchService {
  39. c := p.ClientConfig(ServiceName, cfgs...)
  40. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  41. }
  42. // newClient creates, initializes and returns a new service client instance.
  43. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *ElasticsearchService {
  44. svc := &ElasticsearchService{
  45. Client: client.New(
  46. cfg,
  47. metadata.ClientInfo{
  48. ServiceName: ServiceName,
  49. SigningRegion: signingRegion,
  50. Endpoint: endpoint,
  51. APIVersion: "2015-01-01",
  52. },
  53. handlers,
  54. ),
  55. }
  56. // Handlers
  57. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  58. svc.Handlers.Build.PushBackNamed(restjson.BuildHandler)
  59. svc.Handlers.Unmarshal.PushBackNamed(restjson.UnmarshalHandler)
  60. svc.Handlers.UnmarshalMeta.PushBackNamed(restjson.UnmarshalMetaHandler)
  61. svc.Handlers.UnmarshalError.PushBackNamed(restjson.UnmarshalErrorHandler)
  62. // Run custom client initialization if present
  63. if initClient != nil {
  64. initClient(svc.Client)
  65. }
  66. return svc
  67. }
  68. // newRequest creates a new request for a ElasticsearchService operation and runs any
  69. // custom request initialization.
  70. func (c *ElasticsearchService) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  71. req := c.NewRequest(op, params, data)
  72. // Run custom request initialization if present
  73. if initRequest != nil {
  74. initRequest(req)
  75. }
  76. return req
  77. }