service.go 4.9 KB

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