{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.ListStackInstances
-- 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)
--
-- Returns summary information about stack instances that are associated
-- with the specified stack set. You can filter for stack instances that
-- are associated with a specific Amazon Web Services account name or
-- Region, or that have a specific status.
--
-- This operation returns paginated results.
module Amazonka.CloudFormation.ListStackInstances
  ( -- * Creating a Request
    ListStackInstances (..),
    newListStackInstances,

    -- * Request Lenses
    listStackInstances_stackInstanceRegion,
    listStackInstances_callAs,
    listStackInstances_filters,
    listStackInstances_nextToken,
    listStackInstances_stackInstanceAccount,
    listStackInstances_maxResults,
    listStackInstances_stackSetName,

    -- * Destructuring the Response
    ListStackInstancesResponse (..),
    newListStackInstancesResponse,

    -- * Response Lenses
    listStackInstancesResponse_nextToken,
    listStackInstancesResponse_summaries,
    listStackInstancesResponse_httpStatus,
  )
where

import Amazonka.CloudFormation.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListStackInstances' smart constructor.
data ListStackInstances = ListStackInstances'
  { -- | The name of the Region where you want to list stack instances.
    ListStackInstances -> Maybe Text
stackInstanceRegion :: Prelude.Maybe Prelude.Text,
    -- | [Service-managed permissions] Specifies whether you are acting as an
    -- account administrator in the organization\'s management account or as a
    -- delegated administrator in a member account.
    --
    -- By default, @SELF@ is specified. Use @SELF@ for stack sets with
    -- self-managed permissions.
    --
    -- -   If you are signed in to the management account, specify @SELF@.
    --
    -- -   If you are signed in to a delegated administrator account, specify
    --     @DELEGATED_ADMIN@.
    --
    --     Your Amazon Web Services account must be registered as a delegated
    --     administrator in the management account. For more information, see
    --     <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-orgs-delegated-admin.html Register a delegated administrator>
    --     in the /CloudFormation User Guide/.
    ListStackInstances -> Maybe CallAs
callAs :: Prelude.Maybe CallAs,
    -- | The status that stack instances are filtered by.
    ListStackInstances -> Maybe [StackInstanceFilter]
filters :: Prelude.Maybe [StackInstanceFilter],
    -- | If the previous request didn\'t return all of the remaining results, the
    -- response\'s @NextToken@ parameter value is set to a token. To retrieve
    -- the next set of results, call @ListStackInstances@ again and assign that
    -- token to the request object\'s @NextToken@ parameter. If there are no
    -- remaining results, the previous response object\'s @NextToken@ parameter
    -- is set to @null@.
    ListStackInstances -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The name of the Amazon Web Services account that you want to list stack
    -- instances for.
    ListStackInstances -> Maybe Text
stackInstanceAccount :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to be returned with a single call. If the
    -- number of available results exceeds this maximum, the response includes
    -- a @NextToken@ value that you can assign to the @NextToken@ request
    -- parameter to get the next set of results.
    ListStackInstances -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The name or unique ID of the stack set that you want to list stack
    -- instances for.
    ListStackInstances -> Text
stackSetName :: Prelude.Text
  }
  deriving (ListStackInstances -> ListStackInstances -> Bool
(ListStackInstances -> ListStackInstances -> Bool)
-> (ListStackInstances -> ListStackInstances -> Bool)
-> Eq ListStackInstances
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListStackInstances -> ListStackInstances -> Bool
$c/= :: ListStackInstances -> ListStackInstances -> Bool
== :: ListStackInstances -> ListStackInstances -> Bool
$c== :: ListStackInstances -> ListStackInstances -> Bool
Prelude.Eq, ReadPrec [ListStackInstances]
ReadPrec ListStackInstances
Int -> ReadS ListStackInstances
ReadS [ListStackInstances]
(Int -> ReadS ListStackInstances)
-> ReadS [ListStackInstances]
-> ReadPrec ListStackInstances
-> ReadPrec [ListStackInstances]
-> Read ListStackInstances
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListStackInstances]
$creadListPrec :: ReadPrec [ListStackInstances]
readPrec :: ReadPrec ListStackInstances
$creadPrec :: ReadPrec ListStackInstances
readList :: ReadS [ListStackInstances]
$creadList :: ReadS [ListStackInstances]
readsPrec :: Int -> ReadS ListStackInstances
$creadsPrec :: Int -> ReadS ListStackInstances
Prelude.Read, Int -> ListStackInstances -> ShowS
[ListStackInstances] -> ShowS
ListStackInstances -> String
(Int -> ListStackInstances -> ShowS)
-> (ListStackInstances -> String)
-> ([ListStackInstances] -> ShowS)
-> Show ListStackInstances
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListStackInstances] -> ShowS
$cshowList :: [ListStackInstances] -> ShowS
show :: ListStackInstances -> String
$cshow :: ListStackInstances -> String
showsPrec :: Int -> ListStackInstances -> ShowS
$cshowsPrec :: Int -> ListStackInstances -> ShowS
Prelude.Show, (forall x. ListStackInstances -> Rep ListStackInstances x)
-> (forall x. Rep ListStackInstances x -> ListStackInstances)
-> Generic ListStackInstances
forall x. Rep ListStackInstances x -> ListStackInstances
forall x. ListStackInstances -> Rep ListStackInstances x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListStackInstances x -> ListStackInstances
$cfrom :: forall x. ListStackInstances -> Rep ListStackInstances x
Prelude.Generic)

-- |
-- Create a value of 'ListStackInstances' 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:
--
-- 'stackInstanceRegion', 'listStackInstances_stackInstanceRegion' - The name of the Region where you want to list stack instances.
--
-- 'callAs', 'listStackInstances_callAs' - [Service-managed permissions] Specifies whether you are acting as an
-- account administrator in the organization\'s management account or as a
-- delegated administrator in a member account.
--
-- By default, @SELF@ is specified. Use @SELF@ for stack sets with
-- self-managed permissions.
--
-- -   If you are signed in to the management account, specify @SELF@.
--
-- -   If you are signed in to a delegated administrator account, specify
--     @DELEGATED_ADMIN@.
--
--     Your Amazon Web Services account must be registered as a delegated
--     administrator in the management account. For more information, see
--     <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-orgs-delegated-admin.html Register a delegated administrator>
--     in the /CloudFormation User Guide/.
--
-- 'filters', 'listStackInstances_filters' - The status that stack instances are filtered by.
--
-- 'nextToken', 'listStackInstances_nextToken' - If the previous request didn\'t return all of the remaining results, the
-- response\'s @NextToken@ parameter value is set to a token. To retrieve
-- the next set of results, call @ListStackInstances@ again and assign that
-- token to the request object\'s @NextToken@ parameter. If there are no
-- remaining results, the previous response object\'s @NextToken@ parameter
-- is set to @null@.
--
-- 'stackInstanceAccount', 'listStackInstances_stackInstanceAccount' - The name of the Amazon Web Services account that you want to list stack
-- instances for.
--
-- 'maxResults', 'listStackInstances_maxResults' - The maximum number of results to be returned with a single call. If the
-- number of available results exceeds this maximum, the response includes
-- a @NextToken@ value that you can assign to the @NextToken@ request
-- parameter to get the next set of results.
--
-- 'stackSetName', 'listStackInstances_stackSetName' - The name or unique ID of the stack set that you want to list stack
-- instances for.
newListStackInstances ::
  -- | 'stackSetName'
  Prelude.Text ->
  ListStackInstances
newListStackInstances :: Text -> ListStackInstances
newListStackInstances Text
pStackSetName_ =
  ListStackInstances' :: Maybe Text
-> Maybe CallAs
-> Maybe [StackInstanceFilter]
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> Text
-> ListStackInstances
ListStackInstances'
    { $sel:stackInstanceRegion:ListStackInstances' :: Maybe Text
stackInstanceRegion =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:callAs:ListStackInstances' :: Maybe CallAs
callAs = Maybe CallAs
forall a. Maybe a
Prelude.Nothing,
      $sel:filters:ListStackInstances' :: Maybe [StackInstanceFilter]
filters = Maybe [StackInstanceFilter]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListStackInstances' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:stackInstanceAccount:ListStackInstances' :: Maybe Text
stackInstanceAccount = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListStackInstances' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:stackSetName:ListStackInstances' :: Text
stackSetName = Text
pStackSetName_
    }

-- | The name of the Region where you want to list stack instances.
listStackInstances_stackInstanceRegion :: Lens.Lens' ListStackInstances (Prelude.Maybe Prelude.Text)
listStackInstances_stackInstanceRegion :: (Maybe Text -> f (Maybe Text))
-> ListStackInstances -> f ListStackInstances
listStackInstances_stackInstanceRegion = (ListStackInstances -> Maybe Text)
-> (ListStackInstances -> Maybe Text -> ListStackInstances)
-> Lens
     ListStackInstances ListStackInstances (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStackInstances' {Maybe Text
stackInstanceRegion :: Maybe Text
$sel:stackInstanceRegion:ListStackInstances' :: ListStackInstances -> Maybe Text
stackInstanceRegion} -> Maybe Text
stackInstanceRegion) (\s :: ListStackInstances
s@ListStackInstances' {} Maybe Text
a -> ListStackInstances
s {$sel:stackInstanceRegion:ListStackInstances' :: Maybe Text
stackInstanceRegion = Maybe Text
a} :: ListStackInstances)

-- | [Service-managed permissions] Specifies whether you are acting as an
-- account administrator in the organization\'s management account or as a
-- delegated administrator in a member account.
--
-- By default, @SELF@ is specified. Use @SELF@ for stack sets with
-- self-managed permissions.
--
-- -   If you are signed in to the management account, specify @SELF@.
--
-- -   If you are signed in to a delegated administrator account, specify
--     @DELEGATED_ADMIN@.
--
--     Your Amazon Web Services account must be registered as a delegated
--     administrator in the management account. For more information, see
--     <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-orgs-delegated-admin.html Register a delegated administrator>
--     in the /CloudFormation User Guide/.
listStackInstances_callAs :: Lens.Lens' ListStackInstances (Prelude.Maybe CallAs)
listStackInstances_callAs :: (Maybe CallAs -> f (Maybe CallAs))
-> ListStackInstances -> f ListStackInstances
listStackInstances_callAs = (ListStackInstances -> Maybe CallAs)
-> (ListStackInstances -> Maybe CallAs -> ListStackInstances)
-> Lens
     ListStackInstances ListStackInstances (Maybe CallAs) (Maybe CallAs)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStackInstances' {Maybe CallAs
callAs :: Maybe CallAs
$sel:callAs:ListStackInstances' :: ListStackInstances -> Maybe CallAs
callAs} -> Maybe CallAs
callAs) (\s :: ListStackInstances
s@ListStackInstances' {} Maybe CallAs
a -> ListStackInstances
s {$sel:callAs:ListStackInstances' :: Maybe CallAs
callAs = Maybe CallAs
a} :: ListStackInstances)

-- | The status that stack instances are filtered by.
listStackInstances_filters :: Lens.Lens' ListStackInstances (Prelude.Maybe [StackInstanceFilter])
listStackInstances_filters :: (Maybe [StackInstanceFilter] -> f (Maybe [StackInstanceFilter]))
-> ListStackInstances -> f ListStackInstances
listStackInstances_filters = (ListStackInstances -> Maybe [StackInstanceFilter])
-> (ListStackInstances
    -> Maybe [StackInstanceFilter] -> ListStackInstances)
-> Lens
     ListStackInstances
     ListStackInstances
     (Maybe [StackInstanceFilter])
     (Maybe [StackInstanceFilter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStackInstances' {Maybe [StackInstanceFilter]
filters :: Maybe [StackInstanceFilter]
$sel:filters:ListStackInstances' :: ListStackInstances -> Maybe [StackInstanceFilter]
filters} -> Maybe [StackInstanceFilter]
filters) (\s :: ListStackInstances
s@ListStackInstances' {} Maybe [StackInstanceFilter]
a -> ListStackInstances
s {$sel:filters:ListStackInstances' :: Maybe [StackInstanceFilter]
filters = Maybe [StackInstanceFilter]
a} :: ListStackInstances) ((Maybe [StackInstanceFilter] -> f (Maybe [StackInstanceFilter]))
 -> ListStackInstances -> f ListStackInstances)
-> ((Maybe [StackInstanceFilter]
     -> f (Maybe [StackInstanceFilter]))
    -> Maybe [StackInstanceFilter] -> f (Maybe [StackInstanceFilter]))
-> (Maybe [StackInstanceFilter] -> f (Maybe [StackInstanceFilter]))
-> ListStackInstances
-> f ListStackInstances
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [StackInstanceFilter]
  [StackInstanceFilter]
  [StackInstanceFilter]
  [StackInstanceFilter]
-> Iso
     (Maybe [StackInstanceFilter])
     (Maybe [StackInstanceFilter])
     (Maybe [StackInstanceFilter])
     (Maybe [StackInstanceFilter])
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
  [StackInstanceFilter]
  [StackInstanceFilter]
  [StackInstanceFilter]
  [StackInstanceFilter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | If the previous request didn\'t return all of the remaining results, the
-- response\'s @NextToken@ parameter value is set to a token. To retrieve
-- the next set of results, call @ListStackInstances@ again and assign that
-- token to the request object\'s @NextToken@ parameter. If there are no
-- remaining results, the previous response object\'s @NextToken@ parameter
-- is set to @null@.
listStackInstances_nextToken :: Lens.Lens' ListStackInstances (Prelude.Maybe Prelude.Text)
listStackInstances_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListStackInstances -> f ListStackInstances
listStackInstances_nextToken = (ListStackInstances -> Maybe Text)
-> (ListStackInstances -> Maybe Text -> ListStackInstances)
-> Lens
     ListStackInstances ListStackInstances (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStackInstances' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListStackInstances' :: ListStackInstances -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListStackInstances
s@ListStackInstances' {} Maybe Text
a -> ListStackInstances
s {$sel:nextToken:ListStackInstances' :: Maybe Text
nextToken = Maybe Text
a} :: ListStackInstances)

-- | The name of the Amazon Web Services account that you want to list stack
-- instances for.
listStackInstances_stackInstanceAccount :: Lens.Lens' ListStackInstances (Prelude.Maybe Prelude.Text)
listStackInstances_stackInstanceAccount :: (Maybe Text -> f (Maybe Text))
-> ListStackInstances -> f ListStackInstances
listStackInstances_stackInstanceAccount = (ListStackInstances -> Maybe Text)
-> (ListStackInstances -> Maybe Text -> ListStackInstances)
-> Lens
     ListStackInstances ListStackInstances (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStackInstances' {Maybe Text
stackInstanceAccount :: Maybe Text
$sel:stackInstanceAccount:ListStackInstances' :: ListStackInstances -> Maybe Text
stackInstanceAccount} -> Maybe Text
stackInstanceAccount) (\s :: ListStackInstances
s@ListStackInstances' {} Maybe Text
a -> ListStackInstances
s {$sel:stackInstanceAccount:ListStackInstances' :: Maybe Text
stackInstanceAccount = Maybe Text
a} :: ListStackInstances)

-- | The maximum number of results to be returned with a single call. If the
-- number of available results exceeds this maximum, the response includes
-- a @NextToken@ value that you can assign to the @NextToken@ request
-- parameter to get the next set of results.
listStackInstances_maxResults :: Lens.Lens' ListStackInstances (Prelude.Maybe Prelude.Natural)
listStackInstances_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListStackInstances -> f ListStackInstances
listStackInstances_maxResults = (ListStackInstances -> Maybe Natural)
-> (ListStackInstances -> Maybe Natural -> ListStackInstances)
-> Lens
     ListStackInstances
     ListStackInstances
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStackInstances' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListStackInstances' :: ListStackInstances -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListStackInstances
s@ListStackInstances' {} Maybe Natural
a -> ListStackInstances
s {$sel:maxResults:ListStackInstances' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListStackInstances)

-- | The name or unique ID of the stack set that you want to list stack
-- instances for.
listStackInstances_stackSetName :: Lens.Lens' ListStackInstances Prelude.Text
listStackInstances_stackSetName :: (Text -> f Text) -> ListStackInstances -> f ListStackInstances
listStackInstances_stackSetName = (ListStackInstances -> Text)
-> (ListStackInstances -> Text -> ListStackInstances)
-> Lens ListStackInstances ListStackInstances Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStackInstances' {Text
stackSetName :: Text
$sel:stackSetName:ListStackInstances' :: ListStackInstances -> Text
stackSetName} -> Text
stackSetName) (\s :: ListStackInstances
s@ListStackInstances' {} Text
a -> ListStackInstances
s {$sel:stackSetName:ListStackInstances' :: Text
stackSetName = Text
a} :: ListStackInstances)

instance Core.AWSPager ListStackInstances where
  page :: ListStackInstances
-> AWSResponse ListStackInstances -> Maybe ListStackInstances
page ListStackInstances
rq AWSResponse ListStackInstances
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListStackInstances
ListStackInstancesResponse
rs
            ListStackInstancesResponse
-> Getting (First Text) ListStackInstancesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListStackInstancesResponse
-> Const (First Text) ListStackInstancesResponse
Lens' ListStackInstancesResponse (Maybe Text)
listStackInstancesResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListStackInstancesResponse
 -> Const (First Text) ListStackInstancesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListStackInstancesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListStackInstances
forall a. Maybe a
Prelude.Nothing
    | Maybe [StackInstanceSummary] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListStackInstances
ListStackInstancesResponse
rs
            ListStackInstancesResponse
-> Getting
     (First [StackInstanceSummary])
     ListStackInstancesResponse
     [StackInstanceSummary]
-> Maybe [StackInstanceSummary]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [StackInstanceSummary]
 -> Const
      (First [StackInstanceSummary]) (Maybe [StackInstanceSummary]))
-> ListStackInstancesResponse
-> Const (First [StackInstanceSummary]) ListStackInstancesResponse
Lens' ListStackInstancesResponse (Maybe [StackInstanceSummary])
listStackInstancesResponse_summaries
              ((Maybe [StackInstanceSummary]
  -> Const
       (First [StackInstanceSummary]) (Maybe [StackInstanceSummary]))
 -> ListStackInstancesResponse
 -> Const (First [StackInstanceSummary]) ListStackInstancesResponse)
-> (([StackInstanceSummary]
     -> Const (First [StackInstanceSummary]) [StackInstanceSummary])
    -> Maybe [StackInstanceSummary]
    -> Const
         (First [StackInstanceSummary]) (Maybe [StackInstanceSummary]))
-> Getting
     (First [StackInstanceSummary])
     ListStackInstancesResponse
     [StackInstanceSummary]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([StackInstanceSummary]
 -> Const (First [StackInstanceSummary]) [StackInstanceSummary])
-> Maybe [StackInstanceSummary]
-> Const
     (First [StackInstanceSummary]) (Maybe [StackInstanceSummary])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListStackInstances
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListStackInstances -> Maybe ListStackInstances
forall a. a -> Maybe a
Prelude.Just (ListStackInstances -> Maybe ListStackInstances)
-> ListStackInstances -> Maybe ListStackInstances
forall a b. (a -> b) -> a -> b
Prelude.$
        ListStackInstances
rq
          ListStackInstances
-> (ListStackInstances -> ListStackInstances) -> ListStackInstances
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListStackInstances -> Identity ListStackInstances
Lens
  ListStackInstances ListStackInstances (Maybe Text) (Maybe Text)
listStackInstances_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListStackInstances -> Identity ListStackInstances)
-> Maybe Text -> ListStackInstances -> ListStackInstances
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListStackInstances
ListStackInstancesResponse
rs
          ListStackInstancesResponse
-> Getting (First Text) ListStackInstancesResponse Text
-> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListStackInstancesResponse
-> Const (First Text) ListStackInstancesResponse
Lens' ListStackInstancesResponse (Maybe Text)
listStackInstancesResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListStackInstancesResponse
 -> Const (First Text) ListStackInstancesResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListStackInstancesResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListStackInstances where
  type
    AWSResponse ListStackInstances =
      ListStackInstancesResponse
  request :: ListStackInstances -> Request ListStackInstances
request = Service -> ListStackInstances -> Request ListStackInstances
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy ListStackInstances
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListStackInstances)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse ListStackInstances))
-> Logger
-> Service
-> Proxy ListStackInstances
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListStackInstances)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"ListStackInstancesResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text
-> Maybe [StackInstanceSummary]
-> Int
-> ListStackInstancesResponse
ListStackInstancesResponse'
            (Maybe Text
 -> Maybe [StackInstanceSummary]
 -> Int
 -> ListStackInstancesResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe [StackInstanceSummary] -> Int -> ListStackInstancesResponse)
forall (f :: * -> *) a b. Functor 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
"NextToken")
            Either
  String
  (Maybe [StackInstanceSummary] -> Int -> ListStackInstancesResponse)
-> Either String (Maybe [StackInstanceSummary])
-> Either String (Int -> ListStackInstancesResponse)
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
"Summaries" 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 [StackInstanceSummary]))
-> Either String (Maybe [StackInstanceSummary])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [StackInstanceSummary])
-> [Node] -> Either String (Maybe [StackInstanceSummary])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [StackInstanceSummary]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                        )
            Either String (Int -> ListStackInstancesResponse)
-> Either String Int -> Either String ListStackInstancesResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListStackInstances

instance Prelude.NFData ListStackInstances

instance Core.ToHeaders ListStackInstances where
  toHeaders :: ListStackInstances -> ResponseHeaders
toHeaders = ResponseHeaders -> ListStackInstances -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath ListStackInstances where
  toPath :: ListStackInstances -> ByteString
toPath = ByteString -> ListStackInstances -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery ListStackInstances where
  toQuery :: ListStackInstances -> QueryString
toQuery ListStackInstances' {Maybe Natural
Maybe [StackInstanceFilter]
Maybe Text
Maybe CallAs
Text
stackSetName :: Text
maxResults :: Maybe Natural
stackInstanceAccount :: Maybe Text
nextToken :: Maybe Text
filters :: Maybe [StackInstanceFilter]
callAs :: Maybe CallAs
stackInstanceRegion :: Maybe Text
$sel:stackSetName:ListStackInstances' :: ListStackInstances -> Text
$sel:maxResults:ListStackInstances' :: ListStackInstances -> Maybe Natural
$sel:stackInstanceAccount:ListStackInstances' :: ListStackInstances -> Maybe Text
$sel:nextToken:ListStackInstances' :: ListStackInstances -> Maybe Text
$sel:filters:ListStackInstances' :: ListStackInstances -> Maybe [StackInstanceFilter]
$sel:callAs:ListStackInstances' :: ListStackInstances -> Maybe CallAs
$sel:stackInstanceRegion:ListStackInstances' :: ListStackInstances -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"ListStackInstances" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-15" :: Prelude.ByteString),
        ByteString
"StackInstanceRegion" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
stackInstanceRegion,
        ByteString
"CallAs" ByteString -> Maybe CallAs -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe CallAs
callAs,
        ByteString
"Filters"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [StackInstanceFilter] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([StackInstanceFilter] -> QueryString)
-> Maybe [StackInstanceFilter] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [StackInstanceFilter]
filters),
        ByteString
"NextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
        ByteString
"StackInstanceAccount" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
stackInstanceAccount,
        ByteString
"MaxResults" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
maxResults,
        ByteString
"StackSetName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
stackSetName
      ]

-- | /See:/ 'newListStackInstancesResponse' smart constructor.
data ListStackInstancesResponse = ListStackInstancesResponse'
  { -- | If the request doesn\'t return all of the remaining results, @NextToken@
    -- is set to a token. To retrieve the next set of results, call
    -- @ListStackInstances@ again and assign that token to the request
    -- object\'s @NextToken@ parameter. If the request returns all results,
    -- @NextToken@ is set to @null@.
    ListStackInstancesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of @StackInstanceSummary@ structures that contain information
    -- about the specified stack instances.
    ListStackInstancesResponse -> Maybe [StackInstanceSummary]
summaries :: Prelude.Maybe [StackInstanceSummary],
    -- | The response's http status code.
    ListStackInstancesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListStackInstancesResponse -> ListStackInstancesResponse -> Bool
(ListStackInstancesResponse -> ListStackInstancesResponse -> Bool)
-> (ListStackInstancesResponse
    -> ListStackInstancesResponse -> Bool)
-> Eq ListStackInstancesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListStackInstancesResponse -> ListStackInstancesResponse -> Bool
$c/= :: ListStackInstancesResponse -> ListStackInstancesResponse -> Bool
== :: ListStackInstancesResponse -> ListStackInstancesResponse -> Bool
$c== :: ListStackInstancesResponse -> ListStackInstancesResponse -> Bool
Prelude.Eq, ReadPrec [ListStackInstancesResponse]
ReadPrec ListStackInstancesResponse
Int -> ReadS ListStackInstancesResponse
ReadS [ListStackInstancesResponse]
(Int -> ReadS ListStackInstancesResponse)
-> ReadS [ListStackInstancesResponse]
-> ReadPrec ListStackInstancesResponse
-> ReadPrec [ListStackInstancesResponse]
-> Read ListStackInstancesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListStackInstancesResponse]
$creadListPrec :: ReadPrec [ListStackInstancesResponse]
readPrec :: ReadPrec ListStackInstancesResponse
$creadPrec :: ReadPrec ListStackInstancesResponse
readList :: ReadS [ListStackInstancesResponse]
$creadList :: ReadS [ListStackInstancesResponse]
readsPrec :: Int -> ReadS ListStackInstancesResponse
$creadsPrec :: Int -> ReadS ListStackInstancesResponse
Prelude.Read, Int -> ListStackInstancesResponse -> ShowS
[ListStackInstancesResponse] -> ShowS
ListStackInstancesResponse -> String
(Int -> ListStackInstancesResponse -> ShowS)
-> (ListStackInstancesResponse -> String)
-> ([ListStackInstancesResponse] -> ShowS)
-> Show ListStackInstancesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListStackInstancesResponse] -> ShowS
$cshowList :: [ListStackInstancesResponse] -> ShowS
show :: ListStackInstancesResponse -> String
$cshow :: ListStackInstancesResponse -> String
showsPrec :: Int -> ListStackInstancesResponse -> ShowS
$cshowsPrec :: Int -> ListStackInstancesResponse -> ShowS
Prelude.Show, (forall x.
 ListStackInstancesResponse -> Rep ListStackInstancesResponse x)
-> (forall x.
    Rep ListStackInstancesResponse x -> ListStackInstancesResponse)
-> Generic ListStackInstancesResponse
forall x.
Rep ListStackInstancesResponse x -> ListStackInstancesResponse
forall x.
ListStackInstancesResponse -> Rep ListStackInstancesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListStackInstancesResponse x -> ListStackInstancesResponse
$cfrom :: forall x.
ListStackInstancesResponse -> Rep ListStackInstancesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListStackInstancesResponse' 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:
--
-- 'nextToken', 'listStackInstancesResponse_nextToken' - If the request doesn\'t return all of the remaining results, @NextToken@
-- is set to a token. To retrieve the next set of results, call
-- @ListStackInstances@ again and assign that token to the request
-- object\'s @NextToken@ parameter. If the request returns all results,
-- @NextToken@ is set to @null@.
--
-- 'summaries', 'listStackInstancesResponse_summaries' - A list of @StackInstanceSummary@ structures that contain information
-- about the specified stack instances.
--
-- 'httpStatus', 'listStackInstancesResponse_httpStatus' - The response's http status code.
newListStackInstancesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListStackInstancesResponse
newListStackInstancesResponse :: Int -> ListStackInstancesResponse
newListStackInstancesResponse Int
pHttpStatus_ =
  ListStackInstancesResponse' :: Maybe Text
-> Maybe [StackInstanceSummary]
-> Int
-> ListStackInstancesResponse
ListStackInstancesResponse'
    { $sel:nextToken:ListStackInstancesResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:summaries:ListStackInstancesResponse' :: Maybe [StackInstanceSummary]
summaries = Maybe [StackInstanceSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListStackInstancesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | If the request doesn\'t return all of the remaining results, @NextToken@
-- is set to a token. To retrieve the next set of results, call
-- @ListStackInstances@ again and assign that token to the request
-- object\'s @NextToken@ parameter. If the request returns all results,
-- @NextToken@ is set to @null@.
listStackInstancesResponse_nextToken :: Lens.Lens' ListStackInstancesResponse (Prelude.Maybe Prelude.Text)
listStackInstancesResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListStackInstancesResponse -> f ListStackInstancesResponse
listStackInstancesResponse_nextToken = (ListStackInstancesResponse -> Maybe Text)
-> (ListStackInstancesResponse
    -> Maybe Text -> ListStackInstancesResponse)
-> Lens' ListStackInstancesResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStackInstancesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListStackInstancesResponse' :: ListStackInstancesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListStackInstancesResponse
s@ListStackInstancesResponse' {} Maybe Text
a -> ListStackInstancesResponse
s {$sel:nextToken:ListStackInstancesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListStackInstancesResponse)

-- | A list of @StackInstanceSummary@ structures that contain information
-- about the specified stack instances.
listStackInstancesResponse_summaries :: Lens.Lens' ListStackInstancesResponse (Prelude.Maybe [StackInstanceSummary])
listStackInstancesResponse_summaries :: (Maybe [StackInstanceSummary] -> f (Maybe [StackInstanceSummary]))
-> ListStackInstancesResponse -> f ListStackInstancesResponse
listStackInstancesResponse_summaries = (ListStackInstancesResponse -> Maybe [StackInstanceSummary])
-> (ListStackInstancesResponse
    -> Maybe [StackInstanceSummary] -> ListStackInstancesResponse)
-> Lens' ListStackInstancesResponse (Maybe [StackInstanceSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStackInstancesResponse' {Maybe [StackInstanceSummary]
summaries :: Maybe [StackInstanceSummary]
$sel:summaries:ListStackInstancesResponse' :: ListStackInstancesResponse -> Maybe [StackInstanceSummary]
summaries} -> Maybe [StackInstanceSummary]
summaries) (\s :: ListStackInstancesResponse
s@ListStackInstancesResponse' {} Maybe [StackInstanceSummary]
a -> ListStackInstancesResponse
s {$sel:summaries:ListStackInstancesResponse' :: Maybe [StackInstanceSummary]
summaries = Maybe [StackInstanceSummary]
a} :: ListStackInstancesResponse) ((Maybe [StackInstanceSummary] -> f (Maybe [StackInstanceSummary]))
 -> ListStackInstancesResponse -> f ListStackInstancesResponse)
-> ((Maybe [StackInstanceSummary]
     -> f (Maybe [StackInstanceSummary]))
    -> Maybe [StackInstanceSummary]
    -> f (Maybe [StackInstanceSummary]))
-> (Maybe [StackInstanceSummary]
    -> f (Maybe [StackInstanceSummary]))
-> ListStackInstancesResponse
-> f ListStackInstancesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [StackInstanceSummary]
  [StackInstanceSummary]
  [StackInstanceSummary]
  [StackInstanceSummary]
-> Iso
     (Maybe [StackInstanceSummary])
     (Maybe [StackInstanceSummary])
     (Maybe [StackInstanceSummary])
     (Maybe [StackInstanceSummary])
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
  [StackInstanceSummary]
  [StackInstanceSummary]
  [StackInstanceSummary]
  [StackInstanceSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
listStackInstancesResponse_httpStatus :: Lens.Lens' ListStackInstancesResponse Prelude.Int
listStackInstancesResponse_httpStatus :: (Int -> f Int)
-> ListStackInstancesResponse -> f ListStackInstancesResponse
listStackInstancesResponse_httpStatus = (ListStackInstancesResponse -> Int)
-> (ListStackInstancesResponse
    -> Int -> ListStackInstancesResponse)
-> Lens
     ListStackInstancesResponse ListStackInstancesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStackInstancesResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListStackInstancesResponse' :: ListStackInstancesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListStackInstancesResponse
s@ListStackInstancesResponse' {} Int
a -> ListStackInstancesResponse
s {$sel:httpStatus:ListStackInstancesResponse' :: Int
httpStatus = Int
a} :: ListStackInstancesResponse)

instance Prelude.NFData ListStackInstancesResponse