{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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_accountId,
    describeAnomaly_id,

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

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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DevOpsGuru.Types
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 member account.
    DescribeAnomaly -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the anomaly.
    DescribeAnomaly -> Text
id :: Prelude.Text
  }
  deriving (DescribeAnomaly -> DescribeAnomaly -> Bool
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]
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
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. 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:
--
-- 'accountId', 'describeAnomaly_accountId' - The ID of the member account.
--
-- 'id', 'describeAnomaly_id' - The ID of the anomaly.
newDescribeAnomaly ::
  -- | 'id'
  Prelude.Text ->
  DescribeAnomaly
newDescribeAnomaly :: Text -> DescribeAnomaly
newDescribeAnomaly Text
pId_ =
  DescribeAnomaly'
    { $sel:accountId:DescribeAnomaly' :: Maybe Text
accountId = forall a. Maybe a
Prelude.Nothing,
      $sel:id:DescribeAnomaly' :: Text
id = Text
pId_
    }

-- | The ID of the member account.
describeAnomaly_accountId :: Lens.Lens' DescribeAnomaly (Prelude.Maybe Prelude.Text)
describeAnomaly_accountId :: Lens' DescribeAnomaly (Maybe Text)
describeAnomaly_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeAnomaly' {Maybe Text
accountId :: Maybe Text
$sel:accountId:DescribeAnomaly' :: DescribeAnomaly -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: DescribeAnomaly
s@DescribeAnomaly' {} Maybe Text
a -> DescribeAnomaly
s {$sel:accountId:DescribeAnomaly' :: Maybe Text
accountId = Maybe Text
a} :: DescribeAnomaly)

-- | The ID of the anomaly.
describeAnomaly_id :: Lens.Lens' DescribeAnomaly Prelude.Text
describeAnomaly_id :: Lens' DescribeAnomaly Text
describeAnomaly_id = 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 :: (Service -> Service) -> DescribeAnomaly -> Request DescribeAnomaly
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeAnomaly
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeAnomaly)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe ProactiveAnomaly
-> Maybe ReactiveAnomaly -> Int -> DescribeAnomalyResponse
DescribeAnomalyResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ProactiveAnomaly")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ReactiveAnomaly")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DescribeAnomaly where
  hashWithSalt :: Int -> DescribeAnomaly -> Int
hashWithSalt Int
_salt DescribeAnomaly' {Maybe Text
Text
id :: Text
accountId :: Maybe Text
$sel:id:DescribeAnomaly' :: DescribeAnomaly -> Text
$sel:accountId:DescribeAnomaly' :: DescribeAnomaly -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

instance Prelude.NFData DescribeAnomaly where
  rnf :: DescribeAnomaly -> ()
rnf DescribeAnomaly' {Maybe Text
Text
id :: Text
accountId :: Maybe Text
$sel:id:DescribeAnomaly' :: DescribeAnomaly -> Text
$sel:accountId:DescribeAnomaly' :: DescribeAnomaly -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accountId seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id

instance Data.ToHeaders DescribeAnomaly where
  toHeaders :: DescribeAnomaly -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath DescribeAnomaly where
  toPath :: DescribeAnomaly -> ByteString
toPath DescribeAnomaly' {Maybe Text
Text
id :: Text
accountId :: Maybe Text
$sel:id:DescribeAnomaly' :: DescribeAnomaly -> Text
$sel:accountId:DescribeAnomaly' :: DescribeAnomaly -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/anomalies/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
id]

instance Data.ToQuery DescribeAnomaly where
  toQuery :: DescribeAnomaly -> QueryString
toQuery DescribeAnomaly' {Maybe Text
Text
id :: Text
accountId :: Maybe Text
$sel:id:DescribeAnomaly' :: DescribeAnomaly -> Text
$sel:accountId:DescribeAnomaly' :: DescribeAnomaly -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"AccountId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
accountId]

-- | /See:/ 'newDescribeAnomalyResponse' smart constructor.
data DescribeAnomalyResponse = DescribeAnomalyResponse'
  { -- | A @ProactiveAnomaly@ object that represents the requested anomaly.
    DescribeAnomalyResponse -> Maybe ProactiveAnomaly
proactiveAnomaly :: Prelude.Maybe ProactiveAnomaly,
    -- | A @ReactiveAnomaly@ object that represents the requested anomaly.
    DescribeAnomalyResponse -> Maybe ReactiveAnomaly
reactiveAnomaly :: Prelude.Maybe ReactiveAnomaly,
    -- | The response's http status code.
    DescribeAnomalyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeAnomalyResponse -> DescribeAnomalyResponse -> Bool
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]
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
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. 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:
--
-- 'proactiveAnomaly', 'describeAnomalyResponse_proactiveAnomaly' - A @ProactiveAnomaly@ object that represents the requested anomaly.
--
-- 'reactiveAnomaly', 'describeAnomalyResponse_reactiveAnomaly' - 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'
    { $sel:proactiveAnomaly:DescribeAnomalyResponse' :: Maybe ProactiveAnomaly
proactiveAnomaly =
        forall a. Maybe a
Prelude.Nothing,
      $sel:reactiveAnomaly:DescribeAnomalyResponse' :: Maybe ReactiveAnomaly
reactiveAnomaly = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeAnomalyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A @ProactiveAnomaly@ object that represents the requested anomaly.
describeAnomalyResponse_proactiveAnomaly :: Lens.Lens' DescribeAnomalyResponse (Prelude.Maybe ProactiveAnomaly)
describeAnomalyResponse_proactiveAnomaly :: Lens' DescribeAnomalyResponse (Maybe ProactiveAnomaly)
describeAnomalyResponse_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)

-- | A @ReactiveAnomaly@ object that represents the requested anomaly.
describeAnomalyResponse_reactiveAnomaly :: Lens.Lens' DescribeAnomalyResponse (Prelude.Maybe ReactiveAnomaly)
describeAnomalyResponse_reactiveAnomaly :: Lens' DescribeAnomalyResponse (Maybe ReactiveAnomaly)
describeAnomalyResponse_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)

-- | The response's http status code.
describeAnomalyResponse_httpStatus :: Lens.Lens' DescribeAnomalyResponse Prelude.Int
describeAnomalyResponse_httpStatus :: Lens' DescribeAnomalyResponse Int
describeAnomalyResponse_httpStatus = 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 where
  rnf :: DescribeAnomalyResponse -> ()
rnf DescribeAnomalyResponse' {Int
Maybe ReactiveAnomaly
Maybe ProactiveAnomaly
httpStatus :: Int
reactiveAnomaly :: Maybe ReactiveAnomaly
proactiveAnomaly :: Maybe ProactiveAnomaly
$sel:httpStatus:DescribeAnomalyResponse' :: DescribeAnomalyResponse -> Int
$sel:reactiveAnomaly:DescribeAnomalyResponse' :: DescribeAnomalyResponse -> Maybe ReactiveAnomaly
$sel:proactiveAnomaly:DescribeAnomalyResponse' :: DescribeAnomalyResponse -> Maybe ProactiveAnomaly
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ProactiveAnomaly
proactiveAnomaly
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ReactiveAnomaly
reactiveAnomaly
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus