service.go 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. A Classic Load Balancer makes routing
  24. // and load balancing decisions either at the transport layer (TCP/SSL) or the
  25. // application layer (HTTP/HTTPS), and supports either EC2-Classic or a VPC.
  26. // An Application Load Balancer makes routing and load balancing decisions at
  27. // 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, complete the following tasks:
  36. //
  37. // Create an Application Load Balancer using CreateLoadBalancer.
  38. //
  39. // Create a target group using CreateTargetGroup.
  40. //
  41. // Register targets for the target group using RegisterTargets.
  42. //
  43. // Create one or more listeners for your load balancer using CreateListener.
  44. //
  45. // (Optional) Create one or more rules for content routing based on URL using
  46. // CreateRule.
  47. //
  48. // To delete an Application Load Balancer and its related resources, complete
  49. // the following tasks:
  50. //
  51. // Delete the load balancer using DeleteLoadBalancer.
  52. //
  53. // Delete the target group using DeleteTargetGroup.
  54. //
  55. // All Elastic Load Balancing operations are idempotent, which means that they
  56. // complete at most one time. If you repeat an operation, it succeeds.
  57. //The service client's operations are safe to be used concurrently.
  58. // It is not safe to mutate any of the client's properties though.
  59. type ELBV2 struct {
  60. *client.Client
  61. }
  62. // Used for custom client initialization logic
  63. var initClient func(*client.Client)
  64. // Used for custom request initialization logic
  65. var initRequest func(*request.Request)
  66. // A ServiceName is the name of the service the client will make API calls to.
  67. const ServiceName = "elasticloadbalancing"
  68. // New creates a new instance of the ELBV2 client with a session.
  69. // If additional configuration is needed for the client instance use the optional
  70. // aws.Config parameter to add your extra config.
  71. //
  72. // Example:
  73. // // Create a ELBV2 client from just a session.
  74. // svc := elbv2.New(mySession)
  75. //
  76. // // Create a ELBV2 client with additional configuration
  77. // svc := elbv2.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  78. func New(p client.ConfigProvider, cfgs ...*aws.Config) *ELBV2 {
  79. c := p.ClientConfig(ServiceName, cfgs...)
  80. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  81. }
  82. // newClient creates, initializes and returns a new service client instance.
  83. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *ELBV2 {
  84. svc := &ELBV2{
  85. Client: client.New(
  86. cfg,
  87. metadata.ClientInfo{
  88. ServiceName: ServiceName,
  89. SigningRegion: signingRegion,
  90. Endpoint: endpoint,
  91. APIVersion: "2015-12-01",
  92. },
  93. handlers,
  94. ),
  95. }
  96. // Handlers
  97. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  98. svc.Handlers.Build.PushBackNamed(query.BuildHandler)
  99. svc.Handlers.Unmarshal.PushBackNamed(query.UnmarshalHandler)
  100. svc.Handlers.UnmarshalMeta.PushBackNamed(query.UnmarshalMetaHandler)
  101. svc.Handlers.UnmarshalError.PushBackNamed(query.UnmarshalErrorHandler)
  102. // Run custom client initialization if present
  103. if initClient != nil {
  104. initClient(svc.Client)
  105. }
  106. return svc
  107. }
  108. // newRequest creates a new request for a ELBV2 operation and runs any
  109. // custom request initialization.
  110. func (c *ELBV2) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  111. req := c.NewRequest(op, params, data)
  112. // Run custom request initialization if present
  113. if initRequest != nil {
  114. initRequest(req)
  115. }
  116. return req
  117. }