{-# 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.MacieV2.Types.SecurityHubConfiguration
-- 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.MacieV2.Types.SecurityHubConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies configuration settings that determine which findings are
-- published to Security Hub automatically. For information about how Macie
-- publishes findings to Security Hub, see
-- <https://docs.aws.amazon.com/macie/latest/user/securityhub-integration.html Amazon Macie integration with Security Hub>
-- in the /Amazon Macie User Guide/.
--
-- /See:/ 'newSecurityHubConfiguration' smart constructor.
data SecurityHubConfiguration = SecurityHubConfiguration'
  { -- | Specifies whether to publish policy findings to Security Hub. If you set
    -- this value to true, Amazon Macie automatically publishes all new and
    -- updated policy findings that weren\'t suppressed by a findings filter.
    -- The default value is true.
    SecurityHubConfiguration -> Bool
publishPolicyFindings :: Prelude.Bool,
    -- | Specifies whether to publish sensitive data findings to Security Hub. If
    -- you set this value to true, Amazon Macie automatically publishes all
    -- sensitive data findings that weren\'t suppressed by a findings filter.
    -- The default value is false.
    SecurityHubConfiguration -> Bool
publishClassificationFindings :: Prelude.Bool
  }
  deriving (SecurityHubConfiguration -> SecurityHubConfiguration -> Bool
(SecurityHubConfiguration -> SecurityHubConfiguration -> Bool)
-> (SecurityHubConfiguration -> SecurityHubConfiguration -> Bool)
-> Eq SecurityHubConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SecurityHubConfiguration -> SecurityHubConfiguration -> Bool
$c/= :: SecurityHubConfiguration -> SecurityHubConfiguration -> Bool
== :: SecurityHubConfiguration -> SecurityHubConfiguration -> Bool
$c== :: SecurityHubConfiguration -> SecurityHubConfiguration -> Bool
Prelude.Eq, ReadPrec [SecurityHubConfiguration]
ReadPrec SecurityHubConfiguration
Int -> ReadS SecurityHubConfiguration
ReadS [SecurityHubConfiguration]
(Int -> ReadS SecurityHubConfiguration)
-> ReadS [SecurityHubConfiguration]
-> ReadPrec SecurityHubConfiguration
-> ReadPrec [SecurityHubConfiguration]
-> Read SecurityHubConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SecurityHubConfiguration]
$creadListPrec :: ReadPrec [SecurityHubConfiguration]
readPrec :: ReadPrec SecurityHubConfiguration
$creadPrec :: ReadPrec SecurityHubConfiguration
readList :: ReadS [SecurityHubConfiguration]
$creadList :: ReadS [SecurityHubConfiguration]
readsPrec :: Int -> ReadS SecurityHubConfiguration
$creadsPrec :: Int -> ReadS SecurityHubConfiguration
Prelude.Read, Int -> SecurityHubConfiguration -> ShowS
[SecurityHubConfiguration] -> ShowS
SecurityHubConfiguration -> String
(Int -> SecurityHubConfiguration -> ShowS)
-> (SecurityHubConfiguration -> String)
-> ([SecurityHubConfiguration] -> ShowS)
-> Show SecurityHubConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SecurityHubConfiguration] -> ShowS
$cshowList :: [SecurityHubConfiguration] -> ShowS
show :: SecurityHubConfiguration -> String
$cshow :: SecurityHubConfiguration -> String
showsPrec :: Int -> SecurityHubConfiguration -> ShowS
$cshowsPrec :: Int -> SecurityHubConfiguration -> ShowS
Prelude.Show, (forall x.
 SecurityHubConfiguration -> Rep SecurityHubConfiguration x)
-> (forall x.
    Rep SecurityHubConfiguration x -> SecurityHubConfiguration)
-> Generic SecurityHubConfiguration
forall x.
Rep SecurityHubConfiguration x -> SecurityHubConfiguration
forall x.
SecurityHubConfiguration -> Rep SecurityHubConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SecurityHubConfiguration x -> SecurityHubConfiguration
$cfrom :: forall x.
SecurityHubConfiguration -> Rep SecurityHubConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SecurityHubConfiguration' 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:
--
-- 'publishPolicyFindings', 'securityHubConfiguration_publishPolicyFindings' - Specifies whether to publish policy findings to Security Hub. If you set
-- this value to true, Amazon Macie automatically publishes all new and
-- updated policy findings that weren\'t suppressed by a findings filter.
-- The default value is true.
--
-- 'publishClassificationFindings', 'securityHubConfiguration_publishClassificationFindings' - Specifies whether to publish sensitive data findings to Security Hub. If
-- you set this value to true, Amazon Macie automatically publishes all
-- sensitive data findings that weren\'t suppressed by a findings filter.
-- The default value is false.
newSecurityHubConfiguration ::
  -- | 'publishPolicyFindings'
  Prelude.Bool ->
  -- | 'publishClassificationFindings'
  Prelude.Bool ->
  SecurityHubConfiguration
newSecurityHubConfiguration :: Bool -> Bool -> SecurityHubConfiguration
newSecurityHubConfiguration
  Bool
pPublishPolicyFindings_
  Bool
pPublishClassificationFindings_ =
    SecurityHubConfiguration' :: Bool -> Bool -> SecurityHubConfiguration
SecurityHubConfiguration'
      { $sel:publishPolicyFindings:SecurityHubConfiguration' :: Bool
publishPolicyFindings =
          Bool
pPublishPolicyFindings_,
        $sel:publishClassificationFindings:SecurityHubConfiguration' :: Bool
publishClassificationFindings =
          Bool
pPublishClassificationFindings_
      }

-- | Specifies whether to publish policy findings to Security Hub. If you set
-- this value to true, Amazon Macie automatically publishes all new and
-- updated policy findings that weren\'t suppressed by a findings filter.
-- The default value is true.
securityHubConfiguration_publishPolicyFindings :: Lens.Lens' SecurityHubConfiguration Prelude.Bool
securityHubConfiguration_publishPolicyFindings :: (Bool -> f Bool)
-> SecurityHubConfiguration -> f SecurityHubConfiguration
securityHubConfiguration_publishPolicyFindings = (SecurityHubConfiguration -> Bool)
-> (SecurityHubConfiguration -> Bool -> SecurityHubConfiguration)
-> Lens SecurityHubConfiguration SecurityHubConfiguration Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecurityHubConfiguration' {Bool
publishPolicyFindings :: Bool
$sel:publishPolicyFindings:SecurityHubConfiguration' :: SecurityHubConfiguration -> Bool
publishPolicyFindings} -> Bool
publishPolicyFindings) (\s :: SecurityHubConfiguration
s@SecurityHubConfiguration' {} Bool
a -> SecurityHubConfiguration
s {$sel:publishPolicyFindings:SecurityHubConfiguration' :: Bool
publishPolicyFindings = Bool
a} :: SecurityHubConfiguration)

-- | Specifies whether to publish sensitive data findings to Security Hub. If
-- you set this value to true, Amazon Macie automatically publishes all
-- sensitive data findings that weren\'t suppressed by a findings filter.
-- The default value is false.
securityHubConfiguration_publishClassificationFindings :: Lens.Lens' SecurityHubConfiguration Prelude.Bool
securityHubConfiguration_publishClassificationFindings :: (Bool -> f Bool)
-> SecurityHubConfiguration -> f SecurityHubConfiguration
securityHubConfiguration_publishClassificationFindings = (SecurityHubConfiguration -> Bool)
-> (SecurityHubConfiguration -> Bool -> SecurityHubConfiguration)
-> Lens SecurityHubConfiguration SecurityHubConfiguration Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecurityHubConfiguration' {Bool
publishClassificationFindings :: Bool
$sel:publishClassificationFindings:SecurityHubConfiguration' :: SecurityHubConfiguration -> Bool
publishClassificationFindings} -> Bool
publishClassificationFindings) (\s :: SecurityHubConfiguration
s@SecurityHubConfiguration' {} Bool
a -> SecurityHubConfiguration
s {$sel:publishClassificationFindings:SecurityHubConfiguration' :: Bool
publishClassificationFindings = Bool
a} :: SecurityHubConfiguration)

instance Core.FromJSON SecurityHubConfiguration where
  parseJSON :: Value -> Parser SecurityHubConfiguration
parseJSON =
    String
-> (Object -> Parser SecurityHubConfiguration)
-> Value
-> Parser SecurityHubConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SecurityHubConfiguration"
      ( \Object
x ->
          Bool -> Bool -> SecurityHubConfiguration
SecurityHubConfiguration'
            (Bool -> Bool -> SecurityHubConfiguration)
-> Parser Bool -> Parser (Bool -> SecurityHubConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"publishPolicyFindings")
            Parser (Bool -> SecurityHubConfiguration)
-> Parser Bool -> Parser SecurityHubConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"publishClassificationFindings")
      )

instance Prelude.Hashable SecurityHubConfiguration

instance Prelude.NFData SecurityHubConfiguration

instance Core.ToJSON SecurityHubConfiguration where
  toJSON :: SecurityHubConfiguration -> Value
toJSON SecurityHubConfiguration' {Bool
publishClassificationFindings :: Bool
publishPolicyFindings :: Bool
$sel:publishClassificationFindings:SecurityHubConfiguration' :: SecurityHubConfiguration -> Bool
$sel:publishPolicyFindings:SecurityHubConfiguration' :: SecurityHubConfiguration -> Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"publishPolicyFindings"
                  Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
publishPolicyFindings
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"publishClassificationFindings"
                  Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
publishClassificationFindings
              )
          ]
      )