{-# 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.EMR.Types.InstanceGroupModifyConfig
-- 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.EMR.Types.InstanceGroupModifyConfig where

import qualified Amazonka.Core as Core
import Amazonka.EMR.Types.Configuration
import Amazonka.EMR.Types.ShrinkPolicy
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Modify the size or configurations of an instance group.
--
-- /See:/ 'newInstanceGroupModifyConfig' smart constructor.
data InstanceGroupModifyConfig = InstanceGroupModifyConfig'
  { -- | Target size for the instance group.
    InstanceGroupModifyConfig -> Maybe Int
instanceCount :: Prelude.Maybe Prelude.Int,
    -- | A list of new or modified configurations to apply for an instance group.
    InstanceGroupModifyConfig -> Maybe [Configuration]
configurations :: Prelude.Maybe [Configuration],
    -- | The EC2 InstanceIds to terminate. After you terminate the instances, the
    -- instance group will not return to its original requested size.
    InstanceGroupModifyConfig -> Maybe [Text]
eC2InstanceIdsToTerminate :: Prelude.Maybe [Prelude.Text],
    -- | Policy for customizing shrink operations.
    InstanceGroupModifyConfig -> Maybe ShrinkPolicy
shrinkPolicy :: Prelude.Maybe ShrinkPolicy,
    -- | Unique ID of the instance group to modify.
    InstanceGroupModifyConfig -> Text
instanceGroupId :: Prelude.Text
  }
  deriving (InstanceGroupModifyConfig -> InstanceGroupModifyConfig -> Bool
(InstanceGroupModifyConfig -> InstanceGroupModifyConfig -> Bool)
-> (InstanceGroupModifyConfig -> InstanceGroupModifyConfig -> Bool)
-> Eq InstanceGroupModifyConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceGroupModifyConfig -> InstanceGroupModifyConfig -> Bool
$c/= :: InstanceGroupModifyConfig -> InstanceGroupModifyConfig -> Bool
== :: InstanceGroupModifyConfig -> InstanceGroupModifyConfig -> Bool
$c== :: InstanceGroupModifyConfig -> InstanceGroupModifyConfig -> Bool
Prelude.Eq, ReadPrec [InstanceGroupModifyConfig]
ReadPrec InstanceGroupModifyConfig
Int -> ReadS InstanceGroupModifyConfig
ReadS [InstanceGroupModifyConfig]
(Int -> ReadS InstanceGroupModifyConfig)
-> ReadS [InstanceGroupModifyConfig]
-> ReadPrec InstanceGroupModifyConfig
-> ReadPrec [InstanceGroupModifyConfig]
-> Read InstanceGroupModifyConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceGroupModifyConfig]
$creadListPrec :: ReadPrec [InstanceGroupModifyConfig]
readPrec :: ReadPrec InstanceGroupModifyConfig
$creadPrec :: ReadPrec InstanceGroupModifyConfig
readList :: ReadS [InstanceGroupModifyConfig]
$creadList :: ReadS [InstanceGroupModifyConfig]
readsPrec :: Int -> ReadS InstanceGroupModifyConfig
$creadsPrec :: Int -> ReadS InstanceGroupModifyConfig
Prelude.Read, Int -> InstanceGroupModifyConfig -> ShowS
[InstanceGroupModifyConfig] -> ShowS
InstanceGroupModifyConfig -> String
(Int -> InstanceGroupModifyConfig -> ShowS)
-> (InstanceGroupModifyConfig -> String)
-> ([InstanceGroupModifyConfig] -> ShowS)
-> Show InstanceGroupModifyConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceGroupModifyConfig] -> ShowS
$cshowList :: [InstanceGroupModifyConfig] -> ShowS
show :: InstanceGroupModifyConfig -> String
$cshow :: InstanceGroupModifyConfig -> String
showsPrec :: Int -> InstanceGroupModifyConfig -> ShowS
$cshowsPrec :: Int -> InstanceGroupModifyConfig -> ShowS
Prelude.Show, (forall x.
 InstanceGroupModifyConfig -> Rep InstanceGroupModifyConfig x)
-> (forall x.
    Rep InstanceGroupModifyConfig x -> InstanceGroupModifyConfig)
-> Generic InstanceGroupModifyConfig
forall x.
Rep InstanceGroupModifyConfig x -> InstanceGroupModifyConfig
forall x.
InstanceGroupModifyConfig -> Rep InstanceGroupModifyConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InstanceGroupModifyConfig x -> InstanceGroupModifyConfig
$cfrom :: forall x.
InstanceGroupModifyConfig -> Rep InstanceGroupModifyConfig x
Prelude.Generic)

-- |
-- Create a value of 'InstanceGroupModifyConfig' 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:
--
-- 'instanceCount', 'instanceGroupModifyConfig_instanceCount' - Target size for the instance group.
--
-- 'configurations', 'instanceGroupModifyConfig_configurations' - A list of new or modified configurations to apply for an instance group.
--
-- 'eC2InstanceIdsToTerminate', 'instanceGroupModifyConfig_eC2InstanceIdsToTerminate' - The EC2 InstanceIds to terminate. After you terminate the instances, the
-- instance group will not return to its original requested size.
--
-- 'shrinkPolicy', 'instanceGroupModifyConfig_shrinkPolicy' - Policy for customizing shrink operations.
--
-- 'instanceGroupId', 'instanceGroupModifyConfig_instanceGroupId' - Unique ID of the instance group to modify.
newInstanceGroupModifyConfig ::
  -- | 'instanceGroupId'
  Prelude.Text ->
  InstanceGroupModifyConfig
newInstanceGroupModifyConfig :: Text -> InstanceGroupModifyConfig
newInstanceGroupModifyConfig Text
pInstanceGroupId_ =
  InstanceGroupModifyConfig' :: Maybe Int
-> Maybe [Configuration]
-> Maybe [Text]
-> Maybe ShrinkPolicy
-> Text
-> InstanceGroupModifyConfig
InstanceGroupModifyConfig'
    { $sel:instanceCount:InstanceGroupModifyConfig' :: Maybe Int
instanceCount =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:configurations:InstanceGroupModifyConfig' :: Maybe [Configuration]
configurations = Maybe [Configuration]
forall a. Maybe a
Prelude.Nothing,
      $sel:eC2InstanceIdsToTerminate:InstanceGroupModifyConfig' :: Maybe [Text]
eC2InstanceIdsToTerminate = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:shrinkPolicy:InstanceGroupModifyConfig' :: Maybe ShrinkPolicy
shrinkPolicy = Maybe ShrinkPolicy
forall a. Maybe a
Prelude.Nothing,
      $sel:instanceGroupId:InstanceGroupModifyConfig' :: Text
instanceGroupId = Text
pInstanceGroupId_
    }

-- | Target size for the instance group.
instanceGroupModifyConfig_instanceCount :: Lens.Lens' InstanceGroupModifyConfig (Prelude.Maybe Prelude.Int)
instanceGroupModifyConfig_instanceCount :: (Maybe Int -> f (Maybe Int))
-> InstanceGroupModifyConfig -> f InstanceGroupModifyConfig
instanceGroupModifyConfig_instanceCount = (InstanceGroupModifyConfig -> Maybe Int)
-> (InstanceGroupModifyConfig
    -> Maybe Int -> InstanceGroupModifyConfig)
-> Lens
     InstanceGroupModifyConfig
     InstanceGroupModifyConfig
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceGroupModifyConfig' {Maybe Int
instanceCount :: Maybe Int
$sel:instanceCount:InstanceGroupModifyConfig' :: InstanceGroupModifyConfig -> Maybe Int
instanceCount} -> Maybe Int
instanceCount) (\s :: InstanceGroupModifyConfig
s@InstanceGroupModifyConfig' {} Maybe Int
a -> InstanceGroupModifyConfig
s {$sel:instanceCount:InstanceGroupModifyConfig' :: Maybe Int
instanceCount = Maybe Int
a} :: InstanceGroupModifyConfig)

-- | A list of new or modified configurations to apply for an instance group.
instanceGroupModifyConfig_configurations :: Lens.Lens' InstanceGroupModifyConfig (Prelude.Maybe [Configuration])
instanceGroupModifyConfig_configurations :: (Maybe [Configuration] -> f (Maybe [Configuration]))
-> InstanceGroupModifyConfig -> f InstanceGroupModifyConfig
instanceGroupModifyConfig_configurations = (InstanceGroupModifyConfig -> Maybe [Configuration])
-> (InstanceGroupModifyConfig
    -> Maybe [Configuration] -> InstanceGroupModifyConfig)
-> Lens
     InstanceGroupModifyConfig
     InstanceGroupModifyConfig
     (Maybe [Configuration])
     (Maybe [Configuration])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceGroupModifyConfig' {Maybe [Configuration]
configurations :: Maybe [Configuration]
$sel:configurations:InstanceGroupModifyConfig' :: InstanceGroupModifyConfig -> Maybe [Configuration]
configurations} -> Maybe [Configuration]
configurations) (\s :: InstanceGroupModifyConfig
s@InstanceGroupModifyConfig' {} Maybe [Configuration]
a -> InstanceGroupModifyConfig
s {$sel:configurations:InstanceGroupModifyConfig' :: Maybe [Configuration]
configurations = Maybe [Configuration]
a} :: InstanceGroupModifyConfig) ((Maybe [Configuration] -> f (Maybe [Configuration]))
 -> InstanceGroupModifyConfig -> f InstanceGroupModifyConfig)
-> ((Maybe [Configuration] -> f (Maybe [Configuration]))
    -> Maybe [Configuration] -> f (Maybe [Configuration]))
-> (Maybe [Configuration] -> f (Maybe [Configuration]))
-> InstanceGroupModifyConfig
-> f InstanceGroupModifyConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [Configuration] [Configuration] [Configuration] [Configuration]
-> Iso
     (Maybe [Configuration])
     (Maybe [Configuration])
     (Maybe [Configuration])
     (Maybe [Configuration])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [Configuration] [Configuration] [Configuration] [Configuration]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The EC2 InstanceIds to terminate. After you terminate the instances, the
-- instance group will not return to its original requested size.
instanceGroupModifyConfig_eC2InstanceIdsToTerminate :: Lens.Lens' InstanceGroupModifyConfig (Prelude.Maybe [Prelude.Text])
instanceGroupModifyConfig_eC2InstanceIdsToTerminate :: (Maybe [Text] -> f (Maybe [Text]))
-> InstanceGroupModifyConfig -> f InstanceGroupModifyConfig
instanceGroupModifyConfig_eC2InstanceIdsToTerminate = (InstanceGroupModifyConfig -> Maybe [Text])
-> (InstanceGroupModifyConfig
    -> Maybe [Text] -> InstanceGroupModifyConfig)
-> Lens
     InstanceGroupModifyConfig
     InstanceGroupModifyConfig
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceGroupModifyConfig' {Maybe [Text]
eC2InstanceIdsToTerminate :: Maybe [Text]
$sel:eC2InstanceIdsToTerminate:InstanceGroupModifyConfig' :: InstanceGroupModifyConfig -> Maybe [Text]
eC2InstanceIdsToTerminate} -> Maybe [Text]
eC2InstanceIdsToTerminate) (\s :: InstanceGroupModifyConfig
s@InstanceGroupModifyConfig' {} Maybe [Text]
a -> InstanceGroupModifyConfig
s {$sel:eC2InstanceIdsToTerminate:InstanceGroupModifyConfig' :: Maybe [Text]
eC2InstanceIdsToTerminate = Maybe [Text]
a} :: InstanceGroupModifyConfig) ((Maybe [Text] -> f (Maybe [Text]))
 -> InstanceGroupModifyConfig -> f InstanceGroupModifyConfig)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> InstanceGroupModifyConfig
-> f InstanceGroupModifyConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Policy for customizing shrink operations.
instanceGroupModifyConfig_shrinkPolicy :: Lens.Lens' InstanceGroupModifyConfig (Prelude.Maybe ShrinkPolicy)
instanceGroupModifyConfig_shrinkPolicy :: (Maybe ShrinkPolicy -> f (Maybe ShrinkPolicy))
-> InstanceGroupModifyConfig -> f InstanceGroupModifyConfig
instanceGroupModifyConfig_shrinkPolicy = (InstanceGroupModifyConfig -> Maybe ShrinkPolicy)
-> (InstanceGroupModifyConfig
    -> Maybe ShrinkPolicy -> InstanceGroupModifyConfig)
-> Lens
     InstanceGroupModifyConfig
     InstanceGroupModifyConfig
     (Maybe ShrinkPolicy)
     (Maybe ShrinkPolicy)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceGroupModifyConfig' {Maybe ShrinkPolicy
shrinkPolicy :: Maybe ShrinkPolicy
$sel:shrinkPolicy:InstanceGroupModifyConfig' :: InstanceGroupModifyConfig -> Maybe ShrinkPolicy
shrinkPolicy} -> Maybe ShrinkPolicy
shrinkPolicy) (\s :: InstanceGroupModifyConfig
s@InstanceGroupModifyConfig' {} Maybe ShrinkPolicy
a -> InstanceGroupModifyConfig
s {$sel:shrinkPolicy:InstanceGroupModifyConfig' :: Maybe ShrinkPolicy
shrinkPolicy = Maybe ShrinkPolicy
a} :: InstanceGroupModifyConfig)

-- | Unique ID of the instance group to modify.
instanceGroupModifyConfig_instanceGroupId :: Lens.Lens' InstanceGroupModifyConfig Prelude.Text
instanceGroupModifyConfig_instanceGroupId :: (Text -> f Text)
-> InstanceGroupModifyConfig -> f InstanceGroupModifyConfig
instanceGroupModifyConfig_instanceGroupId = (InstanceGroupModifyConfig -> Text)
-> (InstanceGroupModifyConfig -> Text -> InstanceGroupModifyConfig)
-> Lens
     InstanceGroupModifyConfig InstanceGroupModifyConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceGroupModifyConfig' {Text
instanceGroupId :: Text
$sel:instanceGroupId:InstanceGroupModifyConfig' :: InstanceGroupModifyConfig -> Text
instanceGroupId} -> Text
instanceGroupId) (\s :: InstanceGroupModifyConfig
s@InstanceGroupModifyConfig' {} Text
a -> InstanceGroupModifyConfig
s {$sel:instanceGroupId:InstanceGroupModifyConfig' :: Text
instanceGroupId = Text
a} :: InstanceGroupModifyConfig)

instance Prelude.Hashable InstanceGroupModifyConfig

instance Prelude.NFData InstanceGroupModifyConfig

instance Core.ToJSON InstanceGroupModifyConfig where
  toJSON :: InstanceGroupModifyConfig -> Value
toJSON InstanceGroupModifyConfig' {Maybe Int
Maybe [Text]
Maybe [Configuration]
Maybe ShrinkPolicy
Text
instanceGroupId :: Text
shrinkPolicy :: Maybe ShrinkPolicy
eC2InstanceIdsToTerminate :: Maybe [Text]
configurations :: Maybe [Configuration]
instanceCount :: Maybe Int
$sel:instanceGroupId:InstanceGroupModifyConfig' :: InstanceGroupModifyConfig -> Text
$sel:shrinkPolicy:InstanceGroupModifyConfig' :: InstanceGroupModifyConfig -> Maybe ShrinkPolicy
$sel:eC2InstanceIdsToTerminate:InstanceGroupModifyConfig' :: InstanceGroupModifyConfig -> Maybe [Text]
$sel:configurations:InstanceGroupModifyConfig' :: InstanceGroupModifyConfig -> Maybe [Configuration]
$sel:instanceCount:InstanceGroupModifyConfig' :: InstanceGroupModifyConfig -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"InstanceCount" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
instanceCount,
            (Text
"Configurations" Text -> [Configuration] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Configuration] -> Pair) -> Maybe [Configuration] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Configuration]
configurations,
            (Text
"EC2InstanceIdsToTerminate" 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]
eC2InstanceIdsToTerminate,
            (Text
"ShrinkPolicy" Text -> ShrinkPolicy -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ShrinkPolicy -> Pair) -> Maybe ShrinkPolicy -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ShrinkPolicy
shrinkPolicy,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"InstanceGroupId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
instanceGroupId)
          ]
      )