{-# 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.DataExchange.Types.ExportServerSideEncryption
-- 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.DataExchange.Types.ExportServerSideEncryption where

import qualified Amazonka.Core as Core
import Amazonka.DataExchange.Types.ServerSideEncryptionTypes
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Encryption configuration of the export job. Includes the encryption type
-- in addition to the AWS KMS key. The KMS key is only necessary if you
-- chose the KMS encryption. type.
--
-- /See:/ 'newExportServerSideEncryption' smart constructor.
data ExportServerSideEncryption = ExportServerSideEncryption'
  { -- | The Amazon Resource Name (ARN) of the AWS KMS key you want to use to
    -- encrypt the Amazon S3 objects. This parameter is required if you choose
    -- aws:kms as an encryption type.
    ExportServerSideEncryption -> Maybe Text
kmsKeyArn :: Prelude.Maybe Prelude.Text,
    -- | The type of server side encryption used for encrypting the objects in
    -- Amazon S3.
    ExportServerSideEncryption -> ServerSideEncryptionTypes
type' :: ServerSideEncryptionTypes
  }
  deriving (ExportServerSideEncryption -> ExportServerSideEncryption -> Bool
(ExportServerSideEncryption -> ExportServerSideEncryption -> Bool)
-> (ExportServerSideEncryption
    -> ExportServerSideEncryption -> Bool)
-> Eq ExportServerSideEncryption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExportServerSideEncryption -> ExportServerSideEncryption -> Bool
$c/= :: ExportServerSideEncryption -> ExportServerSideEncryption -> Bool
== :: ExportServerSideEncryption -> ExportServerSideEncryption -> Bool
$c== :: ExportServerSideEncryption -> ExportServerSideEncryption -> Bool
Prelude.Eq, ReadPrec [ExportServerSideEncryption]
ReadPrec ExportServerSideEncryption
Int -> ReadS ExportServerSideEncryption
ReadS [ExportServerSideEncryption]
(Int -> ReadS ExportServerSideEncryption)
-> ReadS [ExportServerSideEncryption]
-> ReadPrec ExportServerSideEncryption
-> ReadPrec [ExportServerSideEncryption]
-> Read ExportServerSideEncryption
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExportServerSideEncryption]
$creadListPrec :: ReadPrec [ExportServerSideEncryption]
readPrec :: ReadPrec ExportServerSideEncryption
$creadPrec :: ReadPrec ExportServerSideEncryption
readList :: ReadS [ExportServerSideEncryption]
$creadList :: ReadS [ExportServerSideEncryption]
readsPrec :: Int -> ReadS ExportServerSideEncryption
$creadsPrec :: Int -> ReadS ExportServerSideEncryption
Prelude.Read, Int -> ExportServerSideEncryption -> ShowS
[ExportServerSideEncryption] -> ShowS
ExportServerSideEncryption -> String
(Int -> ExportServerSideEncryption -> ShowS)
-> (ExportServerSideEncryption -> String)
-> ([ExportServerSideEncryption] -> ShowS)
-> Show ExportServerSideEncryption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExportServerSideEncryption] -> ShowS
$cshowList :: [ExportServerSideEncryption] -> ShowS
show :: ExportServerSideEncryption -> String
$cshow :: ExportServerSideEncryption -> String
showsPrec :: Int -> ExportServerSideEncryption -> ShowS
$cshowsPrec :: Int -> ExportServerSideEncryption -> ShowS
Prelude.Show, (forall x.
 ExportServerSideEncryption -> Rep ExportServerSideEncryption x)
-> (forall x.
    Rep ExportServerSideEncryption x -> ExportServerSideEncryption)
-> Generic ExportServerSideEncryption
forall x.
Rep ExportServerSideEncryption x -> ExportServerSideEncryption
forall x.
ExportServerSideEncryption -> Rep ExportServerSideEncryption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ExportServerSideEncryption x -> ExportServerSideEncryption
$cfrom :: forall x.
ExportServerSideEncryption -> Rep ExportServerSideEncryption x
Prelude.Generic)

-- |
-- Create a value of 'ExportServerSideEncryption' 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:
--
-- 'kmsKeyArn', 'exportServerSideEncryption_kmsKeyArn' - The Amazon Resource Name (ARN) of the AWS KMS key you want to use to
-- encrypt the Amazon S3 objects. This parameter is required if you choose
-- aws:kms as an encryption type.
--
-- 'type'', 'exportServerSideEncryption_type' - The type of server side encryption used for encrypting the objects in
-- Amazon S3.
newExportServerSideEncryption ::
  -- | 'type''
  ServerSideEncryptionTypes ->
  ExportServerSideEncryption
newExportServerSideEncryption :: ServerSideEncryptionTypes -> ExportServerSideEncryption
newExportServerSideEncryption ServerSideEncryptionTypes
pType_ =
  ExportServerSideEncryption' :: Maybe Text
-> ServerSideEncryptionTypes -> ExportServerSideEncryption
ExportServerSideEncryption'
    { $sel:kmsKeyArn:ExportServerSideEncryption' :: Maybe Text
kmsKeyArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':ExportServerSideEncryption' :: ServerSideEncryptionTypes
type' = ServerSideEncryptionTypes
pType_
    }

-- | The Amazon Resource Name (ARN) of the AWS KMS key you want to use to
-- encrypt the Amazon S3 objects. This parameter is required if you choose
-- aws:kms as an encryption type.
exportServerSideEncryption_kmsKeyArn :: Lens.Lens' ExportServerSideEncryption (Prelude.Maybe Prelude.Text)
exportServerSideEncryption_kmsKeyArn :: (Maybe Text -> f (Maybe Text))
-> ExportServerSideEncryption -> f ExportServerSideEncryption
exportServerSideEncryption_kmsKeyArn = (ExportServerSideEncryption -> Maybe Text)
-> (ExportServerSideEncryption
    -> Maybe Text -> ExportServerSideEncryption)
-> Lens
     ExportServerSideEncryption
     ExportServerSideEncryption
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportServerSideEncryption' {Maybe Text
kmsKeyArn :: Maybe Text
$sel:kmsKeyArn:ExportServerSideEncryption' :: ExportServerSideEncryption -> Maybe Text
kmsKeyArn} -> Maybe Text
kmsKeyArn) (\s :: ExportServerSideEncryption
s@ExportServerSideEncryption' {} Maybe Text
a -> ExportServerSideEncryption
s {$sel:kmsKeyArn:ExportServerSideEncryption' :: Maybe Text
kmsKeyArn = Maybe Text
a} :: ExportServerSideEncryption)

-- | The type of server side encryption used for encrypting the objects in
-- Amazon S3.
exportServerSideEncryption_type :: Lens.Lens' ExportServerSideEncryption ServerSideEncryptionTypes
exportServerSideEncryption_type :: (ServerSideEncryptionTypes -> f ServerSideEncryptionTypes)
-> ExportServerSideEncryption -> f ExportServerSideEncryption
exportServerSideEncryption_type = (ExportServerSideEncryption -> ServerSideEncryptionTypes)
-> (ExportServerSideEncryption
    -> ServerSideEncryptionTypes -> ExportServerSideEncryption)
-> Lens
     ExportServerSideEncryption
     ExportServerSideEncryption
     ServerSideEncryptionTypes
     ServerSideEncryptionTypes
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExportServerSideEncryption' {ServerSideEncryptionTypes
type' :: ServerSideEncryptionTypes
$sel:type':ExportServerSideEncryption' :: ExportServerSideEncryption -> ServerSideEncryptionTypes
type'} -> ServerSideEncryptionTypes
type') (\s :: ExportServerSideEncryption
s@ExportServerSideEncryption' {} ServerSideEncryptionTypes
a -> ExportServerSideEncryption
s {$sel:type':ExportServerSideEncryption' :: ServerSideEncryptionTypes
type' = ServerSideEncryptionTypes
a} :: ExportServerSideEncryption)

instance Core.FromJSON ExportServerSideEncryption where
  parseJSON :: Value -> Parser ExportServerSideEncryption
parseJSON =
    String
-> (Object -> Parser ExportServerSideEncryption)
-> Value
-> Parser ExportServerSideEncryption
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ExportServerSideEncryption"
      ( \Object
x ->
          Maybe Text
-> ServerSideEncryptionTypes -> ExportServerSideEncryption
ExportServerSideEncryption'
            (Maybe Text
 -> ServerSideEncryptionTypes -> ExportServerSideEncryption)
-> Parser (Maybe Text)
-> Parser (ServerSideEncryptionTypes -> ExportServerSideEncryption)
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
"KmsKeyArn")
            Parser (ServerSideEncryptionTypes -> ExportServerSideEncryption)
-> Parser ServerSideEncryptionTypes
-> Parser ExportServerSideEncryption
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ServerSideEncryptionTypes
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type")
      )

instance Prelude.Hashable ExportServerSideEncryption

instance Prelude.NFData ExportServerSideEncryption

instance Core.ToJSON ExportServerSideEncryption where
  toJSON :: ExportServerSideEncryption -> Value
toJSON ExportServerSideEncryption' {Maybe Text
ServerSideEncryptionTypes
type' :: ServerSideEncryptionTypes
kmsKeyArn :: Maybe Text
$sel:type':ExportServerSideEncryption' :: ExportServerSideEncryption -> ServerSideEncryptionTypes
$sel:kmsKeyArn:ExportServerSideEncryption' :: ExportServerSideEncryption -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"KmsKeyArn" 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
kmsKeyArn,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> ServerSideEncryptionTypes -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ServerSideEncryptionTypes
type')
          ]
      )