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

    -- * Request Lenses
    deleteVirtualService_meshOwner,
    deleteVirtualService_meshName,
    deleteVirtualService_virtualServiceName,

    -- * Destructuring the Response
    DeleteVirtualServiceResponse (..),
    newDeleteVirtualServiceResponse,

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

-- |
-- Create a value of 'DeleteVirtualService' 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', 'deleteVirtualService_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', 'deleteVirtualService_meshName' - The name of the service mesh to delete the virtual service in.
--
-- 'virtualServiceName', 'deleteVirtualService_virtualServiceName' - The name of the virtual service to delete.
newDeleteVirtualService ::
  -- | 'meshName'
  Prelude.Text ->
  -- | 'virtualServiceName'
  Prelude.Text ->
  DeleteVirtualService
newDeleteVirtualService :: Text -> Text -> DeleteVirtualService
newDeleteVirtualService
  Text
pMeshName_
  Text
pVirtualServiceName_ =
    DeleteVirtualService' :: Maybe Text -> Text -> Text -> DeleteVirtualService
DeleteVirtualService'
      { $sel:meshOwner:DeleteVirtualService' :: Maybe Text
meshOwner = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:meshName:DeleteVirtualService' :: Text
meshName = Text
pMeshName_,
        $sel:virtualServiceName:DeleteVirtualService' :: 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>.
deleteVirtualService_meshOwner :: Lens.Lens' DeleteVirtualService (Prelude.Maybe Prelude.Text)
deleteVirtualService_meshOwner :: (Maybe Text -> f (Maybe Text))
-> DeleteVirtualService -> f DeleteVirtualService
deleteVirtualService_meshOwner = (DeleteVirtualService -> Maybe Text)
-> (DeleteVirtualService -> Maybe Text -> DeleteVirtualService)
-> Lens
     DeleteVirtualService DeleteVirtualService (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteVirtualService' {Maybe Text
meshOwner :: Maybe Text
$sel:meshOwner:DeleteVirtualService' :: DeleteVirtualService -> Maybe Text
meshOwner} -> Maybe Text
meshOwner) (\s :: DeleteVirtualService
s@DeleteVirtualService' {} Maybe Text
a -> DeleteVirtualService
s {$sel:meshOwner:DeleteVirtualService' :: Maybe Text
meshOwner = Maybe Text
a} :: DeleteVirtualService)

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

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

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

instance Prelude.NFData DeleteVirtualService

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

-- |
-- Create a value of 'DeleteVirtualServiceResponse' 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', 'deleteVirtualServiceResponse_httpStatus' - The response's http status code.
--
-- 'virtualService', 'deleteVirtualServiceResponse_virtualService' - The virtual service that was deleted.
newDeleteVirtualServiceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'virtualService'
  VirtualServiceData ->
  DeleteVirtualServiceResponse
newDeleteVirtualServiceResponse :: Int -> VirtualServiceData -> DeleteVirtualServiceResponse
newDeleteVirtualServiceResponse
  Int
pHttpStatus_
  VirtualServiceData
pVirtualService_ =
    DeleteVirtualServiceResponse' :: Int -> VirtualServiceData -> DeleteVirtualServiceResponse
DeleteVirtualServiceResponse'
      { $sel:httpStatus:DeleteVirtualServiceResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:virtualService:DeleteVirtualServiceResponse' :: VirtualServiceData
virtualService = VirtualServiceData
pVirtualService_
      }

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

-- | The virtual service that was deleted.
deleteVirtualServiceResponse_virtualService :: Lens.Lens' DeleteVirtualServiceResponse VirtualServiceData
deleteVirtualServiceResponse_virtualService :: (VirtualServiceData -> f VirtualServiceData)
-> DeleteVirtualServiceResponse -> f DeleteVirtualServiceResponse
deleteVirtualServiceResponse_virtualService = (DeleteVirtualServiceResponse -> VirtualServiceData)
-> (DeleteVirtualServiceResponse
    -> VirtualServiceData -> DeleteVirtualServiceResponse)
-> Lens
     DeleteVirtualServiceResponse
     DeleteVirtualServiceResponse
     VirtualServiceData
     VirtualServiceData
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteVirtualServiceResponse' {VirtualServiceData
virtualService :: VirtualServiceData
$sel:virtualService:DeleteVirtualServiceResponse' :: DeleteVirtualServiceResponse -> VirtualServiceData
virtualService} -> VirtualServiceData
virtualService) (\s :: DeleteVirtualServiceResponse
s@DeleteVirtualServiceResponse' {} VirtualServiceData
a -> DeleteVirtualServiceResponse
s {$sel:virtualService:DeleteVirtualServiceResponse' :: VirtualServiceData
virtualService = VirtualServiceData
a} :: DeleteVirtualServiceResponse)

instance Prelude.NFData DeleteVirtualServiceResponse