service.go 3.0 KB

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