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

import Amazonka.CloudFront.Types.FieldLevelEncryptionConfig
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A complex data type that includes the profile configurations and other
-- options specified for field-level encryption.
--
-- /See:/ 'newFieldLevelEncryption' smart constructor.
data FieldLevelEncryption = FieldLevelEncryption'
  { -- | The configuration ID for a field-level encryption configuration which
    -- includes a set of profiles that specify certain selected data fields to
    -- be encrypted by specific public keys.
    FieldLevelEncryption -> Text
id :: Prelude.Text,
    -- | The last time the field-level encryption configuration was changed.
    FieldLevelEncryption -> ISO8601
lastModifiedTime :: Core.ISO8601,
    -- | A complex data type that includes the profile configurations specified
    -- for field-level encryption.
    FieldLevelEncryption -> FieldLevelEncryptionConfig
fieldLevelEncryptionConfig :: FieldLevelEncryptionConfig
  }
  deriving (FieldLevelEncryption -> FieldLevelEncryption -> Bool
(FieldLevelEncryption -> FieldLevelEncryption -> Bool)
-> (FieldLevelEncryption -> FieldLevelEncryption -> Bool)
-> Eq FieldLevelEncryption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FieldLevelEncryption -> FieldLevelEncryption -> Bool
$c/= :: FieldLevelEncryption -> FieldLevelEncryption -> Bool
== :: FieldLevelEncryption -> FieldLevelEncryption -> Bool
$c== :: FieldLevelEncryption -> FieldLevelEncryption -> Bool
Prelude.Eq, ReadPrec [FieldLevelEncryption]
ReadPrec FieldLevelEncryption
Int -> ReadS FieldLevelEncryption
ReadS [FieldLevelEncryption]
(Int -> ReadS FieldLevelEncryption)
-> ReadS [FieldLevelEncryption]
-> ReadPrec FieldLevelEncryption
-> ReadPrec [FieldLevelEncryption]
-> Read FieldLevelEncryption
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FieldLevelEncryption]
$creadListPrec :: ReadPrec [FieldLevelEncryption]
readPrec :: ReadPrec FieldLevelEncryption
$creadPrec :: ReadPrec FieldLevelEncryption
readList :: ReadS [FieldLevelEncryption]
$creadList :: ReadS [FieldLevelEncryption]
readsPrec :: Int -> ReadS FieldLevelEncryption
$creadsPrec :: Int -> ReadS FieldLevelEncryption
Prelude.Read, Int -> FieldLevelEncryption -> ShowS
[FieldLevelEncryption] -> ShowS
FieldLevelEncryption -> String
(Int -> FieldLevelEncryption -> ShowS)
-> (FieldLevelEncryption -> String)
-> ([FieldLevelEncryption] -> ShowS)
-> Show FieldLevelEncryption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FieldLevelEncryption] -> ShowS
$cshowList :: [FieldLevelEncryption] -> ShowS
show :: FieldLevelEncryption -> String
$cshow :: FieldLevelEncryption -> String
showsPrec :: Int -> FieldLevelEncryption -> ShowS
$cshowsPrec :: Int -> FieldLevelEncryption -> ShowS
Prelude.Show, (forall x. FieldLevelEncryption -> Rep FieldLevelEncryption x)
-> (forall x. Rep FieldLevelEncryption x -> FieldLevelEncryption)
-> Generic FieldLevelEncryption
forall x. Rep FieldLevelEncryption x -> FieldLevelEncryption
forall x. FieldLevelEncryption -> Rep FieldLevelEncryption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FieldLevelEncryption x -> FieldLevelEncryption
$cfrom :: forall x. FieldLevelEncryption -> Rep FieldLevelEncryption x
Prelude.Generic)

-- |
-- Create a value of 'FieldLevelEncryption' 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:
--
-- 'id', 'fieldLevelEncryption_id' - The configuration ID for a field-level encryption configuration which
-- includes a set of profiles that specify certain selected data fields to
-- be encrypted by specific public keys.
--
-- 'lastModifiedTime', 'fieldLevelEncryption_lastModifiedTime' - The last time the field-level encryption configuration was changed.
--
-- 'fieldLevelEncryptionConfig', 'fieldLevelEncryption_fieldLevelEncryptionConfig' - A complex data type that includes the profile configurations specified
-- for field-level encryption.
newFieldLevelEncryption ::
  -- | 'id'
  Prelude.Text ->
  -- | 'lastModifiedTime'
  Prelude.UTCTime ->
  -- | 'fieldLevelEncryptionConfig'
  FieldLevelEncryptionConfig ->
  FieldLevelEncryption
newFieldLevelEncryption :: Text
-> UTCTime -> FieldLevelEncryptionConfig -> FieldLevelEncryption
newFieldLevelEncryption
  Text
pId_
  UTCTime
pLastModifiedTime_
  FieldLevelEncryptionConfig
pFieldLevelEncryptionConfig_ =
    FieldLevelEncryption' :: Text
-> ISO8601 -> FieldLevelEncryptionConfig -> FieldLevelEncryption
FieldLevelEncryption'
      { $sel:id:FieldLevelEncryption' :: Text
id = Text
pId_,
        $sel:lastModifiedTime:FieldLevelEncryption' :: ISO8601
lastModifiedTime =
          Tagged UTCTime (Identity UTCTime)
-> Tagged ISO8601 (Identity ISO8601)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged ISO8601 (Identity ISO8601))
-> UTCTime -> ISO8601
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pLastModifiedTime_,
        $sel:fieldLevelEncryptionConfig:FieldLevelEncryption' :: FieldLevelEncryptionConfig
fieldLevelEncryptionConfig =
          FieldLevelEncryptionConfig
pFieldLevelEncryptionConfig_
      }

-- | The configuration ID for a field-level encryption configuration which
-- includes a set of profiles that specify certain selected data fields to
-- be encrypted by specific public keys.
fieldLevelEncryption_id :: Lens.Lens' FieldLevelEncryption Prelude.Text
fieldLevelEncryption_id :: (Text -> f Text) -> FieldLevelEncryption -> f FieldLevelEncryption
fieldLevelEncryption_id = (FieldLevelEncryption -> Text)
-> (FieldLevelEncryption -> Text -> FieldLevelEncryption)
-> Lens FieldLevelEncryption FieldLevelEncryption Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldLevelEncryption' {Text
id :: Text
$sel:id:FieldLevelEncryption' :: FieldLevelEncryption -> Text
id} -> Text
id) (\s :: FieldLevelEncryption
s@FieldLevelEncryption' {} Text
a -> FieldLevelEncryption
s {$sel:id:FieldLevelEncryption' :: Text
id = Text
a} :: FieldLevelEncryption)

-- | The last time the field-level encryption configuration was changed.
fieldLevelEncryption_lastModifiedTime :: Lens.Lens' FieldLevelEncryption Prelude.UTCTime
fieldLevelEncryption_lastModifiedTime :: (UTCTime -> f UTCTime)
-> FieldLevelEncryption -> f FieldLevelEncryption
fieldLevelEncryption_lastModifiedTime = (FieldLevelEncryption -> ISO8601)
-> (FieldLevelEncryption -> ISO8601 -> FieldLevelEncryption)
-> Lens FieldLevelEncryption FieldLevelEncryption ISO8601 ISO8601
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldLevelEncryption' {ISO8601
lastModifiedTime :: ISO8601
$sel:lastModifiedTime:FieldLevelEncryption' :: FieldLevelEncryption -> ISO8601
lastModifiedTime} -> ISO8601
lastModifiedTime) (\s :: FieldLevelEncryption
s@FieldLevelEncryption' {} ISO8601
a -> FieldLevelEncryption
s {$sel:lastModifiedTime:FieldLevelEncryption' :: ISO8601
lastModifiedTime = ISO8601
a} :: FieldLevelEncryption) ((ISO8601 -> f ISO8601)
 -> FieldLevelEncryption -> f FieldLevelEncryption)
-> ((UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601)
-> (UTCTime -> f UTCTime)
-> FieldLevelEncryption
-> f FieldLevelEncryption
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> ISO8601 -> f ISO8601
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | A complex data type that includes the profile configurations specified
-- for field-level encryption.
fieldLevelEncryption_fieldLevelEncryptionConfig :: Lens.Lens' FieldLevelEncryption FieldLevelEncryptionConfig
fieldLevelEncryption_fieldLevelEncryptionConfig :: (FieldLevelEncryptionConfig -> f FieldLevelEncryptionConfig)
-> FieldLevelEncryption -> f FieldLevelEncryption
fieldLevelEncryption_fieldLevelEncryptionConfig = (FieldLevelEncryption -> FieldLevelEncryptionConfig)
-> (FieldLevelEncryption
    -> FieldLevelEncryptionConfig -> FieldLevelEncryption)
-> Lens
     FieldLevelEncryption
     FieldLevelEncryption
     FieldLevelEncryptionConfig
     FieldLevelEncryptionConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FieldLevelEncryption' {FieldLevelEncryptionConfig
fieldLevelEncryptionConfig :: FieldLevelEncryptionConfig
$sel:fieldLevelEncryptionConfig:FieldLevelEncryption' :: FieldLevelEncryption -> FieldLevelEncryptionConfig
fieldLevelEncryptionConfig} -> FieldLevelEncryptionConfig
fieldLevelEncryptionConfig) (\s :: FieldLevelEncryption
s@FieldLevelEncryption' {} FieldLevelEncryptionConfig
a -> FieldLevelEncryption
s {$sel:fieldLevelEncryptionConfig:FieldLevelEncryption' :: FieldLevelEncryptionConfig
fieldLevelEncryptionConfig = FieldLevelEncryptionConfig
a} :: FieldLevelEncryption)

instance Core.FromXML FieldLevelEncryption where
  parseXML :: [Node] -> Either String FieldLevelEncryption
parseXML [Node]
x =
    Text
-> ISO8601 -> FieldLevelEncryptionConfig -> FieldLevelEncryption
FieldLevelEncryption'
      (Text
 -> ISO8601 -> FieldLevelEncryptionConfig -> FieldLevelEncryption)
-> Either String Text
-> Either
     String
     (ISO8601 -> FieldLevelEncryptionConfig -> FieldLevelEncryption)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"Id")
      Either
  String
  (ISO8601 -> FieldLevelEncryptionConfig -> FieldLevelEncryption)
-> Either String ISO8601
-> Either
     String (FieldLevelEncryptionConfig -> FieldLevelEncryption)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String ISO8601
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"LastModifiedTime")
      Either String (FieldLevelEncryptionConfig -> FieldLevelEncryption)
-> Either String FieldLevelEncryptionConfig
-> Either String FieldLevelEncryption
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String FieldLevelEncryptionConfig
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"FieldLevelEncryptionConfig")

instance Prelude.Hashable FieldLevelEncryption

instance Prelude.NFData FieldLevelEncryption