{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DataExchange.Types.ExportServerSideEncryption where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DataExchange.Types.ServerSideEncryptionTypes
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
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]
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
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.
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'
    { $sel:kmsKeyArn:ExportServerSideEncryption' :: Maybe Text
kmsKeyArn =
        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 :: Lens' ExportServerSideEncryption (Maybe Text)
exportServerSideEncryption_kmsKeyArn = 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 :: Lens' ExportServerSideEncryption ServerSideEncryptionTypes
exportServerSideEncryption_type = 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 Data.FromJSON ExportServerSideEncryption where
  parseJSON :: Value -> Parser ExportServerSideEncryption
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ExportServerSideEncryption"
      ( \Object
x ->
          Maybe Text
-> ServerSideEncryptionTypes -> ExportServerSideEncryption
ExportServerSideEncryption'
            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
"KmsKeyArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Type")
      )

instance Prelude.Hashable ExportServerSideEncryption where
  hashWithSalt :: Int -> ExportServerSideEncryption -> Int
hashWithSalt Int
_salt ExportServerSideEncryption' {Maybe Text
ServerSideEncryptionTypes
type' :: ServerSideEncryptionTypes
kmsKeyArn :: Maybe Text
$sel:type':ExportServerSideEncryption' :: ExportServerSideEncryption -> ServerSideEncryptionTypes
$sel:kmsKeyArn:ExportServerSideEncryption' :: ExportServerSideEncryption -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
kmsKeyArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ServerSideEncryptionTypes
type'

instance Prelude.NFData ExportServerSideEncryption where
  rnf :: ExportServerSideEncryption -> ()
rnf ExportServerSideEncryption' {Maybe Text
ServerSideEncryptionTypes
type' :: ServerSideEncryptionTypes
kmsKeyArn :: Maybe Text
$sel:type':ExportServerSideEncryption' :: ExportServerSideEncryption -> ServerSideEncryptionTypes
$sel:kmsKeyArn:ExportServerSideEncryption' :: ExportServerSideEncryption -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
kmsKeyArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ServerSideEncryptionTypes
type'

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"KmsKeyArn" 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
kmsKeyArn,
            forall a. a -> Maybe a
Prelude.Just (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ServerSideEncryptionTypes
type')
          ]
      )