{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.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:/ 'newDescribeObservation' smart constructor.
data DescribeObservation = DescribeObservation'
  { -- | The ID of the observation.
    DescribeObservation -> Text
observationId :: Prelude.Text
  }
  deriving (DescribeObservation -> DescribeObservation -> Bool
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]
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
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. 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'
    { $sel:observationId:DescribeObservation' :: Text
observationId =
        Text
pObservationId_
    }

-- | The ID of the observation.
describeObservation_observationId :: Lens.Lens' DescribeObservation Prelude.Text
describeObservation_observationId :: Lens' DescribeObservation Text
describeObservation_observationId = 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 :: (Service -> Service)
-> DescribeObservation -> Request DescribeObservation
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 DescribeObservation
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeObservation)))
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 Observation -> Int -> DescribeObservationResponse
DescribeObservationResponse'
            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
"Observation")
            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 DescribeObservation where
  hashWithSalt :: Int -> DescribeObservation -> Int
hashWithSalt Int
_salt DescribeObservation' {Text
observationId :: Text
$sel:observationId:DescribeObservation' :: DescribeObservation -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
observationId

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

instance Data.ToHeaders DescribeObservation where
  toHeaders :: DescribeObservation -> 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.DescribeObservation" ::
                          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 DescribeObservation where
  toJSON :: DescribeObservation -> Value
toJSON DescribeObservation' {Text
observationId :: Text
$sel:observationId:DescribeObservation' :: DescribeObservation -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"ObservationId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
observationId)
          ]
      )

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

instance Data.ToQuery DescribeObservation where
  toQuery :: DescribeObservation -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:observation:DescribeObservationResponse' :: Maybe Observation
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 :: Lens' DescribeObservationResponse (Maybe Observation)
describeObservationResponse_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 :: Lens' DescribeObservationResponse Int
describeObservationResponse_httpStatus = 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 where
  rnf :: DescribeObservationResponse -> ()
rnf DescribeObservationResponse' {Int
Maybe Observation
httpStatus :: Int
observation :: Maybe Observation
$sel:httpStatus:DescribeObservationResponse' :: DescribeObservationResponse -> Int
$sel:observation:DescribeObservationResponse' :: DescribeObservationResponse -> Maybe Observation
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Observation
observation
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus