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

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

-- | Details for an S3 bucket notification configuration.
--
-- /See:/ 'newAwsS3BucketNotificationConfigurationDetail' smart constructor.
data AwsS3BucketNotificationConfigurationDetail = AwsS3BucketNotificationConfigurationDetail'
  { -- | The ARN of the Lambda function, Amazon SQS queue, or Amazon SNS topic
    -- that generates the notification.
    AwsS3BucketNotificationConfigurationDetail -> Maybe Text
destination :: Prelude.Maybe Prelude.Text,
    -- | The list of events that trigger a notification.
    AwsS3BucketNotificationConfigurationDetail -> Maybe [Text]
events :: Prelude.Maybe [Prelude.Text],
    -- | Indicates the type of notification. Notifications can be generated using
    -- Lambda functions, Amazon SQS queues or Amazon SNS topics.
    AwsS3BucketNotificationConfigurationDetail -> Maybe Text
type' :: Prelude.Maybe Prelude.Text,
    -- | The filters that determine which S3 buckets generate notifications.
    AwsS3BucketNotificationConfigurationDetail
-> Maybe AwsS3BucketNotificationConfigurationFilter
filter' :: Prelude.Maybe AwsS3BucketNotificationConfigurationFilter
  }
  deriving (AwsS3BucketNotificationConfigurationDetail
-> AwsS3BucketNotificationConfigurationDetail -> Bool
(AwsS3BucketNotificationConfigurationDetail
 -> AwsS3BucketNotificationConfigurationDetail -> Bool)
-> (AwsS3BucketNotificationConfigurationDetail
    -> AwsS3BucketNotificationConfigurationDetail -> Bool)
-> Eq AwsS3BucketNotificationConfigurationDetail
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsS3BucketNotificationConfigurationDetail
-> AwsS3BucketNotificationConfigurationDetail -> Bool
$c/= :: AwsS3BucketNotificationConfigurationDetail
-> AwsS3BucketNotificationConfigurationDetail -> Bool
== :: AwsS3BucketNotificationConfigurationDetail
-> AwsS3BucketNotificationConfigurationDetail -> Bool
$c== :: AwsS3BucketNotificationConfigurationDetail
-> AwsS3BucketNotificationConfigurationDetail -> Bool
Prelude.Eq, ReadPrec [AwsS3BucketNotificationConfigurationDetail]
ReadPrec AwsS3BucketNotificationConfigurationDetail
Int -> ReadS AwsS3BucketNotificationConfigurationDetail
ReadS [AwsS3BucketNotificationConfigurationDetail]
(Int -> ReadS AwsS3BucketNotificationConfigurationDetail)
-> ReadS [AwsS3BucketNotificationConfigurationDetail]
-> ReadPrec AwsS3BucketNotificationConfigurationDetail
-> ReadPrec [AwsS3BucketNotificationConfigurationDetail]
-> Read AwsS3BucketNotificationConfigurationDetail
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsS3BucketNotificationConfigurationDetail]
$creadListPrec :: ReadPrec [AwsS3BucketNotificationConfigurationDetail]
readPrec :: ReadPrec AwsS3BucketNotificationConfigurationDetail
$creadPrec :: ReadPrec AwsS3BucketNotificationConfigurationDetail
readList :: ReadS [AwsS3BucketNotificationConfigurationDetail]
$creadList :: ReadS [AwsS3BucketNotificationConfigurationDetail]
readsPrec :: Int -> ReadS AwsS3BucketNotificationConfigurationDetail
$creadsPrec :: Int -> ReadS AwsS3BucketNotificationConfigurationDetail
Prelude.Read, Int -> AwsS3BucketNotificationConfigurationDetail -> ShowS
[AwsS3BucketNotificationConfigurationDetail] -> ShowS
AwsS3BucketNotificationConfigurationDetail -> String
(Int -> AwsS3BucketNotificationConfigurationDetail -> ShowS)
-> (AwsS3BucketNotificationConfigurationDetail -> String)
-> ([AwsS3BucketNotificationConfigurationDetail] -> ShowS)
-> Show AwsS3BucketNotificationConfigurationDetail
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsS3BucketNotificationConfigurationDetail] -> ShowS
$cshowList :: [AwsS3BucketNotificationConfigurationDetail] -> ShowS
show :: AwsS3BucketNotificationConfigurationDetail -> String
$cshow :: AwsS3BucketNotificationConfigurationDetail -> String
showsPrec :: Int -> AwsS3BucketNotificationConfigurationDetail -> ShowS
$cshowsPrec :: Int -> AwsS3BucketNotificationConfigurationDetail -> ShowS
Prelude.Show, (forall x.
 AwsS3BucketNotificationConfigurationDetail
 -> Rep AwsS3BucketNotificationConfigurationDetail x)
-> (forall x.
    Rep AwsS3BucketNotificationConfigurationDetail x
    -> AwsS3BucketNotificationConfigurationDetail)
-> Generic AwsS3BucketNotificationConfigurationDetail
forall x.
Rep AwsS3BucketNotificationConfigurationDetail x
-> AwsS3BucketNotificationConfigurationDetail
forall x.
AwsS3BucketNotificationConfigurationDetail
-> Rep AwsS3BucketNotificationConfigurationDetail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsS3BucketNotificationConfigurationDetail x
-> AwsS3BucketNotificationConfigurationDetail
$cfrom :: forall x.
AwsS3BucketNotificationConfigurationDetail
-> Rep AwsS3BucketNotificationConfigurationDetail x
Prelude.Generic)

-- |
-- Create a value of 'AwsS3BucketNotificationConfigurationDetail' 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:
--
-- 'destination', 'awsS3BucketNotificationConfigurationDetail_destination' - The ARN of the Lambda function, Amazon SQS queue, or Amazon SNS topic
-- that generates the notification.
--
-- 'events', 'awsS3BucketNotificationConfigurationDetail_events' - The list of events that trigger a notification.
--
-- 'type'', 'awsS3BucketNotificationConfigurationDetail_type' - Indicates the type of notification. Notifications can be generated using
-- Lambda functions, Amazon SQS queues or Amazon SNS topics.
--
-- 'filter'', 'awsS3BucketNotificationConfigurationDetail_filter' - The filters that determine which S3 buckets generate notifications.
newAwsS3BucketNotificationConfigurationDetail ::
  AwsS3BucketNotificationConfigurationDetail
newAwsS3BucketNotificationConfigurationDetail :: AwsS3BucketNotificationConfigurationDetail
newAwsS3BucketNotificationConfigurationDetail =
  AwsS3BucketNotificationConfigurationDetail' :: Maybe Text
-> Maybe [Text]
-> Maybe Text
-> Maybe AwsS3BucketNotificationConfigurationFilter
-> AwsS3BucketNotificationConfigurationDetail
AwsS3BucketNotificationConfigurationDetail'
    { $sel:destination:AwsS3BucketNotificationConfigurationDetail' :: Maybe Text
destination =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:events:AwsS3BucketNotificationConfigurationDetail' :: Maybe [Text]
events = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:type':AwsS3BucketNotificationConfigurationDetail' :: Maybe Text
type' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:filter':AwsS3BucketNotificationConfigurationDetail' :: Maybe AwsS3BucketNotificationConfigurationFilter
filter' = Maybe AwsS3BucketNotificationConfigurationFilter
forall a. Maybe a
Prelude.Nothing
    }

-- | The ARN of the Lambda function, Amazon SQS queue, or Amazon SNS topic
-- that generates the notification.
awsS3BucketNotificationConfigurationDetail_destination :: Lens.Lens' AwsS3BucketNotificationConfigurationDetail (Prelude.Maybe Prelude.Text)
awsS3BucketNotificationConfigurationDetail_destination :: (Maybe Text -> f (Maybe Text))
-> AwsS3BucketNotificationConfigurationDetail
-> f AwsS3BucketNotificationConfigurationDetail
awsS3BucketNotificationConfigurationDetail_destination = (AwsS3BucketNotificationConfigurationDetail -> Maybe Text)
-> (AwsS3BucketNotificationConfigurationDetail
    -> Maybe Text -> AwsS3BucketNotificationConfigurationDetail)
-> Lens
     AwsS3BucketNotificationConfigurationDetail
     AwsS3BucketNotificationConfigurationDetail
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsS3BucketNotificationConfigurationDetail' {Maybe Text
destination :: Maybe Text
$sel:destination:AwsS3BucketNotificationConfigurationDetail' :: AwsS3BucketNotificationConfigurationDetail -> Maybe Text
destination} -> Maybe Text
destination) (\s :: AwsS3BucketNotificationConfigurationDetail
s@AwsS3BucketNotificationConfigurationDetail' {} Maybe Text
a -> AwsS3BucketNotificationConfigurationDetail
s {$sel:destination:AwsS3BucketNotificationConfigurationDetail' :: Maybe Text
destination = Maybe Text
a} :: AwsS3BucketNotificationConfigurationDetail)

-- | The list of events that trigger a notification.
awsS3BucketNotificationConfigurationDetail_events :: Lens.Lens' AwsS3BucketNotificationConfigurationDetail (Prelude.Maybe [Prelude.Text])
awsS3BucketNotificationConfigurationDetail_events :: (Maybe [Text] -> f (Maybe [Text]))
-> AwsS3BucketNotificationConfigurationDetail
-> f AwsS3BucketNotificationConfigurationDetail
awsS3BucketNotificationConfigurationDetail_events = (AwsS3BucketNotificationConfigurationDetail -> Maybe [Text])
-> (AwsS3BucketNotificationConfigurationDetail
    -> Maybe [Text] -> AwsS3BucketNotificationConfigurationDetail)
-> Lens
     AwsS3BucketNotificationConfigurationDetail
     AwsS3BucketNotificationConfigurationDetail
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsS3BucketNotificationConfigurationDetail' {Maybe [Text]
events :: Maybe [Text]
$sel:events:AwsS3BucketNotificationConfigurationDetail' :: AwsS3BucketNotificationConfigurationDetail -> Maybe [Text]
events} -> Maybe [Text]
events) (\s :: AwsS3BucketNotificationConfigurationDetail
s@AwsS3BucketNotificationConfigurationDetail' {} Maybe [Text]
a -> AwsS3BucketNotificationConfigurationDetail
s {$sel:events:AwsS3BucketNotificationConfigurationDetail' :: Maybe [Text]
events = Maybe [Text]
a} :: AwsS3BucketNotificationConfigurationDetail) ((Maybe [Text] -> f (Maybe [Text]))
 -> AwsS3BucketNotificationConfigurationDetail
 -> f AwsS3BucketNotificationConfigurationDetail)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> AwsS3BucketNotificationConfigurationDetail
-> f AwsS3BucketNotificationConfigurationDetail
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Indicates the type of notification. Notifications can be generated using
-- Lambda functions, Amazon SQS queues or Amazon SNS topics.
awsS3BucketNotificationConfigurationDetail_type :: Lens.Lens' AwsS3BucketNotificationConfigurationDetail (Prelude.Maybe Prelude.Text)
awsS3BucketNotificationConfigurationDetail_type :: (Maybe Text -> f (Maybe Text))
-> AwsS3BucketNotificationConfigurationDetail
-> f AwsS3BucketNotificationConfigurationDetail
awsS3BucketNotificationConfigurationDetail_type = (AwsS3BucketNotificationConfigurationDetail -> Maybe Text)
-> (AwsS3BucketNotificationConfigurationDetail
    -> Maybe Text -> AwsS3BucketNotificationConfigurationDetail)
-> Lens
     AwsS3BucketNotificationConfigurationDetail
     AwsS3BucketNotificationConfigurationDetail
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsS3BucketNotificationConfigurationDetail' {Maybe Text
type' :: Maybe Text
$sel:type':AwsS3BucketNotificationConfigurationDetail' :: AwsS3BucketNotificationConfigurationDetail -> Maybe Text
type'} -> Maybe Text
type') (\s :: AwsS3BucketNotificationConfigurationDetail
s@AwsS3BucketNotificationConfigurationDetail' {} Maybe Text
a -> AwsS3BucketNotificationConfigurationDetail
s {$sel:type':AwsS3BucketNotificationConfigurationDetail' :: Maybe Text
type' = Maybe Text
a} :: AwsS3BucketNotificationConfigurationDetail)

-- | The filters that determine which S3 buckets generate notifications.
awsS3BucketNotificationConfigurationDetail_filter :: Lens.Lens' AwsS3BucketNotificationConfigurationDetail (Prelude.Maybe AwsS3BucketNotificationConfigurationFilter)
awsS3BucketNotificationConfigurationDetail_filter :: (Maybe AwsS3BucketNotificationConfigurationFilter
 -> f (Maybe AwsS3BucketNotificationConfigurationFilter))
-> AwsS3BucketNotificationConfigurationDetail
-> f AwsS3BucketNotificationConfigurationDetail
awsS3BucketNotificationConfigurationDetail_filter = (AwsS3BucketNotificationConfigurationDetail
 -> Maybe AwsS3BucketNotificationConfigurationFilter)
-> (AwsS3BucketNotificationConfigurationDetail
    -> Maybe AwsS3BucketNotificationConfigurationFilter
    -> AwsS3BucketNotificationConfigurationDetail)
-> Lens
     AwsS3BucketNotificationConfigurationDetail
     AwsS3BucketNotificationConfigurationDetail
     (Maybe AwsS3BucketNotificationConfigurationFilter)
     (Maybe AwsS3BucketNotificationConfigurationFilter)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsS3BucketNotificationConfigurationDetail' {Maybe AwsS3BucketNotificationConfigurationFilter
filter' :: Maybe AwsS3BucketNotificationConfigurationFilter
$sel:filter':AwsS3BucketNotificationConfigurationDetail' :: AwsS3BucketNotificationConfigurationDetail
-> Maybe AwsS3BucketNotificationConfigurationFilter
filter'} -> Maybe AwsS3BucketNotificationConfigurationFilter
filter') (\s :: AwsS3BucketNotificationConfigurationDetail
s@AwsS3BucketNotificationConfigurationDetail' {} Maybe AwsS3BucketNotificationConfigurationFilter
a -> AwsS3BucketNotificationConfigurationDetail
s {$sel:filter':AwsS3BucketNotificationConfigurationDetail' :: Maybe AwsS3BucketNotificationConfigurationFilter
filter' = Maybe AwsS3BucketNotificationConfigurationFilter
a} :: AwsS3BucketNotificationConfigurationDetail)

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

instance
  Prelude.Hashable
    AwsS3BucketNotificationConfigurationDetail

instance
  Prelude.NFData
    AwsS3BucketNotificationConfigurationDetail

instance
  Core.ToJSON
    AwsS3BucketNotificationConfigurationDetail
  where
  toJSON :: AwsS3BucketNotificationConfigurationDetail -> Value
toJSON
    AwsS3BucketNotificationConfigurationDetail' {Maybe [Text]
Maybe Text
Maybe AwsS3BucketNotificationConfigurationFilter
filter' :: Maybe AwsS3BucketNotificationConfigurationFilter
type' :: Maybe Text
events :: Maybe [Text]
destination :: Maybe Text
$sel:filter':AwsS3BucketNotificationConfigurationDetail' :: AwsS3BucketNotificationConfigurationDetail
-> Maybe AwsS3BucketNotificationConfigurationFilter
$sel:type':AwsS3BucketNotificationConfigurationDetail' :: AwsS3BucketNotificationConfigurationDetail -> Maybe Text
$sel:events:AwsS3BucketNotificationConfigurationDetail' :: AwsS3BucketNotificationConfigurationDetail -> Maybe [Text]
$sel:destination:AwsS3BucketNotificationConfigurationDetail' :: AwsS3BucketNotificationConfigurationDetail -> Maybe Text
..} =
      [Pair] -> Value
Core.object
        ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
            [ (Text
"Destination" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
destination,
              (Text
"Events" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
events,
              (Text
"Type" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
type',
              (Text
"Filter" Text -> AwsS3BucketNotificationConfigurationFilter -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (AwsS3BucketNotificationConfigurationFilter -> Pair)
-> Maybe AwsS3BucketNotificationConfigurationFilter -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AwsS3BucketNotificationConfigurationFilter
filter'
            ]
        )