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

-- | 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. You can use any non-white space character
    -- in the name.
    GatingRuleUpdate -> Text
name :: Prelude.Text
  }
  deriving (GatingRuleUpdate -> GatingRuleUpdate -> Bool
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]
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
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. 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. You can use any non-white space character
-- in the name.
newGatingRuleUpdate ::
  -- | 'safetyRuleArn'
  Prelude.Text ->
  -- | 'waitPeriodMs'
  Prelude.Int ->
  -- | 'name'
  Prelude.Text ->
  GatingRuleUpdate
newGatingRuleUpdate :: Text -> Int -> Text -> GatingRuleUpdate
newGatingRuleUpdate
  Text
pSafetyRuleArn_
  Int
pWaitPeriodMs_
  Text
pName_ =
    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 :: Lens' GatingRuleUpdate Text
gatingRuleUpdate_safetyRuleArn = 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 :: Lens' GatingRuleUpdate Int
gatingRuleUpdate_waitPeriodMs = 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. You can use any non-white space character
-- in the name.
gatingRuleUpdate_name :: Lens.Lens' GatingRuleUpdate Prelude.Text
gatingRuleUpdate_name :: Lens' GatingRuleUpdate Text
gatingRuleUpdate_name = 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 where
  hashWithSalt :: Int -> GatingRuleUpdate -> Int
hashWithSalt Int
_salt GatingRuleUpdate' {Int
Text
name :: Text
waitPeriodMs :: Int
safetyRuleArn :: Text
$sel:name:GatingRuleUpdate' :: GatingRuleUpdate -> Text
$sel:waitPeriodMs:GatingRuleUpdate' :: GatingRuleUpdate -> Int
$sel:safetyRuleArn:GatingRuleUpdate' :: GatingRuleUpdate -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
safetyRuleArn
      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 GatingRuleUpdate where
  rnf :: GatingRuleUpdate -> ()
rnf GatingRuleUpdate' {Int
Text
name :: Text
waitPeriodMs :: Int
safetyRuleArn :: Text
$sel:name:GatingRuleUpdate' :: GatingRuleUpdate -> Text
$sel:waitPeriodMs:GatingRuleUpdate' :: GatingRuleUpdate -> Int
$sel:safetyRuleArn:GatingRuleUpdate' :: GatingRuleUpdate -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
safetyRuleArn
      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 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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"SafetyRuleArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
safetyRuleArn),
            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)
          ]
      )