service.go 2.9 KB

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