{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.EKS.Types.Provider where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(Provider -> Provider -> Bool)
-> (Provider -> Provider -> Bool) -> Eq Provider
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]
(Int -> ReadS Provider)
-> ReadS [Provider]
-> ReadPrec Provider
-> ReadPrec [Provider]
-> Read 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
(Int -> Provider -> ShowS)
-> (Provider -> String) -> ([Provider] -> ShowS) -> Show Provider
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. Provider -> Rep Provider x)
-> (forall x. Rep Provider x -> Provider) -> Generic Provider
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' :: Maybe Text -> Provider
Provider' {$sel:keyArn:Provider' :: Maybe Text
keyArn = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> Provider -> f Provider
provider_keyArn = (Provider -> Maybe Text)
-> (Provider -> Maybe Text -> Provider)
-> Lens Provider Provider (Maybe Text) (Maybe Text)
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 Core.FromJSON Provider where
  parseJSON :: Value -> Parser Provider
parseJSON =
    String -> (Object -> Parser Provider) -> Value -> Parser Provider
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Provider"
      (\Object
x -> Maybe Text -> Provider
Provider' (Maybe Text -> Provider) -> Parser (Maybe Text) -> Parser Provider
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"keyArn"))

instance Prelude.Hashable Provider

instance Prelude.NFData Provider

instance Core.ToJSON Provider where
  toJSON :: Provider -> Value
toJSON Provider' {Maybe Text
keyArn :: Maybe Text
$sel:keyArn:Provider' :: Provider -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"keyArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
keyArn]
      )