{-# 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.CodeDeploy.CreateDeployment
-- 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)
--
-- Deploys an application revision through the specified deployment group.
module Amazonka.CodeDeploy.CreateDeployment
  ( -- * Creating a Request
    CreateDeployment (..),
    newCreateDeployment,

    -- * Request Lenses
    createDeployment_deploymentConfigName,
    createDeployment_fileExistsBehavior,
    createDeployment_targetInstances,
    createDeployment_revision,
    createDeployment_description,
    createDeployment_autoRollbackConfiguration,
    createDeployment_updateOutdatedInstancesOnly,
    createDeployment_deploymentGroupName,
    createDeployment_ignoreApplicationStopFailures,
    createDeployment_applicationName,

    -- * Destructuring the Response
    CreateDeploymentResponse (..),
    newCreateDeploymentResponse,

    -- * Response Lenses
    createDeploymentResponse_deploymentId,
    createDeploymentResponse_httpStatus,
  )
where

import Amazonka.CodeDeploy.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Represents the input of a @CreateDeployment@ operation.
--
-- /See:/ 'newCreateDeployment' smart constructor.
data CreateDeployment = CreateDeployment'
  { -- | The name of a deployment configuration associated with the IAM user or
    -- AWS account.
    --
    -- If not specified, the value configured in the deployment group is used
    -- as the default. If the deployment group does not have a deployment
    -- configuration associated with it, @CodeDeployDefault@.@OneAtATime@ is
    -- used by default.
    CreateDeployment -> Maybe Text
deploymentConfigName :: Prelude.Maybe Prelude.Text,
    -- | Information about how AWS CodeDeploy handles files that already exist in
    -- a deployment target location but weren\'t part of the previous
    -- successful deployment.
    --
    -- The @fileExistsBehavior@ parameter takes any of the following values:
    --
    -- -   DISALLOW: The deployment fails. This is also the default behavior if
    --     no option is specified.
    --
    -- -   OVERWRITE: The version of the file from the application revision
    --     currently being deployed replaces the version already on the
    --     instance.
    --
    -- -   RETAIN: The version of the file already on the instance is kept and
    --     used as part of the new deployment.
    CreateDeployment -> Maybe FileExistsBehavior
fileExistsBehavior :: Prelude.Maybe FileExistsBehavior,
    -- | Information about the instances that belong to the replacement
    -- environment in a blue\/green deployment.
    CreateDeployment -> Maybe TargetInstances
targetInstances :: Prelude.Maybe TargetInstances,
    -- | The type and location of the revision to deploy.
    CreateDeployment -> Maybe RevisionLocation
revision :: Prelude.Maybe RevisionLocation,
    -- | A comment about the deployment.
    CreateDeployment -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | Configuration information for an automatic rollback that is added when a
    -- deployment is created.
    CreateDeployment -> Maybe AutoRollbackConfiguration
autoRollbackConfiguration :: Prelude.Maybe AutoRollbackConfiguration,
    -- | Indicates whether to deploy to all instances or only to instances that
    -- are not running the latest application revision.
    CreateDeployment -> Maybe Bool
updateOutdatedInstancesOnly :: Prelude.Maybe Prelude.Bool,
    -- | The name of the deployment group.
    CreateDeployment -> Maybe Text
deploymentGroupName :: Prelude.Maybe Prelude.Text,
    -- | If true, then if an @ApplicationStop@, @BeforeBlockTraffic@, or
    -- @AfterBlockTraffic@ deployment lifecycle event to an instance fails,
    -- then the deployment continues to the next deployment lifecycle event.
    -- For example, if @ApplicationStop@ fails, the deployment continues with
    -- @DownloadBundle@. If @BeforeBlockTraffic@ fails, the deployment
    -- continues with @BlockTraffic@. If @AfterBlockTraffic@ fails, the
    -- deployment continues with @ApplicationStop@.
    --
    -- If false or not specified, then if a lifecycle event fails during a
    -- deployment to an instance, that deployment fails. If deployment to that
    -- instance is part of an overall deployment and the number of healthy
    -- hosts is not less than the minimum number of healthy hosts, then a
    -- deployment to the next instance is attempted.
    --
    -- During a deployment, the AWS CodeDeploy agent runs the scripts specified
    -- for @ApplicationStop@, @BeforeBlockTraffic@, and @AfterBlockTraffic@ in
    -- the AppSpec file from the previous successful deployment. (All other
    -- scripts are run from the AppSpec file in the current deployment.) If one
    -- of these scripts contains an error and does not run successfully, the
    -- deployment can fail.
    --
    -- If the cause of the failure is a script from the last successful
    -- deployment that will never run successfully, create a new deployment and
    -- use @ignoreApplicationStopFailures@ to specify that the
    -- @ApplicationStop@, @BeforeBlockTraffic@, and @AfterBlockTraffic@
    -- failures should be ignored.
    CreateDeployment -> Maybe Bool
ignoreApplicationStopFailures :: Prelude.Maybe Prelude.Bool,
    -- | The name of an AWS CodeDeploy application associated with the IAM user
    -- or AWS account.
    CreateDeployment -> Text
applicationName :: Prelude.Text
  }
  deriving (CreateDeployment -> CreateDeployment -> Bool
(CreateDeployment -> CreateDeployment -> Bool)
-> (CreateDeployment -> CreateDeployment -> Bool)
-> Eq CreateDeployment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDeployment -> CreateDeployment -> Bool
$c/= :: CreateDeployment -> CreateDeployment -> Bool
== :: CreateDeployment -> CreateDeployment -> Bool
$c== :: CreateDeployment -> CreateDeployment -> Bool
Prelude.Eq, ReadPrec [CreateDeployment]
ReadPrec CreateDeployment
Int -> ReadS CreateDeployment
ReadS [CreateDeployment]
(Int -> ReadS CreateDeployment)
-> ReadS [CreateDeployment]
-> ReadPrec CreateDeployment
-> ReadPrec [CreateDeployment]
-> Read CreateDeployment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDeployment]
$creadListPrec :: ReadPrec [CreateDeployment]
readPrec :: ReadPrec CreateDeployment
$creadPrec :: ReadPrec CreateDeployment
readList :: ReadS [CreateDeployment]
$creadList :: ReadS [CreateDeployment]
readsPrec :: Int -> ReadS CreateDeployment
$creadsPrec :: Int -> ReadS CreateDeployment
Prelude.Read, Int -> CreateDeployment -> ShowS
[CreateDeployment] -> ShowS
CreateDeployment -> String
(Int -> CreateDeployment -> ShowS)
-> (CreateDeployment -> String)
-> ([CreateDeployment] -> ShowS)
-> Show CreateDeployment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDeployment] -> ShowS
$cshowList :: [CreateDeployment] -> ShowS
show :: CreateDeployment -> String
$cshow :: CreateDeployment -> String
showsPrec :: Int -> CreateDeployment -> ShowS
$cshowsPrec :: Int -> CreateDeployment -> ShowS
Prelude.Show, (forall x. CreateDeployment -> Rep CreateDeployment x)
-> (forall x. Rep CreateDeployment x -> CreateDeployment)
-> Generic CreateDeployment
forall x. Rep CreateDeployment x -> CreateDeployment
forall x. CreateDeployment -> Rep CreateDeployment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateDeployment x -> CreateDeployment
$cfrom :: forall x. CreateDeployment -> Rep CreateDeployment x
Prelude.Generic)

-- |
-- Create a value of 'CreateDeployment' 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:
--
-- 'deploymentConfigName', 'createDeployment_deploymentConfigName' - The name of a deployment configuration associated with the IAM user or
-- AWS account.
--
-- If not specified, the value configured in the deployment group is used
-- as the default. If the deployment group does not have a deployment
-- configuration associated with it, @CodeDeployDefault@.@OneAtATime@ is
-- used by default.
--
-- 'fileExistsBehavior', 'createDeployment_fileExistsBehavior' - Information about how AWS CodeDeploy handles files that already exist in
-- a deployment target location but weren\'t part of the previous
-- successful deployment.
--
-- The @fileExistsBehavior@ parameter takes any of the following values:
--
-- -   DISALLOW: The deployment fails. This is also the default behavior if
--     no option is specified.
--
-- -   OVERWRITE: The version of the file from the application revision
--     currently being deployed replaces the version already on the
--     instance.
--
-- -   RETAIN: The version of the file already on the instance is kept and
--     used as part of the new deployment.
--
-- 'targetInstances', 'createDeployment_targetInstances' - Information about the instances that belong to the replacement
-- environment in a blue\/green deployment.
--
-- 'revision', 'createDeployment_revision' - The type and location of the revision to deploy.
--
-- 'description', 'createDeployment_description' - A comment about the deployment.
--
-- 'autoRollbackConfiguration', 'createDeployment_autoRollbackConfiguration' - Configuration information for an automatic rollback that is added when a
-- deployment is created.
--
-- 'updateOutdatedInstancesOnly', 'createDeployment_updateOutdatedInstancesOnly' - Indicates whether to deploy to all instances or only to instances that
-- are not running the latest application revision.
--
-- 'deploymentGroupName', 'createDeployment_deploymentGroupName' - The name of the deployment group.
--
-- 'ignoreApplicationStopFailures', 'createDeployment_ignoreApplicationStopFailures' - If true, then if an @ApplicationStop@, @BeforeBlockTraffic@, or
-- @AfterBlockTraffic@ deployment lifecycle event to an instance fails,
-- then the deployment continues to the next deployment lifecycle event.
-- For example, if @ApplicationStop@ fails, the deployment continues with
-- @DownloadBundle@. If @BeforeBlockTraffic@ fails, the deployment
-- continues with @BlockTraffic@. If @AfterBlockTraffic@ fails, the
-- deployment continues with @ApplicationStop@.
--
-- If false or not specified, then if a lifecycle event fails during a
-- deployment to an instance, that deployment fails. If deployment to that
-- instance is part of an overall deployment and the number of healthy
-- hosts is not less than the minimum number of healthy hosts, then a
-- deployment to the next instance is attempted.
--
-- During a deployment, the AWS CodeDeploy agent runs the scripts specified
-- for @ApplicationStop@, @BeforeBlockTraffic@, and @AfterBlockTraffic@ in
-- the AppSpec file from the previous successful deployment. (All other
-- scripts are run from the AppSpec file in the current deployment.) If one
-- of these scripts contains an error and does not run successfully, the
-- deployment can fail.
--
-- If the cause of the failure is a script from the last successful
-- deployment that will never run successfully, create a new deployment and
-- use @ignoreApplicationStopFailures@ to specify that the
-- @ApplicationStop@, @BeforeBlockTraffic@, and @AfterBlockTraffic@
-- failures should be ignored.
--
-- 'applicationName', 'createDeployment_applicationName' - The name of an AWS CodeDeploy application associated with the IAM user
-- or AWS account.
newCreateDeployment ::
  -- | 'applicationName'
  Prelude.Text ->
  CreateDeployment
newCreateDeployment :: Text -> CreateDeployment
newCreateDeployment Text
pApplicationName_ =
  CreateDeployment' :: Maybe Text
-> Maybe FileExistsBehavior
-> Maybe TargetInstances
-> Maybe RevisionLocation
-> Maybe Text
-> Maybe AutoRollbackConfiguration
-> Maybe Bool
-> Maybe Text
-> Maybe Bool
-> Text
-> CreateDeployment
CreateDeployment'
    { $sel:deploymentConfigName:CreateDeployment' :: Maybe Text
deploymentConfigName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:fileExistsBehavior:CreateDeployment' :: Maybe FileExistsBehavior
fileExistsBehavior = Maybe FileExistsBehavior
forall a. Maybe a
Prelude.Nothing,
      $sel:targetInstances:CreateDeployment' :: Maybe TargetInstances
targetInstances = Maybe TargetInstances
forall a. Maybe a
Prelude.Nothing,
      $sel:revision:CreateDeployment' :: Maybe RevisionLocation
revision = Maybe RevisionLocation
forall a. Maybe a
Prelude.Nothing,
      $sel:description:CreateDeployment' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:autoRollbackConfiguration:CreateDeployment' :: Maybe AutoRollbackConfiguration
autoRollbackConfiguration = Maybe AutoRollbackConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:updateOutdatedInstancesOnly:CreateDeployment' :: Maybe Bool
updateOutdatedInstancesOnly = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:deploymentGroupName:CreateDeployment' :: Maybe Text
deploymentGroupName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ignoreApplicationStopFailures:CreateDeployment' :: Maybe Bool
ignoreApplicationStopFailures = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:applicationName:CreateDeployment' :: Text
applicationName = Text
pApplicationName_
    }

-- | The name of a deployment configuration associated with the IAM user or
-- AWS account.
--
-- If not specified, the value configured in the deployment group is used
-- as the default. If the deployment group does not have a deployment
-- configuration associated with it, @CodeDeployDefault@.@OneAtATime@ is
-- used by default.
createDeployment_deploymentConfigName :: Lens.Lens' CreateDeployment (Prelude.Maybe Prelude.Text)
createDeployment_deploymentConfigName :: (Maybe Text -> f (Maybe Text))
-> CreateDeployment -> f CreateDeployment
createDeployment_deploymentConfigName = (CreateDeployment -> Maybe Text)
-> (CreateDeployment -> Maybe Text -> CreateDeployment)
-> Lens CreateDeployment CreateDeployment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDeployment' {Maybe Text
deploymentConfigName :: Maybe Text
$sel:deploymentConfigName:CreateDeployment' :: CreateDeployment -> Maybe Text
deploymentConfigName} -> Maybe Text
deploymentConfigName) (\s :: CreateDeployment
s@CreateDeployment' {} Maybe Text
a -> CreateDeployment
s {$sel:deploymentConfigName:CreateDeployment' :: Maybe Text
deploymentConfigName = Maybe Text
a} :: CreateDeployment)

-- | Information about how AWS CodeDeploy handles files that already exist in
-- a deployment target location but weren\'t part of the previous
-- successful deployment.
--
-- The @fileExistsBehavior@ parameter takes any of the following values:
--
-- -   DISALLOW: The deployment fails. This is also the default behavior if
--     no option is specified.
--
-- -   OVERWRITE: The version of the file from the application revision
--     currently being deployed replaces the version already on the
--     instance.
--
-- -   RETAIN: The version of the file already on the instance is kept and
--     used as part of the new deployment.
createDeployment_fileExistsBehavior :: Lens.Lens' CreateDeployment (Prelude.Maybe FileExistsBehavior)
createDeployment_fileExistsBehavior :: (Maybe FileExistsBehavior -> f (Maybe FileExistsBehavior))
-> CreateDeployment -> f CreateDeployment
createDeployment_fileExistsBehavior = (CreateDeployment -> Maybe FileExistsBehavior)
-> (CreateDeployment
    -> Maybe FileExistsBehavior -> CreateDeployment)
-> Lens
     CreateDeployment
     CreateDeployment
     (Maybe FileExistsBehavior)
     (Maybe FileExistsBehavior)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDeployment' {Maybe FileExistsBehavior
fileExistsBehavior :: Maybe FileExistsBehavior
$sel:fileExistsBehavior:CreateDeployment' :: CreateDeployment -> Maybe FileExistsBehavior
fileExistsBehavior} -> Maybe FileExistsBehavior
fileExistsBehavior) (\s :: CreateDeployment
s@CreateDeployment' {} Maybe FileExistsBehavior
a -> CreateDeployment
s {$sel:fileExistsBehavior:CreateDeployment' :: Maybe FileExistsBehavior
fileExistsBehavior = Maybe FileExistsBehavior
a} :: CreateDeployment)

-- | Information about the instances that belong to the replacement
-- environment in a blue\/green deployment.
createDeployment_targetInstances :: Lens.Lens' CreateDeployment (Prelude.Maybe TargetInstances)
createDeployment_targetInstances :: (Maybe TargetInstances -> f (Maybe TargetInstances))
-> CreateDeployment -> f CreateDeployment
createDeployment_targetInstances = (CreateDeployment -> Maybe TargetInstances)
-> (CreateDeployment -> Maybe TargetInstances -> CreateDeployment)
-> Lens
     CreateDeployment
     CreateDeployment
     (Maybe TargetInstances)
     (Maybe TargetInstances)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDeployment' {Maybe TargetInstances
targetInstances :: Maybe TargetInstances
$sel:targetInstances:CreateDeployment' :: CreateDeployment -> Maybe TargetInstances
targetInstances} -> Maybe TargetInstances
targetInstances) (\s :: CreateDeployment
s@CreateDeployment' {} Maybe TargetInstances
a -> CreateDeployment
s {$sel:targetInstances:CreateDeployment' :: Maybe TargetInstances
targetInstances = Maybe TargetInstances
a} :: CreateDeployment)

-- | The type and location of the revision to deploy.
createDeployment_revision :: Lens.Lens' CreateDeployment (Prelude.Maybe RevisionLocation)
createDeployment_revision :: (Maybe RevisionLocation -> f (Maybe RevisionLocation))
-> CreateDeployment -> f CreateDeployment
createDeployment_revision = (CreateDeployment -> Maybe RevisionLocation)
-> (CreateDeployment -> Maybe RevisionLocation -> CreateDeployment)
-> Lens
     CreateDeployment
     CreateDeployment
     (Maybe RevisionLocation)
     (Maybe RevisionLocation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDeployment' {Maybe RevisionLocation
revision :: Maybe RevisionLocation
$sel:revision:CreateDeployment' :: CreateDeployment -> Maybe RevisionLocation
revision} -> Maybe RevisionLocation
revision) (\s :: CreateDeployment
s@CreateDeployment' {} Maybe RevisionLocation
a -> CreateDeployment
s {$sel:revision:CreateDeployment' :: Maybe RevisionLocation
revision = Maybe RevisionLocation
a} :: CreateDeployment)

-- | A comment about the deployment.
createDeployment_description :: Lens.Lens' CreateDeployment (Prelude.Maybe Prelude.Text)
createDeployment_description :: (Maybe Text -> f (Maybe Text))
-> CreateDeployment -> f CreateDeployment
createDeployment_description = (CreateDeployment -> Maybe Text)
-> (CreateDeployment -> Maybe Text -> CreateDeployment)
-> Lens CreateDeployment CreateDeployment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDeployment' {Maybe Text
description :: Maybe Text
$sel:description:CreateDeployment' :: CreateDeployment -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateDeployment
s@CreateDeployment' {} Maybe Text
a -> CreateDeployment
s {$sel:description:CreateDeployment' :: Maybe Text
description = Maybe Text
a} :: CreateDeployment)

-- | Configuration information for an automatic rollback that is added when a
-- deployment is created.
createDeployment_autoRollbackConfiguration :: Lens.Lens' CreateDeployment (Prelude.Maybe AutoRollbackConfiguration)
createDeployment_autoRollbackConfiguration :: (Maybe AutoRollbackConfiguration
 -> f (Maybe AutoRollbackConfiguration))
-> CreateDeployment -> f CreateDeployment
createDeployment_autoRollbackConfiguration = (CreateDeployment -> Maybe AutoRollbackConfiguration)
-> (CreateDeployment
    -> Maybe AutoRollbackConfiguration -> CreateDeployment)
-> Lens
     CreateDeployment
     CreateDeployment
     (Maybe AutoRollbackConfiguration)
     (Maybe AutoRollbackConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDeployment' {Maybe AutoRollbackConfiguration
autoRollbackConfiguration :: Maybe AutoRollbackConfiguration
$sel:autoRollbackConfiguration:CreateDeployment' :: CreateDeployment -> Maybe AutoRollbackConfiguration
autoRollbackConfiguration} -> Maybe AutoRollbackConfiguration
autoRollbackConfiguration) (\s :: CreateDeployment
s@CreateDeployment' {} Maybe AutoRollbackConfiguration
a -> CreateDeployment
s {$sel:autoRollbackConfiguration:CreateDeployment' :: Maybe AutoRollbackConfiguration
autoRollbackConfiguration = Maybe AutoRollbackConfiguration
a} :: CreateDeployment)

-- | Indicates whether to deploy to all instances or only to instances that
-- are not running the latest application revision.
createDeployment_updateOutdatedInstancesOnly :: Lens.Lens' CreateDeployment (Prelude.Maybe Prelude.Bool)
createDeployment_updateOutdatedInstancesOnly :: (Maybe Bool -> f (Maybe Bool))
-> CreateDeployment -> f CreateDeployment
createDeployment_updateOutdatedInstancesOnly = (CreateDeployment -> Maybe Bool)
-> (CreateDeployment -> Maybe Bool -> CreateDeployment)
-> Lens CreateDeployment CreateDeployment (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDeployment' {Maybe Bool
updateOutdatedInstancesOnly :: Maybe Bool
$sel:updateOutdatedInstancesOnly:CreateDeployment' :: CreateDeployment -> Maybe Bool
updateOutdatedInstancesOnly} -> Maybe Bool
updateOutdatedInstancesOnly) (\s :: CreateDeployment
s@CreateDeployment' {} Maybe Bool
a -> CreateDeployment
s {$sel:updateOutdatedInstancesOnly:CreateDeployment' :: Maybe Bool
updateOutdatedInstancesOnly = Maybe Bool
a} :: CreateDeployment)

-- | The name of the deployment group.
createDeployment_deploymentGroupName :: Lens.Lens' CreateDeployment (Prelude.Maybe Prelude.Text)
createDeployment_deploymentGroupName :: (Maybe Text -> f (Maybe Text))
-> CreateDeployment -> f CreateDeployment
createDeployment_deploymentGroupName = (CreateDeployment -> Maybe Text)
-> (CreateDeployment -> Maybe Text -> CreateDeployment)
-> Lens CreateDeployment CreateDeployment (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDeployment' {Maybe Text
deploymentGroupName :: Maybe Text
$sel:deploymentGroupName:CreateDeployment' :: CreateDeployment -> Maybe Text
deploymentGroupName} -> Maybe Text
deploymentGroupName) (\s :: CreateDeployment
s@CreateDeployment' {} Maybe Text
a -> CreateDeployment
s {$sel:deploymentGroupName:CreateDeployment' :: Maybe Text
deploymentGroupName = Maybe Text
a} :: CreateDeployment)

-- | If true, then if an @ApplicationStop@, @BeforeBlockTraffic@, or
-- @AfterBlockTraffic@ deployment lifecycle event to an instance fails,
-- then the deployment continues to the next deployment lifecycle event.
-- For example, if @ApplicationStop@ fails, the deployment continues with
-- @DownloadBundle@. If @BeforeBlockTraffic@ fails, the deployment
-- continues with @BlockTraffic@. If @AfterBlockTraffic@ fails, the
-- deployment continues with @ApplicationStop@.
--
-- If false or not specified, then if a lifecycle event fails during a
-- deployment to an instance, that deployment fails. If deployment to that
-- instance is part of an overall deployment and the number of healthy
-- hosts is not less than the minimum number of healthy hosts, then a
-- deployment to the next instance is attempted.
--
-- During a deployment, the AWS CodeDeploy agent runs the scripts specified
-- for @ApplicationStop@, @BeforeBlockTraffic@, and @AfterBlockTraffic@ in
-- the AppSpec file from the previous successful deployment. (All other
-- scripts are run from the AppSpec file in the current deployment.) If one
-- of these scripts contains an error and does not run successfully, the
-- deployment can fail.
--
-- If the cause of the failure is a script from the last successful
-- deployment that will never run successfully, create a new deployment and
-- use @ignoreApplicationStopFailures@ to specify that the
-- @ApplicationStop@, @BeforeBlockTraffic@, and @AfterBlockTraffic@
-- failures should be ignored.
createDeployment_ignoreApplicationStopFailures :: Lens.Lens' CreateDeployment (Prelude.Maybe Prelude.Bool)
createDeployment_ignoreApplicationStopFailures :: (Maybe Bool -> f (Maybe Bool))
-> CreateDeployment -> f CreateDeployment
createDeployment_ignoreApplicationStopFailures = (CreateDeployment -> Maybe Bool)
-> (CreateDeployment -> Maybe Bool -> CreateDeployment)
-> Lens CreateDeployment CreateDeployment (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDeployment' {Maybe Bool
ignoreApplicationStopFailures :: Maybe Bool
$sel:ignoreApplicationStopFailures:CreateDeployment' :: CreateDeployment -> Maybe Bool
ignoreApplicationStopFailures} -> Maybe Bool
ignoreApplicationStopFailures) (\s :: CreateDeployment
s@CreateDeployment' {} Maybe Bool
a -> CreateDeployment
s {$sel:ignoreApplicationStopFailures:CreateDeployment' :: Maybe Bool
ignoreApplicationStopFailures = Maybe Bool
a} :: CreateDeployment)

-- | The name of an AWS CodeDeploy application associated with the IAM user
-- or AWS account.
createDeployment_applicationName :: Lens.Lens' CreateDeployment Prelude.Text
createDeployment_applicationName :: (Text -> f Text) -> CreateDeployment -> f CreateDeployment
createDeployment_applicationName = (CreateDeployment -> Text)
-> (CreateDeployment -> Text -> CreateDeployment)
-> Lens CreateDeployment CreateDeployment Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDeployment' {Text
applicationName :: Text
$sel:applicationName:CreateDeployment' :: CreateDeployment -> Text
applicationName} -> Text
applicationName) (\s :: CreateDeployment
s@CreateDeployment' {} Text
a -> CreateDeployment
s {$sel:applicationName:CreateDeployment' :: Text
applicationName = Text
a} :: CreateDeployment)

instance Core.AWSRequest CreateDeployment where
  type
    AWSResponse CreateDeployment =
      CreateDeploymentResponse
  request :: CreateDeployment -> Request CreateDeployment
request = Service -> CreateDeployment -> Request CreateDeployment
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateDeployment
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateDeployment)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateDeployment))
-> Logger
-> Service
-> Proxy CreateDeployment
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateDeployment)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> CreateDeploymentResponse
CreateDeploymentResponse'
            (Maybe Text -> Int -> CreateDeploymentResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateDeploymentResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"deploymentId")
            Either String (Int -> CreateDeploymentResponse)
-> Either String Int -> Either String CreateDeploymentResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateDeployment

instance Prelude.NFData CreateDeployment

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

instance Core.ToJSON CreateDeployment where
  toJSON :: CreateDeployment -> Value
toJSON CreateDeployment' {Maybe Bool
Maybe Text
Maybe AutoRollbackConfiguration
Maybe FileExistsBehavior
Maybe RevisionLocation
Maybe TargetInstances
Text
applicationName :: Text
ignoreApplicationStopFailures :: Maybe Bool
deploymentGroupName :: Maybe Text
updateOutdatedInstancesOnly :: Maybe Bool
autoRollbackConfiguration :: Maybe AutoRollbackConfiguration
description :: Maybe Text
revision :: Maybe RevisionLocation
targetInstances :: Maybe TargetInstances
fileExistsBehavior :: Maybe FileExistsBehavior
deploymentConfigName :: Maybe Text
$sel:applicationName:CreateDeployment' :: CreateDeployment -> Text
$sel:ignoreApplicationStopFailures:CreateDeployment' :: CreateDeployment -> Maybe Bool
$sel:deploymentGroupName:CreateDeployment' :: CreateDeployment -> Maybe Text
$sel:updateOutdatedInstancesOnly:CreateDeployment' :: CreateDeployment -> Maybe Bool
$sel:autoRollbackConfiguration:CreateDeployment' :: CreateDeployment -> Maybe AutoRollbackConfiguration
$sel:description:CreateDeployment' :: CreateDeployment -> Maybe Text
$sel:revision:CreateDeployment' :: CreateDeployment -> Maybe RevisionLocation
$sel:targetInstances:CreateDeployment' :: CreateDeployment -> Maybe TargetInstances
$sel:fileExistsBehavior:CreateDeployment' :: CreateDeployment -> Maybe FileExistsBehavior
$sel:deploymentConfigName:CreateDeployment' :: CreateDeployment -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"deploymentConfigName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
deploymentConfigName,
            (Text
"fileExistsBehavior" Text -> FileExistsBehavior -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (FileExistsBehavior -> Pair)
-> Maybe FileExistsBehavior -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FileExistsBehavior
fileExistsBehavior,
            (Text
"targetInstances" Text -> TargetInstances -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (TargetInstances -> Pair) -> Maybe TargetInstances -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TargetInstances
targetInstances,
            (Text
"revision" Text -> RevisionLocation -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (RevisionLocation -> Pair) -> Maybe RevisionLocation -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RevisionLocation
revision,
            (Text
"description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            (Text
"autoRollbackConfiguration" Text -> AutoRollbackConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AutoRollbackConfiguration -> Pair)
-> Maybe AutoRollbackConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AutoRollbackConfiguration
autoRollbackConfiguration,
            (Text
"updateOutdatedInstancesOnly" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
updateOutdatedInstancesOnly,
            (Text
"deploymentGroupName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
deploymentGroupName,
            (Text
"ignoreApplicationStopFailures" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
ignoreApplicationStopFailures,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"applicationName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
applicationName)
          ]
      )

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

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

-- | Represents the output of a @CreateDeployment@ operation.
--
-- /See:/ 'newCreateDeploymentResponse' smart constructor.
data CreateDeploymentResponse = CreateDeploymentResponse'
  { -- | The unique ID of a deployment.
    CreateDeploymentResponse -> Maybe Text
deploymentId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateDeploymentResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateDeploymentResponse -> CreateDeploymentResponse -> Bool
(CreateDeploymentResponse -> CreateDeploymentResponse -> Bool)
-> (CreateDeploymentResponse -> CreateDeploymentResponse -> Bool)
-> Eq CreateDeploymentResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDeploymentResponse -> CreateDeploymentResponse -> Bool
$c/= :: CreateDeploymentResponse -> CreateDeploymentResponse -> Bool
== :: CreateDeploymentResponse -> CreateDeploymentResponse -> Bool
$c== :: CreateDeploymentResponse -> CreateDeploymentResponse -> Bool
Prelude.Eq, ReadPrec [CreateDeploymentResponse]
ReadPrec CreateDeploymentResponse
Int -> ReadS CreateDeploymentResponse
ReadS [CreateDeploymentResponse]
(Int -> ReadS CreateDeploymentResponse)
-> ReadS [CreateDeploymentResponse]
-> ReadPrec CreateDeploymentResponse
-> ReadPrec [CreateDeploymentResponse]
-> Read CreateDeploymentResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDeploymentResponse]
$creadListPrec :: ReadPrec [CreateDeploymentResponse]
readPrec :: ReadPrec CreateDeploymentResponse
$creadPrec :: ReadPrec CreateDeploymentResponse
readList :: ReadS [CreateDeploymentResponse]
$creadList :: ReadS [CreateDeploymentResponse]
readsPrec :: Int -> ReadS CreateDeploymentResponse
$creadsPrec :: Int -> ReadS CreateDeploymentResponse
Prelude.Read, Int -> CreateDeploymentResponse -> ShowS
[CreateDeploymentResponse] -> ShowS
CreateDeploymentResponse -> String
(Int -> CreateDeploymentResponse -> ShowS)
-> (CreateDeploymentResponse -> String)
-> ([CreateDeploymentResponse] -> ShowS)
-> Show CreateDeploymentResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDeploymentResponse] -> ShowS
$cshowList :: [CreateDeploymentResponse] -> ShowS
show :: CreateDeploymentResponse -> String
$cshow :: CreateDeploymentResponse -> String
showsPrec :: Int -> CreateDeploymentResponse -> ShowS
$cshowsPrec :: Int -> CreateDeploymentResponse -> ShowS
Prelude.Show, (forall x.
 CreateDeploymentResponse -> Rep CreateDeploymentResponse x)
-> (forall x.
    Rep CreateDeploymentResponse x -> CreateDeploymentResponse)
-> Generic CreateDeploymentResponse
forall x.
Rep CreateDeploymentResponse x -> CreateDeploymentResponse
forall x.
CreateDeploymentResponse -> Rep CreateDeploymentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateDeploymentResponse x -> CreateDeploymentResponse
$cfrom :: forall x.
CreateDeploymentResponse -> Rep CreateDeploymentResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateDeploymentResponse' 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:
--
-- 'deploymentId', 'createDeploymentResponse_deploymentId' - The unique ID of a deployment.
--
-- 'httpStatus', 'createDeploymentResponse_httpStatus' - The response's http status code.
newCreateDeploymentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateDeploymentResponse
newCreateDeploymentResponse :: Int -> CreateDeploymentResponse
newCreateDeploymentResponse Int
pHttpStatus_ =
  CreateDeploymentResponse' :: Maybe Text -> Int -> CreateDeploymentResponse
CreateDeploymentResponse'
    { $sel:deploymentId:CreateDeploymentResponse' :: Maybe Text
deploymentId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateDeploymentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The unique ID of a deployment.
createDeploymentResponse_deploymentId :: Lens.Lens' CreateDeploymentResponse (Prelude.Maybe Prelude.Text)
createDeploymentResponse_deploymentId :: (Maybe Text -> f (Maybe Text))
-> CreateDeploymentResponse -> f CreateDeploymentResponse
createDeploymentResponse_deploymentId = (CreateDeploymentResponse -> Maybe Text)
-> (CreateDeploymentResponse
    -> Maybe Text -> CreateDeploymentResponse)
-> Lens
     CreateDeploymentResponse
     CreateDeploymentResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDeploymentResponse' {Maybe Text
deploymentId :: Maybe Text
$sel:deploymentId:CreateDeploymentResponse' :: CreateDeploymentResponse -> Maybe Text
deploymentId} -> Maybe Text
deploymentId) (\s :: CreateDeploymentResponse
s@CreateDeploymentResponse' {} Maybe Text
a -> CreateDeploymentResponse
s {$sel:deploymentId:CreateDeploymentResponse' :: Maybe Text
deploymentId = Maybe Text
a} :: CreateDeploymentResponse)

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

instance Prelude.NFData CreateDeploymentResponse