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