{-# 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.AuditManager.Types.Settings
-- 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.AuditManager.Types.Settings where

import Amazonka.AuditManager.Types.AssessmentReportsDestination
import Amazonka.AuditManager.Types.Role
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The settings object that holds all supported Audit Manager settings.
--
-- /See:/ 'newSettings' smart constructor.
data Settings = Settings'
  { -- | The KMS key details.
    Settings -> Maybe Text
kmsKey :: Prelude.Maybe Prelude.Text,
    -- | The default storage destination for assessment reports.
    Settings -> Maybe AssessmentReportsDestination
defaultAssessmentReportsDestination :: Prelude.Maybe AssessmentReportsDestination,
    -- | The designated Amazon Simple Notification Service (Amazon SNS) topic.
    Settings -> Maybe Text
snsTopic :: Prelude.Maybe Prelude.Text,
    -- | The designated default audit owners.
    Settings -> Maybe [Role]
defaultProcessOwners :: Prelude.Maybe [Role],
    -- | Specifies whether Organizations is enabled.
    Settings -> Maybe Bool
isAwsOrgEnabled :: Prelude.Maybe Prelude.Bool
  }
  deriving (Settings -> Settings -> Bool
(Settings -> Settings -> Bool)
-> (Settings -> Settings -> Bool) -> Eq Settings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Settings -> Settings -> Bool
$c/= :: Settings -> Settings -> Bool
== :: Settings -> Settings -> Bool
$c== :: Settings -> Settings -> Bool
Prelude.Eq, ReadPrec [Settings]
ReadPrec Settings
Int -> ReadS Settings
ReadS [Settings]
(Int -> ReadS Settings)
-> ReadS [Settings]
-> ReadPrec Settings
-> ReadPrec [Settings]
-> Read Settings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Settings]
$creadListPrec :: ReadPrec [Settings]
readPrec :: ReadPrec Settings
$creadPrec :: ReadPrec Settings
readList :: ReadS [Settings]
$creadList :: ReadS [Settings]
readsPrec :: Int -> ReadS Settings
$creadsPrec :: Int -> ReadS Settings
Prelude.Read, Int -> Settings -> ShowS
[Settings] -> ShowS
Settings -> String
(Int -> Settings -> ShowS)
-> (Settings -> String) -> ([Settings] -> ShowS) -> Show Settings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Settings] -> ShowS
$cshowList :: [Settings] -> ShowS
show :: Settings -> String
$cshow :: Settings -> String
showsPrec :: Int -> Settings -> ShowS
$cshowsPrec :: Int -> Settings -> ShowS
Prelude.Show, (forall x. Settings -> Rep Settings x)
-> (forall x. Rep Settings x -> Settings) -> Generic Settings
forall x. Rep Settings x -> Settings
forall x. Settings -> Rep Settings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Settings x -> Settings
$cfrom :: forall x. Settings -> Rep Settings x
Prelude.Generic)

-- |
-- Create a value of 'Settings' 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:
--
-- 'kmsKey', 'settings_kmsKey' - The KMS key details.
--
-- 'defaultAssessmentReportsDestination', 'settings_defaultAssessmentReportsDestination' - The default storage destination for assessment reports.
--
-- 'snsTopic', 'settings_snsTopic' - The designated Amazon Simple Notification Service (Amazon SNS) topic.
--
-- 'defaultProcessOwners', 'settings_defaultProcessOwners' - The designated default audit owners.
--
-- 'isAwsOrgEnabled', 'settings_isAwsOrgEnabled' - Specifies whether Organizations is enabled.
newSettings ::
  Settings
newSettings :: Settings
newSettings =
  Settings' :: Maybe Text
-> Maybe AssessmentReportsDestination
-> Maybe Text
-> Maybe [Role]
-> Maybe Bool
-> Settings
Settings'
    { $sel:kmsKey:Settings' :: Maybe Text
kmsKey = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultAssessmentReportsDestination:Settings' :: Maybe AssessmentReportsDestination
defaultAssessmentReportsDestination =
        Maybe AssessmentReportsDestination
forall a. Maybe a
Prelude.Nothing,
      $sel:snsTopic:Settings' :: Maybe Text
snsTopic = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultProcessOwners:Settings' :: Maybe [Role]
defaultProcessOwners = Maybe [Role]
forall a. Maybe a
Prelude.Nothing,
      $sel:isAwsOrgEnabled:Settings' :: Maybe Bool
isAwsOrgEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The KMS key details.
settings_kmsKey :: Lens.Lens' Settings (Prelude.Maybe Prelude.Text)
settings_kmsKey :: (Maybe Text -> f (Maybe Text)) -> Settings -> f Settings
settings_kmsKey = (Settings -> Maybe Text)
-> (Settings -> Maybe Text -> Settings)
-> Lens Settings Settings (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Settings' {Maybe Text
kmsKey :: Maybe Text
$sel:kmsKey:Settings' :: Settings -> Maybe Text
kmsKey} -> Maybe Text
kmsKey) (\s :: Settings
s@Settings' {} Maybe Text
a -> Settings
s {$sel:kmsKey:Settings' :: Maybe Text
kmsKey = Maybe Text
a} :: Settings)

-- | The default storage destination for assessment reports.
settings_defaultAssessmentReportsDestination :: Lens.Lens' Settings (Prelude.Maybe AssessmentReportsDestination)
settings_defaultAssessmentReportsDestination :: (Maybe AssessmentReportsDestination
 -> f (Maybe AssessmentReportsDestination))
-> Settings -> f Settings
settings_defaultAssessmentReportsDestination = (Settings -> Maybe AssessmentReportsDestination)
-> (Settings -> Maybe AssessmentReportsDestination -> Settings)
-> Lens
     Settings
     Settings
     (Maybe AssessmentReportsDestination)
     (Maybe AssessmentReportsDestination)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Settings' {Maybe AssessmentReportsDestination
defaultAssessmentReportsDestination :: Maybe AssessmentReportsDestination
$sel:defaultAssessmentReportsDestination:Settings' :: Settings -> Maybe AssessmentReportsDestination
defaultAssessmentReportsDestination} -> Maybe AssessmentReportsDestination
defaultAssessmentReportsDestination) (\s :: Settings
s@Settings' {} Maybe AssessmentReportsDestination
a -> Settings
s {$sel:defaultAssessmentReportsDestination:Settings' :: Maybe AssessmentReportsDestination
defaultAssessmentReportsDestination = Maybe AssessmentReportsDestination
a} :: Settings)

-- | The designated Amazon Simple Notification Service (Amazon SNS) topic.
settings_snsTopic :: Lens.Lens' Settings (Prelude.Maybe Prelude.Text)
settings_snsTopic :: (Maybe Text -> f (Maybe Text)) -> Settings -> f Settings
settings_snsTopic = (Settings -> Maybe Text)
-> (Settings -> Maybe Text -> Settings)
-> Lens Settings Settings (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Settings' {Maybe Text
snsTopic :: Maybe Text
$sel:snsTopic:Settings' :: Settings -> Maybe Text
snsTopic} -> Maybe Text
snsTopic) (\s :: Settings
s@Settings' {} Maybe Text
a -> Settings
s {$sel:snsTopic:Settings' :: Maybe Text
snsTopic = Maybe Text
a} :: Settings)

-- | The designated default audit owners.
settings_defaultProcessOwners :: Lens.Lens' Settings (Prelude.Maybe [Role])
settings_defaultProcessOwners :: (Maybe [Role] -> f (Maybe [Role])) -> Settings -> f Settings
settings_defaultProcessOwners = (Settings -> Maybe [Role])
-> (Settings -> Maybe [Role] -> Settings)
-> Lens Settings Settings (Maybe [Role]) (Maybe [Role])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Settings' {Maybe [Role]
defaultProcessOwners :: Maybe [Role]
$sel:defaultProcessOwners:Settings' :: Settings -> Maybe [Role]
defaultProcessOwners} -> Maybe [Role]
defaultProcessOwners) (\s :: Settings
s@Settings' {} Maybe [Role]
a -> Settings
s {$sel:defaultProcessOwners:Settings' :: Maybe [Role]
defaultProcessOwners = Maybe [Role]
a} :: Settings) ((Maybe [Role] -> f (Maybe [Role])) -> Settings -> f Settings)
-> ((Maybe [Role] -> f (Maybe [Role]))
    -> Maybe [Role] -> f (Maybe [Role]))
-> (Maybe [Role] -> f (Maybe [Role]))
-> Settings
-> f Settings
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Role] [Role] [Role] [Role]
-> Iso (Maybe [Role]) (Maybe [Role]) (Maybe [Role]) (Maybe [Role])
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 [Role] [Role] [Role] [Role]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Specifies whether Organizations is enabled.
settings_isAwsOrgEnabled :: Lens.Lens' Settings (Prelude.Maybe Prelude.Bool)
settings_isAwsOrgEnabled :: (Maybe Bool -> f (Maybe Bool)) -> Settings -> f Settings
settings_isAwsOrgEnabled = (Settings -> Maybe Bool)
-> (Settings -> Maybe Bool -> Settings)
-> Lens Settings Settings (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Settings' {Maybe Bool
isAwsOrgEnabled :: Maybe Bool
$sel:isAwsOrgEnabled:Settings' :: Settings -> Maybe Bool
isAwsOrgEnabled} -> Maybe Bool
isAwsOrgEnabled) (\s :: Settings
s@Settings' {} Maybe Bool
a -> Settings
s {$sel:isAwsOrgEnabled:Settings' :: Maybe Bool
isAwsOrgEnabled = Maybe Bool
a} :: Settings)

instance Core.FromJSON Settings where
  parseJSON :: Value -> Parser Settings
parseJSON =
    String -> (Object -> Parser Settings) -> Value -> Parser Settings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Settings"
      ( \Object
x ->
          Maybe Text
-> Maybe AssessmentReportsDestination
-> Maybe Text
-> Maybe [Role]
-> Maybe Bool
-> Settings
Settings'
            (Maybe Text
 -> Maybe AssessmentReportsDestination
 -> Maybe Text
 -> Maybe [Role]
 -> Maybe Bool
 -> Settings)
-> Parser (Maybe Text)
-> Parser
     (Maybe AssessmentReportsDestination
      -> Maybe Text -> Maybe [Role] -> Maybe Bool -> Settings)
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
"kmsKey")
            Parser
  (Maybe AssessmentReportsDestination
   -> Maybe Text -> Maybe [Role] -> Maybe Bool -> Settings)
-> Parser (Maybe AssessmentReportsDestination)
-> Parser (Maybe Text -> Maybe [Role] -> Maybe Bool -> Settings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AssessmentReportsDestination)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"defaultAssessmentReportsDestination")
            Parser (Maybe Text -> Maybe [Role] -> Maybe Bool -> Settings)
-> Parser (Maybe Text)
-> Parser (Maybe [Role] -> Maybe Bool -> Settings)
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
"snsTopic")
            Parser (Maybe [Role] -> Maybe Bool -> Settings)
-> Parser (Maybe [Role]) -> Parser (Maybe Bool -> Settings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Role]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"defaultProcessOwners"
                            Parser (Maybe (Maybe [Role]))
-> Maybe [Role] -> Parser (Maybe [Role])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Role]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe Bool -> Settings)
-> Parser (Maybe Bool) -> Parser Settings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"isAwsOrgEnabled")
      )

instance Prelude.Hashable Settings

instance Prelude.NFData Settings