{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.CreateComputeEnvironment
-- 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)
--
-- Creates an Batch compute environment. You can create @MANAGED@ or
-- @UNMANAGED@ compute environments. @MANAGED@ compute environments can use
-- Amazon EC2 or Fargate resources. @UNMANAGED@ compute environments can
-- only use EC2 resources.
--
-- In a managed compute environment, Batch manages the capacity and
-- instance types of the compute resources within the environment. This is
-- based on the compute resource specification that you define or the
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-templates.html launch template>
-- that you specify when you create the compute environment. Either, you
-- can choose to use EC2 On-Demand Instances and EC2 Spot Instances. Or,
-- you can use Fargate and Fargate Spot capacity in your managed compute
-- environment. You can optionally set a maximum price so that Spot
-- Instances only launch when the Spot Instance price is less than a
-- specified percentage of the On-Demand price.
--
-- Multi-node parallel jobs aren\'t supported on Spot Instances.
--
-- In an unmanaged compute environment, you can manage your own EC2 compute
-- resources and have a lot of flexibility with how you configure your
-- compute resources. For example, you can use custom AMIs. However, you
-- must verify that each of your AMIs meet the Amazon ECS container
-- instance AMI specification. For more information, see
-- <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/container_instance_AMIs.html container instance AMIs>
-- in the /Amazon Elastic Container Service Developer Guide/. After you
-- created your unmanaged compute environment, you can use the
-- DescribeComputeEnvironments operation to find the Amazon ECS cluster
-- that\'s associated with it. Then, launch your container instances into
-- that Amazon ECS cluster. For more information, see
-- <https://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_container_instance.html Launching an Amazon ECS container instance>
-- in the /Amazon Elastic Container Service Developer Guide/.
--
-- Batch doesn\'t upgrade the AMIs in a compute environment after the
-- environment is created. For example, it doesn\'t update the AMIs when a
-- newer version of the Amazon ECS optimized AMI is available. Therefore,
-- you\'re responsible for managing the guest operating system (including
-- its updates and security patches) and any additional application
-- software or utilities that you install on the compute resources. To use
-- a new AMI for your Batch jobs, complete these steps:
--
-- 1.  Create a new compute environment with the new AMI.
--
-- 2.  Add the compute environment to an existing job queue.
--
-- 3.  Remove the earlier compute environment from your job queue.
--
-- 4.  Delete the earlier compute environment.
module Amazonka.Batch.CreateComputeEnvironment
  ( -- * Creating a Request
    CreateComputeEnvironment (..),
    newCreateComputeEnvironment,

    -- * Request Lenses
    createComputeEnvironment_state,
    createComputeEnvironment_computeResources,
    createComputeEnvironment_serviceRole,
    createComputeEnvironment_tags,
    createComputeEnvironment_computeEnvironmentName,
    createComputeEnvironment_type,

    -- * Destructuring the Response
    CreateComputeEnvironmentResponse (..),
    newCreateComputeEnvironmentResponse,

    -- * Response Lenses
    createComputeEnvironmentResponse_computeEnvironmentName,
    createComputeEnvironmentResponse_computeEnvironmentArn,
    createComputeEnvironmentResponse_httpStatus,
  )
where

import Amazonka.Batch.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Contains the parameters for @CreateComputeEnvironment@.
--
-- /See:/ 'newCreateComputeEnvironment' smart constructor.
data CreateComputeEnvironment = CreateComputeEnvironment'
  { -- | The state of the compute environment. If the state is @ENABLED@, then
    -- the compute environment accepts jobs from a queue and can scale out
    -- automatically based on queues.
    --
    -- If the state is @ENABLED@, then the Batch scheduler can attempt to place
    -- jobs from an associated job queue on the compute resources within the
    -- environment. If the compute environment is managed, then it can scale
    -- its instances out or in automatically, based on the job queue demand.
    --
    -- If the state is @DISABLED@, then the Batch scheduler doesn\'t attempt to
    -- place jobs within the environment. Jobs in a @STARTING@ or @RUNNING@
    -- state continue to progress normally. Managed compute environments in the
    -- @DISABLED@ state don\'t scale out. However, they scale in to @minvCpus@
    -- value after instances become idle.
    CreateComputeEnvironment -> Maybe CEState
state :: Prelude.Maybe CEState,
    -- | Details about the compute resources managed by the compute environment.
    -- This parameter is required for managed compute environments. For more
    -- information, see
    -- <https://docs.aws.amazon.com/batch/latest/userguide/compute_environments.html Compute Environments>
    -- in the /Batch User Guide/.
    CreateComputeEnvironment -> Maybe ComputeResource
computeResources :: Prelude.Maybe ComputeResource,
    -- | The full Amazon Resource Name (ARN) of the IAM role that allows Batch to
    -- make calls to other Amazon Web Services services on your behalf. For
    -- more information, see
    -- <https://docs.aws.amazon.com/batch/latest/userguide/service_IAM_role.html Batch service IAM role>
    -- in the /Batch User Guide/.
    --
    -- If your account already created the Batch service-linked role, that role
    -- is used by default for your compute environment unless you specify a
    -- different role here. If the Batch service-linked role doesn\'t exist in
    -- your account, and no role is specified here, the service attempts to
    -- create the Batch service-linked role in your account.
    --
    -- If your specified role has a path other than @\/@, then you must specify
    -- either the full role ARN (recommended) or prefix the role name with the
    -- path. For example, if a role with the name @bar@ has a path of @\/foo\/@
    -- then you would specify @\/foo\/bar@ as the role name. For more
    -- information, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-friendly-names Friendly names and paths>
    -- in the /IAM User Guide/.
    --
    -- Depending on how you created your Batch service role, its ARN might
    -- contain the @service-role@ path prefix. When you only specify the name
    -- of the service role, Batch assumes that your ARN doesn\'t use the
    -- @service-role@ path prefix. Because of this, we recommend that you
    -- specify the full ARN of your service role when you create compute
    -- environments.
    CreateComputeEnvironment -> Maybe Text
serviceRole :: Prelude.Maybe Prelude.Text,
    -- | The tags that you apply to the compute environment to help you
    -- categorize and organize your resources. Each tag consists of a key and
    -- an optional value. For more information, see
    -- <https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html Tagging Amazon Web Services Resources>
    -- in /Amazon Web Services General Reference/.
    --
    -- These tags can be updated or removed using the
    -- <https://docs.aws.amazon.com/batch/latest/APIReference/API_TagResource.html TagResource>
    -- and
    -- <https://docs.aws.amazon.com/batch/latest/APIReference/API_UntagResource.html UntagResource>
    -- API operations. These tags don\'t propagate to the underlying compute
    -- resources.
    CreateComputeEnvironment -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The name for your compute environment. Up to 128 letters (uppercase and
    -- lowercase), numbers, hyphens, and underscores are allowed.
    CreateComputeEnvironment -> Text
computeEnvironmentName :: Prelude.Text,
    -- | The type of the compute environment: @MANAGED@ or @UNMANAGED@. For more
    -- information, see
    -- <https://docs.aws.amazon.com/batch/latest/userguide/compute_environments.html Compute Environments>
    -- in the /Batch User Guide/.
    CreateComputeEnvironment -> CEType
type' :: CEType
  }
  deriving (CreateComputeEnvironment -> CreateComputeEnvironment -> Bool
(CreateComputeEnvironment -> CreateComputeEnvironment -> Bool)
-> (CreateComputeEnvironment -> CreateComputeEnvironment -> Bool)
-> Eq CreateComputeEnvironment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateComputeEnvironment -> CreateComputeEnvironment -> Bool
$c/= :: CreateComputeEnvironment -> CreateComputeEnvironment -> Bool
== :: CreateComputeEnvironment -> CreateComputeEnvironment -> Bool
$c== :: CreateComputeEnvironment -> CreateComputeEnvironment -> Bool
Prelude.Eq, ReadPrec [CreateComputeEnvironment]
ReadPrec CreateComputeEnvironment
Int -> ReadS CreateComputeEnvironment
ReadS [CreateComputeEnvironment]
(Int -> ReadS CreateComputeEnvironment)
-> ReadS [CreateComputeEnvironment]
-> ReadPrec CreateComputeEnvironment
-> ReadPrec [CreateComputeEnvironment]
-> Read CreateComputeEnvironment
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateComputeEnvironment]
$creadListPrec :: ReadPrec [CreateComputeEnvironment]
readPrec :: ReadPrec CreateComputeEnvironment
$creadPrec :: ReadPrec CreateComputeEnvironment
readList :: ReadS [CreateComputeEnvironment]
$creadList :: ReadS [CreateComputeEnvironment]
readsPrec :: Int -> ReadS CreateComputeEnvironment
$creadsPrec :: Int -> ReadS CreateComputeEnvironment
Prelude.Read, Int -> CreateComputeEnvironment -> ShowS
[CreateComputeEnvironment] -> ShowS
CreateComputeEnvironment -> String
(Int -> CreateComputeEnvironment -> ShowS)
-> (CreateComputeEnvironment -> String)
-> ([CreateComputeEnvironment] -> ShowS)
-> Show CreateComputeEnvironment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateComputeEnvironment] -> ShowS
$cshowList :: [CreateComputeEnvironment] -> ShowS
show :: CreateComputeEnvironment -> String
$cshow :: CreateComputeEnvironment -> String
showsPrec :: Int -> CreateComputeEnvironment -> ShowS
$cshowsPrec :: Int -> CreateComputeEnvironment -> ShowS
Prelude.Show, (forall x.
 CreateComputeEnvironment -> Rep CreateComputeEnvironment x)
-> (forall x.
    Rep CreateComputeEnvironment x -> CreateComputeEnvironment)
-> Generic CreateComputeEnvironment
forall x.
Rep CreateComputeEnvironment x -> CreateComputeEnvironment
forall x.
CreateComputeEnvironment -> Rep CreateComputeEnvironment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateComputeEnvironment x -> CreateComputeEnvironment
$cfrom :: forall x.
CreateComputeEnvironment -> Rep CreateComputeEnvironment x
Prelude.Generic)

-- |
-- Create a value of 'CreateComputeEnvironment' 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:
--
-- 'state', 'createComputeEnvironment_state' - The state of the compute environment. If the state is @ENABLED@, then
-- the compute environment accepts jobs from a queue and can scale out
-- automatically based on queues.
--
-- If the state is @ENABLED@, then the Batch scheduler can attempt to place
-- jobs from an associated job queue on the compute resources within the
-- environment. If the compute environment is managed, then it can scale
-- its instances out or in automatically, based on the job queue demand.
--
-- If the state is @DISABLED@, then the Batch scheduler doesn\'t attempt to
-- place jobs within the environment. Jobs in a @STARTING@ or @RUNNING@
-- state continue to progress normally. Managed compute environments in the
-- @DISABLED@ state don\'t scale out. However, they scale in to @minvCpus@
-- value after instances become idle.
--
-- 'computeResources', 'createComputeEnvironment_computeResources' - Details about the compute resources managed by the compute environment.
-- This parameter is required for managed compute environments. For more
-- information, see
-- <https://docs.aws.amazon.com/batch/latest/userguide/compute_environments.html Compute Environments>
-- in the /Batch User Guide/.
--
-- 'serviceRole', 'createComputeEnvironment_serviceRole' - The full Amazon Resource Name (ARN) of the IAM role that allows Batch to
-- make calls to other Amazon Web Services services on your behalf. For
-- more information, see
-- <https://docs.aws.amazon.com/batch/latest/userguide/service_IAM_role.html Batch service IAM role>
-- in the /Batch User Guide/.
--
-- If your account already created the Batch service-linked role, that role
-- is used by default for your compute environment unless you specify a
-- different role here. If the Batch service-linked role doesn\'t exist in
-- your account, and no role is specified here, the service attempts to
-- create the Batch service-linked role in your account.
--
-- If your specified role has a path other than @\/@, then you must specify
-- either the full role ARN (recommended) or prefix the role name with the
-- path. For example, if a role with the name @bar@ has a path of @\/foo\/@
-- then you would specify @\/foo\/bar@ as the role name. For more
-- information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-friendly-names Friendly names and paths>
-- in the /IAM User Guide/.
--
-- Depending on how you created your Batch service role, its ARN might
-- contain the @service-role@ path prefix. When you only specify the name
-- of the service role, Batch assumes that your ARN doesn\'t use the
-- @service-role@ path prefix. Because of this, we recommend that you
-- specify the full ARN of your service role when you create compute
-- environments.
--
-- 'tags', 'createComputeEnvironment_tags' - The tags that you apply to the compute environment to help you
-- categorize and organize your resources. Each tag consists of a key and
-- an optional value. For more information, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html Tagging Amazon Web Services Resources>
-- in /Amazon Web Services General Reference/.
--
-- These tags can be updated or removed using the
-- <https://docs.aws.amazon.com/batch/latest/APIReference/API_TagResource.html TagResource>
-- and
-- <https://docs.aws.amazon.com/batch/latest/APIReference/API_UntagResource.html UntagResource>
-- API operations. These tags don\'t propagate to the underlying compute
-- resources.
--
-- 'computeEnvironmentName', 'createComputeEnvironment_computeEnvironmentName' - The name for your compute environment. Up to 128 letters (uppercase and
-- lowercase), numbers, hyphens, and underscores are allowed.
--
-- 'type'', 'createComputeEnvironment_type' - The type of the compute environment: @MANAGED@ or @UNMANAGED@. For more
-- information, see
-- <https://docs.aws.amazon.com/batch/latest/userguide/compute_environments.html Compute Environments>
-- in the /Batch User Guide/.
newCreateComputeEnvironment ::
  -- | 'computeEnvironmentName'
  Prelude.Text ->
  -- | 'type''
  CEType ->
  CreateComputeEnvironment
newCreateComputeEnvironment :: Text -> CEType -> CreateComputeEnvironment
newCreateComputeEnvironment
  Text
pComputeEnvironmentName_
  CEType
pType_ =
    CreateComputeEnvironment' :: Maybe CEState
-> Maybe ComputeResource
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> CEType
-> CreateComputeEnvironment
CreateComputeEnvironment'
      { $sel:state:CreateComputeEnvironment' :: Maybe CEState
state = Maybe CEState
forall a. Maybe a
Prelude.Nothing,
        $sel:computeResources:CreateComputeEnvironment' :: Maybe ComputeResource
computeResources = Maybe ComputeResource
forall a. Maybe a
Prelude.Nothing,
        $sel:serviceRole:CreateComputeEnvironment' :: Maybe Text
serviceRole = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateComputeEnvironment' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:computeEnvironmentName:CreateComputeEnvironment' :: Text
computeEnvironmentName = Text
pComputeEnvironmentName_,
        $sel:type':CreateComputeEnvironment' :: CEType
type' = CEType
pType_
      }

-- | The state of the compute environment. If the state is @ENABLED@, then
-- the compute environment accepts jobs from a queue and can scale out
-- automatically based on queues.
--
-- If the state is @ENABLED@, then the Batch scheduler can attempt to place
-- jobs from an associated job queue on the compute resources within the
-- environment. If the compute environment is managed, then it can scale
-- its instances out or in automatically, based on the job queue demand.
--
-- If the state is @DISABLED@, then the Batch scheduler doesn\'t attempt to
-- place jobs within the environment. Jobs in a @STARTING@ or @RUNNING@
-- state continue to progress normally. Managed compute environments in the
-- @DISABLED@ state don\'t scale out. However, they scale in to @minvCpus@
-- value after instances become idle.
createComputeEnvironment_state :: Lens.Lens' CreateComputeEnvironment (Prelude.Maybe CEState)
createComputeEnvironment_state :: (Maybe CEState -> f (Maybe CEState))
-> CreateComputeEnvironment -> f CreateComputeEnvironment
createComputeEnvironment_state = (CreateComputeEnvironment -> Maybe CEState)
-> (CreateComputeEnvironment
    -> Maybe CEState -> CreateComputeEnvironment)
-> Lens
     CreateComputeEnvironment
     CreateComputeEnvironment
     (Maybe CEState)
     (Maybe CEState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComputeEnvironment' {Maybe CEState
state :: Maybe CEState
$sel:state:CreateComputeEnvironment' :: CreateComputeEnvironment -> Maybe CEState
state} -> Maybe CEState
state) (\s :: CreateComputeEnvironment
s@CreateComputeEnvironment' {} Maybe CEState
a -> CreateComputeEnvironment
s {$sel:state:CreateComputeEnvironment' :: Maybe CEState
state = Maybe CEState
a} :: CreateComputeEnvironment)

-- | Details about the compute resources managed by the compute environment.
-- This parameter is required for managed compute environments. For more
-- information, see
-- <https://docs.aws.amazon.com/batch/latest/userguide/compute_environments.html Compute Environments>
-- in the /Batch User Guide/.
createComputeEnvironment_computeResources :: Lens.Lens' CreateComputeEnvironment (Prelude.Maybe ComputeResource)
createComputeEnvironment_computeResources :: (Maybe ComputeResource -> f (Maybe ComputeResource))
-> CreateComputeEnvironment -> f CreateComputeEnvironment
createComputeEnvironment_computeResources = (CreateComputeEnvironment -> Maybe ComputeResource)
-> (CreateComputeEnvironment
    -> Maybe ComputeResource -> CreateComputeEnvironment)
-> Lens
     CreateComputeEnvironment
     CreateComputeEnvironment
     (Maybe ComputeResource)
     (Maybe ComputeResource)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComputeEnvironment' {Maybe ComputeResource
computeResources :: Maybe ComputeResource
$sel:computeResources:CreateComputeEnvironment' :: CreateComputeEnvironment -> Maybe ComputeResource
computeResources} -> Maybe ComputeResource
computeResources) (\s :: CreateComputeEnvironment
s@CreateComputeEnvironment' {} Maybe ComputeResource
a -> CreateComputeEnvironment
s {$sel:computeResources:CreateComputeEnvironment' :: Maybe ComputeResource
computeResources = Maybe ComputeResource
a} :: CreateComputeEnvironment)

-- | The full Amazon Resource Name (ARN) of the IAM role that allows Batch to
-- make calls to other Amazon Web Services services on your behalf. For
-- more information, see
-- <https://docs.aws.amazon.com/batch/latest/userguide/service_IAM_role.html Batch service IAM role>
-- in the /Batch User Guide/.
--
-- If your account already created the Batch service-linked role, that role
-- is used by default for your compute environment unless you specify a
-- different role here. If the Batch service-linked role doesn\'t exist in
-- your account, and no role is specified here, the service attempts to
-- create the Batch service-linked role in your account.
--
-- If your specified role has a path other than @\/@, then you must specify
-- either the full role ARN (recommended) or prefix the role name with the
-- path. For example, if a role with the name @bar@ has a path of @\/foo\/@
-- then you would specify @\/foo\/bar@ as the role name. For more
-- information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html#identifiers-friendly-names Friendly names and paths>
-- in the /IAM User Guide/.
--
-- Depending on how you created your Batch service role, its ARN might
-- contain the @service-role@ path prefix. When you only specify the name
-- of the service role, Batch assumes that your ARN doesn\'t use the
-- @service-role@ path prefix. Because of this, we recommend that you
-- specify the full ARN of your service role when you create compute
-- environments.
createComputeEnvironment_serviceRole :: Lens.Lens' CreateComputeEnvironment (Prelude.Maybe Prelude.Text)
createComputeEnvironment_serviceRole :: (Maybe Text -> f (Maybe Text))
-> CreateComputeEnvironment -> f CreateComputeEnvironment
createComputeEnvironment_serviceRole = (CreateComputeEnvironment -> Maybe Text)
-> (CreateComputeEnvironment
    -> Maybe Text -> CreateComputeEnvironment)
-> Lens
     CreateComputeEnvironment
     CreateComputeEnvironment
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComputeEnvironment' {Maybe Text
serviceRole :: Maybe Text
$sel:serviceRole:CreateComputeEnvironment' :: CreateComputeEnvironment -> Maybe Text
serviceRole} -> Maybe Text
serviceRole) (\s :: CreateComputeEnvironment
s@CreateComputeEnvironment' {} Maybe Text
a -> CreateComputeEnvironment
s {$sel:serviceRole:CreateComputeEnvironment' :: Maybe Text
serviceRole = Maybe Text
a} :: CreateComputeEnvironment)

-- | The tags that you apply to the compute environment to help you
-- categorize and organize your resources. Each tag consists of a key and
-- an optional value. For more information, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html Tagging Amazon Web Services Resources>
-- in /Amazon Web Services General Reference/.
--
-- These tags can be updated or removed using the
-- <https://docs.aws.amazon.com/batch/latest/APIReference/API_TagResource.html TagResource>
-- and
-- <https://docs.aws.amazon.com/batch/latest/APIReference/API_UntagResource.html UntagResource>
-- API operations. These tags don\'t propagate to the underlying compute
-- resources.
createComputeEnvironment_tags :: Lens.Lens' CreateComputeEnvironment (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createComputeEnvironment_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateComputeEnvironment -> f CreateComputeEnvironment
createComputeEnvironment_tags = (CreateComputeEnvironment -> Maybe (HashMap Text Text))
-> (CreateComputeEnvironment
    -> Maybe (HashMap Text Text) -> CreateComputeEnvironment)
-> Lens
     CreateComputeEnvironment
     CreateComputeEnvironment
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComputeEnvironment' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateComputeEnvironment' :: CreateComputeEnvironment -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateComputeEnvironment
s@CreateComputeEnvironment' {} Maybe (HashMap Text Text)
a -> CreateComputeEnvironment
s {$sel:tags:CreateComputeEnvironment' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateComputeEnvironment) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CreateComputeEnvironment -> f CreateComputeEnvironment)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateComputeEnvironment
-> f CreateComputeEnvironment
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text 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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name for your compute environment. Up to 128 letters (uppercase and
-- lowercase), numbers, hyphens, and underscores are allowed.
createComputeEnvironment_computeEnvironmentName :: Lens.Lens' CreateComputeEnvironment Prelude.Text
createComputeEnvironment_computeEnvironmentName :: (Text -> f Text)
-> CreateComputeEnvironment -> f CreateComputeEnvironment
createComputeEnvironment_computeEnvironmentName = (CreateComputeEnvironment -> Text)
-> (CreateComputeEnvironment -> Text -> CreateComputeEnvironment)
-> Lens CreateComputeEnvironment CreateComputeEnvironment Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComputeEnvironment' {Text
computeEnvironmentName :: Text
$sel:computeEnvironmentName:CreateComputeEnvironment' :: CreateComputeEnvironment -> Text
computeEnvironmentName} -> Text
computeEnvironmentName) (\s :: CreateComputeEnvironment
s@CreateComputeEnvironment' {} Text
a -> CreateComputeEnvironment
s {$sel:computeEnvironmentName:CreateComputeEnvironment' :: Text
computeEnvironmentName = Text
a} :: CreateComputeEnvironment)

-- | The type of the compute environment: @MANAGED@ or @UNMANAGED@. For more
-- information, see
-- <https://docs.aws.amazon.com/batch/latest/userguide/compute_environments.html Compute Environments>
-- in the /Batch User Guide/.
createComputeEnvironment_type :: Lens.Lens' CreateComputeEnvironment CEType
createComputeEnvironment_type :: (CEType -> f CEType)
-> CreateComputeEnvironment -> f CreateComputeEnvironment
createComputeEnvironment_type = (CreateComputeEnvironment -> CEType)
-> (CreateComputeEnvironment -> CEType -> CreateComputeEnvironment)
-> Lens
     CreateComputeEnvironment CreateComputeEnvironment CEType CEType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComputeEnvironment' {CEType
type' :: CEType
$sel:type':CreateComputeEnvironment' :: CreateComputeEnvironment -> CEType
type'} -> CEType
type') (\s :: CreateComputeEnvironment
s@CreateComputeEnvironment' {} CEType
a -> CreateComputeEnvironment
s {$sel:type':CreateComputeEnvironment' :: CEType
type' = CEType
a} :: CreateComputeEnvironment)

instance Core.AWSRequest CreateComputeEnvironment where
  type
    AWSResponse CreateComputeEnvironment =
      CreateComputeEnvironmentResponse
  request :: CreateComputeEnvironment -> Request CreateComputeEnvironment
request = Service
-> CreateComputeEnvironment -> Request CreateComputeEnvironment
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateComputeEnvironment
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateComputeEnvironment)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateComputeEnvironment))
-> Logger
-> Service
-> Proxy CreateComputeEnvironment
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateComputeEnvironment)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Maybe Text -> Int -> CreateComputeEnvironmentResponse
CreateComputeEnvironmentResponse'
            (Maybe Text
 -> Maybe Text -> Int -> CreateComputeEnvironmentResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Int -> CreateComputeEnvironmentResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"computeEnvironmentName")
            Either
  String (Maybe Text -> Int -> CreateComputeEnvironmentResponse)
-> Either String (Maybe Text)
-> Either String (Int -> CreateComputeEnvironmentResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"computeEnvironmentArn")
            Either String (Int -> CreateComputeEnvironmentResponse)
-> Either String Int
-> Either String CreateComputeEnvironmentResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateComputeEnvironment

instance Prelude.NFData CreateComputeEnvironment

instance Core.ToHeaders CreateComputeEnvironment where
  toHeaders :: CreateComputeEnvironment -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateComputeEnvironment -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON CreateComputeEnvironment where
  toJSON :: CreateComputeEnvironment -> Value
toJSON CreateComputeEnvironment' {Maybe Text
Maybe (HashMap Text Text)
Maybe CEState
Maybe ComputeResource
Text
CEType
type' :: CEType
computeEnvironmentName :: Text
tags :: Maybe (HashMap Text Text)
serviceRole :: Maybe Text
computeResources :: Maybe ComputeResource
state :: Maybe CEState
$sel:type':CreateComputeEnvironment' :: CreateComputeEnvironment -> CEType
$sel:computeEnvironmentName:CreateComputeEnvironment' :: CreateComputeEnvironment -> Text
$sel:tags:CreateComputeEnvironment' :: CreateComputeEnvironment -> Maybe (HashMap Text Text)
$sel:serviceRole:CreateComputeEnvironment' :: CreateComputeEnvironment -> Maybe Text
$sel:computeResources:CreateComputeEnvironment' :: CreateComputeEnvironment -> Maybe ComputeResource
$sel:state:CreateComputeEnvironment' :: CreateComputeEnvironment -> Maybe CEState
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"state" Text -> CEState -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (CEState -> Pair) -> Maybe CEState -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CEState
state,
            (Text
"computeResources" Text -> ComputeResource -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ComputeResource -> Pair) -> Maybe ComputeResource -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ComputeResource
computeResources,
            (Text
"serviceRole" 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
serviceRole,
            (Text
"tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"computeEnvironmentName"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
computeEnvironmentName
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"type" Text -> CEType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= CEType
type')
          ]
      )

instance Core.ToPath CreateComputeEnvironment where
  toPath :: CreateComputeEnvironment -> ByteString
toPath = ByteString -> CreateComputeEnvironment -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/v1/createcomputeenvironment"

instance Core.ToQuery CreateComputeEnvironment where
  toQuery :: CreateComputeEnvironment -> QueryString
toQuery = QueryString -> CreateComputeEnvironment -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newCreateComputeEnvironmentResponse' smart constructor.
data CreateComputeEnvironmentResponse = CreateComputeEnvironmentResponse'
  { -- | The name of the compute environment. Up to 128 letters (uppercase and
    -- lowercase), numbers, hyphens, and underscores are allowed.
    CreateComputeEnvironmentResponse -> Maybe Text
computeEnvironmentName :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the compute environment.
    CreateComputeEnvironmentResponse -> Maybe Text
computeEnvironmentArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    CreateComputeEnvironmentResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateComputeEnvironmentResponse
-> CreateComputeEnvironmentResponse -> Bool
(CreateComputeEnvironmentResponse
 -> CreateComputeEnvironmentResponse -> Bool)
-> (CreateComputeEnvironmentResponse
    -> CreateComputeEnvironmentResponse -> Bool)
-> Eq CreateComputeEnvironmentResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateComputeEnvironmentResponse
-> CreateComputeEnvironmentResponse -> Bool
$c/= :: CreateComputeEnvironmentResponse
-> CreateComputeEnvironmentResponse -> Bool
== :: CreateComputeEnvironmentResponse
-> CreateComputeEnvironmentResponse -> Bool
$c== :: CreateComputeEnvironmentResponse
-> CreateComputeEnvironmentResponse -> Bool
Prelude.Eq, ReadPrec [CreateComputeEnvironmentResponse]
ReadPrec CreateComputeEnvironmentResponse
Int -> ReadS CreateComputeEnvironmentResponse
ReadS [CreateComputeEnvironmentResponse]
(Int -> ReadS CreateComputeEnvironmentResponse)
-> ReadS [CreateComputeEnvironmentResponse]
-> ReadPrec CreateComputeEnvironmentResponse
-> ReadPrec [CreateComputeEnvironmentResponse]
-> Read CreateComputeEnvironmentResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateComputeEnvironmentResponse]
$creadListPrec :: ReadPrec [CreateComputeEnvironmentResponse]
readPrec :: ReadPrec CreateComputeEnvironmentResponse
$creadPrec :: ReadPrec CreateComputeEnvironmentResponse
readList :: ReadS [CreateComputeEnvironmentResponse]
$creadList :: ReadS [CreateComputeEnvironmentResponse]
readsPrec :: Int -> ReadS CreateComputeEnvironmentResponse
$creadsPrec :: Int -> ReadS CreateComputeEnvironmentResponse
Prelude.Read, Int -> CreateComputeEnvironmentResponse -> ShowS
[CreateComputeEnvironmentResponse] -> ShowS
CreateComputeEnvironmentResponse -> String
(Int -> CreateComputeEnvironmentResponse -> ShowS)
-> (CreateComputeEnvironmentResponse -> String)
-> ([CreateComputeEnvironmentResponse] -> ShowS)
-> Show CreateComputeEnvironmentResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateComputeEnvironmentResponse] -> ShowS
$cshowList :: [CreateComputeEnvironmentResponse] -> ShowS
show :: CreateComputeEnvironmentResponse -> String
$cshow :: CreateComputeEnvironmentResponse -> String
showsPrec :: Int -> CreateComputeEnvironmentResponse -> ShowS
$cshowsPrec :: Int -> CreateComputeEnvironmentResponse -> ShowS
Prelude.Show, (forall x.
 CreateComputeEnvironmentResponse
 -> Rep CreateComputeEnvironmentResponse x)
-> (forall x.
    Rep CreateComputeEnvironmentResponse x
    -> CreateComputeEnvironmentResponse)
-> Generic CreateComputeEnvironmentResponse
forall x.
Rep CreateComputeEnvironmentResponse x
-> CreateComputeEnvironmentResponse
forall x.
CreateComputeEnvironmentResponse
-> Rep CreateComputeEnvironmentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateComputeEnvironmentResponse x
-> CreateComputeEnvironmentResponse
$cfrom :: forall x.
CreateComputeEnvironmentResponse
-> Rep CreateComputeEnvironmentResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateComputeEnvironmentResponse' 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:
--
-- 'computeEnvironmentName', 'createComputeEnvironmentResponse_computeEnvironmentName' - The name of the compute environment. Up to 128 letters (uppercase and
-- lowercase), numbers, hyphens, and underscores are allowed.
--
-- 'computeEnvironmentArn', 'createComputeEnvironmentResponse_computeEnvironmentArn' - The Amazon Resource Name (ARN) of the compute environment.
--
-- 'httpStatus', 'createComputeEnvironmentResponse_httpStatus' - The response's http status code.
newCreateComputeEnvironmentResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateComputeEnvironmentResponse
newCreateComputeEnvironmentResponse :: Int -> CreateComputeEnvironmentResponse
newCreateComputeEnvironmentResponse Int
pHttpStatus_ =
  CreateComputeEnvironmentResponse' :: Maybe Text -> Maybe Text -> Int -> CreateComputeEnvironmentResponse
CreateComputeEnvironmentResponse'
    { $sel:computeEnvironmentName:CreateComputeEnvironmentResponse' :: Maybe Text
computeEnvironmentName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:computeEnvironmentArn:CreateComputeEnvironmentResponse' :: Maybe Text
computeEnvironmentArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateComputeEnvironmentResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The name of the compute environment. Up to 128 letters (uppercase and
-- lowercase), numbers, hyphens, and underscores are allowed.
createComputeEnvironmentResponse_computeEnvironmentName :: Lens.Lens' CreateComputeEnvironmentResponse (Prelude.Maybe Prelude.Text)
createComputeEnvironmentResponse_computeEnvironmentName :: (Maybe Text -> f (Maybe Text))
-> CreateComputeEnvironmentResponse
-> f CreateComputeEnvironmentResponse
createComputeEnvironmentResponse_computeEnvironmentName = (CreateComputeEnvironmentResponse -> Maybe Text)
-> (CreateComputeEnvironmentResponse
    -> Maybe Text -> CreateComputeEnvironmentResponse)
-> Lens
     CreateComputeEnvironmentResponse
     CreateComputeEnvironmentResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComputeEnvironmentResponse' {Maybe Text
computeEnvironmentName :: Maybe Text
$sel:computeEnvironmentName:CreateComputeEnvironmentResponse' :: CreateComputeEnvironmentResponse -> Maybe Text
computeEnvironmentName} -> Maybe Text
computeEnvironmentName) (\s :: CreateComputeEnvironmentResponse
s@CreateComputeEnvironmentResponse' {} Maybe Text
a -> CreateComputeEnvironmentResponse
s {$sel:computeEnvironmentName:CreateComputeEnvironmentResponse' :: Maybe Text
computeEnvironmentName = Maybe Text
a} :: CreateComputeEnvironmentResponse)

-- | The Amazon Resource Name (ARN) of the compute environment.
createComputeEnvironmentResponse_computeEnvironmentArn :: Lens.Lens' CreateComputeEnvironmentResponse (Prelude.Maybe Prelude.Text)
createComputeEnvironmentResponse_computeEnvironmentArn :: (Maybe Text -> f (Maybe Text))
-> CreateComputeEnvironmentResponse
-> f CreateComputeEnvironmentResponse
createComputeEnvironmentResponse_computeEnvironmentArn = (CreateComputeEnvironmentResponse -> Maybe Text)
-> (CreateComputeEnvironmentResponse
    -> Maybe Text -> CreateComputeEnvironmentResponse)
-> Lens
     CreateComputeEnvironmentResponse
     CreateComputeEnvironmentResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComputeEnvironmentResponse' {Maybe Text
computeEnvironmentArn :: Maybe Text
$sel:computeEnvironmentArn:CreateComputeEnvironmentResponse' :: CreateComputeEnvironmentResponse -> Maybe Text
computeEnvironmentArn} -> Maybe Text
computeEnvironmentArn) (\s :: CreateComputeEnvironmentResponse
s@CreateComputeEnvironmentResponse' {} Maybe Text
a -> CreateComputeEnvironmentResponse
s {$sel:computeEnvironmentArn:CreateComputeEnvironmentResponse' :: Maybe Text
computeEnvironmentArn = Maybe Text
a} :: CreateComputeEnvironmentResponse)

-- | The response's http status code.
createComputeEnvironmentResponse_httpStatus :: Lens.Lens' CreateComputeEnvironmentResponse Prelude.Int
createComputeEnvironmentResponse_httpStatus :: (Int -> f Int)
-> CreateComputeEnvironmentResponse
-> f CreateComputeEnvironmentResponse
createComputeEnvironmentResponse_httpStatus = (CreateComputeEnvironmentResponse -> Int)
-> (CreateComputeEnvironmentResponse
    -> Int -> CreateComputeEnvironmentResponse)
-> Lens
     CreateComputeEnvironmentResponse
     CreateComputeEnvironmentResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateComputeEnvironmentResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateComputeEnvironmentResponse' :: CreateComputeEnvironmentResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateComputeEnvironmentResponse
s@CreateComputeEnvironmentResponse' {} Int
a -> CreateComputeEnvironmentResponse
s {$sel:httpStatus:CreateComputeEnvironmentResponse' :: Int
httpStatus = Int
a} :: CreateComputeEnvironmentResponse)

instance
  Prelude.NFData
    CreateComputeEnvironmentResponse