{-# 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.ThingGroupProperties
-- 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.ThingGroupProperties 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.AttributePayload
import qualified Amazonka.Prelude as Prelude

-- | Thing group properties.
--
-- /See:/ 'newThingGroupProperties' smart constructor.
data ThingGroupProperties = ThingGroupProperties'
  { -- | The thing group attributes in JSON format.
    ThingGroupProperties -> Maybe AttributePayload
attributePayload :: Prelude.Maybe AttributePayload,
    -- | The thing group description.
    ThingGroupProperties -> Maybe Text
thingGroupDescription :: Prelude.Maybe Prelude.Text
  }
  deriving (ThingGroupProperties -> ThingGroupProperties -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ThingGroupProperties -> ThingGroupProperties -> Bool
$c/= :: ThingGroupProperties -> ThingGroupProperties -> Bool
== :: ThingGroupProperties -> ThingGroupProperties -> Bool
$c== :: ThingGroupProperties -> ThingGroupProperties -> Bool
Prelude.Eq, ReadPrec [ThingGroupProperties]
ReadPrec ThingGroupProperties
Int -> ReadS ThingGroupProperties
ReadS [ThingGroupProperties]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ThingGroupProperties]
$creadListPrec :: ReadPrec [ThingGroupProperties]
readPrec :: ReadPrec ThingGroupProperties
$creadPrec :: ReadPrec ThingGroupProperties
readList :: ReadS [ThingGroupProperties]
$creadList :: ReadS [ThingGroupProperties]
readsPrec :: Int -> ReadS ThingGroupProperties
$creadsPrec :: Int -> ReadS ThingGroupProperties
Prelude.Read, Int -> ThingGroupProperties -> ShowS
[ThingGroupProperties] -> ShowS
ThingGroupProperties -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ThingGroupProperties] -> ShowS
$cshowList :: [ThingGroupProperties] -> ShowS
show :: ThingGroupProperties -> String
$cshow :: ThingGroupProperties -> String
showsPrec :: Int -> ThingGroupProperties -> ShowS
$cshowsPrec :: Int -> ThingGroupProperties -> ShowS
Prelude.Show, forall x. Rep ThingGroupProperties x -> ThingGroupProperties
forall x. ThingGroupProperties -> Rep ThingGroupProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ThingGroupProperties x -> ThingGroupProperties
$cfrom :: forall x. ThingGroupProperties -> Rep ThingGroupProperties x
Prelude.Generic)

-- |
-- Create a value of 'ThingGroupProperties' 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:
--
-- 'attributePayload', 'thingGroupProperties_attributePayload' - The thing group attributes in JSON format.
--
-- 'thingGroupDescription', 'thingGroupProperties_thingGroupDescription' - The thing group description.
newThingGroupProperties ::
  ThingGroupProperties
newThingGroupProperties :: ThingGroupProperties
newThingGroupProperties =
  ThingGroupProperties'
    { $sel:attributePayload:ThingGroupProperties' :: Maybe AttributePayload
attributePayload =
        forall a. Maybe a
Prelude.Nothing,
      $sel:thingGroupDescription:ThingGroupProperties' :: Maybe Text
thingGroupDescription = forall a. Maybe a
Prelude.Nothing
    }

-- | The thing group attributes in JSON format.
thingGroupProperties_attributePayload :: Lens.Lens' ThingGroupProperties (Prelude.Maybe AttributePayload)
thingGroupProperties_attributePayload :: Lens' ThingGroupProperties (Maybe AttributePayload)
thingGroupProperties_attributePayload = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThingGroupProperties' {Maybe AttributePayload
attributePayload :: Maybe AttributePayload
$sel:attributePayload:ThingGroupProperties' :: ThingGroupProperties -> Maybe AttributePayload
attributePayload} -> Maybe AttributePayload
attributePayload) (\s :: ThingGroupProperties
s@ThingGroupProperties' {} Maybe AttributePayload
a -> ThingGroupProperties
s {$sel:attributePayload:ThingGroupProperties' :: Maybe AttributePayload
attributePayload = Maybe AttributePayload
a} :: ThingGroupProperties)

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

instance Data.FromJSON ThingGroupProperties where
  parseJSON :: Value -> Parser ThingGroupProperties
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ThingGroupProperties"
      ( \Object
x ->
          Maybe AttributePayload -> Maybe Text -> ThingGroupProperties
ThingGroupProperties'
            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
"attributePayload")
            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")
      )

instance Prelude.Hashable ThingGroupProperties where
  hashWithSalt :: Int -> ThingGroupProperties -> Int
hashWithSalt Int
_salt ThingGroupProperties' {Maybe Text
Maybe AttributePayload
thingGroupDescription :: Maybe Text
attributePayload :: Maybe AttributePayload
$sel:thingGroupDescription:ThingGroupProperties' :: ThingGroupProperties -> Maybe Text
$sel:attributePayload:ThingGroupProperties' :: ThingGroupProperties -> Maybe AttributePayload
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AttributePayload
attributePayload
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
thingGroupDescription

instance Prelude.NFData ThingGroupProperties where
  rnf :: ThingGroupProperties -> ()
rnf ThingGroupProperties' {Maybe Text
Maybe AttributePayload
thingGroupDescription :: Maybe Text
attributePayload :: Maybe AttributePayload
$sel:thingGroupDescription:ThingGroupProperties' :: ThingGroupProperties -> Maybe Text
$sel:attributePayload:ThingGroupProperties' :: ThingGroupProperties -> Maybe AttributePayload
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AttributePayload
attributePayload
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
thingGroupDescription

instance Data.ToJSON ThingGroupProperties where
  toJSON :: ThingGroupProperties -> Value
toJSON ThingGroupProperties' {Maybe Text
Maybe AttributePayload
thingGroupDescription :: Maybe Text
attributePayload :: Maybe AttributePayload
$sel:thingGroupDescription:ThingGroupProperties' :: ThingGroupProperties -> Maybe Text
$sel:attributePayload:ThingGroupProperties' :: ThingGroupProperties -> Maybe AttributePayload
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"attributePayload" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AttributePayload
attributePayload,
            (Key
"thingGroupDescription" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
thingGroupDescription
          ]
      )