{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.DevOpsGuru.DescribeAnomaly
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns details about an anomaly that you specify using its ID.
module Amazonka.DevOpsGuru.DescribeAnomaly
  ( -- * Creating a Request
    DescribeAnomaly (..),
    newDescribeAnomaly,

    -- * Request Lenses
    describeAnomaly_id,

    -- * Destructuring the Response
    DescribeAnomalyResponse (..),
    newDescribeAnomalyResponse,

    -- * Response Lenses
    describeAnomalyResponse_reactiveAnomaly,
    describeAnomalyResponse_proactiveAnomaly,
    describeAnomalyResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.DevOpsGuru.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDescribeAnomaly' smart constructor.
data DescribeAnomaly = DescribeAnomaly'
  { -- | The ID of the anomaly.
    DescribeAnomaly -> Text
id :: Prelude.Text
  }
  deriving (DescribeAnomaly -> DescribeAnomaly -> Bool
(DescribeAnomaly -> DescribeAnomaly -> Bool)
-> (DescribeAnomaly -> DescribeAnomaly -> Bool)
-> Eq DescribeAnomaly
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAnomaly -> DescribeAnomaly -> Bool
$c/= :: DescribeAnomaly -> DescribeAnomaly -> Bool
== :: DescribeAnomaly -> DescribeAnomaly -> Bool
$c== :: DescribeAnomaly -> DescribeAnomaly -> Bool
Prelude.Eq, ReadPrec [DescribeAnomaly]
ReadPrec DescribeAnomaly
Int -> ReadS DescribeAnomaly
ReadS [DescribeAnomaly]
(Int -> ReadS DescribeAnomaly)
-> ReadS [DescribeAnomaly]
-> ReadPrec DescribeAnomaly
-> ReadPrec [DescribeAnomaly]
-> Read DescribeAnomaly
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAnomaly]
$creadListPrec :: ReadPrec [DescribeAnomaly]
readPrec :: ReadPrec DescribeAnomaly
$creadPrec :: ReadPrec DescribeAnomaly
readList :: ReadS [DescribeAnomaly]
$creadList :: ReadS [DescribeAnomaly]
readsPrec :: Int -> ReadS DescribeAnomaly
$creadsPrec :: Int -> ReadS DescribeAnomaly
Prelude.Read, Int -> DescribeAnomaly -> ShowS
[DescribeAnomaly] -> ShowS
DescribeAnomaly -> String
(Int -> DescribeAnomaly -> ShowS)
-> (DescribeAnomaly -> String)
-> ([DescribeAnomaly] -> ShowS)
-> Show DescribeAnomaly
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAnomaly] -> ShowS
$cshowList :: [DescribeAnomaly] -> ShowS
show :: DescribeAnomaly -> String
$cshow :: DescribeAnomaly -> String
showsPrec :: Int -> DescribeAnomaly -> ShowS
$cshowsPrec :: Int -> DescribeAnomaly -> ShowS
Prelude.Show, (forall x. DescribeAnomaly -> Rep DescribeAnomaly x)
-> (forall x. Rep DescribeAnomaly x -> DescribeAnomaly)
-> Generic DescribeAnomaly
forall x. Rep DescribeAnomaly x -> DescribeAnomaly
forall x. DescribeAnomaly -> Rep DescribeAnomaly x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeAnomaly x -> DescribeAnomaly
$cfrom :: forall x. DescribeAnomaly -> Rep DescribeAnomaly x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAnomaly' 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:
--
-- 'id', 'describeAnomaly_id' - The ID of the anomaly.
newDescribeAnomaly ::
  -- | 'id'
  Prelude.Text ->
  DescribeAnomaly
newDescribeAnomaly :: Text -> DescribeAnomaly
newDescribeAnomaly Text
pId_ = DescribeAnomaly' :: Text -> DescribeAnomaly
DescribeAnomaly' {$sel:id:DescribeAnomaly' :: Text
id = Text
pId_}

-- | The ID of the anomaly.
describeAnomaly_id :: Lens.Lens' DescribeAnomaly Prelude.Text
describeAnomaly_id :: (Text -> f Text) -> DescribeAnomaly -> f DescribeAnomaly
describeAnomaly_id = (DescribeAnomaly -> Text)
-> (DescribeAnomaly -> Text -> DescribeAnomaly)
-> Lens DescribeAnomaly DescribeAnomaly Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAnomaly' {Text
id :: Text
$sel:id:DescribeAnomaly' :: DescribeAnomaly -> Text
id} -> Text
id) (\s :: DescribeAnomaly
s@DescribeAnomaly' {} Text
a -> DescribeAnomaly
s {$sel:id:DescribeAnomaly' :: Text
id = Text
a} :: DescribeAnomaly)

instance Core.AWSRequest DescribeAnomaly where
  type
    AWSResponse DescribeAnomaly =
      DescribeAnomalyResponse
  request :: DescribeAnomaly -> Request DescribeAnomaly
request = Service -> DescribeAnomaly -> Request DescribeAnomaly
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeAnomaly
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeAnomaly)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeAnomaly))
-> Logger
-> Service
-> Proxy DescribeAnomaly
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeAnomaly)))
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 ReactiveAnomaly
-> Maybe ProactiveAnomaly -> Int -> DescribeAnomalyResponse
DescribeAnomalyResponse'
            (Maybe ReactiveAnomaly
 -> Maybe ProactiveAnomaly -> Int -> DescribeAnomalyResponse)
-> Either String (Maybe ReactiveAnomaly)
-> Either
     String (Maybe ProactiveAnomaly -> Int -> DescribeAnomalyResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ReactiveAnomaly)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ReactiveAnomaly")
            Either
  String (Maybe ProactiveAnomaly -> Int -> DescribeAnomalyResponse)
-> Either String (Maybe ProactiveAnomaly)
-> Either String (Int -> DescribeAnomalyResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe ProactiveAnomaly)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ProactiveAnomaly")
            Either String (Int -> DescribeAnomalyResponse)
-> Either String Int -> Either String DescribeAnomalyResponse
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 DescribeAnomaly

instance Prelude.NFData DescribeAnomaly

instance Core.ToHeaders DescribeAnomaly where
  toHeaders :: DescribeAnomaly -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeAnomaly -> 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.ToPath DescribeAnomaly where
  toPath :: DescribeAnomaly -> ByteString
toPath DescribeAnomaly' {Text
id :: Text
$sel:id:DescribeAnomaly' :: DescribeAnomaly -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/anomalies/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
id]

instance Core.ToQuery DescribeAnomaly where
  toQuery :: DescribeAnomaly -> QueryString
toQuery = QueryString -> DescribeAnomaly -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newDescribeAnomalyResponse' smart constructor.
data DescribeAnomalyResponse = DescribeAnomalyResponse'
  { -- | A @ProactiveAnomaly@ object that represents the requested anomaly.
    DescribeAnomalyResponse -> Maybe ReactiveAnomaly
reactiveAnomaly :: Prelude.Maybe ReactiveAnomaly,
    -- | A @ReactiveAnomaly@ object that represents the requested anomaly.
    DescribeAnomalyResponse -> Maybe ProactiveAnomaly
proactiveAnomaly :: Prelude.Maybe ProactiveAnomaly,
    -- | The response's http status code.
    DescribeAnomalyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeAnomalyResponse -> DescribeAnomalyResponse -> Bool
(DescribeAnomalyResponse -> DescribeAnomalyResponse -> Bool)
-> (DescribeAnomalyResponse -> DescribeAnomalyResponse -> Bool)
-> Eq DescribeAnomalyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeAnomalyResponse -> DescribeAnomalyResponse -> Bool
$c/= :: DescribeAnomalyResponse -> DescribeAnomalyResponse -> Bool
== :: DescribeAnomalyResponse -> DescribeAnomalyResponse -> Bool
$c== :: DescribeAnomalyResponse -> DescribeAnomalyResponse -> Bool
Prelude.Eq, ReadPrec [DescribeAnomalyResponse]
ReadPrec DescribeAnomalyResponse
Int -> ReadS DescribeAnomalyResponse
ReadS [DescribeAnomalyResponse]
(Int -> ReadS DescribeAnomalyResponse)
-> ReadS [DescribeAnomalyResponse]
-> ReadPrec DescribeAnomalyResponse
-> ReadPrec [DescribeAnomalyResponse]
-> Read DescribeAnomalyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeAnomalyResponse]
$creadListPrec :: ReadPrec [DescribeAnomalyResponse]
readPrec :: ReadPrec DescribeAnomalyResponse
$creadPrec :: ReadPrec DescribeAnomalyResponse
readList :: ReadS [DescribeAnomalyResponse]
$creadList :: ReadS [DescribeAnomalyResponse]
readsPrec :: Int -> ReadS DescribeAnomalyResponse
$creadsPrec :: Int -> ReadS DescribeAnomalyResponse
Prelude.Read, Int -> DescribeAnomalyResponse -> ShowS
[DescribeAnomalyResponse] -> ShowS
DescribeAnomalyResponse -> String
(Int -> DescribeAnomalyResponse -> ShowS)
-> (DescribeAnomalyResponse -> String)
-> ([DescribeAnomalyResponse] -> ShowS)
-> Show DescribeAnomalyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeAnomalyResponse] -> ShowS
$cshowList :: [DescribeAnomalyResponse] -> ShowS
show :: DescribeAnomalyResponse -> String
$cshow :: DescribeAnomalyResponse -> String
showsPrec :: Int -> DescribeAnomalyResponse -> ShowS
$cshowsPrec :: Int -> DescribeAnomalyResponse -> ShowS
Prelude.Show, (forall x.
 DescribeAnomalyResponse -> Rep DescribeAnomalyResponse x)
-> (forall x.
    Rep DescribeAnomalyResponse x -> DescribeAnomalyResponse)
-> Generic DescribeAnomalyResponse
forall x. Rep DescribeAnomalyResponse x -> DescribeAnomalyResponse
forall x. DescribeAnomalyResponse -> Rep DescribeAnomalyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeAnomalyResponse x -> DescribeAnomalyResponse
$cfrom :: forall x. DescribeAnomalyResponse -> Rep DescribeAnomalyResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeAnomalyResponse' 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:
--
-- 'reactiveAnomaly', 'describeAnomalyResponse_reactiveAnomaly' - A @ProactiveAnomaly@ object that represents the requested anomaly.
--
-- 'proactiveAnomaly', 'describeAnomalyResponse_proactiveAnomaly' - A @ReactiveAnomaly@ object that represents the requested anomaly.
--
-- 'httpStatus', 'describeAnomalyResponse_httpStatus' - The response's http status code.
newDescribeAnomalyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeAnomalyResponse
newDescribeAnomalyResponse :: Int -> DescribeAnomalyResponse
newDescribeAnomalyResponse Int
pHttpStatus_ =
  DescribeAnomalyResponse' :: Maybe ReactiveAnomaly
-> Maybe ProactiveAnomaly -> Int -> DescribeAnomalyResponse
DescribeAnomalyResponse'
    { $sel:reactiveAnomaly:DescribeAnomalyResponse' :: Maybe ReactiveAnomaly
reactiveAnomaly =
        Maybe ReactiveAnomaly
forall a. Maybe a
Prelude.Nothing,
      $sel:proactiveAnomaly:DescribeAnomalyResponse' :: Maybe ProactiveAnomaly
proactiveAnomaly = Maybe ProactiveAnomaly
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeAnomalyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A @ProactiveAnomaly@ object that represents the requested anomaly.
describeAnomalyResponse_reactiveAnomaly :: Lens.Lens' DescribeAnomalyResponse (Prelude.Maybe ReactiveAnomaly)
describeAnomalyResponse_reactiveAnomaly :: (Maybe ReactiveAnomaly -> f (Maybe ReactiveAnomaly))
-> DescribeAnomalyResponse -> f DescribeAnomalyResponse
describeAnomalyResponse_reactiveAnomaly = (DescribeAnomalyResponse -> Maybe ReactiveAnomaly)
-> (DescribeAnomalyResponse
    -> Maybe ReactiveAnomaly -> DescribeAnomalyResponse)
-> Lens
     DescribeAnomalyResponse
     DescribeAnomalyResponse
     (Maybe ReactiveAnomaly)
     (Maybe ReactiveAnomaly)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAnomalyResponse' {Maybe ReactiveAnomaly
reactiveAnomaly :: Maybe ReactiveAnomaly
$sel:reactiveAnomaly:DescribeAnomalyResponse' :: DescribeAnomalyResponse -> Maybe ReactiveAnomaly
reactiveAnomaly} -> Maybe ReactiveAnomaly
reactiveAnomaly) (\s :: DescribeAnomalyResponse
s@DescribeAnomalyResponse' {} Maybe ReactiveAnomaly
a -> DescribeAnomalyResponse
s {$sel:reactiveAnomaly:DescribeAnomalyResponse' :: Maybe ReactiveAnomaly
reactiveAnomaly = Maybe ReactiveAnomaly
a} :: DescribeAnomalyResponse)

-- | A @ReactiveAnomaly@ object that represents the requested anomaly.
describeAnomalyResponse_proactiveAnomaly :: Lens.Lens' DescribeAnomalyResponse (Prelude.Maybe ProactiveAnomaly)
describeAnomalyResponse_proactiveAnomaly :: (Maybe ProactiveAnomaly -> f (Maybe ProactiveAnomaly))
-> DescribeAnomalyResponse -> f DescribeAnomalyResponse
describeAnomalyResponse_proactiveAnomaly = (DescribeAnomalyResponse -> Maybe ProactiveAnomaly)
-> (DescribeAnomalyResponse
    -> Maybe ProactiveAnomaly -> DescribeAnomalyResponse)
-> Lens
     DescribeAnomalyResponse
     DescribeAnomalyResponse
     (Maybe ProactiveAnomaly)
     (Maybe ProactiveAnomaly)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAnomalyResponse' {Maybe ProactiveAnomaly
proactiveAnomaly :: Maybe ProactiveAnomaly
$sel:proactiveAnomaly:DescribeAnomalyResponse' :: DescribeAnomalyResponse -> Maybe ProactiveAnomaly
proactiveAnomaly} -> Maybe ProactiveAnomaly
proactiveAnomaly) (\s :: DescribeAnomalyResponse
s@DescribeAnomalyResponse' {} Maybe ProactiveAnomaly
a -> DescribeAnomalyResponse
s {$sel:proactiveAnomaly:DescribeAnomalyResponse' :: Maybe ProactiveAnomaly
proactiveAnomaly = Maybe ProactiveAnomaly
a} :: DescribeAnomalyResponse)

-- | The response's http status code.
describeAnomalyResponse_httpStatus :: Lens.Lens' DescribeAnomalyResponse Prelude.Int
describeAnomalyResponse_httpStatus :: (Int -> f Int)
-> DescribeAnomalyResponse -> f DescribeAnomalyResponse
describeAnomalyResponse_httpStatus = (DescribeAnomalyResponse -> Int)
-> (DescribeAnomalyResponse -> Int -> DescribeAnomalyResponse)
-> Lens DescribeAnomalyResponse DescribeAnomalyResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAnomalyResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeAnomalyResponse' :: DescribeAnomalyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeAnomalyResponse
s@DescribeAnomalyResponse' {} Int
a -> DescribeAnomalyResponse
s {$sel:httpStatus:DescribeAnomalyResponse' :: Int
httpStatus = Int
a} :: DescribeAnomalyResponse)

instance Prelude.NFData DescribeAnomalyResponse