{-# 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.AdminDeleteUserAttributes
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes the user attributes in a user pool as an administrator. Works on
-- any user.
--
-- Calling this action requires developer credentials.
module Amazonka.CognitoIdentityProvider.AdminDeleteUserAttributes
  ( -- * Creating a Request
    AdminDeleteUserAttributes (..),
    newAdminDeleteUserAttributes,

    -- * Request Lenses
    adminDeleteUserAttributes_userPoolId,
    adminDeleteUserAttributes_username,
    adminDeleteUserAttributes_userAttributeNames,

    -- * Destructuring the Response
    AdminDeleteUserAttributesResponse (..),
    newAdminDeleteUserAttributesResponse,

    -- * Response Lenses
    adminDeleteUserAttributesResponse_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

-- | Represents the request to delete user attributes as an administrator.
--
-- /See:/ 'newAdminDeleteUserAttributes' smart constructor.
data AdminDeleteUserAttributes = AdminDeleteUserAttributes'
  { -- | The user pool ID for the user pool where you want to delete user
    -- attributes.
    AdminDeleteUserAttributes -> Text
userPoolId :: Prelude.Text,
    -- | The user name of the user from which you would like to delete
    -- attributes.
    AdminDeleteUserAttributes -> Sensitive Text
username :: Core.Sensitive Prelude.Text,
    -- | An array of strings representing the user attribute names you wish to
    -- delete.
    --
    -- For custom attributes, you must prepend the @custom:@ prefix to the
    -- attribute name.
    AdminDeleteUserAttributes -> [Text]
userAttributeNames :: [Prelude.Text]
  }
  deriving (AdminDeleteUserAttributes -> AdminDeleteUserAttributes -> Bool
(AdminDeleteUserAttributes -> AdminDeleteUserAttributes -> Bool)
-> (AdminDeleteUserAttributes -> AdminDeleteUserAttributes -> Bool)
-> Eq AdminDeleteUserAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AdminDeleteUserAttributes -> AdminDeleteUserAttributes -> Bool
$c/= :: AdminDeleteUserAttributes -> AdminDeleteUserAttributes -> Bool
== :: AdminDeleteUserAttributes -> AdminDeleteUserAttributes -> Bool
$c== :: AdminDeleteUserAttributes -> AdminDeleteUserAttributes -> Bool
Prelude.Eq, Int -> AdminDeleteUserAttributes -> ShowS
[AdminDeleteUserAttributes] -> ShowS
AdminDeleteUserAttributes -> String
(Int -> AdminDeleteUserAttributes -> ShowS)
-> (AdminDeleteUserAttributes -> String)
-> ([AdminDeleteUserAttributes] -> ShowS)
-> Show AdminDeleteUserAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AdminDeleteUserAttributes] -> ShowS
$cshowList :: [AdminDeleteUserAttributes] -> ShowS
show :: AdminDeleteUserAttributes -> String
$cshow :: AdminDeleteUserAttributes -> String
showsPrec :: Int -> AdminDeleteUserAttributes -> ShowS
$cshowsPrec :: Int -> AdminDeleteUserAttributes -> ShowS
Prelude.Show, (forall x.
 AdminDeleteUserAttributes -> Rep AdminDeleteUserAttributes x)
-> (forall x.
    Rep AdminDeleteUserAttributes x -> AdminDeleteUserAttributes)
-> Generic AdminDeleteUserAttributes
forall x.
Rep AdminDeleteUserAttributes x -> AdminDeleteUserAttributes
forall x.
AdminDeleteUserAttributes -> Rep AdminDeleteUserAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AdminDeleteUserAttributes x -> AdminDeleteUserAttributes
$cfrom :: forall x.
AdminDeleteUserAttributes -> Rep AdminDeleteUserAttributes x
Prelude.Generic)

-- |
-- Create a value of 'AdminDeleteUserAttributes' 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:
--
-- 'userPoolId', 'adminDeleteUserAttributes_userPoolId' - The user pool ID for the user pool where you want to delete user
-- attributes.
--
-- 'username', 'adminDeleteUserAttributes_username' - The user name of the user from which you would like to delete
-- attributes.
--
-- 'userAttributeNames', 'adminDeleteUserAttributes_userAttributeNames' - An array of strings representing the user attribute names you wish to
-- delete.
--
-- For custom attributes, you must prepend the @custom:@ prefix to the
-- attribute name.
newAdminDeleteUserAttributes ::
  -- | 'userPoolId'
  Prelude.Text ->
  -- | 'username'
  Prelude.Text ->
  AdminDeleteUserAttributes
newAdminDeleteUserAttributes :: Text -> Text -> AdminDeleteUserAttributes
newAdminDeleteUserAttributes Text
pUserPoolId_ Text
pUsername_ =
  AdminDeleteUserAttributes' :: Text -> Sensitive Text -> [Text] -> AdminDeleteUserAttributes
AdminDeleteUserAttributes'
    { $sel:userPoolId:AdminDeleteUserAttributes' :: Text
userPoolId =
        Text
pUserPoolId_,
      $sel:username:AdminDeleteUserAttributes' :: Sensitive Text
username = 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
pUsername_,
      $sel:userAttributeNames:AdminDeleteUserAttributes' :: [Text]
userAttributeNames = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The user pool ID for the user pool where you want to delete user
-- attributes.
adminDeleteUserAttributes_userPoolId :: Lens.Lens' AdminDeleteUserAttributes Prelude.Text
adminDeleteUserAttributes_userPoolId :: (Text -> f Text)
-> AdminDeleteUserAttributes -> f AdminDeleteUserAttributes
adminDeleteUserAttributes_userPoolId = (AdminDeleteUserAttributes -> Text)
-> (AdminDeleteUserAttributes -> Text -> AdminDeleteUserAttributes)
-> Lens
     AdminDeleteUserAttributes AdminDeleteUserAttributes Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminDeleteUserAttributes' {Text
userPoolId :: Text
$sel:userPoolId:AdminDeleteUserAttributes' :: AdminDeleteUserAttributes -> Text
userPoolId} -> Text
userPoolId) (\s :: AdminDeleteUserAttributes
s@AdminDeleteUserAttributes' {} Text
a -> AdminDeleteUserAttributes
s {$sel:userPoolId:AdminDeleteUserAttributes' :: Text
userPoolId = Text
a} :: AdminDeleteUserAttributes)

-- | The user name of the user from which you would like to delete
-- attributes.
adminDeleteUserAttributes_username :: Lens.Lens' AdminDeleteUserAttributes Prelude.Text
adminDeleteUserAttributes_username :: (Text -> f Text)
-> AdminDeleteUserAttributes -> f AdminDeleteUserAttributes
adminDeleteUserAttributes_username = (AdminDeleteUserAttributes -> Sensitive Text)
-> (AdminDeleteUserAttributes
    -> Sensitive Text -> AdminDeleteUserAttributes)
-> Lens
     AdminDeleteUserAttributes
     AdminDeleteUserAttributes
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminDeleteUserAttributes' {Sensitive Text
username :: Sensitive Text
$sel:username:AdminDeleteUserAttributes' :: AdminDeleteUserAttributes -> Sensitive Text
username} -> Sensitive Text
username) (\s :: AdminDeleteUserAttributes
s@AdminDeleteUserAttributes' {} Sensitive Text
a -> AdminDeleteUserAttributes
s {$sel:username:AdminDeleteUserAttributes' :: Sensitive Text
username = Sensitive Text
a} :: AdminDeleteUserAttributes) ((Sensitive Text -> f (Sensitive Text))
 -> AdminDeleteUserAttributes -> f AdminDeleteUserAttributes)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> AdminDeleteUserAttributes
-> f AdminDeleteUserAttributes
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

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

instance Core.AWSRequest AdminDeleteUserAttributes where
  type
    AWSResponse AdminDeleteUserAttributes =
      AdminDeleteUserAttributesResponse
  request :: AdminDeleteUserAttributes -> Request AdminDeleteUserAttributes
request = Service
-> AdminDeleteUserAttributes -> Request AdminDeleteUserAttributes
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy AdminDeleteUserAttributes
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AdminDeleteUserAttributes)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse AdminDeleteUserAttributes))
-> Logger
-> Service
-> Proxy AdminDeleteUserAttributes
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse AdminDeleteUserAttributes)))
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 -> AdminDeleteUserAttributesResponse
AdminDeleteUserAttributesResponse'
            (Int -> AdminDeleteUserAttributesResponse)
-> Either String Int
-> Either String AdminDeleteUserAttributesResponse
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 AdminDeleteUserAttributes

instance Prelude.NFData AdminDeleteUserAttributes

instance Core.ToHeaders AdminDeleteUserAttributes where
  toHeaders :: AdminDeleteUserAttributes -> ResponseHeaders
toHeaders =
    ResponseHeaders -> AdminDeleteUserAttributes -> 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.AdminDeleteUserAttributes" ::
                          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 AdminDeleteUserAttributes where
  toJSON :: AdminDeleteUserAttributes -> Value
toJSON AdminDeleteUserAttributes' {[Text]
Text
Sensitive Text
userAttributeNames :: [Text]
username :: Sensitive Text
userPoolId :: Text
$sel:userAttributeNames:AdminDeleteUserAttributes' :: AdminDeleteUserAttributes -> [Text]
$sel:username:AdminDeleteUserAttributes' :: AdminDeleteUserAttributes -> Sensitive Text
$sel:userPoolId:AdminDeleteUserAttributes' :: AdminDeleteUserAttributes -> 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
"UserPoolId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
userPoolId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Username" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
username),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"UserAttributeNames" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
userAttributeNames)
          ]
      )

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

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

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

-- |
-- Create a value of 'AdminDeleteUserAttributesResponse' 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', 'adminDeleteUserAttributesResponse_httpStatus' - The response's http status code.
newAdminDeleteUserAttributesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AdminDeleteUserAttributesResponse
newAdminDeleteUserAttributesResponse :: Int -> AdminDeleteUserAttributesResponse
newAdminDeleteUserAttributesResponse Int
pHttpStatus_ =
  AdminDeleteUserAttributesResponse' :: Int -> AdminDeleteUserAttributesResponse
AdminDeleteUserAttributesResponse'
    { $sel:httpStatus:AdminDeleteUserAttributesResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance
  Prelude.NFData
    AdminDeleteUserAttributesResponse