{-# 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.CodeGuruReviewer.Types.KMSKeyDetails
-- 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.CodeGuruReviewer.Types.KMSKeyDetails where

import Amazonka.CodeGuruReviewer.Types.EncryptionOption
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

-- | An object that contains:
--
-- -   The encryption option for a repository association. It is either
--     owned by Amazon Web Services Key Management Service (KMS)
--     (@AWS_OWNED_CMK@) or customer managed (@CUSTOMER_MANAGED_CMK@).
--
-- -   The ID of the Amazon Web Services KMS key that is associated with a
--     repository association.
--
-- /See:/ 'newKMSKeyDetails' smart constructor.
data KMSKeyDetails = KMSKeyDetails'
  { -- | The encryption option for a repository association. It is either owned
    -- by Amazon Web Services Key Management Service (KMS) (@AWS_OWNED_CMK@) or
    -- customer managed (@CUSTOMER_MANAGED_CMK@).
    KMSKeyDetails -> Maybe EncryptionOption
encryptionOption :: Prelude.Maybe EncryptionOption,
    -- | The ID of the Amazon Web Services KMS key that is associated with a
    -- repository association.
    KMSKeyDetails -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text
  }
  deriving (KMSKeyDetails -> KMSKeyDetails -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KMSKeyDetails -> KMSKeyDetails -> Bool
$c/= :: KMSKeyDetails -> KMSKeyDetails -> Bool
== :: KMSKeyDetails -> KMSKeyDetails -> Bool
$c== :: KMSKeyDetails -> KMSKeyDetails -> Bool
Prelude.Eq, ReadPrec [KMSKeyDetails]
ReadPrec KMSKeyDetails
Int -> ReadS KMSKeyDetails
ReadS [KMSKeyDetails]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KMSKeyDetails]
$creadListPrec :: ReadPrec [KMSKeyDetails]
readPrec :: ReadPrec KMSKeyDetails
$creadPrec :: ReadPrec KMSKeyDetails
readList :: ReadS [KMSKeyDetails]
$creadList :: ReadS [KMSKeyDetails]
readsPrec :: Int -> ReadS KMSKeyDetails
$creadsPrec :: Int -> ReadS KMSKeyDetails
Prelude.Read, Int -> KMSKeyDetails -> ShowS
[KMSKeyDetails] -> ShowS
KMSKeyDetails -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KMSKeyDetails] -> ShowS
$cshowList :: [KMSKeyDetails] -> ShowS
show :: KMSKeyDetails -> String
$cshow :: KMSKeyDetails -> String
showsPrec :: Int -> KMSKeyDetails -> ShowS
$cshowsPrec :: Int -> KMSKeyDetails -> ShowS
Prelude.Show, forall x. Rep KMSKeyDetails x -> KMSKeyDetails
forall x. KMSKeyDetails -> Rep KMSKeyDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep KMSKeyDetails x -> KMSKeyDetails
$cfrom :: forall x. KMSKeyDetails -> Rep KMSKeyDetails x
Prelude.Generic)

-- |
-- Create a value of 'KMSKeyDetails' 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:
--
-- 'encryptionOption', 'kmsKeyDetails_encryptionOption' - The encryption option for a repository association. It is either owned
-- by Amazon Web Services Key Management Service (KMS) (@AWS_OWNED_CMK@) or
-- customer managed (@CUSTOMER_MANAGED_CMK@).
--
-- 'kmsKeyId', 'kmsKeyDetails_kmsKeyId' - The ID of the Amazon Web Services KMS key that is associated with a
-- repository association.
newKMSKeyDetails ::
  KMSKeyDetails
newKMSKeyDetails :: KMSKeyDetails
newKMSKeyDetails =
  KMSKeyDetails'
    { $sel:encryptionOption:KMSKeyDetails' :: Maybe EncryptionOption
encryptionOption = forall a. Maybe a
Prelude.Nothing,
      $sel:kmsKeyId:KMSKeyDetails' :: Maybe Text
kmsKeyId = forall a. Maybe a
Prelude.Nothing
    }

-- | The encryption option for a repository association. It is either owned
-- by Amazon Web Services Key Management Service (KMS) (@AWS_OWNED_CMK@) or
-- customer managed (@CUSTOMER_MANAGED_CMK@).
kmsKeyDetails_encryptionOption :: Lens.Lens' KMSKeyDetails (Prelude.Maybe EncryptionOption)
kmsKeyDetails_encryptionOption :: Lens' KMSKeyDetails (Maybe EncryptionOption)
kmsKeyDetails_encryptionOption = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KMSKeyDetails' {Maybe EncryptionOption
encryptionOption :: Maybe EncryptionOption
$sel:encryptionOption:KMSKeyDetails' :: KMSKeyDetails -> Maybe EncryptionOption
encryptionOption} -> Maybe EncryptionOption
encryptionOption) (\s :: KMSKeyDetails
s@KMSKeyDetails' {} Maybe EncryptionOption
a -> KMSKeyDetails
s {$sel:encryptionOption:KMSKeyDetails' :: Maybe EncryptionOption
encryptionOption = Maybe EncryptionOption
a} :: KMSKeyDetails)

-- | The ID of the Amazon Web Services KMS key that is associated with a
-- repository association.
kmsKeyDetails_kmsKeyId :: Lens.Lens' KMSKeyDetails (Prelude.Maybe Prelude.Text)
kmsKeyDetails_kmsKeyId :: Lens' KMSKeyDetails (Maybe Text)
kmsKeyDetails_kmsKeyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\KMSKeyDetails' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:KMSKeyDetails' :: KMSKeyDetails -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: KMSKeyDetails
s@KMSKeyDetails' {} Maybe Text
a -> KMSKeyDetails
s {$sel:kmsKeyId:KMSKeyDetails' :: Maybe Text
kmsKeyId = Maybe Text
a} :: KMSKeyDetails)

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

instance Prelude.Hashable KMSKeyDetails where
  hashWithSalt :: Int -> KMSKeyDetails -> Int
hashWithSalt Int
_salt KMSKeyDetails' {Maybe Text
Maybe EncryptionOption
kmsKeyId :: Maybe Text
encryptionOption :: Maybe EncryptionOption
$sel:kmsKeyId:KMSKeyDetails' :: KMSKeyDetails -> Maybe Text
$sel:encryptionOption:KMSKeyDetails' :: KMSKeyDetails -> Maybe EncryptionOption
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EncryptionOption
encryptionOption
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
kmsKeyId

instance Prelude.NFData KMSKeyDetails where
  rnf :: KMSKeyDetails -> ()
rnf KMSKeyDetails' {Maybe Text
Maybe EncryptionOption
kmsKeyId :: Maybe Text
encryptionOption :: Maybe EncryptionOption
$sel:kmsKeyId:KMSKeyDetails' :: KMSKeyDetails -> Maybe Text
$sel:encryptionOption:KMSKeyDetails' :: KMSKeyDetails -> Maybe EncryptionOption
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe EncryptionOption
encryptionOption
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
kmsKeyId

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