service.go 3.0 KB

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