{-# 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.SSM.Types.ResourceDataSyncSource
-- 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.SSM.Types.ResourceDataSyncSource 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.SSM.Types.ResourceDataSyncAwsOrganizationsSource

-- | Information about the source of the data included in the resource data
-- sync.
--
-- /See:/ 'newResourceDataSyncSource' smart constructor.
data ResourceDataSyncSource = ResourceDataSyncSource'
  { -- | Information about the @AwsOrganizationsSource@ resource data sync
    -- source. A sync source of this type can synchronize data from
    -- Organizations.
    ResourceDataSyncSource
-> Maybe ResourceDataSyncAwsOrganizationsSource
awsOrganizationsSource :: Prelude.Maybe ResourceDataSyncAwsOrganizationsSource,
    -- | When you create a resource data sync, if you choose one of the
    -- Organizations options, then Systems Manager automatically enables all
    -- OpsData sources in the selected Amazon Web Services Regions for all
    -- Amazon Web Services accounts in your organization (or in the selected
    -- organization units). For more information, see
    -- <https://docs.aws.amazon.com/systems-manager/latest/userguide/Explorer-resouce-data-sync-multiple-accounts-and-regions.html About multiple account and Region resource data syncs>
    -- in the /Amazon Web Services Systems Manager User Guide/.
    ResourceDataSyncSource -> Maybe Bool
enableAllOpsDataSources :: Prelude.Maybe Prelude.Bool,
    -- | Whether to automatically synchronize and aggregate data from new Amazon
    -- Web Services Regions when those Regions come online.
    ResourceDataSyncSource -> Maybe Bool
includeFutureRegions :: Prelude.Maybe Prelude.Bool,
    -- | The type of data source for the resource data sync. @SourceType@ is
    -- either @AwsOrganizations@ (if an organization is present in
    -- Organizations) or @SingleAccountMultiRegions@.
    ResourceDataSyncSource -> Text
sourceType :: Prelude.Text,
    -- | The @SyncSource@ Amazon Web Services Regions included in the resource
    -- data sync.
    ResourceDataSyncSource -> [Text]
sourceRegions :: [Prelude.Text]
  }
  deriving (ResourceDataSyncSource -> ResourceDataSyncSource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceDataSyncSource -> ResourceDataSyncSource -> Bool
$c/= :: ResourceDataSyncSource -> ResourceDataSyncSource -> Bool
== :: ResourceDataSyncSource -> ResourceDataSyncSource -> Bool
$c== :: ResourceDataSyncSource -> ResourceDataSyncSource -> Bool
Prelude.Eq, ReadPrec [ResourceDataSyncSource]
ReadPrec ResourceDataSyncSource
Int -> ReadS ResourceDataSyncSource
ReadS [ResourceDataSyncSource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceDataSyncSource]
$creadListPrec :: ReadPrec [ResourceDataSyncSource]
readPrec :: ReadPrec ResourceDataSyncSource
$creadPrec :: ReadPrec ResourceDataSyncSource
readList :: ReadS [ResourceDataSyncSource]
$creadList :: ReadS [ResourceDataSyncSource]
readsPrec :: Int -> ReadS ResourceDataSyncSource
$creadsPrec :: Int -> ReadS ResourceDataSyncSource
Prelude.Read, Int -> ResourceDataSyncSource -> ShowS
[ResourceDataSyncSource] -> ShowS
ResourceDataSyncSource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceDataSyncSource] -> ShowS
$cshowList :: [ResourceDataSyncSource] -> ShowS
show :: ResourceDataSyncSource -> String
$cshow :: ResourceDataSyncSource -> String
showsPrec :: Int -> ResourceDataSyncSource -> ShowS
$cshowsPrec :: Int -> ResourceDataSyncSource -> ShowS
Prelude.Show, forall x. Rep ResourceDataSyncSource x -> ResourceDataSyncSource
forall x. ResourceDataSyncSource -> Rep ResourceDataSyncSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceDataSyncSource x -> ResourceDataSyncSource
$cfrom :: forall x. ResourceDataSyncSource -> Rep ResourceDataSyncSource x
Prelude.Generic)

-- |
-- Create a value of 'ResourceDataSyncSource' 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:
--
-- 'awsOrganizationsSource', 'resourceDataSyncSource_awsOrganizationsSource' - Information about the @AwsOrganizationsSource@ resource data sync
-- source. A sync source of this type can synchronize data from
-- Organizations.
--
-- 'enableAllOpsDataSources', 'resourceDataSyncSource_enableAllOpsDataSources' - When you create a resource data sync, if you choose one of the
-- Organizations options, then Systems Manager automatically enables all
-- OpsData sources in the selected Amazon Web Services Regions for all
-- Amazon Web Services accounts in your organization (or in the selected
-- organization units). For more information, see
-- <https://docs.aws.amazon.com/systems-manager/latest/userguide/Explorer-resouce-data-sync-multiple-accounts-and-regions.html About multiple account and Region resource data syncs>
-- in the /Amazon Web Services Systems Manager User Guide/.
--
-- 'includeFutureRegions', 'resourceDataSyncSource_includeFutureRegions' - Whether to automatically synchronize and aggregate data from new Amazon
-- Web Services Regions when those Regions come online.
--
-- 'sourceType', 'resourceDataSyncSource_sourceType' - The type of data source for the resource data sync. @SourceType@ is
-- either @AwsOrganizations@ (if an organization is present in
-- Organizations) or @SingleAccountMultiRegions@.
--
-- 'sourceRegions', 'resourceDataSyncSource_sourceRegions' - The @SyncSource@ Amazon Web Services Regions included in the resource
-- data sync.
newResourceDataSyncSource ::
  -- | 'sourceType'
  Prelude.Text ->
  ResourceDataSyncSource
newResourceDataSyncSource :: Text -> ResourceDataSyncSource
newResourceDataSyncSource Text
pSourceType_ =
  ResourceDataSyncSource'
    { $sel:awsOrganizationsSource:ResourceDataSyncSource' :: Maybe ResourceDataSyncAwsOrganizationsSource
awsOrganizationsSource =
        forall a. Maybe a
Prelude.Nothing,
      $sel:enableAllOpsDataSources:ResourceDataSyncSource' :: Maybe Bool
enableAllOpsDataSources = forall a. Maybe a
Prelude.Nothing,
      $sel:includeFutureRegions:ResourceDataSyncSource' :: Maybe Bool
includeFutureRegions = forall a. Maybe a
Prelude.Nothing,
      $sel:sourceType:ResourceDataSyncSource' :: Text
sourceType = Text
pSourceType_,
      $sel:sourceRegions:ResourceDataSyncSource' :: [Text]
sourceRegions = forall a. Monoid a => a
Prelude.mempty
    }

-- | Information about the @AwsOrganizationsSource@ resource data sync
-- source. A sync source of this type can synchronize data from
-- Organizations.
resourceDataSyncSource_awsOrganizationsSource :: Lens.Lens' ResourceDataSyncSource (Prelude.Maybe ResourceDataSyncAwsOrganizationsSource)
resourceDataSyncSource_awsOrganizationsSource :: Lens'
  ResourceDataSyncSource
  (Maybe ResourceDataSyncAwsOrganizationsSource)
resourceDataSyncSource_awsOrganizationsSource = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceDataSyncSource' {Maybe ResourceDataSyncAwsOrganizationsSource
awsOrganizationsSource :: Maybe ResourceDataSyncAwsOrganizationsSource
$sel:awsOrganizationsSource:ResourceDataSyncSource' :: ResourceDataSyncSource
-> Maybe ResourceDataSyncAwsOrganizationsSource
awsOrganizationsSource} -> Maybe ResourceDataSyncAwsOrganizationsSource
awsOrganizationsSource) (\s :: ResourceDataSyncSource
s@ResourceDataSyncSource' {} Maybe ResourceDataSyncAwsOrganizationsSource
a -> ResourceDataSyncSource
s {$sel:awsOrganizationsSource:ResourceDataSyncSource' :: Maybe ResourceDataSyncAwsOrganizationsSource
awsOrganizationsSource = Maybe ResourceDataSyncAwsOrganizationsSource
a} :: ResourceDataSyncSource)

-- | When you create a resource data sync, if you choose one of the
-- Organizations options, then Systems Manager automatically enables all
-- OpsData sources in the selected Amazon Web Services Regions for all
-- Amazon Web Services accounts in your organization (or in the selected
-- organization units). For more information, see
-- <https://docs.aws.amazon.com/systems-manager/latest/userguide/Explorer-resouce-data-sync-multiple-accounts-and-regions.html About multiple account and Region resource data syncs>
-- in the /Amazon Web Services Systems Manager User Guide/.
resourceDataSyncSource_enableAllOpsDataSources :: Lens.Lens' ResourceDataSyncSource (Prelude.Maybe Prelude.Bool)
resourceDataSyncSource_enableAllOpsDataSources :: Lens' ResourceDataSyncSource (Maybe Bool)
resourceDataSyncSource_enableAllOpsDataSources = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceDataSyncSource' {Maybe Bool
enableAllOpsDataSources :: Maybe Bool
$sel:enableAllOpsDataSources:ResourceDataSyncSource' :: ResourceDataSyncSource -> Maybe Bool
enableAllOpsDataSources} -> Maybe Bool
enableAllOpsDataSources) (\s :: ResourceDataSyncSource
s@ResourceDataSyncSource' {} Maybe Bool
a -> ResourceDataSyncSource
s {$sel:enableAllOpsDataSources:ResourceDataSyncSource' :: Maybe Bool
enableAllOpsDataSources = Maybe Bool
a} :: ResourceDataSyncSource)

-- | Whether to automatically synchronize and aggregate data from new Amazon
-- Web Services Regions when those Regions come online.
resourceDataSyncSource_includeFutureRegions :: Lens.Lens' ResourceDataSyncSource (Prelude.Maybe Prelude.Bool)
resourceDataSyncSource_includeFutureRegions :: Lens' ResourceDataSyncSource (Maybe Bool)
resourceDataSyncSource_includeFutureRegions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceDataSyncSource' {Maybe Bool
includeFutureRegions :: Maybe Bool
$sel:includeFutureRegions:ResourceDataSyncSource' :: ResourceDataSyncSource -> Maybe Bool
includeFutureRegions} -> Maybe Bool
includeFutureRegions) (\s :: ResourceDataSyncSource
s@ResourceDataSyncSource' {} Maybe Bool
a -> ResourceDataSyncSource
s {$sel:includeFutureRegions:ResourceDataSyncSource' :: Maybe Bool
includeFutureRegions = Maybe Bool
a} :: ResourceDataSyncSource)

-- | The type of data source for the resource data sync. @SourceType@ is
-- either @AwsOrganizations@ (if an organization is present in
-- Organizations) or @SingleAccountMultiRegions@.
resourceDataSyncSource_sourceType :: Lens.Lens' ResourceDataSyncSource Prelude.Text
resourceDataSyncSource_sourceType :: Lens' ResourceDataSyncSource Text
resourceDataSyncSource_sourceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceDataSyncSource' {Text
sourceType :: Text
$sel:sourceType:ResourceDataSyncSource' :: ResourceDataSyncSource -> Text
sourceType} -> Text
sourceType) (\s :: ResourceDataSyncSource
s@ResourceDataSyncSource' {} Text
a -> ResourceDataSyncSource
s {$sel:sourceType:ResourceDataSyncSource' :: Text
sourceType = Text
a} :: ResourceDataSyncSource)

-- | The @SyncSource@ Amazon Web Services Regions included in the resource
-- data sync.
resourceDataSyncSource_sourceRegions :: Lens.Lens' ResourceDataSyncSource [Prelude.Text]
resourceDataSyncSource_sourceRegions :: Lens' ResourceDataSyncSource [Text]
resourceDataSyncSource_sourceRegions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceDataSyncSource' {[Text]
sourceRegions :: [Text]
$sel:sourceRegions:ResourceDataSyncSource' :: ResourceDataSyncSource -> [Text]
sourceRegions} -> [Text]
sourceRegions) (\s :: ResourceDataSyncSource
s@ResourceDataSyncSource' {} [Text]
a -> ResourceDataSyncSource
s {$sel:sourceRegions:ResourceDataSyncSource' :: [Text]
sourceRegions = [Text]
a} :: ResourceDataSyncSource) 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 Prelude.Hashable ResourceDataSyncSource where
  hashWithSalt :: Int -> ResourceDataSyncSource -> Int
hashWithSalt Int
_salt ResourceDataSyncSource' {[Text]
Maybe Bool
Maybe ResourceDataSyncAwsOrganizationsSource
Text
sourceRegions :: [Text]
sourceType :: Text
includeFutureRegions :: Maybe Bool
enableAllOpsDataSources :: Maybe Bool
awsOrganizationsSource :: Maybe ResourceDataSyncAwsOrganizationsSource
$sel:sourceRegions:ResourceDataSyncSource' :: ResourceDataSyncSource -> [Text]
$sel:sourceType:ResourceDataSyncSource' :: ResourceDataSyncSource -> Text
$sel:includeFutureRegions:ResourceDataSyncSource' :: ResourceDataSyncSource -> Maybe Bool
$sel:enableAllOpsDataSources:ResourceDataSyncSource' :: ResourceDataSyncSource -> Maybe Bool
$sel:awsOrganizationsSource:ResourceDataSyncSource' :: ResourceDataSyncSource
-> Maybe ResourceDataSyncAwsOrganizationsSource
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResourceDataSyncAwsOrganizationsSource
awsOrganizationsSource
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
enableAllOpsDataSources
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
includeFutureRegions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
sourceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
sourceRegions

instance Prelude.NFData ResourceDataSyncSource where
  rnf :: ResourceDataSyncSource -> ()
rnf ResourceDataSyncSource' {[Text]
Maybe Bool
Maybe ResourceDataSyncAwsOrganizationsSource
Text
sourceRegions :: [Text]
sourceType :: Text
includeFutureRegions :: Maybe Bool
enableAllOpsDataSources :: Maybe Bool
awsOrganizationsSource :: Maybe ResourceDataSyncAwsOrganizationsSource
$sel:sourceRegions:ResourceDataSyncSource' :: ResourceDataSyncSource -> [Text]
$sel:sourceType:ResourceDataSyncSource' :: ResourceDataSyncSource -> Text
$sel:includeFutureRegions:ResourceDataSyncSource' :: ResourceDataSyncSource -> Maybe Bool
$sel:enableAllOpsDataSources:ResourceDataSyncSource' :: ResourceDataSyncSource -> Maybe Bool
$sel:awsOrganizationsSource:ResourceDataSyncSource' :: ResourceDataSyncSource
-> Maybe ResourceDataSyncAwsOrganizationsSource
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ResourceDataSyncAwsOrganizationsSource
awsOrganizationsSource
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
enableAllOpsDataSources
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
includeFutureRegions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
sourceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
sourceRegions

instance Data.ToJSON ResourceDataSyncSource where
  toJSON :: ResourceDataSyncSource -> Value
toJSON ResourceDataSyncSource' {[Text]
Maybe Bool
Maybe ResourceDataSyncAwsOrganizationsSource
Text
sourceRegions :: [Text]
sourceType :: Text
includeFutureRegions :: Maybe Bool
enableAllOpsDataSources :: Maybe Bool
awsOrganizationsSource :: Maybe ResourceDataSyncAwsOrganizationsSource
$sel:sourceRegions:ResourceDataSyncSource' :: ResourceDataSyncSource -> [Text]
$sel:sourceType:ResourceDataSyncSource' :: ResourceDataSyncSource -> Text
$sel:includeFutureRegions:ResourceDataSyncSource' :: ResourceDataSyncSource -> Maybe Bool
$sel:enableAllOpsDataSources:ResourceDataSyncSource' :: ResourceDataSyncSource -> Maybe Bool
$sel:awsOrganizationsSource:ResourceDataSyncSource' :: ResourceDataSyncSource
-> Maybe ResourceDataSyncAwsOrganizationsSource
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AwsOrganizationsSource" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ResourceDataSyncAwsOrganizationsSource
awsOrganizationsSource,
            (Key
"EnableAllOpsDataSources" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enableAllOpsDataSources,
            (Key
"IncludeFutureRegions" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
includeFutureRegions,
            forall a. a -> Maybe a
Prelude.Just (Key
"SourceType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
sourceType),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"SourceRegions" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
sourceRegions)
          ]
      )