service.go 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package machinelearning
  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. // Definition of the public APIs exposed by Amazon Machine Learning
  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 MachineLearning 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 = "machinelearning"
  23. // New creates a new instance of the MachineLearning 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 MachineLearning client from just a session.
  29. // svc := machinelearning.New(mySession)
  30. //
  31. // // Create a MachineLearning client with additional configuration
  32. // svc := machinelearning.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  33. func New(p client.ConfigProvider, cfgs ...*aws.Config) *MachineLearning {
  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) *MachineLearning {
  39. svc := &MachineLearning{
  40. Client: client.New(
  41. cfg,
  42. metadata.ClientInfo{
  43. ServiceName: ServiceName,
  44. SigningRegion: signingRegion,
  45. Endpoint: endpoint,
  46. APIVersion: "2014-12-12",
  47. JSONVersion: "1.1",
  48. TargetPrefix: "AmazonML_20141212",
  49. },
  50. handlers,
  51. ),
  52. }
  53. // Handlers
  54. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  55. svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
  56. svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
  57. svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
  58. svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)
  59. // Run custom client initialization if present
  60. if initClient != nil {
  61. initClient(svc.Client)
  62. }
  63. return svc
  64. }
  65. // newRequest creates a new request for a MachineLearning operation and runs any
  66. // custom request initialization.
  67. func (c *MachineLearning) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  68. req := c.NewRequest(op, params, data)
  69. // Run custom request initialization if present
  70. if initRequest != nil {
  71. initRequest(req)
  72. }
  73. return req
  74. }