{-# 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.DevOpsGuru.DescribeInsight
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns details about an insight that you specify using its ID.
module Amazonka.DevOpsGuru.DescribeInsight
  ( -- * Creating a Request
    DescribeInsight (..),
    newDescribeInsight,

    -- * Request Lenses
    describeInsight_accountId,
    describeInsight_id,

    -- * Destructuring the Response
    DescribeInsightResponse (..),
    newDescribeInsightResponse,

    -- * Response Lenses
    describeInsightResponse_proactiveInsight,
    describeInsightResponse_reactiveInsight,
    describeInsightResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DevOpsGuru.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDescribeInsight' smart constructor.
data DescribeInsight = DescribeInsight'
  { -- | The ID of the member account in the organization.
    DescribeInsight -> Maybe Text
accountId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the insight.
    DescribeInsight -> Text
id :: Prelude.Text
  }
  deriving (DescribeInsight -> DescribeInsight -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeInsight -> DescribeInsight -> Bool
$c/= :: DescribeInsight -> DescribeInsight -> Bool
== :: DescribeInsight -> DescribeInsight -> Bool
$c== :: DescribeInsight -> DescribeInsight -> Bool
Prelude.Eq, ReadPrec [DescribeInsight]
ReadPrec DescribeInsight
Int -> ReadS DescribeInsight
ReadS [DescribeInsight]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeInsight]
$creadListPrec :: ReadPrec [DescribeInsight]
readPrec :: ReadPrec DescribeInsight
$creadPrec :: ReadPrec DescribeInsight
readList :: ReadS [DescribeInsight]
$creadList :: ReadS [DescribeInsight]
readsPrec :: Int -> ReadS DescribeInsight
$creadsPrec :: Int -> ReadS DescribeInsight
Prelude.Read, Int -> DescribeInsight -> ShowS
[DescribeInsight] -> ShowS
DescribeInsight -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeInsight] -> ShowS
$cshowList :: [DescribeInsight] -> ShowS
show :: DescribeInsight -> String
$cshow :: DescribeInsight -> String
showsPrec :: Int -> DescribeInsight -> ShowS
$cshowsPrec :: Int -> DescribeInsight -> ShowS
Prelude.Show, forall x. Rep DescribeInsight x -> DescribeInsight
forall x. DescribeInsight -> Rep DescribeInsight x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeInsight x -> DescribeInsight
$cfrom :: forall x. DescribeInsight -> Rep DescribeInsight x
Prelude.Generic)

-- |
-- Create a value of 'DescribeInsight' 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:
--
-- 'accountId', 'describeInsight_accountId' - The ID of the member account in the organization.
--
-- 'id', 'describeInsight_id' - The ID of the insight.
newDescribeInsight ::
  -- | 'id'
  Prelude.Text ->
  DescribeInsight
newDescribeInsight :: Text -> DescribeInsight
newDescribeInsight Text
pId_ =
  DescribeInsight'
    { $sel:accountId:DescribeInsight' :: Maybe Text
accountId = forall a. Maybe a
Prelude.Nothing,
      $sel:id:DescribeInsight' :: Text
id = Text
pId_
    }

-- | The ID of the member account in the organization.
describeInsight_accountId :: Lens.Lens' DescribeInsight (Prelude.Maybe Prelude.Text)
describeInsight_accountId :: Lens' DescribeInsight (Maybe Text)
describeInsight_accountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeInsight' {Maybe Text
accountId :: Maybe Text
$sel:accountId:DescribeInsight' :: DescribeInsight -> Maybe Text
accountId} -> Maybe Text
accountId) (\s :: DescribeInsight
s@DescribeInsight' {} Maybe Text
a -> DescribeInsight
s {$sel:accountId:DescribeInsight' :: Maybe Text
accountId = Maybe Text
a} :: DescribeInsight)

-- | The ID of the insight.
describeInsight_id :: Lens.Lens' DescribeInsight Prelude.Text
describeInsight_id :: Lens' DescribeInsight Text
describeInsight_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeInsight' {Text
id :: Text
$sel:id:DescribeInsight' :: DescribeInsight -> Text
id} -> Text
id) (\s :: DescribeInsight
s@DescribeInsight' {} Text
a -> DescribeInsight
s {$sel:id:DescribeInsight' :: Text
id = Text
a} :: DescribeInsight)

instance Core.AWSRequest DescribeInsight where
  type
    AWSResponse DescribeInsight =
      DescribeInsightResponse
  request :: (Service -> Service) -> DescribeInsight -> Request DescribeInsight
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeInsight
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeInsight)))
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 ProactiveInsight
-> Maybe ReactiveInsight -> Int -> DescribeInsightResponse
DescribeInsightResponse'
            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
"ProactiveInsight")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"ReactiveInsight")
            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 DescribeInsight where
  hashWithSalt :: Int -> DescribeInsight -> Int
hashWithSalt Int
_salt DescribeInsight' {Maybe Text
Text
id :: Text
accountId :: Maybe Text
$sel:id:DescribeInsight' :: DescribeInsight -> Text
$sel:accountId:DescribeInsight' :: DescribeInsight -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

instance Prelude.NFData DescribeInsight where
  rnf :: DescribeInsight -> ()
rnf DescribeInsight' {Maybe Text
Text
id :: Text
accountId :: Maybe Text
$sel:id:DescribeInsight' :: DescribeInsight -> Text
$sel:accountId:DescribeInsight' :: DescribeInsight -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accountId seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id

instance Data.ToHeaders DescribeInsight where
  toHeaders :: DescribeInsight -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath DescribeInsight where
  toPath :: DescribeInsight -> ByteString
toPath DescribeInsight' {Maybe Text
Text
id :: Text
accountId :: Maybe Text
$sel:id:DescribeInsight' :: DescribeInsight -> Text
$sel:accountId:DescribeInsight' :: DescribeInsight -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/insights/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
id]

instance Data.ToQuery DescribeInsight where
  toQuery :: DescribeInsight -> QueryString
toQuery DescribeInsight' {Maybe Text
Text
id :: Text
accountId :: Maybe Text
$sel:id:DescribeInsight' :: DescribeInsight -> Text
$sel:accountId:DescribeInsight' :: DescribeInsight -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"AccountId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
accountId]

-- | /See:/ 'newDescribeInsightResponse' smart constructor.
data DescribeInsightResponse = DescribeInsightResponse'
  { -- | A @ProactiveInsight@ object that represents the requested insight.
    DescribeInsightResponse -> Maybe ProactiveInsight
proactiveInsight :: Prelude.Maybe ProactiveInsight,
    -- | A @ReactiveInsight@ object that represents the requested insight.
    DescribeInsightResponse -> Maybe ReactiveInsight
reactiveInsight :: Prelude.Maybe ReactiveInsight,
    -- | The response's http status code.
    DescribeInsightResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeInsightResponse -> DescribeInsightResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeInsightResponse -> DescribeInsightResponse -> Bool
$c/= :: DescribeInsightResponse -> DescribeInsightResponse -> Bool
== :: DescribeInsightResponse -> DescribeInsightResponse -> Bool
$c== :: DescribeInsightResponse -> DescribeInsightResponse -> Bool
Prelude.Eq, ReadPrec [DescribeInsightResponse]
ReadPrec DescribeInsightResponse
Int -> ReadS DescribeInsightResponse
ReadS [DescribeInsightResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeInsightResponse]
$creadListPrec :: ReadPrec [DescribeInsightResponse]
readPrec :: ReadPrec DescribeInsightResponse
$creadPrec :: ReadPrec DescribeInsightResponse
readList :: ReadS [DescribeInsightResponse]
$creadList :: ReadS [DescribeInsightResponse]
readsPrec :: Int -> ReadS DescribeInsightResponse
$creadsPrec :: Int -> ReadS DescribeInsightResponse
Prelude.Read, Int -> DescribeInsightResponse -> ShowS
[DescribeInsightResponse] -> ShowS
DescribeInsightResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeInsightResponse] -> ShowS
$cshowList :: [DescribeInsightResponse] -> ShowS
show :: DescribeInsightResponse -> String
$cshow :: DescribeInsightResponse -> String
showsPrec :: Int -> DescribeInsightResponse -> ShowS
$cshowsPrec :: Int -> DescribeInsightResponse -> ShowS
Prelude.Show, forall x. Rep DescribeInsightResponse x -> DescribeInsightResponse
forall x. DescribeInsightResponse -> Rep DescribeInsightResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeInsightResponse x -> DescribeInsightResponse
$cfrom :: forall x. DescribeInsightResponse -> Rep DescribeInsightResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeInsightResponse' 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:
--
-- 'proactiveInsight', 'describeInsightResponse_proactiveInsight' - A @ProactiveInsight@ object that represents the requested insight.
--
-- 'reactiveInsight', 'describeInsightResponse_reactiveInsight' - A @ReactiveInsight@ object that represents the requested insight.
--
-- 'httpStatus', 'describeInsightResponse_httpStatus' - The response's http status code.
newDescribeInsightResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeInsightResponse
newDescribeInsightResponse :: Int -> DescribeInsightResponse
newDescribeInsightResponse Int
pHttpStatus_ =
  DescribeInsightResponse'
    { $sel:proactiveInsight:DescribeInsightResponse' :: Maybe ProactiveInsight
proactiveInsight =
        forall a. Maybe a
Prelude.Nothing,
      $sel:reactiveInsight:DescribeInsightResponse' :: Maybe ReactiveInsight
reactiveInsight = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeInsightResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A @ProactiveInsight@ object that represents the requested insight.
describeInsightResponse_proactiveInsight :: Lens.Lens' DescribeInsightResponse (Prelude.Maybe ProactiveInsight)
describeInsightResponse_proactiveInsight :: Lens' DescribeInsightResponse (Maybe ProactiveInsight)
describeInsightResponse_proactiveInsight = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeInsightResponse' {Maybe ProactiveInsight
proactiveInsight :: Maybe ProactiveInsight
$sel:proactiveInsight:DescribeInsightResponse' :: DescribeInsightResponse -> Maybe ProactiveInsight
proactiveInsight} -> Maybe ProactiveInsight
proactiveInsight) (\s :: DescribeInsightResponse
s@DescribeInsightResponse' {} Maybe ProactiveInsight
a -> DescribeInsightResponse
s {$sel:proactiveInsight:DescribeInsightResponse' :: Maybe ProactiveInsight
proactiveInsight = Maybe ProactiveInsight
a} :: DescribeInsightResponse)

-- | A @ReactiveInsight@ object that represents the requested insight.
describeInsightResponse_reactiveInsight :: Lens.Lens' DescribeInsightResponse (Prelude.Maybe ReactiveInsight)
describeInsightResponse_reactiveInsight :: Lens' DescribeInsightResponse (Maybe ReactiveInsight)
describeInsightResponse_reactiveInsight = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeInsightResponse' {Maybe ReactiveInsight
reactiveInsight :: Maybe ReactiveInsight
$sel:reactiveInsight:DescribeInsightResponse' :: DescribeInsightResponse -> Maybe ReactiveInsight
reactiveInsight} -> Maybe ReactiveInsight
reactiveInsight) (\s :: DescribeInsightResponse
s@DescribeInsightResponse' {} Maybe ReactiveInsight
a -> DescribeInsightResponse
s {$sel:reactiveInsight:DescribeInsightResponse' :: Maybe ReactiveInsight
reactiveInsight = Maybe ReactiveInsight
a} :: DescribeInsightResponse)

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

instance Prelude.NFData DescribeInsightResponse where
  rnf :: DescribeInsightResponse -> ()
rnf DescribeInsightResponse' {Int
Maybe ReactiveInsight
Maybe ProactiveInsight
httpStatus :: Int
reactiveInsight :: Maybe ReactiveInsight
proactiveInsight :: Maybe ProactiveInsight
$sel:httpStatus:DescribeInsightResponse' :: DescribeInsightResponse -> Int
$sel:reactiveInsight:DescribeInsightResponse' :: DescribeInsightResponse -> Maybe ReactiveInsight
$sel:proactiveInsight:DescribeInsightResponse' :: DescribeInsightResponse -> Maybe ProactiveInsight
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ProactiveInsight
proactiveInsight
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ReactiveInsight
reactiveInsight
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus