module Network.AWS.CognitoIdentity.Types
(
CognitoIdentity
, JSONError
, Credentials
, credentials
, cAccessKeyId
, cExpiration
, cSecretKey
, cSessionToken
, IdentityDescription
, identityDescription
, idCreationDate
, idIdentityId
, idLastModifiedDate
, idLogins
, IdentityPool
, identityPool
, ipAllowUnauthenticatedIdentities
, ipDeveloperProviderName
, ipIdentityPoolId
, ipIdentityPoolName
, ipOpenIdConnectProviderARNs
, ipSupportedLoginProviders
, IdentityPoolShortDescription
, identityPoolShortDescription
, ipsdIdentityPoolId
, ipsdIdentityPoolName
) where
import Network.AWS.Prelude
import Network.AWS.Signing
import qualified GHC.Exts
data CognitoIdentity
instance AWSService CognitoIdentity where
type Sg CognitoIdentity = V4
type Er CognitoIdentity = JSONError
service = service'
where
service' :: Service CognitoIdentity
service' = Service
{ _svcAbbrev = "CognitoIdentity"
, _svcPrefix = "cognito-identity"
, _svcVersion = "2014-06-30"
, _svcTargetPrefix = Just "AWSCognitoIdentityService"
, _svcJSONVersion = Just "1.1"
, _svcHandle = handle
, _svcRetry = retry
}
handle :: Status
-> Maybe (LazyByteString -> ServiceError JSONError)
handle = jsonError statusSuccess service'
retry :: Retry CognitoIdentity
retry = Exponential
{ _retryBase = 0.05
, _retryGrowth = 2
, _retryAttempts = 5
, _retryCheck = check
}
check :: Status
-> JSONError
-> Bool
check (statusCode -> s) (awsErrorCode -> e)
| s == 500 = True
| s == 509 = True
| s == 503 = True
| otherwise = False
data Credentials = Credentials
{ _cAccessKeyId :: Maybe Text
, _cExpiration :: Maybe POSIX
, _cSecretKey :: Maybe Text
, _cSessionToken :: Maybe Text
} deriving (Eq, Ord, Read, Show)
credentials :: Credentials
credentials = Credentials
{ _cAccessKeyId = Nothing
, _cSecretKey = Nothing
, _cSessionToken = Nothing
, _cExpiration = Nothing
}
cAccessKeyId :: Lens' Credentials (Maybe Text)
cAccessKeyId = lens _cAccessKeyId (\s a -> s { _cAccessKeyId = a })
cExpiration :: Lens' Credentials (Maybe UTCTime)
cExpiration = lens _cExpiration (\s a -> s { _cExpiration = a }) . mapping _Time
cSecretKey :: Lens' Credentials (Maybe Text)
cSecretKey = lens _cSecretKey (\s a -> s { _cSecretKey = a })
cSessionToken :: Lens' Credentials (Maybe Text)
cSessionToken = lens _cSessionToken (\s a -> s { _cSessionToken = a })
instance FromJSON Credentials where
parseJSON = withObject "Credentials" $ \o -> Credentials
<$> o .:? "AccessKeyId"
<*> o .:? "Expiration"
<*> o .:? "SecretKey"
<*> o .:? "SessionToken"
instance ToJSON Credentials where
toJSON Credentials{..} = object
[ "AccessKeyId" .= _cAccessKeyId
, "SecretKey" .= _cSecretKey
, "SessionToken" .= _cSessionToken
, "Expiration" .= _cExpiration
]
data IdentityDescription = IdentityDescription
{ _idCreationDate :: Maybe POSIX
, _idIdentityId :: Maybe Text
, _idLastModifiedDate :: Maybe POSIX
, _idLogins :: List "Logins" Text
} deriving (Eq, Ord, Read, Show)
identityDescription :: IdentityDescription
identityDescription = IdentityDescription
{ _idIdentityId = Nothing
, _idLogins = mempty
, _idCreationDate = Nothing
, _idLastModifiedDate = Nothing
}
idCreationDate :: Lens' IdentityDescription (Maybe UTCTime)
idCreationDate = lens _idCreationDate (\s a -> s { _idCreationDate = a }) . mapping _Time
idIdentityId :: Lens' IdentityDescription (Maybe Text)
idIdentityId = lens _idIdentityId (\s a -> s { _idIdentityId = a })
idLastModifiedDate :: Lens' IdentityDescription (Maybe UTCTime)
idLastModifiedDate =
lens _idLastModifiedDate (\s a -> s { _idLastModifiedDate = a })
. mapping _Time
idLogins :: Lens' IdentityDescription [Text]
idLogins = lens _idLogins (\s a -> s { _idLogins = a }) . _List
instance FromJSON IdentityDescription where
parseJSON = withObject "IdentityDescription" $ \o -> IdentityDescription
<$> o .:? "CreationDate"
<*> o .:? "IdentityId"
<*> o .:? "LastModifiedDate"
<*> o .:? "Logins" .!= mempty
instance ToJSON IdentityDescription where
toJSON IdentityDescription{..} = object
[ "IdentityId" .= _idIdentityId
, "Logins" .= _idLogins
, "CreationDate" .= _idCreationDate
, "LastModifiedDate" .= _idLastModifiedDate
]
data IdentityPool = IdentityPool
{ _ipAllowUnauthenticatedIdentities :: Bool
, _ipDeveloperProviderName :: Maybe Text
, _ipIdentityPoolId :: Text
, _ipIdentityPoolName :: Text
, _ipOpenIdConnectProviderARNs :: List "OpenIdConnectProviderARNs" Text
, _ipSupportedLoginProviders :: Map Text Text
} deriving (Eq, Read, Show)
identityPool :: Text
-> Text
-> Bool
-> IdentityPool
identityPool p1 p2 p3 = IdentityPool
{ _ipIdentityPoolId = p1
, _ipIdentityPoolName = p2
, _ipAllowUnauthenticatedIdentities = p3
, _ipSupportedLoginProviders = mempty
, _ipDeveloperProviderName = Nothing
, _ipOpenIdConnectProviderARNs = mempty
}
ipAllowUnauthenticatedIdentities :: Lens' IdentityPool Bool
ipAllowUnauthenticatedIdentities =
lens _ipAllowUnauthenticatedIdentities
(\s a -> s { _ipAllowUnauthenticatedIdentities = a })
ipDeveloperProviderName :: Lens' IdentityPool (Maybe Text)
ipDeveloperProviderName =
lens _ipDeveloperProviderName (\s a -> s { _ipDeveloperProviderName = a })
ipIdentityPoolId :: Lens' IdentityPool Text
ipIdentityPoolId = lens _ipIdentityPoolId (\s a -> s { _ipIdentityPoolId = a })
ipIdentityPoolName :: Lens' IdentityPool Text
ipIdentityPoolName =
lens _ipIdentityPoolName (\s a -> s { _ipIdentityPoolName = a })
ipOpenIdConnectProviderARNs :: Lens' IdentityPool [Text]
ipOpenIdConnectProviderARNs =
lens _ipOpenIdConnectProviderARNs
(\s a -> s { _ipOpenIdConnectProviderARNs = a })
. _List
ipSupportedLoginProviders :: Lens' IdentityPool (HashMap Text Text)
ipSupportedLoginProviders =
lens _ipSupportedLoginProviders
(\s a -> s { _ipSupportedLoginProviders = a })
. _Map
instance FromJSON IdentityPool where
parseJSON = withObject "IdentityPool" $ \o -> IdentityPool
<$> o .: "AllowUnauthenticatedIdentities"
<*> o .:? "DeveloperProviderName"
<*> o .: "IdentityPoolId"
<*> o .: "IdentityPoolName"
<*> o .:? "OpenIdConnectProviderARNs" .!= mempty
<*> o .:? "SupportedLoginProviders" .!= mempty
instance ToJSON IdentityPool where
toJSON IdentityPool{..} = object
[ "IdentityPoolId" .= _ipIdentityPoolId
, "IdentityPoolName" .= _ipIdentityPoolName
, "AllowUnauthenticatedIdentities" .= _ipAllowUnauthenticatedIdentities
, "SupportedLoginProviders" .= _ipSupportedLoginProviders
, "DeveloperProviderName" .= _ipDeveloperProviderName
, "OpenIdConnectProviderARNs" .= _ipOpenIdConnectProviderARNs
]
data IdentityPoolShortDescription = IdentityPoolShortDescription
{ _ipsdIdentityPoolId :: Maybe Text
, _ipsdIdentityPoolName :: Maybe Text
} deriving (Eq, Ord, Read, Show)
identityPoolShortDescription :: IdentityPoolShortDescription
identityPoolShortDescription = IdentityPoolShortDescription
{ _ipsdIdentityPoolId = Nothing
, _ipsdIdentityPoolName = Nothing
}
ipsdIdentityPoolId :: Lens' IdentityPoolShortDescription (Maybe Text)
ipsdIdentityPoolId =
lens _ipsdIdentityPoolId (\s a -> s { _ipsdIdentityPoolId = a })
ipsdIdentityPoolName :: Lens' IdentityPoolShortDescription (Maybe Text)
ipsdIdentityPoolName =
lens _ipsdIdentityPoolName (\s a -> s { _ipsdIdentityPoolName = a })
instance FromJSON IdentityPoolShortDescription where
parseJSON = withObject "IdentityPoolShortDescription" $ \o -> IdentityPoolShortDescription
<$> o .:? "IdentityPoolId"
<*> o .:? "IdentityPoolName"
instance ToJSON IdentityPoolShortDescription where
toJSON IdentityPoolShortDescription{..} = object
[ "IdentityPoolId" .= _ipsdIdentityPoolId
, "IdentityPoolName" .= _ipsdIdentityPoolName
]