{-# 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.GatingRuleUpdate
-- 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.GatingRuleUpdate where

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

-- | Update to a gating rule. You can update the name or the evaluation
-- period (wait period). If you don\'t specify one of the items to update,
-- the item is unchanged.
--
-- /See:/ 'newGatingRuleUpdate' smart constructor.
data GatingRuleUpdate = GatingRuleUpdate'
  { -- | The Amazon Resource Name (ARN) of the gating rule.
    GatingRuleUpdate -> Text
safetyRuleArn :: Prelude.Text,
    -- | 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.
    GatingRuleUpdate -> Int
waitPeriodMs :: Prelude.Int,
    -- | The name for the gating rule.
    GatingRuleUpdate -> Text
name :: Prelude.Text
  }
  deriving (GatingRuleUpdate -> GatingRuleUpdate -> Bool
(GatingRuleUpdate -> GatingRuleUpdate -> Bool)
-> (GatingRuleUpdate -> GatingRuleUpdate -> Bool)
-> Eq GatingRuleUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GatingRuleUpdate -> GatingRuleUpdate -> Bool
$c/= :: GatingRuleUpdate -> GatingRuleUpdate -> Bool
== :: GatingRuleUpdate -> GatingRuleUpdate -> Bool
$c== :: GatingRuleUpdate -> GatingRuleUpdate -> Bool
Prelude.Eq, ReadPrec [GatingRuleUpdate]
ReadPrec GatingRuleUpdate
Int -> ReadS GatingRuleUpdate
ReadS [GatingRuleUpdate]
(Int -> ReadS GatingRuleUpdate)
-> ReadS [GatingRuleUpdate]
-> ReadPrec GatingRuleUpdate
-> ReadPrec [GatingRuleUpdate]
-> Read GatingRuleUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GatingRuleUpdate]
$creadListPrec :: ReadPrec [GatingRuleUpdate]
readPrec :: ReadPrec GatingRuleUpdate
$creadPrec :: ReadPrec GatingRuleUpdate
readList :: ReadS [GatingRuleUpdate]
$creadList :: ReadS [GatingRuleUpdate]
readsPrec :: Int -> ReadS GatingRuleUpdate
$creadsPrec :: Int -> ReadS GatingRuleUpdate
Prelude.Read, Int -> GatingRuleUpdate -> ShowS
[GatingRuleUpdate] -> ShowS
GatingRuleUpdate -> String
(Int -> GatingRuleUpdate -> ShowS)
-> (GatingRuleUpdate -> String)
-> ([GatingRuleUpdate] -> ShowS)
-> Show GatingRuleUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GatingRuleUpdate] -> ShowS
$cshowList :: [GatingRuleUpdate] -> ShowS
show :: GatingRuleUpdate -> String
$cshow :: GatingRuleUpdate -> String
showsPrec :: Int -> GatingRuleUpdate -> ShowS
$cshowsPrec :: Int -> GatingRuleUpdate -> ShowS
Prelude.Show, (forall x. GatingRuleUpdate -> Rep GatingRuleUpdate x)
-> (forall x. Rep GatingRuleUpdate x -> GatingRuleUpdate)
-> Generic GatingRuleUpdate
forall x. Rep GatingRuleUpdate x -> GatingRuleUpdate
forall x. GatingRuleUpdate -> Rep GatingRuleUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GatingRuleUpdate x -> GatingRuleUpdate
$cfrom :: forall x. GatingRuleUpdate -> Rep GatingRuleUpdate x
Prelude.Generic)

-- |
-- Create a value of 'GatingRuleUpdate' 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:
--
-- 'safetyRuleArn', 'gatingRuleUpdate_safetyRuleArn' - The Amazon Resource Name (ARN) of the gating rule.
--
-- 'waitPeriodMs', 'gatingRuleUpdate_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', 'gatingRuleUpdate_name' - The name for the gating rule.
newGatingRuleUpdate ::
  -- | 'safetyRuleArn'
  Prelude.Text ->
  -- | 'waitPeriodMs'
  Prelude.Int ->
  -- | 'name'
  Prelude.Text ->
  GatingRuleUpdate
newGatingRuleUpdate :: Text -> Int -> Text -> GatingRuleUpdate
newGatingRuleUpdate
  Text
pSafetyRuleArn_
  Int
pWaitPeriodMs_
  Text
pName_ =
    GatingRuleUpdate' :: Text -> Int -> Text -> GatingRuleUpdate
GatingRuleUpdate'
      { $sel:safetyRuleArn:GatingRuleUpdate' :: Text
safetyRuleArn = Text
pSafetyRuleArn_,
        $sel:waitPeriodMs:GatingRuleUpdate' :: Int
waitPeriodMs = Int
pWaitPeriodMs_,
        $sel:name:GatingRuleUpdate' :: Text
name = Text
pName_
      }

-- | The Amazon Resource Name (ARN) of the gating rule.
gatingRuleUpdate_safetyRuleArn :: Lens.Lens' GatingRuleUpdate Prelude.Text
gatingRuleUpdate_safetyRuleArn :: (Text -> f Text) -> GatingRuleUpdate -> f GatingRuleUpdate
gatingRuleUpdate_safetyRuleArn = (GatingRuleUpdate -> Text)
-> (GatingRuleUpdate -> Text -> GatingRuleUpdate)
-> Lens GatingRuleUpdate GatingRuleUpdate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GatingRuleUpdate' {Text
safetyRuleArn :: Text
$sel:safetyRuleArn:GatingRuleUpdate' :: GatingRuleUpdate -> Text
safetyRuleArn} -> Text
safetyRuleArn) (\s :: GatingRuleUpdate
s@GatingRuleUpdate' {} Text
a -> GatingRuleUpdate
s {$sel:safetyRuleArn:GatingRuleUpdate' :: Text
safetyRuleArn = Text
a} :: GatingRuleUpdate)

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

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

instance Prelude.Hashable GatingRuleUpdate

instance Prelude.NFData GatingRuleUpdate

instance Core.ToJSON GatingRuleUpdate where
  toJSON :: GatingRuleUpdate -> Value
toJSON GatingRuleUpdate' {Int
Text
name :: Text
waitPeriodMs :: Int
safetyRuleArn :: Text
$sel:name:GatingRuleUpdate' :: GatingRuleUpdate -> Text
$sel:waitPeriodMs:GatingRuleUpdate' :: GatingRuleUpdate -> Int
$sel:safetyRuleArn:GatingRuleUpdate' :: GatingRuleUpdate -> 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
"SafetyRuleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
safetyRuleArn),
            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)
          ]
      )