{-# 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.IoT.Types.ThingTypeMetadata
-- 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.IoT.Types.ThingTypeMetadata where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The ThingTypeMetadata contains additional information about the thing
-- type including: creation date and time, a value indicating whether the
-- thing type is deprecated, and a date and time when time was deprecated.
--
-- /See:/ 'newThingTypeMetadata' smart constructor.
data ThingTypeMetadata = ThingTypeMetadata'
  { -- | The date and time when the thing type was deprecated.
    ThingTypeMetadata -> Maybe POSIX
deprecationDate :: Prelude.Maybe Core.POSIX,
    -- | The date and time when the thing type was created.
    ThingTypeMetadata -> Maybe POSIX
creationDate :: Prelude.Maybe Core.POSIX,
    -- | Whether the thing type is deprecated. If __true__, no new things could
    -- be associated with this type.
    ThingTypeMetadata -> Maybe Bool
deprecated :: Prelude.Maybe Prelude.Bool
  }
  deriving (ThingTypeMetadata -> ThingTypeMetadata -> Bool
(ThingTypeMetadata -> ThingTypeMetadata -> Bool)
-> (ThingTypeMetadata -> ThingTypeMetadata -> Bool)
-> Eq ThingTypeMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ThingTypeMetadata -> ThingTypeMetadata -> Bool
$c/= :: ThingTypeMetadata -> ThingTypeMetadata -> Bool
== :: ThingTypeMetadata -> ThingTypeMetadata -> Bool
$c== :: ThingTypeMetadata -> ThingTypeMetadata -> Bool
Prelude.Eq, ReadPrec [ThingTypeMetadata]
ReadPrec ThingTypeMetadata
Int -> ReadS ThingTypeMetadata
ReadS [ThingTypeMetadata]
(Int -> ReadS ThingTypeMetadata)
-> ReadS [ThingTypeMetadata]
-> ReadPrec ThingTypeMetadata
-> ReadPrec [ThingTypeMetadata]
-> Read ThingTypeMetadata
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ThingTypeMetadata]
$creadListPrec :: ReadPrec [ThingTypeMetadata]
readPrec :: ReadPrec ThingTypeMetadata
$creadPrec :: ReadPrec ThingTypeMetadata
readList :: ReadS [ThingTypeMetadata]
$creadList :: ReadS [ThingTypeMetadata]
readsPrec :: Int -> ReadS ThingTypeMetadata
$creadsPrec :: Int -> ReadS ThingTypeMetadata
Prelude.Read, Int -> ThingTypeMetadata -> ShowS
[ThingTypeMetadata] -> ShowS
ThingTypeMetadata -> String
(Int -> ThingTypeMetadata -> ShowS)
-> (ThingTypeMetadata -> String)
-> ([ThingTypeMetadata] -> ShowS)
-> Show ThingTypeMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ThingTypeMetadata] -> ShowS
$cshowList :: [ThingTypeMetadata] -> ShowS
show :: ThingTypeMetadata -> String
$cshow :: ThingTypeMetadata -> String
showsPrec :: Int -> ThingTypeMetadata -> ShowS
$cshowsPrec :: Int -> ThingTypeMetadata -> ShowS
Prelude.Show, (forall x. ThingTypeMetadata -> Rep ThingTypeMetadata x)
-> (forall x. Rep ThingTypeMetadata x -> ThingTypeMetadata)
-> Generic ThingTypeMetadata
forall x. Rep ThingTypeMetadata x -> ThingTypeMetadata
forall x. ThingTypeMetadata -> Rep ThingTypeMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ThingTypeMetadata x -> ThingTypeMetadata
$cfrom :: forall x. ThingTypeMetadata -> Rep ThingTypeMetadata x
Prelude.Generic)

-- |
-- Create a value of 'ThingTypeMetadata' 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:
--
-- 'deprecationDate', 'thingTypeMetadata_deprecationDate' - The date and time when the thing type was deprecated.
--
-- 'creationDate', 'thingTypeMetadata_creationDate' - The date and time when the thing type was created.
--
-- 'deprecated', 'thingTypeMetadata_deprecated' - Whether the thing type is deprecated. If __true__, no new things could
-- be associated with this type.
newThingTypeMetadata ::
  ThingTypeMetadata
newThingTypeMetadata :: ThingTypeMetadata
newThingTypeMetadata =
  ThingTypeMetadata' :: Maybe POSIX -> Maybe POSIX -> Maybe Bool -> ThingTypeMetadata
ThingTypeMetadata'
    { $sel:deprecationDate:ThingTypeMetadata' :: Maybe POSIX
deprecationDate =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:creationDate:ThingTypeMetadata' :: Maybe POSIX
creationDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:deprecated:ThingTypeMetadata' :: Maybe Bool
deprecated = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The date and time when the thing type was deprecated.
thingTypeMetadata_deprecationDate :: Lens.Lens' ThingTypeMetadata (Prelude.Maybe Prelude.UTCTime)
thingTypeMetadata_deprecationDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ThingTypeMetadata -> f ThingTypeMetadata
thingTypeMetadata_deprecationDate = (ThingTypeMetadata -> Maybe POSIX)
-> (ThingTypeMetadata -> Maybe POSIX -> ThingTypeMetadata)
-> Lens
     ThingTypeMetadata ThingTypeMetadata (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingTypeMetadata' {Maybe POSIX
deprecationDate :: Maybe POSIX
$sel:deprecationDate:ThingTypeMetadata' :: ThingTypeMetadata -> Maybe POSIX
deprecationDate} -> Maybe POSIX
deprecationDate) (\s :: ThingTypeMetadata
s@ThingTypeMetadata' {} Maybe POSIX
a -> ThingTypeMetadata
s {$sel:deprecationDate:ThingTypeMetadata' :: Maybe POSIX
deprecationDate = Maybe POSIX
a} :: ThingTypeMetadata) ((Maybe POSIX -> f (Maybe POSIX))
 -> ThingTypeMetadata -> f ThingTypeMetadata)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ThingTypeMetadata
-> f ThingTypeMetadata
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 date and time when the thing type was created.
thingTypeMetadata_creationDate :: Lens.Lens' ThingTypeMetadata (Prelude.Maybe Prelude.UTCTime)
thingTypeMetadata_creationDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ThingTypeMetadata -> f ThingTypeMetadata
thingTypeMetadata_creationDate = (ThingTypeMetadata -> Maybe POSIX)
-> (ThingTypeMetadata -> Maybe POSIX -> ThingTypeMetadata)
-> Lens
     ThingTypeMetadata ThingTypeMetadata (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingTypeMetadata' {Maybe POSIX
creationDate :: Maybe POSIX
$sel:creationDate:ThingTypeMetadata' :: ThingTypeMetadata -> Maybe POSIX
creationDate} -> Maybe POSIX
creationDate) (\s :: ThingTypeMetadata
s@ThingTypeMetadata' {} Maybe POSIX
a -> ThingTypeMetadata
s {$sel:creationDate:ThingTypeMetadata' :: Maybe POSIX
creationDate = Maybe POSIX
a} :: ThingTypeMetadata) ((Maybe POSIX -> f (Maybe POSIX))
 -> ThingTypeMetadata -> f ThingTypeMetadata)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ThingTypeMetadata
-> f ThingTypeMetadata
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

-- | Whether the thing type is deprecated. If __true__, no new things could
-- be associated with this type.
thingTypeMetadata_deprecated :: Lens.Lens' ThingTypeMetadata (Prelude.Maybe Prelude.Bool)
thingTypeMetadata_deprecated :: (Maybe Bool -> f (Maybe Bool))
-> ThingTypeMetadata -> f ThingTypeMetadata
thingTypeMetadata_deprecated = (ThingTypeMetadata -> Maybe Bool)
-> (ThingTypeMetadata -> Maybe Bool -> ThingTypeMetadata)
-> Lens
     ThingTypeMetadata ThingTypeMetadata (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingTypeMetadata' {Maybe Bool
deprecated :: Maybe Bool
$sel:deprecated:ThingTypeMetadata' :: ThingTypeMetadata -> Maybe Bool
deprecated} -> Maybe Bool
deprecated) (\s :: ThingTypeMetadata
s@ThingTypeMetadata' {} Maybe Bool
a -> ThingTypeMetadata
s {$sel:deprecated:ThingTypeMetadata' :: Maybe Bool
deprecated = Maybe Bool
a} :: ThingTypeMetadata)

instance Core.FromJSON ThingTypeMetadata where
  parseJSON :: Value -> Parser ThingTypeMetadata
parseJSON =
    String
-> (Object -> Parser ThingTypeMetadata)
-> Value
-> Parser ThingTypeMetadata
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ThingTypeMetadata"
      ( \Object
x ->
          Maybe POSIX -> Maybe POSIX -> Maybe Bool -> ThingTypeMetadata
ThingTypeMetadata'
            (Maybe POSIX -> Maybe POSIX -> Maybe Bool -> ThingTypeMetadata)
-> Parser (Maybe POSIX)
-> Parser (Maybe POSIX -> Maybe Bool -> ThingTypeMetadata)
forall (f :: * -> *) a b. Functor 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
"deprecationDate")
            Parser (Maybe POSIX -> Maybe Bool -> ThingTypeMetadata)
-> Parser (Maybe POSIX) -> Parser (Maybe Bool -> ThingTypeMetadata)
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
"creationDate")
            Parser (Maybe Bool -> ThingTypeMetadata)
-> Parser (Maybe Bool) -> Parser ThingTypeMetadata
forall (f :: * -> *) a b. Applicative f => 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
"deprecated")
      )

instance Prelude.Hashable ThingTypeMetadata

instance Prelude.NFData ThingTypeMetadata