{-# 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 #-}
module Amazonka.DynamoDB.Types.Projection where
import qualified Amazonka.Core as Core
import Amazonka.DynamoDB.Types.ProjectionType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Projection = Projection'
{
Projection -> Maybe ProjectionType
projectionType :: Prelude.Maybe ProjectionType,
Projection -> Maybe (NonEmpty Text)
nonKeyAttributes :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text)
}
deriving (Projection -> Projection -> Bool
(Projection -> Projection -> Bool)
-> (Projection -> Projection -> Bool) -> Eq Projection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Projection -> Projection -> Bool
$c/= :: Projection -> Projection -> Bool
== :: Projection -> Projection -> Bool
$c== :: Projection -> Projection -> Bool
Prelude.Eq, ReadPrec [Projection]
ReadPrec Projection
Int -> ReadS Projection
ReadS [Projection]
(Int -> ReadS Projection)
-> ReadS [Projection]
-> ReadPrec Projection
-> ReadPrec [Projection]
-> Read Projection
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Projection]
$creadListPrec :: ReadPrec [Projection]
readPrec :: ReadPrec Projection
$creadPrec :: ReadPrec Projection
readList :: ReadS [Projection]
$creadList :: ReadS [Projection]
readsPrec :: Int -> ReadS Projection
$creadsPrec :: Int -> ReadS Projection
Prelude.Read, Int -> Projection -> ShowS
[Projection] -> ShowS
Projection -> String
(Int -> Projection -> ShowS)
-> (Projection -> String)
-> ([Projection] -> ShowS)
-> Show Projection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Projection] -> ShowS
$cshowList :: [Projection] -> ShowS
show :: Projection -> String
$cshow :: Projection -> String
showsPrec :: Int -> Projection -> ShowS
$cshowsPrec :: Int -> Projection -> ShowS
Prelude.Show, (forall x. Projection -> Rep Projection x)
-> (forall x. Rep Projection x -> Projection) -> Generic Projection
forall x. Rep Projection x -> Projection
forall x. Projection -> Rep Projection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Projection x -> Projection
$cfrom :: forall x. Projection -> Rep Projection x
Prelude.Generic)
newProjection ::
Projection
newProjection :: Projection
newProjection =
Projection' :: Maybe ProjectionType -> Maybe (NonEmpty Text) -> Projection
Projection'
{ $sel:projectionType:Projection' :: Maybe ProjectionType
projectionType = Maybe ProjectionType
forall a. Maybe a
Prelude.Nothing,
$sel:nonKeyAttributes:Projection' :: Maybe (NonEmpty Text)
nonKeyAttributes = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing
}
projection_projectionType :: Lens.Lens' Projection (Prelude.Maybe ProjectionType)
projection_projectionType :: (Maybe ProjectionType -> f (Maybe ProjectionType))
-> Projection -> f Projection
projection_projectionType = (Projection -> Maybe ProjectionType)
-> (Projection -> Maybe ProjectionType -> Projection)
-> Lens
Projection Projection (Maybe ProjectionType) (Maybe ProjectionType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Projection' {Maybe ProjectionType
projectionType :: Maybe ProjectionType
$sel:projectionType:Projection' :: Projection -> Maybe ProjectionType
projectionType} -> Maybe ProjectionType
projectionType) (\s :: Projection
s@Projection' {} Maybe ProjectionType
a -> Projection
s {$sel:projectionType:Projection' :: Maybe ProjectionType
projectionType = Maybe ProjectionType
a} :: Projection)
projection_nonKeyAttributes :: Lens.Lens' Projection (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
projection_nonKeyAttributes :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> Projection -> f Projection
projection_nonKeyAttributes = (Projection -> Maybe (NonEmpty Text))
-> (Projection -> Maybe (NonEmpty Text) -> Projection)
-> Lens
Projection
Projection
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Projection' {Maybe (NonEmpty Text)
nonKeyAttributes :: Maybe (NonEmpty Text)
$sel:nonKeyAttributes:Projection' :: Projection -> Maybe (NonEmpty Text)
nonKeyAttributes} -> Maybe (NonEmpty Text)
nonKeyAttributes) (\s :: Projection
s@Projection' {} Maybe (NonEmpty Text)
a -> Projection
s {$sel:nonKeyAttributes:Projection' :: Maybe (NonEmpty Text)
nonKeyAttributes = Maybe (NonEmpty Text)
a} :: Projection) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> Projection -> f Projection)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> Projection
-> f Projection
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
(Maybe (NonEmpty 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
(NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromJSON Projection where
parseJSON :: Value -> Parser Projection
parseJSON =
String
-> (Object -> Parser Projection) -> Value -> Parser Projection
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Projection"
( \Object
x ->
Maybe ProjectionType -> Maybe (NonEmpty Text) -> Projection
Projection'
(Maybe ProjectionType -> Maybe (NonEmpty Text) -> Projection)
-> Parser (Maybe ProjectionType)
-> Parser (Maybe (NonEmpty Text) -> Projection)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ProjectionType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ProjectionType")
Parser (Maybe (NonEmpty Text) -> Projection)
-> Parser (Maybe (NonEmpty Text)) -> Parser Projection
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NonKeyAttributes")
)
instance Prelude.Hashable Projection
instance Prelude.NFData Projection
instance Core.ToJSON Projection where
toJSON :: Projection -> Value
toJSON Projection' {Maybe (NonEmpty Text)
Maybe ProjectionType
nonKeyAttributes :: Maybe (NonEmpty Text)
projectionType :: Maybe ProjectionType
$sel:nonKeyAttributes:Projection' :: Projection -> Maybe (NonEmpty Text)
$sel:projectionType:Projection' :: Projection -> Maybe ProjectionType
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"ProjectionType" Text -> ProjectionType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(ProjectionType -> Pair) -> Maybe ProjectionType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ProjectionType
projectionType,
(Text
"NonKeyAttributes" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
nonKeyAttributes
]
)