{-# 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.EksPodProperties
-- 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.EksPodProperties where

import Amazonka.Batch.Types.EksContainer
import Amazonka.Batch.Types.EksVolume
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

-- | The properties for the pod.
--
-- /See:/ 'newEksPodProperties' smart constructor.
data EksPodProperties = EksPodProperties'
  { -- | The properties of the container that\'s used on the Amazon EKS pod.
    EksPodProperties -> Maybe [EksContainer]
containers :: Prelude.Maybe [EksContainer],
    -- | The DNS policy for the pod. The default value is @ClusterFirst@. If the
    -- @hostNetwork@ parameter is not specified, the default is
    -- @ClusterFirstWithHostNet@. @ClusterFirst@ indicates that any DNS query
    -- that does not match the configured cluster domain suffix is forwarded to
    -- the upstream nameserver inherited from the node. For more information,
    -- see
    -- <https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-policy Pod\'s DNS policy>
    -- in the /Kubernetes documentation/.
    --
    -- Valid values: @Default@ | @ClusterFirst@ | @ClusterFirstWithHostNet@
    EksPodProperties -> Maybe Text
dnsPolicy :: Prelude.Maybe Prelude.Text,
    -- | Indicates if the pod uses the hosts\' network IP address. The default
    -- value is @true@. Setting this to @false@ enables the Kubernetes pod
    -- networking model. Most Batch workloads are egress-only and don\'t
    -- require the overhead of IP allocation for each pod for incoming
    -- connections. For more information, see
    -- <https://kubernetes.io/docs/concepts/security/pod-security-policy/#host-namespaces Host namespaces>
    -- and
    -- <https://kubernetes.io/docs/concepts/workloads/pods/#pod-networking Pod networking>
    -- in the /Kubernetes documentation/.
    EksPodProperties -> Maybe Bool
hostNetwork :: Prelude.Maybe Prelude.Bool,
    -- | The name of the service account that\'s used to run the pod. For more
    -- information, see
    -- <https://docs.aws.amazon.com/eks/latest/userguide/service-accounts.html Kubernetes service accounts>
    -- and
    -- <https://docs.aws.amazon.com/eks/latest/userguide/associate-service-account-role.html Configure a Kubernetes service account to assume an IAM role>
    -- in the /Amazon EKS User Guide/ and
    -- <https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ Configure service accounts for pods>
    -- in the /Kubernetes documentation/.
    EksPodProperties -> Maybe Text
serviceAccountName :: Prelude.Maybe Prelude.Text,
    -- | Specifies the volumes for a job definition that uses Amazon EKS
    -- resources.
    EksPodProperties -> Maybe [EksVolume]
volumes :: Prelude.Maybe [EksVolume]
  }
  deriving (EksPodProperties -> EksPodProperties -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EksPodProperties -> EksPodProperties -> Bool
$c/= :: EksPodProperties -> EksPodProperties -> Bool
== :: EksPodProperties -> EksPodProperties -> Bool
$c== :: EksPodProperties -> EksPodProperties -> Bool
Prelude.Eq, ReadPrec [EksPodProperties]
ReadPrec EksPodProperties
Int -> ReadS EksPodProperties
ReadS [EksPodProperties]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EksPodProperties]
$creadListPrec :: ReadPrec [EksPodProperties]
readPrec :: ReadPrec EksPodProperties
$creadPrec :: ReadPrec EksPodProperties
readList :: ReadS [EksPodProperties]
$creadList :: ReadS [EksPodProperties]
readsPrec :: Int -> ReadS EksPodProperties
$creadsPrec :: Int -> ReadS EksPodProperties
Prelude.Read, Int -> EksPodProperties -> ShowS
[EksPodProperties] -> ShowS
EksPodProperties -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EksPodProperties] -> ShowS
$cshowList :: [EksPodProperties] -> ShowS
show :: EksPodProperties -> String
$cshow :: EksPodProperties -> String
showsPrec :: Int -> EksPodProperties -> ShowS
$cshowsPrec :: Int -> EksPodProperties -> ShowS
Prelude.Show, forall x. Rep EksPodProperties x -> EksPodProperties
forall x. EksPodProperties -> Rep EksPodProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EksPodProperties x -> EksPodProperties
$cfrom :: forall x. EksPodProperties -> Rep EksPodProperties x
Prelude.Generic)

-- |
-- Create a value of 'EksPodProperties' 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:
--
-- 'containers', 'eksPodProperties_containers' - The properties of the container that\'s used on the Amazon EKS pod.
--
-- 'dnsPolicy', 'eksPodProperties_dnsPolicy' - The DNS policy for the pod. The default value is @ClusterFirst@. If the
-- @hostNetwork@ parameter is not specified, the default is
-- @ClusterFirstWithHostNet@. @ClusterFirst@ indicates that any DNS query
-- that does not match the configured cluster domain suffix is forwarded to
-- the upstream nameserver inherited from the node. For more information,
-- see
-- <https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-policy Pod\'s DNS policy>
-- in the /Kubernetes documentation/.
--
-- Valid values: @Default@ | @ClusterFirst@ | @ClusterFirstWithHostNet@
--
-- 'hostNetwork', 'eksPodProperties_hostNetwork' - Indicates if the pod uses the hosts\' network IP address. The default
-- value is @true@. Setting this to @false@ enables the Kubernetes pod
-- networking model. Most Batch workloads are egress-only and don\'t
-- require the overhead of IP allocation for each pod for incoming
-- connections. For more information, see
-- <https://kubernetes.io/docs/concepts/security/pod-security-policy/#host-namespaces Host namespaces>
-- and
-- <https://kubernetes.io/docs/concepts/workloads/pods/#pod-networking Pod networking>
-- in the /Kubernetes documentation/.
--
-- 'serviceAccountName', 'eksPodProperties_serviceAccountName' - The name of the service account that\'s used to run the pod. For more
-- information, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/service-accounts.html Kubernetes service accounts>
-- and
-- <https://docs.aws.amazon.com/eks/latest/userguide/associate-service-account-role.html Configure a Kubernetes service account to assume an IAM role>
-- in the /Amazon EKS User Guide/ and
-- <https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ Configure service accounts for pods>
-- in the /Kubernetes documentation/.
--
-- 'volumes', 'eksPodProperties_volumes' - Specifies the volumes for a job definition that uses Amazon EKS
-- resources.
newEksPodProperties ::
  EksPodProperties
newEksPodProperties :: EksPodProperties
newEksPodProperties =
  EksPodProperties'
    { $sel:containers:EksPodProperties' :: Maybe [EksContainer]
containers = forall a. Maybe a
Prelude.Nothing,
      $sel:dnsPolicy:EksPodProperties' :: Maybe Text
dnsPolicy = forall a. Maybe a
Prelude.Nothing,
      $sel:hostNetwork:EksPodProperties' :: Maybe Bool
hostNetwork = forall a. Maybe a
Prelude.Nothing,
      $sel:serviceAccountName:EksPodProperties' :: Maybe Text
serviceAccountName = forall a. Maybe a
Prelude.Nothing,
      $sel:volumes:EksPodProperties' :: Maybe [EksVolume]
volumes = forall a. Maybe a
Prelude.Nothing
    }

-- | The properties of the container that\'s used on the Amazon EKS pod.
eksPodProperties_containers :: Lens.Lens' EksPodProperties (Prelude.Maybe [EksContainer])
eksPodProperties_containers :: Lens' EksPodProperties (Maybe [EksContainer])
eksPodProperties_containers = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EksPodProperties' {Maybe [EksContainer]
containers :: Maybe [EksContainer]
$sel:containers:EksPodProperties' :: EksPodProperties -> Maybe [EksContainer]
containers} -> Maybe [EksContainer]
containers) (\s :: EksPodProperties
s@EksPodProperties' {} Maybe [EksContainer]
a -> EksPodProperties
s {$sel:containers:EksPodProperties' :: Maybe [EksContainer]
containers = Maybe [EksContainer]
a} :: EksPodProperties) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The DNS policy for the pod. The default value is @ClusterFirst@. If the
-- @hostNetwork@ parameter is not specified, the default is
-- @ClusterFirstWithHostNet@. @ClusterFirst@ indicates that any DNS query
-- that does not match the configured cluster domain suffix is forwarded to
-- the upstream nameserver inherited from the node. For more information,
-- see
-- <https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-dns-policy Pod\'s DNS policy>
-- in the /Kubernetes documentation/.
--
-- Valid values: @Default@ | @ClusterFirst@ | @ClusterFirstWithHostNet@
eksPodProperties_dnsPolicy :: Lens.Lens' EksPodProperties (Prelude.Maybe Prelude.Text)
eksPodProperties_dnsPolicy :: Lens' EksPodProperties (Maybe Text)
eksPodProperties_dnsPolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EksPodProperties' {Maybe Text
dnsPolicy :: Maybe Text
$sel:dnsPolicy:EksPodProperties' :: EksPodProperties -> Maybe Text
dnsPolicy} -> Maybe Text
dnsPolicy) (\s :: EksPodProperties
s@EksPodProperties' {} Maybe Text
a -> EksPodProperties
s {$sel:dnsPolicy:EksPodProperties' :: Maybe Text
dnsPolicy = Maybe Text
a} :: EksPodProperties)

-- | Indicates if the pod uses the hosts\' network IP address. The default
-- value is @true@. Setting this to @false@ enables the Kubernetes pod
-- networking model. Most Batch workloads are egress-only and don\'t
-- require the overhead of IP allocation for each pod for incoming
-- connections. For more information, see
-- <https://kubernetes.io/docs/concepts/security/pod-security-policy/#host-namespaces Host namespaces>
-- and
-- <https://kubernetes.io/docs/concepts/workloads/pods/#pod-networking Pod networking>
-- in the /Kubernetes documentation/.
eksPodProperties_hostNetwork :: Lens.Lens' EksPodProperties (Prelude.Maybe Prelude.Bool)
eksPodProperties_hostNetwork :: Lens' EksPodProperties (Maybe Bool)
eksPodProperties_hostNetwork = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EksPodProperties' {Maybe Bool
hostNetwork :: Maybe Bool
$sel:hostNetwork:EksPodProperties' :: EksPodProperties -> Maybe Bool
hostNetwork} -> Maybe Bool
hostNetwork) (\s :: EksPodProperties
s@EksPodProperties' {} Maybe Bool
a -> EksPodProperties
s {$sel:hostNetwork:EksPodProperties' :: Maybe Bool
hostNetwork = Maybe Bool
a} :: EksPodProperties)

-- | The name of the service account that\'s used to run the pod. For more
-- information, see
-- <https://docs.aws.amazon.com/eks/latest/userguide/service-accounts.html Kubernetes service accounts>
-- and
-- <https://docs.aws.amazon.com/eks/latest/userguide/associate-service-account-role.html Configure a Kubernetes service account to assume an IAM role>
-- in the /Amazon EKS User Guide/ and
-- <https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ Configure service accounts for pods>
-- in the /Kubernetes documentation/.
eksPodProperties_serviceAccountName :: Lens.Lens' EksPodProperties (Prelude.Maybe Prelude.Text)
eksPodProperties_serviceAccountName :: Lens' EksPodProperties (Maybe Text)
eksPodProperties_serviceAccountName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EksPodProperties' {Maybe Text
serviceAccountName :: Maybe Text
$sel:serviceAccountName:EksPodProperties' :: EksPodProperties -> Maybe Text
serviceAccountName} -> Maybe Text
serviceAccountName) (\s :: EksPodProperties
s@EksPodProperties' {} Maybe Text
a -> EksPodProperties
s {$sel:serviceAccountName:EksPodProperties' :: Maybe Text
serviceAccountName = Maybe Text
a} :: EksPodProperties)

-- | Specifies the volumes for a job definition that uses Amazon EKS
-- resources.
eksPodProperties_volumes :: Lens.Lens' EksPodProperties (Prelude.Maybe [EksVolume])
eksPodProperties_volumes :: Lens' EksPodProperties (Maybe [EksVolume])
eksPodProperties_volumes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EksPodProperties' {Maybe [EksVolume]
volumes :: Maybe [EksVolume]
$sel:volumes:EksPodProperties' :: EksPodProperties -> Maybe [EksVolume]
volumes} -> Maybe [EksVolume]
volumes) (\s :: EksPodProperties
s@EksPodProperties' {} Maybe [EksVolume]
a -> EksPodProperties
s {$sel:volumes:EksPodProperties' :: Maybe [EksVolume]
volumes = Maybe [EksVolume]
a} :: EksPodProperties) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON EksPodProperties where
  parseJSON :: Value -> Parser EksPodProperties
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EksPodProperties"
      ( \Object
x ->
          Maybe [EksContainer]
-> Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe [EksVolume]
-> EksPodProperties
EksPodProperties'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"containers" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"dnsPolicy")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"hostNetwork")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"serviceAccountName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"volumes" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable EksPodProperties where
  hashWithSalt :: Int -> EksPodProperties -> Int
hashWithSalt Int
_salt EksPodProperties' {Maybe Bool
Maybe [EksContainer]
Maybe [EksVolume]
Maybe Text
volumes :: Maybe [EksVolume]
serviceAccountName :: Maybe Text
hostNetwork :: Maybe Bool
dnsPolicy :: Maybe Text
containers :: Maybe [EksContainer]
$sel:volumes:EksPodProperties' :: EksPodProperties -> Maybe [EksVolume]
$sel:serviceAccountName:EksPodProperties' :: EksPodProperties -> Maybe Text
$sel:hostNetwork:EksPodProperties' :: EksPodProperties -> Maybe Bool
$sel:dnsPolicy:EksPodProperties' :: EksPodProperties -> Maybe Text
$sel:containers:EksPodProperties' :: EksPodProperties -> Maybe [EksContainer]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [EksContainer]
containers
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
dnsPolicy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
hostNetwork
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
serviceAccountName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [EksVolume]
volumes

instance Prelude.NFData EksPodProperties where
  rnf :: EksPodProperties -> ()
rnf EksPodProperties' {Maybe Bool
Maybe [EksContainer]
Maybe [EksVolume]
Maybe Text
volumes :: Maybe [EksVolume]
serviceAccountName :: Maybe Text
hostNetwork :: Maybe Bool
dnsPolicy :: Maybe Text
containers :: Maybe [EksContainer]
$sel:volumes:EksPodProperties' :: EksPodProperties -> Maybe [EksVolume]
$sel:serviceAccountName:EksPodProperties' :: EksPodProperties -> Maybe Text
$sel:hostNetwork:EksPodProperties' :: EksPodProperties -> Maybe Bool
$sel:dnsPolicy:EksPodProperties' :: EksPodProperties -> Maybe Text
$sel:containers:EksPodProperties' :: EksPodProperties -> Maybe [EksContainer]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [EksContainer]
containers
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
dnsPolicy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
hostNetwork
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
serviceAccountName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [EksVolume]
volumes

instance Data.ToJSON EksPodProperties where
  toJSON :: EksPodProperties -> Value
toJSON EksPodProperties' {Maybe Bool
Maybe [EksContainer]
Maybe [EksVolume]
Maybe Text
volumes :: Maybe [EksVolume]
serviceAccountName :: Maybe Text
hostNetwork :: Maybe Bool
dnsPolicy :: Maybe Text
containers :: Maybe [EksContainer]
$sel:volumes:EksPodProperties' :: EksPodProperties -> Maybe [EksVolume]
$sel:serviceAccountName:EksPodProperties' :: EksPodProperties -> Maybe Text
$sel:hostNetwork:EksPodProperties' :: EksPodProperties -> Maybe Bool
$sel:dnsPolicy:EksPodProperties' :: EksPodProperties -> Maybe Text
$sel:containers:EksPodProperties' :: EksPodProperties -> Maybe [EksContainer]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"containers" 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 [EksContainer]
containers,
            (Key
"dnsPolicy" 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 Text
dnsPolicy,
            (Key
"hostNetwork" 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 Bool
hostNetwork,
            (Key
"serviceAccountName" 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 Text
serviceAccountName,
            (Key
"volumes" 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 [EksVolume]
volumes
          ]
      )