{-# 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.DescribeVirtualService
-- 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 virtual service.
module Amazonka.AppMesh.DescribeVirtualService
  ( -- * Creating a Request
    DescribeVirtualService (..),
    newDescribeVirtualService,

    -- * Request Lenses
    describeVirtualService_meshOwner,
    describeVirtualService_meshName,
    describeVirtualService_virtualServiceName,

    -- * Destructuring the Response
    DescribeVirtualServiceResponse (..),
    newDescribeVirtualServiceResponse,

    -- * Response Lenses
    describeVirtualServiceResponse_httpStatus,
    describeVirtualServiceResponse_virtualService,
  )
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:/ 'newDescribeVirtualService' smart constructor.
data DescribeVirtualService = DescribeVirtualService'
  { -- | 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>.
    DescribeVirtualService -> Maybe Text
meshOwner :: Prelude.Maybe Prelude.Text,
    -- | The name of the service mesh that the virtual service resides in.
    DescribeVirtualService -> Text
meshName :: Prelude.Text,
    -- | The name of the virtual service to describe.
    DescribeVirtualService -> Text
virtualServiceName :: Prelude.Text
  }
  deriving (DescribeVirtualService -> DescribeVirtualService -> Bool
(DescribeVirtualService -> DescribeVirtualService -> Bool)
-> (DescribeVirtualService -> DescribeVirtualService -> Bool)
-> Eq DescribeVirtualService
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeVirtualService -> DescribeVirtualService -> Bool
$c/= :: DescribeVirtualService -> DescribeVirtualService -> Bool
== :: DescribeVirtualService -> DescribeVirtualService -> Bool
$c== :: DescribeVirtualService -> DescribeVirtualService -> Bool
Prelude.Eq, ReadPrec [DescribeVirtualService]
ReadPrec DescribeVirtualService
Int -> ReadS DescribeVirtualService
ReadS [DescribeVirtualService]
(Int -> ReadS DescribeVirtualService)
-> ReadS [DescribeVirtualService]
-> ReadPrec DescribeVirtualService
-> ReadPrec [DescribeVirtualService]
-> Read DescribeVirtualService
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeVirtualService]
$creadListPrec :: ReadPrec [DescribeVirtualService]
readPrec :: ReadPrec DescribeVirtualService
$creadPrec :: ReadPrec DescribeVirtualService
readList :: ReadS [DescribeVirtualService]
$creadList :: ReadS [DescribeVirtualService]
readsPrec :: Int -> ReadS DescribeVirtualService
$creadsPrec :: Int -> ReadS DescribeVirtualService
Prelude.Read, Int -> DescribeVirtualService -> ShowS
[DescribeVirtualService] -> ShowS
DescribeVirtualService -> String
(Int -> DescribeVirtualService -> ShowS)
-> (DescribeVirtualService -> String)
-> ([DescribeVirtualService] -> ShowS)
-> Show DescribeVirtualService
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeVirtualService] -> ShowS
$cshowList :: [DescribeVirtualService] -> ShowS
show :: DescribeVirtualService -> String
$cshow :: DescribeVirtualService -> String
showsPrec :: Int -> DescribeVirtualService -> ShowS
$cshowsPrec :: Int -> DescribeVirtualService -> ShowS
Prelude.Show, (forall x. DescribeVirtualService -> Rep DescribeVirtualService x)
-> (forall x.
    Rep DescribeVirtualService x -> DescribeVirtualService)
-> Generic DescribeVirtualService
forall x. Rep DescribeVirtualService x -> DescribeVirtualService
forall x. DescribeVirtualService -> Rep DescribeVirtualService x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeVirtualService x -> DescribeVirtualService
$cfrom :: forall x. DescribeVirtualService -> Rep DescribeVirtualService x
Prelude.Generic)

-- |
-- Create a value of 'DescribeVirtualService' 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', 'describeVirtualService_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', 'describeVirtualService_meshName' - The name of the service mesh that the virtual service resides in.
--
-- 'virtualServiceName', 'describeVirtualService_virtualServiceName' - The name of the virtual service to describe.
newDescribeVirtualService ::
  -- | 'meshName'
  Prelude.Text ->
  -- | 'virtualServiceName'
  Prelude.Text ->
  DescribeVirtualService
newDescribeVirtualService :: Text -> Text -> DescribeVirtualService
newDescribeVirtualService
  Text
pMeshName_
  Text
pVirtualServiceName_ =
    DescribeVirtualService' :: Maybe Text -> Text -> Text -> DescribeVirtualService
DescribeVirtualService'
      { $sel:meshOwner:DescribeVirtualService' :: Maybe Text
meshOwner =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:meshName:DescribeVirtualService' :: Text
meshName = Text
pMeshName_,
        $sel:virtualServiceName:DescribeVirtualService' :: Text
virtualServiceName = Text
pVirtualServiceName_
      }

-- | 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>.
describeVirtualService_meshOwner :: Lens.Lens' DescribeVirtualService (Prelude.Maybe Prelude.Text)
describeVirtualService_meshOwner :: (Maybe Text -> f (Maybe Text))
-> DescribeVirtualService -> f DescribeVirtualService
describeVirtualService_meshOwner = (DescribeVirtualService -> Maybe Text)
-> (DescribeVirtualService -> Maybe Text -> DescribeVirtualService)
-> Lens
     DescribeVirtualService
     DescribeVirtualService
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeVirtualService' {Maybe Text
meshOwner :: Maybe Text
$sel:meshOwner:DescribeVirtualService' :: DescribeVirtualService -> Maybe Text
meshOwner} -> Maybe Text
meshOwner) (\s :: DescribeVirtualService
s@DescribeVirtualService' {} Maybe Text
a -> DescribeVirtualService
s {$sel:meshOwner:DescribeVirtualService' :: Maybe Text
meshOwner = Maybe Text
a} :: DescribeVirtualService)

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

-- | The name of the virtual service to describe.
describeVirtualService_virtualServiceName :: Lens.Lens' DescribeVirtualService Prelude.Text
describeVirtualService_virtualServiceName :: (Text -> f Text)
-> DescribeVirtualService -> f DescribeVirtualService
describeVirtualService_virtualServiceName = (DescribeVirtualService -> Text)
-> (DescribeVirtualService -> Text -> DescribeVirtualService)
-> Lens DescribeVirtualService DescribeVirtualService Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeVirtualService' {Text
virtualServiceName :: Text
$sel:virtualServiceName:DescribeVirtualService' :: DescribeVirtualService -> Text
virtualServiceName} -> Text
virtualServiceName) (\s :: DescribeVirtualService
s@DescribeVirtualService' {} Text
a -> DescribeVirtualService
s {$sel:virtualServiceName:DescribeVirtualService' :: Text
virtualServiceName = Text
a} :: DescribeVirtualService)

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

instance Prelude.Hashable DescribeVirtualService

instance Prelude.NFData DescribeVirtualService

instance Core.ToHeaders DescribeVirtualService where
  toHeaders :: DescribeVirtualService -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeVirtualService -> 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 DescribeVirtualService where
  toPath :: DescribeVirtualService -> ByteString
toPath DescribeVirtualService' {Maybe Text
Text
virtualServiceName :: Text
meshName :: Text
meshOwner :: Maybe Text
$sel:virtualServiceName:DescribeVirtualService' :: DescribeVirtualService -> Text
$sel:meshName:DescribeVirtualService' :: DescribeVirtualService -> Text
$sel:meshOwner:DescribeVirtualService' :: DescribeVirtualService -> 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
"/virtualServices/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
virtualServiceName
      ]

instance Core.ToQuery DescribeVirtualService where
  toQuery :: DescribeVirtualService -> QueryString
toQuery DescribeVirtualService' {Maybe Text
Text
virtualServiceName :: Text
meshName :: Text
meshOwner :: Maybe Text
$sel:virtualServiceName:DescribeVirtualService' :: DescribeVirtualService -> Text
$sel:meshName:DescribeVirtualService' :: DescribeVirtualService -> Text
$sel:meshOwner:DescribeVirtualService' :: DescribeVirtualService -> 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:/ 'newDescribeVirtualServiceResponse' smart constructor.
data DescribeVirtualServiceResponse = DescribeVirtualServiceResponse'
  { -- | The response's http status code.
    DescribeVirtualServiceResponse -> Int
httpStatus :: Prelude.Int,
    -- | The full description of your virtual service.
    DescribeVirtualServiceResponse -> VirtualServiceData
virtualService :: VirtualServiceData
  }
  deriving (DescribeVirtualServiceResponse
-> DescribeVirtualServiceResponse -> Bool
(DescribeVirtualServiceResponse
 -> DescribeVirtualServiceResponse -> Bool)
-> (DescribeVirtualServiceResponse
    -> DescribeVirtualServiceResponse -> Bool)
-> Eq DescribeVirtualServiceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeVirtualServiceResponse
-> DescribeVirtualServiceResponse -> Bool
$c/= :: DescribeVirtualServiceResponse
-> DescribeVirtualServiceResponse -> Bool
== :: DescribeVirtualServiceResponse
-> DescribeVirtualServiceResponse -> Bool
$c== :: DescribeVirtualServiceResponse
-> DescribeVirtualServiceResponse -> Bool
Prelude.Eq, ReadPrec [DescribeVirtualServiceResponse]
ReadPrec DescribeVirtualServiceResponse
Int -> ReadS DescribeVirtualServiceResponse
ReadS [DescribeVirtualServiceResponse]
(Int -> ReadS DescribeVirtualServiceResponse)
-> ReadS [DescribeVirtualServiceResponse]
-> ReadPrec DescribeVirtualServiceResponse
-> ReadPrec [DescribeVirtualServiceResponse]
-> Read DescribeVirtualServiceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeVirtualServiceResponse]
$creadListPrec :: ReadPrec [DescribeVirtualServiceResponse]
readPrec :: ReadPrec DescribeVirtualServiceResponse
$creadPrec :: ReadPrec DescribeVirtualServiceResponse
readList :: ReadS [DescribeVirtualServiceResponse]
$creadList :: ReadS [DescribeVirtualServiceResponse]
readsPrec :: Int -> ReadS DescribeVirtualServiceResponse
$creadsPrec :: Int -> ReadS DescribeVirtualServiceResponse
Prelude.Read, Int -> DescribeVirtualServiceResponse -> ShowS
[DescribeVirtualServiceResponse] -> ShowS
DescribeVirtualServiceResponse -> String
(Int -> DescribeVirtualServiceResponse -> ShowS)
-> (DescribeVirtualServiceResponse -> String)
-> ([DescribeVirtualServiceResponse] -> ShowS)
-> Show DescribeVirtualServiceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeVirtualServiceResponse] -> ShowS
$cshowList :: [DescribeVirtualServiceResponse] -> ShowS
show :: DescribeVirtualServiceResponse -> String
$cshow :: DescribeVirtualServiceResponse -> String
showsPrec :: Int -> DescribeVirtualServiceResponse -> ShowS
$cshowsPrec :: Int -> DescribeVirtualServiceResponse -> ShowS
Prelude.Show, (forall x.
 DescribeVirtualServiceResponse
 -> Rep DescribeVirtualServiceResponse x)
-> (forall x.
    Rep DescribeVirtualServiceResponse x
    -> DescribeVirtualServiceResponse)
-> Generic DescribeVirtualServiceResponse
forall x.
Rep DescribeVirtualServiceResponse x
-> DescribeVirtualServiceResponse
forall x.
DescribeVirtualServiceResponse
-> Rep DescribeVirtualServiceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeVirtualServiceResponse x
-> DescribeVirtualServiceResponse
$cfrom :: forall x.
DescribeVirtualServiceResponse
-> Rep DescribeVirtualServiceResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeVirtualServiceResponse' 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', 'describeVirtualServiceResponse_httpStatus' - The response's http status code.
--
-- 'virtualService', 'describeVirtualServiceResponse_virtualService' - The full description of your virtual service.
newDescribeVirtualServiceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'virtualService'
  VirtualServiceData ->
  DescribeVirtualServiceResponse
newDescribeVirtualServiceResponse :: Int -> VirtualServiceData -> DescribeVirtualServiceResponse
newDescribeVirtualServiceResponse
  Int
pHttpStatus_
  VirtualServiceData
pVirtualService_ =
    DescribeVirtualServiceResponse' :: Int -> VirtualServiceData -> DescribeVirtualServiceResponse
DescribeVirtualServiceResponse'
      { $sel:httpStatus:DescribeVirtualServiceResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:virtualService:DescribeVirtualServiceResponse' :: VirtualServiceData
virtualService = VirtualServiceData
pVirtualService_
      }

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

-- | The full description of your virtual service.
describeVirtualServiceResponse_virtualService :: Lens.Lens' DescribeVirtualServiceResponse VirtualServiceData
describeVirtualServiceResponse_virtualService :: (VirtualServiceData -> f VirtualServiceData)
-> DescribeVirtualServiceResponse
-> f DescribeVirtualServiceResponse
describeVirtualServiceResponse_virtualService = (DescribeVirtualServiceResponse -> VirtualServiceData)
-> (DescribeVirtualServiceResponse
    -> VirtualServiceData -> DescribeVirtualServiceResponse)
-> Lens
     DescribeVirtualServiceResponse
     DescribeVirtualServiceResponse
     VirtualServiceData
     VirtualServiceData
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeVirtualServiceResponse' {VirtualServiceData
virtualService :: VirtualServiceData
$sel:virtualService:DescribeVirtualServiceResponse' :: DescribeVirtualServiceResponse -> VirtualServiceData
virtualService} -> VirtualServiceData
virtualService) (\s :: DescribeVirtualServiceResponse
s@DescribeVirtualServiceResponse' {} VirtualServiceData
a -> DescribeVirtualServiceResponse
s {$sel:virtualService:DescribeVirtualServiceResponse' :: VirtualServiceData
virtualService = VirtualServiceData
a} :: DescribeVirtualServiceResponse)

instance
  Prelude.NFData
    DescribeVirtualServiceResponse