{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CognitoIdentityProvider.DeleteUserAttributes
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes the attributes for a user.
module Amazonka.CognitoIdentityProvider.DeleteUserAttributes
  ( -- * Creating a Request
    DeleteUserAttributes (..),
    newDeleteUserAttributes,

    -- * Request Lenses
    deleteUserAttributes_userAttributeNames,
    deleteUserAttributes_accessToken,

    -- * Destructuring the Response
    DeleteUserAttributesResponse (..),
    newDeleteUserAttributesResponse,

    -- * Response Lenses
    deleteUserAttributesResponse_httpStatus,
  )
where

import Amazonka.CognitoIdentityProvider.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Represents the request to delete user attributes.
--
-- /See:/ 'newDeleteUserAttributes' smart constructor.
data DeleteUserAttributes = DeleteUserAttributes'
  { -- | An array of strings representing the user attribute names you want to
    -- delete.
    --
    -- For custom attributes, you must prependattach the @custom:@ prefix to
    -- the front of the attribute name.
    DeleteUserAttributes -> [Text]
userAttributeNames :: [Prelude.Text],
    -- | A valid access token that Amazon Cognito issued to the user whose
    -- attributes you want to delete.
    DeleteUserAttributes -> Sensitive Text
accessToken :: Data.Sensitive Prelude.Text
  }
  deriving (DeleteUserAttributes -> DeleteUserAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteUserAttributes -> DeleteUserAttributes -> Bool
$c/= :: DeleteUserAttributes -> DeleteUserAttributes -> Bool
== :: DeleteUserAttributes -> DeleteUserAttributes -> Bool
$c== :: DeleteUserAttributes -> DeleteUserAttributes -> Bool
Prelude.Eq, Int -> DeleteUserAttributes -> ShowS
[DeleteUserAttributes] -> ShowS
DeleteUserAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteUserAttributes] -> ShowS
$cshowList :: [DeleteUserAttributes] -> ShowS
show :: DeleteUserAttributes -> String
$cshow :: DeleteUserAttributes -> String
showsPrec :: Int -> DeleteUserAttributes -> ShowS
$cshowsPrec :: Int -> DeleteUserAttributes -> ShowS
Prelude.Show, forall x. Rep DeleteUserAttributes x -> DeleteUserAttributes
forall x. DeleteUserAttributes -> Rep DeleteUserAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteUserAttributes x -> DeleteUserAttributes
$cfrom :: forall x. DeleteUserAttributes -> Rep DeleteUserAttributes x
Prelude.Generic)

-- |
-- Create a value of 'DeleteUserAttributes' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'userAttributeNames', 'deleteUserAttributes_userAttributeNames' - An array of strings representing the user attribute names you want to
-- delete.
--
-- For custom attributes, you must prependattach the @custom:@ prefix to
-- the front of the attribute name.
--
-- 'accessToken', 'deleteUserAttributes_accessToken' - A valid access token that Amazon Cognito issued to the user whose
-- attributes you want to delete.
newDeleteUserAttributes ::
  -- | 'accessToken'
  Prelude.Text ->
  DeleteUserAttributes
newDeleteUserAttributes :: Text -> DeleteUserAttributes
newDeleteUserAttributes Text
pAccessToken_ =
  DeleteUserAttributes'
    { $sel:userAttributeNames:DeleteUserAttributes' :: [Text]
userAttributeNames =
        forall a. Monoid a => a
Prelude.mempty,
      $sel:accessToken:DeleteUserAttributes' :: Sensitive Text
accessToken = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pAccessToken_
    }

-- | An array of strings representing the user attribute names you want to
-- delete.
--
-- For custom attributes, you must prependattach the @custom:@ prefix to
-- the front of the attribute name.
deleteUserAttributes_userAttributeNames :: Lens.Lens' DeleteUserAttributes [Prelude.Text]
deleteUserAttributes_userAttributeNames :: Lens' DeleteUserAttributes [Text]
deleteUserAttributes_userAttributeNames = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteUserAttributes' {[Text]
userAttributeNames :: [Text]
$sel:userAttributeNames:DeleteUserAttributes' :: DeleteUserAttributes -> [Text]
userAttributeNames} -> [Text]
userAttributeNames) (\s :: DeleteUserAttributes
s@DeleteUserAttributes' {} [Text]
a -> DeleteUserAttributes
s {$sel:userAttributeNames:DeleteUserAttributes' :: [Text]
userAttributeNames = [Text]
a} :: DeleteUserAttributes) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A valid access token that Amazon Cognito issued to the user whose
-- attributes you want to delete.
deleteUserAttributes_accessToken :: Lens.Lens' DeleteUserAttributes Prelude.Text
deleteUserAttributes_accessToken :: Lens' DeleteUserAttributes Text
deleteUserAttributes_accessToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteUserAttributes' {Sensitive Text
accessToken :: Sensitive Text
$sel:accessToken:DeleteUserAttributes' :: DeleteUserAttributes -> Sensitive Text
accessToken} -> Sensitive Text
accessToken) (\s :: DeleteUserAttributes
s@DeleteUserAttributes' {} Sensitive Text
a -> DeleteUserAttributes
s {$sel:accessToken:DeleteUserAttributes' :: Sensitive Text
accessToken = Sensitive Text
a} :: DeleteUserAttributes) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

instance Core.AWSRequest DeleteUserAttributes where
  type
    AWSResponse DeleteUserAttributes =
      DeleteUserAttributesResponse
  request :: (Service -> Service)
-> DeleteUserAttributes -> Request DeleteUserAttributes
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteUserAttributes
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteUserAttributes)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteUserAttributesResponse
DeleteUserAttributesResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteUserAttributes where
  hashWithSalt :: Int -> DeleteUserAttributes -> Int
hashWithSalt Int
_salt DeleteUserAttributes' {[Text]
Sensitive Text
accessToken :: Sensitive Text
userAttributeNames :: [Text]
$sel:accessToken:DeleteUserAttributes' :: DeleteUserAttributes -> Sensitive Text
$sel:userAttributeNames:DeleteUserAttributes' :: DeleteUserAttributes -> [Text]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
userAttributeNames
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
accessToken

instance Prelude.NFData DeleteUserAttributes where
  rnf :: DeleteUserAttributes -> ()
rnf DeleteUserAttributes' {[Text]
Sensitive Text
accessToken :: Sensitive Text
userAttributeNames :: [Text]
$sel:accessToken:DeleteUserAttributes' :: DeleteUserAttributes -> Sensitive Text
$sel:userAttributeNames:DeleteUserAttributes' :: DeleteUserAttributes -> [Text]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf [Text]
userAttributeNames
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
accessToken

instance Data.ToHeaders DeleteUserAttributes where
  toHeaders :: DeleteUserAttributes -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSCognitoIdentityProviderService.DeleteUserAttributes" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteUserAttributes where
  toJSON :: DeleteUserAttributes -> Value
toJSON DeleteUserAttributes' {[Text]
Sensitive Text
accessToken :: Sensitive Text
userAttributeNames :: [Text]
$sel:accessToken:DeleteUserAttributes' :: DeleteUserAttributes -> Sensitive Text
$sel:userAttributeNames:DeleteUserAttributes' :: DeleteUserAttributes -> [Text]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"UserAttributeNames" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
userAttributeNames),
            forall a. a -> Maybe a
Prelude.Just (Key
"AccessToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
accessToken)
          ]
      )

instance Data.ToPath DeleteUserAttributes where
  toPath :: DeleteUserAttributes -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery DeleteUserAttributes where
  toQuery :: DeleteUserAttributes -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | Represents the response from the server to delete user attributes.
--
-- /See:/ 'newDeleteUserAttributesResponse' smart constructor.
data DeleteUserAttributesResponse = DeleteUserAttributesResponse'
  { -- | The response's http status code.
    DeleteUserAttributesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteUserAttributesResponse
-> DeleteUserAttributesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteUserAttributesResponse
-> DeleteUserAttributesResponse -> Bool
$c/= :: DeleteUserAttributesResponse
-> DeleteUserAttributesResponse -> Bool
== :: DeleteUserAttributesResponse
-> DeleteUserAttributesResponse -> Bool
$c== :: DeleteUserAttributesResponse
-> DeleteUserAttributesResponse -> Bool
Prelude.Eq, ReadPrec [DeleteUserAttributesResponse]
ReadPrec DeleteUserAttributesResponse
Int -> ReadS DeleteUserAttributesResponse
ReadS [DeleteUserAttributesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteUserAttributesResponse]
$creadListPrec :: ReadPrec [DeleteUserAttributesResponse]
readPrec :: ReadPrec DeleteUserAttributesResponse
$creadPrec :: ReadPrec DeleteUserAttributesResponse
readList :: ReadS [DeleteUserAttributesResponse]
$creadList :: ReadS [DeleteUserAttributesResponse]
readsPrec :: Int -> ReadS DeleteUserAttributesResponse
$creadsPrec :: Int -> ReadS DeleteUserAttributesResponse
Prelude.Read, Int -> DeleteUserAttributesResponse -> ShowS
[DeleteUserAttributesResponse] -> ShowS
DeleteUserAttributesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteUserAttributesResponse] -> ShowS
$cshowList :: [DeleteUserAttributesResponse] -> ShowS
show :: DeleteUserAttributesResponse -> String
$cshow :: DeleteUserAttributesResponse -> String
showsPrec :: Int -> DeleteUserAttributesResponse -> ShowS
$cshowsPrec :: Int -> DeleteUserAttributesResponse -> ShowS
Prelude.Show, forall x.
Rep DeleteUserAttributesResponse x -> DeleteUserAttributesResponse
forall x.
DeleteUserAttributesResponse -> Rep DeleteUserAttributesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteUserAttributesResponse x -> DeleteUserAttributesResponse
$cfrom :: forall x.
DeleteUserAttributesResponse -> Rep DeleteUserAttributesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteUserAttributesResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'httpStatus', 'deleteUserAttributesResponse_httpStatus' - The response's http status code.
newDeleteUserAttributesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteUserAttributesResponse
newDeleteUserAttributesResponse :: Int -> DeleteUserAttributesResponse
newDeleteUserAttributesResponse Int
pHttpStatus_ =
  DeleteUserAttributesResponse'
    { $sel:httpStatus:DeleteUserAttributesResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
deleteUserAttributesResponse_httpStatus :: Lens.Lens' DeleteUserAttributesResponse Prelude.Int
deleteUserAttributesResponse_httpStatus :: Lens' DeleteUserAttributesResponse Int
deleteUserAttributesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteUserAttributesResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteUserAttributesResponse' :: DeleteUserAttributesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DeleteUserAttributesResponse
s@DeleteUserAttributesResponse' {} Int
a -> DeleteUserAttributesResponse
s {$sel:httpStatus:DeleteUserAttributesResponse' :: Int
httpStatus = Int
a} :: DeleteUserAttributesResponse)

instance Prelude.NFData DeleteUserAttributesResponse where
  rnf :: DeleteUserAttributesResponse -> ()
rnf DeleteUserAttributesResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteUserAttributesResponse' :: DeleteUserAttributesResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus