{-# 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.AwsDynamoDbTableProjection
-- 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.AwsDynamoDbTableProjection where

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

-- | For global and local secondary indexes, identifies the attributes that
-- are copied from the table into the index.
--
-- /See:/ 'newAwsDynamoDbTableProjection' smart constructor.
data AwsDynamoDbTableProjection = AwsDynamoDbTableProjection'
  { -- | The types of attributes that are projected into the index.
    AwsDynamoDbTableProjection -> Maybe Text
projectionType :: Prelude.Maybe Prelude.Text,
    -- | The nonkey attributes that are projected into the index. For each
    -- attribute, provide the attribute name.
    AwsDynamoDbTableProjection -> Maybe [Text]
nonKeyAttributes :: Prelude.Maybe [Prelude.Text]
  }
  deriving (AwsDynamoDbTableProjection -> AwsDynamoDbTableProjection -> Bool
(AwsDynamoDbTableProjection -> AwsDynamoDbTableProjection -> Bool)
-> (AwsDynamoDbTableProjection
    -> AwsDynamoDbTableProjection -> Bool)
-> Eq AwsDynamoDbTableProjection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsDynamoDbTableProjection -> AwsDynamoDbTableProjection -> Bool
$c/= :: AwsDynamoDbTableProjection -> AwsDynamoDbTableProjection -> Bool
== :: AwsDynamoDbTableProjection -> AwsDynamoDbTableProjection -> Bool
$c== :: AwsDynamoDbTableProjection -> AwsDynamoDbTableProjection -> Bool
Prelude.Eq, ReadPrec [AwsDynamoDbTableProjection]
ReadPrec AwsDynamoDbTableProjection
Int -> ReadS AwsDynamoDbTableProjection
ReadS [AwsDynamoDbTableProjection]
(Int -> ReadS AwsDynamoDbTableProjection)
-> ReadS [AwsDynamoDbTableProjection]
-> ReadPrec AwsDynamoDbTableProjection
-> ReadPrec [AwsDynamoDbTableProjection]
-> Read AwsDynamoDbTableProjection
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsDynamoDbTableProjection]
$creadListPrec :: ReadPrec [AwsDynamoDbTableProjection]
readPrec :: ReadPrec AwsDynamoDbTableProjection
$creadPrec :: ReadPrec AwsDynamoDbTableProjection
readList :: ReadS [AwsDynamoDbTableProjection]
$creadList :: ReadS [AwsDynamoDbTableProjection]
readsPrec :: Int -> ReadS AwsDynamoDbTableProjection
$creadsPrec :: Int -> ReadS AwsDynamoDbTableProjection
Prelude.Read, Int -> AwsDynamoDbTableProjection -> ShowS
[AwsDynamoDbTableProjection] -> ShowS
AwsDynamoDbTableProjection -> String
(Int -> AwsDynamoDbTableProjection -> ShowS)
-> (AwsDynamoDbTableProjection -> String)
-> ([AwsDynamoDbTableProjection] -> ShowS)
-> Show AwsDynamoDbTableProjection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsDynamoDbTableProjection] -> ShowS
$cshowList :: [AwsDynamoDbTableProjection] -> ShowS
show :: AwsDynamoDbTableProjection -> String
$cshow :: AwsDynamoDbTableProjection -> String
showsPrec :: Int -> AwsDynamoDbTableProjection -> ShowS
$cshowsPrec :: Int -> AwsDynamoDbTableProjection -> ShowS
Prelude.Show, (forall x.
 AwsDynamoDbTableProjection -> Rep AwsDynamoDbTableProjection x)
-> (forall x.
    Rep AwsDynamoDbTableProjection x -> AwsDynamoDbTableProjection)
-> Generic AwsDynamoDbTableProjection
forall x.
Rep AwsDynamoDbTableProjection x -> AwsDynamoDbTableProjection
forall x.
AwsDynamoDbTableProjection -> Rep AwsDynamoDbTableProjection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsDynamoDbTableProjection x -> AwsDynamoDbTableProjection
$cfrom :: forall x.
AwsDynamoDbTableProjection -> Rep AwsDynamoDbTableProjection x
Prelude.Generic)

-- |
-- Create a value of 'AwsDynamoDbTableProjection' 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:
--
-- 'projectionType', 'awsDynamoDbTableProjection_projectionType' - The types of attributes that are projected into the index.
--
-- 'nonKeyAttributes', 'awsDynamoDbTableProjection_nonKeyAttributes' - The nonkey attributes that are projected into the index. For each
-- attribute, provide the attribute name.
newAwsDynamoDbTableProjection ::
  AwsDynamoDbTableProjection
newAwsDynamoDbTableProjection :: AwsDynamoDbTableProjection
newAwsDynamoDbTableProjection =
  AwsDynamoDbTableProjection' :: Maybe Text -> Maybe [Text] -> AwsDynamoDbTableProjection
AwsDynamoDbTableProjection'
    { $sel:projectionType:AwsDynamoDbTableProjection' :: Maybe Text
projectionType =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nonKeyAttributes:AwsDynamoDbTableProjection' :: Maybe [Text]
nonKeyAttributes = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | The types of attributes that are projected into the index.
awsDynamoDbTableProjection_projectionType :: Lens.Lens' AwsDynamoDbTableProjection (Prelude.Maybe Prelude.Text)
awsDynamoDbTableProjection_projectionType :: (Maybe Text -> f (Maybe Text))
-> AwsDynamoDbTableProjection -> f AwsDynamoDbTableProjection
awsDynamoDbTableProjection_projectionType = (AwsDynamoDbTableProjection -> Maybe Text)
-> (AwsDynamoDbTableProjection
    -> Maybe Text -> AwsDynamoDbTableProjection)
-> Lens
     AwsDynamoDbTableProjection
     AwsDynamoDbTableProjection
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsDynamoDbTableProjection' {Maybe Text
projectionType :: Maybe Text
$sel:projectionType:AwsDynamoDbTableProjection' :: AwsDynamoDbTableProjection -> Maybe Text
projectionType} -> Maybe Text
projectionType) (\s :: AwsDynamoDbTableProjection
s@AwsDynamoDbTableProjection' {} Maybe Text
a -> AwsDynamoDbTableProjection
s {$sel:projectionType:AwsDynamoDbTableProjection' :: Maybe Text
projectionType = Maybe Text
a} :: AwsDynamoDbTableProjection)

-- | The nonkey attributes that are projected into the index. For each
-- attribute, provide the attribute name.
awsDynamoDbTableProjection_nonKeyAttributes :: Lens.Lens' AwsDynamoDbTableProjection (Prelude.Maybe [Prelude.Text])
awsDynamoDbTableProjection_nonKeyAttributes :: (Maybe [Text] -> f (Maybe [Text]))
-> AwsDynamoDbTableProjection -> f AwsDynamoDbTableProjection
awsDynamoDbTableProjection_nonKeyAttributes = (AwsDynamoDbTableProjection -> Maybe [Text])
-> (AwsDynamoDbTableProjection
    -> Maybe [Text] -> AwsDynamoDbTableProjection)
-> Lens
     AwsDynamoDbTableProjection
     AwsDynamoDbTableProjection
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsDynamoDbTableProjection' {Maybe [Text]
nonKeyAttributes :: Maybe [Text]
$sel:nonKeyAttributes:AwsDynamoDbTableProjection' :: AwsDynamoDbTableProjection -> Maybe [Text]
nonKeyAttributes} -> Maybe [Text]
nonKeyAttributes) (\s :: AwsDynamoDbTableProjection
s@AwsDynamoDbTableProjection' {} Maybe [Text]
a -> AwsDynamoDbTableProjection
s {$sel:nonKeyAttributes:AwsDynamoDbTableProjection' :: Maybe [Text]
nonKeyAttributes = Maybe [Text]
a} :: AwsDynamoDbTableProjection) ((Maybe [Text] -> f (Maybe [Text]))
 -> AwsDynamoDbTableProjection -> f AwsDynamoDbTableProjection)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> AwsDynamoDbTableProjection
-> f AwsDynamoDbTableProjection
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON AwsDynamoDbTableProjection where
  parseJSON :: Value -> Parser AwsDynamoDbTableProjection
parseJSON =
    String
-> (Object -> Parser AwsDynamoDbTableProjection)
-> Value
-> Parser AwsDynamoDbTableProjection
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsDynamoDbTableProjection"
      ( \Object
x ->
          Maybe Text -> Maybe [Text] -> AwsDynamoDbTableProjection
AwsDynamoDbTableProjection'
            (Maybe Text -> Maybe [Text] -> AwsDynamoDbTableProjection)
-> Parser (Maybe Text)
-> Parser (Maybe [Text] -> AwsDynamoDbTableProjection)
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
"ProjectionType")
            Parser (Maybe [Text] -> AwsDynamoDbTableProjection)
-> Parser (Maybe [Text]) -> Parser AwsDynamoDbTableProjection
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NonKeyAttributes"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable AwsDynamoDbTableProjection

instance Prelude.NFData AwsDynamoDbTableProjection

instance Core.ToJSON AwsDynamoDbTableProjection where
  toJSON :: AwsDynamoDbTableProjection -> Value
toJSON AwsDynamoDbTableProjection' {Maybe [Text]
Maybe Text
nonKeyAttributes :: Maybe [Text]
projectionType :: Maybe Text
$sel:nonKeyAttributes:AwsDynamoDbTableProjection' :: AwsDynamoDbTableProjection -> Maybe [Text]
$sel:projectionType:AwsDynamoDbTableProjection' :: AwsDynamoDbTableProjection -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ProjectionType" 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
projectionType,
            (Text
"NonKeyAttributes" 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]
nonKeyAttributes
          ]
      )