{-# 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.APIGateway.GetDomainNames
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Represents a collection of DomainName resources.
--
-- This operation returns paginated results.
module Amazonka.APIGateway.GetDomainNames
  ( -- * Creating a Request
    GetDomainNames (..),
    newGetDomainNames,

    -- * Request Lenses
    getDomainNames_limit,
    getDomainNames_position,

    -- * Destructuring the Response
    GetDomainNamesResponse (..),
    newGetDomainNamesResponse,

    -- * Response Lenses
    getDomainNamesResponse_items,
    getDomainNamesResponse_position,
    getDomainNamesResponse_httpStatus,
  )
where

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

-- | Request to describe a collection of DomainName resources.
--
-- /See:/ 'newGetDomainNames' smart constructor.
data GetDomainNames = GetDomainNames'
  { -- | The maximum number of returned results per page. The default value is 25
    -- and the maximum value is 500.
    GetDomainNames -> Maybe Int
limit :: Prelude.Maybe Prelude.Int,
    -- | The current pagination position in the paged result set.
    GetDomainNames -> Maybe Text
position :: Prelude.Maybe Prelude.Text
  }
  deriving (GetDomainNames -> GetDomainNames -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDomainNames -> GetDomainNames -> Bool
$c/= :: GetDomainNames -> GetDomainNames -> Bool
== :: GetDomainNames -> GetDomainNames -> Bool
$c== :: GetDomainNames -> GetDomainNames -> Bool
Prelude.Eq, ReadPrec [GetDomainNames]
ReadPrec GetDomainNames
Int -> ReadS GetDomainNames
ReadS [GetDomainNames]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDomainNames]
$creadListPrec :: ReadPrec [GetDomainNames]
readPrec :: ReadPrec GetDomainNames
$creadPrec :: ReadPrec GetDomainNames
readList :: ReadS [GetDomainNames]
$creadList :: ReadS [GetDomainNames]
readsPrec :: Int -> ReadS GetDomainNames
$creadsPrec :: Int -> ReadS GetDomainNames
Prelude.Read, Int -> GetDomainNames -> ShowS
[GetDomainNames] -> ShowS
GetDomainNames -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDomainNames] -> ShowS
$cshowList :: [GetDomainNames] -> ShowS
show :: GetDomainNames -> String
$cshow :: GetDomainNames -> String
showsPrec :: Int -> GetDomainNames -> ShowS
$cshowsPrec :: Int -> GetDomainNames -> ShowS
Prelude.Show, forall x. Rep GetDomainNames x -> GetDomainNames
forall x. GetDomainNames -> Rep GetDomainNames x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDomainNames x -> GetDomainNames
$cfrom :: forall x. GetDomainNames -> Rep GetDomainNames x
Prelude.Generic)

-- |
-- Create a value of 'GetDomainNames' 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:
--
-- 'limit', 'getDomainNames_limit' - The maximum number of returned results per page. The default value is 25
-- and the maximum value is 500.
--
-- 'position', 'getDomainNames_position' - The current pagination position in the paged result set.
newGetDomainNames ::
  GetDomainNames
newGetDomainNames :: GetDomainNames
newGetDomainNames =
  GetDomainNames'
    { $sel:limit:GetDomainNames' :: Maybe Int
limit = forall a. Maybe a
Prelude.Nothing,
      $sel:position:GetDomainNames' :: Maybe Text
position = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of returned results per page. The default value is 25
-- and the maximum value is 500.
getDomainNames_limit :: Lens.Lens' GetDomainNames (Prelude.Maybe Prelude.Int)
getDomainNames_limit :: Lens' GetDomainNames (Maybe Int)
getDomainNames_limit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDomainNames' {Maybe Int
limit :: Maybe Int
$sel:limit:GetDomainNames' :: GetDomainNames -> Maybe Int
limit} -> Maybe Int
limit) (\s :: GetDomainNames
s@GetDomainNames' {} Maybe Int
a -> GetDomainNames
s {$sel:limit:GetDomainNames' :: Maybe Int
limit = Maybe Int
a} :: GetDomainNames)

-- | The current pagination position in the paged result set.
getDomainNames_position :: Lens.Lens' GetDomainNames (Prelude.Maybe Prelude.Text)
getDomainNames_position :: Lens' GetDomainNames (Maybe Text)
getDomainNames_position = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDomainNames' {Maybe Text
position :: Maybe Text
$sel:position:GetDomainNames' :: GetDomainNames -> Maybe Text
position} -> Maybe Text
position) (\s :: GetDomainNames
s@GetDomainNames' {} Maybe Text
a -> GetDomainNames
s {$sel:position:GetDomainNames' :: Maybe Text
position = Maybe Text
a} :: GetDomainNames)

instance Core.AWSPager GetDomainNames where
  page :: GetDomainNames
-> AWSResponse GetDomainNames -> Maybe GetDomainNames
page GetDomainNames
rq AWSResponse GetDomainNames
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetDomainNames
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetDomainNamesResponse (Maybe Text)
getDomainNamesResponse_position
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetDomainNames
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetDomainNamesResponse (Maybe [DomainName])
getDomainNamesResponse_items
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ GetDomainNames
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' GetDomainNames (Maybe Text)
getDomainNames_position
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetDomainNames
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetDomainNamesResponse (Maybe Text)
getDomainNamesResponse_position
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest GetDomainNames where
  type
    AWSResponse GetDomainNames =
      GetDomainNamesResponse
  request :: (Service -> Service) -> GetDomainNames -> Request GetDomainNames
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 GetDomainNames
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetDomainNames)))
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 [DomainName] -> Maybe Text -> Int -> GetDomainNamesResponse
GetDomainNamesResponse'
            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
"item" 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
"position")
            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 GetDomainNames where
  hashWithSalt :: Int -> GetDomainNames -> Int
hashWithSalt Int
_salt GetDomainNames' {Maybe Int
Maybe Text
position :: Maybe Text
limit :: Maybe Int
$sel:position:GetDomainNames' :: GetDomainNames -> Maybe Text
$sel:limit:GetDomainNames' :: GetDomainNames -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
limit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
position

instance Prelude.NFData GetDomainNames where
  rnf :: GetDomainNames -> ()
rnf GetDomainNames' {Maybe Int
Maybe Text
position :: Maybe Text
limit :: Maybe Int
$sel:position:GetDomainNames' :: GetDomainNames -> Maybe Text
$sel:limit:GetDomainNames' :: GetDomainNames -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
limit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
position

instance Data.ToHeaders GetDomainNames where
  toHeaders :: GetDomainNames -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Accept"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"application/json" :: Prelude.ByteString)
          ]
      )

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

instance Data.ToQuery GetDomainNames where
  toQuery :: GetDomainNames -> QueryString
toQuery GetDomainNames' {Maybe Int
Maybe Text
position :: Maybe Text
limit :: Maybe Int
$sel:position:GetDomainNames' :: GetDomainNames -> Maybe Text
$sel:limit:GetDomainNames' :: GetDomainNames -> Maybe Int
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"limit" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Int
limit, ByteString
"position" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
position]

-- | Represents a collection of DomainName resources.
--
-- /See:/ 'newGetDomainNamesResponse' smart constructor.
data GetDomainNamesResponse = GetDomainNamesResponse'
  { -- | The current page of elements from this collection.
    GetDomainNamesResponse -> Maybe [DomainName]
items :: Prelude.Maybe [DomainName],
    GetDomainNamesResponse -> Maybe Text
position :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetDomainNamesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetDomainNamesResponse -> GetDomainNamesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDomainNamesResponse -> GetDomainNamesResponse -> Bool
$c/= :: GetDomainNamesResponse -> GetDomainNamesResponse -> Bool
== :: GetDomainNamesResponse -> GetDomainNamesResponse -> Bool
$c== :: GetDomainNamesResponse -> GetDomainNamesResponse -> Bool
Prelude.Eq, ReadPrec [GetDomainNamesResponse]
ReadPrec GetDomainNamesResponse
Int -> ReadS GetDomainNamesResponse
ReadS [GetDomainNamesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDomainNamesResponse]
$creadListPrec :: ReadPrec [GetDomainNamesResponse]
readPrec :: ReadPrec GetDomainNamesResponse
$creadPrec :: ReadPrec GetDomainNamesResponse
readList :: ReadS [GetDomainNamesResponse]
$creadList :: ReadS [GetDomainNamesResponse]
readsPrec :: Int -> ReadS GetDomainNamesResponse
$creadsPrec :: Int -> ReadS GetDomainNamesResponse
Prelude.Read, Int -> GetDomainNamesResponse -> ShowS
[GetDomainNamesResponse] -> ShowS
GetDomainNamesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDomainNamesResponse] -> ShowS
$cshowList :: [GetDomainNamesResponse] -> ShowS
show :: GetDomainNamesResponse -> String
$cshow :: GetDomainNamesResponse -> String
showsPrec :: Int -> GetDomainNamesResponse -> ShowS
$cshowsPrec :: Int -> GetDomainNamesResponse -> ShowS
Prelude.Show, forall x. Rep GetDomainNamesResponse x -> GetDomainNamesResponse
forall x. GetDomainNamesResponse -> Rep GetDomainNamesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDomainNamesResponse x -> GetDomainNamesResponse
$cfrom :: forall x. GetDomainNamesResponse -> Rep GetDomainNamesResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDomainNamesResponse' 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', 'getDomainNamesResponse_items' - The current page of elements from this collection.
--
-- 'position', 'getDomainNamesResponse_position' - Undocumented member.
--
-- 'httpStatus', 'getDomainNamesResponse_httpStatus' - The response's http status code.
newGetDomainNamesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDomainNamesResponse
newGetDomainNamesResponse :: Int -> GetDomainNamesResponse
newGetDomainNamesResponse Int
pHttpStatus_ =
  GetDomainNamesResponse'
    { $sel:items:GetDomainNamesResponse' :: Maybe [DomainName]
items = forall a. Maybe a
Prelude.Nothing,
      $sel:position:GetDomainNamesResponse' :: Maybe Text
position = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDomainNamesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The current page of elements from this collection.
getDomainNamesResponse_items :: Lens.Lens' GetDomainNamesResponse (Prelude.Maybe [DomainName])
getDomainNamesResponse_items :: Lens' GetDomainNamesResponse (Maybe [DomainName])
getDomainNamesResponse_items = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDomainNamesResponse' {Maybe [DomainName]
items :: Maybe [DomainName]
$sel:items:GetDomainNamesResponse' :: GetDomainNamesResponse -> Maybe [DomainName]
items} -> Maybe [DomainName]
items) (\s :: GetDomainNamesResponse
s@GetDomainNamesResponse' {} Maybe [DomainName]
a -> GetDomainNamesResponse
s {$sel:items:GetDomainNamesResponse' :: Maybe [DomainName]
items = Maybe [DomainName]
a} :: GetDomainNamesResponse) 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

-- | Undocumented member.
getDomainNamesResponse_position :: Lens.Lens' GetDomainNamesResponse (Prelude.Maybe Prelude.Text)
getDomainNamesResponse_position :: Lens' GetDomainNamesResponse (Maybe Text)
getDomainNamesResponse_position = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDomainNamesResponse' {Maybe Text
position :: Maybe Text
$sel:position:GetDomainNamesResponse' :: GetDomainNamesResponse -> Maybe Text
position} -> Maybe Text
position) (\s :: GetDomainNamesResponse
s@GetDomainNamesResponse' {} Maybe Text
a -> GetDomainNamesResponse
s {$sel:position:GetDomainNamesResponse' :: Maybe Text
position = Maybe Text
a} :: GetDomainNamesResponse)

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

instance Prelude.NFData GetDomainNamesResponse where
  rnf :: GetDomainNamesResponse -> ()
rnf GetDomainNamesResponse' {Int
Maybe [DomainName]
Maybe Text
httpStatus :: Int
position :: Maybe Text
items :: Maybe [DomainName]
$sel:httpStatus:GetDomainNamesResponse' :: GetDomainNamesResponse -> Int
$sel:position:GetDomainNamesResponse' :: GetDomainNamesResponse -> Maybe Text
$sel:items:GetDomainNamesResponse' :: GetDomainNamesResponse -> Maybe [DomainName]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [DomainName]
items
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
position
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus