service.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
  2. package appsync
  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. // AppSync provides the API operation methods for making requests to
  12. // AWS AppSync. See this package's package overview docs
  13. // for details on the service.
  14. //
  15. // AppSync methods are safe to use concurrently. It is not safe to
  16. // modify mutate any of the struct's properties though.
  17. type AppSync 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. // Service information constants
  25. const (
  26. ServiceName = "appsync" // Name of service.
  27. EndpointsID = ServiceName // ID to lookup a service endpoint with.
  28. ServiceID = "AppSync" // ServiceID is a unique identifer of a specific service.
  29. )
  30. // New creates a new instance of the AppSync client with a session.
  31. // If additional configuration is needed for the client instance use the optional
  32. // aws.Config parameter to add your extra config.
  33. //
  34. // Example:
  35. // // Create a AppSync client from just a session.
  36. // svc := appsync.New(mySession)
  37. //
  38. // // Create a AppSync client with additional configuration
  39. // svc := appsync.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  40. func New(p client.ConfigProvider, cfgs ...*aws.Config) *AppSync {
  41. c := p.ClientConfig(EndpointsID, cfgs...)
  42. if c.SigningNameDerived || len(c.SigningName) == 0 {
  43. c.SigningName = "appsync"
  44. }
  45. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion, c.SigningName)
  46. }
  47. // newClient creates, initializes and returns a new service client instance.
  48. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion, signingName string) *AppSync {
  49. svc := &AppSync{
  50. Client: client.New(
  51. cfg,
  52. metadata.ClientInfo{
  53. ServiceName: ServiceName,
  54. ServiceID: ServiceID,
  55. SigningName: signingName,
  56. SigningRegion: signingRegion,
  57. Endpoint: endpoint,
  58. APIVersion: "2017-07-25",
  59. JSONVersion: "1.1",
  60. },
  61. handlers,
  62. ),
  63. }
  64. // Handlers
  65. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  66. svc.Handlers.Build.PushBackNamed(restjson.BuildHandler)
  67. svc.Handlers.Unmarshal.PushBackNamed(restjson.UnmarshalHandler)
  68. svc.Handlers.UnmarshalMeta.PushBackNamed(restjson.UnmarshalMetaHandler)
  69. svc.Handlers.UnmarshalError.PushBackNamed(restjson.UnmarshalErrorHandler)
  70. // Run custom client initialization if present
  71. if initClient != nil {
  72. initClient(svc.Client)
  73. }
  74. return svc
  75. }
  76. // newRequest creates a new request for a AppSync operation and runs any
  77. // custom request initialization.
  78. func (c *AppSync) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  79. req := c.NewRequest(op, params, data)
  80. // Run custom request initialization if present
  81. if initRequest != nil {
  82. initRequest(req)
  83. }
  84. return req
  85. }