{-# 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-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 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 Amazonka.DataSync.Types
import qualified Amazonka.Lens as Lens
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
(DeleteAgent -> DeleteAgent -> Bool)
-> (DeleteAgent -> DeleteAgent -> Bool) -> Eq DeleteAgent
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]
(Int -> ReadS DeleteAgent)
-> ReadS [DeleteAgent]
-> ReadPrec DeleteAgent
-> ReadPrec [DeleteAgent]
-> Read 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
(Int -> DeleteAgent -> ShowS)
-> (DeleteAgent -> String)
-> ([DeleteAgent] -> ShowS)
-> Show DeleteAgent
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. DeleteAgent -> Rep DeleteAgent x)
-> (forall x. Rep DeleteAgent x -> DeleteAgent)
-> Generic DeleteAgent
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' :: Text -> DeleteAgent
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 :: (Text -> f Text) -> DeleteAgent -> f DeleteAgent
deleteAgent_agentArn = (DeleteAgent -> Text)
-> (DeleteAgent -> Text -> DeleteAgent)
-> Lens DeleteAgent DeleteAgent Text Text
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 :: DeleteAgent -> Request DeleteAgent
request = Service -> DeleteAgent -> Request DeleteAgent
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteAgent
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteAgent)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteAgent))
-> Logger
-> Service
-> Proxy DeleteAgent
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteAgent)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteAgentResponse
DeleteAgentResponse'
            (Int -> DeleteAgentResponse)
-> Either String Int -> Either String DeleteAgentResponse
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))
      )

instance Prelude.Hashable DeleteAgent

instance Prelude.NFData DeleteAgent

instance Core.ToHeaders DeleteAgent where
  toHeaders :: DeleteAgent -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteAgent -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"FmrsService.DeleteAgent" :: Prelude.ByteString),
            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.ToJSON DeleteAgent where
  toJSON :: DeleteAgent -> Value
toJSON DeleteAgent' {Text
agentArn :: Text
$sel:agentArn:DeleteAgent' :: DeleteAgent -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"AgentArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
agentArn)]
      )

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

instance Core.ToQuery DeleteAgent where
  toQuery :: DeleteAgent -> QueryString
toQuery = QueryString -> DeleteAgent -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteAgentResponse -> DeleteAgentResponse -> Bool)
-> (DeleteAgentResponse -> DeleteAgentResponse -> Bool)
-> Eq DeleteAgentResponse
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]
(Int -> ReadS DeleteAgentResponse)
-> ReadS [DeleteAgentResponse]
-> ReadPrec DeleteAgentResponse
-> ReadPrec [DeleteAgentResponse]
-> Read 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
(Int -> DeleteAgentResponse -> ShowS)
-> (DeleteAgentResponse -> String)
-> ([DeleteAgentResponse] -> ShowS)
-> Show DeleteAgentResponse
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. DeleteAgentResponse -> Rep DeleteAgentResponse x)
-> (forall x. Rep DeleteAgentResponse x -> DeleteAgentResponse)
-> Generic DeleteAgentResponse
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' :: Int -> DeleteAgentResponse
DeleteAgentResponse' {$sel:httpStatus:DeleteAgentResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
deleteAgentResponse_httpStatus :: Lens.Lens' DeleteAgentResponse Prelude.Int
deleteAgentResponse_httpStatus :: (Int -> f Int) -> DeleteAgentResponse -> f DeleteAgentResponse
deleteAgentResponse_httpStatus = (DeleteAgentResponse -> Int)
-> (DeleteAgentResponse -> Int -> DeleteAgentResponse)
-> Lens DeleteAgentResponse DeleteAgentResponse Int Int
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