{-# 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.Connect.ListPhoneNumbers
-- 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)
--
-- Provides information about the phone numbers for the specified Amazon
-- Connect instance.
--
-- For more information about phone numbers, see
-- <https://docs.aws.amazon.com/connect/latest/adminguide/contact-center-phone-number.html Set Up Phone Numbers for Your Contact Center>
-- in the /Amazon Connect Administrator Guide/.
--
-- This operation returns paginated results.
module Amazonka.Connect.ListPhoneNumbers
  ( -- * Creating a Request
    ListPhoneNumbers (..),
    newListPhoneNumbers,

    -- * Request Lenses
    listPhoneNumbers_phoneNumberTypes,
    listPhoneNumbers_phoneNumberCountryCodes,
    listPhoneNumbers_nextToken,
    listPhoneNumbers_maxResults,
    listPhoneNumbers_instanceId,

    -- * Destructuring the Response
    ListPhoneNumbersResponse (..),
    newListPhoneNumbersResponse,

    -- * Response Lenses
    listPhoneNumbersResponse_phoneNumberSummaryList,
    listPhoneNumbersResponse_nextToken,
    listPhoneNumbersResponse_httpStatus,
  )
where

import Amazonka.Connect.Types
import qualified Amazonka.Core as Core
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:/ 'newListPhoneNumbers' smart constructor.
data ListPhoneNumbers = ListPhoneNumbers'
  { -- | The type of phone number.
    ListPhoneNumbers -> Maybe [PhoneNumberType]
phoneNumberTypes :: Prelude.Maybe [PhoneNumberType],
    -- | The ISO country code.
    ListPhoneNumbers -> Maybe [PhoneNumberCountryCode]
phoneNumberCountryCodes :: Prelude.Maybe [PhoneNumberCountryCode],
    -- | The token for the next set of results. Use the value returned in the
    -- previous response in the next request to retrieve the next set of
    -- results.
    ListPhoneNumbers -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return per page.
    ListPhoneNumbers -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The identifier of the Amazon Connect instance. You can find the
    -- instanceId in the ARN of the instance.
    ListPhoneNumbers -> Text
instanceId :: Prelude.Text
  }
  deriving (ListPhoneNumbers -> ListPhoneNumbers -> Bool
(ListPhoneNumbers -> ListPhoneNumbers -> Bool)
-> (ListPhoneNumbers -> ListPhoneNumbers -> Bool)
-> Eq ListPhoneNumbers
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPhoneNumbers -> ListPhoneNumbers -> Bool
$c/= :: ListPhoneNumbers -> ListPhoneNumbers -> Bool
== :: ListPhoneNumbers -> ListPhoneNumbers -> Bool
$c== :: ListPhoneNumbers -> ListPhoneNumbers -> Bool
Prelude.Eq, ReadPrec [ListPhoneNumbers]
ReadPrec ListPhoneNumbers
Int -> ReadS ListPhoneNumbers
ReadS [ListPhoneNumbers]
(Int -> ReadS ListPhoneNumbers)
-> ReadS [ListPhoneNumbers]
-> ReadPrec ListPhoneNumbers
-> ReadPrec [ListPhoneNumbers]
-> Read ListPhoneNumbers
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPhoneNumbers]
$creadListPrec :: ReadPrec [ListPhoneNumbers]
readPrec :: ReadPrec ListPhoneNumbers
$creadPrec :: ReadPrec ListPhoneNumbers
readList :: ReadS [ListPhoneNumbers]
$creadList :: ReadS [ListPhoneNumbers]
readsPrec :: Int -> ReadS ListPhoneNumbers
$creadsPrec :: Int -> ReadS ListPhoneNumbers
Prelude.Read, Int -> ListPhoneNumbers -> ShowS
[ListPhoneNumbers] -> ShowS
ListPhoneNumbers -> String
(Int -> ListPhoneNumbers -> ShowS)
-> (ListPhoneNumbers -> String)
-> ([ListPhoneNumbers] -> ShowS)
-> Show ListPhoneNumbers
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPhoneNumbers] -> ShowS
$cshowList :: [ListPhoneNumbers] -> ShowS
show :: ListPhoneNumbers -> String
$cshow :: ListPhoneNumbers -> String
showsPrec :: Int -> ListPhoneNumbers -> ShowS
$cshowsPrec :: Int -> ListPhoneNumbers -> ShowS
Prelude.Show, (forall x. ListPhoneNumbers -> Rep ListPhoneNumbers x)
-> (forall x. Rep ListPhoneNumbers x -> ListPhoneNumbers)
-> Generic ListPhoneNumbers
forall x. Rep ListPhoneNumbers x -> ListPhoneNumbers
forall x. ListPhoneNumbers -> Rep ListPhoneNumbers x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPhoneNumbers x -> ListPhoneNumbers
$cfrom :: forall x. ListPhoneNumbers -> Rep ListPhoneNumbers x
Prelude.Generic)

-- |
-- Create a value of 'ListPhoneNumbers' 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:
--
-- 'phoneNumberTypes', 'listPhoneNumbers_phoneNumberTypes' - The type of phone number.
--
-- 'phoneNumberCountryCodes', 'listPhoneNumbers_phoneNumberCountryCodes' - The ISO country code.
--
-- 'nextToken', 'listPhoneNumbers_nextToken' - The token for the next set of results. Use the value returned in the
-- previous response in the next request to retrieve the next set of
-- results.
--
-- 'maxResults', 'listPhoneNumbers_maxResults' - The maximum number of results to return per page.
--
-- 'instanceId', 'listPhoneNumbers_instanceId' - The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
newListPhoneNumbers ::
  -- | 'instanceId'
  Prelude.Text ->
  ListPhoneNumbers
newListPhoneNumbers :: Text -> ListPhoneNumbers
newListPhoneNumbers Text
pInstanceId_ =
  ListPhoneNumbers' :: Maybe [PhoneNumberType]
-> Maybe [PhoneNumberCountryCode]
-> Maybe Text
-> Maybe Natural
-> Text
-> ListPhoneNumbers
ListPhoneNumbers'
    { $sel:phoneNumberTypes:ListPhoneNumbers' :: Maybe [PhoneNumberType]
phoneNumberTypes =
        Maybe [PhoneNumberType]
forall a. Maybe a
Prelude.Nothing,
      $sel:phoneNumberCountryCodes:ListPhoneNumbers' :: Maybe [PhoneNumberCountryCode]
phoneNumberCountryCodes = Maybe [PhoneNumberCountryCode]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListPhoneNumbers' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListPhoneNumbers' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:instanceId:ListPhoneNumbers' :: Text
instanceId = Text
pInstanceId_
    }

-- | The type of phone number.
listPhoneNumbers_phoneNumberTypes :: Lens.Lens' ListPhoneNumbers (Prelude.Maybe [PhoneNumberType])
listPhoneNumbers_phoneNumberTypes :: (Maybe [PhoneNumberType] -> f (Maybe [PhoneNumberType]))
-> ListPhoneNumbers -> f ListPhoneNumbers
listPhoneNumbers_phoneNumberTypes = (ListPhoneNumbers -> Maybe [PhoneNumberType])
-> (ListPhoneNumbers
    -> Maybe [PhoneNumberType] -> ListPhoneNumbers)
-> Lens
     ListPhoneNumbers
     ListPhoneNumbers
     (Maybe [PhoneNumberType])
     (Maybe [PhoneNumberType])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPhoneNumbers' {Maybe [PhoneNumberType]
phoneNumberTypes :: Maybe [PhoneNumberType]
$sel:phoneNumberTypes:ListPhoneNumbers' :: ListPhoneNumbers -> Maybe [PhoneNumberType]
phoneNumberTypes} -> Maybe [PhoneNumberType]
phoneNumberTypes) (\s :: ListPhoneNumbers
s@ListPhoneNumbers' {} Maybe [PhoneNumberType]
a -> ListPhoneNumbers
s {$sel:phoneNumberTypes:ListPhoneNumbers' :: Maybe [PhoneNumberType]
phoneNumberTypes = Maybe [PhoneNumberType]
a} :: ListPhoneNumbers) ((Maybe [PhoneNumberType] -> f (Maybe [PhoneNumberType]))
 -> ListPhoneNumbers -> f ListPhoneNumbers)
-> ((Maybe [PhoneNumberType] -> f (Maybe [PhoneNumberType]))
    -> Maybe [PhoneNumberType] -> f (Maybe [PhoneNumberType]))
-> (Maybe [PhoneNumberType] -> f (Maybe [PhoneNumberType]))
-> ListPhoneNumbers
-> f ListPhoneNumbers
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PhoneNumberType]
  [PhoneNumberType]
  [PhoneNumberType]
  [PhoneNumberType]
-> Iso
     (Maybe [PhoneNumberType])
     (Maybe [PhoneNumberType])
     (Maybe [PhoneNumberType])
     (Maybe [PhoneNumberType])
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
  [PhoneNumberType]
  [PhoneNumberType]
  [PhoneNumberType]
  [PhoneNumberType]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ISO country code.
listPhoneNumbers_phoneNumberCountryCodes :: Lens.Lens' ListPhoneNumbers (Prelude.Maybe [PhoneNumberCountryCode])
listPhoneNumbers_phoneNumberCountryCodes :: (Maybe [PhoneNumberCountryCode]
 -> f (Maybe [PhoneNumberCountryCode]))
-> ListPhoneNumbers -> f ListPhoneNumbers
listPhoneNumbers_phoneNumberCountryCodes = (ListPhoneNumbers -> Maybe [PhoneNumberCountryCode])
-> (ListPhoneNumbers
    -> Maybe [PhoneNumberCountryCode] -> ListPhoneNumbers)
-> Lens
     ListPhoneNumbers
     ListPhoneNumbers
     (Maybe [PhoneNumberCountryCode])
     (Maybe [PhoneNumberCountryCode])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPhoneNumbers' {Maybe [PhoneNumberCountryCode]
phoneNumberCountryCodes :: Maybe [PhoneNumberCountryCode]
$sel:phoneNumberCountryCodes:ListPhoneNumbers' :: ListPhoneNumbers -> Maybe [PhoneNumberCountryCode]
phoneNumberCountryCodes} -> Maybe [PhoneNumberCountryCode]
phoneNumberCountryCodes) (\s :: ListPhoneNumbers
s@ListPhoneNumbers' {} Maybe [PhoneNumberCountryCode]
a -> ListPhoneNumbers
s {$sel:phoneNumberCountryCodes:ListPhoneNumbers' :: Maybe [PhoneNumberCountryCode]
phoneNumberCountryCodes = Maybe [PhoneNumberCountryCode]
a} :: ListPhoneNumbers) ((Maybe [PhoneNumberCountryCode]
  -> f (Maybe [PhoneNumberCountryCode]))
 -> ListPhoneNumbers -> f ListPhoneNumbers)
-> ((Maybe [PhoneNumberCountryCode]
     -> f (Maybe [PhoneNumberCountryCode]))
    -> Maybe [PhoneNumberCountryCode]
    -> f (Maybe [PhoneNumberCountryCode]))
-> (Maybe [PhoneNumberCountryCode]
    -> f (Maybe [PhoneNumberCountryCode]))
-> ListPhoneNumbers
-> f ListPhoneNumbers
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PhoneNumberCountryCode]
  [PhoneNumberCountryCode]
  [PhoneNumberCountryCode]
  [PhoneNumberCountryCode]
-> Iso
     (Maybe [PhoneNumberCountryCode])
     (Maybe [PhoneNumberCountryCode])
     (Maybe [PhoneNumberCountryCode])
     (Maybe [PhoneNumberCountryCode])
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
  [PhoneNumberCountryCode]
  [PhoneNumberCountryCode]
  [PhoneNumberCountryCode]
  [PhoneNumberCountryCode]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token for the next set of results. Use the value returned in the
-- previous response in the next request to retrieve the next set of
-- results.
listPhoneNumbers_nextToken :: Lens.Lens' ListPhoneNumbers (Prelude.Maybe Prelude.Text)
listPhoneNumbers_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListPhoneNumbers -> f ListPhoneNumbers
listPhoneNumbers_nextToken = (ListPhoneNumbers -> Maybe Text)
-> (ListPhoneNumbers -> Maybe Text -> ListPhoneNumbers)
-> Lens ListPhoneNumbers ListPhoneNumbers (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPhoneNumbers' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListPhoneNumbers' :: ListPhoneNumbers -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListPhoneNumbers
s@ListPhoneNumbers' {} Maybe Text
a -> ListPhoneNumbers
s {$sel:nextToken:ListPhoneNumbers' :: Maybe Text
nextToken = Maybe Text
a} :: ListPhoneNumbers)

-- | The maximum number of results to return per page.
listPhoneNumbers_maxResults :: Lens.Lens' ListPhoneNumbers (Prelude.Maybe Prelude.Natural)
listPhoneNumbers_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListPhoneNumbers -> f ListPhoneNumbers
listPhoneNumbers_maxResults = (ListPhoneNumbers -> Maybe Natural)
-> (ListPhoneNumbers -> Maybe Natural -> ListPhoneNumbers)
-> Lens
     ListPhoneNumbers ListPhoneNumbers (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPhoneNumbers' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListPhoneNumbers' :: ListPhoneNumbers -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListPhoneNumbers
s@ListPhoneNumbers' {} Maybe Natural
a -> ListPhoneNumbers
s {$sel:maxResults:ListPhoneNumbers' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListPhoneNumbers)

-- | The identifier of the Amazon Connect instance. You can find the
-- instanceId in the ARN of the instance.
listPhoneNumbers_instanceId :: Lens.Lens' ListPhoneNumbers Prelude.Text
listPhoneNumbers_instanceId :: (Text -> f Text) -> ListPhoneNumbers -> f ListPhoneNumbers
listPhoneNumbers_instanceId = (ListPhoneNumbers -> Text)
-> (ListPhoneNumbers -> Text -> ListPhoneNumbers)
-> Lens ListPhoneNumbers ListPhoneNumbers Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPhoneNumbers' {Text
instanceId :: Text
$sel:instanceId:ListPhoneNumbers' :: ListPhoneNumbers -> Text
instanceId} -> Text
instanceId) (\s :: ListPhoneNumbers
s@ListPhoneNumbers' {} Text
a -> ListPhoneNumbers
s {$sel:instanceId:ListPhoneNumbers' :: Text
instanceId = Text
a} :: ListPhoneNumbers)

instance Core.AWSPager ListPhoneNumbers where
  page :: ListPhoneNumbers
-> AWSResponse ListPhoneNumbers -> Maybe ListPhoneNumbers
page ListPhoneNumbers
rq AWSResponse ListPhoneNumbers
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListPhoneNumbers
ListPhoneNumbersResponse
rs
            ListPhoneNumbersResponse
-> Getting (First Text) ListPhoneNumbersResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListPhoneNumbersResponse
-> Const (First Text) ListPhoneNumbersResponse
Lens' ListPhoneNumbersResponse (Maybe Text)
listPhoneNumbersResponse_nextToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListPhoneNumbersResponse
 -> Const (First Text) ListPhoneNumbersResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListPhoneNumbersResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListPhoneNumbers
forall a. Maybe a
Prelude.Nothing
    | Maybe [PhoneNumberSummary] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListPhoneNumbers
ListPhoneNumbersResponse
rs
            ListPhoneNumbersResponse
-> Getting
     (First [PhoneNumberSummary])
     ListPhoneNumbersResponse
     [PhoneNumberSummary]
-> Maybe [PhoneNumberSummary]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [PhoneNumberSummary]
 -> Const (First [PhoneNumberSummary]) (Maybe [PhoneNumberSummary]))
-> ListPhoneNumbersResponse
-> Const (First [PhoneNumberSummary]) ListPhoneNumbersResponse
Lens' ListPhoneNumbersResponse (Maybe [PhoneNumberSummary])
listPhoneNumbersResponse_phoneNumberSummaryList
              ((Maybe [PhoneNumberSummary]
  -> Const (First [PhoneNumberSummary]) (Maybe [PhoneNumberSummary]))
 -> ListPhoneNumbersResponse
 -> Const (First [PhoneNumberSummary]) ListPhoneNumbersResponse)
-> (([PhoneNumberSummary]
     -> Const (First [PhoneNumberSummary]) [PhoneNumberSummary])
    -> Maybe [PhoneNumberSummary]
    -> Const (First [PhoneNumberSummary]) (Maybe [PhoneNumberSummary]))
-> Getting
     (First [PhoneNumberSummary])
     ListPhoneNumbersResponse
     [PhoneNumberSummary]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([PhoneNumberSummary]
 -> Const (First [PhoneNumberSummary]) [PhoneNumberSummary])
-> Maybe [PhoneNumberSummary]
-> Const (First [PhoneNumberSummary]) (Maybe [PhoneNumberSummary])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListPhoneNumbers
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListPhoneNumbers -> Maybe ListPhoneNumbers
forall a. a -> Maybe a
Prelude.Just (ListPhoneNumbers -> Maybe ListPhoneNumbers)
-> ListPhoneNumbers -> Maybe ListPhoneNumbers
forall a b. (a -> b) -> a -> b
Prelude.$
        ListPhoneNumbers
rq
          ListPhoneNumbers
-> (ListPhoneNumbers -> ListPhoneNumbers) -> ListPhoneNumbers
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListPhoneNumbers -> Identity ListPhoneNumbers
Lens ListPhoneNumbers ListPhoneNumbers (Maybe Text) (Maybe Text)
listPhoneNumbers_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListPhoneNumbers -> Identity ListPhoneNumbers)
-> Maybe Text -> ListPhoneNumbers -> ListPhoneNumbers
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListPhoneNumbers
ListPhoneNumbersResponse
rs
          ListPhoneNumbersResponse
-> Getting (First Text) ListPhoneNumbersResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListPhoneNumbersResponse
-> Const (First Text) ListPhoneNumbersResponse
Lens' ListPhoneNumbersResponse (Maybe Text)
listPhoneNumbersResponse_nextToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListPhoneNumbersResponse
 -> Const (First Text) ListPhoneNumbersResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListPhoneNumbersResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

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

instance Prelude.NFData ListPhoneNumbers

instance Core.ToHeaders ListPhoneNumbers where
  toHeaders :: ListPhoneNumbers -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListPhoneNumbers -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToPath ListPhoneNumbers where
  toPath :: ListPhoneNumbers -> ByteString
toPath ListPhoneNumbers' {Maybe Natural
Maybe [PhoneNumberCountryCode]
Maybe [PhoneNumberType]
Maybe Text
Text
instanceId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
phoneNumberCountryCodes :: Maybe [PhoneNumberCountryCode]
phoneNumberTypes :: Maybe [PhoneNumberType]
$sel:instanceId:ListPhoneNumbers' :: ListPhoneNumbers -> Text
$sel:maxResults:ListPhoneNumbers' :: ListPhoneNumbers -> Maybe Natural
$sel:nextToken:ListPhoneNumbers' :: ListPhoneNumbers -> Maybe Text
$sel:phoneNumberCountryCodes:ListPhoneNumbers' :: ListPhoneNumbers -> Maybe [PhoneNumberCountryCode]
$sel:phoneNumberTypes:ListPhoneNumbers' :: ListPhoneNumbers -> Maybe [PhoneNumberType]
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/phone-numbers-summary/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
instanceId]

instance Core.ToQuery ListPhoneNumbers where
  toQuery :: ListPhoneNumbers -> QueryString
toQuery ListPhoneNumbers' {Maybe Natural
Maybe [PhoneNumberCountryCode]
Maybe [PhoneNumberType]
Maybe Text
Text
instanceId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
phoneNumberCountryCodes :: Maybe [PhoneNumberCountryCode]
phoneNumberTypes :: Maybe [PhoneNumberType]
$sel:instanceId:ListPhoneNumbers' :: ListPhoneNumbers -> Text
$sel:maxResults:ListPhoneNumbers' :: ListPhoneNumbers -> Maybe Natural
$sel:nextToken:ListPhoneNumbers' :: ListPhoneNumbers -> Maybe Text
$sel:phoneNumberCountryCodes:ListPhoneNumbers' :: ListPhoneNumbers -> Maybe [PhoneNumberCountryCode]
$sel:phoneNumberTypes:ListPhoneNumbers' :: ListPhoneNumbers -> Maybe [PhoneNumberType]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"phoneNumberTypes"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            ( ByteString -> [PhoneNumberType] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member"
                ([PhoneNumberType] -> QueryString)
-> Maybe [PhoneNumberType] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [PhoneNumberType]
phoneNumberTypes
            ),
        ByteString
"phoneNumberCountryCodes"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            ( ByteString -> [PhoneNumberCountryCode] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member"
                ([PhoneNumberCountryCode] -> QueryString)
-> Maybe [PhoneNumberCountryCode] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [PhoneNumberCountryCode]
phoneNumberCountryCodes
            ),
        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:/ 'newListPhoneNumbersResponse' smart constructor.
data ListPhoneNumbersResponse = ListPhoneNumbersResponse'
  { -- | Information about the phone numbers.
    ListPhoneNumbersResponse -> Maybe [PhoneNumberSummary]
phoneNumberSummaryList :: Prelude.Maybe [PhoneNumberSummary],
    -- | If there are additional results, this is the token for the next set of
    -- results.
    ListPhoneNumbersResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListPhoneNumbersResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListPhoneNumbersResponse -> ListPhoneNumbersResponse -> Bool
(ListPhoneNumbersResponse -> ListPhoneNumbersResponse -> Bool)
-> (ListPhoneNumbersResponse -> ListPhoneNumbersResponse -> Bool)
-> Eq ListPhoneNumbersResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPhoneNumbersResponse -> ListPhoneNumbersResponse -> Bool
$c/= :: ListPhoneNumbersResponse -> ListPhoneNumbersResponse -> Bool
== :: ListPhoneNumbersResponse -> ListPhoneNumbersResponse -> Bool
$c== :: ListPhoneNumbersResponse -> ListPhoneNumbersResponse -> Bool
Prelude.Eq, ReadPrec [ListPhoneNumbersResponse]
ReadPrec ListPhoneNumbersResponse
Int -> ReadS ListPhoneNumbersResponse
ReadS [ListPhoneNumbersResponse]
(Int -> ReadS ListPhoneNumbersResponse)
-> ReadS [ListPhoneNumbersResponse]
-> ReadPrec ListPhoneNumbersResponse
-> ReadPrec [ListPhoneNumbersResponse]
-> Read ListPhoneNumbersResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPhoneNumbersResponse]
$creadListPrec :: ReadPrec [ListPhoneNumbersResponse]
readPrec :: ReadPrec ListPhoneNumbersResponse
$creadPrec :: ReadPrec ListPhoneNumbersResponse
readList :: ReadS [ListPhoneNumbersResponse]
$creadList :: ReadS [ListPhoneNumbersResponse]
readsPrec :: Int -> ReadS ListPhoneNumbersResponse
$creadsPrec :: Int -> ReadS ListPhoneNumbersResponse
Prelude.Read, Int -> ListPhoneNumbersResponse -> ShowS
[ListPhoneNumbersResponse] -> ShowS
ListPhoneNumbersResponse -> String
(Int -> ListPhoneNumbersResponse -> ShowS)
-> (ListPhoneNumbersResponse -> String)
-> ([ListPhoneNumbersResponse] -> ShowS)
-> Show ListPhoneNumbersResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPhoneNumbersResponse] -> ShowS
$cshowList :: [ListPhoneNumbersResponse] -> ShowS
show :: ListPhoneNumbersResponse -> String
$cshow :: ListPhoneNumbersResponse -> String
showsPrec :: Int -> ListPhoneNumbersResponse -> ShowS
$cshowsPrec :: Int -> ListPhoneNumbersResponse -> ShowS
Prelude.Show, (forall x.
 ListPhoneNumbersResponse -> Rep ListPhoneNumbersResponse x)
-> (forall x.
    Rep ListPhoneNumbersResponse x -> ListPhoneNumbersResponse)
-> Generic ListPhoneNumbersResponse
forall x.
Rep ListPhoneNumbersResponse x -> ListPhoneNumbersResponse
forall x.
ListPhoneNumbersResponse -> Rep ListPhoneNumbersResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListPhoneNumbersResponse x -> ListPhoneNumbersResponse
$cfrom :: forall x.
ListPhoneNumbersResponse -> Rep ListPhoneNumbersResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListPhoneNumbersResponse' 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:
--
-- 'phoneNumberSummaryList', 'listPhoneNumbersResponse_phoneNumberSummaryList' - Information about the phone numbers.
--
-- 'nextToken', 'listPhoneNumbersResponse_nextToken' - If there are additional results, this is the token for the next set of
-- results.
--
-- 'httpStatus', 'listPhoneNumbersResponse_httpStatus' - The response's http status code.
newListPhoneNumbersResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListPhoneNumbersResponse
newListPhoneNumbersResponse :: Int -> ListPhoneNumbersResponse
newListPhoneNumbersResponse Int
pHttpStatus_ =
  ListPhoneNumbersResponse' :: Maybe [PhoneNumberSummary]
-> Maybe Text -> Int -> ListPhoneNumbersResponse
ListPhoneNumbersResponse'
    { $sel:phoneNumberSummaryList:ListPhoneNumbersResponse' :: Maybe [PhoneNumberSummary]
phoneNumberSummaryList =
        Maybe [PhoneNumberSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListPhoneNumbersResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListPhoneNumbersResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the phone numbers.
listPhoneNumbersResponse_phoneNumberSummaryList :: Lens.Lens' ListPhoneNumbersResponse (Prelude.Maybe [PhoneNumberSummary])
listPhoneNumbersResponse_phoneNumberSummaryList :: (Maybe [PhoneNumberSummary] -> f (Maybe [PhoneNumberSummary]))
-> ListPhoneNumbersResponse -> f ListPhoneNumbersResponse
listPhoneNumbersResponse_phoneNumberSummaryList = (ListPhoneNumbersResponse -> Maybe [PhoneNumberSummary])
-> (ListPhoneNumbersResponse
    -> Maybe [PhoneNumberSummary] -> ListPhoneNumbersResponse)
-> Lens' ListPhoneNumbersResponse (Maybe [PhoneNumberSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPhoneNumbersResponse' {Maybe [PhoneNumberSummary]
phoneNumberSummaryList :: Maybe [PhoneNumberSummary]
$sel:phoneNumberSummaryList:ListPhoneNumbersResponse' :: ListPhoneNumbersResponse -> Maybe [PhoneNumberSummary]
phoneNumberSummaryList} -> Maybe [PhoneNumberSummary]
phoneNumberSummaryList) (\s :: ListPhoneNumbersResponse
s@ListPhoneNumbersResponse' {} Maybe [PhoneNumberSummary]
a -> ListPhoneNumbersResponse
s {$sel:phoneNumberSummaryList:ListPhoneNumbersResponse' :: Maybe [PhoneNumberSummary]
phoneNumberSummaryList = Maybe [PhoneNumberSummary]
a} :: ListPhoneNumbersResponse) ((Maybe [PhoneNumberSummary] -> f (Maybe [PhoneNumberSummary]))
 -> ListPhoneNumbersResponse -> f ListPhoneNumbersResponse)
-> ((Maybe [PhoneNumberSummary] -> f (Maybe [PhoneNumberSummary]))
    -> Maybe [PhoneNumberSummary] -> f (Maybe [PhoneNumberSummary]))
-> (Maybe [PhoneNumberSummary] -> f (Maybe [PhoneNumberSummary]))
-> ListPhoneNumbersResponse
-> f ListPhoneNumbersResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PhoneNumberSummary]
  [PhoneNumberSummary]
  [PhoneNumberSummary]
  [PhoneNumberSummary]
-> Iso
     (Maybe [PhoneNumberSummary])
     (Maybe [PhoneNumberSummary])
     (Maybe [PhoneNumberSummary])
     (Maybe [PhoneNumberSummary])
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
  [PhoneNumberSummary]
  [PhoneNumberSummary]
  [PhoneNumberSummary]
  [PhoneNumberSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | If there are additional results, this is the token for the next set of
-- results.
listPhoneNumbersResponse_nextToken :: Lens.Lens' ListPhoneNumbersResponse (Prelude.Maybe Prelude.Text)
listPhoneNumbersResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListPhoneNumbersResponse -> f ListPhoneNumbersResponse
listPhoneNumbersResponse_nextToken = (ListPhoneNumbersResponse -> Maybe Text)
-> (ListPhoneNumbersResponse
    -> Maybe Text -> ListPhoneNumbersResponse)
-> Lens' ListPhoneNumbersResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPhoneNumbersResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListPhoneNumbersResponse' :: ListPhoneNumbersResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListPhoneNumbersResponse
s@ListPhoneNumbersResponse' {} Maybe Text
a -> ListPhoneNumbersResponse
s {$sel:nextToken:ListPhoneNumbersResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListPhoneNumbersResponse)

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

instance Prelude.NFData ListPhoneNumbersResponse