{-# 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.ApiGatewayV2.GetApiMappings
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets API mappings.
module Amazonka.ApiGatewayV2.GetApiMappings
  ( -- * Creating a Request
    GetApiMappings (..),
    newGetApiMappings,

    -- * Request Lenses
    getApiMappings_maxResults,
    getApiMappings_nextToken,
    getApiMappings_domainName,

    -- * Destructuring the Response
    GetApiMappingsResponse (..),
    newGetApiMappingsResponse,

    -- * Response Lenses
    getApiMappingsResponse_items,
    getApiMappingsResponse_nextToken,
    getApiMappingsResponse_httpStatus,
  )
where

import Amazonka.ApiGatewayV2.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

-- | /See:/ 'newGetApiMappings' smart constructor.
data GetApiMappings = GetApiMappings'
  { -- | The maximum number of elements to be returned for this resource.
    GetApiMappings -> Maybe Text
maxResults :: Prelude.Maybe Prelude.Text,
    -- | The next page of elements from this collection. Not valid for the last
    -- element of the collection.
    GetApiMappings -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The domain name.
    GetApiMappings -> Text
domainName :: Prelude.Text
  }
  deriving (GetApiMappings -> GetApiMappings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetApiMappings -> GetApiMappings -> Bool
$c/= :: GetApiMappings -> GetApiMappings -> Bool
== :: GetApiMappings -> GetApiMappings -> Bool
$c== :: GetApiMappings -> GetApiMappings -> Bool
Prelude.Eq, ReadPrec [GetApiMappings]
ReadPrec GetApiMappings
Int -> ReadS GetApiMappings
ReadS [GetApiMappings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetApiMappings]
$creadListPrec :: ReadPrec [GetApiMappings]
readPrec :: ReadPrec GetApiMappings
$creadPrec :: ReadPrec GetApiMappings
readList :: ReadS [GetApiMappings]
$creadList :: ReadS [GetApiMappings]
readsPrec :: Int -> ReadS GetApiMappings
$creadsPrec :: Int -> ReadS GetApiMappings
Prelude.Read, Int -> GetApiMappings -> ShowS
[GetApiMappings] -> ShowS
GetApiMappings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetApiMappings] -> ShowS
$cshowList :: [GetApiMappings] -> ShowS
show :: GetApiMappings -> String
$cshow :: GetApiMappings -> String
showsPrec :: Int -> GetApiMappings -> ShowS
$cshowsPrec :: Int -> GetApiMappings -> ShowS
Prelude.Show, forall x. Rep GetApiMappings x -> GetApiMappings
forall x. GetApiMappings -> Rep GetApiMappings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetApiMappings x -> GetApiMappings
$cfrom :: forall x. GetApiMappings -> Rep GetApiMappings x
Prelude.Generic)

-- |
-- Create a value of 'GetApiMappings' 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', 'getApiMappings_maxResults' - The maximum number of elements to be returned for this resource.
--
-- 'nextToken', 'getApiMappings_nextToken' - The next page of elements from this collection. Not valid for the last
-- element of the collection.
--
-- 'domainName', 'getApiMappings_domainName' - The domain name.
newGetApiMappings ::
  -- | 'domainName'
  Prelude.Text ->
  GetApiMappings
newGetApiMappings :: Text -> GetApiMappings
newGetApiMappings Text
pDomainName_ =
  GetApiMappings'
    { $sel:maxResults:GetApiMappings' :: Maybe Text
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetApiMappings' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:domainName:GetApiMappings' :: Text
domainName = Text
pDomainName_
    }

-- | The maximum number of elements to be returned for this resource.
getApiMappings_maxResults :: Lens.Lens' GetApiMappings (Prelude.Maybe Prelude.Text)
getApiMappings_maxResults :: Lens' GetApiMappings (Maybe Text)
getApiMappings_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetApiMappings' {Maybe Text
maxResults :: Maybe Text
$sel:maxResults:GetApiMappings' :: GetApiMappings -> Maybe Text
maxResults} -> Maybe Text
maxResults) (\s :: GetApiMappings
s@GetApiMappings' {} Maybe Text
a -> GetApiMappings
s {$sel:maxResults:GetApiMappings' :: Maybe Text
maxResults = Maybe Text
a} :: GetApiMappings)

-- | The next page of elements from this collection. Not valid for the last
-- element of the collection.
getApiMappings_nextToken :: Lens.Lens' GetApiMappings (Prelude.Maybe Prelude.Text)
getApiMappings_nextToken :: Lens' GetApiMappings (Maybe Text)
getApiMappings_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetApiMappings' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetApiMappings' :: GetApiMappings -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetApiMappings
s@GetApiMappings' {} Maybe Text
a -> GetApiMappings
s {$sel:nextToken:GetApiMappings' :: Maybe Text
nextToken = Maybe Text
a} :: GetApiMappings)

-- | The domain name.
getApiMappings_domainName :: Lens.Lens' GetApiMappings Prelude.Text
getApiMappings_domainName :: Lens' GetApiMappings Text
getApiMappings_domainName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetApiMappings' {Text
domainName :: Text
$sel:domainName:GetApiMappings' :: GetApiMappings -> Text
domainName} -> Text
domainName) (\s :: GetApiMappings
s@GetApiMappings' {} Text
a -> GetApiMappings
s {$sel:domainName:GetApiMappings' :: Text
domainName = Text
a} :: GetApiMappings)

instance Core.AWSRequest GetApiMappings where
  type
    AWSResponse GetApiMappings =
      GetApiMappingsResponse
  request :: (Service -> Service) -> GetApiMappings -> Request GetApiMappings
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 GetApiMappings
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetApiMappings)))
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 [ApiMapping] -> Maybe Text -> Int -> GetApiMappingsResponse
GetApiMappingsResponse'
            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 GetApiMappings where
  hashWithSalt :: Int -> GetApiMappings -> Int
hashWithSalt Int
_salt GetApiMappings' {Maybe Text
Text
domainName :: Text
nextToken :: Maybe Text
maxResults :: Maybe Text
$sel:domainName:GetApiMappings' :: GetApiMappings -> Text
$sel:nextToken:GetApiMappings' :: GetApiMappings -> Maybe Text
$sel:maxResults:GetApiMappings' :: GetApiMappings -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domainName

instance Prelude.NFData GetApiMappings where
  rnf :: GetApiMappings -> ()
rnf GetApiMappings' {Maybe Text
Text
domainName :: Text
nextToken :: Maybe Text
maxResults :: Maybe Text
$sel:domainName:GetApiMappings' :: GetApiMappings -> Text
$sel:nextToken:GetApiMappings' :: GetApiMappings -> Maybe Text
$sel:maxResults:GetApiMappings' :: GetApiMappings -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
maxResults
      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 Text
domainName

instance Data.ToHeaders GetApiMappings where
  toHeaders :: GetApiMappings -> 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 GetApiMappings where
  toPath :: GetApiMappings -> ByteString
toPath GetApiMappings' {Maybe Text
Text
domainName :: Text
nextToken :: Maybe Text
maxResults :: Maybe Text
$sel:domainName:GetApiMappings' :: GetApiMappings -> Text
$sel:nextToken:GetApiMappings' :: GetApiMappings -> Maybe Text
$sel:maxResults:GetApiMappings' :: GetApiMappings -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v2/domainnames/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
domainName,
        ByteString
"/apimappings"
      ]

instance Data.ToQuery GetApiMappings where
  toQuery :: GetApiMappings -> QueryString
toQuery GetApiMappings' {Maybe Text
Text
domainName :: Text
nextToken :: Maybe Text
maxResults :: Maybe Text
$sel:domainName:GetApiMappings' :: GetApiMappings -> Text
$sel:nextToken:GetApiMappings' :: GetApiMappings -> Maybe Text
$sel:maxResults:GetApiMappings' :: GetApiMappings -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
maxResults,
        ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newGetApiMappingsResponse' smart constructor.
data GetApiMappingsResponse = GetApiMappingsResponse'
  { -- | The elements from this collection.
    GetApiMappingsResponse -> Maybe [ApiMapping]
items :: Prelude.Maybe [ApiMapping],
    -- | The next page of elements from this collection. Not valid for the last
    -- element of the collection.
    GetApiMappingsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetApiMappingsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetApiMappingsResponse -> GetApiMappingsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetApiMappingsResponse -> GetApiMappingsResponse -> Bool
$c/= :: GetApiMappingsResponse -> GetApiMappingsResponse -> Bool
== :: GetApiMappingsResponse -> GetApiMappingsResponse -> Bool
$c== :: GetApiMappingsResponse -> GetApiMappingsResponse -> Bool
Prelude.Eq, ReadPrec [GetApiMappingsResponse]
ReadPrec GetApiMappingsResponse
Int -> ReadS GetApiMappingsResponse
ReadS [GetApiMappingsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetApiMappingsResponse]
$creadListPrec :: ReadPrec [GetApiMappingsResponse]
readPrec :: ReadPrec GetApiMappingsResponse
$creadPrec :: ReadPrec GetApiMappingsResponse
readList :: ReadS [GetApiMappingsResponse]
$creadList :: ReadS [GetApiMappingsResponse]
readsPrec :: Int -> ReadS GetApiMappingsResponse
$creadsPrec :: Int -> ReadS GetApiMappingsResponse
Prelude.Read, Int -> GetApiMappingsResponse -> ShowS
[GetApiMappingsResponse] -> ShowS
GetApiMappingsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetApiMappingsResponse] -> ShowS
$cshowList :: [GetApiMappingsResponse] -> ShowS
show :: GetApiMappingsResponse -> String
$cshow :: GetApiMappingsResponse -> String
showsPrec :: Int -> GetApiMappingsResponse -> ShowS
$cshowsPrec :: Int -> GetApiMappingsResponse -> ShowS
Prelude.Show, forall x. Rep GetApiMappingsResponse x -> GetApiMappingsResponse
forall x. GetApiMappingsResponse -> Rep GetApiMappingsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetApiMappingsResponse x -> GetApiMappingsResponse
$cfrom :: forall x. GetApiMappingsResponse -> Rep GetApiMappingsResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetApiMappingsResponse' 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', 'getApiMappingsResponse_items' - The elements from this collection.
--
-- 'nextToken', 'getApiMappingsResponse_nextToken' - The next page of elements from this collection. Not valid for the last
-- element of the collection.
--
-- 'httpStatus', 'getApiMappingsResponse_httpStatus' - The response's http status code.
newGetApiMappingsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetApiMappingsResponse
newGetApiMappingsResponse :: Int -> GetApiMappingsResponse
newGetApiMappingsResponse Int
pHttpStatus_ =
  GetApiMappingsResponse'
    { $sel:items:GetApiMappingsResponse' :: Maybe [ApiMapping]
items = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:GetApiMappingsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetApiMappingsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The elements from this collection.
getApiMappingsResponse_items :: Lens.Lens' GetApiMappingsResponse (Prelude.Maybe [ApiMapping])
getApiMappingsResponse_items :: Lens' GetApiMappingsResponse (Maybe [ApiMapping])
getApiMappingsResponse_items = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetApiMappingsResponse' {Maybe [ApiMapping]
items :: Maybe [ApiMapping]
$sel:items:GetApiMappingsResponse' :: GetApiMappingsResponse -> Maybe [ApiMapping]
items} -> Maybe [ApiMapping]
items) (\s :: GetApiMappingsResponse
s@GetApiMappingsResponse' {} Maybe [ApiMapping]
a -> GetApiMappingsResponse
s {$sel:items:GetApiMappingsResponse' :: Maybe [ApiMapping]
items = Maybe [ApiMapping]
a} :: GetApiMappingsResponse) 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 next page of elements from this collection. Not valid for the last
-- element of the collection.
getApiMappingsResponse_nextToken :: Lens.Lens' GetApiMappingsResponse (Prelude.Maybe Prelude.Text)
getApiMappingsResponse_nextToken :: Lens' GetApiMappingsResponse (Maybe Text)
getApiMappingsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetApiMappingsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:GetApiMappingsResponse' :: GetApiMappingsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetApiMappingsResponse
s@GetApiMappingsResponse' {} Maybe Text
a -> GetApiMappingsResponse
s {$sel:nextToken:GetApiMappingsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: GetApiMappingsResponse)

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

instance Prelude.NFData GetApiMappingsResponse where
  rnf :: GetApiMappingsResponse -> ()
rnf GetApiMappingsResponse' {Int
Maybe [ApiMapping]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
items :: Maybe [ApiMapping]
$sel:httpStatus:GetApiMappingsResponse' :: GetApiMappingsResponse -> Int
$sel:nextToken:GetApiMappingsResponse' :: GetApiMappingsResponse -> Maybe Text
$sel:items:GetApiMappingsResponse' :: GetApiMappingsResponse -> Maybe [ApiMapping]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ApiMapping]
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