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

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

-- | The target of a mitigation action task.
--
-- /See:/ 'newDetectMitigationActionsTaskTarget' smart constructor.
data DetectMitigationActionsTaskTarget = DetectMitigationActionsTaskTarget'
  { -- | The unique identifiers of the violations.
    DetectMitigationActionsTaskTarget -> Maybe (NonEmpty Text)
violationIds :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The name of the behavior.
    DetectMitigationActionsTaskTarget -> Maybe Text
behaviorName :: Prelude.Maybe Prelude.Text,
    -- | The name of the security profile.
    DetectMitigationActionsTaskTarget -> Maybe Text
securityProfileName :: Prelude.Maybe Prelude.Text
  }
  deriving (DetectMitigationActionsTaskTarget
-> DetectMitigationActionsTaskTarget -> Bool
(DetectMitigationActionsTaskTarget
 -> DetectMitigationActionsTaskTarget -> Bool)
-> (DetectMitigationActionsTaskTarget
    -> DetectMitigationActionsTaskTarget -> Bool)
-> Eq DetectMitigationActionsTaskTarget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectMitigationActionsTaskTarget
-> DetectMitigationActionsTaskTarget -> Bool
$c/= :: DetectMitigationActionsTaskTarget
-> DetectMitigationActionsTaskTarget -> Bool
== :: DetectMitigationActionsTaskTarget
-> DetectMitigationActionsTaskTarget -> Bool
$c== :: DetectMitigationActionsTaskTarget
-> DetectMitigationActionsTaskTarget -> Bool
Prelude.Eq, ReadPrec [DetectMitigationActionsTaskTarget]
ReadPrec DetectMitigationActionsTaskTarget
Int -> ReadS DetectMitigationActionsTaskTarget
ReadS [DetectMitigationActionsTaskTarget]
(Int -> ReadS DetectMitigationActionsTaskTarget)
-> ReadS [DetectMitigationActionsTaskTarget]
-> ReadPrec DetectMitigationActionsTaskTarget
-> ReadPrec [DetectMitigationActionsTaskTarget]
-> Read DetectMitigationActionsTaskTarget
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetectMitigationActionsTaskTarget]
$creadListPrec :: ReadPrec [DetectMitigationActionsTaskTarget]
readPrec :: ReadPrec DetectMitigationActionsTaskTarget
$creadPrec :: ReadPrec DetectMitigationActionsTaskTarget
readList :: ReadS [DetectMitigationActionsTaskTarget]
$creadList :: ReadS [DetectMitigationActionsTaskTarget]
readsPrec :: Int -> ReadS DetectMitigationActionsTaskTarget
$creadsPrec :: Int -> ReadS DetectMitigationActionsTaskTarget
Prelude.Read, Int -> DetectMitigationActionsTaskTarget -> ShowS
[DetectMitigationActionsTaskTarget] -> ShowS
DetectMitigationActionsTaskTarget -> String
(Int -> DetectMitigationActionsTaskTarget -> ShowS)
-> (DetectMitigationActionsTaskTarget -> String)
-> ([DetectMitigationActionsTaskTarget] -> ShowS)
-> Show DetectMitigationActionsTaskTarget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectMitigationActionsTaskTarget] -> ShowS
$cshowList :: [DetectMitigationActionsTaskTarget] -> ShowS
show :: DetectMitigationActionsTaskTarget -> String
$cshow :: DetectMitigationActionsTaskTarget -> String
showsPrec :: Int -> DetectMitigationActionsTaskTarget -> ShowS
$cshowsPrec :: Int -> DetectMitigationActionsTaskTarget -> ShowS
Prelude.Show, (forall x.
 DetectMitigationActionsTaskTarget
 -> Rep DetectMitigationActionsTaskTarget x)
-> (forall x.
    Rep DetectMitigationActionsTaskTarget x
    -> DetectMitigationActionsTaskTarget)
-> Generic DetectMitigationActionsTaskTarget
forall x.
Rep DetectMitigationActionsTaskTarget x
-> DetectMitigationActionsTaskTarget
forall x.
DetectMitigationActionsTaskTarget
-> Rep DetectMitigationActionsTaskTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DetectMitigationActionsTaskTarget x
-> DetectMitigationActionsTaskTarget
$cfrom :: forall x.
DetectMitigationActionsTaskTarget
-> Rep DetectMitigationActionsTaskTarget x
Prelude.Generic)

-- |
-- Create a value of 'DetectMitigationActionsTaskTarget' 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:
--
-- 'violationIds', 'detectMitigationActionsTaskTarget_violationIds' - The unique identifiers of the violations.
--
-- 'behaviorName', 'detectMitigationActionsTaskTarget_behaviorName' - The name of the behavior.
--
-- 'securityProfileName', 'detectMitigationActionsTaskTarget_securityProfileName' - The name of the security profile.
newDetectMitigationActionsTaskTarget ::
  DetectMitigationActionsTaskTarget
newDetectMitigationActionsTaskTarget :: DetectMitigationActionsTaskTarget
newDetectMitigationActionsTaskTarget =
  DetectMitigationActionsTaskTarget' :: Maybe (NonEmpty Text)
-> Maybe Text -> Maybe Text -> DetectMitigationActionsTaskTarget
DetectMitigationActionsTaskTarget'
    { $sel:violationIds:DetectMitigationActionsTaskTarget' :: Maybe (NonEmpty Text)
violationIds =
        Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:behaviorName:DetectMitigationActionsTaskTarget' :: Maybe Text
behaviorName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:securityProfileName:DetectMitigationActionsTaskTarget' :: Maybe Text
securityProfileName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The unique identifiers of the violations.
detectMitigationActionsTaskTarget_violationIds :: Lens.Lens' DetectMitigationActionsTaskTarget (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
detectMitigationActionsTaskTarget_violationIds :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> DetectMitigationActionsTaskTarget
-> f DetectMitigationActionsTaskTarget
detectMitigationActionsTaskTarget_violationIds = (DetectMitigationActionsTaskTarget -> Maybe (NonEmpty Text))
-> (DetectMitigationActionsTaskTarget
    -> Maybe (NonEmpty Text) -> DetectMitigationActionsTaskTarget)
-> Lens
     DetectMitigationActionsTaskTarget
     DetectMitigationActionsTaskTarget
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectMitigationActionsTaskTarget' {Maybe (NonEmpty Text)
violationIds :: Maybe (NonEmpty Text)
$sel:violationIds:DetectMitigationActionsTaskTarget' :: DetectMitigationActionsTaskTarget -> Maybe (NonEmpty Text)
violationIds} -> Maybe (NonEmpty Text)
violationIds) (\s :: DetectMitigationActionsTaskTarget
s@DetectMitigationActionsTaskTarget' {} Maybe (NonEmpty Text)
a -> DetectMitigationActionsTaskTarget
s {$sel:violationIds:DetectMitigationActionsTaskTarget' :: Maybe (NonEmpty Text)
violationIds = Maybe (NonEmpty Text)
a} :: DetectMitigationActionsTaskTarget) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> DetectMitigationActionsTaskTarget
 -> f DetectMitigationActionsTaskTarget)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> DetectMitigationActionsTaskTarget
-> f DetectMitigationActionsTaskTarget
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the behavior.
detectMitigationActionsTaskTarget_behaviorName :: Lens.Lens' DetectMitigationActionsTaskTarget (Prelude.Maybe Prelude.Text)
detectMitigationActionsTaskTarget_behaviorName :: (Maybe Text -> f (Maybe Text))
-> DetectMitigationActionsTaskTarget
-> f DetectMitigationActionsTaskTarget
detectMitigationActionsTaskTarget_behaviorName = (DetectMitigationActionsTaskTarget -> Maybe Text)
-> (DetectMitigationActionsTaskTarget
    -> Maybe Text -> DetectMitigationActionsTaskTarget)
-> Lens
     DetectMitigationActionsTaskTarget
     DetectMitigationActionsTaskTarget
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectMitigationActionsTaskTarget' {Maybe Text
behaviorName :: Maybe Text
$sel:behaviorName:DetectMitigationActionsTaskTarget' :: DetectMitigationActionsTaskTarget -> Maybe Text
behaviorName} -> Maybe Text
behaviorName) (\s :: DetectMitigationActionsTaskTarget
s@DetectMitigationActionsTaskTarget' {} Maybe Text
a -> DetectMitigationActionsTaskTarget
s {$sel:behaviorName:DetectMitigationActionsTaskTarget' :: Maybe Text
behaviorName = Maybe Text
a} :: DetectMitigationActionsTaskTarget)

-- | The name of the security profile.
detectMitigationActionsTaskTarget_securityProfileName :: Lens.Lens' DetectMitigationActionsTaskTarget (Prelude.Maybe Prelude.Text)
detectMitigationActionsTaskTarget_securityProfileName :: (Maybe Text -> f (Maybe Text))
-> DetectMitigationActionsTaskTarget
-> f DetectMitigationActionsTaskTarget
detectMitigationActionsTaskTarget_securityProfileName = (DetectMitigationActionsTaskTarget -> Maybe Text)
-> (DetectMitigationActionsTaskTarget
    -> Maybe Text -> DetectMitigationActionsTaskTarget)
-> Lens
     DetectMitigationActionsTaskTarget
     DetectMitigationActionsTaskTarget
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectMitigationActionsTaskTarget' {Maybe Text
securityProfileName :: Maybe Text
$sel:securityProfileName:DetectMitigationActionsTaskTarget' :: DetectMitigationActionsTaskTarget -> Maybe Text
securityProfileName} -> Maybe Text
securityProfileName) (\s :: DetectMitigationActionsTaskTarget
s@DetectMitigationActionsTaskTarget' {} Maybe Text
a -> DetectMitigationActionsTaskTarget
s {$sel:securityProfileName:DetectMitigationActionsTaskTarget' :: Maybe Text
securityProfileName = Maybe Text
a} :: DetectMitigationActionsTaskTarget)

instance
  Core.FromJSON
    DetectMitigationActionsTaskTarget
  where
  parseJSON :: Value -> Parser DetectMitigationActionsTaskTarget
parseJSON =
    String
-> (Object -> Parser DetectMitigationActionsTaskTarget)
-> Value
-> Parser DetectMitigationActionsTaskTarget
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DetectMitigationActionsTaskTarget"
      ( \Object
x ->
          Maybe (NonEmpty Text)
-> Maybe Text -> Maybe Text -> DetectMitigationActionsTaskTarget
DetectMitigationActionsTaskTarget'
            (Maybe (NonEmpty Text)
 -> Maybe Text -> Maybe Text -> DetectMitigationActionsTaskTarget)
-> Parser (Maybe (NonEmpty Text))
-> Parser
     (Maybe Text -> Maybe Text -> DetectMitigationActionsTaskTarget)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (NonEmpty Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"violationIds")
            Parser
  (Maybe Text -> Maybe Text -> DetectMitigationActionsTaskTarget)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> DetectMitigationActionsTaskTarget)
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
"behaviorName")
            Parser (Maybe Text -> DetectMitigationActionsTaskTarget)
-> Parser (Maybe Text) -> Parser DetectMitigationActionsTaskTarget
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
"securityProfileName")
      )

instance
  Prelude.Hashable
    DetectMitigationActionsTaskTarget

instance
  Prelude.NFData
    DetectMitigationActionsTaskTarget

instance
  Core.ToJSON
    DetectMitigationActionsTaskTarget
  where
  toJSON :: DetectMitigationActionsTaskTarget -> Value
toJSON DetectMitigationActionsTaskTarget' {Maybe (NonEmpty Text)
Maybe Text
securityProfileName :: Maybe Text
behaviorName :: Maybe Text
violationIds :: Maybe (NonEmpty Text)
$sel:securityProfileName:DetectMitigationActionsTaskTarget' :: DetectMitigationActionsTaskTarget -> Maybe Text
$sel:behaviorName:DetectMitigationActionsTaskTarget' :: DetectMitigationActionsTaskTarget -> Maybe Text
$sel:violationIds:DetectMitigationActionsTaskTarget' :: DetectMitigationActionsTaskTarget -> Maybe (NonEmpty Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"violationIds" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
violationIds,
            (Text
"behaviorName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
behaviorName,
            (Text
"securityProfileName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
securityProfileName
          ]
      )