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

-- | Used in MitigationActionParams, this information identifies the target
-- findings to which the mitigation actions are applied. Only one entry
-- appears.
--
-- /See:/ 'newAuditMitigationActionsTaskTarget' smart constructor.
data AuditMitigationActionsTaskTarget = AuditMitigationActionsTaskTarget'
  { -- | Specifies a filter in the form of an audit check and set of reason codes
    -- that identify the findings from the audit to which the audit mitigation
    -- actions task apply.
    AuditMitigationActionsTaskTarget
-> Maybe (HashMap Text (NonEmpty Text))
auditCheckToReasonCodeFilter :: Prelude.Maybe (Prelude.HashMap Prelude.Text (Prelude.NonEmpty Prelude.Text)),
    -- | If the task will apply a mitigation action to findings from a specific
    -- audit, this value uniquely identifies the audit.
    AuditMitigationActionsTaskTarget -> Maybe Text
auditTaskId :: Prelude.Maybe Prelude.Text,
    -- | If the task will apply a mitigation action to one or more listed
    -- findings, this value uniquely identifies those findings.
    AuditMitigationActionsTaskTarget -> Maybe (NonEmpty Text)
findingIds :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text)
  }
  deriving (AuditMitigationActionsTaskTarget
-> AuditMitigationActionsTaskTarget -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AuditMitigationActionsTaskTarget
-> AuditMitigationActionsTaskTarget -> Bool
$c/= :: AuditMitigationActionsTaskTarget
-> AuditMitigationActionsTaskTarget -> Bool
== :: AuditMitigationActionsTaskTarget
-> AuditMitigationActionsTaskTarget -> Bool
$c== :: AuditMitigationActionsTaskTarget
-> AuditMitigationActionsTaskTarget -> Bool
Prelude.Eq, ReadPrec [AuditMitigationActionsTaskTarget]
ReadPrec AuditMitigationActionsTaskTarget
Int -> ReadS AuditMitigationActionsTaskTarget
ReadS [AuditMitigationActionsTaskTarget]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AuditMitigationActionsTaskTarget]
$creadListPrec :: ReadPrec [AuditMitigationActionsTaskTarget]
readPrec :: ReadPrec AuditMitigationActionsTaskTarget
$creadPrec :: ReadPrec AuditMitigationActionsTaskTarget
readList :: ReadS [AuditMitigationActionsTaskTarget]
$creadList :: ReadS [AuditMitigationActionsTaskTarget]
readsPrec :: Int -> ReadS AuditMitigationActionsTaskTarget
$creadsPrec :: Int -> ReadS AuditMitigationActionsTaskTarget
Prelude.Read, Int -> AuditMitigationActionsTaskTarget -> ShowS
[AuditMitigationActionsTaskTarget] -> ShowS
AuditMitigationActionsTaskTarget -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AuditMitigationActionsTaskTarget] -> ShowS
$cshowList :: [AuditMitigationActionsTaskTarget] -> ShowS
show :: AuditMitigationActionsTaskTarget -> String
$cshow :: AuditMitigationActionsTaskTarget -> String
showsPrec :: Int -> AuditMitigationActionsTaskTarget -> ShowS
$cshowsPrec :: Int -> AuditMitigationActionsTaskTarget -> ShowS
Prelude.Show, forall x.
Rep AuditMitigationActionsTaskTarget x
-> AuditMitigationActionsTaskTarget
forall x.
AuditMitigationActionsTaskTarget
-> Rep AuditMitigationActionsTaskTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AuditMitigationActionsTaskTarget x
-> AuditMitigationActionsTaskTarget
$cfrom :: forall x.
AuditMitigationActionsTaskTarget
-> Rep AuditMitigationActionsTaskTarget x
Prelude.Generic)

-- |
-- Create a value of 'AuditMitigationActionsTaskTarget' 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:
--
-- 'auditCheckToReasonCodeFilter', 'auditMitigationActionsTaskTarget_auditCheckToReasonCodeFilter' - Specifies a filter in the form of an audit check and set of reason codes
-- that identify the findings from the audit to which the audit mitigation
-- actions task apply.
--
-- 'auditTaskId', 'auditMitigationActionsTaskTarget_auditTaskId' - If the task will apply a mitigation action to findings from a specific
-- audit, this value uniquely identifies the audit.
--
-- 'findingIds', 'auditMitigationActionsTaskTarget_findingIds' - If the task will apply a mitigation action to one or more listed
-- findings, this value uniquely identifies those findings.
newAuditMitigationActionsTaskTarget ::
  AuditMitigationActionsTaskTarget
newAuditMitigationActionsTaskTarget :: AuditMitigationActionsTaskTarget
newAuditMitigationActionsTaskTarget =
  AuditMitigationActionsTaskTarget'
    { $sel:auditCheckToReasonCodeFilter:AuditMitigationActionsTaskTarget' :: Maybe (HashMap Text (NonEmpty Text))
auditCheckToReasonCodeFilter =
        forall a. Maybe a
Prelude.Nothing,
      $sel:auditTaskId:AuditMitigationActionsTaskTarget' :: Maybe Text
auditTaskId = forall a. Maybe a
Prelude.Nothing,
      $sel:findingIds:AuditMitigationActionsTaskTarget' :: Maybe (NonEmpty Text)
findingIds = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies a filter in the form of an audit check and set of reason codes
-- that identify the findings from the audit to which the audit mitigation
-- actions task apply.
auditMitigationActionsTaskTarget_auditCheckToReasonCodeFilter :: Lens.Lens' AuditMitigationActionsTaskTarget (Prelude.Maybe (Prelude.HashMap Prelude.Text (Prelude.NonEmpty Prelude.Text)))
auditMitigationActionsTaskTarget_auditCheckToReasonCodeFilter :: Lens'
  AuditMitigationActionsTaskTarget
  (Maybe (HashMap Text (NonEmpty Text)))
auditMitigationActionsTaskTarget_auditCheckToReasonCodeFilter = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuditMitigationActionsTaskTarget' {Maybe (HashMap Text (NonEmpty Text))
auditCheckToReasonCodeFilter :: Maybe (HashMap Text (NonEmpty Text))
$sel:auditCheckToReasonCodeFilter:AuditMitigationActionsTaskTarget' :: AuditMitigationActionsTaskTarget
-> Maybe (HashMap Text (NonEmpty Text))
auditCheckToReasonCodeFilter} -> Maybe (HashMap Text (NonEmpty Text))
auditCheckToReasonCodeFilter) (\s :: AuditMitigationActionsTaskTarget
s@AuditMitigationActionsTaskTarget' {} Maybe (HashMap Text (NonEmpty Text))
a -> AuditMitigationActionsTaskTarget
s {$sel:auditCheckToReasonCodeFilter:AuditMitigationActionsTaskTarget' :: Maybe (HashMap Text (NonEmpty Text))
auditCheckToReasonCodeFilter = Maybe (HashMap Text (NonEmpty Text))
a} :: AuditMitigationActionsTaskTarget) 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

-- | If the task will apply a mitigation action to findings from a specific
-- audit, this value uniquely identifies the audit.
auditMitigationActionsTaskTarget_auditTaskId :: Lens.Lens' AuditMitigationActionsTaskTarget (Prelude.Maybe Prelude.Text)
auditMitigationActionsTaskTarget_auditTaskId :: Lens' AuditMitigationActionsTaskTarget (Maybe Text)
auditMitigationActionsTaskTarget_auditTaskId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuditMitigationActionsTaskTarget' {Maybe Text
auditTaskId :: Maybe Text
$sel:auditTaskId:AuditMitigationActionsTaskTarget' :: AuditMitigationActionsTaskTarget -> Maybe Text
auditTaskId} -> Maybe Text
auditTaskId) (\s :: AuditMitigationActionsTaskTarget
s@AuditMitigationActionsTaskTarget' {} Maybe Text
a -> AuditMitigationActionsTaskTarget
s {$sel:auditTaskId:AuditMitigationActionsTaskTarget' :: Maybe Text
auditTaskId = Maybe Text
a} :: AuditMitigationActionsTaskTarget)

-- | If the task will apply a mitigation action to one or more listed
-- findings, this value uniquely identifies those findings.
auditMitigationActionsTaskTarget_findingIds :: Lens.Lens' AuditMitigationActionsTaskTarget (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
auditMitigationActionsTaskTarget_findingIds :: Lens' AuditMitigationActionsTaskTarget (Maybe (NonEmpty Text))
auditMitigationActionsTaskTarget_findingIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuditMitigationActionsTaskTarget' {Maybe (NonEmpty Text)
findingIds :: Maybe (NonEmpty Text)
$sel:findingIds:AuditMitigationActionsTaskTarget' :: AuditMitigationActionsTaskTarget -> Maybe (NonEmpty Text)
findingIds} -> Maybe (NonEmpty Text)
findingIds) (\s :: AuditMitigationActionsTaskTarget
s@AuditMitigationActionsTaskTarget' {} Maybe (NonEmpty Text)
a -> AuditMitigationActionsTaskTarget
s {$sel:findingIds:AuditMitigationActionsTaskTarget' :: Maybe (NonEmpty Text)
findingIds = Maybe (NonEmpty Text)
a} :: AuditMitigationActionsTaskTarget) 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
    AuditMitigationActionsTaskTarget
  where
  parseJSON :: Value -> Parser AuditMitigationActionsTaskTarget
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AuditMitigationActionsTaskTarget"
      ( \Object
x ->
          Maybe (HashMap Text (NonEmpty Text))
-> Maybe Text
-> Maybe (NonEmpty Text)
-> AuditMitigationActionsTaskTarget
AuditMitigationActionsTaskTarget'
            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
"auditCheckToReasonCodeFilter"
                            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
"auditTaskId")
            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
"findingIds")
      )

instance
  Prelude.Hashable
    AuditMitigationActionsTaskTarget
  where
  hashWithSalt :: Int -> AuditMitigationActionsTaskTarget -> Int
hashWithSalt
    Int
_salt
    AuditMitigationActionsTaskTarget' {Maybe (NonEmpty Text)
Maybe Text
Maybe (HashMap Text (NonEmpty Text))
findingIds :: Maybe (NonEmpty Text)
auditTaskId :: Maybe Text
auditCheckToReasonCodeFilter :: Maybe (HashMap Text (NonEmpty Text))
$sel:findingIds:AuditMitigationActionsTaskTarget' :: AuditMitigationActionsTaskTarget -> Maybe (NonEmpty Text)
$sel:auditTaskId:AuditMitigationActionsTaskTarget' :: AuditMitigationActionsTaskTarget -> Maybe Text
$sel:auditCheckToReasonCodeFilter:AuditMitigationActionsTaskTarget' :: AuditMitigationActionsTaskTarget
-> Maybe (HashMap Text (NonEmpty Text))
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text (NonEmpty Text))
auditCheckToReasonCodeFilter
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
auditTaskId
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
findingIds

instance
  Prelude.NFData
    AuditMitigationActionsTaskTarget
  where
  rnf :: AuditMitigationActionsTaskTarget -> ()
rnf AuditMitigationActionsTaskTarget' {Maybe (NonEmpty Text)
Maybe Text
Maybe (HashMap Text (NonEmpty Text))
findingIds :: Maybe (NonEmpty Text)
auditTaskId :: Maybe Text
auditCheckToReasonCodeFilter :: Maybe (HashMap Text (NonEmpty Text))
$sel:findingIds:AuditMitigationActionsTaskTarget' :: AuditMitigationActionsTaskTarget -> Maybe (NonEmpty Text)
$sel:auditTaskId:AuditMitigationActionsTaskTarget' :: AuditMitigationActionsTaskTarget -> Maybe Text
$sel:auditCheckToReasonCodeFilter:AuditMitigationActionsTaskTarget' :: AuditMitigationActionsTaskTarget
-> Maybe (HashMap Text (NonEmpty Text))
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text (NonEmpty Text))
auditCheckToReasonCodeFilter
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
auditTaskId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
findingIds

instance Data.ToJSON AuditMitigationActionsTaskTarget where
  toJSON :: AuditMitigationActionsTaskTarget -> Value
toJSON AuditMitigationActionsTaskTarget' {Maybe (NonEmpty Text)
Maybe Text
Maybe (HashMap Text (NonEmpty Text))
findingIds :: Maybe (NonEmpty Text)
auditTaskId :: Maybe Text
auditCheckToReasonCodeFilter :: Maybe (HashMap Text (NonEmpty Text))
$sel:findingIds:AuditMitigationActionsTaskTarget' :: AuditMitigationActionsTaskTarget -> Maybe (NonEmpty Text)
$sel:auditTaskId:AuditMitigationActionsTaskTarget' :: AuditMitigationActionsTaskTarget -> Maybe Text
$sel:auditCheckToReasonCodeFilter:AuditMitigationActionsTaskTarget' :: AuditMitigationActionsTaskTarget
-> Maybe (HashMap Text (NonEmpty Text))
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"auditCheckToReasonCodeFilter" 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 (HashMap Text (NonEmpty Text))
auditCheckToReasonCodeFilter,
            (Key
"auditTaskId" 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
auditTaskId,
            (Key
"findingIds" 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 (NonEmpty Text)
findingIds
          ]
      )