{-# 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.SecurityHub.Types.Remediation
-- 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.SecurityHub.Types.Remediation where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.Recommendation

-- | Details about the remediation steps for a finding.
--
-- /See:/ 'newRemediation' smart constructor.
data Remediation = Remediation'
  { -- | A recommendation on the steps to take to remediate the issue identified
    -- by a finding.
    Remediation -> Maybe Recommendation
recommendation :: Prelude.Maybe Recommendation
  }
  deriving (Remediation -> Remediation -> Bool
(Remediation -> Remediation -> Bool)
-> (Remediation -> Remediation -> Bool) -> Eq Remediation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Remediation -> Remediation -> Bool
$c/= :: Remediation -> Remediation -> Bool
== :: Remediation -> Remediation -> Bool
$c== :: Remediation -> Remediation -> Bool
Prelude.Eq, ReadPrec [Remediation]
ReadPrec Remediation
Int -> ReadS Remediation
ReadS [Remediation]
(Int -> ReadS Remediation)
-> ReadS [Remediation]
-> ReadPrec Remediation
-> ReadPrec [Remediation]
-> Read Remediation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Remediation]
$creadListPrec :: ReadPrec [Remediation]
readPrec :: ReadPrec Remediation
$creadPrec :: ReadPrec Remediation
readList :: ReadS [Remediation]
$creadList :: ReadS [Remediation]
readsPrec :: Int -> ReadS Remediation
$creadsPrec :: Int -> ReadS Remediation
Prelude.Read, Int -> Remediation -> ShowS
[Remediation] -> ShowS
Remediation -> String
(Int -> Remediation -> ShowS)
-> (Remediation -> String)
-> ([Remediation] -> ShowS)
-> Show Remediation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Remediation] -> ShowS
$cshowList :: [Remediation] -> ShowS
show :: Remediation -> String
$cshow :: Remediation -> String
showsPrec :: Int -> Remediation -> ShowS
$cshowsPrec :: Int -> Remediation -> ShowS
Prelude.Show, (forall x. Remediation -> Rep Remediation x)
-> (forall x. Rep Remediation x -> Remediation)
-> Generic Remediation
forall x. Rep Remediation x -> Remediation
forall x. Remediation -> Rep Remediation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Remediation x -> Remediation
$cfrom :: forall x. Remediation -> Rep Remediation x
Prelude.Generic)

-- |
-- Create a value of 'Remediation' 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:
--
-- 'recommendation', 'remediation_recommendation' - A recommendation on the steps to take to remediate the issue identified
-- by a finding.
newRemediation ::
  Remediation
newRemediation :: Remediation
newRemediation =
  Remediation' :: Maybe Recommendation -> Remediation
Remediation' {$sel:recommendation:Remediation' :: Maybe Recommendation
recommendation = Maybe Recommendation
forall a. Maybe a
Prelude.Nothing}

-- | A recommendation on the steps to take to remediate the issue identified
-- by a finding.
remediation_recommendation :: Lens.Lens' Remediation (Prelude.Maybe Recommendation)
remediation_recommendation :: (Maybe Recommendation -> f (Maybe Recommendation))
-> Remediation -> f Remediation
remediation_recommendation = (Remediation -> Maybe Recommendation)
-> (Remediation -> Maybe Recommendation -> Remediation)
-> Lens
     Remediation
     Remediation
     (Maybe Recommendation)
     (Maybe Recommendation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Remediation' {Maybe Recommendation
recommendation :: Maybe Recommendation
$sel:recommendation:Remediation' :: Remediation -> Maybe Recommendation
recommendation} -> Maybe Recommendation
recommendation) (\s :: Remediation
s@Remediation' {} Maybe Recommendation
a -> Remediation
s {$sel:recommendation:Remediation' :: Maybe Recommendation
recommendation = Maybe Recommendation
a} :: Remediation)

instance Core.FromJSON Remediation where
  parseJSON :: Value -> Parser Remediation
parseJSON =
    String
-> (Object -> Parser Remediation) -> Value -> Parser Remediation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Remediation"
      ( \Object
x ->
          Maybe Recommendation -> Remediation
Remediation'
            (Maybe Recommendation -> Remediation)
-> Parser (Maybe Recommendation) -> Parser Remediation
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Recommendation)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Recommendation")
      )

instance Prelude.Hashable Remediation

instance Prelude.NFData Remediation

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