{-# 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.UpdateApplicationVersion
-- 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)
--
-- Updates the specified application version to have the specified
-- properties.
--
-- If a property (for example, @description@) is not provided, the value
-- remains unchanged. To clear properties, specify an empty string.
module Amazonka.ElasticBeanstalk.UpdateApplicationVersion
  ( -- * Creating a Request
    UpdateApplicationVersion (..),
    newUpdateApplicationVersion,

    -- * Request Lenses
    updateApplicationVersion_description,
    updateApplicationVersion_applicationName,
    updateApplicationVersion_versionLabel,

    -- * Destructuring the Response
    ApplicationVersionDescriptionMessage (..),
    newApplicationVersionDescriptionMessage,

    -- * Response Lenses
    applicationVersionDescriptionMessage_applicationVersion,
  )
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:/ 'newUpdateApplicationVersion' smart constructor.
data UpdateApplicationVersion = UpdateApplicationVersion'
  { -- | A new description for this version.
    UpdateApplicationVersion -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The name of the application associated with this version.
    --
    -- If no application is found with this name, @UpdateApplication@ returns
    -- an @InvalidParameterValue@ error.
    UpdateApplicationVersion -> Text
applicationName :: Prelude.Text,
    -- | The name of the version to update.
    --
    -- If no application version is found with this label, @UpdateApplication@
    -- returns an @InvalidParameterValue@ error.
    UpdateApplicationVersion -> Text
versionLabel :: Prelude.Text
  }
  deriving (UpdateApplicationVersion -> UpdateApplicationVersion -> Bool
(UpdateApplicationVersion -> UpdateApplicationVersion -> Bool)
-> (UpdateApplicationVersion -> UpdateApplicationVersion -> Bool)
-> Eq UpdateApplicationVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateApplicationVersion -> UpdateApplicationVersion -> Bool
$c/= :: UpdateApplicationVersion -> UpdateApplicationVersion -> Bool
== :: UpdateApplicationVersion -> UpdateApplicationVersion -> Bool
$c== :: UpdateApplicationVersion -> UpdateApplicationVersion -> Bool
Prelude.Eq, ReadPrec [UpdateApplicationVersion]
ReadPrec UpdateApplicationVersion
Int -> ReadS UpdateApplicationVersion
ReadS [UpdateApplicationVersion]
(Int -> ReadS UpdateApplicationVersion)
-> ReadS [UpdateApplicationVersion]
-> ReadPrec UpdateApplicationVersion
-> ReadPrec [UpdateApplicationVersion]
-> Read UpdateApplicationVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateApplicationVersion]
$creadListPrec :: ReadPrec [UpdateApplicationVersion]
readPrec :: ReadPrec UpdateApplicationVersion
$creadPrec :: ReadPrec UpdateApplicationVersion
readList :: ReadS [UpdateApplicationVersion]
$creadList :: ReadS [UpdateApplicationVersion]
readsPrec :: Int -> ReadS UpdateApplicationVersion
$creadsPrec :: Int -> ReadS UpdateApplicationVersion
Prelude.Read, Int -> UpdateApplicationVersion -> ShowS
[UpdateApplicationVersion] -> ShowS
UpdateApplicationVersion -> String
(Int -> UpdateApplicationVersion -> ShowS)
-> (UpdateApplicationVersion -> String)
-> ([UpdateApplicationVersion] -> ShowS)
-> Show UpdateApplicationVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateApplicationVersion] -> ShowS
$cshowList :: [UpdateApplicationVersion] -> ShowS
show :: UpdateApplicationVersion -> String
$cshow :: UpdateApplicationVersion -> String
showsPrec :: Int -> UpdateApplicationVersion -> ShowS
$cshowsPrec :: Int -> UpdateApplicationVersion -> ShowS
Prelude.Show, (forall x.
 UpdateApplicationVersion -> Rep UpdateApplicationVersion x)
-> (forall x.
    Rep UpdateApplicationVersion x -> UpdateApplicationVersion)
-> Generic UpdateApplicationVersion
forall x.
Rep UpdateApplicationVersion x -> UpdateApplicationVersion
forall x.
UpdateApplicationVersion -> Rep UpdateApplicationVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateApplicationVersion x -> UpdateApplicationVersion
$cfrom :: forall x.
UpdateApplicationVersion -> Rep UpdateApplicationVersion x
Prelude.Generic)

-- |
-- Create a value of 'UpdateApplicationVersion' 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:
--
-- 'description', 'updateApplicationVersion_description' - A new description for this version.
--
-- 'applicationName', 'updateApplicationVersion_applicationName' - The name of the application associated with this version.
--
-- If no application is found with this name, @UpdateApplication@ returns
-- an @InvalidParameterValue@ error.
--
-- 'versionLabel', 'updateApplicationVersion_versionLabel' - The name of the version to update.
--
-- If no application version is found with this label, @UpdateApplication@
-- returns an @InvalidParameterValue@ error.
newUpdateApplicationVersion ::
  -- | 'applicationName'
  Prelude.Text ->
  -- | 'versionLabel'
  Prelude.Text ->
  UpdateApplicationVersion
newUpdateApplicationVersion :: Text -> Text -> UpdateApplicationVersion
newUpdateApplicationVersion
  Text
pApplicationName_
  Text
pVersionLabel_ =
    UpdateApplicationVersion' :: Maybe Text -> Text -> Text -> UpdateApplicationVersion
UpdateApplicationVersion'
      { $sel:description:UpdateApplicationVersion' :: Maybe Text
description =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:applicationName:UpdateApplicationVersion' :: Text
applicationName = Text
pApplicationName_,
        $sel:versionLabel:UpdateApplicationVersion' :: Text
versionLabel = Text
pVersionLabel_
      }

-- | A new description for this version.
updateApplicationVersion_description :: Lens.Lens' UpdateApplicationVersion (Prelude.Maybe Prelude.Text)
updateApplicationVersion_description :: (Maybe Text -> f (Maybe Text))
-> UpdateApplicationVersion -> f UpdateApplicationVersion
updateApplicationVersion_description = (UpdateApplicationVersion -> Maybe Text)
-> (UpdateApplicationVersion
    -> Maybe Text -> UpdateApplicationVersion)
-> Lens
     UpdateApplicationVersion
     UpdateApplicationVersion
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateApplicationVersion' {Maybe Text
description :: Maybe Text
$sel:description:UpdateApplicationVersion' :: UpdateApplicationVersion -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdateApplicationVersion
s@UpdateApplicationVersion' {} Maybe Text
a -> UpdateApplicationVersion
s {$sel:description:UpdateApplicationVersion' :: Maybe Text
description = Maybe Text
a} :: UpdateApplicationVersion)

-- | The name of the application associated with this version.
--
-- If no application is found with this name, @UpdateApplication@ returns
-- an @InvalidParameterValue@ error.
updateApplicationVersion_applicationName :: Lens.Lens' UpdateApplicationVersion Prelude.Text
updateApplicationVersion_applicationName :: (Text -> f Text)
-> UpdateApplicationVersion -> f UpdateApplicationVersion
updateApplicationVersion_applicationName = (UpdateApplicationVersion -> Text)
-> (UpdateApplicationVersion -> Text -> UpdateApplicationVersion)
-> Lens UpdateApplicationVersion UpdateApplicationVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateApplicationVersion' {Text
applicationName :: Text
$sel:applicationName:UpdateApplicationVersion' :: UpdateApplicationVersion -> Text
applicationName} -> Text
applicationName) (\s :: UpdateApplicationVersion
s@UpdateApplicationVersion' {} Text
a -> UpdateApplicationVersion
s {$sel:applicationName:UpdateApplicationVersion' :: Text
applicationName = Text
a} :: UpdateApplicationVersion)

-- | The name of the version to update.
--
-- If no application version is found with this label, @UpdateApplication@
-- returns an @InvalidParameterValue@ error.
updateApplicationVersion_versionLabel :: Lens.Lens' UpdateApplicationVersion Prelude.Text
updateApplicationVersion_versionLabel :: (Text -> f Text)
-> UpdateApplicationVersion -> f UpdateApplicationVersion
updateApplicationVersion_versionLabel = (UpdateApplicationVersion -> Text)
-> (UpdateApplicationVersion -> Text -> UpdateApplicationVersion)
-> Lens UpdateApplicationVersion UpdateApplicationVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateApplicationVersion' {Text
versionLabel :: Text
$sel:versionLabel:UpdateApplicationVersion' :: UpdateApplicationVersion -> Text
versionLabel} -> Text
versionLabel) (\s :: UpdateApplicationVersion
s@UpdateApplicationVersion' {} Text
a -> UpdateApplicationVersion
s {$sel:versionLabel:UpdateApplicationVersion' :: Text
versionLabel = Text
a} :: UpdateApplicationVersion)

instance Core.AWSRequest UpdateApplicationVersion where
  type
    AWSResponse UpdateApplicationVersion =
      ApplicationVersionDescriptionMessage
  request :: UpdateApplicationVersion -> Request UpdateApplicationVersion
request = Service
-> UpdateApplicationVersion -> Request UpdateApplicationVersion
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateApplicationVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateApplicationVersion)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse UpdateApplicationVersion))
-> Logger
-> Service
-> Proxy UpdateApplicationVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateApplicationVersion)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"UpdateApplicationVersionResult"
      (\Int
s ResponseHeaders
h [Node]
x -> [Node] -> Either String ApplicationVersionDescriptionMessage
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)

instance Prelude.Hashable UpdateApplicationVersion

instance Prelude.NFData UpdateApplicationVersion

instance Core.ToHeaders UpdateApplicationVersion where
  toHeaders :: UpdateApplicationVersion -> ResponseHeaders
toHeaders = ResponseHeaders -> UpdateApplicationVersion -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery UpdateApplicationVersion where
  toQuery :: UpdateApplicationVersion -> QueryString
toQuery UpdateApplicationVersion' {Maybe Text
Text
versionLabel :: Text
applicationName :: Text
description :: Maybe Text
$sel:versionLabel:UpdateApplicationVersion' :: UpdateApplicationVersion -> Text
$sel:applicationName:UpdateApplicationVersion' :: UpdateApplicationVersion -> Text
$sel:description:UpdateApplicationVersion' :: UpdateApplicationVersion -> 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
"UpdateApplicationVersion" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-12-01" :: Prelude.ByteString),
        ByteString
"Description" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
description,
        ByteString
"ApplicationName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
applicationName,
        ByteString
"VersionLabel" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
versionLabel
      ]