{-# 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.EksSecret
-- 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.EksSecret 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

-- | Specifies the configuration of a Kubernetes @secret@ volume. For more
-- information, see
-- <https://kubernetes.io/docs/concepts/storage/volumes/#secret secret> in
-- the /Kubernetes documentation/.
--
-- /See:/ 'newEksSecret' smart constructor.
data EksSecret = EksSecret'
  { -- | Specifies whether the secret or the secret\'s keys must be defined.
    EksSecret -> Maybe Bool
optional :: Prelude.Maybe Prelude.Bool,
    -- | The name of the secret. The name must be allowed as a DNS subdomain
    -- name. For more information, see
    -- <https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names DNS subdomain names>
    -- in the /Kubernetes documentation/.
    EksSecret -> Text
secretName :: Prelude.Text
  }
  deriving (EksSecret -> EksSecret -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EksSecret -> EksSecret -> Bool
$c/= :: EksSecret -> EksSecret -> Bool
== :: EksSecret -> EksSecret -> Bool
$c== :: EksSecret -> EksSecret -> Bool
Prelude.Eq, ReadPrec [EksSecret]
ReadPrec EksSecret
Int -> ReadS EksSecret
ReadS [EksSecret]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EksSecret]
$creadListPrec :: ReadPrec [EksSecret]
readPrec :: ReadPrec EksSecret
$creadPrec :: ReadPrec EksSecret
readList :: ReadS [EksSecret]
$creadList :: ReadS [EksSecret]
readsPrec :: Int -> ReadS EksSecret
$creadsPrec :: Int -> ReadS EksSecret
Prelude.Read, Int -> EksSecret -> ShowS
[EksSecret] -> ShowS
EksSecret -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EksSecret] -> ShowS
$cshowList :: [EksSecret] -> ShowS
show :: EksSecret -> String
$cshow :: EksSecret -> String
showsPrec :: Int -> EksSecret -> ShowS
$cshowsPrec :: Int -> EksSecret -> ShowS
Prelude.Show, forall x. Rep EksSecret x -> EksSecret
forall x. EksSecret -> Rep EksSecret x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EksSecret x -> EksSecret
$cfrom :: forall x. EksSecret -> Rep EksSecret x
Prelude.Generic)

-- |
-- Create a value of 'EksSecret' 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:
--
-- 'optional', 'eksSecret_optional' - Specifies whether the secret or the secret\'s keys must be defined.
--
-- 'secretName', 'eksSecret_secretName' - The name of the secret. The name must be allowed as a DNS subdomain
-- name. For more information, see
-- <https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names DNS subdomain names>
-- in the /Kubernetes documentation/.
newEksSecret ::
  -- | 'secretName'
  Prelude.Text ->
  EksSecret
newEksSecret :: Text -> EksSecret
newEksSecret Text
pSecretName_ =
  EksSecret'
    { $sel:optional:EksSecret' :: Maybe Bool
optional = forall a. Maybe a
Prelude.Nothing,
      $sel:secretName:EksSecret' :: Text
secretName = Text
pSecretName_
    }

-- | Specifies whether the secret or the secret\'s keys must be defined.
eksSecret_optional :: Lens.Lens' EksSecret (Prelude.Maybe Prelude.Bool)
eksSecret_optional :: Lens' EksSecret (Maybe Bool)
eksSecret_optional = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EksSecret' {Maybe Bool
optional :: Maybe Bool
$sel:optional:EksSecret' :: EksSecret -> Maybe Bool
optional} -> Maybe Bool
optional) (\s :: EksSecret
s@EksSecret' {} Maybe Bool
a -> EksSecret
s {$sel:optional:EksSecret' :: Maybe Bool
optional = Maybe Bool
a} :: EksSecret)

-- | The name of the secret. The name must be allowed as a DNS subdomain
-- name. For more information, see
-- <https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names DNS subdomain names>
-- in the /Kubernetes documentation/.
eksSecret_secretName :: Lens.Lens' EksSecret Prelude.Text
eksSecret_secretName :: Lens' EksSecret Text
eksSecret_secretName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EksSecret' {Text
secretName :: Text
$sel:secretName:EksSecret' :: EksSecret -> Text
secretName} -> Text
secretName) (\s :: EksSecret
s@EksSecret' {} Text
a -> EksSecret
s {$sel:secretName:EksSecret' :: Text
secretName = Text
a} :: EksSecret)

instance Data.FromJSON EksSecret where
  parseJSON :: Value -> Parser EksSecret
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EksSecret"
      ( \Object
x ->
          Maybe Bool -> Text -> EksSecret
EksSecret'
            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
"optional")
            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
"secretName")
      )

instance Prelude.Hashable EksSecret where
  hashWithSalt :: Int -> EksSecret -> Int
hashWithSalt Int
_salt EksSecret' {Maybe Bool
Text
secretName :: Text
optional :: Maybe Bool
$sel:secretName:EksSecret' :: EksSecret -> Text
$sel:optional:EksSecret' :: EksSecret -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
optional
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
secretName

instance Prelude.NFData EksSecret where
  rnf :: EksSecret -> ()
rnf EksSecret' {Maybe Bool
Text
secretName :: Text
optional :: Maybe Bool
$sel:secretName:EksSecret' :: EksSecret -> Text
$sel:optional:EksSecret' :: EksSecret -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
optional
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
secretName

instance Data.ToJSON EksSecret where
  toJSON :: EksSecret -> Value
toJSON EksSecret' {Maybe Bool
Text
secretName :: Text
optional :: Maybe Bool
$sel:secretName:EksSecret' :: EksSecret -> Text
$sel:optional:EksSecret' :: EksSecret -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"optional" 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
optional,
            forall a. a -> Maybe a
Prelude.Just (Key
"secretName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
secretName)
          ]
      )