{-# 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.Location.ListMaps
-- 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 map resources in your AWS account.
--
-- This operation returns paginated results.
module Amazonka.Location.ListMaps
  ( -- * Creating a Request
    ListMaps (..),
    newListMaps,

    -- * Request Lenses
    listMaps_maxResults,
    listMaps_nextToken,

    -- * Destructuring the Response
    ListMapsResponse (..),
    newListMapsResponse,

    -- * Response Lenses
    listMapsResponse_nextToken,
    listMapsResponse_httpStatus,
    listMapsResponse_entries,
  )
where

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

-- | /See:/ 'newListMaps' smart constructor.
data ListMaps = ListMaps'
  { -- | An optional limit for the number of resources returned in a single call.
    --
    -- Default value: @100@
    ListMaps -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The pagination token specifying which page of results to return in the
    -- response. If no token is provided, the default page is the first page.
    --
    -- Default value: @null@
    ListMaps -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListMaps -> ListMaps -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListMaps -> ListMaps -> Bool
$c/= :: ListMaps -> ListMaps -> Bool
== :: ListMaps -> ListMaps -> Bool
$c== :: ListMaps -> ListMaps -> Bool
Prelude.Eq, ReadPrec [ListMaps]
ReadPrec ListMaps
Int -> ReadS ListMaps
ReadS [ListMaps]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListMaps]
$creadListPrec :: ReadPrec [ListMaps]
readPrec :: ReadPrec ListMaps
$creadPrec :: ReadPrec ListMaps
readList :: ReadS [ListMaps]
$creadList :: ReadS [ListMaps]
readsPrec :: Int -> ReadS ListMaps
$creadsPrec :: Int -> ReadS ListMaps
Prelude.Read, Int -> ListMaps -> ShowS
[ListMaps] -> ShowS
ListMaps -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListMaps] -> ShowS
$cshowList :: [ListMaps] -> ShowS
show :: ListMaps -> String
$cshow :: ListMaps -> String
showsPrec :: Int -> ListMaps -> ShowS
$cshowsPrec :: Int -> ListMaps -> ShowS
Prelude.Show, forall x. Rep ListMaps x -> ListMaps
forall x. ListMaps -> Rep ListMaps x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListMaps x -> ListMaps
$cfrom :: forall x. ListMaps -> Rep ListMaps x
Prelude.Generic)

-- |
-- Create a value of 'ListMaps' 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', 'listMaps_maxResults' - An optional limit for the number of resources returned in a single call.
--
-- Default value: @100@
--
-- 'nextToken', 'listMaps_nextToken' - The pagination token specifying which page of results to return in the
-- response. If no token is provided, the default page is the first page.
--
-- Default value: @null@
newListMaps ::
  ListMaps
newListMaps :: ListMaps
newListMaps =
  ListMaps'
    { $sel:maxResults:ListMaps' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListMaps' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | An optional limit for the number of resources returned in a single call.
--
-- Default value: @100@
listMaps_maxResults :: Lens.Lens' ListMaps (Prelude.Maybe Prelude.Natural)
listMaps_maxResults :: Lens' ListMaps (Maybe Natural)
listMaps_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListMaps' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListMaps' :: ListMaps -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListMaps
s@ListMaps' {} Maybe Natural
a -> ListMaps
s {$sel:maxResults:ListMaps' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListMaps)

-- | The pagination token specifying which page of results to return in the
-- response. If no token is provided, the default page is the first page.
--
-- Default value: @null@
listMaps_nextToken :: Lens.Lens' ListMaps (Prelude.Maybe Prelude.Text)
listMaps_nextToken :: Lens' ListMaps (Maybe Text)
listMaps_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListMaps' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListMaps' :: ListMaps -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListMaps
s@ListMaps' {} Maybe Text
a -> ListMaps
s {$sel:nextToken:ListMaps' :: Maybe Text
nextToken = Maybe Text
a} :: ListMaps)

instance Core.AWSPager ListMaps where
  page :: ListMaps -> AWSResponse ListMaps -> Maybe ListMaps
page ListMaps
rq AWSResponse ListMaps
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListMaps
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListMapsResponse (Maybe Text)
listMapsResponse_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 ListMaps
rs forall s a. s -> Getting a s a -> a
Lens.^. Lens' ListMapsResponse [ListMapsResponseEntry]
listMapsResponse_entries) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListMaps
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListMaps (Maybe Text)
listMaps_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListMaps
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListMapsResponse (Maybe Text)
listMapsResponse_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 ListMaps where
  type AWSResponse ListMaps = ListMapsResponse
  request :: (Service -> Service) -> ListMaps -> Request ListMaps
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListMaps
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListMaps)))
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 -> Int -> [ListMapsResponseEntry] -> ListMapsResponse
ListMapsResponse'
            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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            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
"Entries" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ListMaps where
  hashWithSalt :: Int -> ListMaps -> Int
hashWithSalt Int
_salt ListMaps' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListMaps' :: ListMaps -> Maybe Text
$sel:maxResults:ListMaps' :: ListMaps -> 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 ListMaps where
  rnf :: ListMaps -> ()
rnf ListMaps' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListMaps' :: ListMaps -> Maybe Text
$sel:maxResults:ListMaps' :: ListMaps -> 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 ListMaps where
  toHeaders :: ListMaps -> 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.ToJSON ListMaps where
  toJSON :: ListMaps -> Value
toJSON ListMaps' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListMaps' :: ListMaps -> Maybe Text
$sel:maxResults:ListMaps' :: ListMaps -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"MaxResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            (Key
"NextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken
          ]
      )

instance Data.ToPath ListMaps where
  toPath :: ListMaps -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/maps/v0/list-maps"

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

-- | /See:/ 'newListMapsResponse' smart constructor.
data ListMapsResponse = ListMapsResponse'
  { -- | A pagination token indicating there are additional pages available. You
    -- can use the token in a following request to fetch the next set of
    -- results.
    ListMapsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListMapsResponse -> Int
httpStatus :: Prelude.Int,
    -- | Contains a list of maps in your AWS account
    ListMapsResponse -> [ListMapsResponseEntry]
entries :: [ListMapsResponseEntry]
  }
  deriving (ListMapsResponse -> ListMapsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListMapsResponse -> ListMapsResponse -> Bool
$c/= :: ListMapsResponse -> ListMapsResponse -> Bool
== :: ListMapsResponse -> ListMapsResponse -> Bool
$c== :: ListMapsResponse -> ListMapsResponse -> Bool
Prelude.Eq, ReadPrec [ListMapsResponse]
ReadPrec ListMapsResponse
Int -> ReadS ListMapsResponse
ReadS [ListMapsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListMapsResponse]
$creadListPrec :: ReadPrec [ListMapsResponse]
readPrec :: ReadPrec ListMapsResponse
$creadPrec :: ReadPrec ListMapsResponse
readList :: ReadS [ListMapsResponse]
$creadList :: ReadS [ListMapsResponse]
readsPrec :: Int -> ReadS ListMapsResponse
$creadsPrec :: Int -> ReadS ListMapsResponse
Prelude.Read, Int -> ListMapsResponse -> ShowS
[ListMapsResponse] -> ShowS
ListMapsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListMapsResponse] -> ShowS
$cshowList :: [ListMapsResponse] -> ShowS
show :: ListMapsResponse -> String
$cshow :: ListMapsResponse -> String
showsPrec :: Int -> ListMapsResponse -> ShowS
$cshowsPrec :: Int -> ListMapsResponse -> ShowS
Prelude.Show, forall x. Rep ListMapsResponse x -> ListMapsResponse
forall x. ListMapsResponse -> Rep ListMapsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListMapsResponse x -> ListMapsResponse
$cfrom :: forall x. ListMapsResponse -> Rep ListMapsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListMapsResponse' 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', 'listMapsResponse_nextToken' - A pagination token indicating there are additional pages available. You
-- can use the token in a following request to fetch the next set of
-- results.
--
-- 'httpStatus', 'listMapsResponse_httpStatus' - The response's http status code.
--
-- 'entries', 'listMapsResponse_entries' - Contains a list of maps in your AWS account
newListMapsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListMapsResponse
newListMapsResponse :: Int -> ListMapsResponse
newListMapsResponse Int
pHttpStatus_ =
  ListMapsResponse'
    { $sel:nextToken:ListMapsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListMapsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:entries:ListMapsResponse' :: [ListMapsResponseEntry]
entries = forall a. Monoid a => a
Prelude.mempty
    }

-- | A pagination token indicating there are additional pages available. You
-- can use the token in a following request to fetch the next set of
-- results.
listMapsResponse_nextToken :: Lens.Lens' ListMapsResponse (Prelude.Maybe Prelude.Text)
listMapsResponse_nextToken :: Lens' ListMapsResponse (Maybe Text)
listMapsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListMapsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListMapsResponse' :: ListMapsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListMapsResponse
s@ListMapsResponse' {} Maybe Text
a -> ListMapsResponse
s {$sel:nextToken:ListMapsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListMapsResponse)

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

-- | Contains a list of maps in your AWS account
listMapsResponse_entries :: Lens.Lens' ListMapsResponse [ListMapsResponseEntry]
listMapsResponse_entries :: Lens' ListMapsResponse [ListMapsResponseEntry]
listMapsResponse_entries = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListMapsResponse' {[ListMapsResponseEntry]
entries :: [ListMapsResponseEntry]
$sel:entries:ListMapsResponse' :: ListMapsResponse -> [ListMapsResponseEntry]
entries} -> [ListMapsResponseEntry]
entries) (\s :: ListMapsResponse
s@ListMapsResponse' {} [ListMapsResponseEntry]
a -> ListMapsResponse
s {$sel:entries:ListMapsResponse' :: [ListMapsResponseEntry]
entries = [ListMapsResponseEntry]
a} :: ListMapsResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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