{-# 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.Device where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Device = Device'
{
Device -> Maybe Bool
syncShadow :: Prelude.Maybe Prelude.Bool,
Device -> Text
thingArn :: Prelude.Text,
Device -> Text
id :: Prelude.Text,
Device -> Text
certificateArn :: Prelude.Text
}
deriving (Device -> Device -> Bool
(Device -> Device -> Bool)
-> (Device -> Device -> Bool) -> Eq Device
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Device -> Device -> Bool
$c/= :: Device -> Device -> Bool
== :: Device -> Device -> Bool
$c== :: Device -> Device -> Bool
Prelude.Eq, ReadPrec [Device]
ReadPrec Device
Int -> ReadS Device
ReadS [Device]
(Int -> ReadS Device)
-> ReadS [Device]
-> ReadPrec Device
-> ReadPrec [Device]
-> Read Device
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Device]
$creadListPrec :: ReadPrec [Device]
readPrec :: ReadPrec Device
$creadPrec :: ReadPrec Device
readList :: ReadS [Device]
$creadList :: ReadS [Device]
readsPrec :: Int -> ReadS Device
$creadsPrec :: Int -> ReadS Device
Prelude.Read, Int -> Device -> ShowS
[Device] -> ShowS
Device -> String
(Int -> Device -> ShowS)
-> (Device -> String) -> ([Device] -> ShowS) -> Show Device
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Device] -> ShowS
$cshowList :: [Device] -> ShowS
show :: Device -> String
$cshow :: Device -> String
showsPrec :: Int -> Device -> ShowS
$cshowsPrec :: Int -> Device -> ShowS
Prelude.Show, (forall x. Device -> Rep Device x)
-> (forall x. Rep Device x -> Device) -> Generic Device
forall x. Rep Device x -> Device
forall x. Device -> Rep Device x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Device x -> Device
$cfrom :: forall x. Device -> Rep Device x
Prelude.Generic)
newDevice ::
Prelude.Text ->
Prelude.Text ->
Prelude.Text ->
Device
newDevice :: Text -> Text -> Text -> Device
newDevice Text
pThingArn_ Text
pId_ Text
pCertificateArn_ =
Device' :: Maybe Bool -> Text -> Text -> Text -> Device
Device'
{ $sel:syncShadow:Device' :: Maybe Bool
syncShadow = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
$sel:thingArn:Device' :: Text
thingArn = Text
pThingArn_,
$sel:id:Device' :: Text
id = Text
pId_,
$sel:certificateArn:Device' :: Text
certificateArn = Text
pCertificateArn_
}
device_syncShadow :: Lens.Lens' Device (Prelude.Maybe Prelude.Bool)
device_syncShadow :: (Maybe Bool -> f (Maybe Bool)) -> Device -> f Device
device_syncShadow = (Device -> Maybe Bool)
-> (Device -> Maybe Bool -> Device)
-> Lens Device Device (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Device' {Maybe Bool
syncShadow :: Maybe Bool
$sel:syncShadow:Device' :: Device -> Maybe Bool
syncShadow} -> Maybe Bool
syncShadow) (\s :: Device
s@Device' {} Maybe Bool
a -> Device
s {$sel:syncShadow:Device' :: Maybe Bool
syncShadow = Maybe Bool
a} :: Device)
device_thingArn :: Lens.Lens' Device Prelude.Text
device_thingArn :: (Text -> f Text) -> Device -> f Device
device_thingArn = (Device -> Text)
-> (Device -> Text -> Device) -> Lens Device Device Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Device' {Text
thingArn :: Text
$sel:thingArn:Device' :: Device -> Text
thingArn} -> Text
thingArn) (\s :: Device
s@Device' {} Text
a -> Device
s {$sel:thingArn:Device' :: Text
thingArn = Text
a} :: Device)
device_id :: Lens.Lens' Device Prelude.Text
device_id :: (Text -> f Text) -> Device -> f Device
device_id = (Device -> Text)
-> (Device -> Text -> Device) -> Lens Device Device Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Device' {Text
id :: Text
$sel:id:Device' :: Device -> Text
id} -> Text
id) (\s :: Device
s@Device' {} Text
a -> Device
s {$sel:id:Device' :: Text
id = Text
a} :: Device)
device_certificateArn :: Lens.Lens' Device Prelude.Text
device_certificateArn :: (Text -> f Text) -> Device -> f Device
device_certificateArn = (Device -> Text)
-> (Device -> Text -> Device) -> Lens Device Device Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Device' {Text
certificateArn :: Text
$sel:certificateArn:Device' :: Device -> Text
certificateArn} -> Text
certificateArn) (\s :: Device
s@Device' {} Text
a -> Device
s {$sel:certificateArn:Device' :: Text
certificateArn = Text
a} :: Device)
instance Core.FromJSON Device where
parseJSON :: Value -> Parser Device
parseJSON =
String -> (Object -> Parser Device) -> Value -> Parser Device
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Device"
( \Object
x ->
Maybe Bool -> Text -> Text -> Text -> Device
Device'
(Maybe Bool -> Text -> Text -> Text -> Device)
-> Parser (Maybe Bool) -> Parser (Text -> Text -> Text -> Device)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SyncShadow")
Parser (Text -> Text -> Text -> Device)
-> Parser Text -> Parser (Text -> Text -> Device)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ThingArn")
Parser (Text -> Text -> Device)
-> Parser Text -> Parser (Text -> Device)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Id")
Parser (Text -> Device) -> Parser Text -> Parser Device
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"CertificateArn")
)
instance Prelude.Hashable Device
instance Prelude.NFData Device
instance Core.ToJSON Device where
toJSON :: Device -> Value
toJSON Device' {Maybe Bool
Text
certificateArn :: Text
id :: Text
thingArn :: Text
syncShadow :: Maybe Bool
$sel:certificateArn:Device' :: Device -> Text
$sel:id:Device' :: Device -> Text
$sel:thingArn:Device' :: Device -> Text
$sel:syncShadow:Device' :: Device -> Maybe Bool
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"SyncShadow" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
syncShadow,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ThingArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
thingArn),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"CertificateArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
certificateArn)
]
)