{-# 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.Batch.Types.ComputeResourceUpdate
-- 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.Batch.Types.ComputeResourceUpdate where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object representing the attributes of a compute environment that can
-- be updated. For more information, see
-- <https://docs.aws.amazon.com/batch/latest/userguide/compute_environments.html Compute Environments>
-- in the /Batch User Guide/.
--
-- /See:/ 'newComputeResourceUpdate' smart constructor.
data ComputeResourceUpdate = ComputeResourceUpdate'
  { -- | The Amazon EC2 security groups associated with instances launched in the
    -- compute environment. This parameter is required for Fargate compute
    -- resources, where it can contain up to 5 security groups. This can\'t be
    -- specified for EC2 compute resources. Providing an empty list is handled
    -- as if this parameter wasn\'t specified and no change is made.
    ComputeResourceUpdate -> Maybe [Text]
securityGroupIds :: Prelude.Maybe [Prelude.Text],
    -- | The VPC subnets where the compute resources are launched. Fargate
    -- compute resources can contain up to 16 subnets. Providing an empty list
    -- will be handled as if this parameter wasn\'t specified and no change is
    -- made. This can\'t be specified for EC2 compute resources. For more
    -- information, see
    -- <https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html VPCs and Subnets>
    -- in the /Amazon VPC User Guide/.
    ComputeResourceUpdate -> Maybe [Text]
subnets :: Prelude.Maybe [Prelude.Text],
    -- | The minimum number of Amazon EC2 vCPUs that an environment should
    -- maintain.
    --
    -- This parameter isn\'t applicable to jobs that are running on Fargate
    -- resources, and shouldn\'t be specified.
    ComputeResourceUpdate -> Maybe Int
minvCpus :: Prelude.Maybe Prelude.Int,
    -- | The maximum number of Amazon EC2 vCPUs that an environment can reach.
    --
    -- With both @BEST_FIT_PROGRESSIVE@ and @SPOT_CAPACITY_OPTIMIZED@
    -- allocation strategies, Batch might need to exceed @maxvCpus@ to meet
    -- your capacity requirements. In this event, Batch never exceeds
    -- @maxvCpus@ by more than a single instance. That is, no more than a
    -- single instance from among those specified in your compute environment.
    ComputeResourceUpdate -> Maybe Int
maxvCpus :: Prelude.Maybe Prelude.Int,
    -- | The desired number of Amazon EC2 vCPUS in the compute environment.
    --
    -- This parameter isn\'t applicable to jobs that are running on Fargate
    -- resources, and shouldn\'t be specified.
    ComputeResourceUpdate -> Maybe Int
desiredvCpus :: Prelude.Maybe Prelude.Int
  }
  deriving (ComputeResourceUpdate -> ComputeResourceUpdate -> Bool
(ComputeResourceUpdate -> ComputeResourceUpdate -> Bool)
-> (ComputeResourceUpdate -> ComputeResourceUpdate -> Bool)
-> Eq ComputeResourceUpdate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ComputeResourceUpdate -> ComputeResourceUpdate -> Bool
$c/= :: ComputeResourceUpdate -> ComputeResourceUpdate -> Bool
== :: ComputeResourceUpdate -> ComputeResourceUpdate -> Bool
$c== :: ComputeResourceUpdate -> ComputeResourceUpdate -> Bool
Prelude.Eq, ReadPrec [ComputeResourceUpdate]
ReadPrec ComputeResourceUpdate
Int -> ReadS ComputeResourceUpdate
ReadS [ComputeResourceUpdate]
(Int -> ReadS ComputeResourceUpdate)
-> ReadS [ComputeResourceUpdate]
-> ReadPrec ComputeResourceUpdate
-> ReadPrec [ComputeResourceUpdate]
-> Read ComputeResourceUpdate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ComputeResourceUpdate]
$creadListPrec :: ReadPrec [ComputeResourceUpdate]
readPrec :: ReadPrec ComputeResourceUpdate
$creadPrec :: ReadPrec ComputeResourceUpdate
readList :: ReadS [ComputeResourceUpdate]
$creadList :: ReadS [ComputeResourceUpdate]
readsPrec :: Int -> ReadS ComputeResourceUpdate
$creadsPrec :: Int -> ReadS ComputeResourceUpdate
Prelude.Read, Int -> ComputeResourceUpdate -> ShowS
[ComputeResourceUpdate] -> ShowS
ComputeResourceUpdate -> String
(Int -> ComputeResourceUpdate -> ShowS)
-> (ComputeResourceUpdate -> String)
-> ([ComputeResourceUpdate] -> ShowS)
-> Show ComputeResourceUpdate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ComputeResourceUpdate] -> ShowS
$cshowList :: [ComputeResourceUpdate] -> ShowS
show :: ComputeResourceUpdate -> String
$cshow :: ComputeResourceUpdate -> String
showsPrec :: Int -> ComputeResourceUpdate -> ShowS
$cshowsPrec :: Int -> ComputeResourceUpdate -> ShowS
Prelude.Show, (forall x. ComputeResourceUpdate -> Rep ComputeResourceUpdate x)
-> (forall x. Rep ComputeResourceUpdate x -> ComputeResourceUpdate)
-> Generic ComputeResourceUpdate
forall x. Rep ComputeResourceUpdate x -> ComputeResourceUpdate
forall x. ComputeResourceUpdate -> Rep ComputeResourceUpdate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ComputeResourceUpdate x -> ComputeResourceUpdate
$cfrom :: forall x. ComputeResourceUpdate -> Rep ComputeResourceUpdate x
Prelude.Generic)

-- |
-- Create a value of 'ComputeResourceUpdate' 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:
--
-- 'securityGroupIds', 'computeResourceUpdate_securityGroupIds' - The Amazon EC2 security groups associated with instances launched in the
-- compute environment. This parameter is required for Fargate compute
-- resources, where it can contain up to 5 security groups. This can\'t be
-- specified for EC2 compute resources. Providing an empty list is handled
-- as if this parameter wasn\'t specified and no change is made.
--
-- 'subnets', 'computeResourceUpdate_subnets' - The VPC subnets where the compute resources are launched. Fargate
-- compute resources can contain up to 16 subnets. Providing an empty list
-- will be handled as if this parameter wasn\'t specified and no change is
-- made. This can\'t be specified for EC2 compute resources. For more
-- information, see
-- <https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html VPCs and Subnets>
-- in the /Amazon VPC User Guide/.
--
-- 'minvCpus', 'computeResourceUpdate_minvCpus' - The minimum number of Amazon EC2 vCPUs that an environment should
-- maintain.
--
-- This parameter isn\'t applicable to jobs that are running on Fargate
-- resources, and shouldn\'t be specified.
--
-- 'maxvCpus', 'computeResourceUpdate_maxvCpus' - The maximum number of Amazon EC2 vCPUs that an environment can reach.
--
-- With both @BEST_FIT_PROGRESSIVE@ and @SPOT_CAPACITY_OPTIMIZED@
-- allocation strategies, Batch might need to exceed @maxvCpus@ to meet
-- your capacity requirements. In this event, Batch never exceeds
-- @maxvCpus@ by more than a single instance. That is, no more than a
-- single instance from among those specified in your compute environment.
--
-- 'desiredvCpus', 'computeResourceUpdate_desiredvCpus' - The desired number of Amazon EC2 vCPUS in the compute environment.
--
-- This parameter isn\'t applicable to jobs that are running on Fargate
-- resources, and shouldn\'t be specified.
newComputeResourceUpdate ::
  ComputeResourceUpdate
newComputeResourceUpdate :: ComputeResourceUpdate
newComputeResourceUpdate =
  ComputeResourceUpdate' :: Maybe [Text]
-> Maybe [Text]
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> ComputeResourceUpdate
ComputeResourceUpdate'
    { $sel:securityGroupIds:ComputeResourceUpdate' :: Maybe [Text]
securityGroupIds =
        Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:subnets:ComputeResourceUpdate' :: Maybe [Text]
subnets = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:minvCpus:ComputeResourceUpdate' :: Maybe Int
minvCpus = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:maxvCpus:ComputeResourceUpdate' :: Maybe Int
maxvCpus = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:desiredvCpus:ComputeResourceUpdate' :: Maybe Int
desiredvCpus = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon EC2 security groups associated with instances launched in the
-- compute environment. This parameter is required for Fargate compute
-- resources, where it can contain up to 5 security groups. This can\'t be
-- specified for EC2 compute resources. Providing an empty list is handled
-- as if this parameter wasn\'t specified and no change is made.
computeResourceUpdate_securityGroupIds :: Lens.Lens' ComputeResourceUpdate (Prelude.Maybe [Prelude.Text])
computeResourceUpdate_securityGroupIds :: (Maybe [Text] -> f (Maybe [Text]))
-> ComputeResourceUpdate -> f ComputeResourceUpdate
computeResourceUpdate_securityGroupIds = (ComputeResourceUpdate -> Maybe [Text])
-> (ComputeResourceUpdate -> Maybe [Text] -> ComputeResourceUpdate)
-> Lens
     ComputeResourceUpdate
     ComputeResourceUpdate
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComputeResourceUpdate' {Maybe [Text]
securityGroupIds :: Maybe [Text]
$sel:securityGroupIds:ComputeResourceUpdate' :: ComputeResourceUpdate -> Maybe [Text]
securityGroupIds} -> Maybe [Text]
securityGroupIds) (\s :: ComputeResourceUpdate
s@ComputeResourceUpdate' {} Maybe [Text]
a -> ComputeResourceUpdate
s {$sel:securityGroupIds:ComputeResourceUpdate' :: Maybe [Text]
securityGroupIds = Maybe [Text]
a} :: ComputeResourceUpdate) ((Maybe [Text] -> f (Maybe [Text]))
 -> ComputeResourceUpdate -> f ComputeResourceUpdate)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ComputeResourceUpdate
-> f ComputeResourceUpdate
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

-- | The VPC subnets where the compute resources are launched. Fargate
-- compute resources can contain up to 16 subnets. Providing an empty list
-- will be handled as if this parameter wasn\'t specified and no change is
-- made. This can\'t be specified for EC2 compute resources. For more
-- information, see
-- <https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html VPCs and Subnets>
-- in the /Amazon VPC User Guide/.
computeResourceUpdate_subnets :: Lens.Lens' ComputeResourceUpdate (Prelude.Maybe [Prelude.Text])
computeResourceUpdate_subnets :: (Maybe [Text] -> f (Maybe [Text]))
-> ComputeResourceUpdate -> f ComputeResourceUpdate
computeResourceUpdate_subnets = (ComputeResourceUpdate -> Maybe [Text])
-> (ComputeResourceUpdate -> Maybe [Text] -> ComputeResourceUpdate)
-> Lens
     ComputeResourceUpdate
     ComputeResourceUpdate
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComputeResourceUpdate' {Maybe [Text]
subnets :: Maybe [Text]
$sel:subnets:ComputeResourceUpdate' :: ComputeResourceUpdate -> Maybe [Text]
subnets} -> Maybe [Text]
subnets) (\s :: ComputeResourceUpdate
s@ComputeResourceUpdate' {} Maybe [Text]
a -> ComputeResourceUpdate
s {$sel:subnets:ComputeResourceUpdate' :: Maybe [Text]
subnets = Maybe [Text]
a} :: ComputeResourceUpdate) ((Maybe [Text] -> f (Maybe [Text]))
 -> ComputeResourceUpdate -> f ComputeResourceUpdate)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ComputeResourceUpdate
-> f ComputeResourceUpdate
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

-- | The minimum number of Amazon EC2 vCPUs that an environment should
-- maintain.
--
-- This parameter isn\'t applicable to jobs that are running on Fargate
-- resources, and shouldn\'t be specified.
computeResourceUpdate_minvCpus :: Lens.Lens' ComputeResourceUpdate (Prelude.Maybe Prelude.Int)
computeResourceUpdate_minvCpus :: (Maybe Int -> f (Maybe Int))
-> ComputeResourceUpdate -> f ComputeResourceUpdate
computeResourceUpdate_minvCpus = (ComputeResourceUpdate -> Maybe Int)
-> (ComputeResourceUpdate -> Maybe Int -> ComputeResourceUpdate)
-> Lens
     ComputeResourceUpdate ComputeResourceUpdate (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComputeResourceUpdate' {Maybe Int
minvCpus :: Maybe Int
$sel:minvCpus:ComputeResourceUpdate' :: ComputeResourceUpdate -> Maybe Int
minvCpus} -> Maybe Int
minvCpus) (\s :: ComputeResourceUpdate
s@ComputeResourceUpdate' {} Maybe Int
a -> ComputeResourceUpdate
s {$sel:minvCpus:ComputeResourceUpdate' :: Maybe Int
minvCpus = Maybe Int
a} :: ComputeResourceUpdate)

-- | The maximum number of Amazon EC2 vCPUs that an environment can reach.
--
-- With both @BEST_FIT_PROGRESSIVE@ and @SPOT_CAPACITY_OPTIMIZED@
-- allocation strategies, Batch might need to exceed @maxvCpus@ to meet
-- your capacity requirements. In this event, Batch never exceeds
-- @maxvCpus@ by more than a single instance. That is, no more than a
-- single instance from among those specified in your compute environment.
computeResourceUpdate_maxvCpus :: Lens.Lens' ComputeResourceUpdate (Prelude.Maybe Prelude.Int)
computeResourceUpdate_maxvCpus :: (Maybe Int -> f (Maybe Int))
-> ComputeResourceUpdate -> f ComputeResourceUpdate
computeResourceUpdate_maxvCpus = (ComputeResourceUpdate -> Maybe Int)
-> (ComputeResourceUpdate -> Maybe Int -> ComputeResourceUpdate)
-> Lens
     ComputeResourceUpdate ComputeResourceUpdate (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComputeResourceUpdate' {Maybe Int
maxvCpus :: Maybe Int
$sel:maxvCpus:ComputeResourceUpdate' :: ComputeResourceUpdate -> Maybe Int
maxvCpus} -> Maybe Int
maxvCpus) (\s :: ComputeResourceUpdate
s@ComputeResourceUpdate' {} Maybe Int
a -> ComputeResourceUpdate
s {$sel:maxvCpus:ComputeResourceUpdate' :: Maybe Int
maxvCpus = Maybe Int
a} :: ComputeResourceUpdate)

-- | The desired number of Amazon EC2 vCPUS in the compute environment.
--
-- This parameter isn\'t applicable to jobs that are running on Fargate
-- resources, and shouldn\'t be specified.
computeResourceUpdate_desiredvCpus :: Lens.Lens' ComputeResourceUpdate (Prelude.Maybe Prelude.Int)
computeResourceUpdate_desiredvCpus :: (Maybe Int -> f (Maybe Int))
-> ComputeResourceUpdate -> f ComputeResourceUpdate
computeResourceUpdate_desiredvCpus = (ComputeResourceUpdate -> Maybe Int)
-> (ComputeResourceUpdate -> Maybe Int -> ComputeResourceUpdate)
-> Lens
     ComputeResourceUpdate ComputeResourceUpdate (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ComputeResourceUpdate' {Maybe Int
desiredvCpus :: Maybe Int
$sel:desiredvCpus:ComputeResourceUpdate' :: ComputeResourceUpdate -> Maybe Int
desiredvCpus} -> Maybe Int
desiredvCpus) (\s :: ComputeResourceUpdate
s@ComputeResourceUpdate' {} Maybe Int
a -> ComputeResourceUpdate
s {$sel:desiredvCpus:ComputeResourceUpdate' :: Maybe Int
desiredvCpus = Maybe Int
a} :: ComputeResourceUpdate)

instance Prelude.Hashable ComputeResourceUpdate

instance Prelude.NFData ComputeResourceUpdate

instance Core.ToJSON ComputeResourceUpdate where
  toJSON :: ComputeResourceUpdate -> Value
toJSON ComputeResourceUpdate' {Maybe Int
Maybe [Text]
desiredvCpus :: Maybe Int
maxvCpus :: Maybe Int
minvCpus :: Maybe Int
subnets :: Maybe [Text]
securityGroupIds :: Maybe [Text]
$sel:desiredvCpus:ComputeResourceUpdate' :: ComputeResourceUpdate -> Maybe Int
$sel:maxvCpus:ComputeResourceUpdate' :: ComputeResourceUpdate -> Maybe Int
$sel:minvCpus:ComputeResourceUpdate' :: ComputeResourceUpdate -> Maybe Int
$sel:subnets:ComputeResourceUpdate' :: ComputeResourceUpdate -> Maybe [Text]
$sel:securityGroupIds:ComputeResourceUpdate' :: ComputeResourceUpdate -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"securityGroupIds" 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]
securityGroupIds,
            (Text
"subnets" 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]
subnets,
            (Text
"minvCpus" 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
minvCpus,
            (Text
"maxvCpus" 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
maxvCpus,
            (Text
"desiredvCpus" 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
desiredvCpus
          ]
      )