{-# 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.ApplicationInsights.DescribeProblem
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Describes an application problem.
module Amazonka.ApplicationInsights.DescribeProblem
  ( -- * Creating a Request
    DescribeProblem (..),
    newDescribeProblem,

    -- * Request Lenses
    describeProblem_problemId,

    -- * Destructuring the Response
    DescribeProblemResponse (..),
    newDescribeProblemResponse,

    -- * Response Lenses
    describeProblemResponse_problem,
    describeProblemResponse_httpStatus,
  )
where

import Amazonka.ApplicationInsights.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

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

-- |
-- Create a value of 'DescribeProblem' 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:
--
-- 'problemId', 'describeProblem_problemId' - The ID of the problem.
newDescribeProblem ::
  -- | 'problemId'
  Prelude.Text ->
  DescribeProblem
newDescribeProblem :: Text -> DescribeProblem
newDescribeProblem Text
pProblemId_ =
  DescribeProblem' {$sel:problemId:DescribeProblem' :: Text
problemId = Text
pProblemId_}

-- | The ID of the problem.
describeProblem_problemId :: Lens.Lens' DescribeProblem Prelude.Text
describeProblem_problemId :: Lens' DescribeProblem Text
describeProblem_problemId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeProblem' {Text
problemId :: Text
$sel:problemId:DescribeProblem' :: DescribeProblem -> Text
problemId} -> Text
problemId) (\s :: DescribeProblem
s@DescribeProblem' {} Text
a -> DescribeProblem
s {$sel:problemId:DescribeProblem' :: Text
problemId = Text
a} :: DescribeProblem)

instance Core.AWSRequest DescribeProblem where
  type
    AWSResponse DescribeProblem =
      DescribeProblemResponse
  request :: (Service -> Service) -> DescribeProblem -> Request DescribeProblem
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeProblem
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeProblem)))
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 Problem -> Int -> DescribeProblemResponse
DescribeProblemResponse'
            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
"Problem")
            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 DescribeProblem where
  hashWithSalt :: Int -> DescribeProblem -> Int
hashWithSalt Int
_salt DescribeProblem' {Text
problemId :: Text
$sel:problemId:DescribeProblem' :: DescribeProblem -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
problemId

instance Prelude.NFData DescribeProblem where
  rnf :: DescribeProblem -> ()
rnf DescribeProblem' {Text
problemId :: Text
$sel:problemId:DescribeProblem' :: DescribeProblem -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
problemId

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

instance Data.ToJSON DescribeProblem where
  toJSON :: DescribeProblem -> Value
toJSON DescribeProblem' {Text
problemId :: Text
$sel:problemId:DescribeProblem' :: DescribeProblem -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"ProblemId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
problemId)]
      )

instance Data.ToPath DescribeProblem where
  toPath :: DescribeProblem -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newDescribeProblemResponse' smart constructor.
data DescribeProblemResponse = DescribeProblemResponse'
  { -- | Information about the problem.
    DescribeProblemResponse -> Maybe Problem
problem :: Prelude.Maybe Problem,
    -- | The response's http status code.
    DescribeProblemResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeProblemResponse -> DescribeProblemResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeProblemResponse -> DescribeProblemResponse -> Bool
$c/= :: DescribeProblemResponse -> DescribeProblemResponse -> Bool
== :: DescribeProblemResponse -> DescribeProblemResponse -> Bool
$c== :: DescribeProblemResponse -> DescribeProblemResponse -> Bool
Prelude.Eq, ReadPrec [DescribeProblemResponse]
ReadPrec DescribeProblemResponse
Int -> ReadS DescribeProblemResponse
ReadS [DescribeProblemResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeProblemResponse]
$creadListPrec :: ReadPrec [DescribeProblemResponse]
readPrec :: ReadPrec DescribeProblemResponse
$creadPrec :: ReadPrec DescribeProblemResponse
readList :: ReadS [DescribeProblemResponse]
$creadList :: ReadS [DescribeProblemResponse]
readsPrec :: Int -> ReadS DescribeProblemResponse
$creadsPrec :: Int -> ReadS DescribeProblemResponse
Prelude.Read, Int -> DescribeProblemResponse -> ShowS
[DescribeProblemResponse] -> ShowS
DescribeProblemResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeProblemResponse] -> ShowS
$cshowList :: [DescribeProblemResponse] -> ShowS
show :: DescribeProblemResponse -> String
$cshow :: DescribeProblemResponse -> String
showsPrec :: Int -> DescribeProblemResponse -> ShowS
$cshowsPrec :: Int -> DescribeProblemResponse -> ShowS
Prelude.Show, forall x. Rep DescribeProblemResponse x -> DescribeProblemResponse
forall x. DescribeProblemResponse -> Rep DescribeProblemResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeProblemResponse x -> DescribeProblemResponse
$cfrom :: forall x. DescribeProblemResponse -> Rep DescribeProblemResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeProblemResponse' 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:
--
-- 'problem', 'describeProblemResponse_problem' - Information about the problem.
--
-- 'httpStatus', 'describeProblemResponse_httpStatus' - The response's http status code.
newDescribeProblemResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeProblemResponse
newDescribeProblemResponse :: Int -> DescribeProblemResponse
newDescribeProblemResponse Int
pHttpStatus_ =
  DescribeProblemResponse'
    { $sel:problem:DescribeProblemResponse' :: Maybe Problem
problem = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeProblemResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the problem.
describeProblemResponse_problem :: Lens.Lens' DescribeProblemResponse (Prelude.Maybe Problem)
describeProblemResponse_problem :: Lens' DescribeProblemResponse (Maybe Problem)
describeProblemResponse_problem = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeProblemResponse' {Maybe Problem
problem :: Maybe Problem
$sel:problem:DescribeProblemResponse' :: DescribeProblemResponse -> Maybe Problem
problem} -> Maybe Problem
problem) (\s :: DescribeProblemResponse
s@DescribeProblemResponse' {} Maybe Problem
a -> DescribeProblemResponse
s {$sel:problem:DescribeProblemResponse' :: Maybe Problem
problem = Maybe Problem
a} :: DescribeProblemResponse)

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

instance Prelude.NFData DescribeProblemResponse where
  rnf :: DescribeProblemResponse -> ()
rnf DescribeProblemResponse' {Int
Maybe Problem
httpStatus :: Int
problem :: Maybe Problem
$sel:httpStatus:DescribeProblemResponse' :: DescribeProblemResponse -> Int
$sel:problem:DescribeProblemResponse' :: DescribeProblemResponse -> Maybe Problem
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Problem
problem
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus