{-# 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.Proton.UpdateEnvironment
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Update an environment.
--
-- If the environment is associated with an environment account connection,
-- /don\'t/ update or include the @protonServiceRoleArn@ and
-- @provisioningRepository@ parameter to update or connect to an
-- environment account connection.
--
-- You can only update to a new environment account connection if that
-- connection was created in the same environment account that the current
-- environment account connection was created in. The account connection
-- must also be associated with the current environment.
--
-- If the environment /isn\'t/ associated with an environment account
-- connection, /don\'t/ update or include the
-- @environmentAccountConnectionId@ parameter. You /can\'t/ update or
-- connect the environment to an environment account connection if it
-- /isn\'t/ already associated with an environment connection.
--
-- You can update either the @environmentAccountConnectionId@ or
-- @protonServiceRoleArn@ parameter and value. You can’t update both.
--
-- If the environment was configured for Amazon Web Services-managed
-- provisioning, omit the @provisioningRepository@ parameter.
--
-- If the environment was configured for self-managed provisioning, specify
-- the @provisioningRepository@ parameter and omit the
-- @protonServiceRoleArn@ and @environmentAccountConnectionId@ parameters.
--
-- For more information, see
-- <https://docs.aws.amazon.com/proton/latest/userguide/ag-environments.html Environments>
-- and
-- <https://docs.aws.amazon.com/proton/latest/userguide/ag-works-prov-methods.html Provisioning methods>
-- in the /Proton User Guide/.
--
-- There are four modes for updating an environment. The @deploymentType@
-- field defines the mode.
--
-- []
--     @NONE@
--
--     In this mode, a deployment /doesn\'t/ occur. Only the requested
--     metadata parameters are updated.
--
-- []
--     @CURRENT_VERSION@
--
--     In this mode, the environment is deployed and updated with the new
--     spec that you provide. Only requested parameters are updated.
--     /Don’t/ include minor or major version parameters when you use this
--     @deployment-type@.
--
-- []
--     @MINOR_VERSION@
--
--     In this mode, the environment is deployed and updated with the
--     published, recommended (latest) minor version of the current major
--     version in use, by default. You can also specify a different minor
--     version of the current major version in use.
--
-- []
--     @MAJOR_VERSION@
--
--     In this mode, the environment is deployed and updated with the
--     published, recommended (latest) major and minor version of the
--     current template, by default. You can also specify a different major
--     version that\'s higher than the major version in use and a minor
--     version.
module Amazonka.Proton.UpdateEnvironment
  ( -- * Creating a Request
    UpdateEnvironment (..),
    newUpdateEnvironment,

    -- * Request Lenses
    updateEnvironment_codebuildRoleArn,
    updateEnvironment_componentRoleArn,
    updateEnvironment_description,
    updateEnvironment_environmentAccountConnectionId,
    updateEnvironment_protonServiceRoleArn,
    updateEnvironment_provisioningRepository,
    updateEnvironment_spec,
    updateEnvironment_templateMajorVersion,
    updateEnvironment_templateMinorVersion,
    updateEnvironment_deploymentType,
    updateEnvironment_name,

    -- * Destructuring the Response
    UpdateEnvironmentResponse (..),
    newUpdateEnvironmentResponse,

    -- * Response Lenses
    updateEnvironmentResponse_httpStatus,
    updateEnvironmentResponse_environment,
  )
where

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

-- | /See:/ 'newUpdateEnvironment' smart constructor.
data UpdateEnvironment = UpdateEnvironment'
  { -- | The Amazon Resource Name (ARN) of the IAM service role that allows
    -- Proton to provision infrastructure using CodeBuild-based provisioning on
    -- your behalf.
    UpdateEnvironment -> Maybe Text
codebuildRoleArn :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the IAM service role that Proton uses
    -- when provisioning directly defined components in this environment. It
    -- determines the scope of infrastructure that a component can provision.
    --
    -- The environment must have a @componentRoleArn@ to allow directly defined
    -- components to be associated with the environment.
    --
    -- For more information about components, see
    -- <https://docs.aws.amazon.com/proton/latest/userguide/ag-components.html Proton components>
    -- in the /Proton User Guide/.
    UpdateEnvironment -> Maybe Text
componentRoleArn :: Prelude.Maybe Prelude.Text,
    -- | A description of the environment update.
    UpdateEnvironment -> Maybe (Sensitive Text)
description :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The ID of the environment account connection.
    --
    -- You can only update to a new environment account connection if it was
    -- created in the same environment account that the current environment
    -- account connection was created in and is associated with the current
    -- environment.
    UpdateEnvironment -> Maybe Text
environmentAccountConnectionId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the Proton service role that allows
    -- Proton to make API calls to other services your behalf.
    UpdateEnvironment -> Maybe Text
protonServiceRoleArn :: Prelude.Maybe Prelude.Text,
    -- | The linked repository that you use to host your rendered infrastructure
    -- templates for self-managed provisioning. A linked repository is a
    -- repository that has been registered with Proton. For more information,
    -- see CreateRepository.
    UpdateEnvironment -> Maybe RepositoryBranchInput
provisioningRepository :: Prelude.Maybe RepositoryBranchInput,
    -- | The formatted specification that defines the update.
    UpdateEnvironment -> Maybe (Sensitive Text)
spec :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The major version of the environment to update.
    UpdateEnvironment -> Maybe Text
templateMajorVersion :: Prelude.Maybe Prelude.Text,
    -- | The minor version of the environment to update.
    UpdateEnvironment -> Maybe Text
templateMinorVersion :: Prelude.Maybe Prelude.Text,
    -- | There are four modes for updating an environment. The @deploymentType@
    -- field defines the mode.
    --
    -- []
    --     @NONE@
    --
    --     In this mode, a deployment /doesn\'t/ occur. Only the requested
    --     metadata parameters are updated.
    --
    -- []
    --     @CURRENT_VERSION@
    --
    --     In this mode, the environment is deployed and updated with the new
    --     spec that you provide. Only requested parameters are updated.
    --     /Don’t/ include major or minor version parameters when you use this
    --     @deployment-type@.
    --
    -- []
    --     @MINOR_VERSION@
    --
    --     In this mode, the environment is deployed and updated with the
    --     published, recommended (latest) minor version of the current major
    --     version in use, by default. You can also specify a different minor
    --     version of the current major version in use.
    --
    -- []
    --     @MAJOR_VERSION@
    --
    --     In this mode, the environment is deployed and updated with the
    --     published, recommended (latest) major and minor version of the
    --     current template, by default. You can also specify a different major
    --     version that is higher than the major version in use and a minor
    --     version (optional).
    UpdateEnvironment -> DeploymentUpdateType
deploymentType :: DeploymentUpdateType,
    -- | The name of the environment to update.
    UpdateEnvironment -> Text
name :: Prelude.Text
  }
  deriving (UpdateEnvironment -> UpdateEnvironment -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateEnvironment -> UpdateEnvironment -> Bool
$c/= :: UpdateEnvironment -> UpdateEnvironment -> Bool
== :: UpdateEnvironment -> UpdateEnvironment -> Bool
$c== :: UpdateEnvironment -> UpdateEnvironment -> Bool
Prelude.Eq, Int -> UpdateEnvironment -> ShowS
[UpdateEnvironment] -> ShowS
UpdateEnvironment -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateEnvironment] -> ShowS
$cshowList :: [UpdateEnvironment] -> ShowS
show :: UpdateEnvironment -> String
$cshow :: UpdateEnvironment -> String
showsPrec :: Int -> UpdateEnvironment -> ShowS
$cshowsPrec :: Int -> UpdateEnvironment -> ShowS
Prelude.Show, forall x. Rep UpdateEnvironment x -> UpdateEnvironment
forall x. UpdateEnvironment -> Rep UpdateEnvironment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateEnvironment x -> UpdateEnvironment
$cfrom :: forall x. UpdateEnvironment -> Rep UpdateEnvironment x
Prelude.Generic)

-- |
-- Create a value of 'UpdateEnvironment' 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:
--
-- 'codebuildRoleArn', 'updateEnvironment_codebuildRoleArn' - The Amazon Resource Name (ARN) of the IAM service role that allows
-- Proton to provision infrastructure using CodeBuild-based provisioning on
-- your behalf.
--
-- 'componentRoleArn', 'updateEnvironment_componentRoleArn' - The Amazon Resource Name (ARN) of the IAM service role that Proton uses
-- when provisioning directly defined components in this environment. It
-- determines the scope of infrastructure that a component can provision.
--
-- The environment must have a @componentRoleArn@ to allow directly defined
-- components to be associated with the environment.
--
-- For more information about components, see
-- <https://docs.aws.amazon.com/proton/latest/userguide/ag-components.html Proton components>
-- in the /Proton User Guide/.
--
-- 'description', 'updateEnvironment_description' - A description of the environment update.
--
-- 'environmentAccountConnectionId', 'updateEnvironment_environmentAccountConnectionId' - The ID of the environment account connection.
--
-- You can only update to a new environment account connection if it was
-- created in the same environment account that the current environment
-- account connection was created in and is associated with the current
-- environment.
--
-- 'protonServiceRoleArn', 'updateEnvironment_protonServiceRoleArn' - The Amazon Resource Name (ARN) of the Proton service role that allows
-- Proton to make API calls to other services your behalf.
--
-- 'provisioningRepository', 'updateEnvironment_provisioningRepository' - The linked repository that you use to host your rendered infrastructure
-- templates for self-managed provisioning. A linked repository is a
-- repository that has been registered with Proton. For more information,
-- see CreateRepository.
--
-- 'spec', 'updateEnvironment_spec' - The formatted specification that defines the update.
--
-- 'templateMajorVersion', 'updateEnvironment_templateMajorVersion' - The major version of the environment to update.
--
-- 'templateMinorVersion', 'updateEnvironment_templateMinorVersion' - The minor version of the environment to update.
--
-- 'deploymentType', 'updateEnvironment_deploymentType' - There are four modes for updating an environment. The @deploymentType@
-- field defines the mode.
--
-- []
--     @NONE@
--
--     In this mode, a deployment /doesn\'t/ occur. Only the requested
--     metadata parameters are updated.
--
-- []
--     @CURRENT_VERSION@
--
--     In this mode, the environment is deployed and updated with the new
--     spec that you provide. Only requested parameters are updated.
--     /Don’t/ include major or minor version parameters when you use this
--     @deployment-type@.
--
-- []
--     @MINOR_VERSION@
--
--     In this mode, the environment is deployed and updated with the
--     published, recommended (latest) minor version of the current major
--     version in use, by default. You can also specify a different minor
--     version of the current major version in use.
--
-- []
--     @MAJOR_VERSION@
--
--     In this mode, the environment is deployed and updated with the
--     published, recommended (latest) major and minor version of the
--     current template, by default. You can also specify a different major
--     version that is higher than the major version in use and a minor
--     version (optional).
--
-- 'name', 'updateEnvironment_name' - The name of the environment to update.
newUpdateEnvironment ::
  -- | 'deploymentType'
  DeploymentUpdateType ->
  -- | 'name'
  Prelude.Text ->
  UpdateEnvironment
newUpdateEnvironment :: DeploymentUpdateType -> Text -> UpdateEnvironment
newUpdateEnvironment DeploymentUpdateType
pDeploymentType_ Text
pName_ =
  UpdateEnvironment'
    { $sel:codebuildRoleArn:UpdateEnvironment' :: Maybe Text
codebuildRoleArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:componentRoleArn:UpdateEnvironment' :: Maybe Text
componentRoleArn = forall a. Maybe a
Prelude.Nothing,
      $sel:description:UpdateEnvironment' :: Maybe (Sensitive Text)
description = forall a. Maybe a
Prelude.Nothing,
      $sel:environmentAccountConnectionId:UpdateEnvironment' :: Maybe Text
environmentAccountConnectionId = forall a. Maybe a
Prelude.Nothing,
      $sel:protonServiceRoleArn:UpdateEnvironment' :: Maybe Text
protonServiceRoleArn = forall a. Maybe a
Prelude.Nothing,
      $sel:provisioningRepository:UpdateEnvironment' :: Maybe RepositoryBranchInput
provisioningRepository = forall a. Maybe a
Prelude.Nothing,
      $sel:spec:UpdateEnvironment' :: Maybe (Sensitive Text)
spec = forall a. Maybe a
Prelude.Nothing,
      $sel:templateMajorVersion:UpdateEnvironment' :: Maybe Text
templateMajorVersion = forall a. Maybe a
Prelude.Nothing,
      $sel:templateMinorVersion:UpdateEnvironment' :: Maybe Text
templateMinorVersion = forall a. Maybe a
Prelude.Nothing,
      $sel:deploymentType:UpdateEnvironment' :: DeploymentUpdateType
deploymentType = DeploymentUpdateType
pDeploymentType_,
      $sel:name:UpdateEnvironment' :: Text
name = Text
pName_
    }

-- | The Amazon Resource Name (ARN) of the IAM service role that allows
-- Proton to provision infrastructure using CodeBuild-based provisioning on
-- your behalf.
updateEnvironment_codebuildRoleArn :: Lens.Lens' UpdateEnvironment (Prelude.Maybe Prelude.Text)
updateEnvironment_codebuildRoleArn :: Lens' UpdateEnvironment (Maybe Text)
updateEnvironment_codebuildRoleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEnvironment' {Maybe Text
codebuildRoleArn :: Maybe Text
$sel:codebuildRoleArn:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
codebuildRoleArn} -> Maybe Text
codebuildRoleArn) (\s :: UpdateEnvironment
s@UpdateEnvironment' {} Maybe Text
a -> UpdateEnvironment
s {$sel:codebuildRoleArn:UpdateEnvironment' :: Maybe Text
codebuildRoleArn = Maybe Text
a} :: UpdateEnvironment)

-- | The Amazon Resource Name (ARN) of the IAM service role that Proton uses
-- when provisioning directly defined components in this environment. It
-- determines the scope of infrastructure that a component can provision.
--
-- The environment must have a @componentRoleArn@ to allow directly defined
-- components to be associated with the environment.
--
-- For more information about components, see
-- <https://docs.aws.amazon.com/proton/latest/userguide/ag-components.html Proton components>
-- in the /Proton User Guide/.
updateEnvironment_componentRoleArn :: Lens.Lens' UpdateEnvironment (Prelude.Maybe Prelude.Text)
updateEnvironment_componentRoleArn :: Lens' UpdateEnvironment (Maybe Text)
updateEnvironment_componentRoleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEnvironment' {Maybe Text
componentRoleArn :: Maybe Text
$sel:componentRoleArn:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
componentRoleArn} -> Maybe Text
componentRoleArn) (\s :: UpdateEnvironment
s@UpdateEnvironment' {} Maybe Text
a -> UpdateEnvironment
s {$sel:componentRoleArn:UpdateEnvironment' :: Maybe Text
componentRoleArn = Maybe Text
a} :: UpdateEnvironment)

-- | A description of the environment update.
updateEnvironment_description :: Lens.Lens' UpdateEnvironment (Prelude.Maybe Prelude.Text)
updateEnvironment_description :: Lens' UpdateEnvironment (Maybe Text)
updateEnvironment_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEnvironment' {Maybe (Sensitive Text)
description :: Maybe (Sensitive Text)
$sel:description:UpdateEnvironment' :: UpdateEnvironment -> Maybe (Sensitive Text)
description} -> Maybe (Sensitive Text)
description) (\s :: UpdateEnvironment
s@UpdateEnvironment' {} Maybe (Sensitive Text)
a -> UpdateEnvironment
s {$sel:description:UpdateEnvironment' :: Maybe (Sensitive Text)
description = Maybe (Sensitive Text)
a} :: UpdateEnvironment) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | The ID of the environment account connection.
--
-- You can only update to a new environment account connection if it was
-- created in the same environment account that the current environment
-- account connection was created in and is associated with the current
-- environment.
updateEnvironment_environmentAccountConnectionId :: Lens.Lens' UpdateEnvironment (Prelude.Maybe Prelude.Text)
updateEnvironment_environmentAccountConnectionId :: Lens' UpdateEnvironment (Maybe Text)
updateEnvironment_environmentAccountConnectionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEnvironment' {Maybe Text
environmentAccountConnectionId :: Maybe Text
$sel:environmentAccountConnectionId:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
environmentAccountConnectionId} -> Maybe Text
environmentAccountConnectionId) (\s :: UpdateEnvironment
s@UpdateEnvironment' {} Maybe Text
a -> UpdateEnvironment
s {$sel:environmentAccountConnectionId:UpdateEnvironment' :: Maybe Text
environmentAccountConnectionId = Maybe Text
a} :: UpdateEnvironment)

-- | The Amazon Resource Name (ARN) of the Proton service role that allows
-- Proton to make API calls to other services your behalf.
updateEnvironment_protonServiceRoleArn :: Lens.Lens' UpdateEnvironment (Prelude.Maybe Prelude.Text)
updateEnvironment_protonServiceRoleArn :: Lens' UpdateEnvironment (Maybe Text)
updateEnvironment_protonServiceRoleArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEnvironment' {Maybe Text
protonServiceRoleArn :: Maybe Text
$sel:protonServiceRoleArn:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
protonServiceRoleArn} -> Maybe Text
protonServiceRoleArn) (\s :: UpdateEnvironment
s@UpdateEnvironment' {} Maybe Text
a -> UpdateEnvironment
s {$sel:protonServiceRoleArn:UpdateEnvironment' :: Maybe Text
protonServiceRoleArn = Maybe Text
a} :: UpdateEnvironment)

-- | The linked repository that you use to host your rendered infrastructure
-- templates for self-managed provisioning. A linked repository is a
-- repository that has been registered with Proton. For more information,
-- see CreateRepository.
updateEnvironment_provisioningRepository :: Lens.Lens' UpdateEnvironment (Prelude.Maybe RepositoryBranchInput)
updateEnvironment_provisioningRepository :: Lens' UpdateEnvironment (Maybe RepositoryBranchInput)
updateEnvironment_provisioningRepository = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEnvironment' {Maybe RepositoryBranchInput
provisioningRepository :: Maybe RepositoryBranchInput
$sel:provisioningRepository:UpdateEnvironment' :: UpdateEnvironment -> Maybe RepositoryBranchInput
provisioningRepository} -> Maybe RepositoryBranchInput
provisioningRepository) (\s :: UpdateEnvironment
s@UpdateEnvironment' {} Maybe RepositoryBranchInput
a -> UpdateEnvironment
s {$sel:provisioningRepository:UpdateEnvironment' :: Maybe RepositoryBranchInput
provisioningRepository = Maybe RepositoryBranchInput
a} :: UpdateEnvironment)

-- | The formatted specification that defines the update.
updateEnvironment_spec :: Lens.Lens' UpdateEnvironment (Prelude.Maybe Prelude.Text)
updateEnvironment_spec :: Lens' UpdateEnvironment (Maybe Text)
updateEnvironment_spec = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEnvironment' {Maybe (Sensitive Text)
spec :: Maybe (Sensitive Text)
$sel:spec:UpdateEnvironment' :: UpdateEnvironment -> Maybe (Sensitive Text)
spec} -> Maybe (Sensitive Text)
spec) (\s :: UpdateEnvironment
s@UpdateEnvironment' {} Maybe (Sensitive Text)
a -> UpdateEnvironment
s {$sel:spec:UpdateEnvironment' :: Maybe (Sensitive Text)
spec = Maybe (Sensitive Text)
a} :: UpdateEnvironment) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | The major version of the environment to update.
updateEnvironment_templateMajorVersion :: Lens.Lens' UpdateEnvironment (Prelude.Maybe Prelude.Text)
updateEnvironment_templateMajorVersion :: Lens' UpdateEnvironment (Maybe Text)
updateEnvironment_templateMajorVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEnvironment' {Maybe Text
templateMajorVersion :: Maybe Text
$sel:templateMajorVersion:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
templateMajorVersion} -> Maybe Text
templateMajorVersion) (\s :: UpdateEnvironment
s@UpdateEnvironment' {} Maybe Text
a -> UpdateEnvironment
s {$sel:templateMajorVersion:UpdateEnvironment' :: Maybe Text
templateMajorVersion = Maybe Text
a} :: UpdateEnvironment)

-- | The minor version of the environment to update.
updateEnvironment_templateMinorVersion :: Lens.Lens' UpdateEnvironment (Prelude.Maybe Prelude.Text)
updateEnvironment_templateMinorVersion :: Lens' UpdateEnvironment (Maybe Text)
updateEnvironment_templateMinorVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEnvironment' {Maybe Text
templateMinorVersion :: Maybe Text
$sel:templateMinorVersion:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
templateMinorVersion} -> Maybe Text
templateMinorVersion) (\s :: UpdateEnvironment
s@UpdateEnvironment' {} Maybe Text
a -> UpdateEnvironment
s {$sel:templateMinorVersion:UpdateEnvironment' :: Maybe Text
templateMinorVersion = Maybe Text
a} :: UpdateEnvironment)

-- | There are four modes for updating an environment. The @deploymentType@
-- field defines the mode.
--
-- []
--     @NONE@
--
--     In this mode, a deployment /doesn\'t/ occur. Only the requested
--     metadata parameters are updated.
--
-- []
--     @CURRENT_VERSION@
--
--     In this mode, the environment is deployed and updated with the new
--     spec that you provide. Only requested parameters are updated.
--     /Don’t/ include major or minor version parameters when you use this
--     @deployment-type@.
--
-- []
--     @MINOR_VERSION@
--
--     In this mode, the environment is deployed and updated with the
--     published, recommended (latest) minor version of the current major
--     version in use, by default. You can also specify a different minor
--     version of the current major version in use.
--
-- []
--     @MAJOR_VERSION@
--
--     In this mode, the environment is deployed and updated with the
--     published, recommended (latest) major and minor version of the
--     current template, by default. You can also specify a different major
--     version that is higher than the major version in use and a minor
--     version (optional).
updateEnvironment_deploymentType :: Lens.Lens' UpdateEnvironment DeploymentUpdateType
updateEnvironment_deploymentType :: Lens' UpdateEnvironment DeploymentUpdateType
updateEnvironment_deploymentType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEnvironment' {DeploymentUpdateType
deploymentType :: DeploymentUpdateType
$sel:deploymentType:UpdateEnvironment' :: UpdateEnvironment -> DeploymentUpdateType
deploymentType} -> DeploymentUpdateType
deploymentType) (\s :: UpdateEnvironment
s@UpdateEnvironment' {} DeploymentUpdateType
a -> UpdateEnvironment
s {$sel:deploymentType:UpdateEnvironment' :: DeploymentUpdateType
deploymentType = DeploymentUpdateType
a} :: UpdateEnvironment)

-- | The name of the environment to update.
updateEnvironment_name :: Lens.Lens' UpdateEnvironment Prelude.Text
updateEnvironment_name :: Lens' UpdateEnvironment Text
updateEnvironment_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEnvironment' {Text
name :: Text
$sel:name:UpdateEnvironment' :: UpdateEnvironment -> Text
name} -> Text
name) (\s :: UpdateEnvironment
s@UpdateEnvironment' {} Text
a -> UpdateEnvironment
s {$sel:name:UpdateEnvironment' :: Text
name = Text
a} :: UpdateEnvironment)

instance Core.AWSRequest UpdateEnvironment where
  type
    AWSResponse UpdateEnvironment =
      UpdateEnvironmentResponse
  request :: (Service -> Service)
-> UpdateEnvironment -> Request UpdateEnvironment
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateEnvironment
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateEnvironment)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> Environment -> UpdateEnvironmentResponse
UpdateEnvironmentResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"environment")
      )

instance Prelude.Hashable UpdateEnvironment where
  hashWithSalt :: Int -> UpdateEnvironment -> Int
hashWithSalt Int
_salt UpdateEnvironment' {Maybe Text
Maybe (Sensitive Text)
Maybe RepositoryBranchInput
Text
DeploymentUpdateType
name :: Text
deploymentType :: DeploymentUpdateType
templateMinorVersion :: Maybe Text
templateMajorVersion :: Maybe Text
spec :: Maybe (Sensitive Text)
provisioningRepository :: Maybe RepositoryBranchInput
protonServiceRoleArn :: Maybe Text
environmentAccountConnectionId :: Maybe Text
description :: Maybe (Sensitive Text)
componentRoleArn :: Maybe Text
codebuildRoleArn :: Maybe Text
$sel:name:UpdateEnvironment' :: UpdateEnvironment -> Text
$sel:deploymentType:UpdateEnvironment' :: UpdateEnvironment -> DeploymentUpdateType
$sel:templateMinorVersion:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
$sel:templateMajorVersion:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
$sel:spec:UpdateEnvironment' :: UpdateEnvironment -> Maybe (Sensitive Text)
$sel:provisioningRepository:UpdateEnvironment' :: UpdateEnvironment -> Maybe RepositoryBranchInput
$sel:protonServiceRoleArn:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
$sel:environmentAccountConnectionId:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
$sel:description:UpdateEnvironment' :: UpdateEnvironment -> Maybe (Sensitive Text)
$sel:componentRoleArn:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
$sel:codebuildRoleArn:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
codebuildRoleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
componentRoleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
environmentAccountConnectionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
protonServiceRoleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RepositoryBranchInput
provisioningRepository
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
spec
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
templateMajorVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
templateMinorVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` DeploymentUpdateType
deploymentType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData UpdateEnvironment where
  rnf :: UpdateEnvironment -> ()
rnf UpdateEnvironment' {Maybe Text
Maybe (Sensitive Text)
Maybe RepositoryBranchInput
Text
DeploymentUpdateType
name :: Text
deploymentType :: DeploymentUpdateType
templateMinorVersion :: Maybe Text
templateMajorVersion :: Maybe Text
spec :: Maybe (Sensitive Text)
provisioningRepository :: Maybe RepositoryBranchInput
protonServiceRoleArn :: Maybe Text
environmentAccountConnectionId :: Maybe Text
description :: Maybe (Sensitive Text)
componentRoleArn :: Maybe Text
codebuildRoleArn :: Maybe Text
$sel:name:UpdateEnvironment' :: UpdateEnvironment -> Text
$sel:deploymentType:UpdateEnvironment' :: UpdateEnvironment -> DeploymentUpdateType
$sel:templateMinorVersion:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
$sel:templateMajorVersion:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
$sel:spec:UpdateEnvironment' :: UpdateEnvironment -> Maybe (Sensitive Text)
$sel:provisioningRepository:UpdateEnvironment' :: UpdateEnvironment -> Maybe RepositoryBranchInput
$sel:protonServiceRoleArn:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
$sel:environmentAccountConnectionId:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
$sel:description:UpdateEnvironment' :: UpdateEnvironment -> Maybe (Sensitive Text)
$sel:componentRoleArn:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
$sel:codebuildRoleArn:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
codebuildRoleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
componentRoleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
environmentAccountConnectionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
protonServiceRoleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RepositoryBranchInput
provisioningRepository
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
spec
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
templateMajorVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
templateMinorVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf DeploymentUpdateType
deploymentType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToHeaders UpdateEnvironment where
  toHeaders :: UpdateEnvironment -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AwsProton20200720.UpdateEnvironment" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON UpdateEnvironment where
  toJSON :: UpdateEnvironment -> Value
toJSON UpdateEnvironment' {Maybe Text
Maybe (Sensitive Text)
Maybe RepositoryBranchInput
Text
DeploymentUpdateType
name :: Text
deploymentType :: DeploymentUpdateType
templateMinorVersion :: Maybe Text
templateMajorVersion :: Maybe Text
spec :: Maybe (Sensitive Text)
provisioningRepository :: Maybe RepositoryBranchInput
protonServiceRoleArn :: Maybe Text
environmentAccountConnectionId :: Maybe Text
description :: Maybe (Sensitive Text)
componentRoleArn :: Maybe Text
codebuildRoleArn :: Maybe Text
$sel:name:UpdateEnvironment' :: UpdateEnvironment -> Text
$sel:deploymentType:UpdateEnvironment' :: UpdateEnvironment -> DeploymentUpdateType
$sel:templateMinorVersion:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
$sel:templateMajorVersion:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
$sel:spec:UpdateEnvironment' :: UpdateEnvironment -> Maybe (Sensitive Text)
$sel:provisioningRepository:UpdateEnvironment' :: UpdateEnvironment -> Maybe RepositoryBranchInput
$sel:protonServiceRoleArn:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
$sel:environmentAccountConnectionId:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
$sel:description:UpdateEnvironment' :: UpdateEnvironment -> Maybe (Sensitive Text)
$sel:componentRoleArn:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
$sel:codebuildRoleArn:UpdateEnvironment' :: UpdateEnvironment -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"codebuildRoleArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
codebuildRoleArn,
            (Key
"componentRoleArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
componentRoleArn,
            (Key
"description" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
description,
            (Key
"environmentAccountConnectionId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
environmentAccountConnectionId,
            (Key
"protonServiceRoleArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
protonServiceRoleArn,
            (Key
"provisioningRepository" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RepositoryBranchInput
provisioningRepository,
            (Key
"spec" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
spec,
            (Key
"templateMajorVersion" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
templateMajorVersion,
            (Key
"templateMinorVersion" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
templateMinorVersion,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"deploymentType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= DeploymentUpdateType
deploymentType),
            forall a. a -> Maybe a
Prelude.Just (Key
"name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)
          ]
      )

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

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

-- | /See:/ 'newUpdateEnvironmentResponse' smart constructor.
data UpdateEnvironmentResponse = UpdateEnvironmentResponse'
  { -- | The response's http status code.
    UpdateEnvironmentResponse -> Int
httpStatus :: Prelude.Int,
    -- | The environment detail data that\'s returned by Proton.
    UpdateEnvironmentResponse -> Environment
environment :: Environment
  }
  deriving (UpdateEnvironmentResponse -> UpdateEnvironmentResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateEnvironmentResponse -> UpdateEnvironmentResponse -> Bool
$c/= :: UpdateEnvironmentResponse -> UpdateEnvironmentResponse -> Bool
== :: UpdateEnvironmentResponse -> UpdateEnvironmentResponse -> Bool
$c== :: UpdateEnvironmentResponse -> UpdateEnvironmentResponse -> Bool
Prelude.Eq, Int -> UpdateEnvironmentResponse -> ShowS
[UpdateEnvironmentResponse] -> ShowS
UpdateEnvironmentResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateEnvironmentResponse] -> ShowS
$cshowList :: [UpdateEnvironmentResponse] -> ShowS
show :: UpdateEnvironmentResponse -> String
$cshow :: UpdateEnvironmentResponse -> String
showsPrec :: Int -> UpdateEnvironmentResponse -> ShowS
$cshowsPrec :: Int -> UpdateEnvironmentResponse -> ShowS
Prelude.Show, forall x.
Rep UpdateEnvironmentResponse x -> UpdateEnvironmentResponse
forall x.
UpdateEnvironmentResponse -> Rep UpdateEnvironmentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateEnvironmentResponse x -> UpdateEnvironmentResponse
$cfrom :: forall x.
UpdateEnvironmentResponse -> Rep UpdateEnvironmentResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateEnvironmentResponse' 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:
--
-- 'httpStatus', 'updateEnvironmentResponse_httpStatus' - The response's http status code.
--
-- 'environment', 'updateEnvironmentResponse_environment' - The environment detail data that\'s returned by Proton.
newUpdateEnvironmentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'environment'
  Environment ->
  UpdateEnvironmentResponse
newUpdateEnvironmentResponse :: Int -> Environment -> UpdateEnvironmentResponse
newUpdateEnvironmentResponse
  Int
pHttpStatus_
  Environment
pEnvironment_ =
    UpdateEnvironmentResponse'
      { $sel:httpStatus:UpdateEnvironmentResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:environment:UpdateEnvironmentResponse' :: Environment
environment = Environment
pEnvironment_
      }

-- | The response's http status code.
updateEnvironmentResponse_httpStatus :: Lens.Lens' UpdateEnvironmentResponse Prelude.Int
updateEnvironmentResponse_httpStatus :: Lens' UpdateEnvironmentResponse Int
updateEnvironmentResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEnvironmentResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateEnvironmentResponse' :: UpdateEnvironmentResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateEnvironmentResponse
s@UpdateEnvironmentResponse' {} Int
a -> UpdateEnvironmentResponse
s {$sel:httpStatus:UpdateEnvironmentResponse' :: Int
httpStatus = Int
a} :: UpdateEnvironmentResponse)

-- | The environment detail data that\'s returned by Proton.
updateEnvironmentResponse_environment :: Lens.Lens' UpdateEnvironmentResponse Environment
updateEnvironmentResponse_environment :: Lens' UpdateEnvironmentResponse Environment
updateEnvironmentResponse_environment = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEnvironmentResponse' {Environment
environment :: Environment
$sel:environment:UpdateEnvironmentResponse' :: UpdateEnvironmentResponse -> Environment
environment} -> Environment
environment) (\s :: UpdateEnvironmentResponse
s@UpdateEnvironmentResponse' {} Environment
a -> UpdateEnvironmentResponse
s {$sel:environment:UpdateEnvironmentResponse' :: Environment
environment = Environment
a} :: UpdateEnvironmentResponse)

instance Prelude.NFData UpdateEnvironmentResponse where
  rnf :: UpdateEnvironmentResponse -> ()
rnf UpdateEnvironmentResponse' {Int
Environment
environment :: Environment
httpStatus :: Int
$sel:environment:UpdateEnvironmentResponse' :: UpdateEnvironmentResponse -> Environment
$sel:httpStatus:UpdateEnvironmentResponse' :: UpdateEnvironmentResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Environment
environment