{-# 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.CloudWatch.Types.AnomalyDetectorConfiguration where
import Amazonka.CloudWatch.Types.Range
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data AnomalyDetectorConfiguration = AnomalyDetectorConfiguration'
{
AnomalyDetectorConfiguration -> Maybe Text
metricTimezone :: Prelude.Maybe Prelude.Text,
AnomalyDetectorConfiguration -> Maybe [Range]
excludedTimeRanges :: Prelude.Maybe [Range]
}
deriving (AnomalyDetectorConfiguration
-> AnomalyDetectorConfiguration -> Bool
(AnomalyDetectorConfiguration
-> AnomalyDetectorConfiguration -> Bool)
-> (AnomalyDetectorConfiguration
-> AnomalyDetectorConfiguration -> Bool)
-> Eq AnomalyDetectorConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AnomalyDetectorConfiguration
-> AnomalyDetectorConfiguration -> Bool
$c/= :: AnomalyDetectorConfiguration
-> AnomalyDetectorConfiguration -> Bool
== :: AnomalyDetectorConfiguration
-> AnomalyDetectorConfiguration -> Bool
$c== :: AnomalyDetectorConfiguration
-> AnomalyDetectorConfiguration -> Bool
Prelude.Eq, ReadPrec [AnomalyDetectorConfiguration]
ReadPrec AnomalyDetectorConfiguration
Int -> ReadS AnomalyDetectorConfiguration
ReadS [AnomalyDetectorConfiguration]
(Int -> ReadS AnomalyDetectorConfiguration)
-> ReadS [AnomalyDetectorConfiguration]
-> ReadPrec AnomalyDetectorConfiguration
-> ReadPrec [AnomalyDetectorConfiguration]
-> Read AnomalyDetectorConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AnomalyDetectorConfiguration]
$creadListPrec :: ReadPrec [AnomalyDetectorConfiguration]
readPrec :: ReadPrec AnomalyDetectorConfiguration
$creadPrec :: ReadPrec AnomalyDetectorConfiguration
readList :: ReadS [AnomalyDetectorConfiguration]
$creadList :: ReadS [AnomalyDetectorConfiguration]
readsPrec :: Int -> ReadS AnomalyDetectorConfiguration
$creadsPrec :: Int -> ReadS AnomalyDetectorConfiguration
Prelude.Read, Int -> AnomalyDetectorConfiguration -> ShowS
[AnomalyDetectorConfiguration] -> ShowS
AnomalyDetectorConfiguration -> String
(Int -> AnomalyDetectorConfiguration -> ShowS)
-> (AnomalyDetectorConfiguration -> String)
-> ([AnomalyDetectorConfiguration] -> ShowS)
-> Show AnomalyDetectorConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AnomalyDetectorConfiguration] -> ShowS
$cshowList :: [AnomalyDetectorConfiguration] -> ShowS
show :: AnomalyDetectorConfiguration -> String
$cshow :: AnomalyDetectorConfiguration -> String
showsPrec :: Int -> AnomalyDetectorConfiguration -> ShowS
$cshowsPrec :: Int -> AnomalyDetectorConfiguration -> ShowS
Prelude.Show, (forall x.
AnomalyDetectorConfiguration -> Rep AnomalyDetectorConfiguration x)
-> (forall x.
Rep AnomalyDetectorConfiguration x -> AnomalyDetectorConfiguration)
-> Generic AnomalyDetectorConfiguration
forall x.
Rep AnomalyDetectorConfiguration x -> AnomalyDetectorConfiguration
forall x.
AnomalyDetectorConfiguration -> Rep AnomalyDetectorConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AnomalyDetectorConfiguration x -> AnomalyDetectorConfiguration
$cfrom :: forall x.
AnomalyDetectorConfiguration -> Rep AnomalyDetectorConfiguration x
Prelude.Generic)
newAnomalyDetectorConfiguration ::
AnomalyDetectorConfiguration
newAnomalyDetectorConfiguration :: AnomalyDetectorConfiguration
newAnomalyDetectorConfiguration =
AnomalyDetectorConfiguration' :: Maybe Text -> Maybe [Range] -> AnomalyDetectorConfiguration
AnomalyDetectorConfiguration'
{ $sel:metricTimezone:AnomalyDetectorConfiguration' :: Maybe Text
metricTimezone =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:excludedTimeRanges:AnomalyDetectorConfiguration' :: Maybe [Range]
excludedTimeRanges = Maybe [Range]
forall a. Maybe a
Prelude.Nothing
}
anomalyDetectorConfiguration_metricTimezone :: Lens.Lens' AnomalyDetectorConfiguration (Prelude.Maybe Prelude.Text)
anomalyDetectorConfiguration_metricTimezone :: (Maybe Text -> f (Maybe Text))
-> AnomalyDetectorConfiguration -> f AnomalyDetectorConfiguration
anomalyDetectorConfiguration_metricTimezone = (AnomalyDetectorConfiguration -> Maybe Text)
-> (AnomalyDetectorConfiguration
-> Maybe Text -> AnomalyDetectorConfiguration)
-> Lens
AnomalyDetectorConfiguration
AnomalyDetectorConfiguration
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyDetectorConfiguration' {Maybe Text
metricTimezone :: Maybe Text
$sel:metricTimezone:AnomalyDetectorConfiguration' :: AnomalyDetectorConfiguration -> Maybe Text
metricTimezone} -> Maybe Text
metricTimezone) (\s :: AnomalyDetectorConfiguration
s@AnomalyDetectorConfiguration' {} Maybe Text
a -> AnomalyDetectorConfiguration
s {$sel:metricTimezone:AnomalyDetectorConfiguration' :: Maybe Text
metricTimezone = Maybe Text
a} :: AnomalyDetectorConfiguration)
anomalyDetectorConfiguration_excludedTimeRanges :: Lens.Lens' AnomalyDetectorConfiguration (Prelude.Maybe [Range])
anomalyDetectorConfiguration_excludedTimeRanges :: (Maybe [Range] -> f (Maybe [Range]))
-> AnomalyDetectorConfiguration -> f AnomalyDetectorConfiguration
anomalyDetectorConfiguration_excludedTimeRanges = (AnomalyDetectorConfiguration -> Maybe [Range])
-> (AnomalyDetectorConfiguration
-> Maybe [Range] -> AnomalyDetectorConfiguration)
-> Lens
AnomalyDetectorConfiguration
AnomalyDetectorConfiguration
(Maybe [Range])
(Maybe [Range])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AnomalyDetectorConfiguration' {Maybe [Range]
excludedTimeRanges :: Maybe [Range]
$sel:excludedTimeRanges:AnomalyDetectorConfiguration' :: AnomalyDetectorConfiguration -> Maybe [Range]
excludedTimeRanges} -> Maybe [Range]
excludedTimeRanges) (\s :: AnomalyDetectorConfiguration
s@AnomalyDetectorConfiguration' {} Maybe [Range]
a -> AnomalyDetectorConfiguration
s {$sel:excludedTimeRanges:AnomalyDetectorConfiguration' :: Maybe [Range]
excludedTimeRanges = Maybe [Range]
a} :: AnomalyDetectorConfiguration) ((Maybe [Range] -> f (Maybe [Range]))
-> AnomalyDetectorConfiguration -> f AnomalyDetectorConfiguration)
-> ((Maybe [Range] -> f (Maybe [Range]))
-> Maybe [Range] -> f (Maybe [Range]))
-> (Maybe [Range] -> f (Maybe [Range]))
-> AnomalyDetectorConfiguration
-> f AnomalyDetectorConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Range] [Range] [Range] [Range]
-> Iso
(Maybe [Range]) (Maybe [Range]) (Maybe [Range]) (Maybe [Range])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Range] [Range] [Range] [Range]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.FromXML AnomalyDetectorConfiguration where
parseXML :: [Node] -> Either String AnomalyDetectorConfiguration
parseXML [Node]
x =
Maybe Text -> Maybe [Range] -> AnomalyDetectorConfiguration
AnomalyDetectorConfiguration'
(Maybe Text -> Maybe [Range] -> AnomalyDetectorConfiguration)
-> Either String (Maybe Text)
-> Either String (Maybe [Range] -> AnomalyDetectorConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"MetricTimezone")
Either String (Maybe [Range] -> AnomalyDetectorConfiguration)
-> Either String (Maybe [Range])
-> Either String AnomalyDetectorConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ExcludedTimeRanges"
Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
Either String [Node]
-> ([Node] -> Either String (Maybe [Range]))
-> Either String (Maybe [Range])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Range])
-> [Node] -> Either String (Maybe [Range])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Range]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
)
instance
Prelude.Hashable
AnomalyDetectorConfiguration
instance Prelude.NFData AnomalyDetectorConfiguration
instance Core.ToQuery AnomalyDetectorConfiguration where
toQuery :: AnomalyDetectorConfiguration -> QueryString
toQuery AnomalyDetectorConfiguration' {Maybe [Range]
Maybe Text
excludedTimeRanges :: Maybe [Range]
metricTimezone :: Maybe Text
$sel:excludedTimeRanges:AnomalyDetectorConfiguration' :: AnomalyDetectorConfiguration -> Maybe [Range]
$sel:metricTimezone:AnomalyDetectorConfiguration' :: AnomalyDetectorConfiguration -> Maybe Text
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"MetricTimezone" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
metricTimezone,
ByteString
"ExcludedTimeRanges"
ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
( ByteString -> [Range] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member"
([Range] -> QueryString) -> Maybe [Range] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Range]
excludedTimeRanges
)
]