{-# 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.SecurityLake.Types.AutoEnableNewRegionConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SecurityLake.Types.AutoEnableNewRegionConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityLake.Types.AwsLogSourceType
import Amazonka.SecurityLake.Types.Region

-- | Automatically enable new organization accounts as member accounts from
-- an Amazon Security Lake administrator account.
--
-- /See:/ 'newAutoEnableNewRegionConfiguration' smart constructor.
data AutoEnableNewRegionConfiguration = AutoEnableNewRegionConfiguration'
  { -- | The Amazon Web Services Regions where Security Lake is automatically
    -- enabled.
    AutoEnableNewRegionConfiguration -> Region
region :: Region,
    -- | The Amazon Web Services sources that are automatically enabled in
    -- Security Lake.
    AutoEnableNewRegionConfiguration -> [AwsLogSourceType]
sources :: [AwsLogSourceType]
  }
  deriving (AutoEnableNewRegionConfiguration
-> AutoEnableNewRegionConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutoEnableNewRegionConfiguration
-> AutoEnableNewRegionConfiguration -> Bool
$c/= :: AutoEnableNewRegionConfiguration
-> AutoEnableNewRegionConfiguration -> Bool
== :: AutoEnableNewRegionConfiguration
-> AutoEnableNewRegionConfiguration -> Bool
$c== :: AutoEnableNewRegionConfiguration
-> AutoEnableNewRegionConfiguration -> Bool
Prelude.Eq, ReadPrec [AutoEnableNewRegionConfiguration]
ReadPrec AutoEnableNewRegionConfiguration
Int -> ReadS AutoEnableNewRegionConfiguration
ReadS [AutoEnableNewRegionConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AutoEnableNewRegionConfiguration]
$creadListPrec :: ReadPrec [AutoEnableNewRegionConfiguration]
readPrec :: ReadPrec AutoEnableNewRegionConfiguration
$creadPrec :: ReadPrec AutoEnableNewRegionConfiguration
readList :: ReadS [AutoEnableNewRegionConfiguration]
$creadList :: ReadS [AutoEnableNewRegionConfiguration]
readsPrec :: Int -> ReadS AutoEnableNewRegionConfiguration
$creadsPrec :: Int -> ReadS AutoEnableNewRegionConfiguration
Prelude.Read, Int -> AutoEnableNewRegionConfiguration -> ShowS
[AutoEnableNewRegionConfiguration] -> ShowS
AutoEnableNewRegionConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutoEnableNewRegionConfiguration] -> ShowS
$cshowList :: [AutoEnableNewRegionConfiguration] -> ShowS
show :: AutoEnableNewRegionConfiguration -> String
$cshow :: AutoEnableNewRegionConfiguration -> String
showsPrec :: Int -> AutoEnableNewRegionConfiguration -> ShowS
$cshowsPrec :: Int -> AutoEnableNewRegionConfiguration -> ShowS
Prelude.Show, forall x.
Rep AutoEnableNewRegionConfiguration x
-> AutoEnableNewRegionConfiguration
forall x.
AutoEnableNewRegionConfiguration
-> Rep AutoEnableNewRegionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AutoEnableNewRegionConfiguration x
-> AutoEnableNewRegionConfiguration
$cfrom :: forall x.
AutoEnableNewRegionConfiguration
-> Rep AutoEnableNewRegionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'AutoEnableNewRegionConfiguration' 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:
--
-- 'region', 'autoEnableNewRegionConfiguration_region' - The Amazon Web Services Regions where Security Lake is automatically
-- enabled.
--
-- 'sources', 'autoEnableNewRegionConfiguration_sources' - The Amazon Web Services sources that are automatically enabled in
-- Security Lake.
newAutoEnableNewRegionConfiguration ::
  -- | 'region'
  Region ->
  AutoEnableNewRegionConfiguration
newAutoEnableNewRegionConfiguration :: Region -> AutoEnableNewRegionConfiguration
newAutoEnableNewRegionConfiguration Region
pRegion_ =
  AutoEnableNewRegionConfiguration'
    { $sel:region:AutoEnableNewRegionConfiguration' :: Region
region =
        Region
pRegion_,
      $sel:sources:AutoEnableNewRegionConfiguration' :: [AwsLogSourceType]
sources = forall a. Monoid a => a
Prelude.mempty
    }

-- | The Amazon Web Services Regions where Security Lake is automatically
-- enabled.
autoEnableNewRegionConfiguration_region :: Lens.Lens' AutoEnableNewRegionConfiguration Region
autoEnableNewRegionConfiguration_region :: Lens' AutoEnableNewRegionConfiguration Region
autoEnableNewRegionConfiguration_region = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoEnableNewRegionConfiguration' {Region
region :: Region
$sel:region:AutoEnableNewRegionConfiguration' :: AutoEnableNewRegionConfiguration -> Region
region} -> Region
region) (\s :: AutoEnableNewRegionConfiguration
s@AutoEnableNewRegionConfiguration' {} Region
a -> AutoEnableNewRegionConfiguration
s {$sel:region:AutoEnableNewRegionConfiguration' :: Region
region = Region
a} :: AutoEnableNewRegionConfiguration)

-- | The Amazon Web Services sources that are automatically enabled in
-- Security Lake.
autoEnableNewRegionConfiguration_sources :: Lens.Lens' AutoEnableNewRegionConfiguration [AwsLogSourceType]
autoEnableNewRegionConfiguration_sources :: Lens' AutoEnableNewRegionConfiguration [AwsLogSourceType]
autoEnableNewRegionConfiguration_sources = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoEnableNewRegionConfiguration' {[AwsLogSourceType]
sources :: [AwsLogSourceType]
$sel:sources:AutoEnableNewRegionConfiguration' :: AutoEnableNewRegionConfiguration -> [AwsLogSourceType]
sources} -> [AwsLogSourceType]
sources) (\s :: AutoEnableNewRegionConfiguration
s@AutoEnableNewRegionConfiguration' {} [AwsLogSourceType]
a -> AutoEnableNewRegionConfiguration
s {$sel:sources:AutoEnableNewRegionConfiguration' :: [AwsLogSourceType]
sources = [AwsLogSourceType]
a} :: AutoEnableNewRegionConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Data.FromJSON
    AutoEnableNewRegionConfiguration
  where
  parseJSON :: Value -> Parser AutoEnableNewRegionConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AutoEnableNewRegionConfiguration"
      ( \Object
x ->
          Region -> [AwsLogSourceType] -> AutoEnableNewRegionConfiguration
AutoEnableNewRegionConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"region")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"sources" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance
  Prelude.Hashable
    AutoEnableNewRegionConfiguration
  where
  hashWithSalt :: Int -> AutoEnableNewRegionConfiguration -> Int
hashWithSalt
    Int
_salt
    AutoEnableNewRegionConfiguration' {[AwsLogSourceType]
Region
sources :: [AwsLogSourceType]
region :: Region
$sel:sources:AutoEnableNewRegionConfiguration' :: AutoEnableNewRegionConfiguration -> [AwsLogSourceType]
$sel:region:AutoEnableNewRegionConfiguration' :: AutoEnableNewRegionConfiguration -> Region
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Region
region
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [AwsLogSourceType]
sources

instance
  Prelude.NFData
    AutoEnableNewRegionConfiguration
  where
  rnf :: AutoEnableNewRegionConfiguration -> ()
rnf AutoEnableNewRegionConfiguration' {[AwsLogSourceType]
Region
sources :: [AwsLogSourceType]
region :: Region
$sel:sources:AutoEnableNewRegionConfiguration' :: AutoEnableNewRegionConfiguration -> [AwsLogSourceType]
$sel:region:AutoEnableNewRegionConfiguration' :: AutoEnableNewRegionConfiguration -> Region
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Region
region
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [AwsLogSourceType]
sources

instance Data.ToJSON AutoEnableNewRegionConfiguration where
  toJSON :: AutoEnableNewRegionConfiguration -> Value
toJSON AutoEnableNewRegionConfiguration' {[AwsLogSourceType]
Region
sources :: [AwsLogSourceType]
region :: Region
$sel:sources:AutoEnableNewRegionConfiguration' :: AutoEnableNewRegionConfiguration -> [AwsLogSourceType]
$sel:region:AutoEnableNewRegionConfiguration' :: AutoEnableNewRegionConfiguration -> Region
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"region" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Region
region),
            forall a. a -> Maybe a
Prelude.Just (Key
"sources" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [AwsLogSourceType]
sources)
          ]
      )