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

import Amazonka.CloudFormation.Types.AccountFilterType
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

-- | [Service-managed permissions] The Organizations accounts to which
-- StackSets deploys. StackSets doesn\'t 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'
  { -- | Limit deployment targets to individual accounts or include additional
    -- accounts with provided OUs.
    --
    -- The following is a list of possible values for the @AccountFilterType@
    -- operation.
    --
    -- -   @INTERSECTION@: StackSets deploys to the accounts specified in
    --     @Accounts@ parameter.
    --
    -- -   @DIFFERENCE@: StackSets excludes the accounts specified in
    --     @Accounts@ parameter. This enables user to avoid certain accounts
    --     within an OU such as suspended accounts.
    --
    -- -   @UNION@: StackSets includes additional accounts deployment targets.
    --
    --     This is the default value if @AccountFilterType@ is not provided.
    --     This enables user to update an entire OU and individual accounts
    --     from a different OU in one request, which used to be two separate
    --     requests.
    --
    -- -   @NONE@: Deploys to all the accounts in specified organizational
    --     units (OU).
    DeploymentTargets -> Maybe AccountFilterType
accountFilterType :: Prelude.Maybe AccountFilterType,
    -- | 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],
    -- | Returns the value of the @AccountsUrl@ property.
    DeploymentTargets -> Maybe Text
accountsUrl :: 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]
  }
  deriving (DeploymentTargets -> DeploymentTargets -> Bool
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]
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
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. 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:
--
-- 'accountFilterType', 'deploymentTargets_accountFilterType' - Limit deployment targets to individual accounts or include additional
-- accounts with provided OUs.
--
-- The following is a list of possible values for the @AccountFilterType@
-- operation.
--
-- -   @INTERSECTION@: StackSets deploys to the accounts specified in
--     @Accounts@ parameter.
--
-- -   @DIFFERENCE@: StackSets excludes the accounts specified in
--     @Accounts@ parameter. This enables user to avoid certain accounts
--     within an OU such as suspended accounts.
--
-- -   @UNION@: StackSets includes additional accounts deployment targets.
--
--     This is the default value if @AccountFilterType@ is not provided.
--     This enables user to update an entire OU and individual accounts
--     from a different OU in one request, which used to be two separate
--     requests.
--
-- -   @NONE@: Deploys to all the accounts in specified organizational
--     units (OU).
--
-- 'accounts', 'deploymentTargets_accounts' - The names of one or more Amazon Web Services accounts for which you want
-- to deploy stack set updates.
--
-- 'accountsUrl', 'deploymentTargets_accountsUrl' - Returns the value of the @AccountsUrl@ property.
--
-- 'organizationalUnitIds', 'deploymentTargets_organizationalUnitIds' - The organization root ID or organizational unit (OU) IDs to which
-- StackSets deploys.
newDeploymentTargets ::
  DeploymentTargets
newDeploymentTargets :: DeploymentTargets
newDeploymentTargets =
  DeploymentTargets'
    { $sel:accountFilterType:DeploymentTargets' :: Maybe AccountFilterType
accountFilterType =
        forall a. Maybe a
Prelude.Nothing,
      $sel:accounts:DeploymentTargets' :: Maybe [Text]
accounts = forall a. Maybe a
Prelude.Nothing,
      $sel:accountsUrl:DeploymentTargets' :: Maybe Text
accountsUrl = forall a. Maybe a
Prelude.Nothing,
      $sel:organizationalUnitIds:DeploymentTargets' :: Maybe [Text]
organizationalUnitIds = forall a. Maybe a
Prelude.Nothing
    }

-- | Limit deployment targets to individual accounts or include additional
-- accounts with provided OUs.
--
-- The following is a list of possible values for the @AccountFilterType@
-- operation.
--
-- -   @INTERSECTION@: StackSets deploys to the accounts specified in
--     @Accounts@ parameter.
--
-- -   @DIFFERENCE@: StackSets excludes the accounts specified in
--     @Accounts@ parameter. This enables user to avoid certain accounts
--     within an OU such as suspended accounts.
--
-- -   @UNION@: StackSets includes additional accounts deployment targets.
--
--     This is the default value if @AccountFilterType@ is not provided.
--     This enables user to update an entire OU and individual accounts
--     from a different OU in one request, which used to be two separate
--     requests.
--
-- -   @NONE@: Deploys to all the accounts in specified organizational
--     units (OU).
deploymentTargets_accountFilterType :: Lens.Lens' DeploymentTargets (Prelude.Maybe AccountFilterType)
deploymentTargets_accountFilterType :: Lens' DeploymentTargets (Maybe AccountFilterType)
deploymentTargets_accountFilterType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeploymentTargets' {Maybe AccountFilterType
accountFilterType :: Maybe AccountFilterType
$sel:accountFilterType:DeploymentTargets' :: DeploymentTargets -> Maybe AccountFilterType
accountFilterType} -> Maybe AccountFilterType
accountFilterType) (\s :: DeploymentTargets
s@DeploymentTargets' {} Maybe AccountFilterType
a -> DeploymentTargets
s {$sel:accountFilterType:DeploymentTargets' :: Maybe AccountFilterType
accountFilterType = Maybe AccountFilterType
a} :: DeploymentTargets)

-- | 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 :: Lens' DeploymentTargets (Maybe [Text])
deploymentTargets_accounts = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: Lens' DeploymentTargets (Maybe Text)
deploymentTargets_accountsUrl = 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)

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

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

instance Prelude.Hashable DeploymentTargets where
  hashWithSalt :: Int -> DeploymentTargets -> Int
hashWithSalt Int
_salt DeploymentTargets' {Maybe [Text]
Maybe Text
Maybe AccountFilterType
organizationalUnitIds :: Maybe [Text]
accountsUrl :: Maybe Text
accounts :: Maybe [Text]
accountFilterType :: Maybe AccountFilterType
$sel:organizationalUnitIds:DeploymentTargets' :: DeploymentTargets -> Maybe [Text]
$sel:accountsUrl:DeploymentTargets' :: DeploymentTargets -> Maybe Text
$sel:accounts:DeploymentTargets' :: DeploymentTargets -> Maybe [Text]
$sel:accountFilterType:DeploymentTargets' :: DeploymentTargets -> Maybe AccountFilterType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AccountFilterType
accountFilterType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
accounts
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
accountsUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Text]
organizationalUnitIds

instance Prelude.NFData DeploymentTargets where
  rnf :: DeploymentTargets -> ()
rnf DeploymentTargets' {Maybe [Text]
Maybe Text
Maybe AccountFilterType
organizationalUnitIds :: Maybe [Text]
accountsUrl :: Maybe Text
accounts :: Maybe [Text]
accountFilterType :: Maybe AccountFilterType
$sel:organizationalUnitIds:DeploymentTargets' :: DeploymentTargets -> Maybe [Text]
$sel:accountsUrl:DeploymentTargets' :: DeploymentTargets -> Maybe Text
$sel:accounts:DeploymentTargets' :: DeploymentTargets -> Maybe [Text]
$sel:accountFilterType:DeploymentTargets' :: DeploymentTargets -> Maybe AccountFilterType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AccountFilterType
accountFilterType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
accounts
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
accountsUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
organizationalUnitIds

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