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

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

instance Prelude.NFData DescribeProblemObservations

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

instance Core.ToQuery DescribeProblemObservations where
  toQuery :: DescribeProblemObservations -> QueryString
toQuery = QueryString -> DescribeProblemObservations -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DescribeProblemObservationsResponse
 -> DescribeProblemObservationsResponse -> Bool)
-> (DescribeProblemObservationsResponse
    -> DescribeProblemObservationsResponse -> Bool)
-> Eq DescribeProblemObservationsResponse
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]
(Int -> ReadS DescribeProblemObservationsResponse)
-> ReadS [DescribeProblemObservationsResponse]
-> ReadPrec DescribeProblemObservationsResponse
-> ReadPrec [DescribeProblemObservationsResponse]
-> Read 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
(Int -> DescribeProblemObservationsResponse -> ShowS)
-> (DescribeProblemObservationsResponse -> String)
-> ([DescribeProblemObservationsResponse] -> ShowS)
-> Show DescribeProblemObservationsResponse
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.
 DescribeProblemObservationsResponse
 -> Rep DescribeProblemObservationsResponse x)
-> (forall x.
    Rep DescribeProblemObservationsResponse x
    -> DescribeProblemObservationsResponse)
-> Generic DescribeProblemObservationsResponse
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' :: Maybe RelatedObservations
-> Int -> DescribeProblemObservationsResponse
DescribeProblemObservationsResponse'
    { $sel:relatedObservations:DescribeProblemObservationsResponse' :: Maybe RelatedObservations
relatedObservations =
        Maybe 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 :: (Maybe RelatedObservations -> f (Maybe RelatedObservations))
-> DescribeProblemObservationsResponse
-> f DescribeProblemObservationsResponse
describeProblemObservationsResponse_relatedObservations = (DescribeProblemObservationsResponse -> Maybe RelatedObservations)
-> (DescribeProblemObservationsResponse
    -> Maybe RelatedObservations
    -> DescribeProblemObservationsResponse)
-> Lens
     DescribeProblemObservationsResponse
     DescribeProblemObservationsResponse
     (Maybe RelatedObservations)
     (Maybe 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 :: (Int -> f Int)
-> DescribeProblemObservationsResponse
-> f DescribeProblemObservationsResponse
describeProblemObservationsResponse_httpStatus = (DescribeProblemObservationsResponse -> Int)
-> (DescribeProblemObservationsResponse
    -> Int -> DescribeProblemObservationsResponse)
-> Lens
     DescribeProblemObservationsResponse
     DescribeProblemObservationsResponse
     Int
     Int
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