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

-- | Identifies the Key Management Service (KMS) key used to encrypt the
-- secrets.
--
-- /See:/ 'newProvider' smart constructor.
data Provider = Provider'
  { -- | Amazon Resource Name (ARN) or alias of the KMS key. The KMS key must be
    -- symmetric, created in the same region as the cluster, and if the KMS key
    -- was created in a different account, the user must have access to the KMS
    -- key. For more information, see
    -- <https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-modifying-external-accounts.html Allowing Users in Other Accounts to Use a KMS key>
    -- in the /Key Management Service Developer Guide/.
    Provider -> Maybe Text
keyArn :: Prelude.Maybe Prelude.Text
  }
  deriving (Provider -> Provider -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Provider -> Provider -> Bool
$c/= :: Provider -> Provider -> Bool
== :: Provider -> Provider -> Bool
$c== :: Provider -> Provider -> Bool
Prelude.Eq, ReadPrec [Provider]
ReadPrec Provider
Int -> ReadS Provider
ReadS [Provider]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Provider]
$creadListPrec :: ReadPrec [Provider]
readPrec :: ReadPrec Provider
$creadPrec :: ReadPrec Provider
readList :: ReadS [Provider]
$creadList :: ReadS [Provider]
readsPrec :: Int -> ReadS Provider
$creadsPrec :: Int -> ReadS Provider
Prelude.Read, Int -> Provider -> ShowS
[Provider] -> ShowS
Provider -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Provider] -> ShowS
$cshowList :: [Provider] -> ShowS
show :: Provider -> String
$cshow :: Provider -> String
showsPrec :: Int -> Provider -> ShowS
$cshowsPrec :: Int -> Provider -> ShowS
Prelude.Show, forall x. Rep Provider x -> Provider
forall x. Provider -> Rep Provider x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Provider x -> Provider
$cfrom :: forall x. Provider -> Rep Provider x
Prelude.Generic)

-- |
-- Create a value of 'Provider' 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:
--
-- 'keyArn', 'provider_keyArn' - Amazon Resource Name (ARN) or alias of the KMS key. The KMS key must be
-- symmetric, created in the same region as the cluster, and if the KMS key
-- was created in a different account, the user must have access to the KMS
-- key. For more information, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-modifying-external-accounts.html Allowing Users in Other Accounts to Use a KMS key>
-- in the /Key Management Service Developer Guide/.
newProvider ::
  Provider
newProvider :: Provider
newProvider = Provider' {$sel:keyArn:Provider' :: Maybe Text
keyArn = forall a. Maybe a
Prelude.Nothing}

-- | Amazon Resource Name (ARN) or alias of the KMS key. The KMS key must be
-- symmetric, created in the same region as the cluster, and if the KMS key
-- was created in a different account, the user must have access to the KMS
-- key. For more information, see
-- <https://docs.aws.amazon.com/kms/latest/developerguide/key-policy-modifying-external-accounts.html Allowing Users in Other Accounts to Use a KMS key>
-- in the /Key Management Service Developer Guide/.
provider_keyArn :: Lens.Lens' Provider (Prelude.Maybe Prelude.Text)
provider_keyArn :: Lens' Provider (Maybe Text)
provider_keyArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Provider' {Maybe Text
keyArn :: Maybe Text
$sel:keyArn:Provider' :: Provider -> Maybe Text
keyArn} -> Maybe Text
keyArn) (\s :: Provider
s@Provider' {} Maybe Text
a -> Provider
s {$sel:keyArn:Provider' :: Maybe Text
keyArn = Maybe Text
a} :: Provider)

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

instance Prelude.Hashable Provider where
  hashWithSalt :: Int -> Provider -> Int
hashWithSalt Int
_salt Provider' {Maybe Text
keyArn :: Maybe Text
$sel:keyArn:Provider' :: Provider -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
keyArn

instance Prelude.NFData Provider where
  rnf :: Provider -> ()
rnf Provider' {Maybe Text
keyArn :: Maybe Text
$sel:keyArn:Provider' :: Provider -> Maybe Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
keyArn

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