{-# 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.WorkLink.ListFleets
-- 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)
--
-- Retrieves a list of fleets for the current account and Region.
module Amazonka.WorkLink.ListFleets
  ( -- * Creating a Request
    ListFleets (..),
    newListFleets,

    -- * Request Lenses
    listFleets_nextToken,
    listFleets_maxResults,

    -- * Destructuring the Response
    ListFleetsResponse (..),
    newListFleetsResponse,

    -- * Response Lenses
    listFleetsResponse_fleetSummaryList,
    listFleetsResponse_nextToken,
    listFleetsResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'ListFleets' 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', 'listFleets_nextToken' - The pagination token used to retrieve the next page of results for this
-- operation. If this value is null, it retrieves the first page.
--
-- 'maxResults', 'listFleets_maxResults' - The maximum number of results to be included in the next page.
newListFleets ::
  ListFleets
newListFleets :: ListFleets
newListFleets =
  ListFleets' :: Maybe Text -> Maybe Natural -> ListFleets
ListFleets'
    { $sel:nextToken:ListFleets' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListFleets' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The pagination token used to retrieve the next page of results for this
-- operation. If this value is null, it retrieves the first page.
listFleets_nextToken :: Lens.Lens' ListFleets (Prelude.Maybe Prelude.Text)
listFleets_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListFleets -> f ListFleets
listFleets_nextToken = (ListFleets -> Maybe Text)
-> (ListFleets -> Maybe Text -> ListFleets)
-> Lens ListFleets ListFleets (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFleets' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListFleets' :: ListFleets -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListFleets
s@ListFleets' {} Maybe Text
a -> ListFleets
s {$sel:nextToken:ListFleets' :: Maybe Text
nextToken = Maybe Text
a} :: ListFleets)

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

instance Core.AWSRequest ListFleets where
  type AWSResponse ListFleets = ListFleetsResponse
  request :: ListFleets -> Request ListFleets
request = Service -> ListFleets -> Request ListFleets
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListFleets
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListFleets)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListFleets))
-> Logger
-> Service
-> Proxy ListFleets
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListFleets)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [FleetSummary] -> Maybe Text -> Int -> ListFleetsResponse
ListFleetsResponse'
            (Maybe [FleetSummary] -> Maybe Text -> Int -> ListFleetsResponse)
-> Either String (Maybe [FleetSummary])
-> Either String (Maybe Text -> Int -> ListFleetsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Either String (Maybe (Maybe [FleetSummary]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"FleetSummaryList"
                            Either String (Maybe (Maybe [FleetSummary]))
-> Maybe [FleetSummary] -> Either String (Maybe [FleetSummary])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [FleetSummary]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Maybe Text -> Int -> ListFleetsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> ListFleetsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either String (Int -> ListFleetsResponse)
-> Either String Int -> Either String ListFleetsResponse
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 ListFleets

instance Prelude.NFData ListFleets

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

instance Core.ToJSON ListFleets where
  toJSON :: ListFleets -> Value
toJSON ListFleets' {Maybe Natural
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:maxResults:ListFleets' :: ListFleets -> Maybe Natural
$sel:nextToken:ListFleets' :: ListFleets -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"MaxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults
          ]
      )

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

instance Core.ToQuery ListFleets where
  toQuery :: ListFleets -> QueryString
toQuery = QueryString -> ListFleets -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newListFleetsResponse' smart constructor.
data ListFleetsResponse = ListFleetsResponse'
  { -- | The summary list of the fleets.
    ListFleetsResponse -> Maybe [FleetSummary]
fleetSummaryList :: Prelude.Maybe [FleetSummary],
    -- | The pagination token used to retrieve the next page of results for this
    -- operation. If there are no more pages, this value is null.
    ListFleetsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListFleetsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListFleetsResponse -> ListFleetsResponse -> Bool
(ListFleetsResponse -> ListFleetsResponse -> Bool)
-> (ListFleetsResponse -> ListFleetsResponse -> Bool)
-> Eq ListFleetsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListFleetsResponse -> ListFleetsResponse -> Bool
$c/= :: ListFleetsResponse -> ListFleetsResponse -> Bool
== :: ListFleetsResponse -> ListFleetsResponse -> Bool
$c== :: ListFleetsResponse -> ListFleetsResponse -> Bool
Prelude.Eq, ReadPrec [ListFleetsResponse]
ReadPrec ListFleetsResponse
Int -> ReadS ListFleetsResponse
ReadS [ListFleetsResponse]
(Int -> ReadS ListFleetsResponse)
-> ReadS [ListFleetsResponse]
-> ReadPrec ListFleetsResponse
-> ReadPrec [ListFleetsResponse]
-> Read ListFleetsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListFleetsResponse]
$creadListPrec :: ReadPrec [ListFleetsResponse]
readPrec :: ReadPrec ListFleetsResponse
$creadPrec :: ReadPrec ListFleetsResponse
readList :: ReadS [ListFleetsResponse]
$creadList :: ReadS [ListFleetsResponse]
readsPrec :: Int -> ReadS ListFleetsResponse
$creadsPrec :: Int -> ReadS ListFleetsResponse
Prelude.Read, Int -> ListFleetsResponse -> ShowS
[ListFleetsResponse] -> ShowS
ListFleetsResponse -> String
(Int -> ListFleetsResponse -> ShowS)
-> (ListFleetsResponse -> String)
-> ([ListFleetsResponse] -> ShowS)
-> Show ListFleetsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListFleetsResponse] -> ShowS
$cshowList :: [ListFleetsResponse] -> ShowS
show :: ListFleetsResponse -> String
$cshow :: ListFleetsResponse -> String
showsPrec :: Int -> ListFleetsResponse -> ShowS
$cshowsPrec :: Int -> ListFleetsResponse -> ShowS
Prelude.Show, (forall x. ListFleetsResponse -> Rep ListFleetsResponse x)
-> (forall x. Rep ListFleetsResponse x -> ListFleetsResponse)
-> Generic ListFleetsResponse
forall x. Rep ListFleetsResponse x -> ListFleetsResponse
forall x. ListFleetsResponse -> Rep ListFleetsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListFleetsResponse x -> ListFleetsResponse
$cfrom :: forall x. ListFleetsResponse -> Rep ListFleetsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListFleetsResponse' 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:
--
-- 'fleetSummaryList', 'listFleetsResponse_fleetSummaryList' - The summary list of the fleets.
--
-- 'nextToken', 'listFleetsResponse_nextToken' - The pagination token used to retrieve the next page of results for this
-- operation. If there are no more pages, this value is null.
--
-- 'httpStatus', 'listFleetsResponse_httpStatus' - The response's http status code.
newListFleetsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListFleetsResponse
newListFleetsResponse :: Int -> ListFleetsResponse
newListFleetsResponse Int
pHttpStatus_ =
  ListFleetsResponse' :: Maybe [FleetSummary] -> Maybe Text -> Int -> ListFleetsResponse
ListFleetsResponse'
    { $sel:fleetSummaryList:ListFleetsResponse' :: Maybe [FleetSummary]
fleetSummaryList =
        Maybe [FleetSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListFleetsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListFleetsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The summary list of the fleets.
listFleetsResponse_fleetSummaryList :: Lens.Lens' ListFleetsResponse (Prelude.Maybe [FleetSummary])
listFleetsResponse_fleetSummaryList :: (Maybe [FleetSummary] -> f (Maybe [FleetSummary]))
-> ListFleetsResponse -> f ListFleetsResponse
listFleetsResponse_fleetSummaryList = (ListFleetsResponse -> Maybe [FleetSummary])
-> (ListFleetsResponse
    -> Maybe [FleetSummary] -> ListFleetsResponse)
-> Lens
     ListFleetsResponse
     ListFleetsResponse
     (Maybe [FleetSummary])
     (Maybe [FleetSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFleetsResponse' {Maybe [FleetSummary]
fleetSummaryList :: Maybe [FleetSummary]
$sel:fleetSummaryList:ListFleetsResponse' :: ListFleetsResponse -> Maybe [FleetSummary]
fleetSummaryList} -> Maybe [FleetSummary]
fleetSummaryList) (\s :: ListFleetsResponse
s@ListFleetsResponse' {} Maybe [FleetSummary]
a -> ListFleetsResponse
s {$sel:fleetSummaryList:ListFleetsResponse' :: Maybe [FleetSummary]
fleetSummaryList = Maybe [FleetSummary]
a} :: ListFleetsResponse) ((Maybe [FleetSummary] -> f (Maybe [FleetSummary]))
 -> ListFleetsResponse -> f ListFleetsResponse)
-> ((Maybe [FleetSummary] -> f (Maybe [FleetSummary]))
    -> Maybe [FleetSummary] -> f (Maybe [FleetSummary]))
-> (Maybe [FleetSummary] -> f (Maybe [FleetSummary]))
-> ListFleetsResponse
-> f ListFleetsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [FleetSummary] [FleetSummary] [FleetSummary] [FleetSummary]
-> Iso
     (Maybe [FleetSummary])
     (Maybe [FleetSummary])
     (Maybe [FleetSummary])
     (Maybe [FleetSummary])
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 [FleetSummary] [FleetSummary] [FleetSummary] [FleetSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The pagination token used to retrieve the next page of results for this
-- operation. If there are no more pages, this value is null.
listFleetsResponse_nextToken :: Lens.Lens' ListFleetsResponse (Prelude.Maybe Prelude.Text)
listFleetsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListFleetsResponse -> f ListFleetsResponse
listFleetsResponse_nextToken = (ListFleetsResponse -> Maybe Text)
-> (ListFleetsResponse -> Maybe Text -> ListFleetsResponse)
-> Lens
     ListFleetsResponse ListFleetsResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFleetsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListFleetsResponse' :: ListFleetsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListFleetsResponse
s@ListFleetsResponse' {} Maybe Text
a -> ListFleetsResponse
s {$sel:nextToken:ListFleetsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListFleetsResponse)

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

instance Prelude.NFData ListFleetsResponse