{-# 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.Budgets.Types.ActionThreshold
-- 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.Budgets.Types.ActionThreshold where

import Amazonka.Budgets.Types.ThresholdType
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

-- | The trigger threshold of the action.
--
-- /See:/ 'newActionThreshold' smart constructor.
data ActionThreshold = ActionThreshold'
  { ActionThreshold -> Double
actionThresholdValue :: Prelude.Double,
    ActionThreshold -> ThresholdType
actionThresholdType :: ThresholdType
  }
  deriving (ActionThreshold -> ActionThreshold -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ActionThreshold -> ActionThreshold -> Bool
$c/= :: ActionThreshold -> ActionThreshold -> Bool
== :: ActionThreshold -> ActionThreshold -> Bool
$c== :: ActionThreshold -> ActionThreshold -> Bool
Prelude.Eq, ReadPrec [ActionThreshold]
ReadPrec ActionThreshold
Int -> ReadS ActionThreshold
ReadS [ActionThreshold]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ActionThreshold]
$creadListPrec :: ReadPrec [ActionThreshold]
readPrec :: ReadPrec ActionThreshold
$creadPrec :: ReadPrec ActionThreshold
readList :: ReadS [ActionThreshold]
$creadList :: ReadS [ActionThreshold]
readsPrec :: Int -> ReadS ActionThreshold
$creadsPrec :: Int -> ReadS ActionThreshold
Prelude.Read, Int -> ActionThreshold -> ShowS
[ActionThreshold] -> ShowS
ActionThreshold -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ActionThreshold] -> ShowS
$cshowList :: [ActionThreshold] -> ShowS
show :: ActionThreshold -> String
$cshow :: ActionThreshold -> String
showsPrec :: Int -> ActionThreshold -> ShowS
$cshowsPrec :: Int -> ActionThreshold -> ShowS
Prelude.Show, forall x. Rep ActionThreshold x -> ActionThreshold
forall x. ActionThreshold -> Rep ActionThreshold x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ActionThreshold x -> ActionThreshold
$cfrom :: forall x. ActionThreshold -> Rep ActionThreshold x
Prelude.Generic)

-- |
-- Create a value of 'ActionThreshold' 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:
--
-- 'actionThresholdValue', 'actionThreshold_actionThresholdValue' - Undocumented member.
--
-- 'actionThresholdType', 'actionThreshold_actionThresholdType' - Undocumented member.
newActionThreshold ::
  -- | 'actionThresholdValue'
  Prelude.Double ->
  -- | 'actionThresholdType'
  ThresholdType ->
  ActionThreshold
newActionThreshold :: Double -> ThresholdType -> ActionThreshold
newActionThreshold
  Double
pActionThresholdValue_
  ThresholdType
pActionThresholdType_ =
    ActionThreshold'
      { $sel:actionThresholdValue:ActionThreshold' :: Double
actionThresholdValue =
          Double
pActionThresholdValue_,
        $sel:actionThresholdType:ActionThreshold' :: ThresholdType
actionThresholdType = ThresholdType
pActionThresholdType_
      }

-- | Undocumented member.
actionThreshold_actionThresholdValue :: Lens.Lens' ActionThreshold Prelude.Double
actionThreshold_actionThresholdValue :: Lens' ActionThreshold Double
actionThreshold_actionThresholdValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionThreshold' {Double
actionThresholdValue :: Double
$sel:actionThresholdValue:ActionThreshold' :: ActionThreshold -> Double
actionThresholdValue} -> Double
actionThresholdValue) (\s :: ActionThreshold
s@ActionThreshold' {} Double
a -> ActionThreshold
s {$sel:actionThresholdValue:ActionThreshold' :: Double
actionThresholdValue = Double
a} :: ActionThreshold)

-- | Undocumented member.
actionThreshold_actionThresholdType :: Lens.Lens' ActionThreshold ThresholdType
actionThreshold_actionThresholdType :: Lens' ActionThreshold ThresholdType
actionThreshold_actionThresholdType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ActionThreshold' {ThresholdType
actionThresholdType :: ThresholdType
$sel:actionThresholdType:ActionThreshold' :: ActionThreshold -> ThresholdType
actionThresholdType} -> ThresholdType
actionThresholdType) (\s :: ActionThreshold
s@ActionThreshold' {} ThresholdType
a -> ActionThreshold
s {$sel:actionThresholdType:ActionThreshold' :: ThresholdType
actionThresholdType = ThresholdType
a} :: ActionThreshold)

instance Data.FromJSON ActionThreshold where
  parseJSON :: Value -> Parser ActionThreshold
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ActionThreshold"
      ( \Object
x ->
          Double -> ThresholdType -> ActionThreshold
ActionThreshold'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ActionThresholdValue")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ActionThresholdType")
      )

instance Prelude.Hashable ActionThreshold where
  hashWithSalt :: Int -> ActionThreshold -> Int
hashWithSalt Int
_salt ActionThreshold' {Double
ThresholdType
actionThresholdType :: ThresholdType
actionThresholdValue :: Double
$sel:actionThresholdType:ActionThreshold' :: ActionThreshold -> ThresholdType
$sel:actionThresholdValue:ActionThreshold' :: ActionThreshold -> Double
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
actionThresholdValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ThresholdType
actionThresholdType

instance Prelude.NFData ActionThreshold where
  rnf :: ActionThreshold -> ()
rnf ActionThreshold' {Double
ThresholdType
actionThresholdType :: ThresholdType
actionThresholdValue :: Double
$sel:actionThresholdType:ActionThreshold' :: ActionThreshold -> ThresholdType
$sel:actionThresholdValue:ActionThreshold' :: ActionThreshold -> Double
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Double
actionThresholdValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ThresholdType
actionThresholdType

instance Data.ToJSON ActionThreshold where
  toJSON :: ActionThreshold -> Value
toJSON ActionThreshold' {Double
ThresholdType
actionThresholdType :: ThresholdType
actionThresholdValue :: Double
$sel:actionThresholdType:ActionThreshold' :: ActionThreshold -> ThresholdType
$sel:actionThresholdValue:ActionThreshold' :: ActionThreshold -> Double
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"ActionThresholdValue"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Double
actionThresholdValue
              ),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"ActionThresholdType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ThresholdType
actionThresholdType)
          ]
      )