{-# 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.DeleteMesh
-- 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)
--
-- Deletes an existing service mesh.
--
-- You must delete all resources (virtual services, routes, virtual
-- routers, and virtual nodes) in the service mesh before you can delete
-- the mesh itself.
module Amazonka.AppMesh.DeleteMesh
  ( -- * Creating a Request
    DeleteMesh (..),
    newDeleteMesh,

    -- * Request Lenses
    deleteMesh_meshName,

    -- * Destructuring the Response
    DeleteMeshResponse (..),
    newDeleteMeshResponse,

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

-- |
-- Create a value of 'DeleteMesh' 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:
--
-- 'meshName', 'deleteMesh_meshName' - The name of the service mesh to delete.
newDeleteMesh ::
  -- | 'meshName'
  Prelude.Text ->
  DeleteMesh
newDeleteMesh :: Text -> DeleteMesh
newDeleteMesh Text
pMeshName_ =
  DeleteMesh' :: Text -> DeleteMesh
DeleteMesh' {$sel:meshName:DeleteMesh' :: Text
meshName = Text
pMeshName_}

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

instance Core.AWSRequest DeleteMesh where
  type AWSResponse DeleteMesh = DeleteMeshResponse
  request :: DeleteMesh -> Request DeleteMesh
request = Service -> DeleteMesh -> Request DeleteMesh
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteMesh
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteMesh)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteMesh))
-> Logger
-> Service
-> Proxy DeleteMesh
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteMesh)))
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 -> DeleteMeshResponse
DeleteMeshResponse'
            (Int -> MeshData -> DeleteMeshResponse)
-> Either String Int
-> Either String (MeshData -> DeleteMeshResponse)
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 -> DeleteMeshResponse)
-> Either String MeshData -> Either String DeleteMeshResponse
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 DeleteMesh

instance Prelude.NFData DeleteMesh

instance Core.ToHeaders DeleteMesh where
  toHeaders :: DeleteMesh -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteMesh -> 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 DeleteMesh where
  toPath :: DeleteMesh -> ByteString
toPath DeleteMesh' {Text
meshName :: Text
$sel:meshName:DeleteMesh' :: DeleteMesh -> 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 DeleteMesh where
  toQuery :: DeleteMesh -> QueryString
toQuery = QueryString -> DeleteMesh -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

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

-- |
-- Create a value of 'DeleteMeshResponse' 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', 'deleteMeshResponse_httpStatus' - The response's http status code.
--
-- 'mesh', 'deleteMeshResponse_mesh' - The service mesh that was deleted.
newDeleteMeshResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'mesh'
  MeshData ->
  DeleteMeshResponse
newDeleteMeshResponse :: Int -> MeshData -> DeleteMeshResponse
newDeleteMeshResponse Int
pHttpStatus_ MeshData
pMesh_ =
  DeleteMeshResponse' :: Int -> MeshData -> DeleteMeshResponse
DeleteMeshResponse'
    { $sel:httpStatus:DeleteMeshResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:mesh:DeleteMeshResponse' :: MeshData
mesh = MeshData
pMesh_
    }

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

-- | The service mesh that was deleted.
deleteMeshResponse_mesh :: Lens.Lens' DeleteMeshResponse MeshData
deleteMeshResponse_mesh :: (MeshData -> f MeshData)
-> DeleteMeshResponse -> f DeleteMeshResponse
deleteMeshResponse_mesh = (DeleteMeshResponse -> MeshData)
-> (DeleteMeshResponse -> MeshData -> DeleteMeshResponse)
-> Lens DeleteMeshResponse DeleteMeshResponse MeshData MeshData
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteMeshResponse' {MeshData
mesh :: MeshData
$sel:mesh:DeleteMeshResponse' :: DeleteMeshResponse -> MeshData
mesh} -> MeshData
mesh) (\s :: DeleteMeshResponse
s@DeleteMeshResponse' {} MeshData
a -> DeleteMeshResponse
s {$sel:mesh:DeleteMeshResponse' :: MeshData
mesh = MeshData
a} :: DeleteMeshResponse)

instance Prelude.NFData DeleteMeshResponse