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

import Amazonka.CodeGuruReviewer.Types.EncryptionOption
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
--     respository 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
    -- respository association.
    KMSKeyDetails -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text
  }
  deriving (KMSKeyDetails -> KMSKeyDetails -> Bool
(KMSKeyDetails -> KMSKeyDetails -> Bool)
-> (KMSKeyDetails -> KMSKeyDetails -> Bool) -> Eq KMSKeyDetails
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]
(Int -> ReadS KMSKeyDetails)
-> ReadS [KMSKeyDetails]
-> ReadPrec KMSKeyDetails
-> ReadPrec [KMSKeyDetails]
-> Read 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
(Int -> KMSKeyDetails -> ShowS)
-> (KMSKeyDetails -> String)
-> ([KMSKeyDetails] -> ShowS)
-> Show KMSKeyDetails
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. KMSKeyDetails -> Rep KMSKeyDetails x)
-> (forall x. Rep KMSKeyDetails x -> KMSKeyDetails)
-> Generic KMSKeyDetails
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
-- respository association.
newKMSKeyDetails ::
  KMSKeyDetails
newKMSKeyDetails :: KMSKeyDetails
newKMSKeyDetails =
  KMSKeyDetails' :: Maybe EncryptionOption -> Maybe Text -> KMSKeyDetails
KMSKeyDetails'
    { $sel:encryptionOption:KMSKeyDetails' :: Maybe EncryptionOption
encryptionOption = Maybe EncryptionOption
forall a. Maybe a
Prelude.Nothing,
      $sel:kmsKeyId:KMSKeyDetails' :: Maybe Text
kmsKeyId = Maybe Text
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 :: (Maybe EncryptionOption -> f (Maybe EncryptionOption))
-> KMSKeyDetails -> f KMSKeyDetails
kmsKeyDetails_encryptionOption = (KMSKeyDetails -> Maybe EncryptionOption)
-> (KMSKeyDetails -> Maybe EncryptionOption -> KMSKeyDetails)
-> Lens
     KMSKeyDetails
     KMSKeyDetails
     (Maybe EncryptionOption)
     (Maybe 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
-- respository association.
kmsKeyDetails_kmsKeyId :: Lens.Lens' KMSKeyDetails (Prelude.Maybe Prelude.Text)
kmsKeyDetails_kmsKeyId :: (Maybe Text -> f (Maybe Text)) -> KMSKeyDetails -> f KMSKeyDetails
kmsKeyDetails_kmsKeyId = (KMSKeyDetails -> Maybe Text)
-> (KMSKeyDetails -> Maybe Text -> KMSKeyDetails)
-> Lens KMSKeyDetails KMSKeyDetails (Maybe Text) (Maybe Text)
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 Core.FromJSON KMSKeyDetails where
  parseJSON :: Value -> Parser KMSKeyDetails
parseJSON =
    String
-> (Object -> Parser KMSKeyDetails)
-> Value
-> Parser KMSKeyDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"KMSKeyDetails"
      ( \Object
x ->
          Maybe EncryptionOption -> Maybe Text -> KMSKeyDetails
KMSKeyDetails'
            (Maybe EncryptionOption -> Maybe Text -> KMSKeyDetails)
-> Parser (Maybe EncryptionOption)
-> Parser (Maybe Text -> KMSKeyDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe EncryptionOption)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EncryptionOption")
            Parser (Maybe Text -> KMSKeyDetails)
-> Parser (Maybe Text) -> Parser KMSKeyDetails
forall (f :: * -> *) a b. Applicative f => 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
"KMSKeyId")
      )

instance Prelude.Hashable KMSKeyDetails

instance Prelude.NFData KMSKeyDetails

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EncryptionOption" Text -> EncryptionOption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (EncryptionOption -> Pair) -> Maybe EncryptionOption -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EncryptionOption
encryptionOption,
            (Text
"KMSKeyId" 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
kmsKeyId
          ]
      )