{-# 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.VoiceId.ListDomains
-- 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 all the domains in the Amazon Web Services account.
module Amazonka.VoiceId.ListDomains
  ( -- * Creating a Request
    ListDomains (..),
    newListDomains,

    -- * Request Lenses
    listDomains_nextToken,
    listDomains_maxResults,

    -- * Destructuring the Response
    ListDomainsResponse (..),
    newListDomainsResponse,

    -- * Response Lenses
    listDomainsResponse_nextToken,
    listDomainsResponse_domainSummaries,
    listDomainsResponse_httpStatus,
  )
where

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
import Amazonka.VoiceId.Types

-- | /See:/ 'newListDomains' smart constructor.
data ListDomains = ListDomains'
  { -- | If @NextToken@ is returned, there are more results available. The value
    -- of @NextToken@ is a unique pagination token for each page. Make the call
    -- again using the returned token to retrieve the next page. Keep all other
    -- arguments unchanged. Each pagination token expires after 24 hours.
    ListDomains -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results that are returned per call. You can use
    -- @NextToken@ to obtain further pages of results. The default is 100; the
    -- maximum allowed page size is also 100.
    ListDomains -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListDomains -> ListDomains -> Bool
(ListDomains -> ListDomains -> Bool)
-> (ListDomains -> ListDomains -> Bool) -> Eq ListDomains
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDomains -> ListDomains -> Bool
$c/= :: ListDomains -> ListDomains -> Bool
== :: ListDomains -> ListDomains -> Bool
$c== :: ListDomains -> ListDomains -> Bool
Prelude.Eq, ReadPrec [ListDomains]
ReadPrec ListDomains
Int -> ReadS ListDomains
ReadS [ListDomains]
(Int -> ReadS ListDomains)
-> ReadS [ListDomains]
-> ReadPrec ListDomains
-> ReadPrec [ListDomains]
-> Read ListDomains
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDomains]
$creadListPrec :: ReadPrec [ListDomains]
readPrec :: ReadPrec ListDomains
$creadPrec :: ReadPrec ListDomains
readList :: ReadS [ListDomains]
$creadList :: ReadS [ListDomains]
readsPrec :: Int -> ReadS ListDomains
$creadsPrec :: Int -> ReadS ListDomains
Prelude.Read, Int -> ListDomains -> ShowS
[ListDomains] -> ShowS
ListDomains -> String
(Int -> ListDomains -> ShowS)
-> (ListDomains -> String)
-> ([ListDomains] -> ShowS)
-> Show ListDomains
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDomains] -> ShowS
$cshowList :: [ListDomains] -> ShowS
show :: ListDomains -> String
$cshow :: ListDomains -> String
showsPrec :: Int -> ListDomains -> ShowS
$cshowsPrec :: Int -> ListDomains -> ShowS
Prelude.Show, (forall x. ListDomains -> Rep ListDomains x)
-> (forall x. Rep ListDomains x -> ListDomains)
-> Generic ListDomains
forall x. Rep ListDomains x -> ListDomains
forall x. ListDomains -> Rep ListDomains x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDomains x -> ListDomains
$cfrom :: forall x. ListDomains -> Rep ListDomains x
Prelude.Generic)

-- |
-- Create a value of 'ListDomains' 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', 'listDomains_nextToken' - If @NextToken@ is returned, there are more results available. The value
-- of @NextToken@ is a unique pagination token for each page. Make the call
-- again using the returned token to retrieve the next page. Keep all other
-- arguments unchanged. Each pagination token expires after 24 hours.
--
-- 'maxResults', 'listDomains_maxResults' - The maximum number of results that are returned per call. You can use
-- @NextToken@ to obtain further pages of results. The default is 100; the
-- maximum allowed page size is also 100.
newListDomains ::
  ListDomains
newListDomains :: ListDomains
newListDomains =
  ListDomains' :: Maybe Text -> Maybe Natural -> ListDomains
ListDomains'
    { $sel:nextToken:ListDomains' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListDomains' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | If @NextToken@ is returned, there are more results available. The value
-- of @NextToken@ is a unique pagination token for each page. Make the call
-- again using the returned token to retrieve the next page. Keep all other
-- arguments unchanged. Each pagination token expires after 24 hours.
listDomains_nextToken :: Lens.Lens' ListDomains (Prelude.Maybe Prelude.Text)
listDomains_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListDomains -> f ListDomains
listDomains_nextToken = (ListDomains -> Maybe Text)
-> (ListDomains -> Maybe Text -> ListDomains)
-> Lens ListDomains ListDomains (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDomains' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDomains' :: ListDomains -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDomains
s@ListDomains' {} Maybe Text
a -> ListDomains
s {$sel:nextToken:ListDomains' :: Maybe Text
nextToken = Maybe Text
a} :: ListDomains)

-- | The maximum number of results that are returned per call. You can use
-- @NextToken@ to obtain further pages of results. The default is 100; the
-- maximum allowed page size is also 100.
listDomains_maxResults :: Lens.Lens' ListDomains (Prelude.Maybe Prelude.Natural)
listDomains_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListDomains -> f ListDomains
listDomains_maxResults = (ListDomains -> Maybe Natural)
-> (ListDomains -> Maybe Natural -> ListDomains)
-> Lens ListDomains ListDomains (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDomains' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListDomains' :: ListDomains -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListDomains
s@ListDomains' {} Maybe Natural
a -> ListDomains
s {$sel:maxResults:ListDomains' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListDomains)

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

instance Prelude.NFData ListDomains

instance Core.ToHeaders ListDomains where
  toHeaders :: ListDomains -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListDomains -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"VoiceID.ListDomains" :: Prelude.ByteString),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON ListDomains where
  toJSON :: ListDomains -> Value
toJSON ListDomains' {Maybe Natural
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
$sel:maxResults:ListDomains' :: ListDomains -> Maybe Natural
$sel:nextToken:ListDomains' :: ListDomains -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"NextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"MaxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults
          ]
      )

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

instance Core.ToQuery ListDomains where
  toQuery :: ListDomains -> QueryString
toQuery = QueryString -> ListDomains -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newListDomainsResponse' smart constructor.
data ListDomainsResponse = ListDomainsResponse'
  { -- | If @NextToken@ is returned, there are more results available. The value
    -- of @NextToken@ is a unique pagination token for each page. Make the call
    -- again using the returned token to retrieve the next page. Keep all other
    -- arguments unchanged. Each pagination token expires after 24 hours.
    ListDomainsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list containing details about each domain in the Amazon Web Services
    -- account.
    ListDomainsResponse -> Maybe [DomainSummary]
domainSummaries :: Prelude.Maybe [DomainSummary],
    -- | The response's http status code.
    ListDomainsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDomainsResponse -> ListDomainsResponse -> Bool
(ListDomainsResponse -> ListDomainsResponse -> Bool)
-> (ListDomainsResponse -> ListDomainsResponse -> Bool)
-> Eq ListDomainsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListDomainsResponse -> ListDomainsResponse -> Bool
$c/= :: ListDomainsResponse -> ListDomainsResponse -> Bool
== :: ListDomainsResponse -> ListDomainsResponse -> Bool
$c== :: ListDomainsResponse -> ListDomainsResponse -> Bool
Prelude.Eq, Int -> ListDomainsResponse -> ShowS
[ListDomainsResponse] -> ShowS
ListDomainsResponse -> String
(Int -> ListDomainsResponse -> ShowS)
-> (ListDomainsResponse -> String)
-> ([ListDomainsResponse] -> ShowS)
-> Show ListDomainsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListDomainsResponse] -> ShowS
$cshowList :: [ListDomainsResponse] -> ShowS
show :: ListDomainsResponse -> String
$cshow :: ListDomainsResponse -> String
showsPrec :: Int -> ListDomainsResponse -> ShowS
$cshowsPrec :: Int -> ListDomainsResponse -> ShowS
Prelude.Show, (forall x. ListDomainsResponse -> Rep ListDomainsResponse x)
-> (forall x. Rep ListDomainsResponse x -> ListDomainsResponse)
-> Generic ListDomainsResponse
forall x. Rep ListDomainsResponse x -> ListDomainsResponse
forall x. ListDomainsResponse -> Rep ListDomainsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListDomainsResponse x -> ListDomainsResponse
$cfrom :: forall x. ListDomainsResponse -> Rep ListDomainsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListDomainsResponse' 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', 'listDomainsResponse_nextToken' - If @NextToken@ is returned, there are more results available. The value
-- of @NextToken@ is a unique pagination token for each page. Make the call
-- again using the returned token to retrieve the next page. Keep all other
-- arguments unchanged. Each pagination token expires after 24 hours.
--
-- 'domainSummaries', 'listDomainsResponse_domainSummaries' - A list containing details about each domain in the Amazon Web Services
-- account.
--
-- 'httpStatus', 'listDomainsResponse_httpStatus' - The response's http status code.
newListDomainsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDomainsResponse
newListDomainsResponse :: Int -> ListDomainsResponse
newListDomainsResponse Int
pHttpStatus_ =
  ListDomainsResponse' :: Maybe Text -> Maybe [DomainSummary] -> Int -> ListDomainsResponse
ListDomainsResponse'
    { $sel:nextToken:ListDomainsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:domainSummaries:ListDomainsResponse' :: Maybe [DomainSummary]
domainSummaries = Maybe [DomainSummary]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDomainsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | If @NextToken@ is returned, there are more results available. The value
-- of @NextToken@ is a unique pagination token for each page. Make the call
-- again using the returned token to retrieve the next page. Keep all other
-- arguments unchanged. Each pagination token expires after 24 hours.
listDomainsResponse_nextToken :: Lens.Lens' ListDomainsResponse (Prelude.Maybe Prelude.Text)
listDomainsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListDomainsResponse -> f ListDomainsResponse
listDomainsResponse_nextToken = (ListDomainsResponse -> Maybe Text)
-> (ListDomainsResponse -> Maybe Text -> ListDomainsResponse)
-> Lens
     ListDomainsResponse ListDomainsResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDomainsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListDomainsResponse' :: ListDomainsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListDomainsResponse
s@ListDomainsResponse' {} Maybe Text
a -> ListDomainsResponse
s {$sel:nextToken:ListDomainsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListDomainsResponse)

-- | A list containing details about each domain in the Amazon Web Services
-- account.
listDomainsResponse_domainSummaries :: Lens.Lens' ListDomainsResponse (Prelude.Maybe [DomainSummary])
listDomainsResponse_domainSummaries :: (Maybe [DomainSummary] -> f (Maybe [DomainSummary]))
-> ListDomainsResponse -> f ListDomainsResponse
listDomainsResponse_domainSummaries = (ListDomainsResponse -> Maybe [DomainSummary])
-> (ListDomainsResponse
    -> Maybe [DomainSummary] -> ListDomainsResponse)
-> Lens
     ListDomainsResponse
     ListDomainsResponse
     (Maybe [DomainSummary])
     (Maybe [DomainSummary])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDomainsResponse' {Maybe [DomainSummary]
domainSummaries :: Maybe [DomainSummary]
$sel:domainSummaries:ListDomainsResponse' :: ListDomainsResponse -> Maybe [DomainSummary]
domainSummaries} -> Maybe [DomainSummary]
domainSummaries) (\s :: ListDomainsResponse
s@ListDomainsResponse' {} Maybe [DomainSummary]
a -> ListDomainsResponse
s {$sel:domainSummaries:ListDomainsResponse' :: Maybe [DomainSummary]
domainSummaries = Maybe [DomainSummary]
a} :: ListDomainsResponse) ((Maybe [DomainSummary] -> f (Maybe [DomainSummary]))
 -> ListDomainsResponse -> f ListDomainsResponse)
-> ((Maybe [DomainSummary] -> f (Maybe [DomainSummary]))
    -> Maybe [DomainSummary] -> f (Maybe [DomainSummary]))
-> (Maybe [DomainSummary] -> f (Maybe [DomainSummary]))
-> ListDomainsResponse
-> f ListDomainsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DomainSummary] [DomainSummary] [DomainSummary] [DomainSummary]
-> Iso
     (Maybe [DomainSummary])
     (Maybe [DomainSummary])
     (Maybe [DomainSummary])
     (Maybe [DomainSummary])
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
  [DomainSummary] [DomainSummary] [DomainSummary] [DomainSummary]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListDomainsResponse