{-# 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.NewGatingRule
-- 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.NewGatingRule 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 gating rule for a control panel.
--
-- /See:/ 'newNewGatingRule' smart constructor.
data NewGatingRule = NewGatingRule'
  { -- | Routing controls that can only be set or unset if the specified
    -- RuleConfig evaluates to true for the specified GatingControls. For
    -- example, say you have three gating controls, one for each of three
    -- Amazon Web Services Regions. Now you specify AtLeast 2 as your
    -- RuleConfig. With these settings, you can only change (set or unset) the
    -- routing controls that you have specified as TargetControls if that rule
    -- evaluates to true.
    --
    -- In other words, your ability to change the routing controls that you
    -- have specified as TargetControls is gated by the rule that you set for
    -- the routing controls in GatingControls.
    NewGatingRule -> [Text]
targetControls :: [Prelude.Text],
    -- | The Amazon Resource Name (ARN) of the control panel.
    NewGatingRule -> Text
controlPanelArn :: Prelude.Text,
    -- | The gating controls for the new gating rule. That is, routing controls
    -- that are evaluated by the rule configuration that you specify.
    NewGatingRule -> [Text]
gatingControls :: [Prelude.Text],
    -- | The criteria that you set for specific gating controls (routing
    -- controls) that designates how many controls must be enabled to allow you
    -- to change (set or unset) the target controls.
    NewGatingRule -> 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.
    NewGatingRule -> Int
waitPeriodMs :: Prelude.Int,
    -- | The name for the new gating rule.
    NewGatingRule -> Text
name :: Prelude.Text
  }
  deriving (NewGatingRule -> NewGatingRule -> Bool
(NewGatingRule -> NewGatingRule -> Bool)
-> (NewGatingRule -> NewGatingRule -> Bool) -> Eq NewGatingRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NewGatingRule -> NewGatingRule -> Bool
$c/= :: NewGatingRule -> NewGatingRule -> Bool
== :: NewGatingRule -> NewGatingRule -> Bool
$c== :: NewGatingRule -> NewGatingRule -> Bool
Prelude.Eq, ReadPrec [NewGatingRule]
ReadPrec NewGatingRule
Int -> ReadS NewGatingRule
ReadS [NewGatingRule]
(Int -> ReadS NewGatingRule)
-> ReadS [NewGatingRule]
-> ReadPrec NewGatingRule
-> ReadPrec [NewGatingRule]
-> Read NewGatingRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NewGatingRule]
$creadListPrec :: ReadPrec [NewGatingRule]
readPrec :: ReadPrec NewGatingRule
$creadPrec :: ReadPrec NewGatingRule
readList :: ReadS [NewGatingRule]
$creadList :: ReadS [NewGatingRule]
readsPrec :: Int -> ReadS NewGatingRule
$creadsPrec :: Int -> ReadS NewGatingRule
Prelude.Read, Int -> NewGatingRule -> ShowS
[NewGatingRule] -> ShowS
NewGatingRule -> String
(Int -> NewGatingRule -> ShowS)
-> (NewGatingRule -> String)
-> ([NewGatingRule] -> ShowS)
-> Show NewGatingRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NewGatingRule] -> ShowS
$cshowList :: [NewGatingRule] -> ShowS
show :: NewGatingRule -> String
$cshow :: NewGatingRule -> String
showsPrec :: Int -> NewGatingRule -> ShowS
$cshowsPrec :: Int -> NewGatingRule -> ShowS
Prelude.Show, (forall x. NewGatingRule -> Rep NewGatingRule x)
-> (forall x. Rep NewGatingRule x -> NewGatingRule)
-> Generic NewGatingRule
forall x. Rep NewGatingRule x -> NewGatingRule
forall x. NewGatingRule -> Rep NewGatingRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NewGatingRule x -> NewGatingRule
$cfrom :: forall x. NewGatingRule -> Rep NewGatingRule x
Prelude.Generic)

-- |
-- Create a value of 'NewGatingRule' 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:
--
-- 'targetControls', 'newGatingRule_targetControls' - Routing controls that can only be set or unset if the specified
-- RuleConfig evaluates to true for the specified GatingControls. For
-- example, say you have three gating controls, one for each of three
-- Amazon Web Services Regions. Now you specify AtLeast 2 as your
-- RuleConfig. With these settings, you can only change (set or unset) the
-- routing controls that you have specified as TargetControls if that rule
-- evaluates to true.
--
-- In other words, your ability to change the routing controls that you
-- have specified as TargetControls is gated by the rule that you set for
-- the routing controls in GatingControls.
--
-- 'controlPanelArn', 'newGatingRule_controlPanelArn' - The Amazon Resource Name (ARN) of the control panel.
--
-- 'gatingControls', 'newGatingRule_gatingControls' - The gating controls for the new gating rule. That is, routing controls
-- that are evaluated by the rule configuration that you specify.
--
-- 'ruleConfig', 'newGatingRule_ruleConfig' - The criteria that you set for specific gating controls (routing
-- controls) that designates how many controls must be enabled to allow you
-- to change (set or unset) the target controls.
--
-- 'waitPeriodMs', 'newGatingRule_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', 'newGatingRule_name' - The name for the new gating rule.
newNewGatingRule ::
  -- | 'controlPanelArn'
  Prelude.Text ->
  -- | 'ruleConfig'
  RuleConfig ->
  -- | 'waitPeriodMs'
  Prelude.Int ->
  -- | 'name'
  Prelude.Text ->
  NewGatingRule
newNewGatingRule :: Text -> RuleConfig -> Int -> Text -> NewGatingRule
newNewGatingRule
  Text
pControlPanelArn_
  RuleConfig
pRuleConfig_
  Int
pWaitPeriodMs_
  Text
pName_ =
    NewGatingRule' :: [Text]
-> Text -> [Text] -> RuleConfig -> Int -> Text -> NewGatingRule
NewGatingRule'
      { $sel:targetControls:NewGatingRule' :: [Text]
targetControls = [Text]
forall a. Monoid a => a
Prelude.mempty,
        $sel:controlPanelArn:NewGatingRule' :: Text
controlPanelArn = Text
pControlPanelArn_,
        $sel:gatingControls:NewGatingRule' :: [Text]
gatingControls = [Text]
forall a. Monoid a => a
Prelude.mempty,
        $sel:ruleConfig:NewGatingRule' :: RuleConfig
ruleConfig = RuleConfig
pRuleConfig_,
        $sel:waitPeriodMs:NewGatingRule' :: Int
waitPeriodMs = Int
pWaitPeriodMs_,
        $sel:name:NewGatingRule' :: Text
name = Text
pName_
      }

-- | Routing controls that can only be set or unset if the specified
-- RuleConfig evaluates to true for the specified GatingControls. For
-- example, say you have three gating controls, one for each of three
-- Amazon Web Services Regions. Now you specify AtLeast 2 as your
-- RuleConfig. With these settings, you can only change (set or unset) the
-- routing controls that you have specified as TargetControls if that rule
-- evaluates to true.
--
-- In other words, your ability to change the routing controls that you
-- have specified as TargetControls is gated by the rule that you set for
-- the routing controls in GatingControls.
newGatingRule_targetControls :: Lens.Lens' NewGatingRule [Prelude.Text]
newGatingRule_targetControls :: ([Text] -> f [Text]) -> NewGatingRule -> f NewGatingRule
newGatingRule_targetControls = (NewGatingRule -> [Text])
-> (NewGatingRule -> [Text] -> NewGatingRule)
-> Lens NewGatingRule NewGatingRule [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NewGatingRule' {[Text]
targetControls :: [Text]
$sel:targetControls:NewGatingRule' :: NewGatingRule -> [Text]
targetControls} -> [Text]
targetControls) (\s :: NewGatingRule
s@NewGatingRule' {} [Text]
a -> NewGatingRule
s {$sel:targetControls:NewGatingRule' :: [Text]
targetControls = [Text]
a} :: NewGatingRule) (([Text] -> f [Text]) -> NewGatingRule -> f NewGatingRule)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> NewGatingRule
-> f NewGatingRule
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 Amazon Resource Name (ARN) of the control panel.
newGatingRule_controlPanelArn :: Lens.Lens' NewGatingRule Prelude.Text
newGatingRule_controlPanelArn :: (Text -> f Text) -> NewGatingRule -> f NewGatingRule
newGatingRule_controlPanelArn = (NewGatingRule -> Text)
-> (NewGatingRule -> Text -> NewGatingRule)
-> Lens NewGatingRule NewGatingRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NewGatingRule' {Text
controlPanelArn :: Text
$sel:controlPanelArn:NewGatingRule' :: NewGatingRule -> Text
controlPanelArn} -> Text
controlPanelArn) (\s :: NewGatingRule
s@NewGatingRule' {} Text
a -> NewGatingRule
s {$sel:controlPanelArn:NewGatingRule' :: Text
controlPanelArn = Text
a} :: NewGatingRule)

-- | The gating controls for the new gating rule. That is, routing controls
-- that are evaluated by the rule configuration that you specify.
newGatingRule_gatingControls :: Lens.Lens' NewGatingRule [Prelude.Text]
newGatingRule_gatingControls :: ([Text] -> f [Text]) -> NewGatingRule -> f NewGatingRule
newGatingRule_gatingControls = (NewGatingRule -> [Text])
-> (NewGatingRule -> [Text] -> NewGatingRule)
-> Lens NewGatingRule NewGatingRule [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NewGatingRule' {[Text]
gatingControls :: [Text]
$sel:gatingControls:NewGatingRule' :: NewGatingRule -> [Text]
gatingControls} -> [Text]
gatingControls) (\s :: NewGatingRule
s@NewGatingRule' {} [Text]
a -> NewGatingRule
s {$sel:gatingControls:NewGatingRule' :: [Text]
gatingControls = [Text]
a} :: NewGatingRule) (([Text] -> f [Text]) -> NewGatingRule -> f NewGatingRule)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> NewGatingRule
-> f NewGatingRule
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 gating controls (routing
-- controls) that designates how many controls must be enabled to allow you
-- to change (set or unset) the target controls.
newGatingRule_ruleConfig :: Lens.Lens' NewGatingRule RuleConfig
newGatingRule_ruleConfig :: (RuleConfig -> f RuleConfig) -> NewGatingRule -> f NewGatingRule
newGatingRule_ruleConfig = (NewGatingRule -> RuleConfig)
-> (NewGatingRule -> RuleConfig -> NewGatingRule)
-> Lens NewGatingRule NewGatingRule RuleConfig RuleConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NewGatingRule' {RuleConfig
ruleConfig :: RuleConfig
$sel:ruleConfig:NewGatingRule' :: NewGatingRule -> RuleConfig
ruleConfig} -> RuleConfig
ruleConfig) (\s :: NewGatingRule
s@NewGatingRule' {} RuleConfig
a -> NewGatingRule
s {$sel:ruleConfig:NewGatingRule' :: RuleConfig
ruleConfig = RuleConfig
a} :: NewGatingRule)

-- | 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.
newGatingRule_waitPeriodMs :: Lens.Lens' NewGatingRule Prelude.Int
newGatingRule_waitPeriodMs :: (Int -> f Int) -> NewGatingRule -> f NewGatingRule
newGatingRule_waitPeriodMs = (NewGatingRule -> Int)
-> (NewGatingRule -> Int -> NewGatingRule)
-> Lens NewGatingRule NewGatingRule Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NewGatingRule' {Int
waitPeriodMs :: Int
$sel:waitPeriodMs:NewGatingRule' :: NewGatingRule -> Int
waitPeriodMs} -> Int
waitPeriodMs) (\s :: NewGatingRule
s@NewGatingRule' {} Int
a -> NewGatingRule
s {$sel:waitPeriodMs:NewGatingRule' :: Int
waitPeriodMs = Int
a} :: NewGatingRule)

-- | The name for the new gating rule.
newGatingRule_name :: Lens.Lens' NewGatingRule Prelude.Text
newGatingRule_name :: (Text -> f Text) -> NewGatingRule -> f NewGatingRule
newGatingRule_name = (NewGatingRule -> Text)
-> (NewGatingRule -> Text -> NewGatingRule)
-> Lens NewGatingRule NewGatingRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NewGatingRule' {Text
name :: Text
$sel:name:NewGatingRule' :: NewGatingRule -> Text
name} -> Text
name) (\s :: NewGatingRule
s@NewGatingRule' {} Text
a -> NewGatingRule
s {$sel:name:NewGatingRule' :: Text
name = Text
a} :: NewGatingRule)

instance Prelude.Hashable NewGatingRule

instance Prelude.NFData NewGatingRule

instance Core.ToJSON NewGatingRule where
  toJSON :: NewGatingRule -> Value
toJSON NewGatingRule' {Int
[Text]
Text
RuleConfig
name :: Text
waitPeriodMs :: Int
ruleConfig :: RuleConfig
gatingControls :: [Text]
controlPanelArn :: Text
targetControls :: [Text]
$sel:name:NewGatingRule' :: NewGatingRule -> Text
$sel:waitPeriodMs:NewGatingRule' :: NewGatingRule -> Int
$sel:ruleConfig:NewGatingRule' :: NewGatingRule -> RuleConfig
$sel:gatingControls:NewGatingRule' :: NewGatingRule -> [Text]
$sel:controlPanelArn:NewGatingRule' :: NewGatingRule -> Text
$sel:targetControls:NewGatingRule' :: NewGatingRule -> [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
"TargetControls" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
targetControls),
            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
"GatingControls" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
gatingControls),
            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)
          ]
      )