service.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package elb
  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/query"
  10. )
  11. // A load balancer distributes incoming traffic across your EC2 instances. This
  12. // enables you to increase the availability of your application. The load balancer
  13. // also monitors the health of its registered instances and ensures that it
  14. // routes traffic only to healthy instances. You configure your load balancer
  15. // to accept incoming traffic by specifying one or more listeners, which are
  16. // configured with a protocol and port number for connections from clients to
  17. // the load balancer and a protocol and port number for connections from the
  18. // load balancer to the instances.
  19. //
  20. // Elastic Load Balancing supports two types of load balancers: Classic load
  21. // balancers and Application load balancers (new). A Classic load balancer makes
  22. // routing and load balancing decisions either at the transport layer (TCP/SSL)
  23. // or the application layer (HTTP/HTTPS), and supports either EC2-Classic or
  24. // a VPC. An Application load balancer makes routing and load balancing decisions
  25. // at the application layer (HTTP/HTTPS), supports path-based routing, and can
  26. // route requests to one or more ports on each EC2 instance or container instance
  27. // in your virtual private cloud (VPC). For more information, see the .
  28. //
  29. // This reference covers the 2012-06-01 API, which supports Classic load balancers.
  30. // The 2015-12-01 API supports Application load balancers.
  31. //
  32. // To get started, create a load balancer with one or more listeners using CreateLoadBalancer.
  33. // Register your instances with the load balancer using RegisterInstancesWithLoadBalancer.
  34. //
  35. // All Elastic Load Balancing operations are idempotent, which means that they
  36. // complete at most one time. If you repeat an operation, it succeeds with a
  37. // 200 OK response code.
  38. //The service client's operations are safe to be used concurrently.
  39. // It is not safe to mutate any of the client's properties though.
  40. type ELB struct {
  41. *client.Client
  42. }
  43. // Used for custom client initialization logic
  44. var initClient func(*client.Client)
  45. // Used for custom request initialization logic
  46. var initRequest func(*request.Request)
  47. // A ServiceName is the name of the service the client will make API calls to.
  48. const ServiceName = "elasticloadbalancing"
  49. // New creates a new instance of the ELB client with a session.
  50. // If additional configuration is needed for the client instance use the optional
  51. // aws.Config parameter to add your extra config.
  52. //
  53. // Example:
  54. // // Create a ELB client from just a session.
  55. // svc := elb.New(mySession)
  56. //
  57. // // Create a ELB client with additional configuration
  58. // svc := elb.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  59. func New(p client.ConfigProvider, cfgs ...*aws.Config) *ELB {
  60. c := p.ClientConfig(ServiceName, cfgs...)
  61. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  62. }
  63. // newClient creates, initializes and returns a new service client instance.
  64. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *ELB {
  65. svc := &ELB{
  66. Client: client.New(
  67. cfg,
  68. metadata.ClientInfo{
  69. ServiceName: ServiceName,
  70. SigningRegion: signingRegion,
  71. Endpoint: endpoint,
  72. APIVersion: "2012-06-01",
  73. },
  74. handlers,
  75. ),
  76. }
  77. // Handlers
  78. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  79. svc.Handlers.Build.PushBackNamed(query.BuildHandler)
  80. svc.Handlers.Unmarshal.PushBackNamed(query.UnmarshalHandler)
  81. svc.Handlers.UnmarshalMeta.PushBackNamed(query.UnmarshalMetaHandler)
  82. svc.Handlers.UnmarshalError.PushBackNamed(query.UnmarshalErrorHandler)
  83. // Run custom client initialization if present
  84. if initClient != nil {
  85. initClient(svc.Client)
  86. }
  87. return svc
  88. }
  89. // newRequest creates a new request for a ELB operation and runs any
  90. // custom request initialization.
  91. func (c *ELB) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  92. req := c.NewRequest(op, params, data)
  93. // Run custom request initialization if present
  94. if initRequest != nil {
  95. initRequest(req)
  96. }
  97. return req
  98. }