{-# 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.DataSync.DeleteAgent
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes an agent. To specify which agent to delete, use the Amazon
-- Resource Name (ARN) of the agent in your request. The operation
-- disassociates the agent from your Amazon Web Services account. However,
-- it doesn\'t delete the agent virtual machine (VM) from your on-premises
-- environment.
module Amazonka.DataSync.DeleteAgent
  ( -- * Creating a Request
    DeleteAgent (..),
    newDeleteAgent,

    -- * Request Lenses
    deleteAgent_agentArn,

    -- * Destructuring the Response
    DeleteAgentResponse (..),
    newDeleteAgentResponse,

    -- * Response Lenses
    deleteAgentResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DataSync.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | DeleteAgentRequest
--
-- /See:/ 'newDeleteAgent' smart constructor.
data DeleteAgent = DeleteAgent'
  { -- | The Amazon Resource Name (ARN) of the agent to delete. Use the
    -- @ListAgents@ operation to return a list of agents for your account and
    -- Amazon Web Services Region.
    DeleteAgent -> Text
agentArn :: Prelude.Text
  }
  deriving (DeleteAgent -> DeleteAgent -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteAgent -> DeleteAgent -> Bool
$c/= :: DeleteAgent -> DeleteAgent -> Bool
== :: DeleteAgent -> DeleteAgent -> Bool
$c== :: DeleteAgent -> DeleteAgent -> Bool
Prelude.Eq, ReadPrec [DeleteAgent]
ReadPrec DeleteAgent
Int -> ReadS DeleteAgent
ReadS [DeleteAgent]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteAgent]
$creadListPrec :: ReadPrec [DeleteAgent]
readPrec :: ReadPrec DeleteAgent
$creadPrec :: ReadPrec DeleteAgent
readList :: ReadS [DeleteAgent]
$creadList :: ReadS [DeleteAgent]
readsPrec :: Int -> ReadS DeleteAgent
$creadsPrec :: Int -> ReadS DeleteAgent
Prelude.Read, Int -> DeleteAgent -> ShowS
[DeleteAgent] -> ShowS
DeleteAgent -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteAgent] -> ShowS
$cshowList :: [DeleteAgent] -> ShowS
show :: DeleteAgent -> String
$cshow :: DeleteAgent -> String
showsPrec :: Int -> DeleteAgent -> ShowS
$cshowsPrec :: Int -> DeleteAgent -> ShowS
Prelude.Show, forall x. Rep DeleteAgent x -> DeleteAgent
forall x. DeleteAgent -> Rep DeleteAgent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteAgent x -> DeleteAgent
$cfrom :: forall x. DeleteAgent -> Rep DeleteAgent x
Prelude.Generic)

-- |
-- Create a value of 'DeleteAgent' 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:
--
-- 'agentArn', 'deleteAgent_agentArn' - The Amazon Resource Name (ARN) of the agent to delete. Use the
-- @ListAgents@ operation to return a list of agents for your account and
-- Amazon Web Services Region.
newDeleteAgent ::
  -- | 'agentArn'
  Prelude.Text ->
  DeleteAgent
newDeleteAgent :: Text -> DeleteAgent
newDeleteAgent Text
pAgentArn_ =
  DeleteAgent' {$sel:agentArn:DeleteAgent' :: Text
agentArn = Text
pAgentArn_}

-- | The Amazon Resource Name (ARN) of the agent to delete. Use the
-- @ListAgents@ operation to return a list of agents for your account and
-- Amazon Web Services Region.
deleteAgent_agentArn :: Lens.Lens' DeleteAgent Prelude.Text
deleteAgent_agentArn :: Lens' DeleteAgent Text
deleteAgent_agentArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteAgent' {Text
agentArn :: Text
$sel:agentArn:DeleteAgent' :: DeleteAgent -> Text
agentArn} -> Text
agentArn) (\s :: DeleteAgent
s@DeleteAgent' {} Text
a -> DeleteAgent
s {$sel:agentArn:DeleteAgent' :: Text
agentArn = Text
a} :: DeleteAgent)

instance Core.AWSRequest DeleteAgent where
  type AWSResponse DeleteAgent = DeleteAgentResponse
  request :: (Service -> Service) -> DeleteAgent -> Request DeleteAgent
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteAgent
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteAgent)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteAgentResponse
DeleteAgentResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteAgent where
  hashWithSalt :: Int -> DeleteAgent -> Int
hashWithSalt Int
_salt DeleteAgent' {Text
agentArn :: Text
$sel:agentArn:DeleteAgent' :: DeleteAgent -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
agentArn

instance Prelude.NFData DeleteAgent where
  rnf :: DeleteAgent -> ()
rnf DeleteAgent' {Text
agentArn :: Text
$sel:agentArn:DeleteAgent' :: DeleteAgent -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
agentArn

instance Data.ToHeaders DeleteAgent where
  toHeaders :: DeleteAgent -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"FmrsService.DeleteAgent" :: Prelude.ByteString),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteAgent where
  toJSON :: DeleteAgent -> Value
toJSON DeleteAgent' {Text
agentArn :: Text
$sel:agentArn:DeleteAgent' :: DeleteAgent -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"AgentArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
agentArn)]
      )

instance Data.ToPath DeleteAgent where
  toPath :: DeleteAgent -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery DeleteAgent where
  toQuery :: DeleteAgent -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

-- |
-- Create a value of 'DeleteAgentResponse' 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', 'deleteAgentResponse_httpStatus' - The response's http status code.
newDeleteAgentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteAgentResponse
newDeleteAgentResponse :: Int -> DeleteAgentResponse
newDeleteAgentResponse Int
pHttpStatus_ =
  DeleteAgentResponse' {$sel:httpStatus:DeleteAgentResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData DeleteAgentResponse where
  rnf :: DeleteAgentResponse -> ()
rnf DeleteAgentResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteAgentResponse' :: DeleteAgentResponse -> Int
..} = forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus