service.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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
  33. // CreateLoadBalancer. Register your instances with the load balancer using
  34. // RegisterInstancesWithLoadBalancer.
  35. //
  36. // All Elastic Load Balancing operations are idempotent, which means that they
  37. // complete at most one time. If you repeat an operation, it succeeds with a
  38. // 200 OK response code.
  39. //The service client's operations are safe to be used concurrently.
  40. // It is not safe to mutate any of the client's properties though.
  41. type ELB struct {
  42. *client.Client
  43. }
  44. // Used for custom client initialization logic
  45. var initClient func(*client.Client)
  46. // Used for custom request initialization logic
  47. var initRequest func(*request.Request)
  48. // A ServiceName is the name of the service the client will make API calls to.
  49. const ServiceName = "elasticloadbalancing"
  50. // New creates a new instance of the ELB client with a session.
  51. // If additional configuration is needed for the client instance use the optional
  52. // aws.Config parameter to add your extra config.
  53. //
  54. // Example:
  55. // // Create a ELB client from just a session.
  56. // svc := elb.New(mySession)
  57. //
  58. // // Create a ELB client with additional configuration
  59. // svc := elb.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  60. func New(p client.ConfigProvider, cfgs ...*aws.Config) *ELB {
  61. c := p.ClientConfig(ServiceName, cfgs...)
  62. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  63. }
  64. // newClient creates, initializes and returns a new service client instance.
  65. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *ELB {
  66. svc := &ELB{
  67. Client: client.New(
  68. cfg,
  69. metadata.ClientInfo{
  70. ServiceName: ServiceName,
  71. SigningRegion: signingRegion,
  72. Endpoint: endpoint,
  73. APIVersion: "2012-06-01",
  74. },
  75. handlers,
  76. ),
  77. }
  78. // Handlers
  79. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  80. svc.Handlers.Build.PushBackNamed(query.BuildHandler)
  81. svc.Handlers.Unmarshal.PushBackNamed(query.UnmarshalHandler)
  82. svc.Handlers.UnmarshalMeta.PushBackNamed(query.UnmarshalMetaHandler)
  83. svc.Handlers.UnmarshalError.PushBackNamed(query.UnmarshalErrorHandler)
  84. // Run custom client initialization if present
  85. if initClient != nil {
  86. initClient(svc.Client)
  87. }
  88. return svc
  89. }
  90. // newRequest creates a new request for a ELB operation and runs any
  91. // custom request initialization.
  92. func (c *ELB) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  93. req := c.NewRequest(op, params, data)
  94. // Run custom request initialization if present
  95. if initRequest != nil {
  96. initRequest(req)
  97. }
  98. return req
  99. }