{-# 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-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)
--
-- 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.Lens as Lens
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
(DescribeProblem -> DescribeProblem -> Bool)
-> (DescribeProblem -> DescribeProblem -> Bool)
-> Eq DescribeProblem
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]
(Int -> ReadS DescribeProblem)
-> ReadS [DescribeProblem]
-> ReadPrec DescribeProblem
-> ReadPrec [DescribeProblem]
-> Read 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
(Int -> DescribeProblem -> ShowS)
-> (DescribeProblem -> String)
-> ([DescribeProblem] -> ShowS)
-> Show DescribeProblem
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. DescribeProblem -> Rep DescribeProblem x)
-> (forall x. Rep DescribeProblem x -> DescribeProblem)
-> Generic DescribeProblem
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' :: Text -> DescribeProblem
DescribeProblem' {$sel:problemId:DescribeProblem' :: Text
problemId = Text
pProblemId_}

-- | The ID of the problem.
describeProblem_problemId :: Lens.Lens' DescribeProblem Prelude.Text
describeProblem_problemId :: (Text -> f Text) -> DescribeProblem -> f DescribeProblem
describeProblem_problemId = (DescribeProblem -> Text)
-> (DescribeProblem -> Text -> DescribeProblem)
-> Lens DescribeProblem DescribeProblem Text Text
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 :: DescribeProblem -> Request DescribeProblem
request = Service -> DescribeProblem -> Request DescribeProblem
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeProblem
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeProblem)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeProblem))
-> Logger
-> Service
-> Proxy DescribeProblem
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeProblem)))
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 Problem -> Int -> DescribeProblemResponse
DescribeProblemResponse'
            (Maybe Problem -> Int -> DescribeProblemResponse)
-> Either String (Maybe Problem)
-> Either String (Int -> DescribeProblemResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Problem)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Problem")
            Either String (Int -> DescribeProblemResponse)
-> Either String Int -> Either String DescribeProblemResponse
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 DescribeProblem

instance Prelude.NFData DescribeProblem

instance Core.ToHeaders DescribeProblem where
  toHeaders :: DescribeProblem -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeProblem -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"EC2WindowsBarleyService.DescribeProblem" ::
                          Prelude.ByteString
                      ),
            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 DescribeProblem where
  toJSON :: DescribeProblem -> Value
toJSON DescribeProblem' {Text
problemId :: Text
$sel:problemId:DescribeProblem' :: DescribeProblem -> 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
"ProblemId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
problemId)]
      )

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

instance Core.ToQuery DescribeProblem where
  toQuery :: DescribeProblem -> QueryString
toQuery = QueryString -> DescribeProblem -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DescribeProblemResponse -> DescribeProblemResponse -> Bool)
-> (DescribeProblemResponse -> DescribeProblemResponse -> Bool)
-> Eq DescribeProblemResponse
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]
(Int -> ReadS DescribeProblemResponse)
-> ReadS [DescribeProblemResponse]
-> ReadPrec DescribeProblemResponse
-> ReadPrec [DescribeProblemResponse]
-> Read 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
(Int -> DescribeProblemResponse -> ShowS)
-> (DescribeProblemResponse -> String)
-> ([DescribeProblemResponse] -> ShowS)
-> Show DescribeProblemResponse
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.
 DescribeProblemResponse -> Rep DescribeProblemResponse x)
-> (forall x.
    Rep DescribeProblemResponse x -> DescribeProblemResponse)
-> Generic DescribeProblemResponse
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' :: Maybe Problem -> Int -> DescribeProblemResponse
DescribeProblemResponse'
    { $sel:problem:DescribeProblemResponse' :: Maybe Problem
problem = Maybe 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 :: (Maybe Problem -> f (Maybe Problem))
-> DescribeProblemResponse -> f DescribeProblemResponse
describeProblemResponse_problem = (DescribeProblemResponse -> Maybe Problem)
-> (DescribeProblemResponse
    -> Maybe Problem -> DescribeProblemResponse)
-> Lens
     DescribeProblemResponse
     DescribeProblemResponse
     (Maybe Problem)
     (Maybe 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 :: (Int -> f Int)
-> DescribeProblemResponse -> f DescribeProblemResponse
describeProblemResponse_httpStatus = (DescribeProblemResponse -> Int)
-> (DescribeProblemResponse -> Int -> DescribeProblemResponse)
-> Lens DescribeProblemResponse DescribeProblemResponse Int Int
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