{-# 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.ServerSideEncryptionConfiguration
-- 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.ServerSideEncryptionConfiguration 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.ServerSideEncryptionRule

-- | Specifies the default server-side-encryption configuration.
--
-- /See:/ 'newServerSideEncryptionConfiguration' smart constructor.
data ServerSideEncryptionConfiguration = ServerSideEncryptionConfiguration'
  { -- | Container for information about a particular server-side encryption
    -- configuration rule.
    ServerSideEncryptionConfiguration -> [ServerSideEncryptionRule]
rules :: [ServerSideEncryptionRule]
  }
  deriving (ServerSideEncryptionConfiguration
-> ServerSideEncryptionConfiguration -> Bool
(ServerSideEncryptionConfiguration
 -> ServerSideEncryptionConfiguration -> Bool)
-> (ServerSideEncryptionConfiguration
    -> ServerSideEncryptionConfiguration -> Bool)
-> Eq ServerSideEncryptionConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ServerSideEncryptionConfiguration
-> ServerSideEncryptionConfiguration -> Bool
$c/= :: ServerSideEncryptionConfiguration
-> ServerSideEncryptionConfiguration -> Bool
== :: ServerSideEncryptionConfiguration
-> ServerSideEncryptionConfiguration -> Bool
$c== :: ServerSideEncryptionConfiguration
-> ServerSideEncryptionConfiguration -> Bool
Prelude.Eq, Int -> ServerSideEncryptionConfiguration -> ShowS
[ServerSideEncryptionConfiguration] -> ShowS
ServerSideEncryptionConfiguration -> String
(Int -> ServerSideEncryptionConfiguration -> ShowS)
-> (ServerSideEncryptionConfiguration -> String)
-> ([ServerSideEncryptionConfiguration] -> ShowS)
-> Show ServerSideEncryptionConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ServerSideEncryptionConfiguration] -> ShowS
$cshowList :: [ServerSideEncryptionConfiguration] -> ShowS
show :: ServerSideEncryptionConfiguration -> String
$cshow :: ServerSideEncryptionConfiguration -> String
showsPrec :: Int -> ServerSideEncryptionConfiguration -> ShowS
$cshowsPrec :: Int -> ServerSideEncryptionConfiguration -> ShowS
Prelude.Show, (forall x.
 ServerSideEncryptionConfiguration
 -> Rep ServerSideEncryptionConfiguration x)
-> (forall x.
    Rep ServerSideEncryptionConfiguration x
    -> ServerSideEncryptionConfiguration)
-> Generic ServerSideEncryptionConfiguration
forall x.
Rep ServerSideEncryptionConfiguration x
-> ServerSideEncryptionConfiguration
forall x.
ServerSideEncryptionConfiguration
-> Rep ServerSideEncryptionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ServerSideEncryptionConfiguration x
-> ServerSideEncryptionConfiguration
$cfrom :: forall x.
ServerSideEncryptionConfiguration
-> Rep ServerSideEncryptionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'ServerSideEncryptionConfiguration' 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:
--
-- 'rules', 'serverSideEncryptionConfiguration_rules' - Container for information about a particular server-side encryption
-- configuration rule.
newServerSideEncryptionConfiguration ::
  ServerSideEncryptionConfiguration
newServerSideEncryptionConfiguration :: ServerSideEncryptionConfiguration
newServerSideEncryptionConfiguration =
  ServerSideEncryptionConfiguration' :: [ServerSideEncryptionRule] -> ServerSideEncryptionConfiguration
ServerSideEncryptionConfiguration'
    { $sel:rules:ServerSideEncryptionConfiguration' :: [ServerSideEncryptionRule]
rules =
        [ServerSideEncryptionRule]
forall a. Monoid a => a
Prelude.mempty
    }

-- | Container for information about a particular server-side encryption
-- configuration rule.
serverSideEncryptionConfiguration_rules :: Lens.Lens' ServerSideEncryptionConfiguration [ServerSideEncryptionRule]
serverSideEncryptionConfiguration_rules :: ([ServerSideEncryptionRule] -> f [ServerSideEncryptionRule])
-> ServerSideEncryptionConfiguration
-> f ServerSideEncryptionConfiguration
serverSideEncryptionConfiguration_rules = (ServerSideEncryptionConfiguration -> [ServerSideEncryptionRule])
-> (ServerSideEncryptionConfiguration
    -> [ServerSideEncryptionRule] -> ServerSideEncryptionConfiguration)
-> Lens
     ServerSideEncryptionConfiguration
     ServerSideEncryptionConfiguration
     [ServerSideEncryptionRule]
     [ServerSideEncryptionRule]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ServerSideEncryptionConfiguration' {[ServerSideEncryptionRule]
rules :: [ServerSideEncryptionRule]
$sel:rules:ServerSideEncryptionConfiguration' :: ServerSideEncryptionConfiguration -> [ServerSideEncryptionRule]
rules} -> [ServerSideEncryptionRule]
rules) (\s :: ServerSideEncryptionConfiguration
s@ServerSideEncryptionConfiguration' {} [ServerSideEncryptionRule]
a -> ServerSideEncryptionConfiguration
s {$sel:rules:ServerSideEncryptionConfiguration' :: [ServerSideEncryptionRule]
rules = [ServerSideEncryptionRule]
a} :: ServerSideEncryptionConfiguration) (([ServerSideEncryptionRule] -> f [ServerSideEncryptionRule])
 -> ServerSideEncryptionConfiguration
 -> f ServerSideEncryptionConfiguration)
-> (([ServerSideEncryptionRule] -> f [ServerSideEncryptionRule])
    -> [ServerSideEncryptionRule] -> f [ServerSideEncryptionRule])
-> ([ServerSideEncryptionRule] -> f [ServerSideEncryptionRule])
-> ServerSideEncryptionConfiguration
-> f ServerSideEncryptionConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ServerSideEncryptionRule] -> f [ServerSideEncryptionRule])
-> [ServerSideEncryptionRule] -> f [ServerSideEncryptionRule]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Core.FromXML
    ServerSideEncryptionConfiguration
  where
  parseXML :: [Node] -> Either String ServerSideEncryptionConfiguration
parseXML [Node]
x =
    [ServerSideEncryptionRule] -> ServerSideEncryptionConfiguration
ServerSideEncryptionConfiguration'
      ([ServerSideEncryptionRule] -> ServerSideEncryptionConfiguration)
-> Either String [ServerSideEncryptionRule]
-> Either String ServerSideEncryptionConfiguration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Text -> [Node] -> Either String [ServerSideEncryptionRule]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"Rule" [Node]
x)

instance
  Prelude.Hashable
    ServerSideEncryptionConfiguration

instance
  Prelude.NFData
    ServerSideEncryptionConfiguration

instance Core.ToXML ServerSideEncryptionConfiguration where
  toXML :: ServerSideEncryptionConfiguration -> XML
toXML ServerSideEncryptionConfiguration' {[ServerSideEncryptionRule]
rules :: [ServerSideEncryptionRule]
$sel:rules:ServerSideEncryptionConfiguration' :: ServerSideEncryptionConfiguration -> [ServerSideEncryptionRule]
..} =
    [XML] -> XML
forall a. Monoid a => [a] -> a
Prelude.mconcat [Name -> [ServerSideEncryptionRule] -> XML
forall a. (IsList a, ToXML (Item a)) => Name -> a -> XML
Core.toXMLList Name
"Rule" [ServerSideEncryptionRule]
rules]