{-# 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.Transfer.StopServer
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Changes the state of a file transfer protocol-enabled server from
-- @ONLINE@ to @OFFLINE@. An @OFFLINE@ server cannot accept and process
-- file transfer jobs. Information tied to your server, such as server and
-- user properties, are not affected by stopping your server.
--
-- Stopping the server does not reduce or impact your file transfer
-- protocol endpoint billing; you must delete the server to stop being
-- billed.
--
-- The state of @STOPPING@ indicates that the server is in an intermediate
-- state, either not fully able to respond, or not fully offline. The
-- values of @STOP_FAILED@ can indicate an error condition.
--
-- No response is returned from this call.
module Amazonka.Transfer.StopServer
  ( -- * Creating a Request
    StopServer (..),
    newStopServer,

    -- * Request Lenses
    stopServer_serverId,

    -- * Destructuring the Response
    StopServerResponse (..),
    newStopServerResponse,
  )
where

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

-- | /See:/ 'newStopServer' smart constructor.
data StopServer = StopServer'
  { -- | A system-assigned unique identifier for a server that you stopped.
    StopServer -> Text
serverId :: Prelude.Text
  }
  deriving (StopServer -> StopServer -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopServer -> StopServer -> Bool
$c/= :: StopServer -> StopServer -> Bool
== :: StopServer -> StopServer -> Bool
$c== :: StopServer -> StopServer -> Bool
Prelude.Eq, ReadPrec [StopServer]
ReadPrec StopServer
Int -> ReadS StopServer
ReadS [StopServer]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopServer]
$creadListPrec :: ReadPrec [StopServer]
readPrec :: ReadPrec StopServer
$creadPrec :: ReadPrec StopServer
readList :: ReadS [StopServer]
$creadList :: ReadS [StopServer]
readsPrec :: Int -> ReadS StopServer
$creadsPrec :: Int -> ReadS StopServer
Prelude.Read, Int -> StopServer -> ShowS
[StopServer] -> ShowS
StopServer -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopServer] -> ShowS
$cshowList :: [StopServer] -> ShowS
show :: StopServer -> String
$cshow :: StopServer -> String
showsPrec :: Int -> StopServer -> ShowS
$cshowsPrec :: Int -> StopServer -> ShowS
Prelude.Show, forall x. Rep StopServer x -> StopServer
forall x. StopServer -> Rep StopServer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopServer x -> StopServer
$cfrom :: forall x. StopServer -> Rep StopServer x
Prelude.Generic)

-- |
-- Create a value of 'StopServer' 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:
--
-- 'serverId', 'stopServer_serverId' - A system-assigned unique identifier for a server that you stopped.
newStopServer ::
  -- | 'serverId'
  Prelude.Text ->
  StopServer
newStopServer :: Text -> StopServer
newStopServer Text
pServerId_ =
  StopServer' {$sel:serverId:StopServer' :: Text
serverId = Text
pServerId_}

-- | A system-assigned unique identifier for a server that you stopped.
stopServer_serverId :: Lens.Lens' StopServer Prelude.Text
stopServer_serverId :: Lens' StopServer Text
stopServer_serverId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopServer' {Text
serverId :: Text
$sel:serverId:StopServer' :: StopServer -> Text
serverId} -> Text
serverId) (\s :: StopServer
s@StopServer' {} Text
a -> StopServer
s {$sel:serverId:StopServer' :: Text
serverId = Text
a} :: StopServer)

instance Core.AWSRequest StopServer where
  type AWSResponse StopServer = StopServerResponse
  request :: (Service -> Service) -> StopServer -> Request StopServer
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 StopServer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopServer)))
response = forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull StopServerResponse
StopServerResponse'

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

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

instance Data.ToHeaders StopServer where
  toHeaders :: StopServer -> [Header]
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 -> [Header]
Data.=# (ByteString
"TransferService.StopServer" :: Prelude.ByteString),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> [Header]
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

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

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

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

-- |
-- Create a value of 'StopServerResponse' 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.
newStopServerResponse ::
  StopServerResponse
newStopServerResponse :: StopServerResponse
newStopServerResponse = StopServerResponse
StopServerResponse'

instance Prelude.NFData StopServerResponse where
  rnf :: StopServerResponse -> ()
rnf StopServerResponse
_ = ()