{-# 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.IoTWireless.ListDestinations
-- 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 the destinations registered to your AWS account.
module Amazonka.IoTWireless.ListDestinations
  ( -- * Creating a Request
    ListDestinations (..),
    newListDestinations,

    -- * Request Lenses
    listDestinations_maxResults,
    listDestinations_nextToken,

    -- * Destructuring the Response
    ListDestinationsResponse (..),
    newListDestinationsResponse,

    -- * Response Lenses
    listDestinationsResponse_destinationList,
    listDestinationsResponse_nextToken,
    listDestinationsResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListDestinations' smart constructor.
data ListDestinations = ListDestinations'
  { -- | The maximum number of results to return in this operation.
    ListDestinations -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | To retrieve the next set of results, the @nextToken@ value from a
    -- previous response; otherwise __null__ to receive the first set of
    -- results.
    ListDestinations -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListDestinations -> ListDestinations -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDestinations -> ListDestinations -> Bool
$c/= :: ListDestinations -> ListDestinations -> Bool
== :: ListDestinations -> ListDestinations -> Bool
$c== :: ListDestinations -> ListDestinations -> Bool
Prelude.Eq, ReadPrec [ListDestinations]
ReadPrec ListDestinations
Int -> ReadS ListDestinations
ReadS [ListDestinations]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDestinations]
$creadListPrec :: ReadPrec [ListDestinations]
readPrec :: ReadPrec ListDestinations
$creadPrec :: ReadPrec ListDestinations
readList :: ReadS [ListDestinations]
$creadList :: ReadS [ListDestinations]
readsPrec :: Int -> ReadS ListDestinations
$creadsPrec :: Int -> ReadS ListDestinations
Prelude.Read, Int -> ListDestinations -> ShowS
[ListDestinations] -> ShowS
ListDestinations -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDestinations] -> ShowS
$cshowList :: [ListDestinations] -> ShowS
show :: ListDestinations -> String
$cshow :: ListDestinations -> String
showsPrec :: Int -> ListDestinations -> ShowS
$cshowsPrec :: Int -> ListDestinations -> ShowS
Prelude.Show, forall x. Rep ListDestinations x -> ListDestinations
forall x. ListDestinations -> Rep ListDestinations x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDestinations x -> ListDestinations
$cfrom :: forall x. ListDestinations -> Rep ListDestinations x
Prelude.Generic)

-- |
-- Create a value of 'ListDestinations' 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', 'listDestinations_maxResults' - The maximum number of results to return in this operation.
--
-- 'nextToken', 'listDestinations_nextToken' - To retrieve the next set of results, the @nextToken@ value from a
-- previous response; otherwise __null__ to receive the first set of
-- results.
newListDestinations ::
  ListDestinations
newListDestinations :: ListDestinations
newListDestinations =
  ListDestinations'
    { $sel:maxResults:ListDestinations' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDestinations' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of results to return in this operation.
listDestinations_maxResults :: Lens.Lens' ListDestinations (Prelude.Maybe Prelude.Natural)
listDestinations_maxResults :: Lens' ListDestinations (Maybe Natural)
listDestinations_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDestinations' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListDestinations' :: ListDestinations -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListDestinations
s@ListDestinations' {} Maybe Natural
a -> ListDestinations
s {$sel:maxResults:ListDestinations' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListDestinations)

-- | To retrieve the next set of results, the @nextToken@ value from a
-- previous response; otherwise __null__ to receive the first set of
-- results.
listDestinations_nextToken :: Lens.Lens' ListDestinations (Prelude.Maybe Prelude.Text)
listDestinations_nextToken :: Lens' ListDestinations (Maybe Text)
listDestinations_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDestinations' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDestinations' :: ListDestinations -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDestinations
s@ListDestinations' {} Maybe Text
a -> ListDestinations
s {$sel:nextToken:ListDestinations' :: Maybe Text
nextToken = Maybe Text
a} :: ListDestinations)

instance Core.AWSRequest ListDestinations where
  type
    AWSResponse ListDestinations =
      ListDestinationsResponse
  request :: (Service -> Service)
-> ListDestinations -> Request ListDestinations
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 ListDestinations
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDestinations)))
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 [Destinations]
-> Maybe Text -> Int -> ListDestinationsResponse
ListDestinationsResponse'
            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
"DestinationList"
                            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 ListDestinations where
  hashWithSalt :: Int -> ListDestinations -> Int
hashWithSalt Int
_salt ListDestinations' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListDestinations' :: ListDestinations -> Maybe Text
$sel:maxResults:ListDestinations' :: ListDestinations -> 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 ListDestinations where
  rnf :: ListDestinations -> ()
rnf ListDestinations' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListDestinations' :: ListDestinations -> Maybe Text
$sel:maxResults:ListDestinations' :: ListDestinations -> 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 ListDestinations where
  toHeaders :: ListDestinations -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery ListDestinations where
  toQuery :: ListDestinations -> QueryString
toQuery ListDestinations' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListDestinations' :: ListDestinations -> Maybe Text
$sel:maxResults:ListDestinations' :: ListDestinations -> 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:/ 'newListDestinationsResponse' smart constructor.
data ListDestinationsResponse = ListDestinationsResponse'
  { -- | The list of destinations.
    ListDestinationsResponse -> Maybe [Destinations]
destinationList :: Prelude.Maybe [Destinations],
    -- | The token to use to get the next set of results, or __null__ if there
    -- are no additional results.
    ListDestinationsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListDestinationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDestinationsResponse -> ListDestinationsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDestinationsResponse -> ListDestinationsResponse -> Bool
$c/= :: ListDestinationsResponse -> ListDestinationsResponse -> Bool
== :: ListDestinationsResponse -> ListDestinationsResponse -> Bool
$c== :: ListDestinationsResponse -> ListDestinationsResponse -> Bool
Prelude.Eq, ReadPrec [ListDestinationsResponse]
ReadPrec ListDestinationsResponse
Int -> ReadS ListDestinationsResponse
ReadS [ListDestinationsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDestinationsResponse]
$creadListPrec :: ReadPrec [ListDestinationsResponse]
readPrec :: ReadPrec ListDestinationsResponse
$creadPrec :: ReadPrec ListDestinationsResponse
readList :: ReadS [ListDestinationsResponse]
$creadList :: ReadS [ListDestinationsResponse]
readsPrec :: Int -> ReadS ListDestinationsResponse
$creadsPrec :: Int -> ReadS ListDestinationsResponse
Prelude.Read, Int -> ListDestinationsResponse -> ShowS
[ListDestinationsResponse] -> ShowS
ListDestinationsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDestinationsResponse] -> ShowS
$cshowList :: [ListDestinationsResponse] -> ShowS
show :: ListDestinationsResponse -> String
$cshow :: ListDestinationsResponse -> String
showsPrec :: Int -> ListDestinationsResponse -> ShowS
$cshowsPrec :: Int -> ListDestinationsResponse -> ShowS
Prelude.Show, forall x.
Rep ListDestinationsResponse x -> ListDestinationsResponse
forall x.
ListDestinationsResponse -> Rep ListDestinationsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListDestinationsResponse x -> ListDestinationsResponse
$cfrom :: forall x.
ListDestinationsResponse -> Rep ListDestinationsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListDestinationsResponse' 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:
--
-- 'destinationList', 'listDestinationsResponse_destinationList' - The list of destinations.
--
-- 'nextToken', 'listDestinationsResponse_nextToken' - The token to use to get the next set of results, or __null__ if there
-- are no additional results.
--
-- 'httpStatus', 'listDestinationsResponse_httpStatus' - The response's http status code.
newListDestinationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDestinationsResponse
newListDestinationsResponse :: Int -> ListDestinationsResponse
newListDestinationsResponse Int
pHttpStatus_ =
  ListDestinationsResponse'
    { $sel:destinationList:ListDestinationsResponse' :: Maybe [Destinations]
destinationList =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDestinationsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDestinationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The list of destinations.
listDestinationsResponse_destinationList :: Lens.Lens' ListDestinationsResponse (Prelude.Maybe [Destinations])
listDestinationsResponse_destinationList :: Lens' ListDestinationsResponse (Maybe [Destinations])
listDestinationsResponse_destinationList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDestinationsResponse' {Maybe [Destinations]
destinationList :: Maybe [Destinations]
$sel:destinationList:ListDestinationsResponse' :: ListDestinationsResponse -> Maybe [Destinations]
destinationList} -> Maybe [Destinations]
destinationList) (\s :: ListDestinationsResponse
s@ListDestinationsResponse' {} Maybe [Destinations]
a -> ListDestinationsResponse
s {$sel:destinationList:ListDestinationsResponse' :: Maybe [Destinations]
destinationList = Maybe [Destinations]
a} :: ListDestinationsResponse) 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 to use to get the next set of results, or __null__ if there
-- are no additional results.
listDestinationsResponse_nextToken :: Lens.Lens' ListDestinationsResponse (Prelude.Maybe Prelude.Text)
listDestinationsResponse_nextToken :: Lens' ListDestinationsResponse (Maybe Text)
listDestinationsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDestinationsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDestinationsResponse' :: ListDestinationsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDestinationsResponse
s@ListDestinationsResponse' {} Maybe Text
a -> ListDestinationsResponse
s {$sel:nextToken:ListDestinationsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListDestinationsResponse)

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

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