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

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

-- | An update to an assertion 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:/ 'newAssertionRuleUpdate' smart constructor.
data AssertionRuleUpdate = AssertionRuleUpdate'
  { -- | The Amazon Resource Name (ARN) of the assertion rule.
    AssertionRuleUpdate -> 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.
    AssertionRuleUpdate -> Int
waitPeriodMs :: Prelude.Int,
    -- | The name of the assertion rule. You can use any non-white space
    -- character in the name.
    AssertionRuleUpdate -> Text
name :: Prelude.Text
  }
  deriving (AssertionRuleUpdate -> AssertionRuleUpdate -> Bool
(AssertionRuleUpdate -> AssertionRuleUpdate -> Bool)
-> (AssertionRuleUpdate -> AssertionRuleUpdate -> Bool)
-> Eq AssertionRuleUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AssertionRuleUpdate -> AssertionRuleUpdate -> Bool
$c/= :: AssertionRuleUpdate -> AssertionRuleUpdate -> Bool
== :: AssertionRuleUpdate -> AssertionRuleUpdate -> Bool
$c== :: AssertionRuleUpdate -> AssertionRuleUpdate -> Bool
Prelude.Eq, ReadPrec [AssertionRuleUpdate]
ReadPrec AssertionRuleUpdate
Int -> ReadS AssertionRuleUpdate
ReadS [AssertionRuleUpdate]
(Int -> ReadS AssertionRuleUpdate)
-> ReadS [AssertionRuleUpdate]
-> ReadPrec AssertionRuleUpdate
-> ReadPrec [AssertionRuleUpdate]
-> Read AssertionRuleUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AssertionRuleUpdate]
$creadListPrec :: ReadPrec [AssertionRuleUpdate]
readPrec :: ReadPrec AssertionRuleUpdate
$creadPrec :: ReadPrec AssertionRuleUpdate
readList :: ReadS [AssertionRuleUpdate]
$creadList :: ReadS [AssertionRuleUpdate]
readsPrec :: Int -> ReadS AssertionRuleUpdate
$creadsPrec :: Int -> ReadS AssertionRuleUpdate
Prelude.Read, Int -> AssertionRuleUpdate -> ShowS
[AssertionRuleUpdate] -> ShowS
AssertionRuleUpdate -> String
(Int -> AssertionRuleUpdate -> ShowS)
-> (AssertionRuleUpdate -> String)
-> ([AssertionRuleUpdate] -> ShowS)
-> Show AssertionRuleUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AssertionRuleUpdate] -> ShowS
$cshowList :: [AssertionRuleUpdate] -> ShowS
show :: AssertionRuleUpdate -> String
$cshow :: AssertionRuleUpdate -> String
showsPrec :: Int -> AssertionRuleUpdate -> ShowS
$cshowsPrec :: Int -> AssertionRuleUpdate -> ShowS
Prelude.Show, (forall x. AssertionRuleUpdate -> Rep AssertionRuleUpdate x)
-> (forall x. Rep AssertionRuleUpdate x -> AssertionRuleUpdate)
-> Generic AssertionRuleUpdate
forall x. Rep AssertionRuleUpdate x -> AssertionRuleUpdate
forall x. AssertionRuleUpdate -> Rep AssertionRuleUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AssertionRuleUpdate x -> AssertionRuleUpdate
$cfrom :: forall x. AssertionRuleUpdate -> Rep AssertionRuleUpdate x
Prelude.Generic)

-- |
-- Create a value of 'AssertionRuleUpdate' 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', 'assertionRuleUpdate_safetyRuleArn' - The Amazon Resource Name (ARN) of the assertion rule.
--
-- 'waitPeriodMs', 'assertionRuleUpdate_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', 'assertionRuleUpdate_name' - The name of the assertion rule. You can use any non-white space
-- character in the name.
newAssertionRuleUpdate ::
  -- | 'safetyRuleArn'
  Prelude.Text ->
  -- | 'waitPeriodMs'
  Prelude.Int ->
  -- | 'name'
  Prelude.Text ->
  AssertionRuleUpdate
newAssertionRuleUpdate :: Text -> Int -> Text -> AssertionRuleUpdate
newAssertionRuleUpdate
  Text
pSafetyRuleArn_
  Int
pWaitPeriodMs_
  Text
pName_ =
    AssertionRuleUpdate' :: Text -> Int -> Text -> AssertionRuleUpdate
AssertionRuleUpdate'
      { $sel:safetyRuleArn:AssertionRuleUpdate' :: Text
safetyRuleArn =
          Text
pSafetyRuleArn_,
        $sel:waitPeriodMs:AssertionRuleUpdate' :: Int
waitPeriodMs = Int
pWaitPeriodMs_,
        $sel:name:AssertionRuleUpdate' :: Text
name = Text
pName_
      }

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

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

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

instance Prelude.Hashable AssertionRuleUpdate

instance Prelude.NFData AssertionRuleUpdate

instance Core.ToJSON AssertionRuleUpdate where
  toJSON :: AssertionRuleUpdate -> Value
toJSON AssertionRuleUpdate' {Int
Text
name :: Text
waitPeriodMs :: Int
safetyRuleArn :: Text
$sel:name:AssertionRuleUpdate' :: AssertionRuleUpdate -> Text
$sel:waitPeriodMs:AssertionRuleUpdate' :: AssertionRuleUpdate -> Int
$sel:safetyRuleArn:AssertionRuleUpdate' :: AssertionRuleUpdate -> 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)
          ]
      )