{-# 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.DrS.ListStagingAccounts
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns an array of staging accounts for existing extended source
-- servers.
--
-- This operation returns paginated results.
module Amazonka.DrS.ListStagingAccounts
  ( -- * Creating a Request
    ListStagingAccounts (..),
    newListStagingAccounts,

    -- * Request Lenses
    listStagingAccounts_maxResults,
    listStagingAccounts_nextToken,

    -- * Destructuring the Response
    ListStagingAccountsResponse (..),
    newListStagingAccountsResponse,

    -- * Response Lenses
    listStagingAccountsResponse_accounts,
    listStagingAccountsResponse_nextToken,
    listStagingAccountsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DrS.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListStagingAccounts' smart constructor.
data ListStagingAccounts = ListStagingAccounts'
  { -- | The maximum number of staging Accounts to retrieve.
    ListStagingAccounts -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token of the next staging Account to retrieve.
    ListStagingAccounts -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListStagingAccounts -> ListStagingAccounts -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListStagingAccounts -> ListStagingAccounts -> Bool
$c/= :: ListStagingAccounts -> ListStagingAccounts -> Bool
== :: ListStagingAccounts -> ListStagingAccounts -> Bool
$c== :: ListStagingAccounts -> ListStagingAccounts -> Bool
Prelude.Eq, ReadPrec [ListStagingAccounts]
ReadPrec ListStagingAccounts
Int -> ReadS ListStagingAccounts
ReadS [ListStagingAccounts]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListStagingAccounts]
$creadListPrec :: ReadPrec [ListStagingAccounts]
readPrec :: ReadPrec ListStagingAccounts
$creadPrec :: ReadPrec ListStagingAccounts
readList :: ReadS [ListStagingAccounts]
$creadList :: ReadS [ListStagingAccounts]
readsPrec :: Int -> ReadS ListStagingAccounts
$creadsPrec :: Int -> ReadS ListStagingAccounts
Prelude.Read, Int -> ListStagingAccounts -> ShowS
[ListStagingAccounts] -> ShowS
ListStagingAccounts -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListStagingAccounts] -> ShowS
$cshowList :: [ListStagingAccounts] -> ShowS
show :: ListStagingAccounts -> String
$cshow :: ListStagingAccounts -> String
showsPrec :: Int -> ListStagingAccounts -> ShowS
$cshowsPrec :: Int -> ListStagingAccounts -> ShowS
Prelude.Show, forall x. Rep ListStagingAccounts x -> ListStagingAccounts
forall x. ListStagingAccounts -> Rep ListStagingAccounts x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListStagingAccounts x -> ListStagingAccounts
$cfrom :: forall x. ListStagingAccounts -> Rep ListStagingAccounts x
Prelude.Generic)

-- |
-- Create a value of 'ListStagingAccounts' 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:
--
-- 'maxResults', 'listStagingAccounts_maxResults' - The maximum number of staging Accounts to retrieve.
--
-- 'nextToken', 'listStagingAccounts_nextToken' - The token of the next staging Account to retrieve.
newListStagingAccounts ::
  ListStagingAccounts
newListStagingAccounts :: ListStagingAccounts
newListStagingAccounts =
  ListStagingAccounts'
    { $sel:maxResults:ListStagingAccounts' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListStagingAccounts' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of staging Accounts to retrieve.
listStagingAccounts_maxResults :: Lens.Lens' ListStagingAccounts (Prelude.Maybe Prelude.Natural)
listStagingAccounts_maxResults :: Lens' ListStagingAccounts (Maybe Natural)
listStagingAccounts_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStagingAccounts' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListStagingAccounts' :: ListStagingAccounts -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListStagingAccounts
s@ListStagingAccounts' {} Maybe Natural
a -> ListStagingAccounts
s {$sel:maxResults:ListStagingAccounts' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListStagingAccounts)

-- | The token of the next staging Account to retrieve.
listStagingAccounts_nextToken :: Lens.Lens' ListStagingAccounts (Prelude.Maybe Prelude.Text)
listStagingAccounts_nextToken :: Lens' ListStagingAccounts (Maybe Text)
listStagingAccounts_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStagingAccounts' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListStagingAccounts' :: ListStagingAccounts -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListStagingAccounts
s@ListStagingAccounts' {} Maybe Text
a -> ListStagingAccounts
s {$sel:nextToken:ListStagingAccounts' :: Maybe Text
nextToken = Maybe Text
a} :: ListStagingAccounts)

instance Core.AWSPager ListStagingAccounts where
  page :: ListStagingAccounts
-> AWSResponse ListStagingAccounts -> Maybe ListStagingAccounts
page ListStagingAccounts
rq AWSResponse ListStagingAccounts
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListStagingAccounts
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListStagingAccountsResponse (Maybe Text)
listStagingAccountsResponse_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 ListStagingAccounts
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListStagingAccountsResponse (Maybe [Account])
listStagingAccountsResponse_accounts
            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.$ ListStagingAccounts
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListStagingAccounts (Maybe Text)
listStagingAccounts_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListStagingAccounts
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListStagingAccountsResponse (Maybe Text)
listStagingAccountsResponse_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 ListStagingAccounts where
  type
    AWSResponse ListStagingAccounts =
      ListStagingAccountsResponse
  request :: (Service -> Service)
-> ListStagingAccounts -> Request ListStagingAccounts
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListStagingAccounts
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListStagingAccounts)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Account] -> Maybe Text -> Int -> ListStagingAccountsResponse
ListStagingAccountsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"accounts" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"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 ListStagingAccounts where
  hashWithSalt :: Int -> ListStagingAccounts -> Int
hashWithSalt Int
_salt ListStagingAccounts' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListStagingAccounts' :: ListStagingAccounts -> Maybe Text
$sel:maxResults:ListStagingAccounts' :: ListStagingAccounts -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData ListStagingAccounts where
  rnf :: ListStagingAccounts -> ()
rnf ListStagingAccounts' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListStagingAccounts' :: ListStagingAccounts -> Maybe Text
$sel:maxResults:ListStagingAccounts' :: ListStagingAccounts -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

instance Data.ToHeaders ListStagingAccounts where
  toHeaders :: ListStagingAccounts -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

instance Data.ToQuery ListStagingAccounts where
  toQuery :: ListStagingAccounts -> QueryString
toQuery ListStagingAccounts' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListStagingAccounts' :: ListStagingAccounts -> Maybe Text
$sel:maxResults:ListStagingAccounts' :: ListStagingAccounts -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newListStagingAccountsResponse' smart constructor.
data ListStagingAccountsResponse = ListStagingAccountsResponse'
  { -- | An array of staging AWS Accounts.
    ListStagingAccountsResponse -> Maybe [Account]
accounts :: Prelude.Maybe [Account],
    -- | The token of the next staging Account to retrieve.
    ListStagingAccountsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListStagingAccountsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListStagingAccountsResponse -> ListStagingAccountsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListStagingAccountsResponse -> ListStagingAccountsResponse -> Bool
$c/= :: ListStagingAccountsResponse -> ListStagingAccountsResponse -> Bool
== :: ListStagingAccountsResponse -> ListStagingAccountsResponse -> Bool
$c== :: ListStagingAccountsResponse -> ListStagingAccountsResponse -> Bool
Prelude.Eq, ReadPrec [ListStagingAccountsResponse]
ReadPrec ListStagingAccountsResponse
Int -> ReadS ListStagingAccountsResponse
ReadS [ListStagingAccountsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListStagingAccountsResponse]
$creadListPrec :: ReadPrec [ListStagingAccountsResponse]
readPrec :: ReadPrec ListStagingAccountsResponse
$creadPrec :: ReadPrec ListStagingAccountsResponse
readList :: ReadS [ListStagingAccountsResponse]
$creadList :: ReadS [ListStagingAccountsResponse]
readsPrec :: Int -> ReadS ListStagingAccountsResponse
$creadsPrec :: Int -> ReadS ListStagingAccountsResponse
Prelude.Read, Int -> ListStagingAccountsResponse -> ShowS
[ListStagingAccountsResponse] -> ShowS
ListStagingAccountsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListStagingAccountsResponse] -> ShowS
$cshowList :: [ListStagingAccountsResponse] -> ShowS
show :: ListStagingAccountsResponse -> String
$cshow :: ListStagingAccountsResponse -> String
showsPrec :: Int -> ListStagingAccountsResponse -> ShowS
$cshowsPrec :: Int -> ListStagingAccountsResponse -> ShowS
Prelude.Show, forall x.
Rep ListStagingAccountsResponse x -> ListStagingAccountsResponse
forall x.
ListStagingAccountsResponse -> Rep ListStagingAccountsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListStagingAccountsResponse x -> ListStagingAccountsResponse
$cfrom :: forall x.
ListStagingAccountsResponse -> Rep ListStagingAccountsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListStagingAccountsResponse' 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', 'listStagingAccountsResponse_accounts' - An array of staging AWS Accounts.
--
-- 'nextToken', 'listStagingAccountsResponse_nextToken' - The token of the next staging Account to retrieve.
--
-- 'httpStatus', 'listStagingAccountsResponse_httpStatus' - The response's http status code.
newListStagingAccountsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListStagingAccountsResponse
newListStagingAccountsResponse :: Int -> ListStagingAccountsResponse
newListStagingAccountsResponse Int
pHttpStatus_ =
  ListStagingAccountsResponse'
    { $sel:accounts:ListStagingAccountsResponse' :: Maybe [Account]
accounts =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListStagingAccountsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListStagingAccountsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of staging AWS Accounts.
listStagingAccountsResponse_accounts :: Lens.Lens' ListStagingAccountsResponse (Prelude.Maybe [Account])
listStagingAccountsResponse_accounts :: Lens' ListStagingAccountsResponse (Maybe [Account])
listStagingAccountsResponse_accounts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStagingAccountsResponse' {Maybe [Account]
accounts :: Maybe [Account]
$sel:accounts:ListStagingAccountsResponse' :: ListStagingAccountsResponse -> Maybe [Account]
accounts} -> Maybe [Account]
accounts) (\s :: ListStagingAccountsResponse
s@ListStagingAccountsResponse' {} Maybe [Account]
a -> ListStagingAccountsResponse
s {$sel:accounts:ListStagingAccountsResponse' :: Maybe [Account]
accounts = Maybe [Account]
a} :: ListStagingAccountsResponse) 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

-- | The token of the next staging Account to retrieve.
listStagingAccountsResponse_nextToken :: Lens.Lens' ListStagingAccountsResponse (Prelude.Maybe Prelude.Text)
listStagingAccountsResponse_nextToken :: Lens' ListStagingAccountsResponse (Maybe Text)
listStagingAccountsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListStagingAccountsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListStagingAccountsResponse' :: ListStagingAccountsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListStagingAccountsResponse
s@ListStagingAccountsResponse' {} Maybe Text
a -> ListStagingAccountsResponse
s {$sel:nextToken:ListStagingAccountsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListStagingAccountsResponse)

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

instance Prelude.NFData ListStagingAccountsResponse where
  rnf :: ListStagingAccountsResponse -> ()
rnf ListStagingAccountsResponse' {Int
Maybe [Account]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
accounts :: Maybe [Account]
$sel:httpStatus:ListStagingAccountsResponse' :: ListStagingAccountsResponse -> Int
$sel:nextToken:ListStagingAccountsResponse' :: ListStagingAccountsResponse -> Maybe Text
$sel:accounts:ListStagingAccountsResponse' :: ListStagingAccountsResponse -> Maybe [Account]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Account]
accounts
      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