{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.AttributeType
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CognitoIdentityProvider.Types.AttributeType where

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

-- | Specifies whether the attribute is standard or custom.
--
-- /See:/ 'newAttributeType' smart constructor.
data AttributeType = AttributeType'
  { -- | The value of the attribute.
    AttributeType -> Maybe (Sensitive Text)
value :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The name of the attribute.
    AttributeType -> Text
name :: Prelude.Text
  }
  deriving (AttributeType -> AttributeType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttributeType -> AttributeType -> Bool
$c/= :: AttributeType -> AttributeType -> Bool
== :: AttributeType -> AttributeType -> Bool
$c== :: AttributeType -> AttributeType -> Bool
Prelude.Eq, Int -> AttributeType -> ShowS
[AttributeType] -> ShowS
AttributeType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttributeType] -> ShowS
$cshowList :: [AttributeType] -> ShowS
show :: AttributeType -> String
$cshow :: AttributeType -> String
showsPrec :: Int -> AttributeType -> ShowS
$cshowsPrec :: Int -> AttributeType -> ShowS
Prelude.Show, forall x. Rep AttributeType x -> AttributeType
forall x. AttributeType -> Rep AttributeType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttributeType x -> AttributeType
$cfrom :: forall x. AttributeType -> Rep AttributeType x
Prelude.Generic)

-- |
-- Create a value of 'AttributeType' 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:
--
-- 'value', 'attributeType_value' - The value of the attribute.
--
-- 'name', 'attributeType_name' - The name of the attribute.
newAttributeType ::
  -- | 'name'
  Prelude.Text ->
  AttributeType
newAttributeType :: Text -> AttributeType
newAttributeType Text
pName_ =
  AttributeType'
    { $sel:value:AttributeType' :: Maybe (Sensitive Text)
value = forall a. Maybe a
Prelude.Nothing,
      $sel:name:AttributeType' :: Text
name = Text
pName_
    }

-- | The value of the attribute.
attributeType_value :: Lens.Lens' AttributeType (Prelude.Maybe Prelude.Text)
attributeType_value :: Lens' AttributeType (Maybe Text)
attributeType_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttributeType' {Maybe (Sensitive Text)
value :: Maybe (Sensitive Text)
$sel:value:AttributeType' :: AttributeType -> Maybe (Sensitive Text)
value} -> Maybe (Sensitive Text)
value) (\s :: AttributeType
s@AttributeType' {} Maybe (Sensitive Text)
a -> AttributeType
s {$sel:value:AttributeType' :: Maybe (Sensitive Text)
value = Maybe (Sensitive Text)
a} :: AttributeType) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | The name of the attribute.
attributeType_name :: Lens.Lens' AttributeType Prelude.Text
attributeType_name :: Lens' AttributeType Text
attributeType_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttributeType' {Text
name :: Text
$sel:name:AttributeType' :: AttributeType -> Text
name} -> Text
name) (\s :: AttributeType
s@AttributeType' {} Text
a -> AttributeType
s {$sel:name:AttributeType' :: Text
name = Text
a} :: AttributeType)

instance Data.FromJSON AttributeType where
  parseJSON :: Value -> Parser AttributeType
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AttributeType"
      ( \Object
x ->
          Maybe (Sensitive Text) -> Text -> AttributeType
AttributeType'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Value")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Name")
      )

instance Prelude.Hashable AttributeType where
  hashWithSalt :: Int -> AttributeType -> Int
hashWithSalt Int
_salt AttributeType' {Maybe (Sensitive Text)
Text
name :: Text
value :: Maybe (Sensitive Text)
$sel:name:AttributeType' :: AttributeType -> Text
$sel:value:AttributeType' :: AttributeType -> Maybe (Sensitive Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
value
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData AttributeType where
  rnf :: AttributeType -> ()
rnf AttributeType' {Maybe (Sensitive Text)
Text
name :: Text
value :: Maybe (Sensitive Text)
$sel:name:AttributeType' :: AttributeType -> Text
$sel:value:AttributeType' :: AttributeType -> Maybe (Sensitive Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
value seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToJSON AttributeType where
  toJSON :: AttributeType -> Value
toJSON AttributeType' {Maybe (Sensitive Text)
Text
name :: Text
value :: Maybe (Sensitive Text)
$sel:name:AttributeType' :: AttributeType -> Text
$sel:value:AttributeType' :: AttributeType -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Value" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
value,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)
          ]
      )