{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.LookoutMetrics.CreateAlert
(
CreateAlert (..),
newCreateAlert,
createAlert_alertDescription,
createAlert_tags,
createAlert_alertName,
createAlert_alertSensitivityThreshold,
createAlert_anomalyDetectorArn,
createAlert_action,
CreateAlertResponse (..),
newCreateAlertResponse,
createAlertResponse_alertArn,
createAlertResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LookoutMetrics.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateAlert = CreateAlert'
{
CreateAlert -> Maybe Text
alertDescription :: Prelude.Maybe Prelude.Text,
CreateAlert -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
CreateAlert -> Text
alertName :: Prelude.Text,
CreateAlert -> Natural
alertSensitivityThreshold :: Prelude.Natural,
CreateAlert -> Text
anomalyDetectorArn :: Prelude.Text,
CreateAlert -> Action
action :: Action
}
deriving (CreateAlert -> CreateAlert -> Bool
(CreateAlert -> CreateAlert -> Bool)
-> (CreateAlert -> CreateAlert -> Bool) -> Eq CreateAlert
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAlert -> CreateAlert -> Bool
$c/= :: CreateAlert -> CreateAlert -> Bool
== :: CreateAlert -> CreateAlert -> Bool
$c== :: CreateAlert -> CreateAlert -> Bool
Prelude.Eq, ReadPrec [CreateAlert]
ReadPrec CreateAlert
Int -> ReadS CreateAlert
ReadS [CreateAlert]
(Int -> ReadS CreateAlert)
-> ReadS [CreateAlert]
-> ReadPrec CreateAlert
-> ReadPrec [CreateAlert]
-> Read CreateAlert
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateAlert]
$creadListPrec :: ReadPrec [CreateAlert]
readPrec :: ReadPrec CreateAlert
$creadPrec :: ReadPrec CreateAlert
readList :: ReadS [CreateAlert]
$creadList :: ReadS [CreateAlert]
readsPrec :: Int -> ReadS CreateAlert
$creadsPrec :: Int -> ReadS CreateAlert
Prelude.Read, Int -> CreateAlert -> ShowS
[CreateAlert] -> ShowS
CreateAlert -> String
(Int -> CreateAlert -> ShowS)
-> (CreateAlert -> String)
-> ([CreateAlert] -> ShowS)
-> Show CreateAlert
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAlert] -> ShowS
$cshowList :: [CreateAlert] -> ShowS
show :: CreateAlert -> String
$cshow :: CreateAlert -> String
showsPrec :: Int -> CreateAlert -> ShowS
$cshowsPrec :: Int -> CreateAlert -> ShowS
Prelude.Show, (forall x. CreateAlert -> Rep CreateAlert x)
-> (forall x. Rep CreateAlert x -> CreateAlert)
-> Generic CreateAlert
forall x. Rep CreateAlert x -> CreateAlert
forall x. CreateAlert -> Rep CreateAlert x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateAlert x -> CreateAlert
$cfrom :: forall x. CreateAlert -> Rep CreateAlert x
Prelude.Generic)
newCreateAlert ::
Prelude.Text ->
Prelude.Natural ->
Prelude.Text ->
Action ->
CreateAlert
newCreateAlert :: Text -> Natural -> Text -> Action -> CreateAlert
newCreateAlert
Text
pAlertName_
Natural
pAlertSensitivityThreshold_
Text
pAnomalyDetectorArn_
Action
pAction_ =
CreateAlert' :: Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> Natural
-> Text
-> Action
-> CreateAlert
CreateAlert'
{ $sel:alertDescription:CreateAlert' :: Maybe Text
alertDescription = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateAlert' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
$sel:alertName:CreateAlert' :: Text
alertName = Text
pAlertName_,
$sel:alertSensitivityThreshold:CreateAlert' :: Natural
alertSensitivityThreshold =
Natural
pAlertSensitivityThreshold_,
$sel:anomalyDetectorArn:CreateAlert' :: Text
anomalyDetectorArn = Text
pAnomalyDetectorArn_,
$sel:action:CreateAlert' :: Action
action = Action
pAction_
}
createAlert_alertDescription :: Lens.Lens' CreateAlert (Prelude.Maybe Prelude.Text)
createAlert_alertDescription :: (Maybe Text -> f (Maybe Text)) -> CreateAlert -> f CreateAlert
createAlert_alertDescription = (CreateAlert -> Maybe Text)
-> (CreateAlert -> Maybe Text -> CreateAlert)
-> Lens CreateAlert CreateAlert (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAlert' {Maybe Text
alertDescription :: Maybe Text
$sel:alertDescription:CreateAlert' :: CreateAlert -> Maybe Text
alertDescription} -> Maybe Text
alertDescription) (\s :: CreateAlert
s@CreateAlert' {} Maybe Text
a -> CreateAlert
s {$sel:alertDescription:CreateAlert' :: Maybe Text
alertDescription = Maybe Text
a} :: CreateAlert)
createAlert_tags :: Lens.Lens' CreateAlert (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createAlert_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateAlert -> f CreateAlert
createAlert_tags = (CreateAlert -> Maybe (HashMap Text Text))
-> (CreateAlert -> Maybe (HashMap Text Text) -> CreateAlert)
-> Lens
CreateAlert
CreateAlert
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAlert' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateAlert' :: CreateAlert -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateAlert
s@CreateAlert' {} Maybe (HashMap Text Text)
a -> CreateAlert
s {$sel:tags:CreateAlert' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateAlert) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateAlert -> f CreateAlert)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateAlert
-> f CreateAlert
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
-> Iso
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
(Maybe (HashMap Text Text))
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
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
(HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createAlert_alertName :: Lens.Lens' CreateAlert Prelude.Text
createAlert_alertName :: (Text -> f Text) -> CreateAlert -> f CreateAlert
createAlert_alertName = (CreateAlert -> Text)
-> (CreateAlert -> Text -> CreateAlert)
-> Lens CreateAlert CreateAlert Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAlert' {Text
alertName :: Text
$sel:alertName:CreateAlert' :: CreateAlert -> Text
alertName} -> Text
alertName) (\s :: CreateAlert
s@CreateAlert' {} Text
a -> CreateAlert
s {$sel:alertName:CreateAlert' :: Text
alertName = Text
a} :: CreateAlert)
createAlert_alertSensitivityThreshold :: Lens.Lens' CreateAlert Prelude.Natural
createAlert_alertSensitivityThreshold :: (Natural -> f Natural) -> CreateAlert -> f CreateAlert
createAlert_alertSensitivityThreshold = (CreateAlert -> Natural)
-> (CreateAlert -> Natural -> CreateAlert)
-> Lens CreateAlert CreateAlert Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAlert' {Natural
alertSensitivityThreshold :: Natural
$sel:alertSensitivityThreshold:CreateAlert' :: CreateAlert -> Natural
alertSensitivityThreshold} -> Natural
alertSensitivityThreshold) (\s :: CreateAlert
s@CreateAlert' {} Natural
a -> CreateAlert
s {$sel:alertSensitivityThreshold:CreateAlert' :: Natural
alertSensitivityThreshold = Natural
a} :: CreateAlert)
createAlert_anomalyDetectorArn :: Lens.Lens' CreateAlert Prelude.Text
createAlert_anomalyDetectorArn :: (Text -> f Text) -> CreateAlert -> f CreateAlert
createAlert_anomalyDetectorArn = (CreateAlert -> Text)
-> (CreateAlert -> Text -> CreateAlert)
-> Lens CreateAlert CreateAlert Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAlert' {Text
anomalyDetectorArn :: Text
$sel:anomalyDetectorArn:CreateAlert' :: CreateAlert -> Text
anomalyDetectorArn} -> Text
anomalyDetectorArn) (\s :: CreateAlert
s@CreateAlert' {} Text
a -> CreateAlert
s {$sel:anomalyDetectorArn:CreateAlert' :: Text
anomalyDetectorArn = Text
a} :: CreateAlert)
createAlert_action :: Lens.Lens' CreateAlert Action
createAlert_action :: (Action -> f Action) -> CreateAlert -> f CreateAlert
createAlert_action = (CreateAlert -> Action)
-> (CreateAlert -> Action -> CreateAlert)
-> Lens CreateAlert CreateAlert Action Action
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAlert' {Action
action :: Action
$sel:action:CreateAlert' :: CreateAlert -> Action
action} -> Action
action) (\s :: CreateAlert
s@CreateAlert' {} Action
a -> CreateAlert
s {$sel:action:CreateAlert' :: Action
action = Action
a} :: CreateAlert)
instance Core.AWSRequest CreateAlert where
type AWSResponse CreateAlert = CreateAlertResponse
request :: CreateAlert -> Request CreateAlert
request = Service -> CreateAlert -> Request CreateAlert
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateAlert
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateAlert)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateAlert))
-> Logger
-> Service
-> Proxy CreateAlert
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateAlert)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Text -> Int -> CreateAlertResponse
CreateAlertResponse'
(Maybe Text -> Int -> CreateAlertResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateAlertResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"AlertArn")
Either String (Int -> CreateAlertResponse)
-> Either String Int -> Either String CreateAlertResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable CreateAlert
instance Prelude.NFData CreateAlert
instance Core.ToHeaders CreateAlert where
toHeaders :: CreateAlert -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateAlert -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON CreateAlert where
toJSON :: CreateAlert -> Value
toJSON CreateAlert' {Natural
Maybe Text
Maybe (HashMap Text Text)
Text
Action
action :: Action
anomalyDetectorArn :: Text
alertSensitivityThreshold :: Natural
alertName :: Text
tags :: Maybe (HashMap Text Text)
alertDescription :: Maybe Text
$sel:action:CreateAlert' :: CreateAlert -> Action
$sel:anomalyDetectorArn:CreateAlert' :: CreateAlert -> Text
$sel:alertSensitivityThreshold:CreateAlert' :: CreateAlert -> Natural
$sel:alertName:CreateAlert' :: CreateAlert -> Text
$sel:tags:CreateAlert' :: CreateAlert -> Maybe (HashMap Text Text)
$sel:alertDescription:CreateAlert' :: CreateAlert -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"AlertDescription" 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
alertDescription,
(Text
"Tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"AlertName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
alertName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
( Text
"AlertSensitivityThreshold"
Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
alertSensitivityThreshold
),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"AnomalyDetectorArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
anomalyDetectorArn),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Action" Text -> Action -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Action
action)
]
)
instance Core.ToPath CreateAlert where
toPath :: CreateAlert -> ByteString
toPath = ByteString -> CreateAlert -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/CreateAlert"
instance Core.ToQuery CreateAlert where
toQuery :: CreateAlert -> QueryString
toQuery = QueryString -> CreateAlert -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateAlertResponse = CreateAlertResponse'
{
CreateAlertResponse -> Maybe Text
alertArn :: Prelude.Maybe Prelude.Text,
CreateAlertResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateAlertResponse -> CreateAlertResponse -> Bool
(CreateAlertResponse -> CreateAlertResponse -> Bool)
-> (CreateAlertResponse -> CreateAlertResponse -> Bool)
-> Eq CreateAlertResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAlertResponse -> CreateAlertResponse -> Bool
$c/= :: CreateAlertResponse -> CreateAlertResponse -> Bool
== :: CreateAlertResponse -> CreateAlertResponse -> Bool
$c== :: CreateAlertResponse -> CreateAlertResponse -> Bool
Prelude.Eq, ReadPrec [CreateAlertResponse]
ReadPrec CreateAlertResponse
Int -> ReadS CreateAlertResponse
ReadS [CreateAlertResponse]
(Int -> ReadS CreateAlertResponse)
-> ReadS [CreateAlertResponse]
-> ReadPrec CreateAlertResponse
-> ReadPrec [CreateAlertResponse]
-> Read CreateAlertResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateAlertResponse]
$creadListPrec :: ReadPrec [CreateAlertResponse]
readPrec :: ReadPrec CreateAlertResponse
$creadPrec :: ReadPrec CreateAlertResponse
readList :: ReadS [CreateAlertResponse]
$creadList :: ReadS [CreateAlertResponse]
readsPrec :: Int -> ReadS CreateAlertResponse
$creadsPrec :: Int -> ReadS CreateAlertResponse
Prelude.Read, Int -> CreateAlertResponse -> ShowS
[CreateAlertResponse] -> ShowS
CreateAlertResponse -> String
(Int -> CreateAlertResponse -> ShowS)
-> (CreateAlertResponse -> String)
-> ([CreateAlertResponse] -> ShowS)
-> Show CreateAlertResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAlertResponse] -> ShowS
$cshowList :: [CreateAlertResponse] -> ShowS
show :: CreateAlertResponse -> String
$cshow :: CreateAlertResponse -> String
showsPrec :: Int -> CreateAlertResponse -> ShowS
$cshowsPrec :: Int -> CreateAlertResponse -> ShowS
Prelude.Show, (forall x. CreateAlertResponse -> Rep CreateAlertResponse x)
-> (forall x. Rep CreateAlertResponse x -> CreateAlertResponse)
-> Generic CreateAlertResponse
forall x. Rep CreateAlertResponse x -> CreateAlertResponse
forall x. CreateAlertResponse -> Rep CreateAlertResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateAlertResponse x -> CreateAlertResponse
$cfrom :: forall x. CreateAlertResponse -> Rep CreateAlertResponse x
Prelude.Generic)
newCreateAlertResponse ::
Prelude.Int ->
CreateAlertResponse
newCreateAlertResponse :: Int -> CreateAlertResponse
newCreateAlertResponse Int
pHttpStatus_ =
CreateAlertResponse' :: Maybe Text -> Int -> CreateAlertResponse
CreateAlertResponse'
{ $sel:alertArn:CreateAlertResponse' :: Maybe Text
alertArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateAlertResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createAlertResponse_alertArn :: Lens.Lens' CreateAlertResponse (Prelude.Maybe Prelude.Text)
createAlertResponse_alertArn :: (Maybe Text -> f (Maybe Text))
-> CreateAlertResponse -> f CreateAlertResponse
createAlertResponse_alertArn = (CreateAlertResponse -> Maybe Text)
-> (CreateAlertResponse -> Maybe Text -> CreateAlertResponse)
-> Lens
CreateAlertResponse CreateAlertResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAlertResponse' {Maybe Text
alertArn :: Maybe Text
$sel:alertArn:CreateAlertResponse' :: CreateAlertResponse -> Maybe Text
alertArn} -> Maybe Text
alertArn) (\s :: CreateAlertResponse
s@CreateAlertResponse' {} Maybe Text
a -> CreateAlertResponse
s {$sel:alertArn:CreateAlertResponse' :: Maybe Text
alertArn = Maybe Text
a} :: CreateAlertResponse)
createAlertResponse_httpStatus :: Lens.Lens' CreateAlertResponse Prelude.Int
createAlertResponse_httpStatus :: (Int -> f Int) -> CreateAlertResponse -> f CreateAlertResponse
createAlertResponse_httpStatus = (CreateAlertResponse -> Int)
-> (CreateAlertResponse -> Int -> CreateAlertResponse)
-> Lens CreateAlertResponse CreateAlertResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAlertResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateAlertResponse' :: CreateAlertResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateAlertResponse
s@CreateAlertResponse' {} Int
a -> CreateAlertResponse
s {$sel:httpStatus:CreateAlertResponse' :: Int
httpStatus = Int
a} :: CreateAlertResponse)
instance Prelude.NFData CreateAlertResponse