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

    -- * Request Lenses
    listTrackers_maxResults,
    listTrackers_nextToken,

    -- * Destructuring the Response
    ListTrackersResponse (..),
    newListTrackersResponse,

    -- * Response Lenses
    listTrackersResponse_nextToken,
    listTrackersResponse_httpStatus,
    listTrackersResponse_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:/ 'newListTrackers' smart constructor.
data ListTrackers = ListTrackers'
  { -- | An optional limit for the number of resources returned in a single call.
    --
    -- Default value: @100@
    ListTrackers -> 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@
    ListTrackers -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListTrackers -> ListTrackers -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTrackers -> ListTrackers -> Bool
$c/= :: ListTrackers -> ListTrackers -> Bool
== :: ListTrackers -> ListTrackers -> Bool
$c== :: ListTrackers -> ListTrackers -> Bool
Prelude.Eq, ReadPrec [ListTrackers]
ReadPrec ListTrackers
Int -> ReadS ListTrackers
ReadS [ListTrackers]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTrackers]
$creadListPrec :: ReadPrec [ListTrackers]
readPrec :: ReadPrec ListTrackers
$creadPrec :: ReadPrec ListTrackers
readList :: ReadS [ListTrackers]
$creadList :: ReadS [ListTrackers]
readsPrec :: Int -> ReadS ListTrackers
$creadsPrec :: Int -> ReadS ListTrackers
Prelude.Read, Int -> ListTrackers -> ShowS
[ListTrackers] -> ShowS
ListTrackers -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTrackers] -> ShowS
$cshowList :: [ListTrackers] -> ShowS
show :: ListTrackers -> String
$cshow :: ListTrackers -> String
showsPrec :: Int -> ListTrackers -> ShowS
$cshowsPrec :: Int -> ListTrackers -> ShowS
Prelude.Show, forall x. Rep ListTrackers x -> ListTrackers
forall x. ListTrackers -> Rep ListTrackers x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTrackers x -> ListTrackers
$cfrom :: forall x. ListTrackers -> Rep ListTrackers x
Prelude.Generic)

-- |
-- Create a value of 'ListTrackers' 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', 'listTrackers_maxResults' - An optional limit for the number of resources returned in a single call.
--
-- Default value: @100@
--
-- 'nextToken', 'listTrackers_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@
newListTrackers ::
  ListTrackers
newListTrackers :: ListTrackers
newListTrackers =
  ListTrackers'
    { $sel:maxResults:ListTrackers' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListTrackers' :: 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@
listTrackers_maxResults :: Lens.Lens' ListTrackers (Prelude.Maybe Prelude.Natural)
listTrackers_maxResults :: Lens' ListTrackers (Maybe Natural)
listTrackers_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTrackers' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListTrackers' :: ListTrackers -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListTrackers
s@ListTrackers' {} Maybe Natural
a -> ListTrackers
s {$sel:maxResults:ListTrackers' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListTrackers)

-- | 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@
listTrackers_nextToken :: Lens.Lens' ListTrackers (Prelude.Maybe Prelude.Text)
listTrackers_nextToken :: Lens' ListTrackers (Maybe Text)
listTrackers_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTrackers' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTrackers' :: ListTrackers -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTrackers
s@ListTrackers' {} Maybe Text
a -> ListTrackers
s {$sel:nextToken:ListTrackers' :: Maybe Text
nextToken = Maybe Text
a} :: ListTrackers)

instance Core.AWSPager ListTrackers where
  page :: ListTrackers -> AWSResponse ListTrackers -> Maybe ListTrackers
page ListTrackers
rq AWSResponse ListTrackers
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListTrackers
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListTrackersResponse (Maybe Text)
listTrackersResponse_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 ListTrackers
rs forall s a. s -> Getting a s a -> a
Lens.^. Lens' ListTrackersResponse [ListTrackersResponseEntry]
listTrackersResponse_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.$ ListTrackers
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListTrackers (Maybe Text)
listTrackers_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListTrackers
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListTrackersResponse (Maybe Text)
listTrackersResponse_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 ListTrackers where
  type AWSResponse ListTrackers = ListTrackersResponse
  request :: (Service -> Service) -> ListTrackers -> Request ListTrackers
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 ListTrackers
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListTrackers)))
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 -> [ListTrackersResponseEntry] -> ListTrackersResponse
ListTrackersResponse'
            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 ListTrackers where
  hashWithSalt :: Int -> ListTrackers -> Int
hashWithSalt Int
_salt ListTrackers' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListTrackers' :: ListTrackers -> Maybe Text
$sel:maxResults:ListTrackers' :: ListTrackers -> 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 ListTrackers where
  rnf :: ListTrackers -> ()
rnf ListTrackers' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListTrackers' :: ListTrackers -> Maybe Text
$sel:maxResults:ListTrackers' :: ListTrackers -> 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 ListTrackers where
  toHeaders :: ListTrackers -> 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 ListTrackers where
  toJSON :: ListTrackers -> Value
toJSON ListTrackers' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListTrackers' :: ListTrackers -> Maybe Text
$sel:maxResults:ListTrackers' :: ListTrackers -> 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 ListTrackers where
  toPath :: ListTrackers -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/tracking/v0/list-trackers"

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

-- | /See:/ 'newListTrackersResponse' smart constructor.
data ListTrackersResponse = ListTrackersResponse'
  { -- | 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.
    ListTrackersResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListTrackersResponse -> Int
httpStatus :: Prelude.Int,
    -- | Contains tracker resources in your AWS account. Details include tracker
    -- name, description and timestamps for when the tracker was created and
    -- last updated.
    ListTrackersResponse -> [ListTrackersResponseEntry]
entries :: [ListTrackersResponseEntry]
  }
  deriving (ListTrackersResponse -> ListTrackersResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTrackersResponse -> ListTrackersResponse -> Bool
$c/= :: ListTrackersResponse -> ListTrackersResponse -> Bool
== :: ListTrackersResponse -> ListTrackersResponse -> Bool
$c== :: ListTrackersResponse -> ListTrackersResponse -> Bool
Prelude.Eq, ReadPrec [ListTrackersResponse]
ReadPrec ListTrackersResponse
Int -> ReadS ListTrackersResponse
ReadS [ListTrackersResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTrackersResponse]
$creadListPrec :: ReadPrec [ListTrackersResponse]
readPrec :: ReadPrec ListTrackersResponse
$creadPrec :: ReadPrec ListTrackersResponse
readList :: ReadS [ListTrackersResponse]
$creadList :: ReadS [ListTrackersResponse]
readsPrec :: Int -> ReadS ListTrackersResponse
$creadsPrec :: Int -> ReadS ListTrackersResponse
Prelude.Read, Int -> ListTrackersResponse -> ShowS
[ListTrackersResponse] -> ShowS
ListTrackersResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTrackersResponse] -> ShowS
$cshowList :: [ListTrackersResponse] -> ShowS
show :: ListTrackersResponse -> String
$cshow :: ListTrackersResponse -> String
showsPrec :: Int -> ListTrackersResponse -> ShowS
$cshowsPrec :: Int -> ListTrackersResponse -> ShowS
Prelude.Show, forall x. Rep ListTrackersResponse x -> ListTrackersResponse
forall x. ListTrackersResponse -> Rep ListTrackersResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTrackersResponse x -> ListTrackersResponse
$cfrom :: forall x. ListTrackersResponse -> Rep ListTrackersResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListTrackersResponse' 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', 'listTrackersResponse_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', 'listTrackersResponse_httpStatus' - The response's http status code.
--
-- 'entries', 'listTrackersResponse_entries' - Contains tracker resources in your AWS account. Details include tracker
-- name, description and timestamps for when the tracker was created and
-- last updated.
newListTrackersResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListTrackersResponse
newListTrackersResponse :: Int -> ListTrackersResponse
newListTrackersResponse Int
pHttpStatus_ =
  ListTrackersResponse'
    { $sel:nextToken:ListTrackersResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListTrackersResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:entries:ListTrackersResponse' :: [ListTrackersResponseEntry]
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.
listTrackersResponse_nextToken :: Lens.Lens' ListTrackersResponse (Prelude.Maybe Prelude.Text)
listTrackersResponse_nextToken :: Lens' ListTrackersResponse (Maybe Text)
listTrackersResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTrackersResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTrackersResponse' :: ListTrackersResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTrackersResponse
s@ListTrackersResponse' {} Maybe Text
a -> ListTrackersResponse
s {$sel:nextToken:ListTrackersResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListTrackersResponse)

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

-- | Contains tracker resources in your AWS account. Details include tracker
-- name, description and timestamps for when the tracker was created and
-- last updated.
listTrackersResponse_entries :: Lens.Lens' ListTrackersResponse [ListTrackersResponseEntry]
listTrackersResponse_entries :: Lens' ListTrackersResponse [ListTrackersResponseEntry]
listTrackersResponse_entries = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTrackersResponse' {[ListTrackersResponseEntry]
entries :: [ListTrackersResponseEntry]
$sel:entries:ListTrackersResponse' :: ListTrackersResponse -> [ListTrackersResponseEntry]
entries} -> [ListTrackersResponseEntry]
entries) (\s :: ListTrackersResponse
s@ListTrackersResponse' {} [ListTrackersResponseEntry]
a -> ListTrackersResponse
s {$sel:entries:ListTrackersResponse' :: [ListTrackersResponseEntry]
entries = [ListTrackersResponseEntry]
a} :: ListTrackersResponse) 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 ListTrackersResponse where
  rnf :: ListTrackersResponse -> ()
rnf ListTrackersResponse' {Int
[ListTrackersResponseEntry]
Maybe Text
entries :: [ListTrackersResponseEntry]
httpStatus :: Int
nextToken :: Maybe Text
$sel:entries:ListTrackersResponse' :: ListTrackersResponse -> [ListTrackersResponseEntry]
$sel:httpStatus:ListTrackersResponse' :: ListTrackersResponse -> Int
$sel:nextToken:ListTrackersResponse' :: ListTrackersResponse -> 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 [ListTrackersResponseEntry]
entries