{-# 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 #-}
module Amazonka.CostExplorer.Types.AnomalySubscription where
import qualified Amazonka.Core as Core
import Amazonka.CostExplorer.Types.AnomalySubscriptionFrequency
import Amazonka.CostExplorer.Types.Subscriber
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data AnomalySubscription = AnomalySubscription'
{
AnomalySubscription -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
AnomalySubscription -> Maybe Text
subscriptionArn :: Prelude.Maybe Prelude.Text,
AnomalySubscription -> [Text]
monitorArnList :: [Prelude.Text],
AnomalySubscription -> [Subscriber]
subscribers :: [Subscriber],
AnomalySubscription -> Double
threshold :: Prelude.Double,
AnomalySubscription -> AnomalySubscriptionFrequency
frequency :: AnomalySubscriptionFrequency,
AnomalySubscription -> Text
subscriptionName :: Prelude.Text
}
deriving (AnomalySubscription -> AnomalySubscription -> Bool
(AnomalySubscription -> AnomalySubscription -> Bool)
-> (AnomalySubscription -> AnomalySubscription -> Bool)
-> Eq AnomalySubscription
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]
(Int -> ReadS AnomalySubscription)
-> ReadS [AnomalySubscription]
-> ReadPrec AnomalySubscription
-> ReadPrec [AnomalySubscription]
-> Read 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
(Int -> AnomalySubscription -> ShowS)
-> (AnomalySubscription -> String)
-> ([AnomalySubscription] -> ShowS)
-> Show AnomalySubscription
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. AnomalySubscription -> Rep AnomalySubscription x)
-> (forall x. Rep AnomalySubscription x -> AnomalySubscription)
-> Generic AnomalySubscription
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)
newAnomalySubscription ::
Prelude.Double ->
AnomalySubscriptionFrequency ->
Prelude.Text ->
AnomalySubscription
newAnomalySubscription :: Double
-> AnomalySubscriptionFrequency -> Text -> AnomalySubscription
newAnomalySubscription
Double
pThreshold_
AnomalySubscriptionFrequency
pFrequency_
Text
pSubscriptionName_ =
AnomalySubscription' :: Maybe Text
-> Maybe Text
-> [Text]
-> [Subscriber]
-> Double
-> AnomalySubscriptionFrequency
-> Text
-> AnomalySubscription
AnomalySubscription'
{ $sel:accountId:AnomalySubscription' :: Maybe Text
accountId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:subscriptionArn:AnomalySubscription' :: Maybe Text
subscriptionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:monitorArnList:AnomalySubscription' :: [Text]
monitorArnList = [Text]
forall a. Monoid a => a
Prelude.mempty,
$sel:subscribers:AnomalySubscription' :: [Subscriber]
subscribers = [Subscriber]
forall a. Monoid a => a
Prelude.mempty,
$sel:threshold:AnomalySubscription' :: Double
threshold = Double
pThreshold_,
$sel:frequency:AnomalySubscription' :: AnomalySubscriptionFrequency
frequency = AnomalySubscriptionFrequency
pFrequency_,
$sel:subscriptionName:AnomalySubscription' :: Text
subscriptionName = Text
pSubscriptionName_
}
anomalySubscription_accountId :: Lens.Lens' AnomalySubscription (Prelude.Maybe Prelude.Text)
anomalySubscription_accountId :: (Maybe Text -> f (Maybe Text))
-> AnomalySubscription -> f AnomalySubscription
anomalySubscription_accountId = (AnomalySubscription -> Maybe Text)
-> (AnomalySubscription -> Maybe Text -> AnomalySubscription)
-> Lens
AnomalySubscription AnomalySubscription (Maybe Text) (Maybe Text)
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)
anomalySubscription_subscriptionArn :: Lens.Lens' AnomalySubscription (Prelude.Maybe Prelude.Text)
anomalySubscription_subscriptionArn :: (Maybe Text -> f (Maybe Text))
-> AnomalySubscription -> f AnomalySubscription
anomalySubscription_subscriptionArn = (AnomalySubscription -> Maybe Text)
-> (AnomalySubscription -> Maybe Text -> AnomalySubscription)
-> Lens
AnomalySubscription AnomalySubscription (Maybe Text) (Maybe Text)
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)
anomalySubscription_monitorArnList :: Lens.Lens' AnomalySubscription [Prelude.Text]
anomalySubscription_monitorArnList :: ([Text] -> f [Text])
-> AnomalySubscription -> f AnomalySubscription
anomalySubscription_monitorArnList = (AnomalySubscription -> [Text])
-> (AnomalySubscription -> [Text] -> AnomalySubscription)
-> Lens AnomalySubscription AnomalySubscription [Text] [Text]
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) (([Text] -> f [Text])
-> AnomalySubscription -> f AnomalySubscription)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> AnomalySubscription
-> f AnomalySubscription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
anomalySubscription_subscribers :: Lens.Lens' AnomalySubscription [Subscriber]
anomalySubscription_subscribers :: ([Subscriber] -> f [Subscriber])
-> AnomalySubscription -> f AnomalySubscription
anomalySubscription_subscribers = (AnomalySubscription -> [Subscriber])
-> (AnomalySubscription -> [Subscriber] -> AnomalySubscription)
-> Lens
AnomalySubscription AnomalySubscription [Subscriber] [Subscriber]
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) (([Subscriber] -> f [Subscriber])
-> AnomalySubscription -> f AnomalySubscription)
-> (([Subscriber] -> f [Subscriber])
-> [Subscriber] -> f [Subscriber])
-> ([Subscriber] -> f [Subscriber])
-> AnomalySubscription
-> f AnomalySubscription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Subscriber] -> f [Subscriber]) -> [Subscriber] -> f [Subscriber]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
anomalySubscription_threshold :: Lens.Lens' AnomalySubscription Prelude.Double
anomalySubscription_threshold :: (Double -> f Double)
-> AnomalySubscription -> f AnomalySubscription
anomalySubscription_threshold = (AnomalySubscription -> Double)
-> (AnomalySubscription -> Double -> AnomalySubscription)
-> Lens AnomalySubscription AnomalySubscription Double Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalySubscription' {Double
threshold :: Double
$sel:threshold:AnomalySubscription' :: AnomalySubscription -> Double
threshold} -> Double
threshold) (\s :: AnomalySubscription
s@AnomalySubscription' {} Double
a -> AnomalySubscription
s {$sel:threshold:AnomalySubscription' :: Double
threshold = Double
a} :: AnomalySubscription)
anomalySubscription_frequency :: Lens.Lens' AnomalySubscription AnomalySubscriptionFrequency
anomalySubscription_frequency :: (AnomalySubscriptionFrequency -> f AnomalySubscriptionFrequency)
-> AnomalySubscription -> f AnomalySubscription
anomalySubscription_frequency = (AnomalySubscription -> AnomalySubscriptionFrequency)
-> (AnomalySubscription
-> AnomalySubscriptionFrequency -> AnomalySubscription)
-> Lens
AnomalySubscription
AnomalySubscription
AnomalySubscriptionFrequency
AnomalySubscriptionFrequency
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)
anomalySubscription_subscriptionName :: Lens.Lens' AnomalySubscription Prelude.Text
anomalySubscription_subscriptionName :: (Text -> f Text) -> AnomalySubscription -> f AnomalySubscription
anomalySubscription_subscriptionName = (AnomalySubscription -> Text)
-> (AnomalySubscription -> Text -> AnomalySubscription)
-> Lens AnomalySubscription AnomalySubscription Text Text
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 Core.FromJSON AnomalySubscription where
parseJSON :: Value -> Parser AnomalySubscription
parseJSON =
String
-> (Object -> Parser AnomalySubscription)
-> Value
-> Parser AnomalySubscription
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"AnomalySubscription"
( \Object
x ->
Maybe Text
-> Maybe Text
-> [Text]
-> [Subscriber]
-> Double
-> AnomalySubscriptionFrequency
-> Text
-> AnomalySubscription
AnomalySubscription'
(Maybe Text
-> Maybe Text
-> [Text]
-> [Subscriber]
-> Double
-> AnomalySubscriptionFrequency
-> Text
-> AnomalySubscription)
-> Parser (Maybe Text)
-> Parser
(Maybe Text
-> [Text]
-> [Subscriber]
-> Double
-> AnomalySubscriptionFrequency
-> Text
-> AnomalySubscription)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AccountId")
Parser
(Maybe Text
-> [Text]
-> [Subscriber]
-> Double
-> AnomalySubscriptionFrequency
-> Text
-> AnomalySubscription)
-> Parser (Maybe Text)
-> Parser
([Text]
-> [Subscriber]
-> Double
-> AnomalySubscriptionFrequency
-> Text
-> AnomalySubscription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SubscriptionArn")
Parser
([Text]
-> [Subscriber]
-> Double
-> AnomalySubscriptionFrequency
-> Text
-> AnomalySubscription)
-> Parser [Text]
-> Parser
([Subscriber]
-> Double
-> AnomalySubscriptionFrequency
-> Text
-> AnomalySubscription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [Text])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MonitorArnList" Parser (Maybe [Text]) -> [Text] -> Parser [Text]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Text]
forall a. Monoid a => a
Prelude.mempty)
Parser
([Subscriber]
-> Double
-> AnomalySubscriptionFrequency
-> Text
-> AnomalySubscription)
-> Parser [Subscriber]
-> Parser
(Double
-> AnomalySubscriptionFrequency -> Text -> AnomalySubscription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe [Subscriber])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Subscribers" Parser (Maybe [Subscriber]) -> [Subscriber] -> Parser [Subscriber]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Subscriber]
forall a. Monoid a => a
Prelude.mempty)
Parser
(Double
-> AnomalySubscriptionFrequency -> Text -> AnomalySubscription)
-> Parser Double
-> Parser
(AnomalySubscriptionFrequency -> Text -> AnomalySubscription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Threshold")
Parser
(AnomalySubscriptionFrequency -> Text -> AnomalySubscription)
-> Parser AnomalySubscriptionFrequency
-> Parser (Text -> AnomalySubscription)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser AnomalySubscriptionFrequency
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Frequency")
Parser (Text -> AnomalySubscription)
-> Parser Text -> Parser AnomalySubscription
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"SubscriptionName")
)
instance Prelude.Hashable AnomalySubscription
instance Prelude.NFData AnomalySubscription
instance Core.ToJSON AnomalySubscription where
toJSON :: AnomalySubscription -> Value
toJSON AnomalySubscription' {Double
[Text]
[Subscriber]
Maybe Text
Text
AnomalySubscriptionFrequency
subscriptionName :: Text
frequency :: AnomalySubscriptionFrequency
threshold :: Double
subscribers :: [Subscriber]
monitorArnList :: [Text]
subscriptionArn :: Maybe Text
accountId :: Maybe Text
$sel:subscriptionName:AnomalySubscription' :: AnomalySubscription -> Text
$sel:frequency:AnomalySubscription' :: AnomalySubscription -> AnomalySubscriptionFrequency
$sel:threshold:AnomalySubscription' :: AnomalySubscription -> Double
$sel:subscribers:AnomalySubscription' :: AnomalySubscription -> [Subscriber]
$sel:monitorArnList:AnomalySubscription' :: AnomalySubscription -> [Text]
$sel:subscriptionArn:AnomalySubscription' :: AnomalySubscription -> Maybe Text
$sel:accountId:AnomalySubscription' :: AnomalySubscription -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"AccountId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
accountId,
(Text
"SubscriptionArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
subscriptionArn,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"MonitorArnList" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
monitorArnList),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Subscribers" Text -> [Subscriber] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Subscriber]
subscribers),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Threshold" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Double
threshold),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Frequency" Text -> AnomalySubscriptionFrequency -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AnomalySubscriptionFrequency
frequency),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"SubscriptionName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
subscriptionName)
]
)