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