service.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
  2. package ecr
  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"
  10. "github.com/aws/aws-sdk-go/private/protocol/jsonrpc"
  11. )
  12. // ECR provides the API operation methods for making requests to
  13. // Amazon EC2 Container Registry. See this package's package overview docs
  14. // for details on the service.
  15. //
  16. // ECR methods are safe to use concurrently. It is not safe to
  17. // modify mutate any of the struct's properties though.
  18. type ECR struct {
  19. *client.Client
  20. }
  21. // Used for custom client initialization logic
  22. var initClient func(*client.Client)
  23. // Used for custom request initialization logic
  24. var initRequest func(*request.Request)
  25. // Service information constants
  26. const (
  27. ServiceName = "ecr" // Name of service.
  28. EndpointsID = "api.ecr" // ID to lookup a service endpoint with.
  29. ServiceID = "ECR" // ServiceID is a unique identifier of a specific service.
  30. )
  31. // New creates a new instance of the ECR client with a session.
  32. // If additional configuration is needed for the client instance use the optional
  33. // aws.Config parameter to add your extra config.
  34. //
  35. // Example:
  36. // mySession := session.Must(session.NewSession())
  37. //
  38. // // Create a ECR client from just a session.
  39. // svc := ecr.New(mySession)
  40. //
  41. // // Create a ECR client with additional configuration
  42. // svc := ecr.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  43. func New(p client.ConfigProvider, cfgs ...*aws.Config) *ECR {
  44. c := p.ClientConfig(EndpointsID, cfgs...)
  45. if c.SigningNameDerived || len(c.SigningName) == 0 {
  46. c.SigningName = "ecr"
  47. }
  48. return newClient(*c.Config, c.Handlers, c.PartitionID, c.Endpoint, c.SigningRegion, c.SigningName)
  49. }
  50. // newClient creates, initializes and returns a new service client instance.
  51. func newClient(cfg aws.Config, handlers request.Handlers, partitionID, endpoint, signingRegion, signingName string) *ECR {
  52. svc := &ECR{
  53. Client: client.New(
  54. cfg,
  55. metadata.ClientInfo{
  56. ServiceName: ServiceName,
  57. ServiceID: ServiceID,
  58. SigningName: signingName,
  59. SigningRegion: signingRegion,
  60. PartitionID: partitionID,
  61. Endpoint: endpoint,
  62. APIVersion: "2015-09-21",
  63. JSONVersion: "1.1",
  64. TargetPrefix: "AmazonEC2ContainerRegistry_V20150921",
  65. },
  66. handlers,
  67. ),
  68. }
  69. // Handlers
  70. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  71. svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
  72. svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
  73. svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
  74. svc.Handlers.UnmarshalError.PushBackNamed(
  75. protocol.NewUnmarshalErrorHandler(jsonrpc.NewUnmarshalTypedError(exceptionFromCode)).NamedHandler(),
  76. )
  77. // Run custom client initialization if present
  78. if initClient != nil {
  79. initClient(svc.Client)
  80. }
  81. return svc
  82. }
  83. // newRequest creates a new request for a ECR operation and runs any
  84. // custom request initialization.
  85. func (c *ECR) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  86. req := c.NewRequest(op, params, data)
  87. // Run custom request initialization if present
  88. if initRequest != nil {
  89. initRequest(req)
  90. }
  91. return req
  92. }