service.go 2.9 KB

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