{-# 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.EKS.Types.EncryptionConfig
-- 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.EKS.Types.EncryptionConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EKS.Types.Provider
import qualified Amazonka.Prelude as Prelude

-- | The encryption configuration for the cluster.
--
-- /See:/ 'newEncryptionConfig' smart constructor.
data EncryptionConfig = EncryptionConfig'
  { -- | Key Management Service (KMS) key. Either the ARN or the alias can be
    -- used.
    EncryptionConfig -> Maybe Provider
provider :: Prelude.Maybe Provider,
    -- | Specifies the resources to be encrypted. The only supported value is
    -- \"secrets\".
    EncryptionConfig -> Maybe [Text]
resources :: Prelude.Maybe [Prelude.Text]
  }
  deriving (EncryptionConfig -> EncryptionConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EncryptionConfig -> EncryptionConfig -> Bool
$c/= :: EncryptionConfig -> EncryptionConfig -> Bool
== :: EncryptionConfig -> EncryptionConfig -> Bool
$c== :: EncryptionConfig -> EncryptionConfig -> Bool
Prelude.Eq, ReadPrec [EncryptionConfig]
ReadPrec EncryptionConfig
Int -> ReadS EncryptionConfig
ReadS [EncryptionConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EncryptionConfig]
$creadListPrec :: ReadPrec [EncryptionConfig]
readPrec :: ReadPrec EncryptionConfig
$creadPrec :: ReadPrec EncryptionConfig
readList :: ReadS [EncryptionConfig]
$creadList :: ReadS [EncryptionConfig]
readsPrec :: Int -> ReadS EncryptionConfig
$creadsPrec :: Int -> ReadS EncryptionConfig
Prelude.Read, Int -> EncryptionConfig -> ShowS
[EncryptionConfig] -> ShowS
EncryptionConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EncryptionConfig] -> ShowS
$cshowList :: [EncryptionConfig] -> ShowS
show :: EncryptionConfig -> String
$cshow :: EncryptionConfig -> String
showsPrec :: Int -> EncryptionConfig -> ShowS
$cshowsPrec :: Int -> EncryptionConfig -> ShowS
Prelude.Show, forall x. Rep EncryptionConfig x -> EncryptionConfig
forall x. EncryptionConfig -> Rep EncryptionConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EncryptionConfig x -> EncryptionConfig
$cfrom :: forall x. EncryptionConfig -> Rep EncryptionConfig x
Prelude.Generic)

-- |
-- Create a value of 'EncryptionConfig' 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:
--
-- 'provider', 'encryptionConfig_provider' - Key Management Service (KMS) key. Either the ARN or the alias can be
-- used.
--
-- 'resources', 'encryptionConfig_resources' - Specifies the resources to be encrypted. The only supported value is
-- \"secrets\".
newEncryptionConfig ::
  EncryptionConfig
newEncryptionConfig :: EncryptionConfig
newEncryptionConfig =
  EncryptionConfig'
    { $sel:provider:EncryptionConfig' :: Maybe Provider
provider = forall a. Maybe a
Prelude.Nothing,
      $sel:resources:EncryptionConfig' :: Maybe [Text]
resources = forall a. Maybe a
Prelude.Nothing
    }

-- | Key Management Service (KMS) key. Either the ARN or the alias can be
-- used.
encryptionConfig_provider :: Lens.Lens' EncryptionConfig (Prelude.Maybe Provider)
encryptionConfig_provider :: Lens' EncryptionConfig (Maybe Provider)
encryptionConfig_provider = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionConfig' {Maybe Provider
provider :: Maybe Provider
$sel:provider:EncryptionConfig' :: EncryptionConfig -> Maybe Provider
provider} -> Maybe Provider
provider) (\s :: EncryptionConfig
s@EncryptionConfig' {} Maybe Provider
a -> EncryptionConfig
s {$sel:provider:EncryptionConfig' :: Maybe Provider
provider = Maybe Provider
a} :: EncryptionConfig)

-- | Specifies the resources to be encrypted. The only supported value is
-- \"secrets\".
encryptionConfig_resources :: Lens.Lens' EncryptionConfig (Prelude.Maybe [Prelude.Text])
encryptionConfig_resources :: Lens' EncryptionConfig (Maybe [Text])
encryptionConfig_resources = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionConfig' {Maybe [Text]
resources :: Maybe [Text]
$sel:resources:EncryptionConfig' :: EncryptionConfig -> Maybe [Text]
resources} -> Maybe [Text]
resources) (\s :: EncryptionConfig
s@EncryptionConfig' {} Maybe [Text]
a -> EncryptionConfig
s {$sel:resources:EncryptionConfig' :: Maybe [Text]
resources = Maybe [Text]
a} :: EncryptionConfig) 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 EncryptionConfig where
  parseJSON :: Value -> Parser EncryptionConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EncryptionConfig"
      ( \Object
x ->
          Maybe Provider -> Maybe [Text] -> EncryptionConfig
EncryptionConfig'
            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
"provider")
            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
"resources" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable EncryptionConfig where
  hashWithSalt :: Int -> EncryptionConfig -> Int
hashWithSalt Int
_salt EncryptionConfig' {Maybe [Text]
Maybe Provider
resources :: Maybe [Text]
provider :: Maybe Provider
$sel:resources:EncryptionConfig' :: EncryptionConfig -> Maybe [Text]
$sel:provider:EncryptionConfig' :: EncryptionConfig -> Maybe Provider
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Provider
provider
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
resources

instance Prelude.NFData EncryptionConfig where
  rnf :: EncryptionConfig -> ()
rnf EncryptionConfig' {Maybe [Text]
Maybe Provider
resources :: Maybe [Text]
provider :: Maybe Provider
$sel:resources:EncryptionConfig' :: EncryptionConfig -> Maybe [Text]
$sel:provider:EncryptionConfig' :: EncryptionConfig -> Maybe Provider
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Provider
provider
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
resources

instance Data.ToJSON EncryptionConfig where
  toJSON :: EncryptionConfig -> Value
toJSON EncryptionConfig' {Maybe [Text]
Maybe Provider
resources :: Maybe [Text]
provider :: Maybe Provider
$sel:resources:EncryptionConfig' :: EncryptionConfig -> Maybe [Text]
$sel:provider:EncryptionConfig' :: EncryptionConfig -> Maybe Provider
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"provider" 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 Provider
provider,
            (Key
"resources" 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]
resources
          ]
      )