{-# 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-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.AutoScalingGroupProviderUpdate 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.ManagedScaling
import Amazonka.ECS.Types.ManagedTerminationProtection
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 doesn\'t 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. 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 aren\'t protected from termination when the Auto Scaling group
    -- scales in.
    AutoScalingGroupProviderUpdate
-> Maybe ManagedTerminationProtection
managedTerminationProtection :: Prelude.Maybe ManagedTerminationProtection
  }
  deriving (AutoScalingGroupProviderUpdate
-> AutoScalingGroupProviderUpdate -> Bool
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]
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
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.
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 doesn\'t 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. 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 aren\'t protected from termination when the Auto Scaling group
-- scales in.
newAutoScalingGroupProviderUpdate ::
  AutoScalingGroupProviderUpdate
newAutoScalingGroupProviderUpdate :: AutoScalingGroupProviderUpdate
newAutoScalingGroupProviderUpdate =
  AutoScalingGroupProviderUpdate'
    { $sel:managedScaling:AutoScalingGroupProviderUpdate' :: Maybe ManagedScaling
managedScaling =
        forall a. Maybe a
Prelude.Nothing,
      $sel:managedTerminationProtection:AutoScalingGroupProviderUpdate' :: Maybe ManagedTerminationProtection
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 :: Lens' AutoScalingGroupProviderUpdate (Maybe ManagedScaling)
autoScalingGroupProviderUpdate_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 doesn\'t 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. 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 aren\'t protected from termination when the Auto Scaling group
-- scales in.
autoScalingGroupProviderUpdate_managedTerminationProtection :: Lens.Lens' AutoScalingGroupProviderUpdate (Prelude.Maybe ManagedTerminationProtection)
autoScalingGroupProviderUpdate_managedTerminationProtection :: Lens'
  AutoScalingGroupProviderUpdate (Maybe ManagedTerminationProtection)
autoScalingGroupProviderUpdate_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
  where
  hashWithSalt :: Int -> AutoScalingGroupProviderUpdate -> Int
hashWithSalt
    Int
_salt
    AutoScalingGroupProviderUpdate' {Maybe ManagedScaling
Maybe ManagedTerminationProtection
managedTerminationProtection :: Maybe ManagedTerminationProtection
managedScaling :: Maybe ManagedScaling
$sel:managedTerminationProtection:AutoScalingGroupProviderUpdate' :: AutoScalingGroupProviderUpdate
-> Maybe ManagedTerminationProtection
$sel:managedScaling:AutoScalingGroupProviderUpdate' :: AutoScalingGroupProviderUpdate -> Maybe ManagedScaling
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ManagedScaling
managedScaling
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ManagedTerminationProtection
managedTerminationProtection

instance
  Prelude.NFData
    AutoScalingGroupProviderUpdate
  where
  rnf :: AutoScalingGroupProviderUpdate -> ()
rnf AutoScalingGroupProviderUpdate' {Maybe ManagedScaling
Maybe ManagedTerminationProtection
managedTerminationProtection :: Maybe ManagedTerminationProtection
managedScaling :: Maybe ManagedScaling
$sel:managedTerminationProtection:AutoScalingGroupProviderUpdate' :: AutoScalingGroupProviderUpdate
-> Maybe ManagedTerminationProtection
$sel:managedScaling:AutoScalingGroupProviderUpdate' :: AutoScalingGroupProviderUpdate -> Maybe ManagedScaling
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ManagedScaling
managedScaling
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ManagedTerminationProtection
managedTerminationProtection

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"managedScaling" 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 ManagedScaling
managedScaling,
            (Key
"managedTerminationProtection" 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 ManagedTerminationProtection
managedTerminationProtection
          ]
      )