service.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package cognitosync
  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 Cognito Sync provides an AWS service and client library that enable
  12. // cross-device syncing of application-related user data. High-level client
  13. // libraries are available for both iOS and Android. You can use these libraries
  14. // to persist data locally so that it's available even if the device is offline.
  15. // Developer credentials don't need to be stored on the mobile device to access
  16. // the service. You can use Amazon Cognito to obtain a normalized user ID and
  17. // credentials. User data is persisted in a dataset that can store up to 1 MB
  18. // of key-value pairs, and you can have up to 20 datasets per user identity.
  19. //
  20. // With Amazon Cognito Sync, the data stored for each identity is accessible
  21. // only to credentials assigned to that identity. In order to use the Cognito
  22. // Sync service, you need to make API calls using credentials retrieved with
  23. // Amazon Cognito Identity service (http://docs.aws.amazon.com/cognitoidentity/latest/APIReference/Welcome.html).
  24. //
  25. // If you want to use Cognito Sync in an Android or iOS application, you will
  26. // probably want to make API calls via the AWS Mobile SDK. To learn more, see
  27. // the Developer Guide for Android (http://docs.aws.amazon.com/mobile/sdkforandroid/developerguide/cognito-sync.html)
  28. // and the Developer Guide for iOS (http://docs.aws.amazon.com/mobile/sdkforios/developerguide/cognito-sync.html).
  29. //The service client's operations are safe to be used concurrently.
  30. // It is not safe to mutate any of the client's properties though.
  31. type CognitoSync struct {
  32. *client.Client
  33. }
  34. // Used for custom client initialization logic
  35. var initClient func(*client.Client)
  36. // Used for custom request initialization logic
  37. var initRequest func(*request.Request)
  38. // A ServiceName is the name of the service the client will make API calls to.
  39. const ServiceName = "cognito-sync"
  40. // New creates a new instance of the CognitoSync client with a session.
  41. // If additional configuration is needed for the client instance use the optional
  42. // aws.Config parameter to add your extra config.
  43. //
  44. // Example:
  45. // // Create a CognitoSync client from just a session.
  46. // svc := cognitosync.New(mySession)
  47. //
  48. // // Create a CognitoSync client with additional configuration
  49. // svc := cognitosync.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  50. func New(p client.ConfigProvider, cfgs ...*aws.Config) *CognitoSync {
  51. c := p.ClientConfig(ServiceName, cfgs...)
  52. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  53. }
  54. // newClient creates, initializes and returns a new service client instance.
  55. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *CognitoSync {
  56. svc := &CognitoSync{
  57. Client: client.New(
  58. cfg,
  59. metadata.ClientInfo{
  60. ServiceName: ServiceName,
  61. SigningRegion: signingRegion,
  62. Endpoint: endpoint,
  63. APIVersion: "2014-06-30",
  64. },
  65. handlers,
  66. ),
  67. }
  68. // Handlers
  69. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  70. svc.Handlers.Build.PushBackNamed(restjson.BuildHandler)
  71. svc.Handlers.Unmarshal.PushBackNamed(restjson.UnmarshalHandler)
  72. svc.Handlers.UnmarshalMeta.PushBackNamed(restjson.UnmarshalMetaHandler)
  73. svc.Handlers.UnmarshalError.PushBackNamed(restjson.UnmarshalErrorHandler)
  74. // Run custom client initialization if present
  75. if initClient != nil {
  76. initClient(svc.Client)
  77. }
  78. return svc
  79. }
  80. // newRequest creates a new request for a CognitoSync operation and runs any
  81. // custom request initialization.
  82. func (c *CognitoSync) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  83. req := c.NewRequest(op, params, data)
  84. // Run custom request initialization if present
  85. if initRequest != nil {
  86. initRequest(req)
  87. }
  88. return req
  89. }