{-# 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.CloudFront.Types.EncryptionEntity
-- 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.CloudFront.Types.EncryptionEntity where

import Amazonka.CloudFront.Types.FieldPatterns
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

-- | Complex data type for field-level encryption profiles that includes the
-- encryption key and field pattern specifications.
--
-- /See:/ 'newEncryptionEntity' smart constructor.
data EncryptionEntity = EncryptionEntity'
  { -- | The public key associated with a set of field-level encryption patterns,
    -- to be used when encrypting the fields that match the patterns.
    EncryptionEntity -> Text
publicKeyId :: Prelude.Text,
    -- | The provider associated with the public key being used for encryption.
    -- This value must also be provided with the private key for applications
    -- to be able to decrypt data.
    EncryptionEntity -> Text
providerId :: Prelude.Text,
    -- | Field patterns in a field-level encryption content type profile specify
    -- the fields that you want to be encrypted. You can provide the full field
    -- name, or any beginning characters followed by a wildcard (*). You can\'t
    -- overlap field patterns. For example, you can\'t have both ABC* and AB*.
    -- Note that field patterns are case-sensitive.
    EncryptionEntity -> FieldPatterns
fieldPatterns :: FieldPatterns
  }
  deriving (EncryptionEntity -> EncryptionEntity -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EncryptionEntity -> EncryptionEntity -> Bool
$c/= :: EncryptionEntity -> EncryptionEntity -> Bool
== :: EncryptionEntity -> EncryptionEntity -> Bool
$c== :: EncryptionEntity -> EncryptionEntity -> Bool
Prelude.Eq, ReadPrec [EncryptionEntity]
ReadPrec EncryptionEntity
Int -> ReadS EncryptionEntity
ReadS [EncryptionEntity]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EncryptionEntity]
$creadListPrec :: ReadPrec [EncryptionEntity]
readPrec :: ReadPrec EncryptionEntity
$creadPrec :: ReadPrec EncryptionEntity
readList :: ReadS [EncryptionEntity]
$creadList :: ReadS [EncryptionEntity]
readsPrec :: Int -> ReadS EncryptionEntity
$creadsPrec :: Int -> ReadS EncryptionEntity
Prelude.Read, Int -> EncryptionEntity -> ShowS
[EncryptionEntity] -> ShowS
EncryptionEntity -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EncryptionEntity] -> ShowS
$cshowList :: [EncryptionEntity] -> ShowS
show :: EncryptionEntity -> String
$cshow :: EncryptionEntity -> String
showsPrec :: Int -> EncryptionEntity -> ShowS
$cshowsPrec :: Int -> EncryptionEntity -> ShowS
Prelude.Show, forall x. Rep EncryptionEntity x -> EncryptionEntity
forall x. EncryptionEntity -> Rep EncryptionEntity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EncryptionEntity x -> EncryptionEntity
$cfrom :: forall x. EncryptionEntity -> Rep EncryptionEntity x
Prelude.Generic)

-- |
-- Create a value of 'EncryptionEntity' 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:
--
-- 'publicKeyId', 'encryptionEntity_publicKeyId' - The public key associated with a set of field-level encryption patterns,
-- to be used when encrypting the fields that match the patterns.
--
-- 'providerId', 'encryptionEntity_providerId' - The provider associated with the public key being used for encryption.
-- This value must also be provided with the private key for applications
-- to be able to decrypt data.
--
-- 'fieldPatterns', 'encryptionEntity_fieldPatterns' - Field patterns in a field-level encryption content type profile specify
-- the fields that you want to be encrypted. You can provide the full field
-- name, or any beginning characters followed by a wildcard (*). You can\'t
-- overlap field patterns. For example, you can\'t have both ABC* and AB*.
-- Note that field patterns are case-sensitive.
newEncryptionEntity ::
  -- | 'publicKeyId'
  Prelude.Text ->
  -- | 'providerId'
  Prelude.Text ->
  -- | 'fieldPatterns'
  FieldPatterns ->
  EncryptionEntity
newEncryptionEntity :: Text -> Text -> FieldPatterns -> EncryptionEntity
newEncryptionEntity
  Text
pPublicKeyId_
  Text
pProviderId_
  FieldPatterns
pFieldPatterns_ =
    EncryptionEntity'
      { $sel:publicKeyId:EncryptionEntity' :: Text
publicKeyId = Text
pPublicKeyId_,
        $sel:providerId:EncryptionEntity' :: Text
providerId = Text
pProviderId_,
        $sel:fieldPatterns:EncryptionEntity' :: FieldPatterns
fieldPatterns = FieldPatterns
pFieldPatterns_
      }

-- | The public key associated with a set of field-level encryption patterns,
-- to be used when encrypting the fields that match the patterns.
encryptionEntity_publicKeyId :: Lens.Lens' EncryptionEntity Prelude.Text
encryptionEntity_publicKeyId :: Lens' EncryptionEntity Text
encryptionEntity_publicKeyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionEntity' {Text
publicKeyId :: Text
$sel:publicKeyId:EncryptionEntity' :: EncryptionEntity -> Text
publicKeyId} -> Text
publicKeyId) (\s :: EncryptionEntity
s@EncryptionEntity' {} Text
a -> EncryptionEntity
s {$sel:publicKeyId:EncryptionEntity' :: Text
publicKeyId = Text
a} :: EncryptionEntity)

-- | The provider associated with the public key being used for encryption.
-- This value must also be provided with the private key for applications
-- to be able to decrypt data.
encryptionEntity_providerId :: Lens.Lens' EncryptionEntity Prelude.Text
encryptionEntity_providerId :: Lens' EncryptionEntity Text
encryptionEntity_providerId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionEntity' {Text
providerId :: Text
$sel:providerId:EncryptionEntity' :: EncryptionEntity -> Text
providerId} -> Text
providerId) (\s :: EncryptionEntity
s@EncryptionEntity' {} Text
a -> EncryptionEntity
s {$sel:providerId:EncryptionEntity' :: Text
providerId = Text
a} :: EncryptionEntity)

-- | Field patterns in a field-level encryption content type profile specify
-- the fields that you want to be encrypted. You can provide the full field
-- name, or any beginning characters followed by a wildcard (*). You can\'t
-- overlap field patterns. For example, you can\'t have both ABC* and AB*.
-- Note that field patterns are case-sensitive.
encryptionEntity_fieldPatterns :: Lens.Lens' EncryptionEntity FieldPatterns
encryptionEntity_fieldPatterns :: Lens' EncryptionEntity FieldPatterns
encryptionEntity_fieldPatterns = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionEntity' {FieldPatterns
fieldPatterns :: FieldPatterns
$sel:fieldPatterns:EncryptionEntity' :: EncryptionEntity -> FieldPatterns
fieldPatterns} -> FieldPatterns
fieldPatterns) (\s :: EncryptionEntity
s@EncryptionEntity' {} FieldPatterns
a -> EncryptionEntity
s {$sel:fieldPatterns:EncryptionEntity' :: FieldPatterns
fieldPatterns = FieldPatterns
a} :: EncryptionEntity)

instance Data.FromXML EncryptionEntity where
  parseXML :: [Node] -> Either String EncryptionEntity
parseXML [Node]
x =
    Text -> Text -> FieldPatterns -> EncryptionEntity
EncryptionEntity'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"PublicKeyId")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"ProviderId")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"FieldPatterns")

instance Prelude.Hashable EncryptionEntity where
  hashWithSalt :: Int -> EncryptionEntity -> Int
hashWithSalt Int
_salt EncryptionEntity' {Text
FieldPatterns
fieldPatterns :: FieldPatterns
providerId :: Text
publicKeyId :: Text
$sel:fieldPatterns:EncryptionEntity' :: EncryptionEntity -> FieldPatterns
$sel:providerId:EncryptionEntity' :: EncryptionEntity -> Text
$sel:publicKeyId:EncryptionEntity' :: EncryptionEntity -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
publicKeyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
providerId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` FieldPatterns
fieldPatterns

instance Prelude.NFData EncryptionEntity where
  rnf :: EncryptionEntity -> ()
rnf EncryptionEntity' {Text
FieldPatterns
fieldPatterns :: FieldPatterns
providerId :: Text
publicKeyId :: Text
$sel:fieldPatterns:EncryptionEntity' :: EncryptionEntity -> FieldPatterns
$sel:providerId:EncryptionEntity' :: EncryptionEntity -> Text
$sel:publicKeyId:EncryptionEntity' :: EncryptionEntity -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
publicKeyId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
providerId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf FieldPatterns
fieldPatterns

instance Data.ToXML EncryptionEntity where
  toXML :: EncryptionEntity -> XML
toXML EncryptionEntity' {Text
FieldPatterns
fieldPatterns :: FieldPatterns
providerId :: Text
publicKeyId :: Text
$sel:fieldPatterns:EncryptionEntity' :: EncryptionEntity -> FieldPatterns
$sel:providerId:EncryptionEntity' :: EncryptionEntity -> Text
$sel:publicKeyId:EncryptionEntity' :: EncryptionEntity -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ Name
"PublicKeyId" forall a. ToXML a => Name -> a -> XML
Data.@= Text
publicKeyId,
        Name
"ProviderId" forall a. ToXML a => Name -> a -> XML
Data.@= Text
providerId,
        Name
"FieldPatterns" forall a. ToXML a => Name -> a -> XML
Data.@= FieldPatterns
fieldPatterns
      ]