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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | 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,
    -- | 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,
    -- | 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
(ResourceDataSyncSource -> ResourceDataSyncSource -> Bool)
-> (ResourceDataSyncSource -> ResourceDataSyncSource -> Bool)
-> Eq ResourceDataSyncSource
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]
(Int -> ReadS ResourceDataSyncSource)
-> ReadS [ResourceDataSyncSource]
-> ReadPrec ResourceDataSyncSource
-> ReadPrec [ResourceDataSyncSource]
-> Read 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
(Int -> ResourceDataSyncSource -> ShowS)
-> (ResourceDataSyncSource -> String)
-> ([ResourceDataSyncSource] -> ShowS)
-> Show ResourceDataSyncSource
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. ResourceDataSyncSource -> Rep ResourceDataSyncSource x)
-> (forall x.
    Rep ResourceDataSyncSource x -> ResourceDataSyncSource)
-> Generic ResourceDataSyncSource
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:
--
-- '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.
--
-- 'awsOrganizationsSource', 'resourceDataSyncSource_awsOrganizationsSource' - Information about the @AwsOrganizationsSource@ resource data sync
-- source. A sync source of this type can synchronize data from
-- Organizations.
--
-- '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' :: Maybe Bool
-> Maybe Bool
-> Maybe ResourceDataSyncAwsOrganizationsSource
-> Text
-> [Text]
-> ResourceDataSyncSource
ResourceDataSyncSource'
    { $sel:enableAllOpsDataSources:ResourceDataSyncSource' :: Maybe Bool
enableAllOpsDataSources =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:includeFutureRegions:ResourceDataSyncSource' :: Maybe Bool
includeFutureRegions = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:awsOrganizationsSource:ResourceDataSyncSource' :: Maybe ResourceDataSyncAwsOrganizationsSource
awsOrganizationsSource = Maybe ResourceDataSyncAwsOrganizationsSource
forall a. Maybe a
Prelude.Nothing,
      $sel:sourceType:ResourceDataSyncSource' :: Text
sourceType = Text
pSourceType_,
      $sel:sourceRegions:ResourceDataSyncSource' :: [Text]
sourceRegions = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | 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 :: (Maybe Bool -> f (Maybe Bool))
-> ResourceDataSyncSource -> f ResourceDataSyncSource
resourceDataSyncSource_enableAllOpsDataSources = (ResourceDataSyncSource -> Maybe Bool)
-> (ResourceDataSyncSource -> Maybe Bool -> ResourceDataSyncSource)
-> Lens
     ResourceDataSyncSource
     ResourceDataSyncSource
     (Maybe Bool)
     (Maybe Bool)
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 :: (Maybe Bool -> f (Maybe Bool))
-> ResourceDataSyncSource -> f ResourceDataSyncSource
resourceDataSyncSource_includeFutureRegions = (ResourceDataSyncSource -> Maybe Bool)
-> (ResourceDataSyncSource -> Maybe Bool -> ResourceDataSyncSource)
-> Lens
     ResourceDataSyncSource
     ResourceDataSyncSource
     (Maybe Bool)
     (Maybe Bool)
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)

-- | 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 :: (Maybe ResourceDataSyncAwsOrganizationsSource
 -> f (Maybe ResourceDataSyncAwsOrganizationsSource))
-> ResourceDataSyncSource -> f ResourceDataSyncSource
resourceDataSyncSource_awsOrganizationsSource = (ResourceDataSyncSource
 -> Maybe ResourceDataSyncAwsOrganizationsSource)
-> (ResourceDataSyncSource
    -> Maybe ResourceDataSyncAwsOrganizationsSource
    -> ResourceDataSyncSource)
-> Lens
     ResourceDataSyncSource
     ResourceDataSyncSource
     (Maybe ResourceDataSyncAwsOrganizationsSource)
     (Maybe ResourceDataSyncAwsOrganizationsSource)
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)

-- | 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 :: (Text -> f Text)
-> ResourceDataSyncSource -> f ResourceDataSyncSource
resourceDataSyncSource_sourceType = (ResourceDataSyncSource -> Text)
-> (ResourceDataSyncSource -> Text -> ResourceDataSyncSource)
-> Lens ResourceDataSyncSource ResourceDataSyncSource Text Text
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 :: ([Text] -> f [Text])
-> ResourceDataSyncSource -> f ResourceDataSyncSource
resourceDataSyncSource_sourceRegions = (ResourceDataSyncSource -> [Text])
-> (ResourceDataSyncSource -> [Text] -> ResourceDataSyncSource)
-> Lens ResourceDataSyncSource ResourceDataSyncSource [Text] [Text]
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) (([Text] -> f [Text])
 -> ResourceDataSyncSource -> f ResourceDataSyncSource)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> ResourceDataSyncSource
-> f ResourceDataSyncSource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable ResourceDataSyncSource

instance Prelude.NFData ResourceDataSyncSource

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