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

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

-- | Configuration for the Amazon EKS cluster that supports the Batch compute
-- environment. The cluster must exist before the compute environment can
-- be created.
--
-- /See:/ 'newEksConfiguration' smart constructor.
data EksConfiguration = EksConfiguration'
  { -- | The Amazon Resource Name (ARN) of the Amazon EKS cluster. An example is
    -- @arn:@/@aws@/@:eks:@/@us-east-1@/@:@/@123456789012@/@:cluster\/@/@ClusterForBatch@/@ @.
    EksConfiguration -> Text
eksClusterArn :: Prelude.Text,
    -- | The namespace of the Amazon EKS cluster. Batch manages pods in this
    -- namespace. The value can\'t left empty or null. It must be fewer than 64
    -- characters long, can\'t be set to @default@, can\'t start with
    -- \"@kube-@,\" and must match this regular expression:
    -- @^[a-z0-9]([-a-z0-9]*[a-z0-9])?$@. For more information, see
    -- <https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ Namespaces>
    -- in the Kubernetes documentation.
    EksConfiguration -> Text
kubernetesNamespace :: Prelude.Text
  }
  deriving (EksConfiguration -> EksConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EksConfiguration -> EksConfiguration -> Bool
$c/= :: EksConfiguration -> EksConfiguration -> Bool
== :: EksConfiguration -> EksConfiguration -> Bool
$c== :: EksConfiguration -> EksConfiguration -> Bool
Prelude.Eq, ReadPrec [EksConfiguration]
ReadPrec EksConfiguration
Int -> ReadS EksConfiguration
ReadS [EksConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EksConfiguration]
$creadListPrec :: ReadPrec [EksConfiguration]
readPrec :: ReadPrec EksConfiguration
$creadPrec :: ReadPrec EksConfiguration
readList :: ReadS [EksConfiguration]
$creadList :: ReadS [EksConfiguration]
readsPrec :: Int -> ReadS EksConfiguration
$creadsPrec :: Int -> ReadS EksConfiguration
Prelude.Read, Int -> EksConfiguration -> ShowS
[EksConfiguration] -> ShowS
EksConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EksConfiguration] -> ShowS
$cshowList :: [EksConfiguration] -> ShowS
show :: EksConfiguration -> String
$cshow :: EksConfiguration -> String
showsPrec :: Int -> EksConfiguration -> ShowS
$cshowsPrec :: Int -> EksConfiguration -> ShowS
Prelude.Show, forall x. Rep EksConfiguration x -> EksConfiguration
forall x. EksConfiguration -> Rep EksConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EksConfiguration x -> EksConfiguration
$cfrom :: forall x. EksConfiguration -> Rep EksConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'EksConfiguration' 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:
--
-- 'eksClusterArn', 'eksConfiguration_eksClusterArn' - The Amazon Resource Name (ARN) of the Amazon EKS cluster. An example is
-- @arn:@/@aws@/@:eks:@/@us-east-1@/@:@/@123456789012@/@:cluster\/@/@ClusterForBatch@/@ @.
--
-- 'kubernetesNamespace', 'eksConfiguration_kubernetesNamespace' - The namespace of the Amazon EKS cluster. Batch manages pods in this
-- namespace. The value can\'t left empty or null. It must be fewer than 64
-- characters long, can\'t be set to @default@, can\'t start with
-- \"@kube-@,\" and must match this regular expression:
-- @^[a-z0-9]([-a-z0-9]*[a-z0-9])?$@. For more information, see
-- <https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ Namespaces>
-- in the Kubernetes documentation.
newEksConfiguration ::
  -- | 'eksClusterArn'
  Prelude.Text ->
  -- | 'kubernetesNamespace'
  Prelude.Text ->
  EksConfiguration
newEksConfiguration :: Text -> Text -> EksConfiguration
newEksConfiguration
  Text
pEksClusterArn_
  Text
pKubernetesNamespace_ =
    EksConfiguration'
      { $sel:eksClusterArn:EksConfiguration' :: Text
eksClusterArn = Text
pEksClusterArn_,
        $sel:kubernetesNamespace:EksConfiguration' :: Text
kubernetesNamespace = Text
pKubernetesNamespace_
      }

-- | The Amazon Resource Name (ARN) of the Amazon EKS cluster. An example is
-- @arn:@/@aws@/@:eks:@/@us-east-1@/@:@/@123456789012@/@:cluster\/@/@ClusterForBatch@/@ @.
eksConfiguration_eksClusterArn :: Lens.Lens' EksConfiguration Prelude.Text
eksConfiguration_eksClusterArn :: Lens' EksConfiguration Text
eksConfiguration_eksClusterArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EksConfiguration' {Text
eksClusterArn :: Text
$sel:eksClusterArn:EksConfiguration' :: EksConfiguration -> Text
eksClusterArn} -> Text
eksClusterArn) (\s :: EksConfiguration
s@EksConfiguration' {} Text
a -> EksConfiguration
s {$sel:eksClusterArn:EksConfiguration' :: Text
eksClusterArn = Text
a} :: EksConfiguration)

-- | The namespace of the Amazon EKS cluster. Batch manages pods in this
-- namespace. The value can\'t left empty or null. It must be fewer than 64
-- characters long, can\'t be set to @default@, can\'t start with
-- \"@kube-@,\" and must match this regular expression:
-- @^[a-z0-9]([-a-z0-9]*[a-z0-9])?$@. For more information, see
-- <https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ Namespaces>
-- in the Kubernetes documentation.
eksConfiguration_kubernetesNamespace :: Lens.Lens' EksConfiguration Prelude.Text
eksConfiguration_kubernetesNamespace :: Lens' EksConfiguration Text
eksConfiguration_kubernetesNamespace = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EksConfiguration' {Text
kubernetesNamespace :: Text
$sel:kubernetesNamespace:EksConfiguration' :: EksConfiguration -> Text
kubernetesNamespace} -> Text
kubernetesNamespace) (\s :: EksConfiguration
s@EksConfiguration' {} Text
a -> EksConfiguration
s {$sel:kubernetesNamespace:EksConfiguration' :: Text
kubernetesNamespace = Text
a} :: EksConfiguration)

instance Data.FromJSON EksConfiguration where
  parseJSON :: Value -> Parser EksConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EksConfiguration"
      ( \Object
x ->
          Text -> Text -> EksConfiguration
EksConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"eksClusterArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"kubernetesNamespace")
      )

instance Prelude.Hashable EksConfiguration where
  hashWithSalt :: Int -> EksConfiguration -> Int
hashWithSalt Int
_salt EksConfiguration' {Text
kubernetesNamespace :: Text
eksClusterArn :: Text
$sel:kubernetesNamespace:EksConfiguration' :: EksConfiguration -> Text
$sel:eksClusterArn:EksConfiguration' :: EksConfiguration -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
eksClusterArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
kubernetesNamespace

instance Prelude.NFData EksConfiguration where
  rnf :: EksConfiguration -> ()
rnf EksConfiguration' {Text
kubernetesNamespace :: Text
eksClusterArn :: Text
$sel:kubernetesNamespace:EksConfiguration' :: EksConfiguration -> Text
$sel:eksClusterArn:EksConfiguration' :: EksConfiguration -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
eksClusterArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
kubernetesNamespace

instance Data.ToJSON EksConfiguration where
  toJSON :: EksConfiguration -> Value
toJSON EksConfiguration' {Text
kubernetesNamespace :: Text
eksClusterArn :: Text
$sel:kubernetesNamespace:EksConfiguration' :: EksConfiguration -> Text
$sel:eksClusterArn:EksConfiguration' :: EksConfiguration -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"eksClusterArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
eksClusterArn),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"kubernetesNamespace" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
kubernetesNamespace)
          ]
      )