{-# 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.NetworkManager.GetRouteAnalysis
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets information about the specified route analysis.
module Amazonka.NetworkManager.GetRouteAnalysis
  ( -- * Creating a Request
    GetRouteAnalysis (..),
    newGetRouteAnalysis,

    -- * Request Lenses
    getRouteAnalysis_globalNetworkId,
    getRouteAnalysis_routeAnalysisId,

    -- * Destructuring the Response
    GetRouteAnalysisResponse (..),
    newGetRouteAnalysisResponse,

    -- * Response Lenses
    getRouteAnalysisResponse_routeAnalysis,
    getRouteAnalysisResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetRouteAnalysis' smart constructor.
data GetRouteAnalysis = GetRouteAnalysis'
  { -- | The ID of the global network.
    GetRouteAnalysis -> Text
globalNetworkId :: Prelude.Text,
    -- | The ID of the route analysis.
    GetRouteAnalysis -> Text
routeAnalysisId :: Prelude.Text
  }
  deriving (GetRouteAnalysis -> GetRouteAnalysis -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRouteAnalysis -> GetRouteAnalysis -> Bool
$c/= :: GetRouteAnalysis -> GetRouteAnalysis -> Bool
== :: GetRouteAnalysis -> GetRouteAnalysis -> Bool
$c== :: GetRouteAnalysis -> GetRouteAnalysis -> Bool
Prelude.Eq, ReadPrec [GetRouteAnalysis]
ReadPrec GetRouteAnalysis
Int -> ReadS GetRouteAnalysis
ReadS [GetRouteAnalysis]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRouteAnalysis]
$creadListPrec :: ReadPrec [GetRouteAnalysis]
readPrec :: ReadPrec GetRouteAnalysis
$creadPrec :: ReadPrec GetRouteAnalysis
readList :: ReadS [GetRouteAnalysis]
$creadList :: ReadS [GetRouteAnalysis]
readsPrec :: Int -> ReadS GetRouteAnalysis
$creadsPrec :: Int -> ReadS GetRouteAnalysis
Prelude.Read, Int -> GetRouteAnalysis -> ShowS
[GetRouteAnalysis] -> ShowS
GetRouteAnalysis -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRouteAnalysis] -> ShowS
$cshowList :: [GetRouteAnalysis] -> ShowS
show :: GetRouteAnalysis -> String
$cshow :: GetRouteAnalysis -> String
showsPrec :: Int -> GetRouteAnalysis -> ShowS
$cshowsPrec :: Int -> GetRouteAnalysis -> ShowS
Prelude.Show, forall x. Rep GetRouteAnalysis x -> GetRouteAnalysis
forall x. GetRouteAnalysis -> Rep GetRouteAnalysis x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRouteAnalysis x -> GetRouteAnalysis
$cfrom :: forall x. GetRouteAnalysis -> Rep GetRouteAnalysis x
Prelude.Generic)

-- |
-- Create a value of 'GetRouteAnalysis' 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:
--
-- 'globalNetworkId', 'getRouteAnalysis_globalNetworkId' - The ID of the global network.
--
-- 'routeAnalysisId', 'getRouteAnalysis_routeAnalysisId' - The ID of the route analysis.
newGetRouteAnalysis ::
  -- | 'globalNetworkId'
  Prelude.Text ->
  -- | 'routeAnalysisId'
  Prelude.Text ->
  GetRouteAnalysis
newGetRouteAnalysis :: Text -> Text -> GetRouteAnalysis
newGetRouteAnalysis
  Text
pGlobalNetworkId_
  Text
pRouteAnalysisId_ =
    GetRouteAnalysis'
      { $sel:globalNetworkId:GetRouteAnalysis' :: Text
globalNetworkId =
          Text
pGlobalNetworkId_,
        $sel:routeAnalysisId:GetRouteAnalysis' :: Text
routeAnalysisId = Text
pRouteAnalysisId_
      }

-- | The ID of the global network.
getRouteAnalysis_globalNetworkId :: Lens.Lens' GetRouteAnalysis Prelude.Text
getRouteAnalysis_globalNetworkId :: Lens' GetRouteAnalysis Text
getRouteAnalysis_globalNetworkId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRouteAnalysis' {Text
globalNetworkId :: Text
$sel:globalNetworkId:GetRouteAnalysis' :: GetRouteAnalysis -> Text
globalNetworkId} -> Text
globalNetworkId) (\s :: GetRouteAnalysis
s@GetRouteAnalysis' {} Text
a -> GetRouteAnalysis
s {$sel:globalNetworkId:GetRouteAnalysis' :: Text
globalNetworkId = Text
a} :: GetRouteAnalysis)

-- | The ID of the route analysis.
getRouteAnalysis_routeAnalysisId :: Lens.Lens' GetRouteAnalysis Prelude.Text
getRouteAnalysis_routeAnalysisId :: Lens' GetRouteAnalysis Text
getRouteAnalysis_routeAnalysisId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRouteAnalysis' {Text
routeAnalysisId :: Text
$sel:routeAnalysisId:GetRouteAnalysis' :: GetRouteAnalysis -> Text
routeAnalysisId} -> Text
routeAnalysisId) (\s :: GetRouteAnalysis
s@GetRouteAnalysis' {} Text
a -> GetRouteAnalysis
s {$sel:routeAnalysisId:GetRouteAnalysis' :: Text
routeAnalysisId = Text
a} :: GetRouteAnalysis)

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

instance Prelude.NFData GetRouteAnalysis where
  rnf :: GetRouteAnalysis -> ()
rnf GetRouteAnalysis' {Text
routeAnalysisId :: Text
globalNetworkId :: Text
$sel:routeAnalysisId:GetRouteAnalysis' :: GetRouteAnalysis -> Text
$sel:globalNetworkId:GetRouteAnalysis' :: GetRouteAnalysis -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
globalNetworkId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
routeAnalysisId

instance Data.ToHeaders GetRouteAnalysis where
  toHeaders :: GetRouteAnalysis -> 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 GetRouteAnalysis where
  toPath :: GetRouteAnalysis -> ByteString
toPath GetRouteAnalysis' {Text
routeAnalysisId :: Text
globalNetworkId :: Text
$sel:routeAnalysisId:GetRouteAnalysis' :: GetRouteAnalysis -> Text
$sel:globalNetworkId:GetRouteAnalysis' :: GetRouteAnalysis -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/global-networks/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
globalNetworkId,
        ByteString
"/route-analyses/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
routeAnalysisId
      ]

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

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

-- |
-- Create a value of 'GetRouteAnalysisResponse' 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:
--
-- 'routeAnalysis', 'getRouteAnalysisResponse_routeAnalysis' - The route analysis.
--
-- 'httpStatus', 'getRouteAnalysisResponse_httpStatus' - The response's http status code.
newGetRouteAnalysisResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetRouteAnalysisResponse
newGetRouteAnalysisResponse :: Int -> GetRouteAnalysisResponse
newGetRouteAnalysisResponse Int
pHttpStatus_ =
  GetRouteAnalysisResponse'
    { $sel:routeAnalysis:GetRouteAnalysisResponse' :: Maybe RouteAnalysis
routeAnalysis =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetRouteAnalysisResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The route analysis.
getRouteAnalysisResponse_routeAnalysis :: Lens.Lens' GetRouteAnalysisResponse (Prelude.Maybe RouteAnalysis)
getRouteAnalysisResponse_routeAnalysis :: Lens' GetRouteAnalysisResponse (Maybe RouteAnalysis)
getRouteAnalysisResponse_routeAnalysis = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRouteAnalysisResponse' {Maybe RouteAnalysis
routeAnalysis :: Maybe RouteAnalysis
$sel:routeAnalysis:GetRouteAnalysisResponse' :: GetRouteAnalysisResponse -> Maybe RouteAnalysis
routeAnalysis} -> Maybe RouteAnalysis
routeAnalysis) (\s :: GetRouteAnalysisResponse
s@GetRouteAnalysisResponse' {} Maybe RouteAnalysis
a -> GetRouteAnalysisResponse
s {$sel:routeAnalysis:GetRouteAnalysisResponse' :: Maybe RouteAnalysis
routeAnalysis = Maybe RouteAnalysis
a} :: GetRouteAnalysisResponse)

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

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