{-# 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.AppMesh.DescribeRoute
-- 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 existing route.
module Amazonka.AppMesh.DescribeRoute
  ( -- * Creating a Request
    DescribeRoute (..),
    newDescribeRoute,

    -- * Request Lenses
    describeRoute_meshOwner,
    describeRoute_meshName,
    describeRoute_routeName,
    describeRoute_virtualRouterName,

    -- * Destructuring the Response
    DescribeRouteResponse (..),
    newDescribeRouteResponse,

    -- * Response Lenses
    describeRouteResponse_httpStatus,
    describeRouteResponse_route,
  )
where

import Amazonka.AppMesh.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:/ 'newDescribeRoute' smart constructor.
data DescribeRoute = DescribeRoute'
  { -- | The AWS IAM account ID of the service mesh owner. If the account ID is
    -- not your own, then it\'s the ID of the account that shared the mesh with
    -- your account. For more information about mesh sharing, see
    -- <https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html Working with shared meshes>.
    DescribeRoute -> Maybe Text
meshOwner :: Prelude.Maybe Prelude.Text,
    -- | The name of the service mesh that the route resides in.
    DescribeRoute -> Text
meshName :: Prelude.Text,
    -- | The name of the route to describe.
    DescribeRoute -> Text
routeName :: Prelude.Text,
    -- | The name of the virtual router that the route is associated with.
    DescribeRoute -> Text
virtualRouterName :: Prelude.Text
  }
  deriving (DescribeRoute -> DescribeRoute -> Bool
(DescribeRoute -> DescribeRoute -> Bool)
-> (DescribeRoute -> DescribeRoute -> Bool) -> Eq DescribeRoute
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeRoute -> DescribeRoute -> Bool
$c/= :: DescribeRoute -> DescribeRoute -> Bool
== :: DescribeRoute -> DescribeRoute -> Bool
$c== :: DescribeRoute -> DescribeRoute -> Bool
Prelude.Eq, ReadPrec [DescribeRoute]
ReadPrec DescribeRoute
Int -> ReadS DescribeRoute
ReadS [DescribeRoute]
(Int -> ReadS DescribeRoute)
-> ReadS [DescribeRoute]
-> ReadPrec DescribeRoute
-> ReadPrec [DescribeRoute]
-> Read DescribeRoute
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeRoute]
$creadListPrec :: ReadPrec [DescribeRoute]
readPrec :: ReadPrec DescribeRoute
$creadPrec :: ReadPrec DescribeRoute
readList :: ReadS [DescribeRoute]
$creadList :: ReadS [DescribeRoute]
readsPrec :: Int -> ReadS DescribeRoute
$creadsPrec :: Int -> ReadS DescribeRoute
Prelude.Read, Int -> DescribeRoute -> ShowS
[DescribeRoute] -> ShowS
DescribeRoute -> String
(Int -> DescribeRoute -> ShowS)
-> (DescribeRoute -> String)
-> ([DescribeRoute] -> ShowS)
-> Show DescribeRoute
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeRoute] -> ShowS
$cshowList :: [DescribeRoute] -> ShowS
show :: DescribeRoute -> String
$cshow :: DescribeRoute -> String
showsPrec :: Int -> DescribeRoute -> ShowS
$cshowsPrec :: Int -> DescribeRoute -> ShowS
Prelude.Show, (forall x. DescribeRoute -> Rep DescribeRoute x)
-> (forall x. Rep DescribeRoute x -> DescribeRoute)
-> Generic DescribeRoute
forall x. Rep DescribeRoute x -> DescribeRoute
forall x. DescribeRoute -> Rep DescribeRoute x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeRoute x -> DescribeRoute
$cfrom :: forall x. DescribeRoute -> Rep DescribeRoute x
Prelude.Generic)

-- |
-- Create a value of 'DescribeRoute' 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:
--
-- 'meshOwner', 'describeRoute_meshOwner' - The AWS IAM account ID of the service mesh owner. If the account ID is
-- not your own, then it\'s the ID of the account that shared the mesh with
-- your account. For more information about mesh sharing, see
-- <https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html Working with shared meshes>.
--
-- 'meshName', 'describeRoute_meshName' - The name of the service mesh that the route resides in.
--
-- 'routeName', 'describeRoute_routeName' - The name of the route to describe.
--
-- 'virtualRouterName', 'describeRoute_virtualRouterName' - The name of the virtual router that the route is associated with.
newDescribeRoute ::
  -- | 'meshName'
  Prelude.Text ->
  -- | 'routeName'
  Prelude.Text ->
  -- | 'virtualRouterName'
  Prelude.Text ->
  DescribeRoute
newDescribeRoute :: Text -> Text -> Text -> DescribeRoute
newDescribeRoute
  Text
pMeshName_
  Text
pRouteName_
  Text
pVirtualRouterName_ =
    DescribeRoute' :: Maybe Text -> Text -> Text -> Text -> DescribeRoute
DescribeRoute'
      { $sel:meshOwner:DescribeRoute' :: Maybe Text
meshOwner = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:meshName:DescribeRoute' :: Text
meshName = Text
pMeshName_,
        $sel:routeName:DescribeRoute' :: Text
routeName = Text
pRouteName_,
        $sel:virtualRouterName:DescribeRoute' :: Text
virtualRouterName = Text
pVirtualRouterName_
      }

-- | The AWS IAM account ID of the service mesh owner. If the account ID is
-- not your own, then it\'s the ID of the account that shared the mesh with
-- your account. For more information about mesh sharing, see
-- <https://docs.aws.amazon.com/app-mesh/latest/userguide/sharing.html Working with shared meshes>.
describeRoute_meshOwner :: Lens.Lens' DescribeRoute (Prelude.Maybe Prelude.Text)
describeRoute_meshOwner :: (Maybe Text -> f (Maybe Text)) -> DescribeRoute -> f DescribeRoute
describeRoute_meshOwner = (DescribeRoute -> Maybe Text)
-> (DescribeRoute -> Maybe Text -> DescribeRoute)
-> Lens DescribeRoute DescribeRoute (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRoute' {Maybe Text
meshOwner :: Maybe Text
$sel:meshOwner:DescribeRoute' :: DescribeRoute -> Maybe Text
meshOwner} -> Maybe Text
meshOwner) (\s :: DescribeRoute
s@DescribeRoute' {} Maybe Text
a -> DescribeRoute
s {$sel:meshOwner:DescribeRoute' :: Maybe Text
meshOwner = Maybe Text
a} :: DescribeRoute)

-- | The name of the service mesh that the route resides in.
describeRoute_meshName :: Lens.Lens' DescribeRoute Prelude.Text
describeRoute_meshName :: (Text -> f Text) -> DescribeRoute -> f DescribeRoute
describeRoute_meshName = (DescribeRoute -> Text)
-> (DescribeRoute -> Text -> DescribeRoute)
-> Lens DescribeRoute DescribeRoute Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRoute' {Text
meshName :: Text
$sel:meshName:DescribeRoute' :: DescribeRoute -> Text
meshName} -> Text
meshName) (\s :: DescribeRoute
s@DescribeRoute' {} Text
a -> DescribeRoute
s {$sel:meshName:DescribeRoute' :: Text
meshName = Text
a} :: DescribeRoute)

-- | The name of the route to describe.
describeRoute_routeName :: Lens.Lens' DescribeRoute Prelude.Text
describeRoute_routeName :: (Text -> f Text) -> DescribeRoute -> f DescribeRoute
describeRoute_routeName = (DescribeRoute -> Text)
-> (DescribeRoute -> Text -> DescribeRoute)
-> Lens DescribeRoute DescribeRoute Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRoute' {Text
routeName :: Text
$sel:routeName:DescribeRoute' :: DescribeRoute -> Text
routeName} -> Text
routeName) (\s :: DescribeRoute
s@DescribeRoute' {} Text
a -> DescribeRoute
s {$sel:routeName:DescribeRoute' :: Text
routeName = Text
a} :: DescribeRoute)

-- | The name of the virtual router that the route is associated with.
describeRoute_virtualRouterName :: Lens.Lens' DescribeRoute Prelude.Text
describeRoute_virtualRouterName :: (Text -> f Text) -> DescribeRoute -> f DescribeRoute
describeRoute_virtualRouterName = (DescribeRoute -> Text)
-> (DescribeRoute -> Text -> DescribeRoute)
-> Lens DescribeRoute DescribeRoute Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRoute' {Text
virtualRouterName :: Text
$sel:virtualRouterName:DescribeRoute' :: DescribeRoute -> Text
virtualRouterName} -> Text
virtualRouterName) (\s :: DescribeRoute
s@DescribeRoute' {} Text
a -> DescribeRoute
s {$sel:virtualRouterName:DescribeRoute' :: Text
virtualRouterName = Text
a} :: DescribeRoute)

instance Core.AWSRequest DescribeRoute where
  type
    AWSResponse DescribeRoute =
      DescribeRouteResponse
  request :: DescribeRoute -> Request DescribeRoute
request = Service -> DescribeRoute -> Request DescribeRoute
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeRoute
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeRoute)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeRoute))
-> Logger
-> Service
-> Proxy DescribeRoute
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeRoute)))
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 ->
          Int -> RouteData -> DescribeRouteResponse
DescribeRouteResponse'
            (Int -> RouteData -> DescribeRouteResponse)
-> Either String Int
-> Either String (RouteData -> DescribeRouteResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String (RouteData -> DescribeRouteResponse)
-> Either String RouteData -> Either String DescribeRouteResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String RouteData
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
      )

instance Prelude.Hashable DescribeRoute

instance Prelude.NFData DescribeRoute

instance Core.ToHeaders DescribeRoute where
  toHeaders :: DescribeRoute -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeRoute -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath DescribeRoute where
  toPath :: DescribeRoute -> ByteString
toPath DescribeRoute' {Maybe Text
Text
virtualRouterName :: Text
routeName :: Text
meshName :: Text
meshOwner :: Maybe Text
$sel:virtualRouterName:DescribeRoute' :: DescribeRoute -> Text
$sel:routeName:DescribeRoute' :: DescribeRoute -> Text
$sel:meshName:DescribeRoute' :: DescribeRoute -> Text
$sel:meshOwner:DescribeRoute' :: DescribeRoute -> Maybe Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v20190125/meshes/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
meshName,
        ByteString
"/virtualRouter/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
virtualRouterName,
        ByteString
"/routes/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
routeName
      ]

instance Core.ToQuery DescribeRoute where
  toQuery :: DescribeRoute -> QueryString
toQuery DescribeRoute' {Maybe Text
Text
virtualRouterName :: Text
routeName :: Text
meshName :: Text
meshOwner :: Maybe Text
$sel:virtualRouterName:DescribeRoute' :: DescribeRoute -> Text
$sel:routeName:DescribeRoute' :: DescribeRoute -> Text
$sel:meshName:DescribeRoute' :: DescribeRoute -> Text
$sel:meshOwner:DescribeRoute' :: DescribeRoute -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"meshOwner" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
meshOwner]

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

-- |
-- Create a value of 'DescribeRouteResponse' 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:
--
-- 'httpStatus', 'describeRouteResponse_httpStatus' - The response's http status code.
--
-- 'route', 'describeRouteResponse_route' - The full description of your route.
newDescribeRouteResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'route'
  RouteData ->
  DescribeRouteResponse
newDescribeRouteResponse :: Int -> RouteData -> DescribeRouteResponse
newDescribeRouteResponse Int
pHttpStatus_ RouteData
pRoute_ =
  DescribeRouteResponse' :: Int -> RouteData -> DescribeRouteResponse
DescribeRouteResponse'
    { $sel:httpStatus:DescribeRouteResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:route:DescribeRouteResponse' :: RouteData
route = RouteData
pRoute_
    }

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

-- | The full description of your route.
describeRouteResponse_route :: Lens.Lens' DescribeRouteResponse RouteData
describeRouteResponse_route :: (RouteData -> f RouteData)
-> DescribeRouteResponse -> f DescribeRouteResponse
describeRouteResponse_route = (DescribeRouteResponse -> RouteData)
-> (DescribeRouteResponse -> RouteData -> DescribeRouteResponse)
-> Lens
     DescribeRouteResponse DescribeRouteResponse RouteData RouteData
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeRouteResponse' {RouteData
route :: RouteData
$sel:route:DescribeRouteResponse' :: DescribeRouteResponse -> RouteData
route} -> RouteData
route) (\s :: DescribeRouteResponse
s@DescribeRouteResponse' {} RouteData
a -> DescribeRouteResponse
s {$sel:route:DescribeRouteResponse' :: RouteData
route = RouteData
a} :: DescribeRouteResponse)

instance Prelude.NFData DescribeRouteResponse