{-# 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.CostExplorer.Types.AnomalySubscription
-- 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.CostExplorer.Types.AnomalySubscription where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import Amazonka.CostExplorer.Types.AnomalySubscriptionFrequency
import Amazonka.CostExplorer.Types.Expression
import Amazonka.CostExplorer.Types.Subscriber
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The association between a monitor, threshold, and list of subscribers
-- used to deliver notifications about anomalies detected by a monitor that
-- exceeds a threshold. The content consists of the detailed metadata and
-- the current status of the @AnomalySubscription@ object.
--
-- /See:/ 'newAnomalySubscription' smart constructor.
data AnomalySubscription = AnomalySubscription'
  { -- | Your unique account identifier.
    AnomalySubscription -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | The @AnomalySubscription@ Amazon Resource Name (ARN).
    AnomalySubscription -> Maybe Text
subscriptionArn :: Prelude.Maybe Prelude.Text,
    -- | (deprecated)
    --
    -- The dollar value that triggers a notification if the threshold is
    -- exceeded.
    --
    -- This field has been deprecated. To specify a threshold, use
    -- ThresholdExpression. Continued use of Threshold will be treated as
    -- shorthand syntax for a ThresholdExpression.
    --
    -- One of Threshold or ThresholdExpression is required for this resource.
    AnomalySubscription -> Maybe Double
threshold :: Prelude.Maybe Prelude.Double,
    -- | An
    -- <https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Expression.html Expression>
    -- object used to specify the anomalies that you want to generate alerts
    -- for. This supports dimensions and nested expressions. The supported
    -- dimensions are @ANOMALY_TOTAL_IMPACT_ABSOLUTE@ and
    -- @ANOMALY_TOTAL_IMPACT_PERCENTAGE@. The supported nested expression types
    -- are @AND@ and @OR@. The match option @GREATER_THAN_OR_EQUAL@ is
    -- required. Values must be numbers between 0 and 10,000,000,000.
    --
    -- One of Threshold or ThresholdExpression is required for this resource.
    --
    -- The following are examples of valid ThresholdExpressions:
    --
    -- -   Absolute threshold:
    --     @{ \"Dimensions\": { \"Key\": \"ANOMALY_TOTAL_IMPACT_ABSOLUTE\", \"MatchOptions\": [ \"GREATER_THAN_OR_EQUAL\" ], \"Values\": [ \"100\" ] } }@
    --
    -- -   Percentage threshold:
    --     @{ \"Dimensions\": { \"Key\": \"ANOMALY_TOTAL_IMPACT_PERCENTAGE\", \"MatchOptions\": [ \"GREATER_THAN_OR_EQUAL\" ], \"Values\": [ \"100\" ] } }@
    --
    -- -   @AND@ two thresholds together:
    --     @{ \"And\": [ { \"Dimensions\": { \"Key\": \"ANOMALY_TOTAL_IMPACT_ABSOLUTE\", \"MatchOptions\": [ \"GREATER_THAN_OR_EQUAL\" ], \"Values\": [ \"100\" ] } }, { \"Dimensions\": { \"Key\": \"ANOMALY_TOTAL_IMPACT_PERCENTAGE\", \"MatchOptions\": [ \"GREATER_THAN_OR_EQUAL\" ], \"Values\": [ \"100\" ] } } ] }@
    --
    -- -   @OR@ two thresholds together:
    --     @{ \"Or\": [ { \"Dimensions\": { \"Key\": \"ANOMALY_TOTAL_IMPACT_ABSOLUTE\", \"MatchOptions\": [ \"GREATER_THAN_OR_EQUAL\" ], \"Values\": [ \"100\" ] } }, { \"Dimensions\": { \"Key\": \"ANOMALY_TOTAL_IMPACT_PERCENTAGE\", \"MatchOptions\": [ \"GREATER_THAN_OR_EQUAL\" ], \"Values\": [ \"100\" ] } } ] }@
    AnomalySubscription -> Maybe Expression
thresholdExpression :: Prelude.Maybe Expression,
    -- | A list of cost anomaly monitors.
    AnomalySubscription -> [Text]
monitorArnList :: [Prelude.Text],
    -- | A list of subscribers to notify.
    AnomalySubscription -> [Subscriber]
subscribers :: [Subscriber],
    -- | The frequency that anomaly reports are sent over email.
    AnomalySubscription -> AnomalySubscriptionFrequency
frequency :: AnomalySubscriptionFrequency,
    -- | The name for the subscription.
    AnomalySubscription -> Text
subscriptionName :: Prelude.Text
  }
  deriving (AnomalySubscription -> AnomalySubscription -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnomalySubscription -> AnomalySubscription -> Bool
$c/= :: AnomalySubscription -> AnomalySubscription -> Bool
== :: AnomalySubscription -> AnomalySubscription -> Bool
$c== :: AnomalySubscription -> AnomalySubscription -> Bool
Prelude.Eq, ReadPrec [AnomalySubscription]
ReadPrec AnomalySubscription
Int -> ReadS AnomalySubscription
ReadS [AnomalySubscription]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnomalySubscription]
$creadListPrec :: ReadPrec [AnomalySubscription]
readPrec :: ReadPrec AnomalySubscription
$creadPrec :: ReadPrec AnomalySubscription
readList :: ReadS [AnomalySubscription]
$creadList :: ReadS [AnomalySubscription]
readsPrec :: Int -> ReadS AnomalySubscription
$creadsPrec :: Int -> ReadS AnomalySubscription
Prelude.Read, Int -> AnomalySubscription -> ShowS
[AnomalySubscription] -> ShowS
AnomalySubscription -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnomalySubscription] -> ShowS
$cshowList :: [AnomalySubscription] -> ShowS
show :: AnomalySubscription -> String
$cshow :: AnomalySubscription -> String
showsPrec :: Int -> AnomalySubscription -> ShowS
$cshowsPrec :: Int -> AnomalySubscription -> ShowS
Prelude.Show, forall x. Rep AnomalySubscription x -> AnomalySubscription
forall x. AnomalySubscription -> Rep AnomalySubscription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AnomalySubscription x -> AnomalySubscription
$cfrom :: forall x. AnomalySubscription -> Rep AnomalySubscription x
Prelude.Generic)

-- |
-- Create a value of 'AnomalySubscription' 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:
--
-- 'accountId', 'anomalySubscription_accountId' - Your unique account identifier.
--
-- 'subscriptionArn', 'anomalySubscription_subscriptionArn' - The @AnomalySubscription@ Amazon Resource Name (ARN).
--
-- 'threshold', 'anomalySubscription_threshold' - (deprecated)
--
-- The dollar value that triggers a notification if the threshold is
-- exceeded.
--
-- This field has been deprecated. To specify a threshold, use
-- ThresholdExpression. Continued use of Threshold will be treated as
-- shorthand syntax for a ThresholdExpression.
--
-- One of Threshold or ThresholdExpression is required for this resource.
--
-- 'thresholdExpression', 'anomalySubscription_thresholdExpression' - An
-- <https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Expression.html Expression>
-- object used to specify the anomalies that you want to generate alerts
-- for. This supports dimensions and nested expressions. The supported
-- dimensions are @ANOMALY_TOTAL_IMPACT_ABSOLUTE@ and
-- @ANOMALY_TOTAL_IMPACT_PERCENTAGE@. The supported nested expression types
-- are @AND@ and @OR@. The match option @GREATER_THAN_OR_EQUAL@ is
-- required. Values must be numbers between 0 and 10,000,000,000.
--
-- One of Threshold or ThresholdExpression is required for this resource.
--
-- The following are examples of valid ThresholdExpressions:
--
-- -   Absolute threshold:
--     @{ \"Dimensions\": { \"Key\": \"ANOMALY_TOTAL_IMPACT_ABSOLUTE\", \"MatchOptions\": [ \"GREATER_THAN_OR_EQUAL\" ], \"Values\": [ \"100\" ] } }@
--
-- -   Percentage threshold:
--     @{ \"Dimensions\": { \"Key\": \"ANOMALY_TOTAL_IMPACT_PERCENTAGE\", \"MatchOptions\": [ \"GREATER_THAN_OR_EQUAL\" ], \"Values\": [ \"100\" ] } }@
--
-- -   @AND@ two thresholds together:
--     @{ \"And\": [ { \"Dimensions\": { \"Key\": \"ANOMALY_TOTAL_IMPACT_ABSOLUTE\", \"MatchOptions\": [ \"GREATER_THAN_OR_EQUAL\" ], \"Values\": [ \"100\" ] } }, { \"Dimensions\": { \"Key\": \"ANOMALY_TOTAL_IMPACT_PERCENTAGE\", \"MatchOptions\": [ \"GREATER_THAN_OR_EQUAL\" ], \"Values\": [ \"100\" ] } } ] }@
--
-- -   @OR@ two thresholds together:
--     @{ \"Or\": [ { \"Dimensions\": { \"Key\": \"ANOMALY_TOTAL_IMPACT_ABSOLUTE\", \"MatchOptions\": [ \"GREATER_THAN_OR_EQUAL\" ], \"Values\": [ \"100\" ] } }, { \"Dimensions\": { \"Key\": \"ANOMALY_TOTAL_IMPACT_PERCENTAGE\", \"MatchOptions\": [ \"GREATER_THAN_OR_EQUAL\" ], \"Values\": [ \"100\" ] } } ] }@
--
-- 'monitorArnList', 'anomalySubscription_monitorArnList' - A list of cost anomaly monitors.
--
-- 'subscribers', 'anomalySubscription_subscribers' - A list of subscribers to notify.
--
-- 'frequency', 'anomalySubscription_frequency' - The frequency that anomaly reports are sent over email.
--
-- 'subscriptionName', 'anomalySubscription_subscriptionName' - The name for the subscription.
newAnomalySubscription ::
  -- | 'frequency'
  AnomalySubscriptionFrequency ->
  -- | 'subscriptionName'
  Prelude.Text ->
  AnomalySubscription
newAnomalySubscription :: AnomalySubscriptionFrequency -> Text -> AnomalySubscription
newAnomalySubscription AnomalySubscriptionFrequency
pFrequency_ Text
pSubscriptionName_ =
  AnomalySubscription'
    { $sel:accountId:AnomalySubscription' :: Maybe Text
accountId = forall a. Maybe a
Prelude.Nothing,
      $sel:subscriptionArn:AnomalySubscription' :: Maybe Text
subscriptionArn = forall a. Maybe a
Prelude.Nothing,
      $sel:threshold:AnomalySubscription' :: Maybe Double
threshold = forall a. Maybe a
Prelude.Nothing,
      $sel:thresholdExpression:AnomalySubscription' :: Maybe Expression
thresholdExpression = forall a. Maybe a
Prelude.Nothing,
      $sel:monitorArnList:AnomalySubscription' :: [Text]
monitorArnList = forall a. Monoid a => a
Prelude.mempty,
      $sel:subscribers:AnomalySubscription' :: [Subscriber]
subscribers = forall a. Monoid a => a
Prelude.mempty,
      $sel:frequency:AnomalySubscription' :: AnomalySubscriptionFrequency
frequency = AnomalySubscriptionFrequency
pFrequency_,
      $sel:subscriptionName:AnomalySubscription' :: Text
subscriptionName = Text
pSubscriptionName_
    }

-- | Your unique account identifier.
anomalySubscription_accountId :: Lens.Lens' AnomalySubscription (Prelude.Maybe Prelude.Text)
anomalySubscription_accountId :: Lens' AnomalySubscription (Maybe Text)
anomalySubscription_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalySubscription' {Maybe Text
accountId :: Maybe Text
$sel:accountId:AnomalySubscription' :: AnomalySubscription -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: AnomalySubscription
s@AnomalySubscription' {} Maybe Text
a -> AnomalySubscription
s {$sel:accountId:AnomalySubscription' :: Maybe Text
accountId = Maybe Text
a} :: AnomalySubscription)

-- | The @AnomalySubscription@ Amazon Resource Name (ARN).
anomalySubscription_subscriptionArn :: Lens.Lens' AnomalySubscription (Prelude.Maybe Prelude.Text)
anomalySubscription_subscriptionArn :: Lens' AnomalySubscription (Maybe Text)
anomalySubscription_subscriptionArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalySubscription' {Maybe Text
subscriptionArn :: Maybe Text
$sel:subscriptionArn:AnomalySubscription' :: AnomalySubscription -> Maybe Text
subscriptionArn} -> Maybe Text
subscriptionArn) (\s :: AnomalySubscription
s@AnomalySubscription' {} Maybe Text
a -> AnomalySubscription
s {$sel:subscriptionArn:AnomalySubscription' :: Maybe Text
subscriptionArn = Maybe Text
a} :: AnomalySubscription)

-- | (deprecated)
--
-- The dollar value that triggers a notification if the threshold is
-- exceeded.
--
-- This field has been deprecated. To specify a threshold, use
-- ThresholdExpression. Continued use of Threshold will be treated as
-- shorthand syntax for a ThresholdExpression.
--
-- One of Threshold or ThresholdExpression is required for this resource.
anomalySubscription_threshold :: Lens.Lens' AnomalySubscription (Prelude.Maybe Prelude.Double)
anomalySubscription_threshold :: Lens' AnomalySubscription (Maybe Double)
anomalySubscription_threshold = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalySubscription' {Maybe Double
threshold :: Maybe Double
$sel:threshold:AnomalySubscription' :: AnomalySubscription -> Maybe Double
threshold} -> Maybe Double
threshold) (\s :: AnomalySubscription
s@AnomalySubscription' {} Maybe Double
a -> AnomalySubscription
s {$sel:threshold:AnomalySubscription' :: Maybe Double
threshold = Maybe Double
a} :: AnomalySubscription)

-- | An
-- <https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_Expression.html Expression>
-- object used to specify the anomalies that you want to generate alerts
-- for. This supports dimensions and nested expressions. The supported
-- dimensions are @ANOMALY_TOTAL_IMPACT_ABSOLUTE@ and
-- @ANOMALY_TOTAL_IMPACT_PERCENTAGE@. The supported nested expression types
-- are @AND@ and @OR@. The match option @GREATER_THAN_OR_EQUAL@ is
-- required. Values must be numbers between 0 and 10,000,000,000.
--
-- One of Threshold or ThresholdExpression is required for this resource.
--
-- The following are examples of valid ThresholdExpressions:
--
-- -   Absolute threshold:
--     @{ \"Dimensions\": { \"Key\": \"ANOMALY_TOTAL_IMPACT_ABSOLUTE\", \"MatchOptions\": [ \"GREATER_THAN_OR_EQUAL\" ], \"Values\": [ \"100\" ] } }@
--
-- -   Percentage threshold:
--     @{ \"Dimensions\": { \"Key\": \"ANOMALY_TOTAL_IMPACT_PERCENTAGE\", \"MatchOptions\": [ \"GREATER_THAN_OR_EQUAL\" ], \"Values\": [ \"100\" ] } }@
--
-- -   @AND@ two thresholds together:
--     @{ \"And\": [ { \"Dimensions\": { \"Key\": \"ANOMALY_TOTAL_IMPACT_ABSOLUTE\", \"MatchOptions\": [ \"GREATER_THAN_OR_EQUAL\" ], \"Values\": [ \"100\" ] } }, { \"Dimensions\": { \"Key\": \"ANOMALY_TOTAL_IMPACT_PERCENTAGE\", \"MatchOptions\": [ \"GREATER_THAN_OR_EQUAL\" ], \"Values\": [ \"100\" ] } } ] }@
--
-- -   @OR@ two thresholds together:
--     @{ \"Or\": [ { \"Dimensions\": { \"Key\": \"ANOMALY_TOTAL_IMPACT_ABSOLUTE\", \"MatchOptions\": [ \"GREATER_THAN_OR_EQUAL\" ], \"Values\": [ \"100\" ] } }, { \"Dimensions\": { \"Key\": \"ANOMALY_TOTAL_IMPACT_PERCENTAGE\", \"MatchOptions\": [ \"GREATER_THAN_OR_EQUAL\" ], \"Values\": [ \"100\" ] } } ] }@
anomalySubscription_thresholdExpression :: Lens.Lens' AnomalySubscription (Prelude.Maybe Expression)
anomalySubscription_thresholdExpression :: Lens' AnomalySubscription (Maybe Expression)
anomalySubscription_thresholdExpression = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalySubscription' {Maybe Expression
thresholdExpression :: Maybe Expression
$sel:thresholdExpression:AnomalySubscription' :: AnomalySubscription -> Maybe Expression
thresholdExpression} -> Maybe Expression
thresholdExpression) (\s :: AnomalySubscription
s@AnomalySubscription' {} Maybe Expression
a -> AnomalySubscription
s {$sel:thresholdExpression:AnomalySubscription' :: Maybe Expression
thresholdExpression = Maybe Expression
a} :: AnomalySubscription)

-- | A list of cost anomaly monitors.
anomalySubscription_monitorArnList :: Lens.Lens' AnomalySubscription [Prelude.Text]
anomalySubscription_monitorArnList :: Lens' AnomalySubscription [Text]
anomalySubscription_monitorArnList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalySubscription' {[Text]
monitorArnList :: [Text]
$sel:monitorArnList:AnomalySubscription' :: AnomalySubscription -> [Text]
monitorArnList} -> [Text]
monitorArnList) (\s :: AnomalySubscription
s@AnomalySubscription' {} [Text]
a -> AnomalySubscription
s {$sel:monitorArnList:AnomalySubscription' :: [Text]
monitorArnList = [Text]
a} :: AnomalySubscription) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A list of subscribers to notify.
anomalySubscription_subscribers :: Lens.Lens' AnomalySubscription [Subscriber]
anomalySubscription_subscribers :: Lens' AnomalySubscription [Subscriber]
anomalySubscription_subscribers = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalySubscription' {[Subscriber]
subscribers :: [Subscriber]
$sel:subscribers:AnomalySubscription' :: AnomalySubscription -> [Subscriber]
subscribers} -> [Subscriber]
subscribers) (\s :: AnomalySubscription
s@AnomalySubscription' {} [Subscriber]
a -> AnomalySubscription
s {$sel:subscribers:AnomalySubscription' :: [Subscriber]
subscribers = [Subscriber]
a} :: AnomalySubscription) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The frequency that anomaly reports are sent over email.
anomalySubscription_frequency :: Lens.Lens' AnomalySubscription AnomalySubscriptionFrequency
anomalySubscription_frequency :: Lens' AnomalySubscription AnomalySubscriptionFrequency
anomalySubscription_frequency = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalySubscription' {AnomalySubscriptionFrequency
frequency :: AnomalySubscriptionFrequency
$sel:frequency:AnomalySubscription' :: AnomalySubscription -> AnomalySubscriptionFrequency
frequency} -> AnomalySubscriptionFrequency
frequency) (\s :: AnomalySubscription
s@AnomalySubscription' {} AnomalySubscriptionFrequency
a -> AnomalySubscription
s {$sel:frequency:AnomalySubscription' :: AnomalySubscriptionFrequency
frequency = AnomalySubscriptionFrequency
a} :: AnomalySubscription)

-- | The name for the subscription.
anomalySubscription_subscriptionName :: Lens.Lens' AnomalySubscription Prelude.Text
anomalySubscription_subscriptionName :: Lens' AnomalySubscription Text
anomalySubscription_subscriptionName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalySubscription' {Text
subscriptionName :: Text
$sel:subscriptionName:AnomalySubscription' :: AnomalySubscription -> Text
subscriptionName} -> Text
subscriptionName) (\s :: AnomalySubscription
s@AnomalySubscription' {} Text
a -> AnomalySubscription
s {$sel:subscriptionName:AnomalySubscription' :: Text
subscriptionName = Text
a} :: AnomalySubscription)

instance Data.FromJSON AnomalySubscription where
  parseJSON :: Value -> Parser AnomalySubscription
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AnomalySubscription"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Double
-> Maybe Expression
-> [Text]
-> [Subscriber]
-> AnomalySubscriptionFrequency
-> Text
-> AnomalySubscription
AnomalySubscription'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"AccountId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"SubscriptionArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Threshold")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ThresholdExpression")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"MonitorArnList" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Subscribers" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"Frequency")
            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
"SubscriptionName")
      )

instance Prelude.Hashable AnomalySubscription where
  hashWithSalt :: Int -> AnomalySubscription -> Int
hashWithSalt Int
_salt AnomalySubscription' {[Text]
[Subscriber]
Maybe Double
Maybe Text
Maybe Expression
Text
AnomalySubscriptionFrequency
subscriptionName :: Text
frequency :: AnomalySubscriptionFrequency
subscribers :: [Subscriber]
monitorArnList :: [Text]
thresholdExpression :: Maybe Expression
threshold :: Maybe Double
subscriptionArn :: Maybe Text
accountId :: Maybe Text
$sel:subscriptionName:AnomalySubscription' :: AnomalySubscription -> Text
$sel:frequency:AnomalySubscription' :: AnomalySubscription -> AnomalySubscriptionFrequency
$sel:subscribers:AnomalySubscription' :: AnomalySubscription -> [Subscriber]
$sel:monitorArnList:AnomalySubscription' :: AnomalySubscription -> [Text]
$sel:thresholdExpression:AnomalySubscription' :: AnomalySubscription -> Maybe Expression
$sel:threshold:AnomalySubscription' :: AnomalySubscription -> Maybe Double
$sel:subscriptionArn:AnomalySubscription' :: AnomalySubscription -> Maybe Text
$sel:accountId:AnomalySubscription' :: AnomalySubscription -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
subscriptionArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
threshold
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Expression
thresholdExpression
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
monitorArnList
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Subscriber]
subscribers
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` AnomalySubscriptionFrequency
frequency
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
subscriptionName

instance Prelude.NFData AnomalySubscription where
  rnf :: AnomalySubscription -> ()
rnf AnomalySubscription' {[Text]
[Subscriber]
Maybe Double
Maybe Text
Maybe Expression
Text
AnomalySubscriptionFrequency
subscriptionName :: Text
frequency :: AnomalySubscriptionFrequency
subscribers :: [Subscriber]
monitorArnList :: [Text]
thresholdExpression :: Maybe Expression
threshold :: Maybe Double
subscriptionArn :: Maybe Text
accountId :: Maybe Text
$sel:subscriptionName:AnomalySubscription' :: AnomalySubscription -> Text
$sel:frequency:AnomalySubscription' :: AnomalySubscription -> AnomalySubscriptionFrequency
$sel:subscribers:AnomalySubscription' :: AnomalySubscription -> [Subscriber]
$sel:monitorArnList:AnomalySubscription' :: AnomalySubscription -> [Text]
$sel:thresholdExpression:AnomalySubscription' :: AnomalySubscription -> Maybe Expression
$sel:threshold:AnomalySubscription' :: AnomalySubscription -> Maybe Double
$sel:subscriptionArn:AnomalySubscription' :: AnomalySubscription -> Maybe Text
$sel:accountId:AnomalySubscription' :: AnomalySubscription -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
subscriptionArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
threshold
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Expression
thresholdExpression
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
monitorArnList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Subscriber]
subscribers
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf AnomalySubscriptionFrequency
frequency
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
subscriptionName

instance Data.ToJSON AnomalySubscription where
  toJSON :: AnomalySubscription -> Value
toJSON AnomalySubscription' {[Text]
[Subscriber]
Maybe Double
Maybe Text
Maybe Expression
Text
AnomalySubscriptionFrequency
subscriptionName :: Text
frequency :: AnomalySubscriptionFrequency
subscribers :: [Subscriber]
monitorArnList :: [Text]
thresholdExpression :: Maybe Expression
threshold :: Maybe Double
subscriptionArn :: Maybe Text
accountId :: Maybe Text
$sel:subscriptionName:AnomalySubscription' :: AnomalySubscription -> Text
$sel:frequency:AnomalySubscription' :: AnomalySubscription -> AnomalySubscriptionFrequency
$sel:subscribers:AnomalySubscription' :: AnomalySubscription -> [Subscriber]
$sel:monitorArnList:AnomalySubscription' :: AnomalySubscription -> [Text]
$sel:thresholdExpression:AnomalySubscription' :: AnomalySubscription -> Maybe Expression
$sel:threshold:AnomalySubscription' :: AnomalySubscription -> Maybe Double
$sel:subscriptionArn:AnomalySubscription' :: AnomalySubscription -> Maybe Text
$sel:accountId:AnomalySubscription' :: AnomalySubscription -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AccountId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
accountId,
            (Key
"SubscriptionArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
subscriptionArn,
            (Key
"Threshold" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
threshold,
            (Key
"ThresholdExpression" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Expression
thresholdExpression,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"MonitorArnList" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
monitorArnList),
            forall a. a -> Maybe a
Prelude.Just (Key
"Subscribers" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Subscriber]
subscribers),
            forall a. a -> Maybe a
Prelude.Just (Key
"Frequency" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= AnomalySubscriptionFrequency
frequency),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"SubscriptionName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
subscriptionName)
          ]
      )