{-# 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.AutoScalingGroupProviderUpdate
-- 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.AutoScalingGroupProviderUpdate where

import qualified Amazonka.Core as Core
import Amazonka.ECS.Types.ManagedScaling
import Amazonka.ECS.Types.ManagedTerminationProtection
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The details of the Auto Scaling group capacity provider to update.
--
-- /See:/ 'newAutoScalingGroupProviderUpdate' smart constructor.
data AutoScalingGroupProviderUpdate = AutoScalingGroupProviderUpdate'
  { -- | The managed scaling settings for the Auto Scaling group capacity
    -- provider.
    AutoScalingGroupProviderUpdate -> Maybe ManagedScaling
managedScaling :: Prelude.Maybe ManagedScaling,
    -- | The managed termination protection setting to use for the Auto Scaling
    -- group capacity provider. This determines whether the Auto Scaling group
    -- has managed termination protection.
    --
    -- When using managed termination protection, managed scaling must also be
    -- used otherwise managed termination protection will not work.
    --
    -- When managed termination protection is enabled, Amazon ECS prevents the
    -- Amazon EC2 instances in an Auto Scaling group that contain tasks from
    -- being terminated during a scale-in action. The Auto Scaling group and
    -- each instance in the Auto Scaling group must have instance protection
    -- from scale-in actions enabled as well. For more information, see
    -- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-instance-termination.html#instance-protection Instance Protection>
    -- in the /Auto Scaling User Guide/.
    --
    -- When managed termination protection is disabled, your Amazon EC2
    -- instances are not protected from termination when the Auto Scaling group
    -- scales in.
    AutoScalingGroupProviderUpdate
-> Maybe ManagedTerminationProtection
managedTerminationProtection :: Prelude.Maybe ManagedTerminationProtection
  }
  deriving (AutoScalingGroupProviderUpdate
-> AutoScalingGroupProviderUpdate -> Bool
(AutoScalingGroupProviderUpdate
 -> AutoScalingGroupProviderUpdate -> Bool)
-> (AutoScalingGroupProviderUpdate
    -> AutoScalingGroupProviderUpdate -> Bool)
-> Eq AutoScalingGroupProviderUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutoScalingGroupProviderUpdate
-> AutoScalingGroupProviderUpdate -> Bool
$c/= :: AutoScalingGroupProviderUpdate
-> AutoScalingGroupProviderUpdate -> Bool
== :: AutoScalingGroupProviderUpdate
-> AutoScalingGroupProviderUpdate -> Bool
$c== :: AutoScalingGroupProviderUpdate
-> AutoScalingGroupProviderUpdate -> Bool
Prelude.Eq, ReadPrec [AutoScalingGroupProviderUpdate]
ReadPrec AutoScalingGroupProviderUpdate
Int -> ReadS AutoScalingGroupProviderUpdate
ReadS [AutoScalingGroupProviderUpdate]
(Int -> ReadS AutoScalingGroupProviderUpdate)
-> ReadS [AutoScalingGroupProviderUpdate]
-> ReadPrec AutoScalingGroupProviderUpdate
-> ReadPrec [AutoScalingGroupProviderUpdate]
-> Read AutoScalingGroupProviderUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AutoScalingGroupProviderUpdate]
$creadListPrec :: ReadPrec [AutoScalingGroupProviderUpdate]
readPrec :: ReadPrec AutoScalingGroupProviderUpdate
$creadPrec :: ReadPrec AutoScalingGroupProviderUpdate
readList :: ReadS [AutoScalingGroupProviderUpdate]
$creadList :: ReadS [AutoScalingGroupProviderUpdate]
readsPrec :: Int -> ReadS AutoScalingGroupProviderUpdate
$creadsPrec :: Int -> ReadS AutoScalingGroupProviderUpdate
Prelude.Read, Int -> AutoScalingGroupProviderUpdate -> ShowS
[AutoScalingGroupProviderUpdate] -> ShowS
AutoScalingGroupProviderUpdate -> String
(Int -> AutoScalingGroupProviderUpdate -> ShowS)
-> (AutoScalingGroupProviderUpdate -> String)
-> ([AutoScalingGroupProviderUpdate] -> ShowS)
-> Show AutoScalingGroupProviderUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutoScalingGroupProviderUpdate] -> ShowS
$cshowList :: [AutoScalingGroupProviderUpdate] -> ShowS
show :: AutoScalingGroupProviderUpdate -> String
$cshow :: AutoScalingGroupProviderUpdate -> String
showsPrec :: Int -> AutoScalingGroupProviderUpdate -> ShowS
$cshowsPrec :: Int -> AutoScalingGroupProviderUpdate -> ShowS
Prelude.Show, (forall x.
 AutoScalingGroupProviderUpdate
 -> Rep AutoScalingGroupProviderUpdate x)
-> (forall x.
    Rep AutoScalingGroupProviderUpdate x
    -> AutoScalingGroupProviderUpdate)
-> Generic AutoScalingGroupProviderUpdate
forall x.
Rep AutoScalingGroupProviderUpdate x
-> AutoScalingGroupProviderUpdate
forall x.
AutoScalingGroupProviderUpdate
-> Rep AutoScalingGroupProviderUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AutoScalingGroupProviderUpdate x
-> AutoScalingGroupProviderUpdate
$cfrom :: forall x.
AutoScalingGroupProviderUpdate
-> Rep AutoScalingGroupProviderUpdate x
Prelude.Generic)

-- |
-- Create a value of 'AutoScalingGroupProviderUpdate' 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:
--
-- 'managedScaling', 'autoScalingGroupProviderUpdate_managedScaling' - The managed scaling settings for the Auto Scaling group capacity
-- provider.
--
-- 'managedTerminationProtection', 'autoScalingGroupProviderUpdate_managedTerminationProtection' - The managed termination protection setting to use for the Auto Scaling
-- group capacity provider. This determines whether the Auto Scaling group
-- has managed termination protection.
--
-- When using managed termination protection, managed scaling must also be
-- used otherwise managed termination protection will not work.
--
-- When managed termination protection is enabled, Amazon ECS prevents the
-- Amazon EC2 instances in an Auto Scaling group that contain tasks from
-- being terminated during a scale-in action. The Auto Scaling group and
-- each instance in the Auto Scaling group must have instance protection
-- from scale-in actions enabled as well. For more information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-instance-termination.html#instance-protection Instance Protection>
-- in the /Auto Scaling User Guide/.
--
-- When managed termination protection is disabled, your Amazon EC2
-- instances are not protected from termination when the Auto Scaling group
-- scales in.
newAutoScalingGroupProviderUpdate ::
  AutoScalingGroupProviderUpdate
newAutoScalingGroupProviderUpdate :: AutoScalingGroupProviderUpdate
newAutoScalingGroupProviderUpdate =
  AutoScalingGroupProviderUpdate' :: Maybe ManagedScaling
-> Maybe ManagedTerminationProtection
-> AutoScalingGroupProviderUpdate
AutoScalingGroupProviderUpdate'
    { $sel:managedScaling:AutoScalingGroupProviderUpdate' :: Maybe ManagedScaling
managedScaling =
        Maybe ManagedScaling
forall a. Maybe a
Prelude.Nothing,
      $sel:managedTerminationProtection:AutoScalingGroupProviderUpdate' :: Maybe ManagedTerminationProtection
managedTerminationProtection =
        Maybe ManagedTerminationProtection
forall a. Maybe a
Prelude.Nothing
    }

-- | The managed scaling settings for the Auto Scaling group capacity
-- provider.
autoScalingGroupProviderUpdate_managedScaling :: Lens.Lens' AutoScalingGroupProviderUpdate (Prelude.Maybe ManagedScaling)
autoScalingGroupProviderUpdate_managedScaling :: (Maybe ManagedScaling -> f (Maybe ManagedScaling))
-> AutoScalingGroupProviderUpdate
-> f AutoScalingGroupProviderUpdate
autoScalingGroupProviderUpdate_managedScaling = (AutoScalingGroupProviderUpdate -> Maybe ManagedScaling)
-> (AutoScalingGroupProviderUpdate
    -> Maybe ManagedScaling -> AutoScalingGroupProviderUpdate)
-> Lens
     AutoScalingGroupProviderUpdate
     AutoScalingGroupProviderUpdate
     (Maybe ManagedScaling)
     (Maybe ManagedScaling)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingGroupProviderUpdate' {Maybe ManagedScaling
managedScaling :: Maybe ManagedScaling
$sel:managedScaling:AutoScalingGroupProviderUpdate' :: AutoScalingGroupProviderUpdate -> Maybe ManagedScaling
managedScaling} -> Maybe ManagedScaling
managedScaling) (\s :: AutoScalingGroupProviderUpdate
s@AutoScalingGroupProviderUpdate' {} Maybe ManagedScaling
a -> AutoScalingGroupProviderUpdate
s {$sel:managedScaling:AutoScalingGroupProviderUpdate' :: Maybe ManagedScaling
managedScaling = Maybe ManagedScaling
a} :: AutoScalingGroupProviderUpdate)

-- | The managed termination protection setting to use for the Auto Scaling
-- group capacity provider. This determines whether the Auto Scaling group
-- has managed termination protection.
--
-- When using managed termination protection, managed scaling must also be
-- used otherwise managed termination protection will not work.
--
-- When managed termination protection is enabled, Amazon ECS prevents the
-- Amazon EC2 instances in an Auto Scaling group that contain tasks from
-- being terminated during a scale-in action. The Auto Scaling group and
-- each instance in the Auto Scaling group must have instance protection
-- from scale-in actions enabled as well. For more information, see
-- <https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-instance-termination.html#instance-protection Instance Protection>
-- in the /Auto Scaling User Guide/.
--
-- When managed termination protection is disabled, your Amazon EC2
-- instances are not protected from termination when the Auto Scaling group
-- scales in.
autoScalingGroupProviderUpdate_managedTerminationProtection :: Lens.Lens' AutoScalingGroupProviderUpdate (Prelude.Maybe ManagedTerminationProtection)
autoScalingGroupProviderUpdate_managedTerminationProtection :: (Maybe ManagedTerminationProtection
 -> f (Maybe ManagedTerminationProtection))
-> AutoScalingGroupProviderUpdate
-> f AutoScalingGroupProviderUpdate
autoScalingGroupProviderUpdate_managedTerminationProtection = (AutoScalingGroupProviderUpdate
 -> Maybe ManagedTerminationProtection)
-> (AutoScalingGroupProviderUpdate
    -> Maybe ManagedTerminationProtection
    -> AutoScalingGroupProviderUpdate)
-> Lens
     AutoScalingGroupProviderUpdate
     AutoScalingGroupProviderUpdate
     (Maybe ManagedTerminationProtection)
     (Maybe ManagedTerminationProtection)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingGroupProviderUpdate' {Maybe ManagedTerminationProtection
managedTerminationProtection :: Maybe ManagedTerminationProtection
$sel:managedTerminationProtection:AutoScalingGroupProviderUpdate' :: AutoScalingGroupProviderUpdate
-> Maybe ManagedTerminationProtection
managedTerminationProtection} -> Maybe ManagedTerminationProtection
managedTerminationProtection) (\s :: AutoScalingGroupProviderUpdate
s@AutoScalingGroupProviderUpdate' {} Maybe ManagedTerminationProtection
a -> AutoScalingGroupProviderUpdate
s {$sel:managedTerminationProtection:AutoScalingGroupProviderUpdate' :: Maybe ManagedTerminationProtection
managedTerminationProtection = Maybe ManagedTerminationProtection
a} :: AutoScalingGroupProviderUpdate)

instance
  Prelude.Hashable
    AutoScalingGroupProviderUpdate

instance
  Prelude.NFData
    AutoScalingGroupProviderUpdate

instance Core.ToJSON AutoScalingGroupProviderUpdate where
  toJSON :: AutoScalingGroupProviderUpdate -> Value
toJSON AutoScalingGroupProviderUpdate' {Maybe ManagedScaling
Maybe ManagedTerminationProtection
managedTerminationProtection :: Maybe ManagedTerminationProtection
managedScaling :: Maybe ManagedScaling
$sel:managedTerminationProtection:AutoScalingGroupProviderUpdate' :: AutoScalingGroupProviderUpdate
-> Maybe ManagedTerminationProtection
$sel:managedScaling:AutoScalingGroupProviderUpdate' :: AutoScalingGroupProviderUpdate -> Maybe ManagedScaling
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"managedScaling" Text -> ManagedScaling -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ManagedScaling -> Pair) -> Maybe ManagedScaling -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ManagedScaling
managedScaling,
            (Text
"managedTerminationProtection" Text -> ManagedTerminationProtection -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ManagedTerminationProtection -> Pair)
-> Maybe ManagedTerminationProtection -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ManagedTerminationProtection
managedTerminationProtection
          ]
      )