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