{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.CognitoIdentityProvider.ChangePassword
(
ChangePassword (..),
newChangePassword,
changePassword_previousPassword,
changePassword_proposedPassword,
changePassword_accessToken,
ChangePasswordResponse (..),
newChangePasswordResponse,
changePasswordResponse_httpStatus,
)
where
import Amazonka.CognitoIdentityProvider.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data ChangePassword = ChangePassword'
{
ChangePassword -> Sensitive Text
previousPassword :: Core.Sensitive Prelude.Text,
ChangePassword -> Sensitive Text
proposedPassword :: Core.Sensitive Prelude.Text,
ChangePassword -> Sensitive Text
accessToken :: Core.Sensitive Prelude.Text
}
deriving (ChangePassword -> ChangePassword -> Bool
(ChangePassword -> ChangePassword -> Bool)
-> (ChangePassword -> ChangePassword -> Bool) -> Eq ChangePassword
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChangePassword -> ChangePassword -> Bool
$c/= :: ChangePassword -> ChangePassword -> Bool
== :: ChangePassword -> ChangePassword -> Bool
$c== :: ChangePassword -> ChangePassword -> Bool
Prelude.Eq, Int -> ChangePassword -> ShowS
[ChangePassword] -> ShowS
ChangePassword -> String
(Int -> ChangePassword -> ShowS)
-> (ChangePassword -> String)
-> ([ChangePassword] -> ShowS)
-> Show ChangePassword
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChangePassword] -> ShowS
$cshowList :: [ChangePassword] -> ShowS
show :: ChangePassword -> String
$cshow :: ChangePassword -> String
showsPrec :: Int -> ChangePassword -> ShowS
$cshowsPrec :: Int -> ChangePassword -> ShowS
Prelude.Show, (forall x. ChangePassword -> Rep ChangePassword x)
-> (forall x. Rep ChangePassword x -> ChangePassword)
-> Generic ChangePassword
forall x. Rep ChangePassword x -> ChangePassword
forall x. ChangePassword -> Rep ChangePassword x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChangePassword x -> ChangePassword
$cfrom :: forall x. ChangePassword -> Rep ChangePassword x
Prelude.Generic)
newChangePassword ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
ChangePassword
newChangePassword :: Text -> Text -> Text -> ChangePassword
newChangePassword
Text
pPreviousPassword_
Text
pProposedPassword_
Text
pAccessToken_ =
ChangePassword' :: Sensitive Text
-> Sensitive Text -> Sensitive Text -> ChangePassword
ChangePassword'
{ $sel:previousPassword:ChangePassword' :: Sensitive Text
previousPassword =
Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pPreviousPassword_,
$sel:proposedPassword:ChangePassword' :: Sensitive Text
proposedPassword =
Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pProposedPassword_,
$sel:accessToken:ChangePassword' :: Sensitive Text
accessToken = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pAccessToken_
}
changePassword_previousPassword :: Lens.Lens' ChangePassword Prelude.Text
changePassword_previousPassword :: (Text -> f Text) -> ChangePassword -> f ChangePassword
changePassword_previousPassword = (ChangePassword -> Sensitive Text)
-> (ChangePassword -> Sensitive Text -> ChangePassword)
-> Lens
ChangePassword ChangePassword (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChangePassword' {Sensitive Text
previousPassword :: Sensitive Text
$sel:previousPassword:ChangePassword' :: ChangePassword -> Sensitive Text
previousPassword} -> Sensitive Text
previousPassword) (\s :: ChangePassword
s@ChangePassword' {} Sensitive Text
a -> ChangePassword
s {$sel:previousPassword:ChangePassword' :: Sensitive Text
previousPassword = Sensitive Text
a} :: ChangePassword) ((Sensitive Text -> f (Sensitive Text))
-> ChangePassword -> f ChangePassword)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> ChangePassword
-> f ChangePassword
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive
changePassword_proposedPassword :: Lens.Lens' ChangePassword Prelude.Text
changePassword_proposedPassword :: (Text -> f Text) -> ChangePassword -> f ChangePassword
changePassword_proposedPassword = (ChangePassword -> Sensitive Text)
-> (ChangePassword -> Sensitive Text -> ChangePassword)
-> Lens
ChangePassword ChangePassword (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChangePassword' {Sensitive Text
proposedPassword :: Sensitive Text
$sel:proposedPassword:ChangePassword' :: ChangePassword -> Sensitive Text
proposedPassword} -> Sensitive Text
proposedPassword) (\s :: ChangePassword
s@ChangePassword' {} Sensitive Text
a -> ChangePassword
s {$sel:proposedPassword:ChangePassword' :: Sensitive Text
proposedPassword = Sensitive Text
a} :: ChangePassword) ((Sensitive Text -> f (Sensitive Text))
-> ChangePassword -> f ChangePassword)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> ChangePassword
-> f ChangePassword
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive
changePassword_accessToken :: Lens.Lens' ChangePassword Prelude.Text
changePassword_accessToken :: (Text -> f Text) -> ChangePassword -> f ChangePassword
changePassword_accessToken = (ChangePassword -> Sensitive Text)
-> (ChangePassword -> Sensitive Text -> ChangePassword)
-> Lens
ChangePassword ChangePassword (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChangePassword' {Sensitive Text
accessToken :: Sensitive Text
$sel:accessToken:ChangePassword' :: ChangePassword -> Sensitive Text
accessToken} -> Sensitive Text
accessToken) (\s :: ChangePassword
s@ChangePassword' {} Sensitive Text
a -> ChangePassword
s {$sel:accessToken:ChangePassword' :: Sensitive Text
accessToken = Sensitive Text
a} :: ChangePassword) ((Sensitive Text -> f (Sensitive Text))
-> ChangePassword -> f ChangePassword)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> ChangePassword
-> f ChangePassword
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive
instance Core.AWSRequest ChangePassword where
type
AWSResponse ChangePassword =
ChangePasswordResponse
request :: ChangePassword -> Request ChangePassword
request = Service -> ChangePassword -> Request ChangePassword
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy ChangePassword
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ChangePassword)))
response =
(Int
-> ResponseHeaders
-> ()
-> Either String (AWSResponse ChangePassword))
-> Logger
-> Service
-> Proxy ChangePassword
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ChangePassword)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
( \Int
s ResponseHeaders
h ()
x ->
Int -> ChangePasswordResponse
ChangePasswordResponse'
(Int -> ChangePasswordResponse)
-> Either String Int -> Either String ChangePasswordResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable ChangePassword
instance Prelude.NFData ChangePassword
instance Core.ToHeaders ChangePassword where
toHeaders :: ChangePassword -> ResponseHeaders
toHeaders =
ResponseHeaders -> ChangePassword -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSCognitoIdentityProviderService.ChangePassword" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON ChangePassword where
toJSON :: ChangePassword -> Value
toJSON ChangePassword' {Sensitive Text
accessToken :: Sensitive Text
proposedPassword :: Sensitive Text
previousPassword :: Sensitive Text
$sel:accessToken:ChangePassword' :: ChangePassword -> Sensitive Text
$sel:proposedPassword:ChangePassword' :: ChangePassword -> Sensitive Text
$sel:previousPassword:ChangePassword' :: ChangePassword -> Sensitive Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"PreviousPassword" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
previousPassword),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"ProposedPassword" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
proposedPassword),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"AccessToken" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
accessToken)
]
)
instance Core.ToPath ChangePassword where
toPath :: ChangePassword -> ByteString
toPath = ByteString -> ChangePassword -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery ChangePassword where
toQuery :: ChangePassword -> QueryString
toQuery = QueryString -> ChangePassword -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data ChangePasswordResponse = ChangePasswordResponse'
{
ChangePasswordResponse -> Int
httpStatus :: Prelude.Int
}
deriving (ChangePasswordResponse -> ChangePasswordResponse -> Bool
(ChangePasswordResponse -> ChangePasswordResponse -> Bool)
-> (ChangePasswordResponse -> ChangePasswordResponse -> Bool)
-> Eq ChangePasswordResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChangePasswordResponse -> ChangePasswordResponse -> Bool
$c/= :: ChangePasswordResponse -> ChangePasswordResponse -> Bool
== :: ChangePasswordResponse -> ChangePasswordResponse -> Bool
$c== :: ChangePasswordResponse -> ChangePasswordResponse -> Bool
Prelude.Eq, ReadPrec [ChangePasswordResponse]
ReadPrec ChangePasswordResponse
Int -> ReadS ChangePasswordResponse
ReadS [ChangePasswordResponse]
(Int -> ReadS ChangePasswordResponse)
-> ReadS [ChangePasswordResponse]
-> ReadPrec ChangePasswordResponse
-> ReadPrec [ChangePasswordResponse]
-> Read ChangePasswordResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChangePasswordResponse]
$creadListPrec :: ReadPrec [ChangePasswordResponse]
readPrec :: ReadPrec ChangePasswordResponse
$creadPrec :: ReadPrec ChangePasswordResponse
readList :: ReadS [ChangePasswordResponse]
$creadList :: ReadS [ChangePasswordResponse]
readsPrec :: Int -> ReadS ChangePasswordResponse
$creadsPrec :: Int -> ReadS ChangePasswordResponse
Prelude.Read, Int -> ChangePasswordResponse -> ShowS
[ChangePasswordResponse] -> ShowS
ChangePasswordResponse -> String
(Int -> ChangePasswordResponse -> ShowS)
-> (ChangePasswordResponse -> String)
-> ([ChangePasswordResponse] -> ShowS)
-> Show ChangePasswordResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChangePasswordResponse] -> ShowS
$cshowList :: [ChangePasswordResponse] -> ShowS
show :: ChangePasswordResponse -> String
$cshow :: ChangePasswordResponse -> String
showsPrec :: Int -> ChangePasswordResponse -> ShowS
$cshowsPrec :: Int -> ChangePasswordResponse -> ShowS
Prelude.Show, (forall x. ChangePasswordResponse -> Rep ChangePasswordResponse x)
-> (forall x.
Rep ChangePasswordResponse x -> ChangePasswordResponse)
-> Generic ChangePasswordResponse
forall x. Rep ChangePasswordResponse x -> ChangePasswordResponse
forall x. ChangePasswordResponse -> Rep ChangePasswordResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChangePasswordResponse x -> ChangePasswordResponse
$cfrom :: forall x. ChangePasswordResponse -> Rep ChangePasswordResponse x
Prelude.Generic)
newChangePasswordResponse ::
Prelude.Int ->
ChangePasswordResponse
newChangePasswordResponse :: Int -> ChangePasswordResponse
newChangePasswordResponse Int
pHttpStatus_ =
ChangePasswordResponse' :: Int -> ChangePasswordResponse
ChangePasswordResponse' {$sel:httpStatus:ChangePasswordResponse' :: Int
httpStatus = Int
pHttpStatus_}
changePasswordResponse_httpStatus :: Lens.Lens' ChangePasswordResponse Prelude.Int
changePasswordResponse_httpStatus :: (Int -> f Int)
-> ChangePasswordResponse -> f ChangePasswordResponse
changePasswordResponse_httpStatus = (ChangePasswordResponse -> Int)
-> (ChangePasswordResponse -> Int -> ChangePasswordResponse)
-> Lens ChangePasswordResponse ChangePasswordResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChangePasswordResponse' {Int
httpStatus :: Int
$sel:httpStatus:ChangePasswordResponse' :: ChangePasswordResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ChangePasswordResponse
s@ChangePasswordResponse' {} Int
a -> ChangePasswordResponse
s {$sel:httpStatus:ChangePasswordResponse' :: Int
httpStatus = Int
a} :: ChangePasswordResponse)
instance Prelude.NFData ChangePasswordResponse