{-# 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.ResourceDataSyncAwsOrganizationsSource
-- 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.ResourceDataSyncAwsOrganizationsSource where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SSM.Types.ResourceDataSyncOrganizationalUnit

-- | Information about the @AwsOrganizationsSource@ resource data sync
-- source. A sync source of this type can synchronize data from
-- Organizations or, if an Amazon Web Services organization isn\'t present,
-- from multiple Amazon Web Services Regions.
--
-- /See:/ 'newResourceDataSyncAwsOrganizationsSource' smart constructor.
data ResourceDataSyncAwsOrganizationsSource = ResourceDataSyncAwsOrganizationsSource'
  { -- | The Organizations organization units included in the sync.
    ResourceDataSyncAwsOrganizationsSource
-> Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
organizationalUnits :: Prelude.Maybe (Prelude.NonEmpty ResourceDataSyncOrganizationalUnit),
    -- | If an Amazon Web Services organization is present, this is either
    -- @OrganizationalUnits@ or @EntireOrganization@. For
    -- @OrganizationalUnits@, the data is aggregated from a set of organization
    -- units. For @EntireOrganization@, the data is aggregated from the entire
    -- Amazon Web Services organization.
    ResourceDataSyncAwsOrganizationsSource -> Text
organizationSourceType :: Prelude.Text
  }
  deriving (ResourceDataSyncAwsOrganizationsSource
-> ResourceDataSyncAwsOrganizationsSource -> Bool
(ResourceDataSyncAwsOrganizationsSource
 -> ResourceDataSyncAwsOrganizationsSource -> Bool)
-> (ResourceDataSyncAwsOrganizationsSource
    -> ResourceDataSyncAwsOrganizationsSource -> Bool)
-> Eq ResourceDataSyncAwsOrganizationsSource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceDataSyncAwsOrganizationsSource
-> ResourceDataSyncAwsOrganizationsSource -> Bool
$c/= :: ResourceDataSyncAwsOrganizationsSource
-> ResourceDataSyncAwsOrganizationsSource -> Bool
== :: ResourceDataSyncAwsOrganizationsSource
-> ResourceDataSyncAwsOrganizationsSource -> Bool
$c== :: ResourceDataSyncAwsOrganizationsSource
-> ResourceDataSyncAwsOrganizationsSource -> Bool
Prelude.Eq, ReadPrec [ResourceDataSyncAwsOrganizationsSource]
ReadPrec ResourceDataSyncAwsOrganizationsSource
Int -> ReadS ResourceDataSyncAwsOrganizationsSource
ReadS [ResourceDataSyncAwsOrganizationsSource]
(Int -> ReadS ResourceDataSyncAwsOrganizationsSource)
-> ReadS [ResourceDataSyncAwsOrganizationsSource]
-> ReadPrec ResourceDataSyncAwsOrganizationsSource
-> ReadPrec [ResourceDataSyncAwsOrganizationsSource]
-> Read ResourceDataSyncAwsOrganizationsSource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceDataSyncAwsOrganizationsSource]
$creadListPrec :: ReadPrec [ResourceDataSyncAwsOrganizationsSource]
readPrec :: ReadPrec ResourceDataSyncAwsOrganizationsSource
$creadPrec :: ReadPrec ResourceDataSyncAwsOrganizationsSource
readList :: ReadS [ResourceDataSyncAwsOrganizationsSource]
$creadList :: ReadS [ResourceDataSyncAwsOrganizationsSource]
readsPrec :: Int -> ReadS ResourceDataSyncAwsOrganizationsSource
$creadsPrec :: Int -> ReadS ResourceDataSyncAwsOrganizationsSource
Prelude.Read, Int -> ResourceDataSyncAwsOrganizationsSource -> ShowS
[ResourceDataSyncAwsOrganizationsSource] -> ShowS
ResourceDataSyncAwsOrganizationsSource -> String
(Int -> ResourceDataSyncAwsOrganizationsSource -> ShowS)
-> (ResourceDataSyncAwsOrganizationsSource -> String)
-> ([ResourceDataSyncAwsOrganizationsSource] -> ShowS)
-> Show ResourceDataSyncAwsOrganizationsSource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceDataSyncAwsOrganizationsSource] -> ShowS
$cshowList :: [ResourceDataSyncAwsOrganizationsSource] -> ShowS
show :: ResourceDataSyncAwsOrganizationsSource -> String
$cshow :: ResourceDataSyncAwsOrganizationsSource -> String
showsPrec :: Int -> ResourceDataSyncAwsOrganizationsSource -> ShowS
$cshowsPrec :: Int -> ResourceDataSyncAwsOrganizationsSource -> ShowS
Prelude.Show, (forall x.
 ResourceDataSyncAwsOrganizationsSource
 -> Rep ResourceDataSyncAwsOrganizationsSource x)
-> (forall x.
    Rep ResourceDataSyncAwsOrganizationsSource x
    -> ResourceDataSyncAwsOrganizationsSource)
-> Generic ResourceDataSyncAwsOrganizationsSource
forall x.
Rep ResourceDataSyncAwsOrganizationsSource x
-> ResourceDataSyncAwsOrganizationsSource
forall x.
ResourceDataSyncAwsOrganizationsSource
-> Rep ResourceDataSyncAwsOrganizationsSource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ResourceDataSyncAwsOrganizationsSource x
-> ResourceDataSyncAwsOrganizationsSource
$cfrom :: forall x.
ResourceDataSyncAwsOrganizationsSource
-> Rep ResourceDataSyncAwsOrganizationsSource x
Prelude.Generic)

-- |
-- Create a value of 'ResourceDataSyncAwsOrganizationsSource' 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:
--
-- 'organizationalUnits', 'resourceDataSyncAwsOrganizationsSource_organizationalUnits' - The Organizations organization units included in the sync.
--
-- 'organizationSourceType', 'resourceDataSyncAwsOrganizationsSource_organizationSourceType' - If an Amazon Web Services organization is present, this is either
-- @OrganizationalUnits@ or @EntireOrganization@. For
-- @OrganizationalUnits@, the data is aggregated from a set of organization
-- units. For @EntireOrganization@, the data is aggregated from the entire
-- Amazon Web Services organization.
newResourceDataSyncAwsOrganizationsSource ::
  -- | 'organizationSourceType'
  Prelude.Text ->
  ResourceDataSyncAwsOrganizationsSource
newResourceDataSyncAwsOrganizationsSource :: Text -> ResourceDataSyncAwsOrganizationsSource
newResourceDataSyncAwsOrganizationsSource
  Text
pOrganizationSourceType_ =
    ResourceDataSyncAwsOrganizationsSource' :: Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
-> Text -> ResourceDataSyncAwsOrganizationsSource
ResourceDataSyncAwsOrganizationsSource'
      { $sel:organizationalUnits:ResourceDataSyncAwsOrganizationsSource' :: Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
organizationalUnits =
          Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
forall a. Maybe a
Prelude.Nothing,
        $sel:organizationSourceType:ResourceDataSyncAwsOrganizationsSource' :: Text
organizationSourceType =
          Text
pOrganizationSourceType_
      }

-- | The Organizations organization units included in the sync.
resourceDataSyncAwsOrganizationsSource_organizationalUnits :: Lens.Lens' ResourceDataSyncAwsOrganizationsSource (Prelude.Maybe (Prelude.NonEmpty ResourceDataSyncOrganizationalUnit))
resourceDataSyncAwsOrganizationsSource_organizationalUnits :: (Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
 -> f (Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)))
-> ResourceDataSyncAwsOrganizationsSource
-> f ResourceDataSyncAwsOrganizationsSource
resourceDataSyncAwsOrganizationsSource_organizationalUnits = (ResourceDataSyncAwsOrganizationsSource
 -> Maybe (NonEmpty ResourceDataSyncOrganizationalUnit))
-> (ResourceDataSyncAwsOrganizationsSource
    -> Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
    -> ResourceDataSyncAwsOrganizationsSource)
-> Lens
     ResourceDataSyncAwsOrganizationsSource
     ResourceDataSyncAwsOrganizationsSource
     (Maybe (NonEmpty ResourceDataSyncOrganizationalUnit))
     (Maybe (NonEmpty ResourceDataSyncOrganizationalUnit))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceDataSyncAwsOrganizationsSource' {Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
organizationalUnits :: Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
$sel:organizationalUnits:ResourceDataSyncAwsOrganizationsSource' :: ResourceDataSyncAwsOrganizationsSource
-> Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
organizationalUnits} -> Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
organizationalUnits) (\s :: ResourceDataSyncAwsOrganizationsSource
s@ResourceDataSyncAwsOrganizationsSource' {} Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
a -> ResourceDataSyncAwsOrganizationsSource
s {$sel:organizationalUnits:ResourceDataSyncAwsOrganizationsSource' :: Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
organizationalUnits = Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
a} :: ResourceDataSyncAwsOrganizationsSource) ((Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
  -> f (Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)))
 -> ResourceDataSyncAwsOrganizationsSource
 -> f ResourceDataSyncAwsOrganizationsSource)
-> ((Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
     -> f (Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)))
    -> Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
    -> f (Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)))
-> (Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
    -> f (Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)))
-> ResourceDataSyncAwsOrganizationsSource
-> f ResourceDataSyncAwsOrganizationsSource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty ResourceDataSyncOrganizationalUnit)
  (NonEmpty ResourceDataSyncOrganizationalUnit)
  (NonEmpty ResourceDataSyncOrganizationalUnit)
  (NonEmpty ResourceDataSyncOrganizationalUnit)
-> Iso
     (Maybe (NonEmpty ResourceDataSyncOrganizationalUnit))
     (Maybe (NonEmpty ResourceDataSyncOrganizationalUnit))
     (Maybe (NonEmpty ResourceDataSyncOrganizationalUnit))
     (Maybe (NonEmpty ResourceDataSyncOrganizationalUnit))
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
  (NonEmpty ResourceDataSyncOrganizationalUnit)
  (NonEmpty ResourceDataSyncOrganizationalUnit)
  (NonEmpty ResourceDataSyncOrganizationalUnit)
  (NonEmpty ResourceDataSyncOrganizationalUnit)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | If an Amazon Web Services organization is present, this is either
-- @OrganizationalUnits@ or @EntireOrganization@. For
-- @OrganizationalUnits@, the data is aggregated from a set of organization
-- units. For @EntireOrganization@, the data is aggregated from the entire
-- Amazon Web Services organization.
resourceDataSyncAwsOrganizationsSource_organizationSourceType :: Lens.Lens' ResourceDataSyncAwsOrganizationsSource Prelude.Text
resourceDataSyncAwsOrganizationsSource_organizationSourceType :: (Text -> f Text)
-> ResourceDataSyncAwsOrganizationsSource
-> f ResourceDataSyncAwsOrganizationsSource
resourceDataSyncAwsOrganizationsSource_organizationSourceType = (ResourceDataSyncAwsOrganizationsSource -> Text)
-> (ResourceDataSyncAwsOrganizationsSource
    -> Text -> ResourceDataSyncAwsOrganizationsSource)
-> Lens
     ResourceDataSyncAwsOrganizationsSource
     ResourceDataSyncAwsOrganizationsSource
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceDataSyncAwsOrganizationsSource' {Text
organizationSourceType :: Text
$sel:organizationSourceType:ResourceDataSyncAwsOrganizationsSource' :: ResourceDataSyncAwsOrganizationsSource -> Text
organizationSourceType} -> Text
organizationSourceType) (\s :: ResourceDataSyncAwsOrganizationsSource
s@ResourceDataSyncAwsOrganizationsSource' {} Text
a -> ResourceDataSyncAwsOrganizationsSource
s {$sel:organizationSourceType:ResourceDataSyncAwsOrganizationsSource' :: Text
organizationSourceType = Text
a} :: ResourceDataSyncAwsOrganizationsSource)

instance
  Core.FromJSON
    ResourceDataSyncAwsOrganizationsSource
  where
  parseJSON :: Value -> Parser ResourceDataSyncAwsOrganizationsSource
parseJSON =
    String
-> (Object -> Parser ResourceDataSyncAwsOrganizationsSource)
-> Value
-> Parser ResourceDataSyncAwsOrganizationsSource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResourceDataSyncAwsOrganizationsSource"
      ( \Object
x ->
          Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
-> Text -> ResourceDataSyncAwsOrganizationsSource
ResourceDataSyncAwsOrganizationsSource'
            (Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
 -> Text -> ResourceDataSyncAwsOrganizationsSource)
-> Parser (Maybe (NonEmpty ResourceDataSyncOrganizationalUnit))
-> Parser (Text -> ResourceDataSyncAwsOrganizationsSource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text
-> Parser (Maybe (NonEmpty ResourceDataSyncOrganizationalUnit))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"OrganizationalUnits")
            Parser (Text -> ResourceDataSyncAwsOrganizationsSource)
-> Parser Text -> Parser ResourceDataSyncAwsOrganizationsSource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"OrganizationSourceType")
      )

instance
  Prelude.Hashable
    ResourceDataSyncAwsOrganizationsSource

instance
  Prelude.NFData
    ResourceDataSyncAwsOrganizationsSource

instance
  Core.ToJSON
    ResourceDataSyncAwsOrganizationsSource
  where
  toJSON :: ResourceDataSyncAwsOrganizationsSource -> Value
toJSON ResourceDataSyncAwsOrganizationsSource' {Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
Text
organizationSourceType :: Text
organizationalUnits :: Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
$sel:organizationSourceType:ResourceDataSyncAwsOrganizationsSource' :: ResourceDataSyncAwsOrganizationsSource -> Text
$sel:organizationalUnits:ResourceDataSyncAwsOrganizationsSource' :: ResourceDataSyncAwsOrganizationsSource
-> Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"OrganizationalUnits" Text -> NonEmpty ResourceDataSyncOrganizationalUnit -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (NonEmpty ResourceDataSyncOrganizationalUnit -> Pair)
-> Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
-> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty ResourceDataSyncOrganizationalUnit)
organizationalUnits,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"OrganizationSourceType"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
organizationSourceType
              )
          ]
      )