service.go 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package autoscaling
  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. // Auto Scaling is designed to automatically launch or terminate EC2 instances
  12. // based on user-defined policies, schedules, and health checks. Use this service
  13. // in conjunction with the Amazon CloudWatch and Elastic Load Balancing services.
  14. //The service client's operations are safe to be used concurrently.
  15. // It is not safe to mutate any of the client's properties though.
  16. type AutoScaling struct {
  17. *client.Client
  18. }
  19. // Used for custom client initialization logic
  20. var initClient func(*client.Client)
  21. // Used for custom request initialization logic
  22. var initRequest func(*request.Request)
  23. // A ServiceName is the name of the service the client will make API calls to.
  24. const ServiceName = "autoscaling"
  25. // New creates a new instance of the AutoScaling client with a session.
  26. // If additional configuration is needed for the client instance use the optional
  27. // aws.Config parameter to add your extra config.
  28. //
  29. // Example:
  30. // // Create a AutoScaling client from just a session.
  31. // svc := autoscaling.New(mySession)
  32. //
  33. // // Create a AutoScaling client with additional configuration
  34. // svc := autoscaling.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  35. func New(p client.ConfigProvider, cfgs ...*aws.Config) *AutoScaling {
  36. c := p.ClientConfig(ServiceName, cfgs...)
  37. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  38. }
  39. // newClient creates, initializes and returns a new service client instance.
  40. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *AutoScaling {
  41. svc := &AutoScaling{
  42. Client: client.New(
  43. cfg,
  44. metadata.ClientInfo{
  45. ServiceName: ServiceName,
  46. SigningRegion: signingRegion,
  47. Endpoint: endpoint,
  48. APIVersion: "2011-01-01",
  49. },
  50. handlers,
  51. ),
  52. }
  53. // Handlers
  54. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  55. svc.Handlers.Build.PushBackNamed(query.BuildHandler)
  56. svc.Handlers.Unmarshal.PushBackNamed(query.UnmarshalHandler)
  57. svc.Handlers.UnmarshalMeta.PushBackNamed(query.UnmarshalMetaHandler)
  58. svc.Handlers.UnmarshalError.PushBackNamed(query.UnmarshalErrorHandler)
  59. // Run custom client initialization if present
  60. if initClient != nil {
  61. initClient(svc.Client)
  62. }
  63. return svc
  64. }
  65. // newRequest creates a new request for a AutoScaling operation and runs any
  66. // custom request initialization.
  67. func (c *AutoScaling) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  68. req := c.NewRequest(op, params, data)
  69. // Run custom request initialization if present
  70. if initRequest != nil {
  71. initRequest(req)
  72. }
  73. return req
  74. }