{-# 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 #-}
module Amazonka.APIGateway.GetModels
(
GetModels (..),
newGetModels,
getModels_limit,
getModels_position,
getModels_restApiId,
GetModelsResponse (..),
newGetModelsResponse,
getModelsResponse_items,
getModelsResponse_position,
getModelsResponse_httpStatus,
)
where
import Amazonka.APIGateway.Types
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
data GetModels = GetModels'
{
GetModels -> Maybe Int
limit :: Prelude.Maybe Prelude.Int,
GetModels -> Maybe Text
position :: Prelude.Maybe Prelude.Text,
GetModels -> Text
restApiId :: Prelude.Text
}
deriving (GetModels -> GetModels -> Bool
(GetModels -> GetModels -> Bool)
-> (GetModels -> GetModels -> Bool) -> Eq GetModels
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetModels -> GetModels -> Bool
$c/= :: GetModels -> GetModels -> Bool
== :: GetModels -> GetModels -> Bool
$c== :: GetModels -> GetModels -> Bool
Prelude.Eq, ReadPrec [GetModels]
ReadPrec GetModels
Int -> ReadS GetModels
ReadS [GetModels]
(Int -> ReadS GetModels)
-> ReadS [GetModels]
-> ReadPrec GetModels
-> ReadPrec [GetModels]
-> Read GetModels
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetModels]
$creadListPrec :: ReadPrec [GetModels]
readPrec :: ReadPrec GetModels
$creadPrec :: ReadPrec GetModels
readList :: ReadS [GetModels]
$creadList :: ReadS [GetModels]
readsPrec :: Int -> ReadS GetModels
$creadsPrec :: Int -> ReadS GetModels
Prelude.Read, Int -> GetModels -> ShowS
[GetModels] -> ShowS
GetModels -> String
(Int -> GetModels -> ShowS)
-> (GetModels -> String)
-> ([GetModels] -> ShowS)
-> Show GetModels
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetModels] -> ShowS
$cshowList :: [GetModels] -> ShowS
show :: GetModels -> String
$cshow :: GetModels -> String
showsPrec :: Int -> GetModels -> ShowS
$cshowsPrec :: Int -> GetModels -> ShowS
Prelude.Show, (forall x. GetModels -> Rep GetModels x)
-> (forall x. Rep GetModels x -> GetModels) -> Generic GetModels
forall x. Rep GetModels x -> GetModels
forall x. GetModels -> Rep GetModels x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetModels x -> GetModels
$cfrom :: forall x. GetModels -> Rep GetModels x
Prelude.Generic)
newGetModels ::
Prelude.Text ->
GetModels
newGetModels :: Text -> GetModels
newGetModels Text
pRestApiId_ =
GetModels' :: Maybe Int -> Maybe Text -> Text -> GetModels
GetModels'
{ $sel:limit:GetModels' :: Maybe Int
limit = Maybe Int
forall a. Maybe a
Prelude.Nothing,
$sel:position:GetModels' :: Maybe Text
position = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:restApiId:GetModels' :: Text
restApiId = Text
pRestApiId_
}
getModels_limit :: Lens.Lens' GetModels (Prelude.Maybe Prelude.Int)
getModels_limit :: (Maybe Int -> f (Maybe Int)) -> GetModels -> f GetModels
getModels_limit = (GetModels -> Maybe Int)
-> (GetModels -> Maybe Int -> GetModels)
-> Lens GetModels GetModels (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetModels' {Maybe Int
limit :: Maybe Int
$sel:limit:GetModels' :: GetModels -> Maybe Int
limit} -> Maybe Int
limit) (\s :: GetModels
s@GetModels' {} Maybe Int
a -> GetModels
s {$sel:limit:GetModels' :: Maybe Int
limit = Maybe Int
a} :: GetModels)
getModels_position :: Lens.Lens' GetModels (Prelude.Maybe Prelude.Text)
getModels_position :: (Maybe Text -> f (Maybe Text)) -> GetModels -> f GetModels
getModels_position = (GetModels -> Maybe Text)
-> (GetModels -> Maybe Text -> GetModels)
-> Lens GetModels GetModels (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetModels' {Maybe Text
position :: Maybe Text
$sel:position:GetModels' :: GetModels -> Maybe Text
position} -> Maybe Text
position) (\s :: GetModels
s@GetModels' {} Maybe Text
a -> GetModels
s {$sel:position:GetModels' :: Maybe Text
position = Maybe Text
a} :: GetModels)
getModels_restApiId :: Lens.Lens' GetModels Prelude.Text
getModels_restApiId :: (Text -> f Text) -> GetModels -> f GetModels
getModels_restApiId = (GetModels -> Text)
-> (GetModels -> Text -> GetModels)
-> Lens GetModels GetModels Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetModels' {Text
restApiId :: Text
$sel:restApiId:GetModels' :: GetModels -> Text
restApiId} -> Text
restApiId) (\s :: GetModels
s@GetModels' {} Text
a -> GetModels
s {$sel:restApiId:GetModels' :: Text
restApiId = Text
a} :: GetModels)
instance Core.AWSPager GetModels where
page :: GetModels -> AWSResponse GetModels -> Maybe GetModels
page GetModels
rq AWSResponse GetModels
rs
| Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse GetModels
GetModelsResponse
rs
GetModelsResponse
-> Getting (First Text) GetModelsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetModelsResponse -> Const (First Text) GetModelsResponse
Lens' GetModelsResponse (Maybe Text)
getModelsResponse_position ((Maybe Text -> Const (First Text) (Maybe Text))
-> GetModelsResponse -> Const (First Text) GetModelsResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetModelsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
Maybe GetModels
forall a. Maybe a
Prelude.Nothing
| Maybe [Model] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse GetModels
GetModelsResponse
rs
GetModelsResponse
-> Getting (First [Model]) GetModelsResponse [Model]
-> Maybe [Model]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Model] -> Const (First [Model]) (Maybe [Model]))
-> GetModelsResponse -> Const (First [Model]) GetModelsResponse
Lens' GetModelsResponse (Maybe [Model])
getModelsResponse_items ((Maybe [Model] -> Const (First [Model]) (Maybe [Model]))
-> GetModelsResponse -> Const (First [Model]) GetModelsResponse)
-> (([Model] -> Const (First [Model]) [Model])
-> Maybe [Model] -> Const (First [Model]) (Maybe [Model]))
-> Getting (First [Model]) GetModelsResponse [Model]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Model] -> Const (First [Model]) [Model])
-> Maybe [Model] -> Const (First [Model]) (Maybe [Model])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
Maybe GetModels
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
GetModels -> Maybe GetModels
forall a. a -> Maybe a
Prelude.Just (GetModels -> Maybe GetModels) -> GetModels -> Maybe GetModels
forall a b. (a -> b) -> a -> b
Prelude.$
GetModels
rq
GetModels -> (GetModels -> GetModels) -> GetModels
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> GetModels -> Identity GetModels
Lens GetModels GetModels (Maybe Text) (Maybe Text)
getModels_position
((Maybe Text -> Identity (Maybe Text))
-> GetModels -> Identity GetModels)
-> Maybe Text -> GetModels -> GetModels
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse GetModels
GetModelsResponse
rs
GetModelsResponse
-> Getting (First Text) GetModelsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> GetModelsResponse -> Const (First Text) GetModelsResponse
Lens' GetModelsResponse (Maybe Text)
getModelsResponse_position ((Maybe Text -> Const (First Text) (Maybe Text))
-> GetModelsResponse -> Const (First Text) GetModelsResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) GetModelsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
instance Core.AWSRequest GetModels where
type AWSResponse GetModels = GetModelsResponse
request :: GetModels -> Request GetModels
request = Service -> GetModels -> Request GetModels
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
response :: Logger
-> Service
-> Proxy GetModels
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetModels)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetModels))
-> Logger
-> Service
-> Proxy GetModels
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetModels)))
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 [Model] -> Maybe Text -> Int -> GetModelsResponse
GetModelsResponse'
(Maybe [Model] -> Maybe Text -> Int -> GetModelsResponse)
-> Either String (Maybe [Model])
-> Either String (Maybe Text -> Int -> GetModelsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Model]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"item" Either String (Maybe (Maybe [Model]))
-> Maybe [Model] -> Either String (Maybe [Model])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Model]
forall a. Monoid a => a
Prelude.mempty)
Either String (Maybe Text -> Int -> GetModelsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetModelsResponse)
forall (f :: * -> *) a b. Applicative f => 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
"position")
Either String (Int -> GetModelsResponse)
-> Either String Int -> Either String GetModelsResponse
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 GetModels
instance Prelude.NFData GetModels
instance Core.ToHeaders GetModels where
toHeaders :: GetModels -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetModels -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Accept"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"application/json" :: Prelude.ByteString)
]
)
instance Core.ToPath GetModels where
toPath :: GetModels -> ByteString
toPath GetModels' {Maybe Int
Maybe Text
Text
restApiId :: Text
position :: Maybe Text
limit :: Maybe Int
$sel:restApiId:GetModels' :: GetModels -> Text
$sel:position:GetModels' :: GetModels -> Maybe Text
$sel:limit:GetModels' :: GetModels -> Maybe Int
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/restapis/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
restApiId, ByteString
"/models"]
instance Core.ToQuery GetModels where
toQuery :: GetModels -> QueryString
toQuery GetModels' {Maybe Int
Maybe Text
Text
restApiId :: Text
position :: Maybe Text
limit :: Maybe Int
$sel:restApiId:GetModels' :: GetModels -> Text
$sel:position:GetModels' :: GetModels -> Maybe Text
$sel:limit:GetModels' :: GetModels -> Maybe Int
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"limit" ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
limit, ByteString
"position" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
position]
data GetModelsResponse = GetModelsResponse'
{
GetModelsResponse -> Maybe [Model]
items :: Prelude.Maybe [Model],
GetModelsResponse -> Maybe Text
position :: Prelude.Maybe Prelude.Text,
GetModelsResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetModelsResponse -> GetModelsResponse -> Bool
(GetModelsResponse -> GetModelsResponse -> Bool)
-> (GetModelsResponse -> GetModelsResponse -> Bool)
-> Eq GetModelsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetModelsResponse -> GetModelsResponse -> Bool
$c/= :: GetModelsResponse -> GetModelsResponse -> Bool
== :: GetModelsResponse -> GetModelsResponse -> Bool
$c== :: GetModelsResponse -> GetModelsResponse -> Bool
Prelude.Eq, ReadPrec [GetModelsResponse]
ReadPrec GetModelsResponse
Int -> ReadS GetModelsResponse
ReadS [GetModelsResponse]
(Int -> ReadS GetModelsResponse)
-> ReadS [GetModelsResponse]
-> ReadPrec GetModelsResponse
-> ReadPrec [GetModelsResponse]
-> Read GetModelsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetModelsResponse]
$creadListPrec :: ReadPrec [GetModelsResponse]
readPrec :: ReadPrec GetModelsResponse
$creadPrec :: ReadPrec GetModelsResponse
readList :: ReadS [GetModelsResponse]
$creadList :: ReadS [GetModelsResponse]
readsPrec :: Int -> ReadS GetModelsResponse
$creadsPrec :: Int -> ReadS GetModelsResponse
Prelude.Read, Int -> GetModelsResponse -> ShowS
[GetModelsResponse] -> ShowS
GetModelsResponse -> String
(Int -> GetModelsResponse -> ShowS)
-> (GetModelsResponse -> String)
-> ([GetModelsResponse] -> ShowS)
-> Show GetModelsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetModelsResponse] -> ShowS
$cshowList :: [GetModelsResponse] -> ShowS
show :: GetModelsResponse -> String
$cshow :: GetModelsResponse -> String
showsPrec :: Int -> GetModelsResponse -> ShowS
$cshowsPrec :: Int -> GetModelsResponse -> ShowS
Prelude.Show, (forall x. GetModelsResponse -> Rep GetModelsResponse x)
-> (forall x. Rep GetModelsResponse x -> GetModelsResponse)
-> Generic GetModelsResponse
forall x. Rep GetModelsResponse x -> GetModelsResponse
forall x. GetModelsResponse -> Rep GetModelsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetModelsResponse x -> GetModelsResponse
$cfrom :: forall x. GetModelsResponse -> Rep GetModelsResponse x
Prelude.Generic)
newGetModelsResponse ::
Prelude.Int ->
GetModelsResponse
newGetModelsResponse :: Int -> GetModelsResponse
newGetModelsResponse Int
pHttpStatus_ =
GetModelsResponse' :: Maybe [Model] -> Maybe Text -> Int -> GetModelsResponse
GetModelsResponse'
{ $sel:items:GetModelsResponse' :: Maybe [Model]
items = Maybe [Model]
forall a. Maybe a
Prelude.Nothing,
$sel:position:GetModelsResponse' :: Maybe Text
position = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetModelsResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getModelsResponse_items :: Lens.Lens' GetModelsResponse (Prelude.Maybe [Model])
getModelsResponse_items :: (Maybe [Model] -> f (Maybe [Model]))
-> GetModelsResponse -> f GetModelsResponse
getModelsResponse_items = (GetModelsResponse -> Maybe [Model])
-> (GetModelsResponse -> Maybe [Model] -> GetModelsResponse)
-> Lens' GetModelsResponse (Maybe [Model])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetModelsResponse' {Maybe [Model]
items :: Maybe [Model]
$sel:items:GetModelsResponse' :: GetModelsResponse -> Maybe [Model]
items} -> Maybe [Model]
items) (\s :: GetModelsResponse
s@GetModelsResponse' {} Maybe [Model]
a -> GetModelsResponse
s {$sel:items:GetModelsResponse' :: Maybe [Model]
items = Maybe [Model]
a} :: GetModelsResponse) ((Maybe [Model] -> f (Maybe [Model]))
-> GetModelsResponse -> f GetModelsResponse)
-> ((Maybe [Model] -> f (Maybe [Model]))
-> Maybe [Model] -> f (Maybe [Model]))
-> (Maybe [Model] -> f (Maybe [Model]))
-> GetModelsResponse
-> f GetModelsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Model] [Model] [Model] [Model]
-> Iso
(Maybe [Model]) (Maybe [Model]) (Maybe [Model]) (Maybe [Model])
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 [Model] [Model] [Model] [Model]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
getModelsResponse_position :: Lens.Lens' GetModelsResponse (Prelude.Maybe Prelude.Text)
getModelsResponse_position :: (Maybe Text -> f (Maybe Text))
-> GetModelsResponse -> f GetModelsResponse
getModelsResponse_position = (GetModelsResponse -> Maybe Text)
-> (GetModelsResponse -> Maybe Text -> GetModelsResponse)
-> Lens' GetModelsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetModelsResponse' {Maybe Text
position :: Maybe Text
$sel:position:GetModelsResponse' :: GetModelsResponse -> Maybe Text
position} -> Maybe Text
position) (\s :: GetModelsResponse
s@GetModelsResponse' {} Maybe Text
a -> GetModelsResponse
s {$sel:position:GetModelsResponse' :: Maybe Text
position = Maybe Text
a} :: GetModelsResponse)
getModelsResponse_httpStatus :: Lens.Lens' GetModelsResponse Prelude.Int
getModelsResponse_httpStatus :: (Int -> f Int) -> GetModelsResponse -> f GetModelsResponse
getModelsResponse_httpStatus = (GetModelsResponse -> Int)
-> (GetModelsResponse -> Int -> GetModelsResponse)
-> Lens GetModelsResponse GetModelsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetModelsResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetModelsResponse' :: GetModelsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetModelsResponse
s@GetModelsResponse' {} Int
a -> GetModelsResponse
s {$sel:httpStatus:GetModelsResponse' :: Int
httpStatus = Int
a} :: GetModelsResponse)
instance Prelude.NFData GetModelsResponse