{-# 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.DescribeProblemObservations
-- 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 the anomalies or errors associated with the problem.
module Amazonka.ApplicationInsights.DescribeProblemObservations
  ( -- * Creating a Request
    DescribeProblemObservations (..),
    newDescribeProblemObservations,

    -- * Request Lenses
    describeProblemObservations_problemId,

    -- * Destructuring the Response
    DescribeProblemObservationsResponse (..),
    newDescribeProblemObservationsResponse,

    -- * Response Lenses
    describeProblemObservationsResponse_relatedObservations,
    describeProblemObservationsResponse_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:/ 'newDescribeProblemObservations' smart constructor.
data DescribeProblemObservations = DescribeProblemObservations'
  { -- | The ID of the problem.
    DescribeProblemObservations -> Text
problemId :: Prelude.Text
  }
  deriving (DescribeProblemObservations -> DescribeProblemObservations -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeProblemObservations -> DescribeProblemObservations -> Bool
$c/= :: DescribeProblemObservations -> DescribeProblemObservations -> Bool
== :: DescribeProblemObservations -> DescribeProblemObservations -> Bool
$c== :: DescribeProblemObservations -> DescribeProblemObservations -> Bool
Prelude.Eq, ReadPrec [DescribeProblemObservations]
ReadPrec DescribeProblemObservations
Int -> ReadS DescribeProblemObservations
ReadS [DescribeProblemObservations]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeProblemObservations]
$creadListPrec :: ReadPrec [DescribeProblemObservations]
readPrec :: ReadPrec DescribeProblemObservations
$creadPrec :: ReadPrec DescribeProblemObservations
readList :: ReadS [DescribeProblemObservations]
$creadList :: ReadS [DescribeProblemObservations]
readsPrec :: Int -> ReadS DescribeProblemObservations
$creadsPrec :: Int -> ReadS DescribeProblemObservations
Prelude.Read, Int -> DescribeProblemObservations -> ShowS
[DescribeProblemObservations] -> ShowS
DescribeProblemObservations -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeProblemObservations] -> ShowS
$cshowList :: [DescribeProblemObservations] -> ShowS
show :: DescribeProblemObservations -> String
$cshow :: DescribeProblemObservations -> String
showsPrec :: Int -> DescribeProblemObservations -> ShowS
$cshowsPrec :: Int -> DescribeProblemObservations -> ShowS
Prelude.Show, forall x.
Rep DescribeProblemObservations x -> DescribeProblemObservations
forall x.
DescribeProblemObservations -> Rep DescribeProblemObservations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeProblemObservations x -> DescribeProblemObservations
$cfrom :: forall x.
DescribeProblemObservations -> Rep DescribeProblemObservations x
Prelude.Generic)

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

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

instance Core.AWSRequest DescribeProblemObservations where
  type
    AWSResponse DescribeProblemObservations =
      DescribeProblemObservationsResponse
  request :: (Service -> Service)
-> DescribeProblemObservations
-> Request DescribeProblemObservations
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 DescribeProblemObservations
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeProblemObservations)))
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 RelatedObservations
-> Int -> DescribeProblemObservationsResponse
DescribeProblemObservationsResponse'
            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
"RelatedObservations")
            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 DescribeProblemObservations where
  hashWithSalt :: Int -> DescribeProblemObservations -> Int
hashWithSalt Int
_salt DescribeProblemObservations' {Text
problemId :: Text
$sel:problemId:DescribeProblemObservations' :: DescribeProblemObservations -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
problemId

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

instance Data.ToHeaders DescribeProblemObservations where
  toHeaders :: DescribeProblemObservations -> 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.DescribeProblemObservations" ::
                          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 DescribeProblemObservations where
  toJSON :: DescribeProblemObservations -> Value
toJSON DescribeProblemObservations' {Text
problemId :: Text
$sel:problemId:DescribeProblemObservations' :: DescribeProblemObservations -> 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 DescribeProblemObservations where
  toPath :: DescribeProblemObservations -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'DescribeProblemObservationsResponse' 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:
--
-- 'relatedObservations', 'describeProblemObservationsResponse_relatedObservations' - Observations related to the problem.
--
-- 'httpStatus', 'describeProblemObservationsResponse_httpStatus' - The response's http status code.
newDescribeProblemObservationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeProblemObservationsResponse
newDescribeProblemObservationsResponse :: Int -> DescribeProblemObservationsResponse
newDescribeProblemObservationsResponse Int
pHttpStatus_ =
  DescribeProblemObservationsResponse'
    { $sel:relatedObservations:DescribeProblemObservationsResponse' :: Maybe RelatedObservations
relatedObservations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeProblemObservationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Observations related to the problem.
describeProblemObservationsResponse_relatedObservations :: Lens.Lens' DescribeProblemObservationsResponse (Prelude.Maybe RelatedObservations)
describeProblemObservationsResponse_relatedObservations :: Lens'
  DescribeProblemObservationsResponse (Maybe RelatedObservations)
describeProblemObservationsResponse_relatedObservations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeProblemObservationsResponse' {Maybe RelatedObservations
relatedObservations :: Maybe RelatedObservations
$sel:relatedObservations:DescribeProblemObservationsResponse' :: DescribeProblemObservationsResponse -> Maybe RelatedObservations
relatedObservations} -> Maybe RelatedObservations
relatedObservations) (\s :: DescribeProblemObservationsResponse
s@DescribeProblemObservationsResponse' {} Maybe RelatedObservations
a -> DescribeProblemObservationsResponse
s {$sel:relatedObservations:DescribeProblemObservationsResponse' :: Maybe RelatedObservations
relatedObservations = Maybe RelatedObservations
a} :: DescribeProblemObservationsResponse)

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

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