{-# 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-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)
module Amazonka.ECS.Types.DeploymentController where

import qualified Amazonka.Core as Core
import Amazonka.ECS.Types.DeploymentControllerType
import qualified Amazonka.Lens as Lens
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
(DeploymentController -> DeploymentController -> Bool)
-> (DeploymentController -> DeploymentController -> Bool)
-> Eq DeploymentController
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]
(Int -> ReadS DeploymentController)
-> ReadS [DeploymentController]
-> ReadPrec DeploymentController
-> ReadPrec [DeploymentController]
-> Read 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
(Int -> DeploymentController -> ShowS)
-> (DeploymentController -> String)
-> ([DeploymentController] -> ShowS)
-> Show DeploymentController
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. DeploymentController -> Rep DeploymentController x)
-> (forall x. Rep DeploymentController x -> DeploymentController)
-> Generic DeploymentController
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' :: DeploymentControllerType -> DeploymentController
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 :: (DeploymentControllerType -> f DeploymentControllerType)
-> DeploymentController -> f DeploymentController
deploymentController_type = (DeploymentController -> DeploymentControllerType)
-> (DeploymentController
    -> DeploymentControllerType -> DeploymentController)
-> Lens
     DeploymentController
     DeploymentController
     DeploymentControllerType
     DeploymentControllerType
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 Core.FromJSON DeploymentController where
  parseJSON :: Value -> Parser DeploymentController
parseJSON =
    String
-> (Object -> Parser DeploymentController)
-> Value
-> Parser DeploymentController
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DeploymentController"
      ( \Object
x ->
          DeploymentControllerType -> DeploymentController
DeploymentController' (DeploymentControllerType -> DeploymentController)
-> Parser DeploymentControllerType -> Parser DeploymentController
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser DeploymentControllerType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"type")
      )

instance Prelude.Hashable DeploymentController

instance Prelude.NFData DeploymentController

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