{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Route53RecoveryControlConfig.Types.NewAssertionRule 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
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 control states must be ON 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 ON, so that at least
    -- two Amazon Web Services Regions have traffic flowing to them.
    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
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]
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
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. 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 control states must be ON 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 ON, so that at least
-- two Amazon Web Services Regions have traffic flowing to them.
--
-- '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'
      { $sel:controlPanelArn:NewAssertionRule' :: Text
controlPanelArn =
          Text
pControlPanelArn_,
        $sel:assertedControls:NewAssertionRule' :: [Text]
assertedControls = 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 :: Lens' NewAssertionRule Text
newAssertionRule_controlPanelArn = 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 :: Lens' NewAssertionRule [Text]
newAssertionRule_assertedControls = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 control states must be ON 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 ON, so that at least
-- two Amazon Web Services Regions have traffic flowing to them.
newAssertionRule_ruleConfig :: Lens.Lens' NewAssertionRule RuleConfig
newAssertionRule_ruleConfig :: Lens' NewAssertionRule RuleConfig
newAssertionRule_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 :: Lens' NewAssertionRule Int
newAssertionRule_waitPeriodMs = 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 :: Lens' NewAssertionRule Text
newAssertionRule_name = 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 where
  hashWithSalt :: Int -> NewAssertionRule -> Int
hashWithSalt Int
_salt 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
controlPanelArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
assertedControls
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RuleConfig
ruleConfig
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
waitPeriodMs
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData NewAssertionRule where
  rnf :: NewAssertionRule -> ()
rnf 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
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
controlPanelArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
assertedControls
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf RuleConfig
ruleConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
waitPeriodMs
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"ControlPanelArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
controlPanelArn),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"AssertedControls" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
assertedControls),
            forall a. a -> Maybe a
Prelude.Just (Key
"RuleConfig" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= RuleConfig
ruleConfig),
            forall a. a -> Maybe a
Prelude.Just (Key
"WaitPeriodMs" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Int
waitPeriodMs),
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)
          ]
      )