{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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_contentType,
    getModelResponse_description,
    getModelResponse_modelId,
    getModelResponse_name,
    getModelResponse_schema,
    getModelResponse_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:/ '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
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]
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
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. 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' {$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 :: Lens' GetModel Text
getModel_modelId = 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 :: Lens' GetModel Text
getModel_apiId = 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 :: (Service -> Service) -> GetModel -> Request GetModel
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 GetModel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetModel)))
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 Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Int
-> GetModelResponse
GetModelResponse'
            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
"contentType")
            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
"description")
            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
"modelId")
            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
"name")
            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
"schema")
            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 GetModel where
  hashWithSalt :: Int -> GetModel -> Int
hashWithSalt Int
_salt GetModel' {Text
apiId :: Text
modelId :: Text
$sel:apiId:GetModel' :: GetModel -> Text
$sel:modelId:GetModel' :: GetModel -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
modelId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
apiId

instance Prelude.NFData GetModel where
  rnf :: GetModel -> ()
rnf GetModel' {Text
apiId :: Text
modelId :: Text
$sel:apiId:GetModel' :: GetModel -> Text
$sel:modelId:GetModel' :: GetModel -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
modelId seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
apiId

instance Data.ToHeaders GetModel where
  toHeaders :: GetModel -> 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 GetModel where
  toPath :: GetModel -> ByteString
toPath GetModel' {Text
apiId :: Text
modelId :: Text
$sel:apiId:GetModel' :: GetModel -> Text
$sel:modelId:GetModel' :: GetModel -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v2/apis/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
apiId,
        ByteString
"/models/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
modelId
      ]

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

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

-- | The content-type for the model, for example, \"application\/json\".
getModelResponse_contentType :: Lens.Lens' GetModelResponse (Prelude.Maybe Prelude.Text)
getModelResponse_contentType :: Lens' GetModelResponse (Maybe Text)
getModelResponse_contentType = 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 description of the model.
getModelResponse_description :: Lens.Lens' GetModelResponse (Prelude.Maybe Prelude.Text)
getModelResponse_description :: Lens' GetModelResponse (Maybe Text)
getModelResponse_description = 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 model identifier.
getModelResponse_modelId :: Lens.Lens' GetModelResponse (Prelude.Maybe Prelude.Text)
getModelResponse_modelId :: Lens' GetModelResponse (Maybe Text)
getModelResponse_modelId = 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 name of the model. Must be alphanumeric.
getModelResponse_name :: Lens.Lens' GetModelResponse (Prelude.Maybe Prelude.Text)
getModelResponse_name :: Lens' GetModelResponse (Maybe Text)
getModelResponse_name = 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 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 :: Lens' GetModelResponse (Maybe Text)
getModelResponse_schema = 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 response's http status code.
getModelResponse_httpStatus :: Lens.Lens' GetModelResponse Prelude.Int
getModelResponse_httpStatus :: Lens' GetModelResponse Int
getModelResponse_httpStatus = 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 where
  rnf :: GetModelResponse -> ()
rnf GetModelResponse' {Int
Maybe Text
httpStatus :: Int
schema :: Maybe Text
name :: Maybe Text
modelId :: Maybe Text
description :: Maybe Text
contentType :: Maybe Text
$sel:httpStatus:GetModelResponse' :: GetModelResponse -> Int
$sel:schema:GetModelResponse' :: GetModelResponse -> Maybe Text
$sel:name:GetModelResponse' :: GetModelResponse -> Maybe Text
$sel:modelId:GetModelResponse' :: GetModelResponse -> Maybe Text
$sel:description:GetModelResponse' :: GetModelResponse -> Maybe Text
$sel:contentType:GetModelResponse' :: GetModelResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
contentType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
modelId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
schema
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus