{-# 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-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)
--
-- 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 will 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.Lens as Lens
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
(StopServer -> StopServer -> Bool)
-> (StopServer -> StopServer -> Bool) -> Eq StopServer
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]
(Int -> ReadS StopServer)
-> ReadS [StopServer]
-> ReadPrec StopServer
-> ReadPrec [StopServer]
-> Read 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
(Int -> StopServer -> ShowS)
-> (StopServer -> String)
-> ([StopServer] -> ShowS)
-> Show StopServer
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. StopServer -> Rep StopServer x)
-> (forall x. Rep StopServer x -> StopServer) -> Generic StopServer
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' :: Text -> StopServer
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 :: (Text -> f Text) -> StopServer -> f StopServer
stopServer_serverId = (StopServer -> Text)
-> (StopServer -> Text -> StopServer)
-> Lens StopServer StopServer Text Text
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 :: StopServer -> Request StopServer
request = Service -> StopServer -> Request StopServer
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopServer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopServer)))
response = AWSResponse StopServer
-> Logger
-> Service
-> Proxy StopServer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopServer)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse StopServer
StopServerResponse
StopServerResponse'

instance Prelude.Hashable StopServer

instance Prelude.NFData StopServer

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

instance Core.ToJSON StopServer where
  toJSON :: StopServer -> Value
toJSON StopServer' {Text
serverId :: Text
$sel:serverId:StopServer' :: StopServer -> 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
"ServerId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
serverId)]
      )

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

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

-- | /See:/ 'newStopServerResponse' smart constructor.
data StopServerResponse = StopServerResponse'
  {
  }
  deriving (StopServerResponse -> StopServerResponse -> Bool
(StopServerResponse -> StopServerResponse -> Bool)
-> (StopServerResponse -> StopServerResponse -> Bool)
-> Eq StopServerResponse
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]
(Int -> ReadS StopServerResponse)
-> ReadS [StopServerResponse]
-> ReadPrec StopServerResponse
-> ReadPrec [StopServerResponse]
-> Read 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
(Int -> StopServerResponse -> ShowS)
-> (StopServerResponse -> String)
-> ([StopServerResponse] -> ShowS)
-> Show StopServerResponse
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. StopServerResponse -> Rep StopServerResponse x)
-> (forall x. Rep StopServerResponse x -> StopServerResponse)
-> Generic StopServerResponse
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