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

-- | 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
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]
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
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. 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'
      { $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 :: Lens' AssertionRuleUpdate Text
assertionRuleUpdate_safetyRuleArn = 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 :: Lens' AssertionRuleUpdate Int
assertionRuleUpdate_waitPeriodMs = 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 :: Lens' AssertionRuleUpdate Text
assertionRuleUpdate_name = 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 where
  hashWithSalt :: Int -> AssertionRuleUpdate -> Int
hashWithSalt Int
_salt AssertionRuleUpdate' {Int
Text
name :: Text
waitPeriodMs :: Int
safetyRuleArn :: Text
$sel:name:AssertionRuleUpdate' :: AssertionRuleUpdate -> Text
$sel:waitPeriodMs:AssertionRuleUpdate' :: AssertionRuleUpdate -> Int
$sel:safetyRuleArn:AssertionRuleUpdate' :: AssertionRuleUpdate -> 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 AssertionRuleUpdate where
  rnf :: AssertionRuleUpdate -> ()
rnf AssertionRuleUpdate' {Int
Text
name :: Text
waitPeriodMs :: Int
safetyRuleArn :: Text
$sel:name:AssertionRuleUpdate' :: AssertionRuleUpdate -> Text
$sel:waitPeriodMs:AssertionRuleUpdate' :: AssertionRuleUpdate -> Int
$sel:safetyRuleArn:AssertionRuleUpdate' :: AssertionRuleUpdate -> 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 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
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)
          ]
      )