{-# 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.SecurityHub.Types.AwsDynamoDbTableAttributeDefinition
-- 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)
module Amazonka.SecurityHub.Types.AwsDynamoDbTableAttributeDefinition where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains a definition of an attribute for the table.
--
-- /See:/ 'newAwsDynamoDbTableAttributeDefinition' smart constructor.
data AwsDynamoDbTableAttributeDefinition = AwsDynamoDbTableAttributeDefinition'
  { -- | The type of the attribute.
    AwsDynamoDbTableAttributeDefinition -> Maybe Text
attributeType :: Prelude.Maybe Prelude.Text,
    -- | The name of the attribute.
    AwsDynamoDbTableAttributeDefinition -> Maybe Text
attributeName :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsDynamoDbTableAttributeDefinition
-> AwsDynamoDbTableAttributeDefinition -> Bool
(AwsDynamoDbTableAttributeDefinition
 -> AwsDynamoDbTableAttributeDefinition -> Bool)
-> (AwsDynamoDbTableAttributeDefinition
    -> AwsDynamoDbTableAttributeDefinition -> Bool)
-> Eq AwsDynamoDbTableAttributeDefinition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsDynamoDbTableAttributeDefinition
-> AwsDynamoDbTableAttributeDefinition -> Bool
$c/= :: AwsDynamoDbTableAttributeDefinition
-> AwsDynamoDbTableAttributeDefinition -> Bool
== :: AwsDynamoDbTableAttributeDefinition
-> AwsDynamoDbTableAttributeDefinition -> Bool
$c== :: AwsDynamoDbTableAttributeDefinition
-> AwsDynamoDbTableAttributeDefinition -> Bool
Prelude.Eq, ReadPrec [AwsDynamoDbTableAttributeDefinition]
ReadPrec AwsDynamoDbTableAttributeDefinition
Int -> ReadS AwsDynamoDbTableAttributeDefinition
ReadS [AwsDynamoDbTableAttributeDefinition]
(Int -> ReadS AwsDynamoDbTableAttributeDefinition)
-> ReadS [AwsDynamoDbTableAttributeDefinition]
-> ReadPrec AwsDynamoDbTableAttributeDefinition
-> ReadPrec [AwsDynamoDbTableAttributeDefinition]
-> Read AwsDynamoDbTableAttributeDefinition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsDynamoDbTableAttributeDefinition]
$creadListPrec :: ReadPrec [AwsDynamoDbTableAttributeDefinition]
readPrec :: ReadPrec AwsDynamoDbTableAttributeDefinition
$creadPrec :: ReadPrec AwsDynamoDbTableAttributeDefinition
readList :: ReadS [AwsDynamoDbTableAttributeDefinition]
$creadList :: ReadS [AwsDynamoDbTableAttributeDefinition]
readsPrec :: Int -> ReadS AwsDynamoDbTableAttributeDefinition
$creadsPrec :: Int -> ReadS AwsDynamoDbTableAttributeDefinition
Prelude.Read, Int -> AwsDynamoDbTableAttributeDefinition -> ShowS
[AwsDynamoDbTableAttributeDefinition] -> ShowS
AwsDynamoDbTableAttributeDefinition -> String
(Int -> AwsDynamoDbTableAttributeDefinition -> ShowS)
-> (AwsDynamoDbTableAttributeDefinition -> String)
-> ([AwsDynamoDbTableAttributeDefinition] -> ShowS)
-> Show AwsDynamoDbTableAttributeDefinition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsDynamoDbTableAttributeDefinition] -> ShowS
$cshowList :: [AwsDynamoDbTableAttributeDefinition] -> ShowS
show :: AwsDynamoDbTableAttributeDefinition -> String
$cshow :: AwsDynamoDbTableAttributeDefinition -> String
showsPrec :: Int -> AwsDynamoDbTableAttributeDefinition -> ShowS
$cshowsPrec :: Int -> AwsDynamoDbTableAttributeDefinition -> ShowS
Prelude.Show, (forall x.
 AwsDynamoDbTableAttributeDefinition
 -> Rep AwsDynamoDbTableAttributeDefinition x)
-> (forall x.
    Rep AwsDynamoDbTableAttributeDefinition x
    -> AwsDynamoDbTableAttributeDefinition)
-> Generic AwsDynamoDbTableAttributeDefinition
forall x.
Rep AwsDynamoDbTableAttributeDefinition x
-> AwsDynamoDbTableAttributeDefinition
forall x.
AwsDynamoDbTableAttributeDefinition
-> Rep AwsDynamoDbTableAttributeDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsDynamoDbTableAttributeDefinition x
-> AwsDynamoDbTableAttributeDefinition
$cfrom :: forall x.
AwsDynamoDbTableAttributeDefinition
-> Rep AwsDynamoDbTableAttributeDefinition x
Prelude.Generic)

-- |
-- Create a value of 'AwsDynamoDbTableAttributeDefinition' 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:
--
-- 'attributeType', 'awsDynamoDbTableAttributeDefinition_attributeType' - The type of the attribute.
--
-- 'attributeName', 'awsDynamoDbTableAttributeDefinition_attributeName' - The name of the attribute.
newAwsDynamoDbTableAttributeDefinition ::
  AwsDynamoDbTableAttributeDefinition
newAwsDynamoDbTableAttributeDefinition :: AwsDynamoDbTableAttributeDefinition
newAwsDynamoDbTableAttributeDefinition =
  AwsDynamoDbTableAttributeDefinition' :: Maybe Text -> Maybe Text -> AwsDynamoDbTableAttributeDefinition
AwsDynamoDbTableAttributeDefinition'
    { $sel:attributeType:AwsDynamoDbTableAttributeDefinition' :: Maybe Text
attributeType =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:attributeName:AwsDynamoDbTableAttributeDefinition' :: Maybe Text
attributeName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The type of the attribute.
awsDynamoDbTableAttributeDefinition_attributeType :: Lens.Lens' AwsDynamoDbTableAttributeDefinition (Prelude.Maybe Prelude.Text)
awsDynamoDbTableAttributeDefinition_attributeType :: (Maybe Text -> f (Maybe Text))
-> AwsDynamoDbTableAttributeDefinition
-> f AwsDynamoDbTableAttributeDefinition
awsDynamoDbTableAttributeDefinition_attributeType = (AwsDynamoDbTableAttributeDefinition -> Maybe Text)
-> (AwsDynamoDbTableAttributeDefinition
    -> Maybe Text -> AwsDynamoDbTableAttributeDefinition)
-> Lens
     AwsDynamoDbTableAttributeDefinition
     AwsDynamoDbTableAttributeDefinition
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsDynamoDbTableAttributeDefinition' {Maybe Text
attributeType :: Maybe Text
$sel:attributeType:AwsDynamoDbTableAttributeDefinition' :: AwsDynamoDbTableAttributeDefinition -> Maybe Text
attributeType} -> Maybe Text
attributeType) (\s :: AwsDynamoDbTableAttributeDefinition
s@AwsDynamoDbTableAttributeDefinition' {} Maybe Text
a -> AwsDynamoDbTableAttributeDefinition
s {$sel:attributeType:AwsDynamoDbTableAttributeDefinition' :: Maybe Text
attributeType = Maybe Text
a} :: AwsDynamoDbTableAttributeDefinition)

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

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

instance
  Prelude.Hashable
    AwsDynamoDbTableAttributeDefinition

instance
  Prelude.NFData
    AwsDynamoDbTableAttributeDefinition

instance
  Core.ToJSON
    AwsDynamoDbTableAttributeDefinition
  where
  toJSON :: AwsDynamoDbTableAttributeDefinition -> Value
toJSON AwsDynamoDbTableAttributeDefinition' {Maybe Text
attributeName :: Maybe Text
attributeType :: Maybe Text
$sel:attributeName:AwsDynamoDbTableAttributeDefinition' :: AwsDynamoDbTableAttributeDefinition -> Maybe Text
$sel:attributeType:AwsDynamoDbTableAttributeDefinition' :: AwsDynamoDbTableAttributeDefinition -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AttributeType" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
attributeType,
            (Text
"AttributeName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
attributeName
          ]
      )