{-# 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.DescribeAlert
(
DescribeAlert (..),
newDescribeAlert,
describeAlert_alertArn,
DescribeAlertResponse (..),
newDescribeAlertResponse,
describeAlertResponse_alert,
describeAlertResponse_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 DescribeAlert = DescribeAlert'
{
DescribeAlert -> Text
alertArn :: Prelude.Text
}
deriving (DescribeAlert -> DescribeAlert -> Bool
(DescribeAlert -> DescribeAlert -> Bool)
-> (DescribeAlert -> DescribeAlert -> Bool) -> Eq DescribeAlert
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAlert -> DescribeAlert -> Bool
$c/= :: DescribeAlert -> DescribeAlert -> Bool
== :: DescribeAlert -> DescribeAlert -> Bool
$c== :: DescribeAlert -> DescribeAlert -> Bool
Prelude.Eq, ReadPrec [DescribeAlert]
ReadPrec DescribeAlert
Int -> ReadS DescribeAlert
ReadS [DescribeAlert]
(Int -> ReadS DescribeAlert)
-> ReadS [DescribeAlert]
-> ReadPrec DescribeAlert
-> ReadPrec [DescribeAlert]
-> Read DescribeAlert
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAlert]
$creadListPrec :: ReadPrec [DescribeAlert]
readPrec :: ReadPrec DescribeAlert
$creadPrec :: ReadPrec DescribeAlert
readList :: ReadS [DescribeAlert]
$creadList :: ReadS [DescribeAlert]
readsPrec :: Int -> ReadS DescribeAlert
$creadsPrec :: Int -> ReadS DescribeAlert
Prelude.Read, Int -> DescribeAlert -> ShowS
[DescribeAlert] -> ShowS
DescribeAlert -> String
(Int -> DescribeAlert -> ShowS)
-> (DescribeAlert -> String)
-> ([DescribeAlert] -> ShowS)
-> Show DescribeAlert
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAlert] -> ShowS
$cshowList :: [DescribeAlert] -> ShowS
show :: DescribeAlert -> String
$cshow :: DescribeAlert -> String
showsPrec :: Int -> DescribeAlert -> ShowS
$cshowsPrec :: Int -> DescribeAlert -> ShowS
Prelude.Show, (forall x. DescribeAlert -> Rep DescribeAlert x)
-> (forall x. Rep DescribeAlert x -> DescribeAlert)
-> Generic DescribeAlert
forall x. Rep DescribeAlert x -> DescribeAlert
forall x. DescribeAlert -> Rep DescribeAlert x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeAlert x -> DescribeAlert
$cfrom :: forall x. DescribeAlert -> Rep DescribeAlert x
Prelude.Generic)
newDescribeAlert ::
Prelude.Text ->
DescribeAlert
newDescribeAlert :: Text -> DescribeAlert
newDescribeAlert Text
pAlertArn_ =
DescribeAlert' :: Text -> DescribeAlert
DescribeAlert' {$sel:alertArn:DescribeAlert' :: Text
alertArn = Text
pAlertArn_}
describeAlert_alertArn :: Lens.Lens' DescribeAlert Prelude.Text
describeAlert_alertArn :: (Text -> f Text) -> DescribeAlert -> f DescribeAlert
describeAlert_alertArn = (DescribeAlert -> Text)
-> (DescribeAlert -> Text -> DescribeAlert)
-> Lens DescribeAlert DescribeAlert Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlert' {Text
alertArn :: Text
$sel:alertArn:DescribeAlert' :: DescribeAlert -> Text
alertArn} -> Text
alertArn) (\s :: DescribeAlert
s@DescribeAlert' {} Text
a -> DescribeAlert
s {$sel:alertArn:DescribeAlert' :: Text
alertArn = Text
a} :: DescribeAlert)
instance Core.AWSRequest DescribeAlert where
type
AWSResponse DescribeAlert =
DescribeAlertResponse
request :: DescribeAlert -> Request DescribeAlert
request = Service -> DescribeAlert -> Request DescribeAlert
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy DescribeAlert
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeAlert)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse DescribeAlert))
-> Logger
-> Service
-> Proxy DescribeAlert
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeAlert)))
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 Alert -> Int -> DescribeAlertResponse
DescribeAlertResponse'
(Maybe Alert -> Int -> DescribeAlertResponse)
-> Either String (Maybe Alert)
-> Either String (Int -> DescribeAlertResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Alert)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Alert")
Either String (Int -> DescribeAlertResponse)
-> Either String Int -> Either String DescribeAlertResponse
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 DescribeAlert
instance Prelude.NFData DescribeAlert
instance Core.ToHeaders DescribeAlert where
toHeaders :: DescribeAlert -> ResponseHeaders
toHeaders =
ResponseHeaders -> DescribeAlert -> 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 DescribeAlert where
toJSON :: DescribeAlert -> Value
toJSON DescribeAlert' {Text
alertArn :: Text
$sel:alertArn:DescribeAlert' :: DescribeAlert -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"AlertArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
alertArn)]
)
instance Core.ToPath DescribeAlert where
toPath :: DescribeAlert -> ByteString
toPath = ByteString -> DescribeAlert -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/DescribeAlert"
instance Core.ToQuery DescribeAlert where
toQuery :: DescribeAlert -> QueryString
toQuery = QueryString -> DescribeAlert -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data DescribeAlertResponse = DescribeAlertResponse'
{
DescribeAlertResponse -> Maybe Alert
alert :: Prelude.Maybe Alert,
DescribeAlertResponse -> Int
httpStatus :: Prelude.Int
}
deriving (DescribeAlertResponse -> DescribeAlertResponse -> Bool
(DescribeAlertResponse -> DescribeAlertResponse -> Bool)
-> (DescribeAlertResponse -> DescribeAlertResponse -> Bool)
-> Eq DescribeAlertResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAlertResponse -> DescribeAlertResponse -> Bool
$c/= :: DescribeAlertResponse -> DescribeAlertResponse -> Bool
== :: DescribeAlertResponse -> DescribeAlertResponse -> Bool
$c== :: DescribeAlertResponse -> DescribeAlertResponse -> Bool
Prelude.Eq, ReadPrec [DescribeAlertResponse]
ReadPrec DescribeAlertResponse
Int -> ReadS DescribeAlertResponse
ReadS [DescribeAlertResponse]
(Int -> ReadS DescribeAlertResponse)
-> ReadS [DescribeAlertResponse]
-> ReadPrec DescribeAlertResponse
-> ReadPrec [DescribeAlertResponse]
-> Read DescribeAlertResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAlertResponse]
$creadListPrec :: ReadPrec [DescribeAlertResponse]
readPrec :: ReadPrec DescribeAlertResponse
$creadPrec :: ReadPrec DescribeAlertResponse
readList :: ReadS [DescribeAlertResponse]
$creadList :: ReadS [DescribeAlertResponse]
readsPrec :: Int -> ReadS DescribeAlertResponse
$creadsPrec :: Int -> ReadS DescribeAlertResponse
Prelude.Read, Int -> DescribeAlertResponse -> ShowS
[DescribeAlertResponse] -> ShowS
DescribeAlertResponse -> String
(Int -> DescribeAlertResponse -> ShowS)
-> (DescribeAlertResponse -> String)
-> ([DescribeAlertResponse] -> ShowS)
-> Show DescribeAlertResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAlertResponse] -> ShowS
$cshowList :: [DescribeAlertResponse] -> ShowS
show :: DescribeAlertResponse -> String
$cshow :: DescribeAlertResponse -> String
showsPrec :: Int -> DescribeAlertResponse -> ShowS
$cshowsPrec :: Int -> DescribeAlertResponse -> ShowS
Prelude.Show, (forall x. DescribeAlertResponse -> Rep DescribeAlertResponse x)
-> (forall x. Rep DescribeAlertResponse x -> DescribeAlertResponse)
-> Generic DescribeAlertResponse
forall x. Rep DescribeAlertResponse x -> DescribeAlertResponse
forall x. DescribeAlertResponse -> Rep DescribeAlertResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeAlertResponse x -> DescribeAlertResponse
$cfrom :: forall x. DescribeAlertResponse -> Rep DescribeAlertResponse x
Prelude.Generic)
newDescribeAlertResponse ::
Prelude.Int ->
DescribeAlertResponse
newDescribeAlertResponse :: Int -> DescribeAlertResponse
newDescribeAlertResponse Int
pHttpStatus_ =
DescribeAlertResponse' :: Maybe Alert -> Int -> DescribeAlertResponse
DescribeAlertResponse'
{ $sel:alert:DescribeAlertResponse' :: Maybe Alert
alert = Maybe Alert
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:DescribeAlertResponse' :: Int
httpStatus = Int
pHttpStatus_
}
describeAlertResponse_alert :: Lens.Lens' DescribeAlertResponse (Prelude.Maybe Alert)
describeAlertResponse_alert :: (Maybe Alert -> f (Maybe Alert))
-> DescribeAlertResponse -> f DescribeAlertResponse
describeAlertResponse_alert = (DescribeAlertResponse -> Maybe Alert)
-> (DescribeAlertResponse -> Maybe Alert -> DescribeAlertResponse)
-> Lens
DescribeAlertResponse
DescribeAlertResponse
(Maybe Alert)
(Maybe Alert)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlertResponse' {Maybe Alert
alert :: Maybe Alert
$sel:alert:DescribeAlertResponse' :: DescribeAlertResponse -> Maybe Alert
alert} -> Maybe Alert
alert) (\s :: DescribeAlertResponse
s@DescribeAlertResponse' {} Maybe Alert
a -> DescribeAlertResponse
s {$sel:alert:DescribeAlertResponse' :: Maybe Alert
alert = Maybe Alert
a} :: DescribeAlertResponse)
describeAlertResponse_httpStatus :: Lens.Lens' DescribeAlertResponse Prelude.Int
describeAlertResponse_httpStatus :: (Int -> f Int) -> DescribeAlertResponse -> f DescribeAlertResponse
describeAlertResponse_httpStatus = (DescribeAlertResponse -> Int)
-> (DescribeAlertResponse -> Int -> DescribeAlertResponse)
-> Lens DescribeAlertResponse DescribeAlertResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAlertResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeAlertResponse' :: DescribeAlertResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeAlertResponse
s@DescribeAlertResponse' {} Int
a -> DescribeAlertResponse
s {$sel:httpStatus:DescribeAlertResponse' :: Int
httpStatus = Int
a} :: DescribeAlertResponse)
instance Prelude.NFData DescribeAlertResponse