{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.IoTThingsGraph.Types.EntityDescription
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoTThingsGraph.Types.EntityDescription where

import qualified Amazonka.Core as Core
import Amazonka.IoTThingsGraph.Types.DefinitionDocument
import Amazonka.IoTThingsGraph.Types.EntityType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the properties of an entity.
--
-- /See:/ 'newEntityDescription' smart constructor.
data EntityDescription = EntityDescription'
  { -- | The entity ARN.
    EntityDescription -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The time at which the entity was created.
    EntityDescription -> Maybe POSIX
createdAt :: Prelude.Maybe Core.POSIX,
    -- | The definition document of the entity.
    EntityDescription -> Maybe DefinitionDocument
definition :: Prelude.Maybe DefinitionDocument,
    -- | The entity ID.
    EntityDescription -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | The entity type.
    EntityDescription -> Maybe EntityType
type' :: Prelude.Maybe EntityType
  }
  deriving (EntityDescription -> EntityDescription -> Bool
(EntityDescription -> EntityDescription -> Bool)
-> (EntityDescription -> EntityDescription -> Bool)
-> Eq EntityDescription
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EntityDescription -> EntityDescription -> Bool
$c/= :: EntityDescription -> EntityDescription -> Bool
== :: EntityDescription -> EntityDescription -> Bool
$c== :: EntityDescription -> EntityDescription -> Bool
Prelude.Eq, ReadPrec [EntityDescription]
ReadPrec EntityDescription
Int -> ReadS EntityDescription
ReadS [EntityDescription]
(Int -> ReadS EntityDescription)
-> ReadS [EntityDescription]
-> ReadPrec EntityDescription
-> ReadPrec [EntityDescription]
-> Read EntityDescription
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EntityDescription]
$creadListPrec :: ReadPrec [EntityDescription]
readPrec :: ReadPrec EntityDescription
$creadPrec :: ReadPrec EntityDescription
readList :: ReadS [EntityDescription]
$creadList :: ReadS [EntityDescription]
readsPrec :: Int -> ReadS EntityDescription
$creadsPrec :: Int -> ReadS EntityDescription
Prelude.Read, Int -> EntityDescription -> ShowS
[EntityDescription] -> ShowS
EntityDescription -> String
(Int -> EntityDescription -> ShowS)
-> (EntityDescription -> String)
-> ([EntityDescription] -> ShowS)
-> Show EntityDescription
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EntityDescription] -> ShowS
$cshowList :: [EntityDescription] -> ShowS
show :: EntityDescription -> String
$cshow :: EntityDescription -> String
showsPrec :: Int -> EntityDescription -> ShowS
$cshowsPrec :: Int -> EntityDescription -> ShowS
Prelude.Show, (forall x. EntityDescription -> Rep EntityDescription x)
-> (forall x. Rep EntityDescription x -> EntityDescription)
-> Generic EntityDescription
forall x. Rep EntityDescription x -> EntityDescription
forall x. EntityDescription -> Rep EntityDescription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EntityDescription x -> EntityDescription
$cfrom :: forall x. EntityDescription -> Rep EntityDescription x
Prelude.Generic)

-- |
-- Create a value of 'EntityDescription' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'arn', 'entityDescription_arn' - The entity ARN.
--
-- 'createdAt', 'entityDescription_createdAt' - The time at which the entity was created.
--
-- 'definition', 'entityDescription_definition' - The definition document of the entity.
--
-- 'id', 'entityDescription_id' - The entity ID.
--
-- 'type'', 'entityDescription_type' - The entity type.
newEntityDescription ::
  EntityDescription
newEntityDescription :: EntityDescription
newEntityDescription =
  EntityDescription' :: Maybe Text
-> Maybe POSIX
-> Maybe DefinitionDocument
-> Maybe Text
-> Maybe EntityType
-> EntityDescription
EntityDescription'
    { $sel:arn:EntityDescription' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:createdAt:EntityDescription' :: Maybe POSIX
createdAt = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:definition:EntityDescription' :: Maybe DefinitionDocument
definition = Maybe DefinitionDocument
forall a. Maybe a
Prelude.Nothing,
      $sel:id:EntityDescription' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':EntityDescription' :: Maybe EntityType
type' = Maybe EntityType
forall a. Maybe a
Prelude.Nothing
    }

-- | The entity ARN.
entityDescription_arn :: Lens.Lens' EntityDescription (Prelude.Maybe Prelude.Text)
entityDescription_arn :: (Maybe Text -> f (Maybe Text))
-> EntityDescription -> f EntityDescription
entityDescription_arn = (EntityDescription -> Maybe Text)
-> (EntityDescription -> Maybe Text -> EntityDescription)
-> Lens
     EntityDescription EntityDescription (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityDescription' {Maybe Text
arn :: Maybe Text
$sel:arn:EntityDescription' :: EntityDescription -> Maybe Text
arn} -> Maybe Text
arn) (\s :: EntityDescription
s@EntityDescription' {} Maybe Text
a -> EntityDescription
s {$sel:arn:EntityDescription' :: Maybe Text
arn = Maybe Text
a} :: EntityDescription)

-- | The time at which the entity was created.
entityDescription_createdAt :: Lens.Lens' EntityDescription (Prelude.Maybe Prelude.UTCTime)
entityDescription_createdAt :: (Maybe UTCTime -> f (Maybe UTCTime))
-> EntityDescription -> f EntityDescription
entityDescription_createdAt = (EntityDescription -> Maybe POSIX)
-> (EntityDescription -> Maybe POSIX -> EntityDescription)
-> Lens
     EntityDescription EntityDescription (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityDescription' {Maybe POSIX
createdAt :: Maybe POSIX
$sel:createdAt:EntityDescription' :: EntityDescription -> Maybe POSIX
createdAt} -> Maybe POSIX
createdAt) (\s :: EntityDescription
s@EntityDescription' {} Maybe POSIX
a -> EntityDescription
s {$sel:createdAt:EntityDescription' :: Maybe POSIX
createdAt = Maybe POSIX
a} :: EntityDescription) ((Maybe POSIX -> f (Maybe POSIX))
 -> EntityDescription -> f EntityDescription)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> EntityDescription
-> f EntityDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The definition document of the entity.
entityDescription_definition :: Lens.Lens' EntityDescription (Prelude.Maybe DefinitionDocument)
entityDescription_definition :: (Maybe DefinitionDocument -> f (Maybe DefinitionDocument))
-> EntityDescription -> f EntityDescription
entityDescription_definition = (EntityDescription -> Maybe DefinitionDocument)
-> (EntityDescription
    -> Maybe DefinitionDocument -> EntityDescription)
-> Lens
     EntityDescription
     EntityDescription
     (Maybe DefinitionDocument)
     (Maybe DefinitionDocument)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityDescription' {Maybe DefinitionDocument
definition :: Maybe DefinitionDocument
$sel:definition:EntityDescription' :: EntityDescription -> Maybe DefinitionDocument
definition} -> Maybe DefinitionDocument
definition) (\s :: EntityDescription
s@EntityDescription' {} Maybe DefinitionDocument
a -> EntityDescription
s {$sel:definition:EntityDescription' :: Maybe DefinitionDocument
definition = Maybe DefinitionDocument
a} :: EntityDescription)

-- | The entity ID.
entityDescription_id :: Lens.Lens' EntityDescription (Prelude.Maybe Prelude.Text)
entityDescription_id :: (Maybe Text -> f (Maybe Text))
-> EntityDescription -> f EntityDescription
entityDescription_id = (EntityDescription -> Maybe Text)
-> (EntityDescription -> Maybe Text -> EntityDescription)
-> Lens
     EntityDescription EntityDescription (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityDescription' {Maybe Text
id :: Maybe Text
$sel:id:EntityDescription' :: EntityDescription -> Maybe Text
id} -> Maybe Text
id) (\s :: EntityDescription
s@EntityDescription' {} Maybe Text
a -> EntityDescription
s {$sel:id:EntityDescription' :: Maybe Text
id = Maybe Text
a} :: EntityDescription)

-- | The entity type.
entityDescription_type :: Lens.Lens' EntityDescription (Prelude.Maybe EntityType)
entityDescription_type :: (Maybe EntityType -> f (Maybe EntityType))
-> EntityDescription -> f EntityDescription
entityDescription_type = (EntityDescription -> Maybe EntityType)
-> (EntityDescription -> Maybe EntityType -> EntityDescription)
-> Lens
     EntityDescription
     EntityDescription
     (Maybe EntityType)
     (Maybe EntityType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityDescription' {Maybe EntityType
type' :: Maybe EntityType
$sel:type':EntityDescription' :: EntityDescription -> Maybe EntityType
type'} -> Maybe EntityType
type') (\s :: EntityDescription
s@EntityDescription' {} Maybe EntityType
a -> EntityDescription
s {$sel:type':EntityDescription' :: Maybe EntityType
type' = Maybe EntityType
a} :: EntityDescription)

instance Core.FromJSON EntityDescription where
  parseJSON :: Value -> Parser EntityDescription
parseJSON =
    String
-> (Object -> Parser EntityDescription)
-> Value
-> Parser EntityDescription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EntityDescription"
      ( \Object
x ->
          Maybe Text
-> Maybe POSIX
-> Maybe DefinitionDocument
-> Maybe Text
-> Maybe EntityType
-> EntityDescription
EntityDescription'
            (Maybe Text
 -> Maybe POSIX
 -> Maybe DefinitionDocument
 -> Maybe Text
 -> Maybe EntityType
 -> EntityDescription)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe DefinitionDocument
      -> Maybe Text
      -> Maybe EntityType
      -> EntityDescription)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"arn")
            Parser
  (Maybe POSIX
   -> Maybe DefinitionDocument
   -> Maybe Text
   -> Maybe EntityType
   -> EntityDescription)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe DefinitionDocument
      -> Maybe Text -> Maybe EntityType -> EntityDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"createdAt")
            Parser
  (Maybe DefinitionDocument
   -> Maybe Text -> Maybe EntityType -> EntityDescription)
-> Parser (Maybe DefinitionDocument)
-> Parser (Maybe Text -> Maybe EntityType -> EntityDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DefinitionDocument)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"definition")
            Parser (Maybe Text -> Maybe EntityType -> EntityDescription)
-> Parser (Maybe Text)
-> Parser (Maybe EntityType -> EntityDescription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"id")
            Parser (Maybe EntityType -> EntityDescription)
-> Parser (Maybe EntityType) -> Parser EntityDescription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EntityType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"type")
      )

instance Prelude.Hashable EntityDescription

instance Prelude.NFData EntityDescription