{-# 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.WorkSpacesWeb.ListPortals
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves a list or web portals.
module Amazonka.WorkSpacesWeb.ListPortals
  ( -- * Creating a Request
    ListPortals (..),
    newListPortals,

    -- * Request Lenses
    listPortals_maxResults,
    listPortals_nextToken,

    -- * Destructuring the Response
    ListPortalsResponse (..),
    newListPortalsResponse,

    -- * Response Lenses
    listPortalsResponse_nextToken,
    listPortalsResponse_portals,
    listPortalsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListPortals' smart constructor.
data ListPortals = ListPortals'
  { -- | The maximum number of results to be included in the next page.
    ListPortals -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The pagination token used to retrieve the next page of results for this
    -- operation.
    ListPortals -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListPortals -> ListPortals -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPortals -> ListPortals -> Bool
$c/= :: ListPortals -> ListPortals -> Bool
== :: ListPortals -> ListPortals -> Bool
$c== :: ListPortals -> ListPortals -> Bool
Prelude.Eq, ReadPrec [ListPortals]
ReadPrec ListPortals
Int -> ReadS ListPortals
ReadS [ListPortals]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPortals]
$creadListPrec :: ReadPrec [ListPortals]
readPrec :: ReadPrec ListPortals
$creadPrec :: ReadPrec ListPortals
readList :: ReadS [ListPortals]
$creadList :: ReadS [ListPortals]
readsPrec :: Int -> ReadS ListPortals
$creadsPrec :: Int -> ReadS ListPortals
Prelude.Read, Int -> ListPortals -> ShowS
[ListPortals] -> ShowS
ListPortals -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPortals] -> ShowS
$cshowList :: [ListPortals] -> ShowS
show :: ListPortals -> String
$cshow :: ListPortals -> String
showsPrec :: Int -> ListPortals -> ShowS
$cshowsPrec :: Int -> ListPortals -> ShowS
Prelude.Show, forall x. Rep ListPortals x -> ListPortals
forall x. ListPortals -> Rep ListPortals x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPortals x -> ListPortals
$cfrom :: forall x. ListPortals -> Rep ListPortals x
Prelude.Generic)

-- |
-- Create a value of 'ListPortals' 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', 'listPortals_maxResults' - The maximum number of results to be included in the next page.
--
-- 'nextToken', 'listPortals_nextToken' - The pagination token used to retrieve the next page of results for this
-- operation.
newListPortals ::
  ListPortals
newListPortals :: ListPortals
newListPortals =
  ListPortals'
    { $sel:maxResults:ListPortals' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListPortals' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of results to be included in the next page.
listPortals_maxResults :: Lens.Lens' ListPortals (Prelude.Maybe Prelude.Natural)
listPortals_maxResults :: Lens' ListPortals (Maybe Natural)
listPortals_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPortals' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListPortals' :: ListPortals -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListPortals
s@ListPortals' {} Maybe Natural
a -> ListPortals
s {$sel:maxResults:ListPortals' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListPortals)

-- | The pagination token used to retrieve the next page of results for this
-- operation.
listPortals_nextToken :: Lens.Lens' ListPortals (Prelude.Maybe Prelude.Text)
listPortals_nextToken :: Lens' ListPortals (Maybe Text)
listPortals_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPortals' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListPortals' :: ListPortals -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListPortals
s@ListPortals' {} Maybe Text
a -> ListPortals
s {$sel:nextToken:ListPortals' :: Maybe Text
nextToken = Maybe Text
a} :: ListPortals)

instance Core.AWSRequest ListPortals where
  type AWSResponse ListPortals = ListPortalsResponse
  request :: (Service -> Service) -> ListPortals -> Request ListPortals
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 ListPortals
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListPortals)))
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 Text -> Maybe [PortalSummary] -> Int -> ListPortalsResponse
ListPortalsResponse'
            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
"nextToken")
            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
"portals" 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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListPortals where
  hashWithSalt :: Int -> ListPortals -> Int
hashWithSalt Int
_salt ListPortals' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListPortals' :: ListPortals -> Maybe Text
$sel:maxResults:ListPortals' :: ListPortals -> 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 ListPortals where
  rnf :: ListPortals -> ()
rnf ListPortals' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListPortals' :: ListPortals -> Maybe Text
$sel:maxResults:ListPortals' :: ListPortals -> 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 ListPortals where
  toHeaders :: ListPortals -> 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 ListPortals where
  toPath :: ListPortals -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/portals"

instance Data.ToQuery ListPortals where
  toQuery :: ListPortals -> QueryString
toQuery ListPortals' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListPortals' :: ListPortals -> Maybe Text
$sel:maxResults:ListPortals' :: ListPortals -> 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:/ 'newListPortalsResponse' smart constructor.
data ListPortalsResponse = ListPortalsResponse'
  { -- | The pagination token used to retrieve the next page of results for this
    -- operation.
    ListPortalsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The portals in the list.
    ListPortalsResponse -> Maybe [PortalSummary]
portals :: Prelude.Maybe [PortalSummary],
    -- | The response's http status code.
    ListPortalsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListPortalsResponse -> ListPortalsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPortalsResponse -> ListPortalsResponse -> Bool
$c/= :: ListPortalsResponse -> ListPortalsResponse -> Bool
== :: ListPortalsResponse -> ListPortalsResponse -> Bool
$c== :: ListPortalsResponse -> ListPortalsResponse -> Bool
Prelude.Eq, Int -> ListPortalsResponse -> ShowS
[ListPortalsResponse] -> ShowS
ListPortalsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPortalsResponse] -> ShowS
$cshowList :: [ListPortalsResponse] -> ShowS
show :: ListPortalsResponse -> String
$cshow :: ListPortalsResponse -> String
showsPrec :: Int -> ListPortalsResponse -> ShowS
$cshowsPrec :: Int -> ListPortalsResponse -> ShowS
Prelude.Show, forall x. Rep ListPortalsResponse x -> ListPortalsResponse
forall x. ListPortalsResponse -> Rep ListPortalsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPortalsResponse x -> ListPortalsResponse
$cfrom :: forall x. ListPortalsResponse -> Rep ListPortalsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListPortalsResponse' 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', 'listPortalsResponse_nextToken' - The pagination token used to retrieve the next page of results for this
-- operation.
--
-- 'portals', 'listPortalsResponse_portals' - The portals in the list.
--
-- 'httpStatus', 'listPortalsResponse_httpStatus' - The response's http status code.
newListPortalsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListPortalsResponse
newListPortalsResponse :: Int -> ListPortalsResponse
newListPortalsResponse Int
pHttpStatus_ =
  ListPortalsResponse'
    { $sel:nextToken:ListPortalsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:portals:ListPortalsResponse' :: Maybe [PortalSummary]
portals = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListPortalsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The pagination token used to retrieve the next page of results for this
-- operation.
listPortalsResponse_nextToken :: Lens.Lens' ListPortalsResponse (Prelude.Maybe Prelude.Text)
listPortalsResponse_nextToken :: Lens' ListPortalsResponse (Maybe Text)
listPortalsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPortalsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListPortalsResponse' :: ListPortalsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListPortalsResponse
s@ListPortalsResponse' {} Maybe Text
a -> ListPortalsResponse
s {$sel:nextToken:ListPortalsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListPortalsResponse)

-- | The portals in the list.
listPortalsResponse_portals :: Lens.Lens' ListPortalsResponse (Prelude.Maybe [PortalSummary])
listPortalsResponse_portals :: Lens' ListPortalsResponse (Maybe [PortalSummary])
listPortalsResponse_portals = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPortalsResponse' {Maybe [PortalSummary]
portals :: Maybe [PortalSummary]
$sel:portals:ListPortalsResponse' :: ListPortalsResponse -> Maybe [PortalSummary]
portals} -> Maybe [PortalSummary]
portals) (\s :: ListPortalsResponse
s@ListPortalsResponse' {} Maybe [PortalSummary]
a -> ListPortalsResponse
s {$sel:portals:ListPortalsResponse' :: Maybe [PortalSummary]
portals = Maybe [PortalSummary]
a} :: ListPortalsResponse) 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 response's http status code.
listPortalsResponse_httpStatus :: Lens.Lens' ListPortalsResponse Prelude.Int
listPortalsResponse_httpStatus :: Lens' ListPortalsResponse Int
listPortalsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPortalsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListPortalsResponse' :: ListPortalsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListPortalsResponse
s@ListPortalsResponse' {} Int
a -> ListPortalsResponse
s {$sel:httpStatus:ListPortalsResponse' :: Int
httpStatus = Int
a} :: ListPortalsResponse)

instance Prelude.NFData ListPortalsResponse where
  rnf :: ListPortalsResponse -> ()
rnf ListPortalsResponse' {Int
Maybe [PortalSummary]
Maybe Text
httpStatus :: Int
portals :: Maybe [PortalSummary]
nextToken :: Maybe Text
$sel:httpStatus:ListPortalsResponse' :: ListPortalsResponse -> Int
$sel:portals:ListPortalsResponse' :: ListPortalsResponse -> Maybe [PortalSummary]
$sel:nextToken:ListPortalsResponse' :: ListPortalsResponse -> Maybe Text
..} =
    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 Maybe [PortalSummary]
portals
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus