{-# 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.GetModel
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets a Model.
module Amazonka.ApiGatewayV2.GetModel
  ( -- * Creating a Request
    GetModel (..),
    newGetModel,

    -- * Request Lenses
    getModel_modelId,
    getModel_apiId,

    -- * Destructuring the Response
    GetModelResponse (..),
    newGetModelResponse,

    -- * Response Lenses
    getModelResponse_modelId,
    getModelResponse_schema,
    getModelResponse_name,
    getModelResponse_description,
    getModelResponse_contentType,
    getModelResponse_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

-- | /See:/ 'newGetModel' smart constructor.
data GetModel = GetModel'
  { -- | The model ID.
    GetModel -> Text
modelId :: Prelude.Text,
    -- | The API identifier.
    GetModel -> Text
apiId :: Prelude.Text
  }
  deriving (GetModel -> GetModel -> Bool
(GetModel -> GetModel -> Bool)
-> (GetModel -> GetModel -> Bool) -> Eq GetModel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetModel -> GetModel -> Bool
$c/= :: GetModel -> GetModel -> Bool
== :: GetModel -> GetModel -> Bool
$c== :: GetModel -> GetModel -> Bool
Prelude.Eq, ReadPrec [GetModel]
ReadPrec GetModel
Int -> ReadS GetModel
ReadS [GetModel]
(Int -> ReadS GetModel)
-> ReadS [GetModel]
-> ReadPrec GetModel
-> ReadPrec [GetModel]
-> Read GetModel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetModel]
$creadListPrec :: ReadPrec [GetModel]
readPrec :: ReadPrec GetModel
$creadPrec :: ReadPrec GetModel
readList :: ReadS [GetModel]
$creadList :: ReadS [GetModel]
readsPrec :: Int -> ReadS GetModel
$creadsPrec :: Int -> ReadS GetModel
Prelude.Read, Int -> GetModel -> ShowS
[GetModel] -> ShowS
GetModel -> String
(Int -> GetModel -> ShowS)
-> (GetModel -> String) -> ([GetModel] -> ShowS) -> Show GetModel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetModel] -> ShowS
$cshowList :: [GetModel] -> ShowS
show :: GetModel -> String
$cshow :: GetModel -> String
showsPrec :: Int -> GetModel -> ShowS
$cshowsPrec :: Int -> GetModel -> ShowS
Prelude.Show, (forall x. GetModel -> Rep GetModel x)
-> (forall x. Rep GetModel x -> GetModel) -> Generic GetModel
forall x. Rep GetModel x -> GetModel
forall x. GetModel -> Rep GetModel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetModel x -> GetModel
$cfrom :: forall x. GetModel -> Rep GetModel x
Prelude.Generic)

-- |
-- Create a value of 'GetModel' 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:
--
-- 'modelId', 'getModel_modelId' - The model ID.
--
-- 'apiId', 'getModel_apiId' - The API identifier.
newGetModel ::
  -- | 'modelId'
  Prelude.Text ->
  -- | 'apiId'
  Prelude.Text ->
  GetModel
newGetModel :: Text -> Text -> GetModel
newGetModel Text
pModelId_ Text
pApiId_ =
  GetModel' :: Text -> Text -> GetModel
GetModel' {$sel:modelId:GetModel' :: Text
modelId = Text
pModelId_, $sel:apiId:GetModel' :: Text
apiId = Text
pApiId_}

-- | The model ID.
getModel_modelId :: Lens.Lens' GetModel Prelude.Text
getModel_modelId :: (Text -> f Text) -> GetModel -> f GetModel
getModel_modelId = (GetModel -> Text)
-> (GetModel -> Text -> GetModel)
-> Lens GetModel GetModel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetModel' {Text
modelId :: Text
$sel:modelId:GetModel' :: GetModel -> Text
modelId} -> Text
modelId) (\s :: GetModel
s@GetModel' {} Text
a -> GetModel
s {$sel:modelId:GetModel' :: Text
modelId = Text
a} :: GetModel)

-- | The API identifier.
getModel_apiId :: Lens.Lens' GetModel Prelude.Text
getModel_apiId :: (Text -> f Text) -> GetModel -> f GetModel
getModel_apiId = (GetModel -> Text)
-> (GetModel -> Text -> GetModel)
-> Lens GetModel GetModel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetModel' {Text
apiId :: Text
$sel:apiId:GetModel' :: GetModel -> Text
apiId} -> Text
apiId) (\s :: GetModel
s@GetModel' {} Text
a -> GetModel
s {$sel:apiId:GetModel' :: Text
apiId = Text
a} :: GetModel)

instance Core.AWSRequest GetModel where
  type AWSResponse GetModel = GetModelResponse
  request :: GetModel -> Request GetModel
request = Service -> GetModel -> Request GetModel
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetModel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetModel)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetModel))
-> Logger
-> Service
-> Proxy GetModel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetModel)))
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 Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> GetModelResponse
GetModelResponse'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Int
 -> GetModelResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Int
      -> GetModelResponse)
forall (f :: * -> *) a b. Functor 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
"modelId")
            Either
  String
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Int
   -> GetModelResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text -> Maybe Text -> Maybe Text -> Int -> GetModelResponse)
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
"schema")
            Either
  String
  (Maybe Text -> Maybe Text -> Maybe Text -> Int -> GetModelResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Maybe Text -> Int -> GetModelResponse)
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
"name")
            Either String (Maybe Text -> Maybe Text -> Int -> GetModelResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> GetModelResponse)
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
"description")
            Either String (Maybe Text -> Int -> GetModelResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetModelResponse)
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
"contentType")
            Either String (Int -> GetModelResponse)
-> Either String Int -> Either String GetModelResponse
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 GetModel

instance Prelude.NFData GetModel

instance Core.ToHeaders GetModel where
  toHeaders :: GetModel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetModel -> 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 GetModel where
  toPath :: GetModel -> ByteString
toPath GetModel' {Text
apiId :: Text
modelId :: Text
$sel:apiId:GetModel' :: GetModel -> Text
$sel:modelId:GetModel' :: GetModel -> 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/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
modelId
      ]

instance Core.ToQuery GetModel where
  toQuery :: GetModel -> QueryString
toQuery = QueryString -> GetModel -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGetModelResponse' smart constructor.
data GetModelResponse = GetModelResponse'
  { -- | The model identifier.
    GetModelResponse -> Maybe Text
modelId :: Prelude.Maybe Prelude.Text,
    -- | The schema for the model. For application\/json models, this should be
    -- JSON schema draft 4 model.
    GetModelResponse -> Maybe Text
schema :: Prelude.Maybe Prelude.Text,
    -- | The name of the model. Must be alphanumeric.
    GetModelResponse -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The description of the model.
    GetModelResponse -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The content-type for the model, for example, \"application\/json\".
    GetModelResponse -> Maybe Text
contentType :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetModelResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetModelResponse -> GetModelResponse -> Bool
(GetModelResponse -> GetModelResponse -> Bool)
-> (GetModelResponse -> GetModelResponse -> Bool)
-> Eq GetModelResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetModelResponse -> GetModelResponse -> Bool
$c/= :: GetModelResponse -> GetModelResponse -> Bool
== :: GetModelResponse -> GetModelResponse -> Bool
$c== :: GetModelResponse -> GetModelResponse -> Bool
Prelude.Eq, ReadPrec [GetModelResponse]
ReadPrec GetModelResponse
Int -> ReadS GetModelResponse
ReadS [GetModelResponse]
(Int -> ReadS GetModelResponse)
-> ReadS [GetModelResponse]
-> ReadPrec GetModelResponse
-> ReadPrec [GetModelResponse]
-> Read GetModelResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetModelResponse]
$creadListPrec :: ReadPrec [GetModelResponse]
readPrec :: ReadPrec GetModelResponse
$creadPrec :: ReadPrec GetModelResponse
readList :: ReadS [GetModelResponse]
$creadList :: ReadS [GetModelResponse]
readsPrec :: Int -> ReadS GetModelResponse
$creadsPrec :: Int -> ReadS GetModelResponse
Prelude.Read, Int -> GetModelResponse -> ShowS
[GetModelResponse] -> ShowS
GetModelResponse -> String
(Int -> GetModelResponse -> ShowS)
-> (GetModelResponse -> String)
-> ([GetModelResponse] -> ShowS)
-> Show GetModelResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetModelResponse] -> ShowS
$cshowList :: [GetModelResponse] -> ShowS
show :: GetModelResponse -> String
$cshow :: GetModelResponse -> String
showsPrec :: Int -> GetModelResponse -> ShowS
$cshowsPrec :: Int -> GetModelResponse -> ShowS
Prelude.Show, (forall x. GetModelResponse -> Rep GetModelResponse x)
-> (forall x. Rep GetModelResponse x -> GetModelResponse)
-> Generic GetModelResponse
forall x. Rep GetModelResponse x -> GetModelResponse
forall x. GetModelResponse -> Rep GetModelResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetModelResponse x -> GetModelResponse
$cfrom :: forall x. GetModelResponse -> Rep GetModelResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetModelResponse' 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:
--
-- 'modelId', 'getModelResponse_modelId' - The model identifier.
--
-- 'schema', 'getModelResponse_schema' - The schema for the model. For application\/json models, this should be
-- JSON schema draft 4 model.
--
-- 'name', 'getModelResponse_name' - The name of the model. Must be alphanumeric.
--
-- 'description', 'getModelResponse_description' - The description of the model.
--
-- 'contentType', 'getModelResponse_contentType' - The content-type for the model, for example, \"application\/json\".
--
-- 'httpStatus', 'getModelResponse_httpStatus' - The response's http status code.
newGetModelResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetModelResponse
newGetModelResponse :: Int -> GetModelResponse
newGetModelResponse Int
pHttpStatus_ =
  GetModelResponse' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> GetModelResponse
GetModelResponse'
    { $sel:modelId:GetModelResponse' :: Maybe Text
modelId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:schema:GetModelResponse' :: Maybe Text
schema = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:GetModelResponse' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:GetModelResponse' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:contentType:GetModelResponse' :: Maybe Text
contentType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetModelResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The model identifier.
getModelResponse_modelId :: Lens.Lens' GetModelResponse (Prelude.Maybe Prelude.Text)
getModelResponse_modelId :: (Maybe Text -> f (Maybe Text))
-> GetModelResponse -> f GetModelResponse
getModelResponse_modelId = (GetModelResponse -> Maybe Text)
-> (GetModelResponse -> Maybe Text -> GetModelResponse)
-> Lens GetModelResponse GetModelResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetModelResponse' {Maybe Text
modelId :: Maybe Text
$sel:modelId:GetModelResponse' :: GetModelResponse -> Maybe Text
modelId} -> Maybe Text
modelId) (\s :: GetModelResponse
s@GetModelResponse' {} Maybe Text
a -> GetModelResponse
s {$sel:modelId:GetModelResponse' :: Maybe Text
modelId = Maybe Text
a} :: GetModelResponse)

-- | The schema for the model. For application\/json models, this should be
-- JSON schema draft 4 model.
getModelResponse_schema :: Lens.Lens' GetModelResponse (Prelude.Maybe Prelude.Text)
getModelResponse_schema :: (Maybe Text -> f (Maybe Text))
-> GetModelResponse -> f GetModelResponse
getModelResponse_schema = (GetModelResponse -> Maybe Text)
-> (GetModelResponse -> Maybe Text -> GetModelResponse)
-> Lens GetModelResponse GetModelResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetModelResponse' {Maybe Text
schema :: Maybe Text
$sel:schema:GetModelResponse' :: GetModelResponse -> Maybe Text
schema} -> Maybe Text
schema) (\s :: GetModelResponse
s@GetModelResponse' {} Maybe Text
a -> GetModelResponse
s {$sel:schema:GetModelResponse' :: Maybe Text
schema = Maybe Text
a} :: GetModelResponse)

-- | The name of the model. Must be alphanumeric.
getModelResponse_name :: Lens.Lens' GetModelResponse (Prelude.Maybe Prelude.Text)
getModelResponse_name :: (Maybe Text -> f (Maybe Text))
-> GetModelResponse -> f GetModelResponse
getModelResponse_name = (GetModelResponse -> Maybe Text)
-> (GetModelResponse -> Maybe Text -> GetModelResponse)
-> Lens GetModelResponse GetModelResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetModelResponse' {Maybe Text
name :: Maybe Text
$sel:name:GetModelResponse' :: GetModelResponse -> Maybe Text
name} -> Maybe Text
name) (\s :: GetModelResponse
s@GetModelResponse' {} Maybe Text
a -> GetModelResponse
s {$sel:name:GetModelResponse' :: Maybe Text
name = Maybe Text
a} :: GetModelResponse)

-- | The description of the model.
getModelResponse_description :: Lens.Lens' GetModelResponse (Prelude.Maybe Prelude.Text)
getModelResponse_description :: (Maybe Text -> f (Maybe Text))
-> GetModelResponse -> f GetModelResponse
getModelResponse_description = (GetModelResponse -> Maybe Text)
-> (GetModelResponse -> Maybe Text -> GetModelResponse)
-> Lens GetModelResponse GetModelResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetModelResponse' {Maybe Text
description :: Maybe Text
$sel:description:GetModelResponse' :: GetModelResponse -> Maybe Text
description} -> Maybe Text
description) (\s :: GetModelResponse
s@GetModelResponse' {} Maybe Text
a -> GetModelResponse
s {$sel:description:GetModelResponse' :: Maybe Text
description = Maybe Text
a} :: GetModelResponse)

-- | The content-type for the model, for example, \"application\/json\".
getModelResponse_contentType :: Lens.Lens' GetModelResponse (Prelude.Maybe Prelude.Text)
getModelResponse_contentType :: (Maybe Text -> f (Maybe Text))
-> GetModelResponse -> f GetModelResponse
getModelResponse_contentType = (GetModelResponse -> Maybe Text)
-> (GetModelResponse -> Maybe Text -> GetModelResponse)
-> Lens GetModelResponse GetModelResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetModelResponse' {Maybe Text
contentType :: Maybe Text
$sel:contentType:GetModelResponse' :: GetModelResponse -> Maybe Text
contentType} -> Maybe Text
contentType) (\s :: GetModelResponse
s@GetModelResponse' {} Maybe Text
a -> GetModelResponse
s {$sel:contentType:GetModelResponse' :: Maybe Text
contentType = Maybe Text
a} :: GetModelResponse)

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

instance Prelude.NFData GetModelResponse