service.go 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
  2. package s3
  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/restxml"
  10. )
  11. // S3 provides the API operation methods for making requests to
  12. // Amazon Simple Storage Service. See this package's package overview docs
  13. // for details on the service.
  14. //
  15. // S3 methods are safe to use concurrently. It is not safe to
  16. // modify mutate any of the struct's properties though.
  17. type S3 struct {
  18. *client.Client
  19. }
  20. // Used for custom client initialization logic
  21. var initClient func(*client.Client)
  22. // Used for custom request initialization logic
  23. var initRequest func(*request.Request)
  24. // Service information constants
  25. const (
  26. ServiceName = "s3" // Name of service.
  27. EndpointsID = ServiceName // ID to lookup a service endpoint with.
  28. ServiceID = "S3" // ServiceID is a unique identifier of a specific service.
  29. )
  30. // New creates a new instance of the S3 client with a session.
  31. // If additional configuration is needed for the client instance use the optional
  32. // aws.Config parameter to add your extra config.
  33. //
  34. // Example:
  35. //
  36. // mySession := session.Must(session.NewSession())
  37. //
  38. // // Create a S3 client from just a session.
  39. // svc := s3.New(mySession)
  40. //
  41. // // Create a S3 client with additional configuration
  42. // svc := s3.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  43. func New(p client.ConfigProvider, cfgs ...*aws.Config) *S3 {
  44. c := p.ClientConfig(EndpointsID, cfgs...)
  45. if c.SigningNameDerived || len(c.SigningName) == 0 {
  46. c.SigningName = "s3"
  47. }
  48. return newClient(*c.Config, c.Handlers, c.PartitionID, c.Endpoint, c.SigningRegion, c.SigningName, c.ResolvedRegion)
  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, resolvedRegion string) *S3 {
  52. svc := &S3{
  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: "2006-03-01",
  63. ResolvedRegion: resolvedRegion,
  64. },
  65. handlers,
  66. ),
  67. }
  68. // Handlers
  69. svc.Handlers.Sign.PushBackNamed(v4.BuildNamedHandler(v4.SignRequestHandler.Name, func(s *v4.Signer) {
  70. s.DisableURIPathEscaping = true
  71. }))
  72. svc.Handlers.Build.PushBackNamed(restxml.BuildHandler)
  73. svc.Handlers.Unmarshal.PushBackNamed(restxml.UnmarshalHandler)
  74. svc.Handlers.UnmarshalMeta.PushBackNamed(restxml.UnmarshalMetaHandler)
  75. svc.Handlers.UnmarshalError.PushBackNamed(restxml.UnmarshalErrorHandler)
  76. svc.Handlers.BuildStream.PushBackNamed(restxml.BuildHandler)
  77. svc.Handlers.UnmarshalStream.PushBackNamed(restxml.UnmarshalHandler)
  78. // Run custom client initialization if present
  79. if initClient != nil {
  80. initClient(svc.Client)
  81. }
  82. return svc
  83. }
  84. // newRequest creates a new request for a S3 operation and runs any
  85. // custom request initialization.
  86. func (c *S3) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  87. req := c.NewRequest(op, params, data)
  88. // Run custom request initialization if present
  89. if initRequest != nil {
  90. initRequest(req)
  91. }
  92. return req
  93. }