{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.ECS.Types.DeploymentController
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ECS.Types.DeploymentController where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ECS.Types.DeploymentControllerType
import qualified Amazonka.Prelude as Prelude

-- | The deployment controller to use for the service. For more information,
-- see
-- <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/deployment-types.html Amazon ECS deployment types>
-- in the /Amazon Elastic Container Service Developer Guide/.
--
-- /See:/ 'newDeploymentController' smart constructor.
data DeploymentController = DeploymentController'
  { -- | The deployment controller type to use.
    --
    -- There are three deployment controller types available:
    --
    -- [ECS]
    --     The rolling update (@ECS@) deployment type involves replacing the
    --     current running version of the container with the latest version.
    --     The number of containers Amazon ECS adds or removes from the service
    --     during a rolling update is controlled by adjusting the minimum and
    --     maximum number of healthy tasks allowed during a service deployment,
    --     as specified in the DeploymentConfiguration.
    --
    -- [CODE_DEPLOY]
    --     The blue\/green (@CODE_DEPLOY@) deployment type uses the blue\/green
    --     deployment model powered by CodeDeploy, which allows you to verify a
    --     new deployment of a service before sending production traffic to it.
    --
    -- [EXTERNAL]
    --     The external (@EXTERNAL@) deployment type enables you to use any
    --     third-party deployment controller for full control over the
    --     deployment process for an Amazon ECS service.
    DeploymentController -> DeploymentControllerType
type' :: DeploymentControllerType
  }
  deriving (DeploymentController -> DeploymentController -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeploymentController -> DeploymentController -> Bool
$c/= :: DeploymentController -> DeploymentController -> Bool
== :: DeploymentController -> DeploymentController -> Bool
$c== :: DeploymentController -> DeploymentController -> Bool
Prelude.Eq, ReadPrec [DeploymentController]
ReadPrec DeploymentController
Int -> ReadS DeploymentController
ReadS [DeploymentController]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeploymentController]
$creadListPrec :: ReadPrec [DeploymentController]
readPrec :: ReadPrec DeploymentController
$creadPrec :: ReadPrec DeploymentController
readList :: ReadS [DeploymentController]
$creadList :: ReadS [DeploymentController]
readsPrec :: Int -> ReadS DeploymentController
$creadsPrec :: Int -> ReadS DeploymentController
Prelude.Read, Int -> DeploymentController -> ShowS
[DeploymentController] -> ShowS
DeploymentController -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeploymentController] -> ShowS
$cshowList :: [DeploymentController] -> ShowS
show :: DeploymentController -> String
$cshow :: DeploymentController -> String
showsPrec :: Int -> DeploymentController -> ShowS
$cshowsPrec :: Int -> DeploymentController -> ShowS
Prelude.Show, forall x. Rep DeploymentController x -> DeploymentController
forall x. DeploymentController -> Rep DeploymentController x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeploymentController x -> DeploymentController
$cfrom :: forall x. DeploymentController -> Rep DeploymentController x
Prelude.Generic)

-- |
-- Create a value of 'DeploymentController' 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:
--
-- 'type'', 'deploymentController_type' - The deployment controller type to use.
--
-- There are three deployment controller types available:
--
-- [ECS]
--     The rolling update (@ECS@) deployment type involves replacing the
--     current running version of the container with the latest version.
--     The number of containers Amazon ECS adds or removes from the service
--     during a rolling update is controlled by adjusting the minimum and
--     maximum number of healthy tasks allowed during a service deployment,
--     as specified in the DeploymentConfiguration.
--
-- [CODE_DEPLOY]
--     The blue\/green (@CODE_DEPLOY@) deployment type uses the blue\/green
--     deployment model powered by CodeDeploy, which allows you to verify a
--     new deployment of a service before sending production traffic to it.
--
-- [EXTERNAL]
--     The external (@EXTERNAL@) deployment type enables you to use any
--     third-party deployment controller for full control over the
--     deployment process for an Amazon ECS service.
newDeploymentController ::
  -- | 'type''
  DeploymentControllerType ->
  DeploymentController
newDeploymentController :: DeploymentControllerType -> DeploymentController
newDeploymentController DeploymentControllerType
pType_ =
  DeploymentController' {$sel:type':DeploymentController' :: DeploymentControllerType
type' = DeploymentControllerType
pType_}

-- | The deployment controller type to use.
--
-- There are three deployment controller types available:
--
-- [ECS]
--     The rolling update (@ECS@) deployment type involves replacing the
--     current running version of the container with the latest version.
--     The number of containers Amazon ECS adds or removes from the service
--     during a rolling update is controlled by adjusting the minimum and
--     maximum number of healthy tasks allowed during a service deployment,
--     as specified in the DeploymentConfiguration.
--
-- [CODE_DEPLOY]
--     The blue\/green (@CODE_DEPLOY@) deployment type uses the blue\/green
--     deployment model powered by CodeDeploy, which allows you to verify a
--     new deployment of a service before sending production traffic to it.
--
-- [EXTERNAL]
--     The external (@EXTERNAL@) deployment type enables you to use any
--     third-party deployment controller for full control over the
--     deployment process for an Amazon ECS service.
deploymentController_type :: Lens.Lens' DeploymentController DeploymentControllerType
deploymentController_type :: Lens' DeploymentController DeploymentControllerType
deploymentController_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentController' {DeploymentControllerType
type' :: DeploymentControllerType
$sel:type':DeploymentController' :: DeploymentController -> DeploymentControllerType
type'} -> DeploymentControllerType
type') (\s :: DeploymentController
s@DeploymentController' {} DeploymentControllerType
a -> DeploymentController
s {$sel:type':DeploymentController' :: DeploymentControllerType
type' = DeploymentControllerType
a} :: DeploymentController)

instance Data.FromJSON DeploymentController where
  parseJSON :: Value -> Parser DeploymentController
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DeploymentController"
      ( \Object
x ->
          DeploymentControllerType -> DeploymentController
DeploymentController' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"type")
      )

instance Prelude.Hashable DeploymentController where
  hashWithSalt :: Int -> DeploymentController -> Int
hashWithSalt Int
_salt DeploymentController' {DeploymentControllerType
type' :: DeploymentControllerType
$sel:type':DeploymentController' :: DeploymentController -> DeploymentControllerType
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` DeploymentControllerType
type'

instance Prelude.NFData DeploymentController where
  rnf :: DeploymentController -> ()
rnf DeploymentController' {DeploymentControllerType
type' :: DeploymentControllerType
$sel:type':DeploymentController' :: DeploymentController -> DeploymentControllerType
..} = forall a. NFData a => a -> ()
Prelude.rnf DeploymentControllerType
type'

instance Data.ToJSON DeploymentController where
  toJSON :: DeploymentController -> Value
toJSON DeploymentController' {DeploymentControllerType
type' :: DeploymentControllerType
$sel:type':DeploymentController' :: DeploymentController -> DeploymentControllerType
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= DeploymentControllerType
type')]
      )