{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoT.Types.ThingGroupMetadata where

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

-- | Thing group metadata.
--
-- /See:/ 'newThingGroupMetadata' smart constructor.
data ThingGroupMetadata = ThingGroupMetadata'
  { -- | The UNIX timestamp of when the thing group was created.
    ThingGroupMetadata -> Maybe POSIX
creationDate :: Prelude.Maybe Data.POSIX,
    -- | The parent thing group name.
    ThingGroupMetadata -> Maybe Text
parentGroupName :: Prelude.Maybe Prelude.Text,
    -- | The root parent thing group.
    ThingGroupMetadata -> Maybe [GroupNameAndArn]
rootToParentThingGroups :: Prelude.Maybe [GroupNameAndArn]
  }
  deriving (ThingGroupMetadata -> ThingGroupMetadata -> Bool
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]
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
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. 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:
--
-- 'creationDate', 'thingGroupMetadata_creationDate' - The UNIX timestamp of when the thing group was created.
--
-- 'parentGroupName', 'thingGroupMetadata_parentGroupName' - The parent thing group name.
--
-- 'rootToParentThingGroups', 'thingGroupMetadata_rootToParentThingGroups' - The root parent thing group.
newThingGroupMetadata ::
  ThingGroupMetadata
newThingGroupMetadata :: ThingGroupMetadata
newThingGroupMetadata =
  ThingGroupMetadata'
    { $sel:creationDate:ThingGroupMetadata' :: Maybe POSIX
creationDate = forall a. Maybe a
Prelude.Nothing,
      $sel:parentGroupName:ThingGroupMetadata' :: Maybe Text
parentGroupName = forall a. Maybe a
Prelude.Nothing,
      $sel:rootToParentThingGroups:ThingGroupMetadata' :: Maybe [GroupNameAndArn]
rootToParentThingGroups = forall a. Maybe a
Prelude.Nothing
    }

-- | The UNIX timestamp of when the thing group was created.
thingGroupMetadata_creationDate :: Lens.Lens' ThingGroupMetadata (Prelude.Maybe Prelude.UTCTime)
thingGroupMetadata_creationDate :: Lens' ThingGroupMetadata (Maybe UTCTime)
thingGroupMetadata_creationDate = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The parent thing group name.
thingGroupMetadata_parentGroupName :: Lens.Lens' ThingGroupMetadata (Prelude.Maybe Prelude.Text)
thingGroupMetadata_parentGroupName :: Lens' ThingGroupMetadata (Maybe Text)
thingGroupMetadata_parentGroupName = 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 root parent thing group.
thingGroupMetadata_rootToParentThingGroups :: Lens.Lens' ThingGroupMetadata (Prelude.Maybe [GroupNameAndArn])
thingGroupMetadata_rootToParentThingGroups :: Lens' ThingGroupMetadata (Maybe [GroupNameAndArn])
thingGroupMetadata_rootToParentThingGroups = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.Hashable ThingGroupMetadata where
  hashWithSalt :: Int -> ThingGroupMetadata -> Int
hashWithSalt Int
_salt ThingGroupMetadata' {Maybe [GroupNameAndArn]
Maybe Text
Maybe POSIX
rootToParentThingGroups :: Maybe [GroupNameAndArn]
parentGroupName :: Maybe Text
creationDate :: Maybe POSIX
$sel:rootToParentThingGroups:ThingGroupMetadata' :: ThingGroupMetadata -> Maybe [GroupNameAndArn]
$sel:parentGroupName:ThingGroupMetadata' :: ThingGroupMetadata -> Maybe Text
$sel:creationDate:ThingGroupMetadata' :: ThingGroupMetadata -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
creationDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
parentGroupName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [GroupNameAndArn]
rootToParentThingGroups

instance Prelude.NFData ThingGroupMetadata where
  rnf :: ThingGroupMetadata -> ()
rnf ThingGroupMetadata' {Maybe [GroupNameAndArn]
Maybe Text
Maybe POSIX
rootToParentThingGroups :: Maybe [GroupNameAndArn]
parentGroupName :: Maybe Text
creationDate :: Maybe POSIX
$sel:rootToParentThingGroups:ThingGroupMetadata' :: ThingGroupMetadata -> Maybe [GroupNameAndArn]
$sel:parentGroupName:ThingGroupMetadata' :: ThingGroupMetadata -> Maybe Text
$sel:creationDate:ThingGroupMetadata' :: ThingGroupMetadata -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
creationDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
parentGroupName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [GroupNameAndArn]
rootToParentThingGroups