{-# 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-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 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.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.
--
-- /See:/ 'newDeleteUserAttributes' smart constructor.
data DeleteUserAttributes = DeleteUserAttributes'
  { -- | 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.
    DeleteUserAttributes -> [Text]
userAttributeNames :: [Prelude.Text],
    -- | The access token used in the request to delete user attributes.
    DeleteUserAttributes -> Sensitive Text
accessToken :: Core.Sensitive Prelude.Text
  }
  deriving (DeleteUserAttributes -> DeleteUserAttributes -> Bool
(DeleteUserAttributes -> DeleteUserAttributes -> Bool)
-> (DeleteUserAttributes -> DeleteUserAttributes -> Bool)
-> Eq DeleteUserAttributes
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
(Int -> DeleteUserAttributes -> ShowS)
-> (DeleteUserAttributes -> String)
-> ([DeleteUserAttributes] -> ShowS)
-> Show DeleteUserAttributes
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. DeleteUserAttributes -> Rep DeleteUserAttributes x)
-> (forall x. Rep DeleteUserAttributes x -> DeleteUserAttributes)
-> Generic DeleteUserAttributes
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 wish to
-- delete.
--
-- For custom attributes, you must prepend the @custom:@ prefix to the
-- attribute name.
--
-- 'accessToken', 'deleteUserAttributes_accessToken' - The access token used in the request to delete user attributes.
newDeleteUserAttributes ::
  -- | 'accessToken'
  Prelude.Text ->
  DeleteUserAttributes
newDeleteUserAttributes :: Text -> DeleteUserAttributes
newDeleteUserAttributes Text
pAccessToken_ =
  DeleteUserAttributes' :: [Text] -> Sensitive Text -> DeleteUserAttributes
DeleteUserAttributes'
    { $sel:userAttributeNames:DeleteUserAttributes' :: [Text]
userAttributeNames =
        [Text]
forall a. Monoid a => a
Prelude.mempty,
      $sel:accessToken:DeleteUserAttributes' :: 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_
    }

-- | 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.
deleteUserAttributes_userAttributeNames :: Lens.Lens' DeleteUserAttributes [Prelude.Text]
deleteUserAttributes_userAttributeNames :: ([Text] -> f [Text])
-> DeleteUserAttributes -> f DeleteUserAttributes
deleteUserAttributes_userAttributeNames = (DeleteUserAttributes -> [Text])
-> (DeleteUserAttributes -> [Text] -> DeleteUserAttributes)
-> Lens DeleteUserAttributes DeleteUserAttributes [Text] [Text]
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) (([Text] -> f [Text])
 -> DeleteUserAttributes -> f DeleteUserAttributes)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> DeleteUserAttributes
-> f DeleteUserAttributes
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

-- | The access token used in the request to delete user attributes.
deleteUserAttributes_accessToken :: Lens.Lens' DeleteUserAttributes Prelude.Text
deleteUserAttributes_accessToken :: (Text -> f Text) -> DeleteUserAttributes -> f DeleteUserAttributes
deleteUserAttributes_accessToken = (DeleteUserAttributes -> Sensitive Text)
-> (DeleteUserAttributes -> Sensitive Text -> DeleteUserAttributes)
-> Lens
     DeleteUserAttributes
     DeleteUserAttributes
     (Sensitive Text)
     (Sensitive Text)
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) ((Sensitive Text -> f (Sensitive Text))
 -> DeleteUserAttributes -> f DeleteUserAttributes)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> DeleteUserAttributes
-> f DeleteUserAttributes
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 DeleteUserAttributes where
  type
    AWSResponse DeleteUserAttributes =
      DeleteUserAttributesResponse
  request :: DeleteUserAttributes -> Request DeleteUserAttributes
request = Service -> DeleteUserAttributes -> Request DeleteUserAttributes
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteUserAttributes
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteUserAttributes)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteUserAttributes))
-> Logger
-> Service
-> Proxy DeleteUserAttributes
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteUserAttributes)))
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 -> DeleteUserAttributesResponse
DeleteUserAttributesResponse'
            (Int -> DeleteUserAttributesResponse)
-> Either String Int -> Either String DeleteUserAttributesResponse
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 DeleteUserAttributes

instance Prelude.NFData DeleteUserAttributes

instance Core.ToHeaders DeleteUserAttributes where
  toHeaders :: DeleteUserAttributes -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteUserAttributes -> 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.DeleteUserAttributes" ::
                          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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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),
            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 DeleteUserAttributes where
  toPath :: DeleteUserAttributes -> ByteString
toPath = ByteString -> DeleteUserAttributes -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery DeleteUserAttributes where
  toQuery :: DeleteUserAttributes -> QueryString
toQuery = QueryString -> DeleteUserAttributes -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteUserAttributesResponse
 -> DeleteUserAttributesResponse -> Bool)
-> (DeleteUserAttributesResponse
    -> DeleteUserAttributesResponse -> Bool)
-> Eq DeleteUserAttributesResponse
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]
(Int -> ReadS DeleteUserAttributesResponse)
-> ReadS [DeleteUserAttributesResponse]
-> ReadPrec DeleteUserAttributesResponse
-> ReadPrec [DeleteUserAttributesResponse]
-> Read 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
(Int -> DeleteUserAttributesResponse -> ShowS)
-> (DeleteUserAttributesResponse -> String)
-> ([DeleteUserAttributesResponse] -> ShowS)
-> Show DeleteUserAttributesResponse
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.
 DeleteUserAttributesResponse -> Rep DeleteUserAttributesResponse x)
-> (forall x.
    Rep DeleteUserAttributesResponse x -> DeleteUserAttributesResponse)
-> Generic DeleteUserAttributesResponse
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' :: Int -> DeleteUserAttributesResponse
DeleteUserAttributesResponse'
    { $sel:httpStatus:DeleteUserAttributesResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
deleteUserAttributesResponse_httpStatus :: Lens.Lens' DeleteUserAttributesResponse Prelude.Int
deleteUserAttributesResponse_httpStatus :: (Int -> f Int)
-> DeleteUserAttributesResponse -> f DeleteUserAttributesResponse
deleteUserAttributesResponse_httpStatus = (DeleteUserAttributesResponse -> Int)
-> (DeleteUserAttributesResponse
    -> Int -> DeleteUserAttributesResponse)
-> Lens
     DeleteUserAttributesResponse DeleteUserAttributesResponse Int Int
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