{-# 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.GetAuthorizers
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Describe an existing Authorizers resource.
--
-- This operation returns paginated results.
module Amazonka.APIGateway.GetAuthorizers
  ( -- * Creating a Request
    GetAuthorizers (..),
    newGetAuthorizers,

    -- * Request Lenses
    getAuthorizers_limit,
    getAuthorizers_position,
    getAuthorizers_restApiId,

    -- * Destructuring the Response
    GetAuthorizersResponse (..),
    newGetAuthorizersResponse,

    -- * Response Lenses
    getAuthorizersResponse_items,
    getAuthorizersResponse_position,
    getAuthorizersResponse_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 an existing Authorizers resource.
--
-- /See:/ 'newGetAuthorizers' smart constructor.
data GetAuthorizers = GetAuthorizers'
  { -- | The maximum number of returned results per page. The default value is 25
    -- and the maximum value is 500.
    GetAuthorizers -> Maybe Int
limit :: Prelude.Maybe Prelude.Int,
    -- | The current pagination position in the paged result set.
    GetAuthorizers -> Maybe Text
position :: Prelude.Maybe Prelude.Text,
    -- | The string identifier of the associated RestApi.
    GetAuthorizers -> Text
restApiId :: Prelude.Text
  }
  deriving (GetAuthorizers -> GetAuthorizers -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAuthorizers -> GetAuthorizers -> Bool
$c/= :: GetAuthorizers -> GetAuthorizers -> Bool
== :: GetAuthorizers -> GetAuthorizers -> Bool
$c== :: GetAuthorizers -> GetAuthorizers -> Bool
Prelude.Eq, ReadPrec [GetAuthorizers]
ReadPrec GetAuthorizers
Int -> ReadS GetAuthorizers
ReadS [GetAuthorizers]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAuthorizers]
$creadListPrec :: ReadPrec [GetAuthorizers]
readPrec :: ReadPrec GetAuthorizers
$creadPrec :: ReadPrec GetAuthorizers
readList :: ReadS [GetAuthorizers]
$creadList :: ReadS [GetAuthorizers]
readsPrec :: Int -> ReadS GetAuthorizers
$creadsPrec :: Int -> ReadS GetAuthorizers
Prelude.Read, Int -> GetAuthorizers -> ShowS
[GetAuthorizers] -> ShowS
GetAuthorizers -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAuthorizers] -> ShowS
$cshowList :: [GetAuthorizers] -> ShowS
show :: GetAuthorizers -> String
$cshow :: GetAuthorizers -> String
showsPrec :: Int -> GetAuthorizers -> ShowS
$cshowsPrec :: Int -> GetAuthorizers -> ShowS
Prelude.Show, forall x. Rep GetAuthorizers x -> GetAuthorizers
forall x. GetAuthorizers -> Rep GetAuthorizers x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetAuthorizers x -> GetAuthorizers
$cfrom :: forall x. GetAuthorizers -> Rep GetAuthorizers x
Prelude.Generic)

-- |
-- Create a value of 'GetAuthorizers' 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', 'getAuthorizers_limit' - The maximum number of returned results per page. The default value is 25
-- and the maximum value is 500.
--
-- 'position', 'getAuthorizers_position' - The current pagination position in the paged result set.
--
-- 'restApiId', 'getAuthorizers_restApiId' - The string identifier of the associated RestApi.
newGetAuthorizers ::
  -- | 'restApiId'
  Prelude.Text ->
  GetAuthorizers
newGetAuthorizers :: Text -> GetAuthorizers
newGetAuthorizers Text
pRestApiId_ =
  GetAuthorizers'
    { $sel:limit:GetAuthorizers' :: Maybe Int
limit = forall a. Maybe a
Prelude.Nothing,
      $sel:position:GetAuthorizers' :: Maybe Text
position = forall a. Maybe a
Prelude.Nothing,
      $sel:restApiId:GetAuthorizers' :: Text
restApiId = Text
pRestApiId_
    }

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

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

-- | The string identifier of the associated RestApi.
getAuthorizers_restApiId :: Lens.Lens' GetAuthorizers Prelude.Text
getAuthorizers_restApiId :: Lens' GetAuthorizers Text
getAuthorizers_restApiId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAuthorizers' {Text
restApiId :: Text
$sel:restApiId:GetAuthorizers' :: GetAuthorizers -> Text
restApiId} -> Text
restApiId) (\s :: GetAuthorizers
s@GetAuthorizers' {} Text
a -> GetAuthorizers
s {$sel:restApiId:GetAuthorizers' :: Text
restApiId = Text
a} :: GetAuthorizers)

instance Core.AWSPager GetAuthorizers where
  page :: GetAuthorizers
-> AWSResponse GetAuthorizers -> Maybe GetAuthorizers
page GetAuthorizers
rq AWSResponse GetAuthorizers
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse GetAuthorizers
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetAuthorizersResponse (Maybe Text)
getAuthorizersResponse_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 GetAuthorizers
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetAuthorizersResponse (Maybe [Authorizer])
getAuthorizersResponse_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.$ GetAuthorizers
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' GetAuthorizers (Maybe Text)
getAuthorizers_position
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetAuthorizers
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' GetAuthorizersResponse (Maybe Text)
getAuthorizersResponse_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 GetAuthorizers where
  type
    AWSResponse GetAuthorizers =
      GetAuthorizersResponse
  request :: (Service -> Service) -> GetAuthorizers -> Request GetAuthorizers
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 GetAuthorizers
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAuthorizers)))
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 [Authorizer] -> Maybe Text -> Int -> GetAuthorizersResponse
GetAuthorizersResponse'
            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 GetAuthorizers where
  hashWithSalt :: Int -> GetAuthorizers -> Int
hashWithSalt Int
_salt GetAuthorizers' {Maybe Int
Maybe Text
Text
restApiId :: Text
position :: Maybe Text
limit :: Maybe Int
$sel:restApiId:GetAuthorizers' :: GetAuthorizers -> Text
$sel:position:GetAuthorizers' :: GetAuthorizers -> Maybe Text
$sel:limit:GetAuthorizers' :: GetAuthorizers -> 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
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
restApiId

instance Prelude.NFData GetAuthorizers where
  rnf :: GetAuthorizers -> ()
rnf GetAuthorizers' {Maybe Int
Maybe Text
Text
restApiId :: Text
position :: Maybe Text
limit :: Maybe Int
$sel:restApiId:GetAuthorizers' :: GetAuthorizers -> Text
$sel:position:GetAuthorizers' :: GetAuthorizers -> Maybe Text
$sel:limit:GetAuthorizers' :: GetAuthorizers -> 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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
restApiId

instance Data.ToHeaders GetAuthorizers where
  toHeaders :: GetAuthorizers -> 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 GetAuthorizers where
  toPath :: GetAuthorizers -> ByteString
toPath GetAuthorizers' {Maybe Int
Maybe Text
Text
restApiId :: Text
position :: Maybe Text
limit :: Maybe Int
$sel:restApiId:GetAuthorizers' :: GetAuthorizers -> Text
$sel:position:GetAuthorizers' :: GetAuthorizers -> Maybe Text
$sel:limit:GetAuthorizers' :: GetAuthorizers -> Maybe Int
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/restapis/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
restApiId, ByteString
"/authorizers"]

instance Data.ToQuery GetAuthorizers where
  toQuery :: GetAuthorizers -> QueryString
toQuery GetAuthorizers' {Maybe Int
Maybe Text
Text
restApiId :: Text
position :: Maybe Text
limit :: Maybe Int
$sel:restApiId:GetAuthorizers' :: GetAuthorizers -> Text
$sel:position:GetAuthorizers' :: GetAuthorizers -> Maybe Text
$sel:limit:GetAuthorizers' :: GetAuthorizers -> 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 Authorizer resources.
--
-- /See:/ 'newGetAuthorizersResponse' smart constructor.
data GetAuthorizersResponse = GetAuthorizersResponse'
  { -- | The current page of elements from this collection.
    GetAuthorizersResponse -> Maybe [Authorizer]
items :: Prelude.Maybe [Authorizer],
    GetAuthorizersResponse -> Maybe Text
position :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetAuthorizersResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetAuthorizersResponse -> GetAuthorizersResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAuthorizersResponse -> GetAuthorizersResponse -> Bool
$c/= :: GetAuthorizersResponse -> GetAuthorizersResponse -> Bool
== :: GetAuthorizersResponse -> GetAuthorizersResponse -> Bool
$c== :: GetAuthorizersResponse -> GetAuthorizersResponse -> Bool
Prelude.Eq, ReadPrec [GetAuthorizersResponse]
ReadPrec GetAuthorizersResponse
Int -> ReadS GetAuthorizersResponse
ReadS [GetAuthorizersResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAuthorizersResponse]
$creadListPrec :: ReadPrec [GetAuthorizersResponse]
readPrec :: ReadPrec GetAuthorizersResponse
$creadPrec :: ReadPrec GetAuthorizersResponse
readList :: ReadS [GetAuthorizersResponse]
$creadList :: ReadS [GetAuthorizersResponse]
readsPrec :: Int -> ReadS GetAuthorizersResponse
$creadsPrec :: Int -> ReadS GetAuthorizersResponse
Prelude.Read, Int -> GetAuthorizersResponse -> ShowS
[GetAuthorizersResponse] -> ShowS
GetAuthorizersResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAuthorizersResponse] -> ShowS
$cshowList :: [GetAuthorizersResponse] -> ShowS
show :: GetAuthorizersResponse -> String
$cshow :: GetAuthorizersResponse -> String
showsPrec :: Int -> GetAuthorizersResponse -> ShowS
$cshowsPrec :: Int -> GetAuthorizersResponse -> ShowS
Prelude.Show, forall x. Rep GetAuthorizersResponse x -> GetAuthorizersResponse
forall x. GetAuthorizersResponse -> Rep GetAuthorizersResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetAuthorizersResponse x -> GetAuthorizersResponse
$cfrom :: forall x. GetAuthorizersResponse -> Rep GetAuthorizersResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetAuthorizersResponse' 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', 'getAuthorizersResponse_items' - The current page of elements from this collection.
--
-- 'position', 'getAuthorizersResponse_position' - Undocumented member.
--
-- 'httpStatus', 'getAuthorizersResponse_httpStatus' - The response's http status code.
newGetAuthorizersResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetAuthorizersResponse
newGetAuthorizersResponse :: Int -> GetAuthorizersResponse
newGetAuthorizersResponse Int
pHttpStatus_ =
  GetAuthorizersResponse'
    { $sel:items:GetAuthorizersResponse' :: Maybe [Authorizer]
items = forall a. Maybe a
Prelude.Nothing,
      $sel:position:GetAuthorizersResponse' :: Maybe Text
position = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetAuthorizersResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

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

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