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

    -- * Request Lenses
    listDestinations_nextToken,
    listDestinations_maxResults,

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

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

import qualified Amazonka.Core as Core
import Amazonka.IoTWireless.Types
import qualified Amazonka.Lens as Lens
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'
  { -- | 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,
    -- | The maximum number of results to return in this operation.
    ListDestinations -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListDestinations -> ListDestinations -> Bool
(ListDestinations -> ListDestinations -> Bool)
-> (ListDestinations -> ListDestinations -> Bool)
-> Eq ListDestinations
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]
(Int -> ReadS ListDestinations)
-> ReadS [ListDestinations]
-> ReadPrec ListDestinations
-> ReadPrec [ListDestinations]
-> Read 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
(Int -> ListDestinations -> ShowS)
-> (ListDestinations -> String)
-> ([ListDestinations] -> ShowS)
-> Show ListDestinations
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. ListDestinations -> Rep ListDestinations x)
-> (forall x. Rep ListDestinations x -> ListDestinations)
-> Generic ListDestinations
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:
--
-- '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.
--
-- 'maxResults', 'listDestinations_maxResults' - The maximum number of results to return in this operation.
newListDestinations ::
  ListDestinations
newListDestinations :: ListDestinations
newListDestinations =
  ListDestinations' :: Maybe Text -> Maybe Natural -> ListDestinations
ListDestinations'
    { $sel:nextToken:ListDestinations' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListDestinations' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> ListDestinations -> f ListDestinations
listDestinations_nextToken = (ListDestinations -> Maybe Text)
-> (ListDestinations -> Maybe Text -> ListDestinations)
-> Lens ListDestinations ListDestinations (Maybe Text) (Maybe Text)
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)

-- | The maximum number of results to return in this operation.
listDestinations_maxResults :: Lens.Lens' ListDestinations (Prelude.Maybe Prelude.Natural)
listDestinations_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListDestinations -> f ListDestinations
listDestinations_maxResults = (ListDestinations -> Maybe Natural)
-> (ListDestinations -> Maybe Natural -> ListDestinations)
-> Lens
     ListDestinations ListDestinations (Maybe Natural) (Maybe Natural)
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)

instance Core.AWSRequest ListDestinations where
  type
    AWSResponse ListDestinations =
      ListDestinationsResponse
  request :: ListDestinations -> Request ListDestinations
request = Service -> ListDestinations -> Request ListDestinations
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListDestinations
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDestinations)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListDestinations))
-> Logger
-> Service
-> Proxy ListDestinations
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDestinations)))
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 Text
-> Maybe [Destinations] -> Int -> ListDestinationsResponse
ListDestinationsResponse'
            (Maybe Text
 -> Maybe [Destinations] -> Int -> ListDestinationsResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe [Destinations] -> Int -> ListDestinationsResponse)
forall (f :: * -> *) a b. Functor 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 (Maybe [Destinations] -> Int -> ListDestinationsResponse)
-> Either String (Maybe [Destinations])
-> Either String (Int -> ListDestinationsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Either String (Maybe (Maybe [Destinations]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"DestinationList"
                            Either String (Maybe (Maybe [Destinations]))
-> Maybe [Destinations] -> Either String (Maybe [Destinations])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Destinations]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Int -> ListDestinationsResponse)
-> Either String Int -> Either String ListDestinationsResponse
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 ListDestinations

instance Prelude.NFData ListDestinations

instance Core.ToHeaders ListDestinations where
  toHeaders :: ListDestinations -> ResponseHeaders
toHeaders = ResponseHeaders -> ListDestinations -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery ListDestinations where
  toQuery :: ListDestinations -> QueryString
toQuery ListDestinations' {Maybe Natural
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:maxResults:ListDestinations' :: ListDestinations -> Maybe Natural
$sel:nextToken:ListDestinations' :: ListDestinations -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"nextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
        ByteString
"maxResults" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
maxResults
      ]

-- | /See:/ 'newListDestinationsResponse' smart constructor.
data ListDestinationsResponse = ListDestinationsResponse'
  { -- | 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 list of destinations.
    ListDestinationsResponse -> Maybe [Destinations]
destinationList :: Prelude.Maybe [Destinations],
    -- | The response's http status code.
    ListDestinationsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDestinationsResponse -> ListDestinationsResponse -> Bool
(ListDestinationsResponse -> ListDestinationsResponse -> Bool)
-> (ListDestinationsResponse -> ListDestinationsResponse -> Bool)
-> Eq ListDestinationsResponse
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]
(Int -> ReadS ListDestinationsResponse)
-> ReadS [ListDestinationsResponse]
-> ReadPrec ListDestinationsResponse
-> ReadPrec [ListDestinationsResponse]
-> Read 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
(Int -> ListDestinationsResponse -> ShowS)
-> (ListDestinationsResponse -> String)
-> ([ListDestinationsResponse] -> ShowS)
-> Show ListDestinationsResponse
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.
 ListDestinationsResponse -> Rep ListDestinationsResponse x)
-> (forall x.
    Rep ListDestinationsResponse x -> ListDestinationsResponse)
-> Generic ListDestinationsResponse
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:
--
-- 'nextToken', 'listDestinationsResponse_nextToken' - The token to use to get the next set of results, or __null__ if there
-- are no additional results.
--
-- 'destinationList', 'listDestinationsResponse_destinationList' - The list of destinations.
--
-- 'httpStatus', 'listDestinationsResponse_httpStatus' - The response's http status code.
newListDestinationsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDestinationsResponse
newListDestinationsResponse :: Int -> ListDestinationsResponse
newListDestinationsResponse Int
pHttpStatus_ =
  ListDestinationsResponse' :: Maybe Text
-> Maybe [Destinations] -> Int -> ListDestinationsResponse
ListDestinationsResponse'
    { $sel:nextToken:ListDestinationsResponse' :: Maybe Text
nextToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:destinationList:ListDestinationsResponse' :: Maybe [Destinations]
destinationList = Maybe [Destinations]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDestinationsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> ListDestinationsResponse -> f ListDestinationsResponse
listDestinationsResponse_nextToken = (ListDestinationsResponse -> Maybe Text)
-> (ListDestinationsResponse
    -> Maybe Text -> ListDestinationsResponse)
-> Lens
     ListDestinationsResponse
     ListDestinationsResponse
     (Maybe Text)
     (Maybe Text)
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 list of destinations.
listDestinationsResponse_destinationList :: Lens.Lens' ListDestinationsResponse (Prelude.Maybe [Destinations])
listDestinationsResponse_destinationList :: (Maybe [Destinations] -> f (Maybe [Destinations]))
-> ListDestinationsResponse -> f ListDestinationsResponse
listDestinationsResponse_destinationList = (ListDestinationsResponse -> Maybe [Destinations])
-> (ListDestinationsResponse
    -> Maybe [Destinations] -> ListDestinationsResponse)
-> Lens
     ListDestinationsResponse
     ListDestinationsResponse
     (Maybe [Destinations])
     (Maybe [Destinations])
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) ((Maybe [Destinations] -> f (Maybe [Destinations]))
 -> ListDestinationsResponse -> f ListDestinationsResponse)
-> ((Maybe [Destinations] -> f (Maybe [Destinations]))
    -> Maybe [Destinations] -> f (Maybe [Destinations]))
-> (Maybe [Destinations] -> f (Maybe [Destinations]))
-> ListDestinationsResponse
-> f ListDestinationsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Destinations] [Destinations] [Destinations] [Destinations]
-> Iso
     (Maybe [Destinations])
     (Maybe [Destinations])
     (Maybe [Destinations])
     (Maybe [Destinations])
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 [Destinations] [Destinations] [Destinations] [Destinations]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
listDestinationsResponse_httpStatus :: Lens.Lens' ListDestinationsResponse Prelude.Int
listDestinationsResponse_httpStatus :: (Int -> f Int)
-> ListDestinationsResponse -> f ListDestinationsResponse
listDestinationsResponse_httpStatus = (ListDestinationsResponse -> Int)
-> (ListDestinationsResponse -> Int -> ListDestinationsResponse)
-> Lens ListDestinationsResponse ListDestinationsResponse Int Int
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