{-# 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.ApiGatewayV2.GetModels
(
GetModels (..),
newGetModels,
getModels_nextToken,
getModels_maxResults,
getModels_apiId,
GetModelsResponse (..),
newGetModelsResponse,
getModelsResponse_items,
getModelsResponse_nextToken,
getModelsResponse_httpStatus,
)
where
import Amazonka.ApiGatewayV2.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 Text
nextToken :: Prelude.Maybe Prelude.Text,
GetModels -> Maybe Text
maxResults :: Prelude.Maybe Prelude.Text,
GetModels -> Text
apiId :: 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
pApiId_ =
GetModels' :: Maybe Text -> Maybe Text -> Text -> GetModels
GetModels'
{ $sel:nextToken:GetModels' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:maxResults:GetModels' :: Maybe Text
maxResults = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:apiId:GetModels' :: Text
apiId = Text
pApiId_
}
getModels_nextToken :: Lens.Lens' GetModels (Prelude.Maybe Prelude.Text)
getModels_nextToken :: (Maybe Text -> f (Maybe Text)) -> GetModels -> f GetModels
getModels_nextToken = (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
nextToken :: Maybe Text
$sel:nextToken:GetModels' :: GetModels -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetModels
s@GetModels' {} Maybe Text
a -> GetModels
s {$sel:nextToken:GetModels' :: Maybe Text
nextToken = Maybe Text
a} :: GetModels)
getModels_maxResults :: Lens.Lens' GetModels (Prelude.Maybe Prelude.Text)
getModels_maxResults :: (Maybe Text -> f (Maybe Text)) -> GetModels -> f GetModels
getModels_maxResults = (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
maxResults :: Maybe Text
$sel:maxResults:GetModels' :: GetModels -> Maybe Text
maxResults} -> Maybe Text
maxResults) (\s :: GetModels
s@GetModels' {} Maybe Text
a -> GetModels
s {$sel:maxResults:GetModels' :: Maybe Text
maxResults = Maybe Text
a} :: GetModels)
getModels_apiId :: Lens.Lens' GetModels Prelude.Text
getModels_apiId :: (Text -> f Text) -> GetModels -> f GetModels
getModels_apiId = (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
apiId :: Text
$sel:apiId:GetModels' :: GetModels -> Text
apiId} -> Text
apiId) (\s :: GetModels
s@GetModels' {} Text
a -> GetModels
s {$sel:apiId:GetModels' :: Text
apiId = 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_nextToken ((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_nextToken
((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_nextToken ((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
"items" 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
"nextToken")
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
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToPath GetModels where
toPath :: GetModels -> ByteString
toPath GetModels' {Maybe Text
Text
apiId :: Text
maxResults :: Maybe Text
nextToken :: Maybe Text
$sel:apiId:GetModels' :: GetModels -> Text
$sel:maxResults:GetModels' :: GetModels -> Maybe Text
$sel:nextToken:GetModels' :: GetModels -> Maybe Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/v2/apis/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
apiId, ByteString
"/models"]
instance Core.ToQuery GetModels where
toQuery :: GetModels -> QueryString
toQuery GetModels' {Maybe Text
Text
apiId :: Text
maxResults :: Maybe Text
nextToken :: Maybe Text
$sel:apiId:GetModels' :: GetModels -> Text
$sel:maxResults:GetModels' :: GetModels -> Maybe Text
$sel:nextToken:GetModels' :: GetModels -> Maybe Text
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"nextToken" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
ByteString
"maxResults" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
maxResults
]
data GetModelsResponse = GetModelsResponse'
{
GetModelsResponse -> Maybe [Model]
items :: Prelude.Maybe [Model],
GetModelsResponse -> Maybe Text
nextToken :: 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:nextToken:GetModelsResponse' :: Maybe Text
nextToken = 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_nextToken :: Lens.Lens' GetModelsResponse (Prelude.Maybe Prelude.Text)
getModelsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> GetModelsResponse -> f GetModelsResponse
getModelsResponse_nextToken = (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
nextToken :: Maybe Text
$sel:nextToken:GetModelsResponse' :: GetModelsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: GetModelsResponse
s@GetModelsResponse' {} Maybe Text
a -> GetModelsResponse
s {$sel:nextToken:GetModelsResponse' :: Maybe Text
nextToken = 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