{-# 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.ThingGroupMetadata
-- 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.ThingGroupMetadata where

import qualified Amazonka.Core as Core
import Amazonka.IoT.Types.GroupNameAndArn
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Thing group metadata.
--
-- /See:/ 'newThingGroupMetadata' smart constructor.
data ThingGroupMetadata = ThingGroupMetadata'
  { -- | The root parent thing group.
    ThingGroupMetadata -> Maybe [GroupNameAndArn]
rootToParentThingGroups :: Prelude.Maybe [GroupNameAndArn],
    -- | The parent thing group name.
    ThingGroupMetadata -> Maybe Text
parentGroupName :: Prelude.Maybe Prelude.Text,
    -- | The UNIX timestamp of when the thing group was created.
    ThingGroupMetadata -> Maybe POSIX
creationDate :: Prelude.Maybe Core.POSIX
  }
  deriving (ThingGroupMetadata -> ThingGroupMetadata -> Bool
(ThingGroupMetadata -> ThingGroupMetadata -> Bool)
-> (ThingGroupMetadata -> ThingGroupMetadata -> Bool)
-> Eq ThingGroupMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ThingGroupMetadata -> ThingGroupMetadata -> Bool
$c/= :: ThingGroupMetadata -> ThingGroupMetadata -> Bool
== :: ThingGroupMetadata -> ThingGroupMetadata -> Bool
$c== :: ThingGroupMetadata -> ThingGroupMetadata -> Bool
Prelude.Eq, ReadPrec [ThingGroupMetadata]
ReadPrec ThingGroupMetadata
Int -> ReadS ThingGroupMetadata
ReadS [ThingGroupMetadata]
(Int -> ReadS ThingGroupMetadata)
-> ReadS [ThingGroupMetadata]
-> ReadPrec ThingGroupMetadata
-> ReadPrec [ThingGroupMetadata]
-> Read ThingGroupMetadata
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ThingGroupMetadata]
$creadListPrec :: ReadPrec [ThingGroupMetadata]
readPrec :: ReadPrec ThingGroupMetadata
$creadPrec :: ReadPrec ThingGroupMetadata
readList :: ReadS [ThingGroupMetadata]
$creadList :: ReadS [ThingGroupMetadata]
readsPrec :: Int -> ReadS ThingGroupMetadata
$creadsPrec :: Int -> ReadS ThingGroupMetadata
Prelude.Read, Int -> ThingGroupMetadata -> ShowS
[ThingGroupMetadata] -> ShowS
ThingGroupMetadata -> String
(Int -> ThingGroupMetadata -> ShowS)
-> (ThingGroupMetadata -> String)
-> ([ThingGroupMetadata] -> ShowS)
-> Show ThingGroupMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ThingGroupMetadata] -> ShowS
$cshowList :: [ThingGroupMetadata] -> ShowS
show :: ThingGroupMetadata -> String
$cshow :: ThingGroupMetadata -> String
showsPrec :: Int -> ThingGroupMetadata -> ShowS
$cshowsPrec :: Int -> ThingGroupMetadata -> ShowS
Prelude.Show, (forall x. ThingGroupMetadata -> Rep ThingGroupMetadata x)
-> (forall x. Rep ThingGroupMetadata x -> ThingGroupMetadata)
-> Generic ThingGroupMetadata
forall x. Rep ThingGroupMetadata x -> ThingGroupMetadata
forall x. ThingGroupMetadata -> Rep ThingGroupMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ThingGroupMetadata x -> ThingGroupMetadata
$cfrom :: forall x. ThingGroupMetadata -> Rep ThingGroupMetadata x
Prelude.Generic)

-- |
-- Create a value of 'ThingGroupMetadata' 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:
--
-- 'rootToParentThingGroups', 'thingGroupMetadata_rootToParentThingGroups' - The root parent thing group.
--
-- 'parentGroupName', 'thingGroupMetadata_parentGroupName' - The parent thing group name.
--
-- 'creationDate', 'thingGroupMetadata_creationDate' - The UNIX timestamp of when the thing group was created.
newThingGroupMetadata ::
  ThingGroupMetadata
newThingGroupMetadata :: ThingGroupMetadata
newThingGroupMetadata =
  ThingGroupMetadata' :: Maybe [GroupNameAndArn]
-> Maybe Text -> Maybe POSIX -> ThingGroupMetadata
ThingGroupMetadata'
    { $sel:rootToParentThingGroups:ThingGroupMetadata' :: Maybe [GroupNameAndArn]
rootToParentThingGroups =
        Maybe [GroupNameAndArn]
forall a. Maybe a
Prelude.Nothing,
      $sel:parentGroupName:ThingGroupMetadata' :: Maybe Text
parentGroupName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:creationDate:ThingGroupMetadata' :: Maybe POSIX
creationDate = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The root parent thing group.
thingGroupMetadata_rootToParentThingGroups :: Lens.Lens' ThingGroupMetadata (Prelude.Maybe [GroupNameAndArn])
thingGroupMetadata_rootToParentThingGroups :: (Maybe [GroupNameAndArn] -> f (Maybe [GroupNameAndArn]))
-> ThingGroupMetadata -> f ThingGroupMetadata
thingGroupMetadata_rootToParentThingGroups = (ThingGroupMetadata -> Maybe [GroupNameAndArn])
-> (ThingGroupMetadata
    -> Maybe [GroupNameAndArn] -> ThingGroupMetadata)
-> Lens
     ThingGroupMetadata
     ThingGroupMetadata
     (Maybe [GroupNameAndArn])
     (Maybe [GroupNameAndArn])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingGroupMetadata' {Maybe [GroupNameAndArn]
rootToParentThingGroups :: Maybe [GroupNameAndArn]
$sel:rootToParentThingGroups:ThingGroupMetadata' :: ThingGroupMetadata -> Maybe [GroupNameAndArn]
rootToParentThingGroups} -> Maybe [GroupNameAndArn]
rootToParentThingGroups) (\s :: ThingGroupMetadata
s@ThingGroupMetadata' {} Maybe [GroupNameAndArn]
a -> ThingGroupMetadata
s {$sel:rootToParentThingGroups:ThingGroupMetadata' :: Maybe [GroupNameAndArn]
rootToParentThingGroups = Maybe [GroupNameAndArn]
a} :: ThingGroupMetadata) ((Maybe [GroupNameAndArn] -> f (Maybe [GroupNameAndArn]))
 -> ThingGroupMetadata -> f ThingGroupMetadata)
-> ((Maybe [GroupNameAndArn] -> f (Maybe [GroupNameAndArn]))
    -> Maybe [GroupNameAndArn] -> f (Maybe [GroupNameAndArn]))
-> (Maybe [GroupNameAndArn] -> f (Maybe [GroupNameAndArn]))
-> ThingGroupMetadata
-> f ThingGroupMetadata
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [GroupNameAndArn]
  [GroupNameAndArn]
  [GroupNameAndArn]
  [GroupNameAndArn]
-> Iso
     (Maybe [GroupNameAndArn])
     (Maybe [GroupNameAndArn])
     (Maybe [GroupNameAndArn])
     (Maybe [GroupNameAndArn])
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
  [GroupNameAndArn]
  [GroupNameAndArn]
  [GroupNameAndArn]
  [GroupNameAndArn]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The parent thing group name.
thingGroupMetadata_parentGroupName :: Lens.Lens' ThingGroupMetadata (Prelude.Maybe Prelude.Text)
thingGroupMetadata_parentGroupName :: (Maybe Text -> f (Maybe Text))
-> ThingGroupMetadata -> f ThingGroupMetadata
thingGroupMetadata_parentGroupName = (ThingGroupMetadata -> Maybe Text)
-> (ThingGroupMetadata -> Maybe Text -> ThingGroupMetadata)
-> Lens
     ThingGroupMetadata ThingGroupMetadata (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingGroupMetadata' {Maybe Text
parentGroupName :: Maybe Text
$sel:parentGroupName:ThingGroupMetadata' :: ThingGroupMetadata -> Maybe Text
parentGroupName} -> Maybe Text
parentGroupName) (\s :: ThingGroupMetadata
s@ThingGroupMetadata' {} Maybe Text
a -> ThingGroupMetadata
s {$sel:parentGroupName:ThingGroupMetadata' :: Maybe Text
parentGroupName = Maybe Text
a} :: ThingGroupMetadata)

-- | The UNIX timestamp of when the thing group was created.
thingGroupMetadata_creationDate :: Lens.Lens' ThingGroupMetadata (Prelude.Maybe Prelude.UTCTime)
thingGroupMetadata_creationDate :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ThingGroupMetadata -> f ThingGroupMetadata
thingGroupMetadata_creationDate = (ThingGroupMetadata -> Maybe POSIX)
-> (ThingGroupMetadata -> Maybe POSIX -> ThingGroupMetadata)
-> Lens
     ThingGroupMetadata ThingGroupMetadata (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingGroupMetadata' {Maybe POSIX
creationDate :: Maybe POSIX
$sel:creationDate:ThingGroupMetadata' :: ThingGroupMetadata -> Maybe POSIX
creationDate} -> Maybe POSIX
creationDate) (\s :: ThingGroupMetadata
s@ThingGroupMetadata' {} Maybe POSIX
a -> ThingGroupMetadata
s {$sel:creationDate:ThingGroupMetadata' :: Maybe POSIX
creationDate = Maybe POSIX
a} :: ThingGroupMetadata) ((Maybe POSIX -> f (Maybe POSIX))
 -> ThingGroupMetadata -> f ThingGroupMetadata)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ThingGroupMetadata
-> f ThingGroupMetadata
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

instance Core.FromJSON ThingGroupMetadata where
  parseJSON :: Value -> Parser ThingGroupMetadata
parseJSON =
    String
-> (Object -> Parser ThingGroupMetadata)
-> Value
-> Parser ThingGroupMetadata
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ThingGroupMetadata"
      ( \Object
x ->
          Maybe [GroupNameAndArn]
-> Maybe Text -> Maybe POSIX -> ThingGroupMetadata
ThingGroupMetadata'
            (Maybe [GroupNameAndArn]
 -> Maybe Text -> Maybe POSIX -> ThingGroupMetadata)
-> Parser (Maybe [GroupNameAndArn])
-> Parser (Maybe Text -> Maybe POSIX -> ThingGroupMetadata)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [GroupNameAndArn]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"rootToParentThingGroups"
                            Parser (Maybe (Maybe [GroupNameAndArn]))
-> Maybe [GroupNameAndArn] -> Parser (Maybe [GroupNameAndArn])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [GroupNameAndArn]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Text -> Maybe POSIX -> ThingGroupMetadata)
-> Parser (Maybe Text)
-> Parser (Maybe POSIX -> ThingGroupMetadata)
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
"parentGroupName")
            Parser (Maybe POSIX -> ThingGroupMetadata)
-> Parser (Maybe POSIX) -> Parser ThingGroupMetadata
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")
      )

instance Prelude.Hashable ThingGroupMetadata

instance Prelude.NFData ThingGroupMetadata