service.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package ecs
  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/jsonrpc"
  10. )
  11. // Amazon EC2 Container Service (Amazon ECS) is a highly scalable, fast, container
  12. // management service that makes it easy to run, stop, and manage Docker containers
  13. // on a cluster of EC2 instances. Amazon ECS lets you launch and stop container-enabled
  14. // applications with simple API calls, allows you to get the state of your cluster
  15. // from a centralized service, and gives you access to many familiar Amazon
  16. // EC2 features like security groups, Amazon EBS volumes, and IAM roles.
  17. //
  18. // You can use Amazon ECS to schedule the placement of containers across your
  19. // cluster based on your resource needs, isolation policies, and availability
  20. // requirements. Amazon EC2 Container Service eliminates the need for you to
  21. // operate your own cluster management and configuration management systems
  22. // or worry about scaling your management infrastructure.
  23. //The service client's operations are safe to be used concurrently.
  24. // It is not safe to mutate any of the client's properties though.
  25. type ECS struct {
  26. *client.Client
  27. }
  28. // Used for custom client initialization logic
  29. var initClient func(*client.Client)
  30. // Used for custom request initialization logic
  31. var initRequest func(*request.Request)
  32. // A ServiceName is the name of the service the client will make API calls to.
  33. const ServiceName = "ecs"
  34. // New creates a new instance of the ECS client with a session.
  35. // If additional configuration is needed for the client instance use the optional
  36. // aws.Config parameter to add your extra config.
  37. //
  38. // Example:
  39. // // Create a ECS client from just a session.
  40. // svc := ecs.New(mySession)
  41. //
  42. // // Create a ECS client with additional configuration
  43. // svc := ecs.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  44. func New(p client.ConfigProvider, cfgs ...*aws.Config) *ECS {
  45. c := p.ClientConfig(ServiceName, cfgs...)
  46. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  47. }
  48. // newClient creates, initializes and returns a new service client instance.
  49. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *ECS {
  50. svc := &ECS{
  51. Client: client.New(
  52. cfg,
  53. metadata.ClientInfo{
  54. ServiceName: ServiceName,
  55. SigningRegion: signingRegion,
  56. Endpoint: endpoint,
  57. APIVersion: "2014-11-13",
  58. JSONVersion: "1.1",
  59. TargetPrefix: "AmazonEC2ContainerServiceV20141113",
  60. },
  61. handlers,
  62. ),
  63. }
  64. // Handlers
  65. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  66. svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
  67. svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
  68. svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
  69. svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)
  70. // Run custom client initialization if present
  71. if initClient != nil {
  72. initClient(svc.Client)
  73. }
  74. return svc
  75. }
  76. // newRequest creates a new request for a ECS operation and runs any
  77. // custom request initialization.
  78. func (c *ECS) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  79. req := c.NewRequest(op, params, data)
  80. // Run custom request initialization if present
  81. if initRequest != nil {
  82. initRequest(req)
  83. }
  84. return req
  85. }