{-# 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.AddThingsToThingGroupParams
-- 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.AddThingsToThingGroupParams 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

-- | Parameters used when defining a mitigation action that move a set of
-- things to a thing group.
--
-- /See:/ 'newAddThingsToThingGroupParams' smart constructor.
data AddThingsToThingGroupParams = AddThingsToThingGroupParams'
  { -- | Specifies if this mitigation action can move the things that triggered
    -- the mitigation action even if they are part of one or more dynamic thing
    -- groups.
    AddThingsToThingGroupParams -> Maybe Bool
overrideDynamicGroups :: Prelude.Maybe Prelude.Bool,
    -- | The list of groups to which you want to add the things that triggered
    -- the mitigation action. You can add a thing to a maximum of 10 groups,
    -- but you can\'t add a thing to more than one group in the same hierarchy.
    AddThingsToThingGroupParams -> NonEmpty Text
thingGroupNames :: Prelude.NonEmpty Prelude.Text
  }
  deriving (AddThingsToThingGroupParams -> AddThingsToThingGroupParams -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AddThingsToThingGroupParams -> AddThingsToThingGroupParams -> Bool
$c/= :: AddThingsToThingGroupParams -> AddThingsToThingGroupParams -> Bool
== :: AddThingsToThingGroupParams -> AddThingsToThingGroupParams -> Bool
$c== :: AddThingsToThingGroupParams -> AddThingsToThingGroupParams -> Bool
Prelude.Eq, ReadPrec [AddThingsToThingGroupParams]
ReadPrec AddThingsToThingGroupParams
Int -> ReadS AddThingsToThingGroupParams
ReadS [AddThingsToThingGroupParams]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AddThingsToThingGroupParams]
$creadListPrec :: ReadPrec [AddThingsToThingGroupParams]
readPrec :: ReadPrec AddThingsToThingGroupParams
$creadPrec :: ReadPrec AddThingsToThingGroupParams
readList :: ReadS [AddThingsToThingGroupParams]
$creadList :: ReadS [AddThingsToThingGroupParams]
readsPrec :: Int -> ReadS AddThingsToThingGroupParams
$creadsPrec :: Int -> ReadS AddThingsToThingGroupParams
Prelude.Read, Int -> AddThingsToThingGroupParams -> ShowS
[AddThingsToThingGroupParams] -> ShowS
AddThingsToThingGroupParams -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AddThingsToThingGroupParams] -> ShowS
$cshowList :: [AddThingsToThingGroupParams] -> ShowS
show :: AddThingsToThingGroupParams -> String
$cshow :: AddThingsToThingGroupParams -> String
showsPrec :: Int -> AddThingsToThingGroupParams -> ShowS
$cshowsPrec :: Int -> AddThingsToThingGroupParams -> ShowS
Prelude.Show, forall x.
Rep AddThingsToThingGroupParams x -> AddThingsToThingGroupParams
forall x.
AddThingsToThingGroupParams -> Rep AddThingsToThingGroupParams x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AddThingsToThingGroupParams x -> AddThingsToThingGroupParams
$cfrom :: forall x.
AddThingsToThingGroupParams -> Rep AddThingsToThingGroupParams x
Prelude.Generic)

-- |
-- Create a value of 'AddThingsToThingGroupParams' 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:
--
-- 'overrideDynamicGroups', 'addThingsToThingGroupParams_overrideDynamicGroups' - Specifies if this mitigation action can move the things that triggered
-- the mitigation action even if they are part of one or more dynamic thing
-- groups.
--
-- 'thingGroupNames', 'addThingsToThingGroupParams_thingGroupNames' - The list of groups to which you want to add the things that triggered
-- the mitigation action. You can add a thing to a maximum of 10 groups,
-- but you can\'t add a thing to more than one group in the same hierarchy.
newAddThingsToThingGroupParams ::
  -- | 'thingGroupNames'
  Prelude.NonEmpty Prelude.Text ->
  AddThingsToThingGroupParams
newAddThingsToThingGroupParams :: NonEmpty Text -> AddThingsToThingGroupParams
newAddThingsToThingGroupParams NonEmpty Text
pThingGroupNames_ =
  AddThingsToThingGroupParams'
    { $sel:overrideDynamicGroups:AddThingsToThingGroupParams' :: Maybe Bool
overrideDynamicGroups =
        forall a. Maybe a
Prelude.Nothing,
      $sel:thingGroupNames:AddThingsToThingGroupParams' :: NonEmpty Text
thingGroupNames =
        forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pThingGroupNames_
    }

-- | Specifies if this mitigation action can move the things that triggered
-- the mitigation action even if they are part of one or more dynamic thing
-- groups.
addThingsToThingGroupParams_overrideDynamicGroups :: Lens.Lens' AddThingsToThingGroupParams (Prelude.Maybe Prelude.Bool)
addThingsToThingGroupParams_overrideDynamicGroups :: Lens' AddThingsToThingGroupParams (Maybe Bool)
addThingsToThingGroupParams_overrideDynamicGroups = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddThingsToThingGroupParams' {Maybe Bool
overrideDynamicGroups :: Maybe Bool
$sel:overrideDynamicGroups:AddThingsToThingGroupParams' :: AddThingsToThingGroupParams -> Maybe Bool
overrideDynamicGroups} -> Maybe Bool
overrideDynamicGroups) (\s :: AddThingsToThingGroupParams
s@AddThingsToThingGroupParams' {} Maybe Bool
a -> AddThingsToThingGroupParams
s {$sel:overrideDynamicGroups:AddThingsToThingGroupParams' :: Maybe Bool
overrideDynamicGroups = Maybe Bool
a} :: AddThingsToThingGroupParams)

-- | The list of groups to which you want to add the things that triggered
-- the mitigation action. You can add a thing to a maximum of 10 groups,
-- but you can\'t add a thing to more than one group in the same hierarchy.
addThingsToThingGroupParams_thingGroupNames :: Lens.Lens' AddThingsToThingGroupParams (Prelude.NonEmpty Prelude.Text)
addThingsToThingGroupParams_thingGroupNames :: Lens' AddThingsToThingGroupParams (NonEmpty Text)
addThingsToThingGroupParams_thingGroupNames = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AddThingsToThingGroupParams' {NonEmpty Text
thingGroupNames :: NonEmpty Text
$sel:thingGroupNames:AddThingsToThingGroupParams' :: AddThingsToThingGroupParams -> NonEmpty Text
thingGroupNames} -> NonEmpty Text
thingGroupNames) (\s :: AddThingsToThingGroupParams
s@AddThingsToThingGroupParams' {} NonEmpty Text
a -> AddThingsToThingGroupParams
s {$sel:thingGroupNames:AddThingsToThingGroupParams' :: NonEmpty Text
thingGroupNames = NonEmpty Text
a} :: AddThingsToThingGroupParams) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON AddThingsToThingGroupParams where
  parseJSON :: Value -> Parser AddThingsToThingGroupParams
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AddThingsToThingGroupParams"
      ( \Object
x ->
          Maybe Bool -> NonEmpty Text -> AddThingsToThingGroupParams
AddThingsToThingGroupParams'
            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
"overrideDynamicGroups")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"thingGroupNames")
      )

instance Prelude.Hashable AddThingsToThingGroupParams where
  hashWithSalt :: Int -> AddThingsToThingGroupParams -> Int
hashWithSalt Int
_salt AddThingsToThingGroupParams' {Maybe Bool
NonEmpty Text
thingGroupNames :: NonEmpty Text
overrideDynamicGroups :: Maybe Bool
$sel:thingGroupNames:AddThingsToThingGroupParams' :: AddThingsToThingGroupParams -> NonEmpty Text
$sel:overrideDynamicGroups:AddThingsToThingGroupParams' :: AddThingsToThingGroupParams -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
overrideDynamicGroups
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
thingGroupNames

instance Prelude.NFData AddThingsToThingGroupParams where
  rnf :: AddThingsToThingGroupParams -> ()
rnf AddThingsToThingGroupParams' {Maybe Bool
NonEmpty Text
thingGroupNames :: NonEmpty Text
overrideDynamicGroups :: Maybe Bool
$sel:thingGroupNames:AddThingsToThingGroupParams' :: AddThingsToThingGroupParams -> NonEmpty Text
$sel:overrideDynamicGroups:AddThingsToThingGroupParams' :: AddThingsToThingGroupParams -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
overrideDynamicGroups
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
thingGroupNames

instance Data.ToJSON AddThingsToThingGroupParams where
  toJSON :: AddThingsToThingGroupParams -> Value
toJSON AddThingsToThingGroupParams' {Maybe Bool
NonEmpty Text
thingGroupNames :: NonEmpty Text
overrideDynamicGroups :: Maybe Bool
$sel:thingGroupNames:AddThingsToThingGroupParams' :: AddThingsToThingGroupParams -> NonEmpty Text
$sel:overrideDynamicGroups:AddThingsToThingGroupParams' :: AddThingsToThingGroupParams -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"overrideDynamicGroups" 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 Bool
overrideDynamicGroups,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"thingGroupNames" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
thingGroupNames)
          ]
      )