{-# 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.SecurityHub.Types.AwsS3BucketServerSideEncryptionConfiguration
-- 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.SecurityHub.Types.AwsS3BucketServerSideEncryptionConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.AwsS3BucketServerSideEncryptionRule

-- | The encryption configuration for the S3 bucket.
--
-- /See:/ 'newAwsS3BucketServerSideEncryptionConfiguration' smart constructor.
data AwsS3BucketServerSideEncryptionConfiguration = AwsS3BucketServerSideEncryptionConfiguration'
  { -- | The encryption rules that are applied to the S3 bucket.
    AwsS3BucketServerSideEncryptionConfiguration
-> Maybe [AwsS3BucketServerSideEncryptionRule]
rules :: Prelude.Maybe [AwsS3BucketServerSideEncryptionRule]
  }
  deriving (AwsS3BucketServerSideEncryptionConfiguration
-> AwsS3BucketServerSideEncryptionConfiguration -> Bool
(AwsS3BucketServerSideEncryptionConfiguration
 -> AwsS3BucketServerSideEncryptionConfiguration -> Bool)
-> (AwsS3BucketServerSideEncryptionConfiguration
    -> AwsS3BucketServerSideEncryptionConfiguration -> Bool)
-> Eq AwsS3BucketServerSideEncryptionConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsS3BucketServerSideEncryptionConfiguration
-> AwsS3BucketServerSideEncryptionConfiguration -> Bool
$c/= :: AwsS3BucketServerSideEncryptionConfiguration
-> AwsS3BucketServerSideEncryptionConfiguration -> Bool
== :: AwsS3BucketServerSideEncryptionConfiguration
-> AwsS3BucketServerSideEncryptionConfiguration -> Bool
$c== :: AwsS3BucketServerSideEncryptionConfiguration
-> AwsS3BucketServerSideEncryptionConfiguration -> Bool
Prelude.Eq, ReadPrec [AwsS3BucketServerSideEncryptionConfiguration]
ReadPrec AwsS3BucketServerSideEncryptionConfiguration
Int -> ReadS AwsS3BucketServerSideEncryptionConfiguration
ReadS [AwsS3BucketServerSideEncryptionConfiguration]
(Int -> ReadS AwsS3BucketServerSideEncryptionConfiguration)
-> ReadS [AwsS3BucketServerSideEncryptionConfiguration]
-> ReadPrec AwsS3BucketServerSideEncryptionConfiguration
-> ReadPrec [AwsS3BucketServerSideEncryptionConfiguration]
-> Read AwsS3BucketServerSideEncryptionConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsS3BucketServerSideEncryptionConfiguration]
$creadListPrec :: ReadPrec [AwsS3BucketServerSideEncryptionConfiguration]
readPrec :: ReadPrec AwsS3BucketServerSideEncryptionConfiguration
$creadPrec :: ReadPrec AwsS3BucketServerSideEncryptionConfiguration
readList :: ReadS [AwsS3BucketServerSideEncryptionConfiguration]
$creadList :: ReadS [AwsS3BucketServerSideEncryptionConfiguration]
readsPrec :: Int -> ReadS AwsS3BucketServerSideEncryptionConfiguration
$creadsPrec :: Int -> ReadS AwsS3BucketServerSideEncryptionConfiguration
Prelude.Read, Int -> AwsS3BucketServerSideEncryptionConfiguration -> ShowS
[AwsS3BucketServerSideEncryptionConfiguration] -> ShowS
AwsS3BucketServerSideEncryptionConfiguration -> String
(Int -> AwsS3BucketServerSideEncryptionConfiguration -> ShowS)
-> (AwsS3BucketServerSideEncryptionConfiguration -> String)
-> ([AwsS3BucketServerSideEncryptionConfiguration] -> ShowS)
-> Show AwsS3BucketServerSideEncryptionConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsS3BucketServerSideEncryptionConfiguration] -> ShowS
$cshowList :: [AwsS3BucketServerSideEncryptionConfiguration] -> ShowS
show :: AwsS3BucketServerSideEncryptionConfiguration -> String
$cshow :: AwsS3BucketServerSideEncryptionConfiguration -> String
showsPrec :: Int -> AwsS3BucketServerSideEncryptionConfiguration -> ShowS
$cshowsPrec :: Int -> AwsS3BucketServerSideEncryptionConfiguration -> ShowS
Prelude.Show, (forall x.
 AwsS3BucketServerSideEncryptionConfiguration
 -> Rep AwsS3BucketServerSideEncryptionConfiguration x)
-> (forall x.
    Rep AwsS3BucketServerSideEncryptionConfiguration x
    -> AwsS3BucketServerSideEncryptionConfiguration)
-> Generic AwsS3BucketServerSideEncryptionConfiguration
forall x.
Rep AwsS3BucketServerSideEncryptionConfiguration x
-> AwsS3BucketServerSideEncryptionConfiguration
forall x.
AwsS3BucketServerSideEncryptionConfiguration
-> Rep AwsS3BucketServerSideEncryptionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsS3BucketServerSideEncryptionConfiguration x
-> AwsS3BucketServerSideEncryptionConfiguration
$cfrom :: forall x.
AwsS3BucketServerSideEncryptionConfiguration
-> Rep AwsS3BucketServerSideEncryptionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'AwsS3BucketServerSideEncryptionConfiguration' 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', 'awsS3BucketServerSideEncryptionConfiguration_rules' - The encryption rules that are applied to the S3 bucket.
newAwsS3BucketServerSideEncryptionConfiguration ::
  AwsS3BucketServerSideEncryptionConfiguration
newAwsS3BucketServerSideEncryptionConfiguration :: AwsS3BucketServerSideEncryptionConfiguration
newAwsS3BucketServerSideEncryptionConfiguration =
  AwsS3BucketServerSideEncryptionConfiguration' :: Maybe [AwsS3BucketServerSideEncryptionRule]
-> AwsS3BucketServerSideEncryptionConfiguration
AwsS3BucketServerSideEncryptionConfiguration'
    { $sel:rules:AwsS3BucketServerSideEncryptionConfiguration' :: Maybe [AwsS3BucketServerSideEncryptionRule]
rules =
        Maybe [AwsS3BucketServerSideEncryptionRule]
forall a. Maybe a
Prelude.Nothing
    }

-- | The encryption rules that are applied to the S3 bucket.
awsS3BucketServerSideEncryptionConfiguration_rules :: Lens.Lens' AwsS3BucketServerSideEncryptionConfiguration (Prelude.Maybe [AwsS3BucketServerSideEncryptionRule])
awsS3BucketServerSideEncryptionConfiguration_rules :: (Maybe [AwsS3BucketServerSideEncryptionRule]
 -> f (Maybe [AwsS3BucketServerSideEncryptionRule]))
-> AwsS3BucketServerSideEncryptionConfiguration
-> f AwsS3BucketServerSideEncryptionConfiguration
awsS3BucketServerSideEncryptionConfiguration_rules = (AwsS3BucketServerSideEncryptionConfiguration
 -> Maybe [AwsS3BucketServerSideEncryptionRule])
-> (AwsS3BucketServerSideEncryptionConfiguration
    -> Maybe [AwsS3BucketServerSideEncryptionRule]
    -> AwsS3BucketServerSideEncryptionConfiguration)
-> Lens
     AwsS3BucketServerSideEncryptionConfiguration
     AwsS3BucketServerSideEncryptionConfiguration
     (Maybe [AwsS3BucketServerSideEncryptionRule])
     (Maybe [AwsS3BucketServerSideEncryptionRule])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsS3BucketServerSideEncryptionConfiguration' {Maybe [AwsS3BucketServerSideEncryptionRule]
rules :: Maybe [AwsS3BucketServerSideEncryptionRule]
$sel:rules:AwsS3BucketServerSideEncryptionConfiguration' :: AwsS3BucketServerSideEncryptionConfiguration
-> Maybe [AwsS3BucketServerSideEncryptionRule]
rules} -> Maybe [AwsS3BucketServerSideEncryptionRule]
rules) (\s :: AwsS3BucketServerSideEncryptionConfiguration
s@AwsS3BucketServerSideEncryptionConfiguration' {} Maybe [AwsS3BucketServerSideEncryptionRule]
a -> AwsS3BucketServerSideEncryptionConfiguration
s {$sel:rules:AwsS3BucketServerSideEncryptionConfiguration' :: Maybe [AwsS3BucketServerSideEncryptionRule]
rules = Maybe [AwsS3BucketServerSideEncryptionRule]
a} :: AwsS3BucketServerSideEncryptionConfiguration) ((Maybe [AwsS3BucketServerSideEncryptionRule]
  -> f (Maybe [AwsS3BucketServerSideEncryptionRule]))
 -> AwsS3BucketServerSideEncryptionConfiguration
 -> f AwsS3BucketServerSideEncryptionConfiguration)
-> ((Maybe [AwsS3BucketServerSideEncryptionRule]
     -> f (Maybe [AwsS3BucketServerSideEncryptionRule]))
    -> Maybe [AwsS3BucketServerSideEncryptionRule]
    -> f (Maybe [AwsS3BucketServerSideEncryptionRule]))
-> (Maybe [AwsS3BucketServerSideEncryptionRule]
    -> f (Maybe [AwsS3BucketServerSideEncryptionRule]))
-> AwsS3BucketServerSideEncryptionConfiguration
-> f AwsS3BucketServerSideEncryptionConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AwsS3BucketServerSideEncryptionRule]
  [AwsS3BucketServerSideEncryptionRule]
  [AwsS3BucketServerSideEncryptionRule]
  [AwsS3BucketServerSideEncryptionRule]
-> Iso
     (Maybe [AwsS3BucketServerSideEncryptionRule])
     (Maybe [AwsS3BucketServerSideEncryptionRule])
     (Maybe [AwsS3BucketServerSideEncryptionRule])
     (Maybe [AwsS3BucketServerSideEncryptionRule])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [AwsS3BucketServerSideEncryptionRule]
  [AwsS3BucketServerSideEncryptionRule]
  [AwsS3BucketServerSideEncryptionRule]
  [AwsS3BucketServerSideEncryptionRule]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Core.FromJSON
    AwsS3BucketServerSideEncryptionConfiguration
  where
  parseJSON :: Value -> Parser AwsS3BucketServerSideEncryptionConfiguration
parseJSON =
    String
-> (Object -> Parser AwsS3BucketServerSideEncryptionConfiguration)
-> Value
-> Parser AwsS3BucketServerSideEncryptionConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsS3BucketServerSideEncryptionConfiguration"
      ( \Object
x ->
          Maybe [AwsS3BucketServerSideEncryptionRule]
-> AwsS3BucketServerSideEncryptionConfiguration
AwsS3BucketServerSideEncryptionConfiguration'
            (Maybe [AwsS3BucketServerSideEncryptionRule]
 -> AwsS3BucketServerSideEncryptionConfiguration)
-> Parser (Maybe [AwsS3BucketServerSideEncryptionRule])
-> Parser AwsS3BucketServerSideEncryptionConfiguration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text
-> Parser (Maybe (Maybe [AwsS3BucketServerSideEncryptionRule]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Rules" Parser (Maybe (Maybe [AwsS3BucketServerSideEncryptionRule]))
-> Maybe [AwsS3BucketServerSideEncryptionRule]
-> Parser (Maybe [AwsS3BucketServerSideEncryptionRule])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [AwsS3BucketServerSideEncryptionRule]
forall a. Monoid a => a
Prelude.mempty)
      )

instance
  Prelude.Hashable
    AwsS3BucketServerSideEncryptionConfiguration

instance
  Prelude.NFData
    AwsS3BucketServerSideEncryptionConfiguration

instance
  Core.ToJSON
    AwsS3BucketServerSideEncryptionConfiguration
  where
  toJSON :: AwsS3BucketServerSideEncryptionConfiguration -> Value
toJSON
    AwsS3BucketServerSideEncryptionConfiguration' {Maybe [AwsS3BucketServerSideEncryptionRule]
rules :: Maybe [AwsS3BucketServerSideEncryptionRule]
$sel:rules:AwsS3BucketServerSideEncryptionConfiguration' :: AwsS3BucketServerSideEncryptionConfiguration
-> Maybe [AwsS3BucketServerSideEncryptionRule]
..} =
      [Pair] -> Value
Core.object
        ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
            [(Text
"Rules" Text -> [AwsS3BucketServerSideEncryptionRule] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([AwsS3BucketServerSideEncryptionRule] -> Pair)
-> Maybe [AwsS3BucketServerSideEncryptionRule] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AwsS3BucketServerSideEncryptionRule]
rules]
        )