{-# 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.CloudFormation.Types.DeploymentTargets
-- 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.CloudFormation.Types.DeploymentTargets where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | [Service-managed permissions] The Organizations accounts to which
-- StackSets deploys. StackSets does not deploy stack instances to the
-- organization management account, even if the organization management
-- account is in your organization or in an OU in your organization.
--
-- For update operations, you can specify either @Accounts@ or
-- @OrganizationalUnitIds@. For create and delete operations, specify
-- @OrganizationalUnitIds@.
--
-- /See:/ 'newDeploymentTargets' smart constructor.
data DeploymentTargets = DeploymentTargets'
  { -- | The names of one or more Amazon Web Services accounts for which you want
    -- to deploy stack set updates.
    DeploymentTargets -> Maybe [Text]
accounts :: Prelude.Maybe [Prelude.Text],
    -- | The organization root ID or organizational unit (OU) IDs to which
    -- StackSets deploys.
    DeploymentTargets -> Maybe [Text]
organizationalUnitIds :: Prelude.Maybe [Prelude.Text],
    -- | Returns the value of the @AccountsUrl@ property.
    DeploymentTargets -> Maybe Text
accountsUrl :: Prelude.Maybe Prelude.Text
  }
  deriving (DeploymentTargets -> DeploymentTargets -> Bool
(DeploymentTargets -> DeploymentTargets -> Bool)
-> (DeploymentTargets -> DeploymentTargets -> Bool)
-> Eq DeploymentTargets
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeploymentTargets -> DeploymentTargets -> Bool
$c/= :: DeploymentTargets -> DeploymentTargets -> Bool
== :: DeploymentTargets -> DeploymentTargets -> Bool
$c== :: DeploymentTargets -> DeploymentTargets -> Bool
Prelude.Eq, ReadPrec [DeploymentTargets]
ReadPrec DeploymentTargets
Int -> ReadS DeploymentTargets
ReadS [DeploymentTargets]
(Int -> ReadS DeploymentTargets)
-> ReadS [DeploymentTargets]
-> ReadPrec DeploymentTargets
-> ReadPrec [DeploymentTargets]
-> Read DeploymentTargets
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeploymentTargets]
$creadListPrec :: ReadPrec [DeploymentTargets]
readPrec :: ReadPrec DeploymentTargets
$creadPrec :: ReadPrec DeploymentTargets
readList :: ReadS [DeploymentTargets]
$creadList :: ReadS [DeploymentTargets]
readsPrec :: Int -> ReadS DeploymentTargets
$creadsPrec :: Int -> ReadS DeploymentTargets
Prelude.Read, Int -> DeploymentTargets -> ShowS
[DeploymentTargets] -> ShowS
DeploymentTargets -> String
(Int -> DeploymentTargets -> ShowS)
-> (DeploymentTargets -> String)
-> ([DeploymentTargets] -> ShowS)
-> Show DeploymentTargets
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeploymentTargets] -> ShowS
$cshowList :: [DeploymentTargets] -> ShowS
show :: DeploymentTargets -> String
$cshow :: DeploymentTargets -> String
showsPrec :: Int -> DeploymentTargets -> ShowS
$cshowsPrec :: Int -> DeploymentTargets -> ShowS
Prelude.Show, (forall x. DeploymentTargets -> Rep DeploymentTargets x)
-> (forall x. Rep DeploymentTargets x -> DeploymentTargets)
-> Generic DeploymentTargets
forall x. Rep DeploymentTargets x -> DeploymentTargets
forall x. DeploymentTargets -> Rep DeploymentTargets x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeploymentTargets x -> DeploymentTargets
$cfrom :: forall x. DeploymentTargets -> Rep DeploymentTargets x
Prelude.Generic)

-- |
-- Create a value of 'DeploymentTargets' 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:
--
-- 'accounts', 'deploymentTargets_accounts' - The names of one or more Amazon Web Services accounts for which you want
-- to deploy stack set updates.
--
-- 'organizationalUnitIds', 'deploymentTargets_organizationalUnitIds' - The organization root ID or organizational unit (OU) IDs to which
-- StackSets deploys.
--
-- 'accountsUrl', 'deploymentTargets_accountsUrl' - Returns the value of the @AccountsUrl@ property.
newDeploymentTargets ::
  DeploymentTargets
newDeploymentTargets :: DeploymentTargets
newDeploymentTargets =
  DeploymentTargets' :: Maybe [Text] -> Maybe [Text] -> Maybe Text -> DeploymentTargets
DeploymentTargets'
    { $sel:accounts:DeploymentTargets' :: Maybe [Text]
accounts = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:organizationalUnitIds:DeploymentTargets' :: Maybe [Text]
organizationalUnitIds = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:accountsUrl:DeploymentTargets' :: Maybe Text
accountsUrl = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The names of one or more Amazon Web Services accounts for which you want
-- to deploy stack set updates.
deploymentTargets_accounts :: Lens.Lens' DeploymentTargets (Prelude.Maybe [Prelude.Text])
deploymentTargets_accounts :: (Maybe [Text] -> f (Maybe [Text]))
-> DeploymentTargets -> f DeploymentTargets
deploymentTargets_accounts = (DeploymentTargets -> Maybe [Text])
-> (DeploymentTargets -> Maybe [Text] -> DeploymentTargets)
-> Lens
     DeploymentTargets DeploymentTargets (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentTargets' {Maybe [Text]
accounts :: Maybe [Text]
$sel:accounts:DeploymentTargets' :: DeploymentTargets -> Maybe [Text]
accounts} -> Maybe [Text]
accounts) (\s :: DeploymentTargets
s@DeploymentTargets' {} Maybe [Text]
a -> DeploymentTargets
s {$sel:accounts:DeploymentTargets' :: Maybe [Text]
accounts = Maybe [Text]
a} :: DeploymentTargets) ((Maybe [Text] -> f (Maybe [Text]))
 -> DeploymentTargets -> f DeploymentTargets)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DeploymentTargets
-> f DeploymentTargets
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The organization root ID or organizational unit (OU) IDs to which
-- StackSets deploys.
deploymentTargets_organizationalUnitIds :: Lens.Lens' DeploymentTargets (Prelude.Maybe [Prelude.Text])
deploymentTargets_organizationalUnitIds :: (Maybe [Text] -> f (Maybe [Text]))
-> DeploymentTargets -> f DeploymentTargets
deploymentTargets_organizationalUnitIds = (DeploymentTargets -> Maybe [Text])
-> (DeploymentTargets -> Maybe [Text] -> DeploymentTargets)
-> Lens
     DeploymentTargets DeploymentTargets (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentTargets' {Maybe [Text]
organizationalUnitIds :: Maybe [Text]
$sel:organizationalUnitIds:DeploymentTargets' :: DeploymentTargets -> Maybe [Text]
organizationalUnitIds} -> Maybe [Text]
organizationalUnitIds) (\s :: DeploymentTargets
s@DeploymentTargets' {} Maybe [Text]
a -> DeploymentTargets
s {$sel:organizationalUnitIds:DeploymentTargets' :: Maybe [Text]
organizationalUnitIds = Maybe [Text]
a} :: DeploymentTargets) ((Maybe [Text] -> f (Maybe [Text]))
 -> DeploymentTargets -> f DeploymentTargets)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DeploymentTargets
-> f DeploymentTargets
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Returns the value of the @AccountsUrl@ property.
deploymentTargets_accountsUrl :: Lens.Lens' DeploymentTargets (Prelude.Maybe Prelude.Text)
deploymentTargets_accountsUrl :: (Maybe Text -> f (Maybe Text))
-> DeploymentTargets -> f DeploymentTargets
deploymentTargets_accountsUrl = (DeploymentTargets -> Maybe Text)
-> (DeploymentTargets -> Maybe Text -> DeploymentTargets)
-> Lens
     DeploymentTargets DeploymentTargets (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentTargets' {Maybe Text
accountsUrl :: Maybe Text
$sel:accountsUrl:DeploymentTargets' :: DeploymentTargets -> Maybe Text
accountsUrl} -> Maybe Text
accountsUrl) (\s :: DeploymentTargets
s@DeploymentTargets' {} Maybe Text
a -> DeploymentTargets
s {$sel:accountsUrl:DeploymentTargets' :: Maybe Text
accountsUrl = Maybe Text
a} :: DeploymentTargets)

instance Core.FromXML DeploymentTargets where
  parseXML :: [Node] -> Either String DeploymentTargets
parseXML [Node]
x =
    Maybe [Text] -> Maybe [Text] -> Maybe Text -> DeploymentTargets
DeploymentTargets'
      (Maybe [Text] -> Maybe [Text] -> Maybe Text -> DeploymentTargets)
-> Either String (Maybe [Text])
-> Either String (Maybe [Text] -> Maybe Text -> DeploymentTargets)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Accounts" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [Text]))
-> Either String (Maybe [Text])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Text])
-> [Node] -> Either String (Maybe [Text])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Text]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )
      Either String (Maybe [Text] -> Maybe Text -> DeploymentTargets)
-> Either String (Maybe [Text])
-> Either String (Maybe Text -> DeploymentTargets)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"OrganizationalUnitIds"
                      Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [Text]))
-> Either String (Maybe [Text])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Text])
-> [Node] -> Either String (Maybe [Text])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Text]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )
      Either String (Maybe Text -> DeploymentTargets)
-> Either String (Maybe Text) -> Either String DeploymentTargets
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"AccountsUrl")

instance Prelude.Hashable DeploymentTargets

instance Prelude.NFData DeploymentTargets

instance Core.ToQuery DeploymentTargets where
  toQuery :: DeploymentTargets -> QueryString
toQuery DeploymentTargets' {Maybe [Text]
Maybe Text
accountsUrl :: Maybe Text
organizationalUnitIds :: Maybe [Text]
accounts :: Maybe [Text]
$sel:accountsUrl:DeploymentTargets' :: DeploymentTargets -> Maybe Text
$sel:organizationalUnitIds:DeploymentTargets' :: DeploymentTargets -> Maybe [Text]
$sel:accounts:DeploymentTargets' :: DeploymentTargets -> Maybe [Text]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Accounts"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
accounts),
        ByteString
"OrganizationalUnitIds"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            ( ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member"
                ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
organizationalUnitIds
            ),
        ByteString
"AccountsUrl" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
accountsUrl
      ]