{-# 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.ListPartnerAccounts
-- 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 partner accounts associated with your AWS account.
module Amazonka.IoTWireless.ListPartnerAccounts
  ( -- * Creating a Request
    ListPartnerAccounts (..),
    newListPartnerAccounts,

    -- * Request Lenses
    listPartnerAccounts_maxResults,
    listPartnerAccounts_nextToken,

    -- * Destructuring the Response
    ListPartnerAccountsResponse (..),
    newListPartnerAccountsResponse,

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

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

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

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

instance Core.AWSRequest ListPartnerAccounts where
  type
    AWSResponse ListPartnerAccounts =
      ListPartnerAccountsResponse
  request :: (Service -> Service)
-> ListPartnerAccounts -> Request ListPartnerAccounts
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 ListPartnerAccounts
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListPartnerAccounts)))
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
-> Maybe [SidewalkAccountInfoWithFingerprint]
-> Int
-> ListPartnerAccountsResponse
ListPartnerAccountsResponse'
            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.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Sidewalk" 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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListPartnerAccounts where
  hashWithSalt :: Int -> ListPartnerAccounts -> Int
hashWithSalt Int
_salt ListPartnerAccounts' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListPartnerAccounts' :: ListPartnerAccounts -> Maybe Text
$sel:maxResults:ListPartnerAccounts' :: ListPartnerAccounts -> 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 ListPartnerAccounts where
  rnf :: ListPartnerAccounts -> ()
rnf ListPartnerAccounts' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListPartnerAccounts' :: ListPartnerAccounts -> Maybe Text
$sel:maxResults:ListPartnerAccounts' :: ListPartnerAccounts -> 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 ListPartnerAccounts where
  toHeaders :: ListPartnerAccounts -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath ListPartnerAccounts where
  toPath :: ListPartnerAccounts -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/partner-accounts"

instance Data.ToQuery ListPartnerAccounts where
  toQuery :: ListPartnerAccounts -> QueryString
toQuery ListPartnerAccounts' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListPartnerAccounts' :: ListPartnerAccounts -> Maybe Text
$sel:maxResults:ListPartnerAccounts' :: ListPartnerAccounts -> 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:/ 'newListPartnerAccountsResponse' smart constructor.
data ListPartnerAccountsResponse = ListPartnerAccountsResponse'
  { -- | The token to use to get the next set of results, or __null__ if there
    -- are no additional results.
    ListPartnerAccountsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The Sidewalk account credentials.
    ListPartnerAccountsResponse
-> Maybe [SidewalkAccountInfoWithFingerprint]
sidewalk :: Prelude.Maybe [SidewalkAccountInfoWithFingerprint],
    -- | The response's http status code.
    ListPartnerAccountsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListPartnerAccountsResponse -> ListPartnerAccountsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPartnerAccountsResponse -> ListPartnerAccountsResponse -> Bool
$c/= :: ListPartnerAccountsResponse -> ListPartnerAccountsResponse -> Bool
== :: ListPartnerAccountsResponse -> ListPartnerAccountsResponse -> Bool
$c== :: ListPartnerAccountsResponse -> ListPartnerAccountsResponse -> Bool
Prelude.Eq, Int -> ListPartnerAccountsResponse -> ShowS
[ListPartnerAccountsResponse] -> ShowS
ListPartnerAccountsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPartnerAccountsResponse] -> ShowS
$cshowList :: [ListPartnerAccountsResponse] -> ShowS
show :: ListPartnerAccountsResponse -> String
$cshow :: ListPartnerAccountsResponse -> String
showsPrec :: Int -> ListPartnerAccountsResponse -> ShowS
$cshowsPrec :: Int -> ListPartnerAccountsResponse -> ShowS
Prelude.Show, forall x.
Rep ListPartnerAccountsResponse x -> ListPartnerAccountsResponse
forall x.
ListPartnerAccountsResponse -> Rep ListPartnerAccountsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListPartnerAccountsResponse x -> ListPartnerAccountsResponse
$cfrom :: forall x.
ListPartnerAccountsResponse -> Rep ListPartnerAccountsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListPartnerAccountsResponse' 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', 'listPartnerAccountsResponse_nextToken' - The token to use to get the next set of results, or __null__ if there
-- are no additional results.
--
-- 'sidewalk', 'listPartnerAccountsResponse_sidewalk' - The Sidewalk account credentials.
--
-- 'httpStatus', 'listPartnerAccountsResponse_httpStatus' - The response's http status code.
newListPartnerAccountsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListPartnerAccountsResponse
newListPartnerAccountsResponse :: Int -> ListPartnerAccountsResponse
newListPartnerAccountsResponse Int
pHttpStatus_ =
  ListPartnerAccountsResponse'
    { $sel:nextToken:ListPartnerAccountsResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:sidewalk:ListPartnerAccountsResponse' :: Maybe [SidewalkAccountInfoWithFingerprint]
sidewalk = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListPartnerAccountsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The token to use to get the next set of results, or __null__ if there
-- are no additional results.
listPartnerAccountsResponse_nextToken :: Lens.Lens' ListPartnerAccountsResponse (Prelude.Maybe Prelude.Text)
listPartnerAccountsResponse_nextToken :: Lens' ListPartnerAccountsResponse (Maybe Text)
listPartnerAccountsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPartnerAccountsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListPartnerAccountsResponse' :: ListPartnerAccountsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListPartnerAccountsResponse
s@ListPartnerAccountsResponse' {} Maybe Text
a -> ListPartnerAccountsResponse
s {$sel:nextToken:ListPartnerAccountsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListPartnerAccountsResponse)

-- | The Sidewalk account credentials.
listPartnerAccountsResponse_sidewalk :: Lens.Lens' ListPartnerAccountsResponse (Prelude.Maybe [SidewalkAccountInfoWithFingerprint])
listPartnerAccountsResponse_sidewalk :: Lens'
  ListPartnerAccountsResponse
  (Maybe [SidewalkAccountInfoWithFingerprint])
listPartnerAccountsResponse_sidewalk = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPartnerAccountsResponse' {Maybe [SidewalkAccountInfoWithFingerprint]
sidewalk :: Maybe [SidewalkAccountInfoWithFingerprint]
$sel:sidewalk:ListPartnerAccountsResponse' :: ListPartnerAccountsResponse
-> Maybe [SidewalkAccountInfoWithFingerprint]
sidewalk} -> Maybe [SidewalkAccountInfoWithFingerprint]
sidewalk) (\s :: ListPartnerAccountsResponse
s@ListPartnerAccountsResponse' {} Maybe [SidewalkAccountInfoWithFingerprint]
a -> ListPartnerAccountsResponse
s {$sel:sidewalk:ListPartnerAccountsResponse' :: Maybe [SidewalkAccountInfoWithFingerprint]
sidewalk = Maybe [SidewalkAccountInfoWithFingerprint]
a} :: ListPartnerAccountsResponse) 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 response's http status code.
listPartnerAccountsResponse_httpStatus :: Lens.Lens' ListPartnerAccountsResponse Prelude.Int
listPartnerAccountsResponse_httpStatus :: Lens' ListPartnerAccountsResponse Int
listPartnerAccountsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPartnerAccountsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListPartnerAccountsResponse' :: ListPartnerAccountsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListPartnerAccountsResponse
s@ListPartnerAccountsResponse' {} Int
a -> ListPartnerAccountsResponse
s {$sel:httpStatus:ListPartnerAccountsResponse' :: Int
httpStatus = Int
a} :: ListPartnerAccountsResponse)

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