{-# 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.DescribeMesh
-- 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 service mesh.
module Amazonka.AppMesh.DescribeMesh
  ( -- * Creating a Request
    DescribeMesh (..),
    newDescribeMesh,

    -- * Request Lenses
    describeMesh_meshOwner,
    describeMesh_meshName,

    -- * Destructuring the Response
    DescribeMeshResponse (..),
    newDescribeMeshResponse,

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

-- |
-- Create a value of 'DescribeMesh' 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', 'describeMesh_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', 'describeMesh_meshName' - The name of the service mesh to describe.
newDescribeMesh ::
  -- | 'meshName'
  Prelude.Text ->
  DescribeMesh
newDescribeMesh :: Text -> DescribeMesh
newDescribeMesh Text
pMeshName_ =
  DescribeMesh' :: Maybe Text -> Text -> DescribeMesh
DescribeMesh'
    { $sel:meshOwner:DescribeMesh' :: Maybe Text
meshOwner = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:meshName:DescribeMesh' :: Text
meshName = Text
pMeshName_
    }

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

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

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

instance Prelude.Hashable DescribeMesh

instance Prelude.NFData DescribeMesh

instance Core.ToHeaders DescribeMesh where
  toHeaders :: DescribeMesh -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeMesh -> 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 DescribeMesh where
  toPath :: DescribeMesh -> ByteString
toPath DescribeMesh' {Maybe Text
Text
meshName :: Text
meshOwner :: Maybe Text
$sel:meshName:DescribeMesh' :: DescribeMesh -> Text
$sel:meshOwner:DescribeMesh' :: DescribeMesh -> 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]

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

-- |
-- Create a value of 'DescribeMeshResponse' 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', 'describeMeshResponse_httpStatus' - The response's http status code.
--
-- 'mesh', 'describeMeshResponse_mesh' - The full description of your service mesh.
newDescribeMeshResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'mesh'
  MeshData ->
  DescribeMeshResponse
newDescribeMeshResponse :: Int -> MeshData -> DescribeMeshResponse
newDescribeMeshResponse Int
pHttpStatus_ MeshData
pMesh_ =
  DescribeMeshResponse' :: Int -> MeshData -> DescribeMeshResponse
DescribeMeshResponse'
    { $sel:httpStatus:DescribeMeshResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:mesh:DescribeMeshResponse' :: MeshData
mesh = MeshData
pMesh_
    }

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

-- | The full description of your service mesh.
describeMeshResponse_mesh :: Lens.Lens' DescribeMeshResponse MeshData
describeMeshResponse_mesh :: (MeshData -> f MeshData)
-> DescribeMeshResponse -> f DescribeMeshResponse
describeMeshResponse_mesh = (DescribeMeshResponse -> MeshData)
-> (DescribeMeshResponse -> MeshData -> DescribeMeshResponse)
-> Lens DescribeMeshResponse DescribeMeshResponse MeshData MeshData
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeMeshResponse' {MeshData
mesh :: MeshData
$sel:mesh:DescribeMeshResponse' :: DescribeMeshResponse -> MeshData
mesh} -> MeshData
mesh) (\s :: DescribeMeshResponse
s@DescribeMeshResponse' {} MeshData
a -> DescribeMeshResponse
s {$sel:mesh:DescribeMeshResponse' :: MeshData
mesh = MeshData
a} :: DescribeMeshResponse)

instance Prelude.NFData DescribeMeshResponse