{-# 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.CustomerProfiles.ListDomains
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns a list of all the domains for an AWS account that have been
-- created.
module Amazonka.CustomerProfiles.ListDomains
  ( -- * Creating a Request
    ListDomains (..),
    newListDomains,

    -- * Request Lenses
    listDomains_maxResults,
    listDomains_nextToken,

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

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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import Amazonka.CustomerProfiles.Types
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListDomains' smart constructor.
data ListDomains = ListDomains'
  { -- | The maximum number of objects returned per page.
    ListDomains -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The pagination token from the previous ListDomain API call.
    ListDomains -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListDomains -> ListDomains -> Bool
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]
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
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. 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:
--
-- 'maxResults', 'listDomains_maxResults' - The maximum number of objects returned per page.
--
-- 'nextToken', 'listDomains_nextToken' - The pagination token from the previous ListDomain API call.
newListDomains ::
  ListDomains
newListDomains :: ListDomains
newListDomains =
  ListDomains'
    { $sel:maxResults:ListDomains' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDomains' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of objects returned per page.
listDomains_maxResults :: Lens.Lens' ListDomains (Prelude.Maybe Prelude.Natural)
listDomains_maxResults :: Lens' ListDomains (Maybe Natural)
listDomains_maxResults = 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)

-- | The pagination token from the previous ListDomain API call.
listDomains_nextToken :: Lens.Lens' ListDomains (Prelude.Maybe Prelude.Text)
listDomains_nextToken :: Lens' ListDomains (Maybe Text)
listDomains_nextToken = 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)

instance Core.AWSRequest ListDomains where
  type AWSResponse ListDomains = ListDomainsResponse
  request :: (Service -> Service) -> ListDomains -> Request ListDomains
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 ListDomains
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListDomains)))
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 [ListDomainItem] -> Maybe Text -> Int -> ListDomainsResponse
ListDomainsResponse'
            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
"Items" 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 ListDomains where
  hashWithSalt :: Int -> ListDomains -> Int
hashWithSalt Int
_salt ListDomains' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListDomains' :: ListDomains -> Maybe Text
$sel:maxResults:ListDomains' :: ListDomains -> 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 ListDomains where
  rnf :: ListDomains -> ()
rnf ListDomains' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListDomains' :: ListDomains -> Maybe Text
$sel:maxResults:ListDomains' :: ListDomains -> 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 ListDomains where
  toHeaders :: ListDomains -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

instance Data.ToQuery ListDomains where
  toQuery :: ListDomains -> QueryString
toQuery ListDomains' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListDomains' :: ListDomains -> Maybe Text
$sel:maxResults:ListDomains' :: ListDomains -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"max-results" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"next-token" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newListDomainsResponse' smart constructor.
data ListDomainsResponse = ListDomainsResponse'
  { -- | The list of ListDomains instances.
    ListDomainsResponse -> Maybe [ListDomainItem]
items :: Prelude.Maybe [ListDomainItem],
    -- | The pagination token from the previous ListDomains API call.
    ListDomainsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListDomainsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListDomainsResponse -> ListDomainsResponse -> Bool
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, ReadPrec [ListDomainsResponse]
ReadPrec ListDomainsResponse
Int -> ReadS ListDomainsResponse
ReadS [ListDomainsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListDomainsResponse]
$creadListPrec :: ReadPrec [ListDomainsResponse]
readPrec :: ReadPrec ListDomainsResponse
$creadPrec :: ReadPrec ListDomainsResponse
readList :: ReadS [ListDomainsResponse]
$creadList :: ReadS [ListDomainsResponse]
readsPrec :: Int -> ReadS ListDomainsResponse
$creadsPrec :: Int -> ReadS ListDomainsResponse
Prelude.Read, Int -> ListDomainsResponse -> ShowS
[ListDomainsResponse] -> ShowS
ListDomainsResponse -> String
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. 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:
--
-- 'items', 'listDomainsResponse_items' - The list of ListDomains instances.
--
-- 'nextToken', 'listDomainsResponse_nextToken' - The pagination token from the previous ListDomains API call.
--
-- 'httpStatus', 'listDomainsResponse_httpStatus' - The response's http status code.
newListDomainsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListDomainsResponse
newListDomainsResponse :: Int -> ListDomainsResponse
newListDomainsResponse Int
pHttpStatus_ =
  ListDomainsResponse'
    { $sel:items:ListDomainsResponse' :: Maybe [ListDomainItem]
items = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListDomainsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListDomainsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The list of ListDomains instances.
listDomainsResponse_items :: Lens.Lens' ListDomainsResponse (Prelude.Maybe [ListDomainItem])
listDomainsResponse_items :: Lens' ListDomainsResponse (Maybe [ListDomainItem])
listDomainsResponse_items = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListDomainsResponse' {Maybe [ListDomainItem]
items :: Maybe [ListDomainItem]
$sel:items:ListDomainsResponse' :: ListDomainsResponse -> Maybe [ListDomainItem]
items} -> Maybe [ListDomainItem]
items) (\s :: ListDomainsResponse
s@ListDomainsResponse' {} Maybe [ListDomainItem]
a -> ListDomainsResponse
s {$sel:items:ListDomainsResponse' :: Maybe [ListDomainItem]
items = Maybe [ListDomainItem]
a} :: ListDomainsResponse) 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 pagination token from the previous ListDomains API call.
listDomainsResponse_nextToken :: Lens.Lens' ListDomainsResponse (Prelude.Maybe Prelude.Text)
listDomainsResponse_nextToken :: Lens' ListDomainsResponse (Maybe Text)
listDomainsResponse_nextToken = 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)

-- | The response's http status code.
listDomainsResponse_httpStatus :: Lens.Lens' ListDomainsResponse Prelude.Int
listDomainsResponse_httpStatus :: Lens' ListDomainsResponse Int
listDomainsResponse_httpStatus = 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 where
  rnf :: ListDomainsResponse -> ()
rnf ListDomainsResponse' {Int
Maybe [ListDomainItem]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
items :: Maybe [ListDomainItem]
$sel:httpStatus:ListDomainsResponse' :: ListDomainsResponse -> Int
$sel:nextToken:ListDomainsResponse' :: ListDomainsResponse -> Maybe Text
$sel:items:ListDomainsResponse' :: ListDomainsResponse -> Maybe [ListDomainItem]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ListDomainItem]
items
      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