{-# 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.S3.Types.InventoryEncryption
-- 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.S3.Types.InventoryEncryption where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.S3.Internal
import Amazonka.S3.Types.SSEKMS
import Amazonka.S3.Types.SSES3

-- | Contains the type of server-side encryption used to encrypt the
-- inventory results.
--
-- /See:/ 'newInventoryEncryption' smart constructor.
data InventoryEncryption = InventoryEncryption'
  { -- | Specifies the use of SSE-S3 to encrypt delivered inventory reports.
    InventoryEncryption -> Maybe SSES3
sses3 :: Prelude.Maybe SSES3,
    -- | Specifies the use of SSE-KMS to encrypt delivered inventory reports.
    InventoryEncryption -> Maybe SSEKMS
ssekms :: Prelude.Maybe SSEKMS
  }
  deriving (InventoryEncryption -> InventoryEncryption -> Bool
(InventoryEncryption -> InventoryEncryption -> Bool)
-> (InventoryEncryption -> InventoryEncryption -> Bool)
-> Eq InventoryEncryption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InventoryEncryption -> InventoryEncryption -> Bool
$c/= :: InventoryEncryption -> InventoryEncryption -> Bool
== :: InventoryEncryption -> InventoryEncryption -> Bool
$c== :: InventoryEncryption -> InventoryEncryption -> Bool
Prelude.Eq, Int -> InventoryEncryption -> ShowS
[InventoryEncryption] -> ShowS
InventoryEncryption -> String
(Int -> InventoryEncryption -> ShowS)
-> (InventoryEncryption -> String)
-> ([InventoryEncryption] -> ShowS)
-> Show InventoryEncryption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InventoryEncryption] -> ShowS
$cshowList :: [InventoryEncryption] -> ShowS
show :: InventoryEncryption -> String
$cshow :: InventoryEncryption -> String
showsPrec :: Int -> InventoryEncryption -> ShowS
$cshowsPrec :: Int -> InventoryEncryption -> ShowS
Prelude.Show, (forall x. InventoryEncryption -> Rep InventoryEncryption x)
-> (forall x. Rep InventoryEncryption x -> InventoryEncryption)
-> Generic InventoryEncryption
forall x. Rep InventoryEncryption x -> InventoryEncryption
forall x. InventoryEncryption -> Rep InventoryEncryption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InventoryEncryption x -> InventoryEncryption
$cfrom :: forall x. InventoryEncryption -> Rep InventoryEncryption x
Prelude.Generic)

-- |
-- Create a value of 'InventoryEncryption' 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:
--
-- 'sses3', 'inventoryEncryption_sses3' - Specifies the use of SSE-S3 to encrypt delivered inventory reports.
--
-- 'ssekms', 'inventoryEncryption_ssekms' - Specifies the use of SSE-KMS to encrypt delivered inventory reports.
newInventoryEncryption ::
  InventoryEncryption
newInventoryEncryption :: InventoryEncryption
newInventoryEncryption =
  InventoryEncryption' :: Maybe SSES3 -> Maybe SSEKMS -> InventoryEncryption
InventoryEncryption'
    { $sel:sses3:InventoryEncryption' :: Maybe SSES3
sses3 = Maybe SSES3
forall a. Maybe a
Prelude.Nothing,
      $sel:ssekms:InventoryEncryption' :: Maybe SSEKMS
ssekms = Maybe SSEKMS
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the use of SSE-S3 to encrypt delivered inventory reports.
inventoryEncryption_sses3 :: Lens.Lens' InventoryEncryption (Prelude.Maybe SSES3)
inventoryEncryption_sses3 :: (Maybe SSES3 -> f (Maybe SSES3))
-> InventoryEncryption -> f InventoryEncryption
inventoryEncryption_sses3 = (InventoryEncryption -> Maybe SSES3)
-> (InventoryEncryption -> Maybe SSES3 -> InventoryEncryption)
-> Lens
     InventoryEncryption InventoryEncryption (Maybe SSES3) (Maybe SSES3)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryEncryption' {Maybe SSES3
sses3 :: Maybe SSES3
$sel:sses3:InventoryEncryption' :: InventoryEncryption -> Maybe SSES3
sses3} -> Maybe SSES3
sses3) (\s :: InventoryEncryption
s@InventoryEncryption' {} Maybe SSES3
a -> InventoryEncryption
s {$sel:sses3:InventoryEncryption' :: Maybe SSES3
sses3 = Maybe SSES3
a} :: InventoryEncryption)

-- | Specifies the use of SSE-KMS to encrypt delivered inventory reports.
inventoryEncryption_ssekms :: Lens.Lens' InventoryEncryption (Prelude.Maybe SSEKMS)
inventoryEncryption_ssekms :: (Maybe SSEKMS -> f (Maybe SSEKMS))
-> InventoryEncryption -> f InventoryEncryption
inventoryEncryption_ssekms = (InventoryEncryption -> Maybe SSEKMS)
-> (InventoryEncryption -> Maybe SSEKMS -> InventoryEncryption)
-> Lens
     InventoryEncryption
     InventoryEncryption
     (Maybe SSEKMS)
     (Maybe SSEKMS)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InventoryEncryption' {Maybe SSEKMS
ssekms :: Maybe SSEKMS
$sel:ssekms:InventoryEncryption' :: InventoryEncryption -> Maybe SSEKMS
ssekms} -> Maybe SSEKMS
ssekms) (\s :: InventoryEncryption
s@InventoryEncryption' {} Maybe SSEKMS
a -> InventoryEncryption
s {$sel:ssekms:InventoryEncryption' :: Maybe SSEKMS
ssekms = Maybe SSEKMS
a} :: InventoryEncryption)

instance Core.FromXML InventoryEncryption where
  parseXML :: [Node] -> Either String InventoryEncryption
parseXML [Node]
x =
    Maybe SSES3 -> Maybe SSEKMS -> InventoryEncryption
InventoryEncryption'
      (Maybe SSES3 -> Maybe SSEKMS -> InventoryEncryption)
-> Either String (Maybe SSES3)
-> Either String (Maybe SSEKMS -> InventoryEncryption)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe SSES3)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SSE-S3")
      Either String (Maybe SSEKMS -> InventoryEncryption)
-> Either String (Maybe SSEKMS)
-> Either String InventoryEncryption
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe SSEKMS)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SSE-KMS")

instance Prelude.Hashable InventoryEncryption

instance Prelude.NFData InventoryEncryption

instance Core.ToXML InventoryEncryption where
  toXML :: InventoryEncryption -> XML
toXML InventoryEncryption' {Maybe SSEKMS
Maybe SSES3
ssekms :: Maybe SSEKMS
sses3 :: Maybe SSES3
$sel:ssekms:InventoryEncryption' :: InventoryEncryption -> Maybe SSEKMS
$sel:sses3:InventoryEncryption' :: InventoryEncryption -> Maybe SSES3
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [Name
"SSE-S3" Name -> Maybe SSES3 -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe SSES3
sses3, Name
"SSE-KMS" Name -> Maybe SSEKMS -> XML
forall a. ToXML a => Name -> a -> XML
Core.@= Maybe SSEKMS
ssekms]