{-# 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.DeleteVirtualNode
-- 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 virtual node.
--
-- You must delete any virtual services that list a virtual node as a
-- service provider before you can delete the virtual node itself.
module Amazonka.AppMesh.DeleteVirtualNode
  ( -- * Creating a Request
    DeleteVirtualNode (..),
    newDeleteVirtualNode,

    -- * Request Lenses
    deleteVirtualNode_meshOwner,
    deleteVirtualNode_meshName,
    deleteVirtualNode_virtualNodeName,

    -- * Destructuring the Response
    DeleteVirtualNodeResponse (..),
    newDeleteVirtualNodeResponse,

    -- * Response Lenses
    deleteVirtualNodeResponse_httpStatus,
    deleteVirtualNodeResponse_virtualNode,
  )
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

-- | Deletes a virtual node input.
--
-- /See:/ 'newDeleteVirtualNode' smart constructor.
data DeleteVirtualNode = DeleteVirtualNode'
  { -- | 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>.
    DeleteVirtualNode -> Maybe Text
meshOwner :: Prelude.Maybe Prelude.Text,
    -- | The name of the service mesh to delete the virtual node in.
    DeleteVirtualNode -> Text
meshName :: Prelude.Text,
    -- | The name of the virtual node to delete.
    DeleteVirtualNode -> Text
virtualNodeName :: Prelude.Text
  }
  deriving (DeleteVirtualNode -> DeleteVirtualNode -> Bool
(DeleteVirtualNode -> DeleteVirtualNode -> Bool)
-> (DeleteVirtualNode -> DeleteVirtualNode -> Bool)
-> Eq DeleteVirtualNode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteVirtualNode -> DeleteVirtualNode -> Bool
$c/= :: DeleteVirtualNode -> DeleteVirtualNode -> Bool
== :: DeleteVirtualNode -> DeleteVirtualNode -> Bool
$c== :: DeleteVirtualNode -> DeleteVirtualNode -> Bool
Prelude.Eq, ReadPrec [DeleteVirtualNode]
ReadPrec DeleteVirtualNode
Int -> ReadS DeleteVirtualNode
ReadS [DeleteVirtualNode]
(Int -> ReadS DeleteVirtualNode)
-> ReadS [DeleteVirtualNode]
-> ReadPrec DeleteVirtualNode
-> ReadPrec [DeleteVirtualNode]
-> Read DeleteVirtualNode
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteVirtualNode]
$creadListPrec :: ReadPrec [DeleteVirtualNode]
readPrec :: ReadPrec DeleteVirtualNode
$creadPrec :: ReadPrec DeleteVirtualNode
readList :: ReadS [DeleteVirtualNode]
$creadList :: ReadS [DeleteVirtualNode]
readsPrec :: Int -> ReadS DeleteVirtualNode
$creadsPrec :: Int -> ReadS DeleteVirtualNode
Prelude.Read, Int -> DeleteVirtualNode -> ShowS
[DeleteVirtualNode] -> ShowS
DeleteVirtualNode -> String
(Int -> DeleteVirtualNode -> ShowS)
-> (DeleteVirtualNode -> String)
-> ([DeleteVirtualNode] -> ShowS)
-> Show DeleteVirtualNode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteVirtualNode] -> ShowS
$cshowList :: [DeleteVirtualNode] -> ShowS
show :: DeleteVirtualNode -> String
$cshow :: DeleteVirtualNode -> String
showsPrec :: Int -> DeleteVirtualNode -> ShowS
$cshowsPrec :: Int -> DeleteVirtualNode -> ShowS
Prelude.Show, (forall x. DeleteVirtualNode -> Rep DeleteVirtualNode x)
-> (forall x. Rep DeleteVirtualNode x -> DeleteVirtualNode)
-> Generic DeleteVirtualNode
forall x. Rep DeleteVirtualNode x -> DeleteVirtualNode
forall x. DeleteVirtualNode -> Rep DeleteVirtualNode x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteVirtualNode x -> DeleteVirtualNode
$cfrom :: forall x. DeleteVirtualNode -> Rep DeleteVirtualNode x
Prelude.Generic)

-- |
-- Create a value of 'DeleteVirtualNode' 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', 'deleteVirtualNode_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', 'deleteVirtualNode_meshName' - The name of the service mesh to delete the virtual node in.
--
-- 'virtualNodeName', 'deleteVirtualNode_virtualNodeName' - The name of the virtual node to delete.
newDeleteVirtualNode ::
  -- | 'meshName'
  Prelude.Text ->
  -- | 'virtualNodeName'
  Prelude.Text ->
  DeleteVirtualNode
newDeleteVirtualNode :: Text -> Text -> DeleteVirtualNode
newDeleteVirtualNode Text
pMeshName_ Text
pVirtualNodeName_ =
  DeleteVirtualNode' :: Maybe Text -> Text -> Text -> DeleteVirtualNode
DeleteVirtualNode'
    { $sel:meshOwner:DeleteVirtualNode' :: Maybe Text
meshOwner = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:meshName:DeleteVirtualNode' :: Text
meshName = Text
pMeshName_,
      $sel:virtualNodeName:DeleteVirtualNode' :: Text
virtualNodeName = Text
pVirtualNodeName_
    }

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

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

-- | The name of the virtual node to delete.
deleteVirtualNode_virtualNodeName :: Lens.Lens' DeleteVirtualNode Prelude.Text
deleteVirtualNode_virtualNodeName :: (Text -> f Text) -> DeleteVirtualNode -> f DeleteVirtualNode
deleteVirtualNode_virtualNodeName = (DeleteVirtualNode -> Text)
-> (DeleteVirtualNode -> Text -> DeleteVirtualNode)
-> Lens DeleteVirtualNode DeleteVirtualNode Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteVirtualNode' {Text
virtualNodeName :: Text
$sel:virtualNodeName:DeleteVirtualNode' :: DeleteVirtualNode -> Text
virtualNodeName} -> Text
virtualNodeName) (\s :: DeleteVirtualNode
s@DeleteVirtualNode' {} Text
a -> DeleteVirtualNode
s {$sel:virtualNodeName:DeleteVirtualNode' :: Text
virtualNodeName = Text
a} :: DeleteVirtualNode)

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

instance Prelude.Hashable DeleteVirtualNode

instance Prelude.NFData DeleteVirtualNode

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

instance Core.ToQuery DeleteVirtualNode where
  toQuery :: DeleteVirtualNode -> QueryString
toQuery DeleteVirtualNode' {Maybe Text
Text
virtualNodeName :: Text
meshName :: Text
meshOwner :: Maybe Text
$sel:virtualNodeName:DeleteVirtualNode' :: DeleteVirtualNode -> Text
$sel:meshName:DeleteVirtualNode' :: DeleteVirtualNode -> Text
$sel:meshOwner:DeleteVirtualNode' :: DeleteVirtualNode -> 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:/ 'newDeleteVirtualNodeResponse' smart constructor.
data DeleteVirtualNodeResponse = DeleteVirtualNodeResponse'
  { -- | The response's http status code.
    DeleteVirtualNodeResponse -> Int
httpStatus :: Prelude.Int,
    -- | The virtual node that was deleted.
    DeleteVirtualNodeResponse -> VirtualNodeData
virtualNode :: VirtualNodeData
  }
  deriving (DeleteVirtualNodeResponse -> DeleteVirtualNodeResponse -> Bool
(DeleteVirtualNodeResponse -> DeleteVirtualNodeResponse -> Bool)
-> (DeleteVirtualNodeResponse -> DeleteVirtualNodeResponse -> Bool)
-> Eq DeleteVirtualNodeResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteVirtualNodeResponse -> DeleteVirtualNodeResponse -> Bool
$c/= :: DeleteVirtualNodeResponse -> DeleteVirtualNodeResponse -> Bool
== :: DeleteVirtualNodeResponse -> DeleteVirtualNodeResponse -> Bool
$c== :: DeleteVirtualNodeResponse -> DeleteVirtualNodeResponse -> Bool
Prelude.Eq, ReadPrec [DeleteVirtualNodeResponse]
ReadPrec DeleteVirtualNodeResponse
Int -> ReadS DeleteVirtualNodeResponse
ReadS [DeleteVirtualNodeResponse]
(Int -> ReadS DeleteVirtualNodeResponse)
-> ReadS [DeleteVirtualNodeResponse]
-> ReadPrec DeleteVirtualNodeResponse
-> ReadPrec [DeleteVirtualNodeResponse]
-> Read DeleteVirtualNodeResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteVirtualNodeResponse]
$creadListPrec :: ReadPrec [DeleteVirtualNodeResponse]
readPrec :: ReadPrec DeleteVirtualNodeResponse
$creadPrec :: ReadPrec DeleteVirtualNodeResponse
readList :: ReadS [DeleteVirtualNodeResponse]
$creadList :: ReadS [DeleteVirtualNodeResponse]
readsPrec :: Int -> ReadS DeleteVirtualNodeResponse
$creadsPrec :: Int -> ReadS DeleteVirtualNodeResponse
Prelude.Read, Int -> DeleteVirtualNodeResponse -> ShowS
[DeleteVirtualNodeResponse] -> ShowS
DeleteVirtualNodeResponse -> String
(Int -> DeleteVirtualNodeResponse -> ShowS)
-> (DeleteVirtualNodeResponse -> String)
-> ([DeleteVirtualNodeResponse] -> ShowS)
-> Show DeleteVirtualNodeResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteVirtualNodeResponse] -> ShowS
$cshowList :: [DeleteVirtualNodeResponse] -> ShowS
show :: DeleteVirtualNodeResponse -> String
$cshow :: DeleteVirtualNodeResponse -> String
showsPrec :: Int -> DeleteVirtualNodeResponse -> ShowS
$cshowsPrec :: Int -> DeleteVirtualNodeResponse -> ShowS
Prelude.Show, (forall x.
 DeleteVirtualNodeResponse -> Rep DeleteVirtualNodeResponse x)
-> (forall x.
    Rep DeleteVirtualNodeResponse x -> DeleteVirtualNodeResponse)
-> Generic DeleteVirtualNodeResponse
forall x.
Rep DeleteVirtualNodeResponse x -> DeleteVirtualNodeResponse
forall x.
DeleteVirtualNodeResponse -> Rep DeleteVirtualNodeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteVirtualNodeResponse x -> DeleteVirtualNodeResponse
$cfrom :: forall x.
DeleteVirtualNodeResponse -> Rep DeleteVirtualNodeResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteVirtualNodeResponse' 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', 'deleteVirtualNodeResponse_httpStatus' - The response's http status code.
--
-- 'virtualNode', 'deleteVirtualNodeResponse_virtualNode' - The virtual node that was deleted.
newDeleteVirtualNodeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'virtualNode'
  VirtualNodeData ->
  DeleteVirtualNodeResponse
newDeleteVirtualNodeResponse :: Int -> VirtualNodeData -> DeleteVirtualNodeResponse
newDeleteVirtualNodeResponse
  Int
pHttpStatus_
  VirtualNodeData
pVirtualNode_ =
    DeleteVirtualNodeResponse' :: Int -> VirtualNodeData -> DeleteVirtualNodeResponse
DeleteVirtualNodeResponse'
      { $sel:httpStatus:DeleteVirtualNodeResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:virtualNode:DeleteVirtualNodeResponse' :: VirtualNodeData
virtualNode = VirtualNodeData
pVirtualNode_
      }

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

-- | The virtual node that was deleted.
deleteVirtualNodeResponse_virtualNode :: Lens.Lens' DeleteVirtualNodeResponse VirtualNodeData
deleteVirtualNodeResponse_virtualNode :: (VirtualNodeData -> f VirtualNodeData)
-> DeleteVirtualNodeResponse -> f DeleteVirtualNodeResponse
deleteVirtualNodeResponse_virtualNode = (DeleteVirtualNodeResponse -> VirtualNodeData)
-> (DeleteVirtualNodeResponse
    -> VirtualNodeData -> DeleteVirtualNodeResponse)
-> Lens
     DeleteVirtualNodeResponse
     DeleteVirtualNodeResponse
     VirtualNodeData
     VirtualNodeData
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteVirtualNodeResponse' {VirtualNodeData
virtualNode :: VirtualNodeData
$sel:virtualNode:DeleteVirtualNodeResponse' :: DeleteVirtualNodeResponse -> VirtualNodeData
virtualNode} -> VirtualNodeData
virtualNode) (\s :: DeleteVirtualNodeResponse
s@DeleteVirtualNodeResponse' {} VirtualNodeData
a -> DeleteVirtualNodeResponse
s {$sel:virtualNode:DeleteVirtualNodeResponse' :: VirtualNodeData
virtualNode = VirtualNodeData
a} :: DeleteVirtualNodeResponse)

instance Prelude.NFData DeleteVirtualNodeResponse