service.go 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package workspaces
  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/jsonrpc"
  10. )
  11. // This reference provides detailed information about the Amazon WorkSpaces
  12. // operations.
  13. //The service client's operations are safe to be used concurrently.
  14. // It is not safe to mutate any of the client's properties though.
  15. type WorkSpaces struct {
  16. *client.Client
  17. }
  18. // Used for custom client initialization logic
  19. var initClient func(*client.Client)
  20. // Used for custom request initialization logic
  21. var initRequest func(*request.Request)
  22. // A ServiceName is the name of the service the client will make API calls to.
  23. const ServiceName = "workspaces"
  24. // New creates a new instance of the WorkSpaces client with a session.
  25. // If additional configuration is needed for the client instance use the optional
  26. // aws.Config parameter to add your extra config.
  27. //
  28. // Example:
  29. // // Create a WorkSpaces client from just a session.
  30. // svc := workspaces.New(mySession)
  31. //
  32. // // Create a WorkSpaces client with additional configuration
  33. // svc := workspaces.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  34. func New(p client.ConfigProvider, cfgs ...*aws.Config) *WorkSpaces {
  35. c := p.ClientConfig(ServiceName, cfgs...)
  36. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  37. }
  38. // newClient creates, initializes and returns a new service client instance.
  39. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *WorkSpaces {
  40. svc := &WorkSpaces{
  41. Client: client.New(
  42. cfg,
  43. metadata.ClientInfo{
  44. ServiceName: ServiceName,
  45. SigningRegion: signingRegion,
  46. Endpoint: endpoint,
  47. APIVersion: "2015-04-08",
  48. JSONVersion: "1.1",
  49. TargetPrefix: "WorkspacesService",
  50. },
  51. handlers,
  52. ),
  53. }
  54. // Handlers
  55. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  56. svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
  57. svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
  58. svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
  59. svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.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 WorkSpaces operation and runs any
  67. // custom request initialization.
  68. func (c *WorkSpaces) 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. }