{-# 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.Config.Types.SsmControls
-- 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.Config.Types.SsmControls where

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

-- | Amazon Web Services Systems Manager (SSM) specific remediation controls.
--
-- /See:/ 'newSsmControls' smart constructor.
data SsmControls = SsmControls'
  { -- | The maximum percentage of remediation actions allowed to run in parallel
    -- on the non-compliant resources for that specific rule. You can specify a
    -- percentage, such as 10%. The default value is 10.
    SsmControls -> Maybe Natural
concurrentExecutionRatePercentage :: Prelude.Maybe Prelude.Natural,
    -- | The percentage of errors that are allowed before SSM stops running
    -- automations on non-compliant resources for that specific rule. You can
    -- specify a percentage of errors, for example 10%. If you do not specifiy
    -- a percentage, the default is 50%. For example, if you set the
    -- ErrorPercentage to 40% for 10 non-compliant resources, then SSM stops
    -- running the automations when the fifth error is received.
    SsmControls -> Maybe Natural
errorPercentage :: Prelude.Maybe Prelude.Natural
  }
  deriving (SsmControls -> SsmControls -> Bool
(SsmControls -> SsmControls -> Bool)
-> (SsmControls -> SsmControls -> Bool) -> Eq SsmControls
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SsmControls -> SsmControls -> Bool
$c/= :: SsmControls -> SsmControls -> Bool
== :: SsmControls -> SsmControls -> Bool
$c== :: SsmControls -> SsmControls -> Bool
Prelude.Eq, ReadPrec [SsmControls]
ReadPrec SsmControls
Int -> ReadS SsmControls
ReadS [SsmControls]
(Int -> ReadS SsmControls)
-> ReadS [SsmControls]
-> ReadPrec SsmControls
-> ReadPrec [SsmControls]
-> Read SsmControls
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SsmControls]
$creadListPrec :: ReadPrec [SsmControls]
readPrec :: ReadPrec SsmControls
$creadPrec :: ReadPrec SsmControls
readList :: ReadS [SsmControls]
$creadList :: ReadS [SsmControls]
readsPrec :: Int -> ReadS SsmControls
$creadsPrec :: Int -> ReadS SsmControls
Prelude.Read, Int -> SsmControls -> ShowS
[SsmControls] -> ShowS
SsmControls -> String
(Int -> SsmControls -> ShowS)
-> (SsmControls -> String)
-> ([SsmControls] -> ShowS)
-> Show SsmControls
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SsmControls] -> ShowS
$cshowList :: [SsmControls] -> ShowS
show :: SsmControls -> String
$cshow :: SsmControls -> String
showsPrec :: Int -> SsmControls -> ShowS
$cshowsPrec :: Int -> SsmControls -> ShowS
Prelude.Show, (forall x. SsmControls -> Rep SsmControls x)
-> (forall x. Rep SsmControls x -> SsmControls)
-> Generic SsmControls
forall x. Rep SsmControls x -> SsmControls
forall x. SsmControls -> Rep SsmControls x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SsmControls x -> SsmControls
$cfrom :: forall x. SsmControls -> Rep SsmControls x
Prelude.Generic)

-- |
-- Create a value of 'SsmControls' 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:
--
-- 'concurrentExecutionRatePercentage', 'ssmControls_concurrentExecutionRatePercentage' - The maximum percentage of remediation actions allowed to run in parallel
-- on the non-compliant resources for that specific rule. You can specify a
-- percentage, such as 10%. The default value is 10.
--
-- 'errorPercentage', 'ssmControls_errorPercentage' - The percentage of errors that are allowed before SSM stops running
-- automations on non-compliant resources for that specific rule. You can
-- specify a percentage of errors, for example 10%. If you do not specifiy
-- a percentage, the default is 50%. For example, if you set the
-- ErrorPercentage to 40% for 10 non-compliant resources, then SSM stops
-- running the automations when the fifth error is received.
newSsmControls ::
  SsmControls
newSsmControls :: SsmControls
newSsmControls =
  SsmControls' :: Maybe Natural -> Maybe Natural -> SsmControls
SsmControls'
    { $sel:concurrentExecutionRatePercentage:SsmControls' :: Maybe Natural
concurrentExecutionRatePercentage =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:errorPercentage:SsmControls' :: Maybe Natural
errorPercentage = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum percentage of remediation actions allowed to run in parallel
-- on the non-compliant resources for that specific rule. You can specify a
-- percentage, such as 10%. The default value is 10.
ssmControls_concurrentExecutionRatePercentage :: Lens.Lens' SsmControls (Prelude.Maybe Prelude.Natural)
ssmControls_concurrentExecutionRatePercentage :: (Maybe Natural -> f (Maybe Natural))
-> SsmControls -> f SsmControls
ssmControls_concurrentExecutionRatePercentage = (SsmControls -> Maybe Natural)
-> (SsmControls -> Maybe Natural -> SsmControls)
-> Lens SsmControls SsmControls (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SsmControls' {Maybe Natural
concurrentExecutionRatePercentage :: Maybe Natural
$sel:concurrentExecutionRatePercentage:SsmControls' :: SsmControls -> Maybe Natural
concurrentExecutionRatePercentage} -> Maybe Natural
concurrentExecutionRatePercentage) (\s :: SsmControls
s@SsmControls' {} Maybe Natural
a -> SsmControls
s {$sel:concurrentExecutionRatePercentage:SsmControls' :: Maybe Natural
concurrentExecutionRatePercentage = Maybe Natural
a} :: SsmControls)

-- | The percentage of errors that are allowed before SSM stops running
-- automations on non-compliant resources for that specific rule. You can
-- specify a percentage of errors, for example 10%. If you do not specifiy
-- a percentage, the default is 50%. For example, if you set the
-- ErrorPercentage to 40% for 10 non-compliant resources, then SSM stops
-- running the automations when the fifth error is received.
ssmControls_errorPercentage :: Lens.Lens' SsmControls (Prelude.Maybe Prelude.Natural)
ssmControls_errorPercentage :: (Maybe Natural -> f (Maybe Natural))
-> SsmControls -> f SsmControls
ssmControls_errorPercentage = (SsmControls -> Maybe Natural)
-> (SsmControls -> Maybe Natural -> SsmControls)
-> Lens SsmControls SsmControls (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SsmControls' {Maybe Natural
errorPercentage :: Maybe Natural
$sel:errorPercentage:SsmControls' :: SsmControls -> Maybe Natural
errorPercentage} -> Maybe Natural
errorPercentage) (\s :: SsmControls
s@SsmControls' {} Maybe Natural
a -> SsmControls
s {$sel:errorPercentage:SsmControls' :: Maybe Natural
errorPercentage = Maybe Natural
a} :: SsmControls)

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

instance Prelude.Hashable SsmControls

instance Prelude.NFData SsmControls

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