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

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

-- | The notification configuration for the S3 bucket.
--
-- /See:/ 'newAwsS3BucketNotificationConfiguration' smart constructor.
data AwsS3BucketNotificationConfiguration = AwsS3BucketNotificationConfiguration'
  { -- | Configurations for S3 bucket notifications.
    AwsS3BucketNotificationConfiguration
-> Maybe [AwsS3BucketNotificationConfigurationDetail]
configurations :: Prelude.Maybe [AwsS3BucketNotificationConfigurationDetail]
  }
  deriving (AwsS3BucketNotificationConfiguration
-> AwsS3BucketNotificationConfiguration -> Bool
(AwsS3BucketNotificationConfiguration
 -> AwsS3BucketNotificationConfiguration -> Bool)
-> (AwsS3BucketNotificationConfiguration
    -> AwsS3BucketNotificationConfiguration -> Bool)
-> Eq AwsS3BucketNotificationConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsS3BucketNotificationConfiguration
-> AwsS3BucketNotificationConfiguration -> Bool
$c/= :: AwsS3BucketNotificationConfiguration
-> AwsS3BucketNotificationConfiguration -> Bool
== :: AwsS3BucketNotificationConfiguration
-> AwsS3BucketNotificationConfiguration -> Bool
$c== :: AwsS3BucketNotificationConfiguration
-> AwsS3BucketNotificationConfiguration -> Bool
Prelude.Eq, ReadPrec [AwsS3BucketNotificationConfiguration]
ReadPrec AwsS3BucketNotificationConfiguration
Int -> ReadS AwsS3BucketNotificationConfiguration
ReadS [AwsS3BucketNotificationConfiguration]
(Int -> ReadS AwsS3BucketNotificationConfiguration)
-> ReadS [AwsS3BucketNotificationConfiguration]
-> ReadPrec AwsS3BucketNotificationConfiguration
-> ReadPrec [AwsS3BucketNotificationConfiguration]
-> Read AwsS3BucketNotificationConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsS3BucketNotificationConfiguration]
$creadListPrec :: ReadPrec [AwsS3BucketNotificationConfiguration]
readPrec :: ReadPrec AwsS3BucketNotificationConfiguration
$creadPrec :: ReadPrec AwsS3BucketNotificationConfiguration
readList :: ReadS [AwsS3BucketNotificationConfiguration]
$creadList :: ReadS [AwsS3BucketNotificationConfiguration]
readsPrec :: Int -> ReadS AwsS3BucketNotificationConfiguration
$creadsPrec :: Int -> ReadS AwsS3BucketNotificationConfiguration
Prelude.Read, Int -> AwsS3BucketNotificationConfiguration -> ShowS
[AwsS3BucketNotificationConfiguration] -> ShowS
AwsS3BucketNotificationConfiguration -> String
(Int -> AwsS3BucketNotificationConfiguration -> ShowS)
-> (AwsS3BucketNotificationConfiguration -> String)
-> ([AwsS3BucketNotificationConfiguration] -> ShowS)
-> Show AwsS3BucketNotificationConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsS3BucketNotificationConfiguration] -> ShowS
$cshowList :: [AwsS3BucketNotificationConfiguration] -> ShowS
show :: AwsS3BucketNotificationConfiguration -> String
$cshow :: AwsS3BucketNotificationConfiguration -> String
showsPrec :: Int -> AwsS3BucketNotificationConfiguration -> ShowS
$cshowsPrec :: Int -> AwsS3BucketNotificationConfiguration -> ShowS
Prelude.Show, (forall x.
 AwsS3BucketNotificationConfiguration
 -> Rep AwsS3BucketNotificationConfiguration x)
-> (forall x.
    Rep AwsS3BucketNotificationConfiguration x
    -> AwsS3BucketNotificationConfiguration)
-> Generic AwsS3BucketNotificationConfiguration
forall x.
Rep AwsS3BucketNotificationConfiguration x
-> AwsS3BucketNotificationConfiguration
forall x.
AwsS3BucketNotificationConfiguration
-> Rep AwsS3BucketNotificationConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsS3BucketNotificationConfiguration x
-> AwsS3BucketNotificationConfiguration
$cfrom :: forall x.
AwsS3BucketNotificationConfiguration
-> Rep AwsS3BucketNotificationConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'AwsS3BucketNotificationConfiguration' 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:
--
-- 'configurations', 'awsS3BucketNotificationConfiguration_configurations' - Configurations for S3 bucket notifications.
newAwsS3BucketNotificationConfiguration ::
  AwsS3BucketNotificationConfiguration
newAwsS3BucketNotificationConfiguration :: AwsS3BucketNotificationConfiguration
newAwsS3BucketNotificationConfiguration =
  AwsS3BucketNotificationConfiguration' :: Maybe [AwsS3BucketNotificationConfigurationDetail]
-> AwsS3BucketNotificationConfiguration
AwsS3BucketNotificationConfiguration'
    { $sel:configurations:AwsS3BucketNotificationConfiguration' :: Maybe [AwsS3BucketNotificationConfigurationDetail]
configurations =
        Maybe [AwsS3BucketNotificationConfigurationDetail]
forall a. Maybe a
Prelude.Nothing
    }

-- | Configurations for S3 bucket notifications.
awsS3BucketNotificationConfiguration_configurations :: Lens.Lens' AwsS3BucketNotificationConfiguration (Prelude.Maybe [AwsS3BucketNotificationConfigurationDetail])
awsS3BucketNotificationConfiguration_configurations :: (Maybe [AwsS3BucketNotificationConfigurationDetail]
 -> f (Maybe [AwsS3BucketNotificationConfigurationDetail]))
-> AwsS3BucketNotificationConfiguration
-> f AwsS3BucketNotificationConfiguration
awsS3BucketNotificationConfiguration_configurations = (AwsS3BucketNotificationConfiguration
 -> Maybe [AwsS3BucketNotificationConfigurationDetail])
-> (AwsS3BucketNotificationConfiguration
    -> Maybe [AwsS3BucketNotificationConfigurationDetail]
    -> AwsS3BucketNotificationConfiguration)
-> Lens
     AwsS3BucketNotificationConfiguration
     AwsS3BucketNotificationConfiguration
     (Maybe [AwsS3BucketNotificationConfigurationDetail])
     (Maybe [AwsS3BucketNotificationConfigurationDetail])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsS3BucketNotificationConfiguration' {Maybe [AwsS3BucketNotificationConfigurationDetail]
configurations :: Maybe [AwsS3BucketNotificationConfigurationDetail]
$sel:configurations:AwsS3BucketNotificationConfiguration' :: AwsS3BucketNotificationConfiguration
-> Maybe [AwsS3BucketNotificationConfigurationDetail]
configurations} -> Maybe [AwsS3BucketNotificationConfigurationDetail]
configurations) (\s :: AwsS3BucketNotificationConfiguration
s@AwsS3BucketNotificationConfiguration' {} Maybe [AwsS3BucketNotificationConfigurationDetail]
a -> AwsS3BucketNotificationConfiguration
s {$sel:configurations:AwsS3BucketNotificationConfiguration' :: Maybe [AwsS3BucketNotificationConfigurationDetail]
configurations = Maybe [AwsS3BucketNotificationConfigurationDetail]
a} :: AwsS3BucketNotificationConfiguration) ((Maybe [AwsS3BucketNotificationConfigurationDetail]
  -> f (Maybe [AwsS3BucketNotificationConfigurationDetail]))
 -> AwsS3BucketNotificationConfiguration
 -> f AwsS3BucketNotificationConfiguration)
-> ((Maybe [AwsS3BucketNotificationConfigurationDetail]
     -> f (Maybe [AwsS3BucketNotificationConfigurationDetail]))
    -> Maybe [AwsS3BucketNotificationConfigurationDetail]
    -> f (Maybe [AwsS3BucketNotificationConfigurationDetail]))
-> (Maybe [AwsS3BucketNotificationConfigurationDetail]
    -> f (Maybe [AwsS3BucketNotificationConfigurationDetail]))
-> AwsS3BucketNotificationConfiguration
-> f AwsS3BucketNotificationConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AwsS3BucketNotificationConfigurationDetail]
  [AwsS3BucketNotificationConfigurationDetail]
  [AwsS3BucketNotificationConfigurationDetail]
  [AwsS3BucketNotificationConfigurationDetail]
-> Iso
     (Maybe [AwsS3BucketNotificationConfigurationDetail])
     (Maybe [AwsS3BucketNotificationConfigurationDetail])
     (Maybe [AwsS3BucketNotificationConfigurationDetail])
     (Maybe [AwsS3BucketNotificationConfigurationDetail])
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
  [AwsS3BucketNotificationConfigurationDetail]
  [AwsS3BucketNotificationConfigurationDetail]
  [AwsS3BucketNotificationConfigurationDetail]
  [AwsS3BucketNotificationConfigurationDetail]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.Hashable
    AwsS3BucketNotificationConfiguration

instance
  Prelude.NFData
    AwsS3BucketNotificationConfiguration

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