service.go 2.6 KB

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