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

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

-- | The thing group search index document.
--
-- /See:/ 'newThingGroupDocument' smart constructor.
data ThingGroupDocument = ThingGroupDocument'
  { -- | The thing group attributes.
    ThingGroupDocument -> Maybe (HashMap Text Text)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | Parent group names.
    ThingGroupDocument -> Maybe [Text]
parentGroupNames :: Prelude.Maybe [Prelude.Text],
    -- | The thing group description.
    ThingGroupDocument -> Maybe Text
thingGroupDescription :: Prelude.Maybe Prelude.Text,
    -- | The thing group ID.
    ThingGroupDocument -> Maybe Text
thingGroupId :: Prelude.Maybe Prelude.Text,
    -- | The thing group name.
    ThingGroupDocument -> Maybe Text
thingGroupName :: Prelude.Maybe Prelude.Text
  }
  deriving (ThingGroupDocument -> ThingGroupDocument -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ThingGroupDocument -> ThingGroupDocument -> Bool
$c/= :: ThingGroupDocument -> ThingGroupDocument -> Bool
== :: ThingGroupDocument -> ThingGroupDocument -> Bool
$c== :: ThingGroupDocument -> ThingGroupDocument -> Bool
Prelude.Eq, ReadPrec [ThingGroupDocument]
ReadPrec ThingGroupDocument
Int -> ReadS ThingGroupDocument
ReadS [ThingGroupDocument]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ThingGroupDocument]
$creadListPrec :: ReadPrec [ThingGroupDocument]
readPrec :: ReadPrec ThingGroupDocument
$creadPrec :: ReadPrec ThingGroupDocument
readList :: ReadS [ThingGroupDocument]
$creadList :: ReadS [ThingGroupDocument]
readsPrec :: Int -> ReadS ThingGroupDocument
$creadsPrec :: Int -> ReadS ThingGroupDocument
Prelude.Read, Int -> ThingGroupDocument -> ShowS
[ThingGroupDocument] -> ShowS
ThingGroupDocument -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ThingGroupDocument] -> ShowS
$cshowList :: [ThingGroupDocument] -> ShowS
show :: ThingGroupDocument -> String
$cshow :: ThingGroupDocument -> String
showsPrec :: Int -> ThingGroupDocument -> ShowS
$cshowsPrec :: Int -> ThingGroupDocument -> ShowS
Prelude.Show, forall x. Rep ThingGroupDocument x -> ThingGroupDocument
forall x. ThingGroupDocument -> Rep ThingGroupDocument x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ThingGroupDocument x -> ThingGroupDocument
$cfrom :: forall x. ThingGroupDocument -> Rep ThingGroupDocument x
Prelude.Generic)

-- |
-- Create a value of 'ThingGroupDocument' 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:
--
-- 'attributes', 'thingGroupDocument_attributes' - The thing group attributes.
--
-- 'parentGroupNames', 'thingGroupDocument_parentGroupNames' - Parent group names.
--
-- 'thingGroupDescription', 'thingGroupDocument_thingGroupDescription' - The thing group description.
--
-- 'thingGroupId', 'thingGroupDocument_thingGroupId' - The thing group ID.
--
-- 'thingGroupName', 'thingGroupDocument_thingGroupName' - The thing group name.
newThingGroupDocument ::
  ThingGroupDocument
newThingGroupDocument :: ThingGroupDocument
newThingGroupDocument =
  ThingGroupDocument'
    { $sel:attributes:ThingGroupDocument' :: Maybe (HashMap Text Text)
attributes = forall a. Maybe a
Prelude.Nothing,
      $sel:parentGroupNames:ThingGroupDocument' :: Maybe [Text]
parentGroupNames = forall a. Maybe a
Prelude.Nothing,
      $sel:thingGroupDescription:ThingGroupDocument' :: Maybe Text
thingGroupDescription = forall a. Maybe a
Prelude.Nothing,
      $sel:thingGroupId:ThingGroupDocument' :: Maybe Text
thingGroupId = forall a. Maybe a
Prelude.Nothing,
      $sel:thingGroupName:ThingGroupDocument' :: Maybe Text
thingGroupName = forall a. Maybe a
Prelude.Nothing
    }

-- | The thing group attributes.
thingGroupDocument_attributes :: Lens.Lens' ThingGroupDocument (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
thingGroupDocument_attributes :: Lens' ThingGroupDocument (Maybe (HashMap Text Text))
thingGroupDocument_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingGroupDocument' {Maybe (HashMap Text Text)
attributes :: Maybe (HashMap Text Text)
$sel:attributes:ThingGroupDocument' :: ThingGroupDocument -> Maybe (HashMap Text Text)
attributes} -> Maybe (HashMap Text Text)
attributes) (\s :: ThingGroupDocument
s@ThingGroupDocument' {} Maybe (HashMap Text Text)
a -> ThingGroupDocument
s {$sel:attributes:ThingGroupDocument' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
a} :: ThingGroupDocument) 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

-- | Parent group names.
thingGroupDocument_parentGroupNames :: Lens.Lens' ThingGroupDocument (Prelude.Maybe [Prelude.Text])
thingGroupDocument_parentGroupNames :: Lens' ThingGroupDocument (Maybe [Text])
thingGroupDocument_parentGroupNames = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingGroupDocument' {Maybe [Text]
parentGroupNames :: Maybe [Text]
$sel:parentGroupNames:ThingGroupDocument' :: ThingGroupDocument -> Maybe [Text]
parentGroupNames} -> Maybe [Text]
parentGroupNames) (\s :: ThingGroupDocument
s@ThingGroupDocument' {} Maybe [Text]
a -> ThingGroupDocument
s {$sel:parentGroupNames:ThingGroupDocument' :: Maybe [Text]
parentGroupNames = Maybe [Text]
a} :: ThingGroupDocument) 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

-- | The thing group description.
thingGroupDocument_thingGroupDescription :: Lens.Lens' ThingGroupDocument (Prelude.Maybe Prelude.Text)
thingGroupDocument_thingGroupDescription :: Lens' ThingGroupDocument (Maybe Text)
thingGroupDocument_thingGroupDescription = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingGroupDocument' {Maybe Text
thingGroupDescription :: Maybe Text
$sel:thingGroupDescription:ThingGroupDocument' :: ThingGroupDocument -> Maybe Text
thingGroupDescription} -> Maybe Text
thingGroupDescription) (\s :: ThingGroupDocument
s@ThingGroupDocument' {} Maybe Text
a -> ThingGroupDocument
s {$sel:thingGroupDescription:ThingGroupDocument' :: Maybe Text
thingGroupDescription = Maybe Text
a} :: ThingGroupDocument)

-- | The thing group ID.
thingGroupDocument_thingGroupId :: Lens.Lens' ThingGroupDocument (Prelude.Maybe Prelude.Text)
thingGroupDocument_thingGroupId :: Lens' ThingGroupDocument (Maybe Text)
thingGroupDocument_thingGroupId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingGroupDocument' {Maybe Text
thingGroupId :: Maybe Text
$sel:thingGroupId:ThingGroupDocument' :: ThingGroupDocument -> Maybe Text
thingGroupId} -> Maybe Text
thingGroupId) (\s :: ThingGroupDocument
s@ThingGroupDocument' {} Maybe Text
a -> ThingGroupDocument
s {$sel:thingGroupId:ThingGroupDocument' :: Maybe Text
thingGroupId = Maybe Text
a} :: ThingGroupDocument)

-- | The thing group name.
thingGroupDocument_thingGroupName :: Lens.Lens' ThingGroupDocument (Prelude.Maybe Prelude.Text)
thingGroupDocument_thingGroupName :: Lens' ThingGroupDocument (Maybe Text)
thingGroupDocument_thingGroupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingGroupDocument' {Maybe Text
thingGroupName :: Maybe Text
$sel:thingGroupName:ThingGroupDocument' :: ThingGroupDocument -> Maybe Text
thingGroupName} -> Maybe Text
thingGroupName) (\s :: ThingGroupDocument
s@ThingGroupDocument' {} Maybe Text
a -> ThingGroupDocument
s {$sel:thingGroupName:ThingGroupDocument' :: Maybe Text
thingGroupName = Maybe Text
a} :: ThingGroupDocument)

instance Data.FromJSON ThingGroupDocument where
  parseJSON :: Value -> Parser ThingGroupDocument
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ThingGroupDocument"
      ( \Object
x ->
          Maybe (HashMap Text Text)
-> Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> ThingGroupDocument
ThingGroupDocument'
            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
"attributes" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"parentGroupNames"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            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
"thingGroupDescription")
            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
"thingGroupId")
            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
"thingGroupName")
      )

instance Prelude.Hashable ThingGroupDocument where
  hashWithSalt :: Int -> ThingGroupDocument -> Int
hashWithSalt Int
_salt ThingGroupDocument' {Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
thingGroupName :: Maybe Text
thingGroupId :: Maybe Text
thingGroupDescription :: Maybe Text
parentGroupNames :: Maybe [Text]
attributes :: Maybe (HashMap Text Text)
$sel:thingGroupName:ThingGroupDocument' :: ThingGroupDocument -> Maybe Text
$sel:thingGroupId:ThingGroupDocument' :: ThingGroupDocument -> Maybe Text
$sel:thingGroupDescription:ThingGroupDocument' :: ThingGroupDocument -> Maybe Text
$sel:parentGroupNames:ThingGroupDocument' :: ThingGroupDocument -> Maybe [Text]
$sel:attributes:ThingGroupDocument' :: ThingGroupDocument -> Maybe (HashMap Text Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
attributes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
parentGroupNames
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
thingGroupDescription
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
thingGroupId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
thingGroupName

instance Prelude.NFData ThingGroupDocument where
  rnf :: ThingGroupDocument -> ()
rnf ThingGroupDocument' {Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
thingGroupName :: Maybe Text
thingGroupId :: Maybe Text
thingGroupDescription :: Maybe Text
parentGroupNames :: Maybe [Text]
attributes :: Maybe (HashMap Text Text)
$sel:thingGroupName:ThingGroupDocument' :: ThingGroupDocument -> Maybe Text
$sel:thingGroupId:ThingGroupDocument' :: ThingGroupDocument -> Maybe Text
$sel:thingGroupDescription:ThingGroupDocument' :: ThingGroupDocument -> Maybe Text
$sel:parentGroupNames:ThingGroupDocument' :: ThingGroupDocument -> Maybe [Text]
$sel:attributes:ThingGroupDocument' :: ThingGroupDocument -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
attributes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
parentGroupNames
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
thingGroupDescription
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
thingGroupId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
thingGroupName