service.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package cognitoidentity
  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. // Amazon Cognito is a web service that delivers scoped temporary credentials
  12. // to mobile devices and other untrusted environments. Amazon Cognito uniquely
  13. // identifies a device and supplies the user with a consistent identity over
  14. // the lifetime of an application.
  15. //
  16. // Using Amazon Cognito, you can enable authentication with one or more third-party
  17. // identity providers (Facebook, Google, or Login with Amazon), and you can
  18. // also choose to support unauthenticated access from your app. Cognito delivers
  19. // a unique identifier for each user and acts as an OpenID token provider trusted
  20. // by AWS Security Token Service (STS) to access temporary, limited-privilege
  21. // AWS credentials.
  22. //
  23. // To provide end-user credentials, first make an unsigned call to GetId. If
  24. // the end user is authenticated with one of the supported identity providers,
  25. // set the Logins map with the identity provider token. GetId returns a unique
  26. // identifier for the user.
  27. //
  28. // Next, make an unsigned call to GetCredentialsForIdentity. This call expects
  29. // the same Logins map as the GetId call, as well as the IdentityID originally
  30. // returned by GetId. Assuming your identity pool has been configured via the
  31. // SetIdentityPoolRoles operation, GetCredentialsForIdentity will return AWS
  32. // credentials for your use. If your pool has not been configured with SetIdentityPoolRoles,
  33. // or if you want to follow legacy flow, make an unsigned call to GetOpenIdToken,
  34. // which returns the OpenID token necessary to call STS and retrieve AWS credentials.
  35. // This call expects the same Logins map as the GetId call, as well as the IdentityID
  36. // originally returned by GetId. The token returned by GetOpenIdToken can be
  37. // passed to the STS operation AssumeRoleWithWebIdentity (http://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRoleWithWebIdentity.html)
  38. // to retrieve AWS credentials.
  39. //
  40. // If you want to use Amazon Cognito in an Android, iOS, or Unity application,
  41. // you will probably want to make API calls via the AWS Mobile SDK. To learn
  42. // more, see the AWS Mobile SDK Developer Guide (http://docs.aws.amazon.com/mobile/index.html).
  43. //The service client's operations are safe to be used concurrently.
  44. // It is not safe to mutate any of the client's properties though.
  45. type CognitoIdentity struct {
  46. *client.Client
  47. }
  48. // Used for custom client initialization logic
  49. var initClient func(*client.Client)
  50. // Used for custom request initialization logic
  51. var initRequest func(*request.Request)
  52. // A ServiceName is the name of the service the client will make API calls to.
  53. const ServiceName = "cognito-identity"
  54. // New creates a new instance of the CognitoIdentity client with a session.
  55. // If additional configuration is needed for the client instance use the optional
  56. // aws.Config parameter to add your extra config.
  57. //
  58. // Example:
  59. // // Create a CognitoIdentity client from just a session.
  60. // svc := cognitoidentity.New(mySession)
  61. //
  62. // // Create a CognitoIdentity client with additional configuration
  63. // svc := cognitoidentity.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  64. func New(p client.ConfigProvider, cfgs ...*aws.Config) *CognitoIdentity {
  65. c := p.ClientConfig(ServiceName, cfgs...)
  66. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  67. }
  68. // newClient creates, initializes and returns a new service client instance.
  69. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *CognitoIdentity {
  70. svc := &CognitoIdentity{
  71. Client: client.New(
  72. cfg,
  73. metadata.ClientInfo{
  74. ServiceName: ServiceName,
  75. SigningRegion: signingRegion,
  76. Endpoint: endpoint,
  77. APIVersion: "2014-06-30",
  78. JSONVersion: "1.1",
  79. TargetPrefix: "AWSCognitoIdentityService",
  80. },
  81. handlers,
  82. ),
  83. }
  84. // Handlers
  85. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  86. svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
  87. svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
  88. svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
  89. svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)
  90. // Run custom client initialization if present
  91. if initClient != nil {
  92. initClient(svc.Client)
  93. }
  94. return svc
  95. }
  96. // newRequest creates a new request for a CognitoIdentity operation and runs any
  97. // custom request initialization.
  98. func (c *CognitoIdentity) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  99. req := c.NewRequest(op, params, data)
  100. // Run custom request initialization if present
  101. if initRequest != nil {
  102. initRequest(req)
  103. }
  104. return req
  105. }