{-# 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.ListDeviceProfiles
-- 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 device profiles registered to your AWS account.
module Amazonka.IoTWireless.ListDeviceProfiles
  ( -- * Creating a Request
    ListDeviceProfiles (..),
    newListDeviceProfiles,

    -- * Request Lenses
    listDeviceProfiles_maxResults,
    listDeviceProfiles_nextToken,

    -- * Destructuring the Response
    ListDeviceProfilesResponse (..),
    newListDeviceProfilesResponse,

    -- * Response Lenses
    listDeviceProfilesResponse_deviceProfileList,
    listDeviceProfilesResponse_nextToken,
    listDeviceProfilesResponse_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:/ 'newListDeviceProfiles' smart constructor.
data ListDeviceProfiles = ListDeviceProfiles'
  { -- | The maximum number of results to return in this operation.
    ListDeviceProfiles -> 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.
    ListDeviceProfiles -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListDeviceProfiles -> ListDeviceProfiles -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDeviceProfiles -> ListDeviceProfiles -> Bool
$c/= :: ListDeviceProfiles -> ListDeviceProfiles -> Bool
== :: ListDeviceProfiles -> ListDeviceProfiles -> Bool
$c== :: ListDeviceProfiles -> ListDeviceProfiles -> Bool
Prelude.Eq, ReadPrec [ListDeviceProfiles]
ReadPrec ListDeviceProfiles
Int -> ReadS ListDeviceProfiles
ReadS [ListDeviceProfiles]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDeviceProfiles]
$creadListPrec :: ReadPrec [ListDeviceProfiles]
readPrec :: ReadPrec ListDeviceProfiles
$creadPrec :: ReadPrec ListDeviceProfiles
readList :: ReadS [ListDeviceProfiles]
$creadList :: ReadS [ListDeviceProfiles]
readsPrec :: Int -> ReadS ListDeviceProfiles
$creadsPrec :: Int -> ReadS ListDeviceProfiles
Prelude.Read, Int -> ListDeviceProfiles -> ShowS
[ListDeviceProfiles] -> ShowS
ListDeviceProfiles -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDeviceProfiles] -> ShowS
$cshowList :: [ListDeviceProfiles] -> ShowS
show :: ListDeviceProfiles -> String
$cshow :: ListDeviceProfiles -> String
showsPrec :: Int -> ListDeviceProfiles -> ShowS
$cshowsPrec :: Int -> ListDeviceProfiles -> ShowS
Prelude.Show, forall x. Rep ListDeviceProfiles x -> ListDeviceProfiles
forall x. ListDeviceProfiles -> Rep ListDeviceProfiles x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDeviceProfiles x -> ListDeviceProfiles
$cfrom :: forall x. ListDeviceProfiles -> Rep ListDeviceProfiles x
Prelude.Generic)

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

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

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

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

instance Data.ToPath ListDeviceProfiles where
  toPath :: ListDeviceProfiles -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/device-profiles"

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

-- |
-- Create a value of 'ListDeviceProfilesResponse' 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:
--
-- 'deviceProfileList', 'listDeviceProfilesResponse_deviceProfileList' - The list of device profiles.
--
-- 'nextToken', 'listDeviceProfilesResponse_nextToken' - The token to use to get the next set of results, or __null__ if there
-- are no additional results.
--
-- 'httpStatus', 'listDeviceProfilesResponse_httpStatus' - The response's http status code.
newListDeviceProfilesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDeviceProfilesResponse
newListDeviceProfilesResponse :: Int -> ListDeviceProfilesResponse
newListDeviceProfilesResponse Int
pHttpStatus_ =
  ListDeviceProfilesResponse'
    { $sel:deviceProfileList:ListDeviceProfilesResponse' :: Maybe [DeviceProfile]
deviceProfileList =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDeviceProfilesResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDeviceProfilesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The list of device profiles.
listDeviceProfilesResponse_deviceProfileList :: Lens.Lens' ListDeviceProfilesResponse (Prelude.Maybe [DeviceProfile])
listDeviceProfilesResponse_deviceProfileList :: Lens' ListDeviceProfilesResponse (Maybe [DeviceProfile])
listDeviceProfilesResponse_deviceProfileList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDeviceProfilesResponse' {Maybe [DeviceProfile]
deviceProfileList :: Maybe [DeviceProfile]
$sel:deviceProfileList:ListDeviceProfilesResponse' :: ListDeviceProfilesResponse -> Maybe [DeviceProfile]
deviceProfileList} -> Maybe [DeviceProfile]
deviceProfileList) (\s :: ListDeviceProfilesResponse
s@ListDeviceProfilesResponse' {} Maybe [DeviceProfile]
a -> ListDeviceProfilesResponse
s {$sel:deviceProfileList:ListDeviceProfilesResponse' :: Maybe [DeviceProfile]
deviceProfileList = Maybe [DeviceProfile]
a} :: ListDeviceProfilesResponse) 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.
listDeviceProfilesResponse_nextToken :: Lens.Lens' ListDeviceProfilesResponse (Prelude.Maybe Prelude.Text)
listDeviceProfilesResponse_nextToken :: Lens' ListDeviceProfilesResponse (Maybe Text)
listDeviceProfilesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDeviceProfilesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDeviceProfilesResponse' :: ListDeviceProfilesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDeviceProfilesResponse
s@ListDeviceProfilesResponse' {} Maybe Text
a -> ListDeviceProfilesResponse
s {$sel:nextToken:ListDeviceProfilesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListDeviceProfilesResponse)

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

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