{-# 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.UpdateAgent
-- 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)
--
-- Updates the name of an agent.
module Amazonka.DataSync.UpdateAgent
  ( -- * Creating a Request
    UpdateAgent (..),
    newUpdateAgent,

    -- * Request Lenses
    updateAgent_name,
    updateAgent_agentArn,

    -- * Destructuring the Response
    UpdateAgentResponse (..),
    newUpdateAgentResponse,

    -- * Response Lenses
    updateAgentResponse_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

-- | UpdateAgentRequest
--
-- /See:/ 'newUpdateAgent' smart constructor.
data UpdateAgent = UpdateAgent'
  { -- | The name that you want to use to configure the agent.
    UpdateAgent -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the agent to update.
    UpdateAgent -> Text
agentArn :: Prelude.Text
  }
  deriving (UpdateAgent -> UpdateAgent -> Bool
(UpdateAgent -> UpdateAgent -> Bool)
-> (UpdateAgent -> UpdateAgent -> Bool) -> Eq UpdateAgent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateAgent -> UpdateAgent -> Bool
$c/= :: UpdateAgent -> UpdateAgent -> Bool
== :: UpdateAgent -> UpdateAgent -> Bool
$c== :: UpdateAgent -> UpdateAgent -> Bool
Prelude.Eq, ReadPrec [UpdateAgent]
ReadPrec UpdateAgent
Int -> ReadS UpdateAgent
ReadS [UpdateAgent]
(Int -> ReadS UpdateAgent)
-> ReadS [UpdateAgent]
-> ReadPrec UpdateAgent
-> ReadPrec [UpdateAgent]
-> Read UpdateAgent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateAgent]
$creadListPrec :: ReadPrec [UpdateAgent]
readPrec :: ReadPrec UpdateAgent
$creadPrec :: ReadPrec UpdateAgent
readList :: ReadS [UpdateAgent]
$creadList :: ReadS [UpdateAgent]
readsPrec :: Int -> ReadS UpdateAgent
$creadsPrec :: Int -> ReadS UpdateAgent
Prelude.Read, Int -> UpdateAgent -> ShowS
[UpdateAgent] -> ShowS
UpdateAgent -> String
(Int -> UpdateAgent -> ShowS)
-> (UpdateAgent -> String)
-> ([UpdateAgent] -> ShowS)
-> Show UpdateAgent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateAgent] -> ShowS
$cshowList :: [UpdateAgent] -> ShowS
show :: UpdateAgent -> String
$cshow :: UpdateAgent -> String
showsPrec :: Int -> UpdateAgent -> ShowS
$cshowsPrec :: Int -> UpdateAgent -> ShowS
Prelude.Show, (forall x. UpdateAgent -> Rep UpdateAgent x)
-> (forall x. Rep UpdateAgent x -> UpdateAgent)
-> Generic UpdateAgent
forall x. Rep UpdateAgent x -> UpdateAgent
forall x. UpdateAgent -> Rep UpdateAgent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateAgent x -> UpdateAgent
$cfrom :: forall x. UpdateAgent -> Rep UpdateAgent x
Prelude.Generic)

-- |
-- Create a value of 'UpdateAgent' 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:
--
-- 'name', 'updateAgent_name' - The name that you want to use to configure the agent.
--
-- 'agentArn', 'updateAgent_agentArn' - The Amazon Resource Name (ARN) of the agent to update.
newUpdateAgent ::
  -- | 'agentArn'
  Prelude.Text ->
  UpdateAgent
newUpdateAgent :: Text -> UpdateAgent
newUpdateAgent Text
pAgentArn_ =
  UpdateAgent' :: Maybe Text -> Text -> UpdateAgent
UpdateAgent'
    { $sel:name:UpdateAgent' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:agentArn:UpdateAgent' :: Text
agentArn = Text
pAgentArn_
    }

-- | The name that you want to use to configure the agent.
updateAgent_name :: Lens.Lens' UpdateAgent (Prelude.Maybe Prelude.Text)
updateAgent_name :: (Maybe Text -> f (Maybe Text)) -> UpdateAgent -> f UpdateAgent
updateAgent_name = (UpdateAgent -> Maybe Text)
-> (UpdateAgent -> Maybe Text -> UpdateAgent)
-> Lens UpdateAgent UpdateAgent (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAgent' {Maybe Text
name :: Maybe Text
$sel:name:UpdateAgent' :: UpdateAgent -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateAgent
s@UpdateAgent' {} Maybe Text
a -> UpdateAgent
s {$sel:name:UpdateAgent' :: Maybe Text
name = Maybe Text
a} :: UpdateAgent)

-- | The Amazon Resource Name (ARN) of the agent to update.
updateAgent_agentArn :: Lens.Lens' UpdateAgent Prelude.Text
updateAgent_agentArn :: (Text -> f Text) -> UpdateAgent -> f UpdateAgent
updateAgent_agentArn = (UpdateAgent -> Text)
-> (UpdateAgent -> Text -> UpdateAgent)
-> Lens UpdateAgent UpdateAgent Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateAgent' {Text
agentArn :: Text
$sel:agentArn:UpdateAgent' :: UpdateAgent -> Text
agentArn} -> Text
agentArn) (\s :: UpdateAgent
s@UpdateAgent' {} Text
a -> UpdateAgent
s {$sel:agentArn:UpdateAgent' :: Text
agentArn = Text
a} :: UpdateAgent)

instance Core.AWSRequest UpdateAgent where
  type AWSResponse UpdateAgent = UpdateAgentResponse
  request :: UpdateAgent -> Request UpdateAgent
request = Service -> UpdateAgent -> Request UpdateAgent
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateAgent
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateAgent)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateAgent))
-> Logger
-> Service
-> Proxy UpdateAgent
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateAgent)))
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 -> UpdateAgentResponse
UpdateAgentResponse'
            (Int -> UpdateAgentResponse)
-> Either String Int -> Either String UpdateAgentResponse
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 UpdateAgent

instance Prelude.NFData UpdateAgent

instance Core.ToHeaders UpdateAgent where
  toHeaders :: UpdateAgent -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateAgent -> 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.UpdateAgent" :: 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 UpdateAgent where
  toJSON :: UpdateAgent -> Value
toJSON UpdateAgent' {Maybe Text
Text
agentArn :: Text
name :: Maybe Text
$sel:agentArn:UpdateAgent' :: UpdateAgent -> Text
$sel:name:UpdateAgent' :: UpdateAgent -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
            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 UpdateAgent where
  toPath :: UpdateAgent -> ByteString
toPath = ByteString -> UpdateAgent -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

instance Prelude.NFData UpdateAgentResponse