{-# 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.DescribeObservation
-- 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 anomaly or error with the application.
module Amazonka.ApplicationInsights.DescribeObservation
  ( -- * Creating a Request
    DescribeObservation (..),
    newDescribeObservation,

    -- * Request Lenses
    describeObservation_observationId,

    -- * Destructuring the Response
    DescribeObservationResponse (..),
    newDescribeObservationResponse,

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

-- |
-- Create a value of 'DescribeObservation' 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:
--
-- 'observationId', 'describeObservation_observationId' - The ID of the observation.
newDescribeObservation ::
  -- | 'observationId'
  Prelude.Text ->
  DescribeObservation
newDescribeObservation :: Text -> DescribeObservation
newDescribeObservation Text
pObservationId_ =
  DescribeObservation' :: Text -> DescribeObservation
DescribeObservation'
    { $sel:observationId:DescribeObservation' :: Text
observationId =
        Text
pObservationId_
    }

-- | The ID of the observation.
describeObservation_observationId :: Lens.Lens' DescribeObservation Prelude.Text
describeObservation_observationId :: (Text -> f Text) -> DescribeObservation -> f DescribeObservation
describeObservation_observationId = (DescribeObservation -> Text)
-> (DescribeObservation -> Text -> DescribeObservation)
-> Lens DescribeObservation DescribeObservation Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeObservation' {Text
observationId :: Text
$sel:observationId:DescribeObservation' :: DescribeObservation -> Text
observationId} -> Text
observationId) (\s :: DescribeObservation
s@DescribeObservation' {} Text
a -> DescribeObservation
s {$sel:observationId:DescribeObservation' :: Text
observationId = Text
a} :: DescribeObservation)

instance Core.AWSRequest DescribeObservation where
  type
    AWSResponse DescribeObservation =
      DescribeObservationResponse
  request :: DescribeObservation -> Request DescribeObservation
request = Service -> DescribeObservation -> Request DescribeObservation
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeObservation
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeObservation)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeObservation))
-> Logger
-> Service
-> Proxy DescribeObservation
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeObservation)))
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 Observation -> Int -> DescribeObservationResponse
DescribeObservationResponse'
            (Maybe Observation -> Int -> DescribeObservationResponse)
-> Either String (Maybe Observation)
-> Either String (Int -> DescribeObservationResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Observation)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Observation")
            Either String (Int -> DescribeObservationResponse)
-> Either String Int -> Either String DescribeObservationResponse
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 DescribeObservation

instance Prelude.NFData DescribeObservation

instance Core.ToHeaders DescribeObservation where
  toHeaders :: DescribeObservation -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeObservation -> 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.DescribeObservation" ::
                          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 DescribeObservation where
  toJSON :: DescribeObservation -> Value
toJSON DescribeObservation' {Text
observationId :: Text
$sel:observationId:DescribeObservation' :: DescribeObservation -> 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
"ObservationId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
observationId)
          ]
      )

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

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

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

-- |
-- Create a value of 'DescribeObservationResponse' 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:
--
-- 'observation', 'describeObservationResponse_observation' - Information about the observation.
--
-- 'httpStatus', 'describeObservationResponse_httpStatus' - The response's http status code.
newDescribeObservationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeObservationResponse
newDescribeObservationResponse :: Int -> DescribeObservationResponse
newDescribeObservationResponse Int
pHttpStatus_ =
  DescribeObservationResponse' :: Maybe Observation -> Int -> DescribeObservationResponse
DescribeObservationResponse'
    { $sel:observation:DescribeObservationResponse' :: Maybe Observation
observation =
        Maybe Observation
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeObservationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the observation.
describeObservationResponse_observation :: Lens.Lens' DescribeObservationResponse (Prelude.Maybe Observation)
describeObservationResponse_observation :: (Maybe Observation -> f (Maybe Observation))
-> DescribeObservationResponse -> f DescribeObservationResponse
describeObservationResponse_observation = (DescribeObservationResponse -> Maybe Observation)
-> (DescribeObservationResponse
    -> Maybe Observation -> DescribeObservationResponse)
-> Lens
     DescribeObservationResponse
     DescribeObservationResponse
     (Maybe Observation)
     (Maybe Observation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeObservationResponse' {Maybe Observation
observation :: Maybe Observation
$sel:observation:DescribeObservationResponse' :: DescribeObservationResponse -> Maybe Observation
observation} -> Maybe Observation
observation) (\s :: DescribeObservationResponse
s@DescribeObservationResponse' {} Maybe Observation
a -> DescribeObservationResponse
s {$sel:observation:DescribeObservationResponse' :: Maybe Observation
observation = Maybe Observation
a} :: DescribeObservationResponse)

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

instance Prelude.NFData DescribeObservationResponse