{-# 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.ListExports
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists all exported output values in the account and Region in which you
-- call this action. Use this action to see the exported output values that
-- you can import into other stacks. To import values, use the
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-importvalue.html Fn::ImportValue>
-- function.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-stack-exports.html CloudFormation export stack output values>.
--
-- This operation returns paginated results.
module Amazonka.CloudFormation.ListExports
  ( -- * Creating a Request
    ListExports (..),
    newListExports,

    -- * Request Lenses
    listExports_nextToken,

    -- * Destructuring the Response
    ListExportsResponse (..),
    newListExportsResponse,

    -- * Response Lenses
    listExportsResponse_exports,
    listExportsResponse_nextToken,
    listExportsResponse_httpStatus,
  )
where

import Amazonka.CloudFormation.Types
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
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListExports' smart constructor.
data ListExports = ListExports'
  { -- | A string (provided by the ListExports response output) that identifies
    -- the next page of exported output values that you asked to retrieve.
    ListExports -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListExports -> ListExports -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListExports -> ListExports -> Bool
$c/= :: ListExports -> ListExports -> Bool
== :: ListExports -> ListExports -> Bool
$c== :: ListExports -> ListExports -> Bool
Prelude.Eq, ReadPrec [ListExports]
ReadPrec ListExports
Int -> ReadS ListExports
ReadS [ListExports]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListExports]
$creadListPrec :: ReadPrec [ListExports]
readPrec :: ReadPrec ListExports
$creadPrec :: ReadPrec ListExports
readList :: ReadS [ListExports]
$creadList :: ReadS [ListExports]
readsPrec :: Int -> ReadS ListExports
$creadsPrec :: Int -> ReadS ListExports
Prelude.Read, Int -> ListExports -> ShowS
[ListExports] -> ShowS
ListExports -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListExports] -> ShowS
$cshowList :: [ListExports] -> ShowS
show :: ListExports -> String
$cshow :: ListExports -> String
showsPrec :: Int -> ListExports -> ShowS
$cshowsPrec :: Int -> ListExports -> ShowS
Prelude.Show, forall x. Rep ListExports x -> ListExports
forall x. ListExports -> Rep ListExports x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListExports x -> ListExports
$cfrom :: forall x. ListExports -> Rep ListExports x
Prelude.Generic)

-- |
-- Create a value of 'ListExports' 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', 'listExports_nextToken' - A string (provided by the ListExports response output) that identifies
-- the next page of exported output values that you asked to retrieve.
newListExports ::
  ListExports
newListExports :: ListExports
newListExports =
  ListExports' {$sel:nextToken:ListExports' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing}

-- | A string (provided by the ListExports response output) that identifies
-- the next page of exported output values that you asked to retrieve.
listExports_nextToken :: Lens.Lens' ListExports (Prelude.Maybe Prelude.Text)
listExports_nextToken :: Lens' ListExports (Maybe Text)
listExports_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListExports' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListExports' :: ListExports -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListExports
s@ListExports' {} Maybe Text
a -> ListExports
s {$sel:nextToken:ListExports' :: Maybe Text
nextToken = Maybe Text
a} :: ListExports)

instance Core.AWSPager ListExports where
  page :: ListExports -> AWSResponse ListExports -> Maybe ListExports
page ListExports
rq AWSResponse ListExports
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListExports
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListExportsResponse (Maybe Text)
listExportsResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListExports
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListExportsResponse (Maybe [Export])
listExportsResponse_exports
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListExports
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListExports (Maybe Text)
listExports_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListExports
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListExportsResponse (Maybe Text)
listExportsResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListExports where
  type AWSResponse ListExports = ListExportsResponse
  request :: (Service -> Service) -> ListExports -> Request ListExports
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListExports
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListExports)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"ListExportsResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe [Export] -> Maybe Text -> Int -> ListExportsResponse
ListExportsResponse'
            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
"Exports"
                            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
"NextToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListExports where
  hashWithSalt :: Int -> ListExports -> Int
hashWithSalt Int
_salt ListExports' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListExports' :: ListExports -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData ListExports where
  rnf :: ListExports -> ()
rnf ListExports' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListExports' :: ListExports -> Maybe Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

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

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

instance Data.ToQuery ListExports where
  toQuery :: ListExports -> QueryString
toQuery ListExports' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListExports' :: ListExports -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"ListExports" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-05-15" :: Prelude.ByteString),
        ByteString
"NextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newListExportsResponse' smart constructor.
data ListExportsResponse = ListExportsResponse'
  { -- | The output for the ListExports action.
    ListExportsResponse -> Maybe [Export]
exports :: Prelude.Maybe [Export],
    -- | If the output exceeds 100 exported output values, a string that
    -- identifies the next page of exports. If there is no additional page,
    -- this value is null.
    ListExportsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListExportsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListExportsResponse -> ListExportsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListExportsResponse -> ListExportsResponse -> Bool
$c/= :: ListExportsResponse -> ListExportsResponse -> Bool
== :: ListExportsResponse -> ListExportsResponse -> Bool
$c== :: ListExportsResponse -> ListExportsResponse -> Bool
Prelude.Eq, ReadPrec [ListExportsResponse]
ReadPrec ListExportsResponse
Int -> ReadS ListExportsResponse
ReadS [ListExportsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListExportsResponse]
$creadListPrec :: ReadPrec [ListExportsResponse]
readPrec :: ReadPrec ListExportsResponse
$creadPrec :: ReadPrec ListExportsResponse
readList :: ReadS [ListExportsResponse]
$creadList :: ReadS [ListExportsResponse]
readsPrec :: Int -> ReadS ListExportsResponse
$creadsPrec :: Int -> ReadS ListExportsResponse
Prelude.Read, Int -> ListExportsResponse -> ShowS
[ListExportsResponse] -> ShowS
ListExportsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListExportsResponse] -> ShowS
$cshowList :: [ListExportsResponse] -> ShowS
show :: ListExportsResponse -> String
$cshow :: ListExportsResponse -> String
showsPrec :: Int -> ListExportsResponse -> ShowS
$cshowsPrec :: Int -> ListExportsResponse -> ShowS
Prelude.Show, forall x. Rep ListExportsResponse x -> ListExportsResponse
forall x. ListExportsResponse -> Rep ListExportsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListExportsResponse x -> ListExportsResponse
$cfrom :: forall x. ListExportsResponse -> Rep ListExportsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListExportsResponse' 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:
--
-- 'exports', 'listExportsResponse_exports' - The output for the ListExports action.
--
-- 'nextToken', 'listExportsResponse_nextToken' - If the output exceeds 100 exported output values, a string that
-- identifies the next page of exports. If there is no additional page,
-- this value is null.
--
-- 'httpStatus', 'listExportsResponse_httpStatus' - The response's http status code.
newListExportsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListExportsResponse
newListExportsResponse :: Int -> ListExportsResponse
newListExportsResponse Int
pHttpStatus_ =
  ListExportsResponse'
    { $sel:exports:ListExportsResponse' :: Maybe [Export]
exports = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListExportsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListExportsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The output for the ListExports action.
listExportsResponse_exports :: Lens.Lens' ListExportsResponse (Prelude.Maybe [Export])
listExportsResponse_exports :: Lens' ListExportsResponse (Maybe [Export])
listExportsResponse_exports = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListExportsResponse' {Maybe [Export]
exports :: Maybe [Export]
$sel:exports:ListExportsResponse' :: ListExportsResponse -> Maybe [Export]
exports} -> Maybe [Export]
exports) (\s :: ListExportsResponse
s@ListExportsResponse' {} Maybe [Export]
a -> ListExportsResponse
s {$sel:exports:ListExportsResponse' :: Maybe [Export]
exports = Maybe [Export]
a} :: ListExportsResponse) 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

-- | If the output exceeds 100 exported output values, a string that
-- identifies the next page of exports. If there is no additional page,
-- this value is null.
listExportsResponse_nextToken :: Lens.Lens' ListExportsResponse (Prelude.Maybe Prelude.Text)
listExportsResponse_nextToken :: Lens' ListExportsResponse (Maybe Text)
listExportsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListExportsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListExportsResponse' :: ListExportsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListExportsResponse
s@ListExportsResponse' {} Maybe Text
a -> ListExportsResponse
s {$sel:nextToken:ListExportsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListExportsResponse)

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

instance Prelude.NFData ListExportsResponse where
  rnf :: ListExportsResponse -> ()
rnf ListExportsResponse' {Int
Maybe [Export]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
exports :: Maybe [Export]
$sel:httpStatus:ListExportsResponse' :: ListExportsResponse -> Int
$sel:nextToken:ListExportsResponse' :: ListExportsResponse -> Maybe Text
$sel:exports:ListExportsResponse' :: ListExportsResponse -> Maybe [Export]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Export]
exports
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus