{-# 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.ElasticBeanstalk.RestartAppServer
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Causes the environment to restart the application container server
-- running on each Amazon EC2 instance.
module Amazonka.ElasticBeanstalk.RestartAppServer
  ( -- * Creating a Request
    RestartAppServer (..),
    newRestartAppServer,

    -- * Request Lenses
    restartAppServer_environmentId,
    restartAppServer_environmentName,

    -- * Destructuring the Response
    RestartAppServerResponse (..),
    newRestartAppServerResponse,
  )
where

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

-- |
--
-- /See:/ 'newRestartAppServer' smart constructor.
data RestartAppServer = RestartAppServer'
  { -- | The ID of the environment to restart the server for.
    --
    -- Condition: You must specify either this or an EnvironmentName, or both.
    -- If you do not specify either, AWS Elastic Beanstalk returns
    -- @MissingRequiredParameter@ error.
    RestartAppServer -> Maybe Text
environmentId :: Prelude.Maybe Prelude.Text,
    -- | The name of the environment to restart the server for.
    --
    -- Condition: You must specify either this or an EnvironmentId, or both. If
    -- you do not specify either, AWS Elastic Beanstalk returns
    -- @MissingRequiredParameter@ error.
    RestartAppServer -> Maybe Text
environmentName :: Prelude.Maybe Prelude.Text
  }
  deriving (RestartAppServer -> RestartAppServer -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RestartAppServer -> RestartAppServer -> Bool
$c/= :: RestartAppServer -> RestartAppServer -> Bool
== :: RestartAppServer -> RestartAppServer -> Bool
$c== :: RestartAppServer -> RestartAppServer -> Bool
Prelude.Eq, ReadPrec [RestartAppServer]
ReadPrec RestartAppServer
Int -> ReadS RestartAppServer
ReadS [RestartAppServer]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RestartAppServer]
$creadListPrec :: ReadPrec [RestartAppServer]
readPrec :: ReadPrec RestartAppServer
$creadPrec :: ReadPrec RestartAppServer
readList :: ReadS [RestartAppServer]
$creadList :: ReadS [RestartAppServer]
readsPrec :: Int -> ReadS RestartAppServer
$creadsPrec :: Int -> ReadS RestartAppServer
Prelude.Read, Int -> RestartAppServer -> ShowS
[RestartAppServer] -> ShowS
RestartAppServer -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RestartAppServer] -> ShowS
$cshowList :: [RestartAppServer] -> ShowS
show :: RestartAppServer -> String
$cshow :: RestartAppServer -> String
showsPrec :: Int -> RestartAppServer -> ShowS
$cshowsPrec :: Int -> RestartAppServer -> ShowS
Prelude.Show, forall x. Rep RestartAppServer x -> RestartAppServer
forall x. RestartAppServer -> Rep RestartAppServer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RestartAppServer x -> RestartAppServer
$cfrom :: forall x. RestartAppServer -> Rep RestartAppServer x
Prelude.Generic)

-- |
-- Create a value of 'RestartAppServer' 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:
--
-- 'environmentId', 'restartAppServer_environmentId' - The ID of the environment to restart the server for.
--
-- Condition: You must specify either this or an EnvironmentName, or both.
-- If you do not specify either, AWS Elastic Beanstalk returns
-- @MissingRequiredParameter@ error.
--
-- 'environmentName', 'restartAppServer_environmentName' - The name of the environment to restart the server for.
--
-- Condition: You must specify either this or an EnvironmentId, or both. If
-- you do not specify either, AWS Elastic Beanstalk returns
-- @MissingRequiredParameter@ error.
newRestartAppServer ::
  RestartAppServer
newRestartAppServer :: RestartAppServer
newRestartAppServer =
  RestartAppServer'
    { $sel:environmentId:RestartAppServer' :: Maybe Text
environmentId = forall a. Maybe a
Prelude.Nothing,
      $sel:environmentName:RestartAppServer' :: Maybe Text
environmentName = forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the environment to restart the server for.
--
-- Condition: You must specify either this or an EnvironmentName, or both.
-- If you do not specify either, AWS Elastic Beanstalk returns
-- @MissingRequiredParameter@ error.
restartAppServer_environmentId :: Lens.Lens' RestartAppServer (Prelude.Maybe Prelude.Text)
restartAppServer_environmentId :: Lens' RestartAppServer (Maybe Text)
restartAppServer_environmentId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestartAppServer' {Maybe Text
environmentId :: Maybe Text
$sel:environmentId:RestartAppServer' :: RestartAppServer -> Maybe Text
environmentId} -> Maybe Text
environmentId) (\s :: RestartAppServer
s@RestartAppServer' {} Maybe Text
a -> RestartAppServer
s {$sel:environmentId:RestartAppServer' :: Maybe Text
environmentId = Maybe Text
a} :: RestartAppServer)

-- | The name of the environment to restart the server for.
--
-- Condition: You must specify either this or an EnvironmentId, or both. If
-- you do not specify either, AWS Elastic Beanstalk returns
-- @MissingRequiredParameter@ error.
restartAppServer_environmentName :: Lens.Lens' RestartAppServer (Prelude.Maybe Prelude.Text)
restartAppServer_environmentName :: Lens' RestartAppServer (Maybe Text)
restartAppServer_environmentName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RestartAppServer' {Maybe Text
environmentName :: Maybe Text
$sel:environmentName:RestartAppServer' :: RestartAppServer -> Maybe Text
environmentName} -> Maybe Text
environmentName) (\s :: RestartAppServer
s@RestartAppServer' {} Maybe Text
a -> RestartAppServer
s {$sel:environmentName:RestartAppServer' :: Maybe Text
environmentName = Maybe Text
a} :: RestartAppServer)

instance Core.AWSRequest RestartAppServer where
  type
    AWSResponse RestartAppServer =
      RestartAppServerResponse
  request :: (Service -> Service)
-> RestartAppServer -> Request RestartAppServer
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy RestartAppServer
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RestartAppServer)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull RestartAppServerResponse
RestartAppServerResponse'

instance Prelude.Hashable RestartAppServer where
  hashWithSalt :: Int -> RestartAppServer -> Int
hashWithSalt Int
_salt RestartAppServer' {Maybe Text
environmentName :: Maybe Text
environmentId :: Maybe Text
$sel:environmentName:RestartAppServer' :: RestartAppServer -> Maybe Text
$sel:environmentId:RestartAppServer' :: RestartAppServer -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
environmentId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
environmentName

instance Prelude.NFData RestartAppServer where
  rnf :: RestartAppServer -> ()
rnf RestartAppServer' {Maybe Text
environmentName :: Maybe Text
environmentId :: Maybe Text
$sel:environmentName:RestartAppServer' :: RestartAppServer -> Maybe Text
$sel:environmentId:RestartAppServer' :: RestartAppServer -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
environmentId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
environmentName

instance Data.ToHeaders RestartAppServer where
  toHeaders :: RestartAppServer -> [Header]
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery RestartAppServer where
  toQuery :: RestartAppServer -> QueryString
toQuery RestartAppServer' {Maybe Text
environmentName :: Maybe Text
environmentId :: Maybe Text
$sel:environmentName:RestartAppServer' :: RestartAppServer -> Maybe Text
$sel:environmentId:RestartAppServer' :: RestartAppServer -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"RestartAppServer" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"EnvironmentId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
environmentId,
        ByteString
"EnvironmentName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
environmentName
      ]

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

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

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