{-# 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.AwsS3BucketServerSideEncryptionRule
-- 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.AwsS3BucketServerSideEncryptionRule where

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

-- | An encryption rule to apply to the S3 bucket.
--
-- /See:/ 'newAwsS3BucketServerSideEncryptionRule' smart constructor.
data AwsS3BucketServerSideEncryptionRule = AwsS3BucketServerSideEncryptionRule'
  { -- | Specifies the default server-side encryption to apply to new objects in
    -- the bucket. If a @PUT@ object request doesn\'t specify any server-side
    -- encryption, this default encryption is applied.
    AwsS3BucketServerSideEncryptionRule
-> Maybe AwsS3BucketServerSideEncryptionByDefault
applyServerSideEncryptionByDefault :: Prelude.Maybe AwsS3BucketServerSideEncryptionByDefault
  }
  deriving (AwsS3BucketServerSideEncryptionRule
-> AwsS3BucketServerSideEncryptionRule -> Bool
(AwsS3BucketServerSideEncryptionRule
 -> AwsS3BucketServerSideEncryptionRule -> Bool)
-> (AwsS3BucketServerSideEncryptionRule
    -> AwsS3BucketServerSideEncryptionRule -> Bool)
-> Eq AwsS3BucketServerSideEncryptionRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsS3BucketServerSideEncryptionRule
-> AwsS3BucketServerSideEncryptionRule -> Bool
$c/= :: AwsS3BucketServerSideEncryptionRule
-> AwsS3BucketServerSideEncryptionRule -> Bool
== :: AwsS3BucketServerSideEncryptionRule
-> AwsS3BucketServerSideEncryptionRule -> Bool
$c== :: AwsS3BucketServerSideEncryptionRule
-> AwsS3BucketServerSideEncryptionRule -> Bool
Prelude.Eq, ReadPrec [AwsS3BucketServerSideEncryptionRule]
ReadPrec AwsS3BucketServerSideEncryptionRule
Int -> ReadS AwsS3BucketServerSideEncryptionRule
ReadS [AwsS3BucketServerSideEncryptionRule]
(Int -> ReadS AwsS3BucketServerSideEncryptionRule)
-> ReadS [AwsS3BucketServerSideEncryptionRule]
-> ReadPrec AwsS3BucketServerSideEncryptionRule
-> ReadPrec [AwsS3BucketServerSideEncryptionRule]
-> Read AwsS3BucketServerSideEncryptionRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsS3BucketServerSideEncryptionRule]
$creadListPrec :: ReadPrec [AwsS3BucketServerSideEncryptionRule]
readPrec :: ReadPrec AwsS3BucketServerSideEncryptionRule
$creadPrec :: ReadPrec AwsS3BucketServerSideEncryptionRule
readList :: ReadS [AwsS3BucketServerSideEncryptionRule]
$creadList :: ReadS [AwsS3BucketServerSideEncryptionRule]
readsPrec :: Int -> ReadS AwsS3BucketServerSideEncryptionRule
$creadsPrec :: Int -> ReadS AwsS3BucketServerSideEncryptionRule
Prelude.Read, Int -> AwsS3BucketServerSideEncryptionRule -> ShowS
[AwsS3BucketServerSideEncryptionRule] -> ShowS
AwsS3BucketServerSideEncryptionRule -> String
(Int -> AwsS3BucketServerSideEncryptionRule -> ShowS)
-> (AwsS3BucketServerSideEncryptionRule -> String)
-> ([AwsS3BucketServerSideEncryptionRule] -> ShowS)
-> Show AwsS3BucketServerSideEncryptionRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsS3BucketServerSideEncryptionRule] -> ShowS
$cshowList :: [AwsS3BucketServerSideEncryptionRule] -> ShowS
show :: AwsS3BucketServerSideEncryptionRule -> String
$cshow :: AwsS3BucketServerSideEncryptionRule -> String
showsPrec :: Int -> AwsS3BucketServerSideEncryptionRule -> ShowS
$cshowsPrec :: Int -> AwsS3BucketServerSideEncryptionRule -> ShowS
Prelude.Show, (forall x.
 AwsS3BucketServerSideEncryptionRule
 -> Rep AwsS3BucketServerSideEncryptionRule x)
-> (forall x.
    Rep AwsS3BucketServerSideEncryptionRule x
    -> AwsS3BucketServerSideEncryptionRule)
-> Generic AwsS3BucketServerSideEncryptionRule
forall x.
Rep AwsS3BucketServerSideEncryptionRule x
-> AwsS3BucketServerSideEncryptionRule
forall x.
AwsS3BucketServerSideEncryptionRule
-> Rep AwsS3BucketServerSideEncryptionRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsS3BucketServerSideEncryptionRule x
-> AwsS3BucketServerSideEncryptionRule
$cfrom :: forall x.
AwsS3BucketServerSideEncryptionRule
-> Rep AwsS3BucketServerSideEncryptionRule x
Prelude.Generic)

-- |
-- Create a value of 'AwsS3BucketServerSideEncryptionRule' 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:
--
-- 'applyServerSideEncryptionByDefault', 'awsS3BucketServerSideEncryptionRule_applyServerSideEncryptionByDefault' - Specifies the default server-side encryption to apply to new objects in
-- the bucket. If a @PUT@ object request doesn\'t specify any server-side
-- encryption, this default encryption is applied.
newAwsS3BucketServerSideEncryptionRule ::
  AwsS3BucketServerSideEncryptionRule
newAwsS3BucketServerSideEncryptionRule :: AwsS3BucketServerSideEncryptionRule
newAwsS3BucketServerSideEncryptionRule =
  AwsS3BucketServerSideEncryptionRule' :: Maybe AwsS3BucketServerSideEncryptionByDefault
-> AwsS3BucketServerSideEncryptionRule
AwsS3BucketServerSideEncryptionRule'
    { $sel:applyServerSideEncryptionByDefault:AwsS3BucketServerSideEncryptionRule' :: Maybe AwsS3BucketServerSideEncryptionByDefault
applyServerSideEncryptionByDefault =
        Maybe AwsS3BucketServerSideEncryptionByDefault
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the default server-side encryption to apply to new objects in
-- the bucket. If a @PUT@ object request doesn\'t specify any server-side
-- encryption, this default encryption is applied.
awsS3BucketServerSideEncryptionRule_applyServerSideEncryptionByDefault :: Lens.Lens' AwsS3BucketServerSideEncryptionRule (Prelude.Maybe AwsS3BucketServerSideEncryptionByDefault)
awsS3BucketServerSideEncryptionRule_applyServerSideEncryptionByDefault :: (Maybe AwsS3BucketServerSideEncryptionByDefault
 -> f (Maybe AwsS3BucketServerSideEncryptionByDefault))
-> AwsS3BucketServerSideEncryptionRule
-> f AwsS3BucketServerSideEncryptionRule
awsS3BucketServerSideEncryptionRule_applyServerSideEncryptionByDefault = (AwsS3BucketServerSideEncryptionRule
 -> Maybe AwsS3BucketServerSideEncryptionByDefault)
-> (AwsS3BucketServerSideEncryptionRule
    -> Maybe AwsS3BucketServerSideEncryptionByDefault
    -> AwsS3BucketServerSideEncryptionRule)
-> Lens
     AwsS3BucketServerSideEncryptionRule
     AwsS3BucketServerSideEncryptionRule
     (Maybe AwsS3BucketServerSideEncryptionByDefault)
     (Maybe AwsS3BucketServerSideEncryptionByDefault)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsS3BucketServerSideEncryptionRule' {Maybe AwsS3BucketServerSideEncryptionByDefault
applyServerSideEncryptionByDefault :: Maybe AwsS3BucketServerSideEncryptionByDefault
$sel:applyServerSideEncryptionByDefault:AwsS3BucketServerSideEncryptionRule' :: AwsS3BucketServerSideEncryptionRule
-> Maybe AwsS3BucketServerSideEncryptionByDefault
applyServerSideEncryptionByDefault} -> Maybe AwsS3BucketServerSideEncryptionByDefault
applyServerSideEncryptionByDefault) (\s :: AwsS3BucketServerSideEncryptionRule
s@AwsS3BucketServerSideEncryptionRule' {} Maybe AwsS3BucketServerSideEncryptionByDefault
a -> AwsS3BucketServerSideEncryptionRule
s {$sel:applyServerSideEncryptionByDefault:AwsS3BucketServerSideEncryptionRule' :: Maybe AwsS3BucketServerSideEncryptionByDefault
applyServerSideEncryptionByDefault = Maybe AwsS3BucketServerSideEncryptionByDefault
a} :: AwsS3BucketServerSideEncryptionRule)

instance
  Core.FromJSON
    AwsS3BucketServerSideEncryptionRule
  where
  parseJSON :: Value -> Parser AwsS3BucketServerSideEncryptionRule
parseJSON =
    String
-> (Object -> Parser AwsS3BucketServerSideEncryptionRule)
-> Value
-> Parser AwsS3BucketServerSideEncryptionRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsS3BucketServerSideEncryptionRule"
      ( \Object
x ->
          Maybe AwsS3BucketServerSideEncryptionByDefault
-> AwsS3BucketServerSideEncryptionRule
AwsS3BucketServerSideEncryptionRule'
            (Maybe AwsS3BucketServerSideEncryptionByDefault
 -> AwsS3BucketServerSideEncryptionRule)
-> Parser (Maybe AwsS3BucketServerSideEncryptionByDefault)
-> Parser AwsS3BucketServerSideEncryptionRule
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Parser (Maybe AwsS3BucketServerSideEncryptionByDefault)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ApplyServerSideEncryptionByDefault")
      )

instance
  Prelude.Hashable
    AwsS3BucketServerSideEncryptionRule

instance
  Prelude.NFData
    AwsS3BucketServerSideEncryptionRule

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