service.go 2.6 KB

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