{-# 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.Route53RecoveryControlConfig.Types.NewAssertionRule
-- 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.Route53RecoveryControlConfig.Types.NewAssertionRule where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Route53RecoveryControlConfig.Types.RuleConfig

-- | A new assertion rule for a control panel.
--
-- /See:/ 'newNewAssertionRule' smart constructor.
data NewAssertionRule = NewAssertionRule'
  { -- | The Amazon Resource Name (ARN) for the control panel.
    NewAssertionRule -> Text
controlPanelArn :: Prelude.Text,
    -- | The routing controls that are part of transactions that are evaluated to
    -- determine if a request to change a routing control state is allowed. For
    -- example, you might include three routing controls, one for each of three
    -- Amazon Web Services Regions.
    NewAssertionRule -> [Text]
assertedControls :: [Prelude.Text],
    -- | The criteria that you set for specific assertion controls (routing
    -- controls) that designate how many controls must be enabled as the result
    -- of a transaction. For example, if you have three assertion controls, you
    -- might specify atleast 2 for your rule configuration. This means that at
    -- least two assertion controls must be enabled, so that at least two
    -- Amazon Web Services Regions are enabled.
    NewAssertionRule -> RuleConfig
ruleConfig :: RuleConfig,
    -- | An evaluation period, in milliseconds (ms), during which any request
    -- against the target routing controls will fail. This helps prevent
    -- \"flapping\" of state. The wait period is 5000 ms by default, but you
    -- can choose a custom value.
    NewAssertionRule -> Int
waitPeriodMs :: Prelude.Int,
    -- | The name of the assertion rule. You can use any non-white space
    -- character in the name.
    NewAssertionRule -> Text
name :: Prelude.Text
  }
  deriving (NewAssertionRule -> NewAssertionRule -> Bool
(NewAssertionRule -> NewAssertionRule -> Bool)
-> (NewAssertionRule -> NewAssertionRule -> Bool)
-> Eq NewAssertionRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NewAssertionRule -> NewAssertionRule -> Bool
$c/= :: NewAssertionRule -> NewAssertionRule -> Bool
== :: NewAssertionRule -> NewAssertionRule -> Bool
$c== :: NewAssertionRule -> NewAssertionRule -> Bool
Prelude.Eq, ReadPrec [NewAssertionRule]
ReadPrec NewAssertionRule
Int -> ReadS NewAssertionRule
ReadS [NewAssertionRule]
(Int -> ReadS NewAssertionRule)
-> ReadS [NewAssertionRule]
-> ReadPrec NewAssertionRule
-> ReadPrec [NewAssertionRule]
-> Read NewAssertionRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NewAssertionRule]
$creadListPrec :: ReadPrec [NewAssertionRule]
readPrec :: ReadPrec NewAssertionRule
$creadPrec :: ReadPrec NewAssertionRule
readList :: ReadS [NewAssertionRule]
$creadList :: ReadS [NewAssertionRule]
readsPrec :: Int -> ReadS NewAssertionRule
$creadsPrec :: Int -> ReadS NewAssertionRule
Prelude.Read, Int -> NewAssertionRule -> ShowS
[NewAssertionRule] -> ShowS
NewAssertionRule -> String
(Int -> NewAssertionRule -> ShowS)
-> (NewAssertionRule -> String)
-> ([NewAssertionRule] -> ShowS)
-> Show NewAssertionRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NewAssertionRule] -> ShowS
$cshowList :: [NewAssertionRule] -> ShowS
show :: NewAssertionRule -> String
$cshow :: NewAssertionRule -> String
showsPrec :: Int -> NewAssertionRule -> ShowS
$cshowsPrec :: Int -> NewAssertionRule -> ShowS
Prelude.Show, (forall x. NewAssertionRule -> Rep NewAssertionRule x)
-> (forall x. Rep NewAssertionRule x -> NewAssertionRule)
-> Generic NewAssertionRule
forall x. Rep NewAssertionRule x -> NewAssertionRule
forall x. NewAssertionRule -> Rep NewAssertionRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NewAssertionRule x -> NewAssertionRule
$cfrom :: forall x. NewAssertionRule -> Rep NewAssertionRule x
Prelude.Generic)

-- |
-- Create a value of 'NewAssertionRule' 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:
--
-- 'controlPanelArn', 'newAssertionRule_controlPanelArn' - The Amazon Resource Name (ARN) for the control panel.
--
-- 'assertedControls', 'newAssertionRule_assertedControls' - The routing controls that are part of transactions that are evaluated to
-- determine if a request to change a routing control state is allowed. For
-- example, you might include three routing controls, one for each of three
-- Amazon Web Services Regions.
--
-- 'ruleConfig', 'newAssertionRule_ruleConfig' - The criteria that you set for specific assertion controls (routing
-- controls) that designate how many controls must be enabled as the result
-- of a transaction. For example, if you have three assertion controls, you
-- might specify atleast 2 for your rule configuration. This means that at
-- least two assertion controls must be enabled, so that at least two
-- Amazon Web Services Regions are enabled.
--
-- 'waitPeriodMs', 'newAssertionRule_waitPeriodMs' - An evaluation period, in milliseconds (ms), during which any request
-- against the target routing controls will fail. This helps prevent
-- \"flapping\" of state. The wait period is 5000 ms by default, but you
-- can choose a custom value.
--
-- 'name', 'newAssertionRule_name' - The name of the assertion rule. You can use any non-white space
-- character in the name.
newNewAssertionRule ::
  -- | 'controlPanelArn'
  Prelude.Text ->
  -- | 'ruleConfig'
  RuleConfig ->
  -- | 'waitPeriodMs'
  Prelude.Int ->
  -- | 'name'
  Prelude.Text ->
  NewAssertionRule
newNewAssertionRule :: Text -> RuleConfig -> Int -> Text -> NewAssertionRule
newNewAssertionRule
  Text
pControlPanelArn_
  RuleConfig
pRuleConfig_
  Int
pWaitPeriodMs_
  Text
pName_ =
    NewAssertionRule' :: Text -> [Text] -> RuleConfig -> Int -> Text -> NewAssertionRule
NewAssertionRule'
      { $sel:controlPanelArn:NewAssertionRule' :: Text
controlPanelArn =
          Text
pControlPanelArn_,
        $sel:assertedControls:NewAssertionRule' :: [Text]
assertedControls = [Text]
forall a. Monoid a => a
Prelude.mempty,
        $sel:ruleConfig:NewAssertionRule' :: RuleConfig
ruleConfig = RuleConfig
pRuleConfig_,
        $sel:waitPeriodMs:NewAssertionRule' :: Int
waitPeriodMs = Int
pWaitPeriodMs_,
        $sel:name:NewAssertionRule' :: Text
name = Text
pName_
      }

-- | The Amazon Resource Name (ARN) for the control panel.
newAssertionRule_controlPanelArn :: Lens.Lens' NewAssertionRule Prelude.Text
newAssertionRule_controlPanelArn :: (Text -> f Text) -> NewAssertionRule -> f NewAssertionRule
newAssertionRule_controlPanelArn = (NewAssertionRule -> Text)
-> (NewAssertionRule -> Text -> NewAssertionRule)
-> Lens NewAssertionRule NewAssertionRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NewAssertionRule' {Text
controlPanelArn :: Text
$sel:controlPanelArn:NewAssertionRule' :: NewAssertionRule -> Text
controlPanelArn} -> Text
controlPanelArn) (\s :: NewAssertionRule
s@NewAssertionRule' {} Text
a -> NewAssertionRule
s {$sel:controlPanelArn:NewAssertionRule' :: Text
controlPanelArn = Text
a} :: NewAssertionRule)

-- | The routing controls that are part of transactions that are evaluated to
-- determine if a request to change a routing control state is allowed. For
-- example, you might include three routing controls, one for each of three
-- Amazon Web Services Regions.
newAssertionRule_assertedControls :: Lens.Lens' NewAssertionRule [Prelude.Text]
newAssertionRule_assertedControls :: ([Text] -> f [Text]) -> NewAssertionRule -> f NewAssertionRule
newAssertionRule_assertedControls = (NewAssertionRule -> [Text])
-> (NewAssertionRule -> [Text] -> NewAssertionRule)
-> Lens NewAssertionRule NewAssertionRule [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NewAssertionRule' {[Text]
assertedControls :: [Text]
$sel:assertedControls:NewAssertionRule' :: NewAssertionRule -> [Text]
assertedControls} -> [Text]
assertedControls) (\s :: NewAssertionRule
s@NewAssertionRule' {} [Text]
a -> NewAssertionRule
s {$sel:assertedControls:NewAssertionRule' :: [Text]
assertedControls = [Text]
a} :: NewAssertionRule) (([Text] -> f [Text]) -> NewAssertionRule -> f NewAssertionRule)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> NewAssertionRule
-> f NewAssertionRule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The criteria that you set for specific assertion controls (routing
-- controls) that designate how many controls must be enabled as the result
-- of a transaction. For example, if you have three assertion controls, you
-- might specify atleast 2 for your rule configuration. This means that at
-- least two assertion controls must be enabled, so that at least two
-- Amazon Web Services Regions are enabled.
newAssertionRule_ruleConfig :: Lens.Lens' NewAssertionRule RuleConfig
newAssertionRule_ruleConfig :: (RuleConfig -> f RuleConfig)
-> NewAssertionRule -> f NewAssertionRule
newAssertionRule_ruleConfig = (NewAssertionRule -> RuleConfig)
-> (NewAssertionRule -> RuleConfig -> NewAssertionRule)
-> Lens NewAssertionRule NewAssertionRule RuleConfig RuleConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NewAssertionRule' {RuleConfig
ruleConfig :: RuleConfig
$sel:ruleConfig:NewAssertionRule' :: NewAssertionRule -> RuleConfig
ruleConfig} -> RuleConfig
ruleConfig) (\s :: NewAssertionRule
s@NewAssertionRule' {} RuleConfig
a -> NewAssertionRule
s {$sel:ruleConfig:NewAssertionRule' :: RuleConfig
ruleConfig = RuleConfig
a} :: NewAssertionRule)

-- | An evaluation period, in milliseconds (ms), during which any request
-- against the target routing controls will fail. This helps prevent
-- \"flapping\" of state. The wait period is 5000 ms by default, but you
-- can choose a custom value.
newAssertionRule_waitPeriodMs :: Lens.Lens' NewAssertionRule Prelude.Int
newAssertionRule_waitPeriodMs :: (Int -> f Int) -> NewAssertionRule -> f NewAssertionRule
newAssertionRule_waitPeriodMs = (NewAssertionRule -> Int)
-> (NewAssertionRule -> Int -> NewAssertionRule)
-> Lens NewAssertionRule NewAssertionRule Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NewAssertionRule' {Int
waitPeriodMs :: Int
$sel:waitPeriodMs:NewAssertionRule' :: NewAssertionRule -> Int
waitPeriodMs} -> Int
waitPeriodMs) (\s :: NewAssertionRule
s@NewAssertionRule' {} Int
a -> NewAssertionRule
s {$sel:waitPeriodMs:NewAssertionRule' :: Int
waitPeriodMs = Int
a} :: NewAssertionRule)

-- | The name of the assertion rule. You can use any non-white space
-- character in the name.
newAssertionRule_name :: Lens.Lens' NewAssertionRule Prelude.Text
newAssertionRule_name :: (Text -> f Text) -> NewAssertionRule -> f NewAssertionRule
newAssertionRule_name = (NewAssertionRule -> Text)
-> (NewAssertionRule -> Text -> NewAssertionRule)
-> Lens NewAssertionRule NewAssertionRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NewAssertionRule' {Text
name :: Text
$sel:name:NewAssertionRule' :: NewAssertionRule -> Text
name} -> Text
name) (\s :: NewAssertionRule
s@NewAssertionRule' {} Text
a -> NewAssertionRule
s {$sel:name:NewAssertionRule' :: Text
name = Text
a} :: NewAssertionRule)

instance Prelude.Hashable NewAssertionRule

instance Prelude.NFData NewAssertionRule

instance Core.ToJSON NewAssertionRule where
  toJSON :: NewAssertionRule -> Value
toJSON NewAssertionRule' {Int
[Text]
Text
RuleConfig
name :: Text
waitPeriodMs :: Int
ruleConfig :: RuleConfig
assertedControls :: [Text]
controlPanelArn :: Text
$sel:name:NewAssertionRule' :: NewAssertionRule -> Text
$sel:waitPeriodMs:NewAssertionRule' :: NewAssertionRule -> Int
$sel:ruleConfig:NewAssertionRule' :: NewAssertionRule -> RuleConfig
$sel:assertedControls:NewAssertionRule' :: NewAssertionRule -> [Text]
$sel:controlPanelArn:NewAssertionRule' :: NewAssertionRule -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ControlPanelArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
controlPanelArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AssertedControls" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
assertedControls),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RuleConfig" Text -> RuleConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RuleConfig
ruleConfig),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"WaitPeriodMs" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Int
waitPeriodMs),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
          ]
      )