{-# 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-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)
--
-- 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_environmentName,
    restartAppServer_environmentId,

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

import qualified Amazonka.Core as Core
import Amazonka.ElasticBeanstalk.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

-- |
--
-- /See:/ 'newRestartAppServer' smart constructor.
data RestartAppServer = 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 -> Maybe Text
environmentName :: Prelude.Maybe Prelude.Text,
    -- | 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
  }
  deriving (RestartAppServer -> RestartAppServer -> Bool
(RestartAppServer -> RestartAppServer -> Bool)
-> (RestartAppServer -> RestartAppServer -> Bool)
-> Eq RestartAppServer
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]
(Int -> ReadS RestartAppServer)
-> ReadS [RestartAppServer]
-> ReadPrec RestartAppServer
-> ReadPrec [RestartAppServer]
-> Read 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
(Int -> RestartAppServer -> ShowS)
-> (RestartAppServer -> String)
-> ([RestartAppServer] -> ShowS)
-> Show RestartAppServer
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. RestartAppServer -> Rep RestartAppServer x)
-> (forall x. Rep RestartAppServer x -> RestartAppServer)
-> Generic RestartAppServer
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:
--
-- '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.
--
-- '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.
newRestartAppServer ::
  RestartAppServer
newRestartAppServer :: RestartAppServer
newRestartAppServer =
  RestartAppServer' :: Maybe Text -> Maybe Text -> RestartAppServer
RestartAppServer'
    { $sel:environmentName:RestartAppServer' :: Maybe Text
environmentName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:environmentId:RestartAppServer' :: Maybe Text
environmentId = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> RestartAppServer -> f RestartAppServer
restartAppServer_environmentName = (RestartAppServer -> Maybe Text)
-> (RestartAppServer -> Maybe Text -> RestartAppServer)
-> Lens RestartAppServer RestartAppServer (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> RestartAppServer -> f RestartAppServer
restartAppServer_environmentId = (RestartAppServer -> Maybe Text)
-> (RestartAppServer -> Maybe Text -> RestartAppServer)
-> Lens RestartAppServer RestartAppServer (Maybe Text) (Maybe Text)
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)

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

instance Prelude.Hashable RestartAppServer

instance Prelude.NFData RestartAppServer

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

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

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

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