{-# 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.RebuildEnvironment
-- 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)
--
-- Deletes and recreates all of the AWS resources (for example: the Auto
-- Scaling group, load balancer, etc.) for a specified environment and
-- forces a restart.
module Amazonka.ElasticBeanstalk.RebuildEnvironment
  ( -- * Creating a Request
    RebuildEnvironment (..),
    newRebuildEnvironment,

    -- * Request Lenses
    rebuildEnvironment_environmentName,
    rebuildEnvironment_environmentId,

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

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

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

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

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

instance Prelude.Hashable RebuildEnvironment

instance Prelude.NFData RebuildEnvironment

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

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

instance Core.ToQuery RebuildEnvironment where
  toQuery :: RebuildEnvironment -> QueryString
toQuery RebuildEnvironment' {Maybe Text
environmentId :: Maybe Text
environmentName :: Maybe Text
$sel:environmentId:RebuildEnvironment' :: RebuildEnvironment -> Maybe Text
$sel:environmentName:RebuildEnvironment' :: RebuildEnvironment -> 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
"RebuildEnvironment" :: 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:/ 'newRebuildEnvironmentResponse' smart constructor.
data RebuildEnvironmentResponse = RebuildEnvironmentResponse'
  {
  }
  deriving (RebuildEnvironmentResponse -> RebuildEnvironmentResponse -> Bool
(RebuildEnvironmentResponse -> RebuildEnvironmentResponse -> Bool)
-> (RebuildEnvironmentResponse
    -> RebuildEnvironmentResponse -> Bool)
-> Eq RebuildEnvironmentResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RebuildEnvironmentResponse -> RebuildEnvironmentResponse -> Bool
$c/= :: RebuildEnvironmentResponse -> RebuildEnvironmentResponse -> Bool
== :: RebuildEnvironmentResponse -> RebuildEnvironmentResponse -> Bool
$c== :: RebuildEnvironmentResponse -> RebuildEnvironmentResponse -> Bool
Prelude.Eq, ReadPrec [RebuildEnvironmentResponse]
ReadPrec RebuildEnvironmentResponse
Int -> ReadS RebuildEnvironmentResponse
ReadS [RebuildEnvironmentResponse]
(Int -> ReadS RebuildEnvironmentResponse)
-> ReadS [RebuildEnvironmentResponse]
-> ReadPrec RebuildEnvironmentResponse
-> ReadPrec [RebuildEnvironmentResponse]
-> Read RebuildEnvironmentResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RebuildEnvironmentResponse]
$creadListPrec :: ReadPrec [RebuildEnvironmentResponse]
readPrec :: ReadPrec RebuildEnvironmentResponse
$creadPrec :: ReadPrec RebuildEnvironmentResponse
readList :: ReadS [RebuildEnvironmentResponse]
$creadList :: ReadS [RebuildEnvironmentResponse]
readsPrec :: Int -> ReadS RebuildEnvironmentResponse
$creadsPrec :: Int -> ReadS RebuildEnvironmentResponse
Prelude.Read, Int -> RebuildEnvironmentResponse -> ShowS
[RebuildEnvironmentResponse] -> ShowS
RebuildEnvironmentResponse -> String
(Int -> RebuildEnvironmentResponse -> ShowS)
-> (RebuildEnvironmentResponse -> String)
-> ([RebuildEnvironmentResponse] -> ShowS)
-> Show RebuildEnvironmentResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RebuildEnvironmentResponse] -> ShowS
$cshowList :: [RebuildEnvironmentResponse] -> ShowS
show :: RebuildEnvironmentResponse -> String
$cshow :: RebuildEnvironmentResponse -> String
showsPrec :: Int -> RebuildEnvironmentResponse -> ShowS
$cshowsPrec :: Int -> RebuildEnvironmentResponse -> ShowS
Prelude.Show, (forall x.
 RebuildEnvironmentResponse -> Rep RebuildEnvironmentResponse x)
-> (forall x.
    Rep RebuildEnvironmentResponse x -> RebuildEnvironmentResponse)
-> Generic RebuildEnvironmentResponse
forall x.
Rep RebuildEnvironmentResponse x -> RebuildEnvironmentResponse
forall x.
RebuildEnvironmentResponse -> Rep RebuildEnvironmentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RebuildEnvironmentResponse x -> RebuildEnvironmentResponse
$cfrom :: forall x.
RebuildEnvironmentResponse -> Rep RebuildEnvironmentResponse x
Prelude.Generic)

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

instance Prelude.NFData RebuildEnvironmentResponse