{-# 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.LookoutVision.DescribeModel
-- 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)
--
-- Describes a version of an Amazon Lookout for Vision model.
--
-- This operation requires permissions to perform the
-- @lookoutvision:DescribeModel@ operation.
module Amazonka.LookoutVision.DescribeModel
  ( -- * Creating a Request
    DescribeModel (..),
    newDescribeModel,

    -- * Request Lenses
    describeModel_projectName,
    describeModel_modelVersion,

    -- * Destructuring the Response
    DescribeModelResponse (..),
    newDescribeModelResponse,

    -- * Response Lenses
    describeModelResponse_modelDescription,
    describeModelResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LookoutVision.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDescribeModel' smart constructor.
data DescribeModel = DescribeModel'
  { -- | The project that contains the version of a model that you want to
    -- describe.
    DescribeModel -> Text
projectName :: Prelude.Text,
    -- | The version of the model that you want to describe.
    DescribeModel -> Text
modelVersion :: Prelude.Text
  }
  deriving (DescribeModel -> DescribeModel -> Bool
(DescribeModel -> DescribeModel -> Bool)
-> (DescribeModel -> DescribeModel -> Bool) -> Eq DescribeModel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeModel -> DescribeModel -> Bool
$c/= :: DescribeModel -> DescribeModel -> Bool
== :: DescribeModel -> DescribeModel -> Bool
$c== :: DescribeModel -> DescribeModel -> Bool
Prelude.Eq, ReadPrec [DescribeModel]
ReadPrec DescribeModel
Int -> ReadS DescribeModel
ReadS [DescribeModel]
(Int -> ReadS DescribeModel)
-> ReadS [DescribeModel]
-> ReadPrec DescribeModel
-> ReadPrec [DescribeModel]
-> Read DescribeModel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeModel]
$creadListPrec :: ReadPrec [DescribeModel]
readPrec :: ReadPrec DescribeModel
$creadPrec :: ReadPrec DescribeModel
readList :: ReadS [DescribeModel]
$creadList :: ReadS [DescribeModel]
readsPrec :: Int -> ReadS DescribeModel
$creadsPrec :: Int -> ReadS DescribeModel
Prelude.Read, Int -> DescribeModel -> ShowS
[DescribeModel] -> ShowS
DescribeModel -> String
(Int -> DescribeModel -> ShowS)
-> (DescribeModel -> String)
-> ([DescribeModel] -> ShowS)
-> Show DescribeModel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeModel] -> ShowS
$cshowList :: [DescribeModel] -> ShowS
show :: DescribeModel -> String
$cshow :: DescribeModel -> String
showsPrec :: Int -> DescribeModel -> ShowS
$cshowsPrec :: Int -> DescribeModel -> ShowS
Prelude.Show, (forall x. DescribeModel -> Rep DescribeModel x)
-> (forall x. Rep DescribeModel x -> DescribeModel)
-> Generic DescribeModel
forall x. Rep DescribeModel x -> DescribeModel
forall x. DescribeModel -> Rep DescribeModel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeModel x -> DescribeModel
$cfrom :: forall x. DescribeModel -> Rep DescribeModel x
Prelude.Generic)

-- |
-- Create a value of 'DescribeModel' 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:
--
-- 'projectName', 'describeModel_projectName' - The project that contains the version of a model that you want to
-- describe.
--
-- 'modelVersion', 'describeModel_modelVersion' - The version of the model that you want to describe.
newDescribeModel ::
  -- | 'projectName'
  Prelude.Text ->
  -- | 'modelVersion'
  Prelude.Text ->
  DescribeModel
newDescribeModel :: Text -> Text -> DescribeModel
newDescribeModel Text
pProjectName_ Text
pModelVersion_ =
  DescribeModel' :: Text -> Text -> DescribeModel
DescribeModel'
    { $sel:projectName:DescribeModel' :: Text
projectName = Text
pProjectName_,
      $sel:modelVersion:DescribeModel' :: Text
modelVersion = Text
pModelVersion_
    }

-- | The project that contains the version of a model that you want to
-- describe.
describeModel_projectName :: Lens.Lens' DescribeModel Prelude.Text
describeModel_projectName :: (Text -> f Text) -> DescribeModel -> f DescribeModel
describeModel_projectName = (DescribeModel -> Text)
-> (DescribeModel -> Text -> DescribeModel)
-> Lens DescribeModel DescribeModel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeModel' {Text
projectName :: Text
$sel:projectName:DescribeModel' :: DescribeModel -> Text
projectName} -> Text
projectName) (\s :: DescribeModel
s@DescribeModel' {} Text
a -> DescribeModel
s {$sel:projectName:DescribeModel' :: Text
projectName = Text
a} :: DescribeModel)

-- | The version of the model that you want to describe.
describeModel_modelVersion :: Lens.Lens' DescribeModel Prelude.Text
describeModel_modelVersion :: (Text -> f Text) -> DescribeModel -> f DescribeModel
describeModel_modelVersion = (DescribeModel -> Text)
-> (DescribeModel -> Text -> DescribeModel)
-> Lens DescribeModel DescribeModel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeModel' {Text
modelVersion :: Text
$sel:modelVersion:DescribeModel' :: DescribeModel -> Text
modelVersion} -> Text
modelVersion) (\s :: DescribeModel
s@DescribeModel' {} Text
a -> DescribeModel
s {$sel:modelVersion:DescribeModel' :: Text
modelVersion = Text
a} :: DescribeModel)

instance Core.AWSRequest DescribeModel where
  type
    AWSResponse DescribeModel =
      DescribeModelResponse
  request :: DescribeModel -> Request DescribeModel
request = Service -> DescribeModel -> Request DescribeModel
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeModel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeModel)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeModel))
-> Logger
-> Service
-> Proxy DescribeModel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeModel)))
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 ModelDescription -> Int -> DescribeModelResponse
DescribeModelResponse'
            (Maybe ModelDescription -> Int -> DescribeModelResponse)
-> Either String (Maybe ModelDescription)
-> Either String (Int -> DescribeModelResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ModelDescription)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ModelDescription")
            Either String (Int -> DescribeModelResponse)
-> Either String Int -> Either String DescribeModelResponse
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 DescribeModel

instance Prelude.NFData DescribeModel

instance Core.ToHeaders DescribeModel where
  toHeaders :: DescribeModel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeModel -> 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 DescribeModel where
  toPath :: DescribeModel -> ByteString
toPath DescribeModel' {Text
modelVersion :: Text
projectName :: Text
$sel:modelVersion:DescribeModel' :: DescribeModel -> Text
$sel:projectName:DescribeModel' :: DescribeModel -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/2020-11-20/projects/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
projectName,
        ByteString
"/models/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
modelVersion
      ]

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

-- | /See:/ 'newDescribeModelResponse' smart constructor.
data DescribeModelResponse = DescribeModelResponse'
  { -- | Contains the description of the model.
    DescribeModelResponse -> Maybe ModelDescription
modelDescription :: Prelude.Maybe ModelDescription,
    -- | The response's http status code.
    DescribeModelResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeModelResponse -> DescribeModelResponse -> Bool
(DescribeModelResponse -> DescribeModelResponse -> Bool)
-> (DescribeModelResponse -> DescribeModelResponse -> Bool)
-> Eq DescribeModelResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeModelResponse -> DescribeModelResponse -> Bool
$c/= :: DescribeModelResponse -> DescribeModelResponse -> Bool
== :: DescribeModelResponse -> DescribeModelResponse -> Bool
$c== :: DescribeModelResponse -> DescribeModelResponse -> Bool
Prelude.Eq, ReadPrec [DescribeModelResponse]
ReadPrec DescribeModelResponse
Int -> ReadS DescribeModelResponse
ReadS [DescribeModelResponse]
(Int -> ReadS DescribeModelResponse)
-> ReadS [DescribeModelResponse]
-> ReadPrec DescribeModelResponse
-> ReadPrec [DescribeModelResponse]
-> Read DescribeModelResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeModelResponse]
$creadListPrec :: ReadPrec [DescribeModelResponse]
readPrec :: ReadPrec DescribeModelResponse
$creadPrec :: ReadPrec DescribeModelResponse
readList :: ReadS [DescribeModelResponse]
$creadList :: ReadS [DescribeModelResponse]
readsPrec :: Int -> ReadS DescribeModelResponse
$creadsPrec :: Int -> ReadS DescribeModelResponse
Prelude.Read, Int -> DescribeModelResponse -> ShowS
[DescribeModelResponse] -> ShowS
DescribeModelResponse -> String
(Int -> DescribeModelResponse -> ShowS)
-> (DescribeModelResponse -> String)
-> ([DescribeModelResponse] -> ShowS)
-> Show DescribeModelResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeModelResponse] -> ShowS
$cshowList :: [DescribeModelResponse] -> ShowS
show :: DescribeModelResponse -> String
$cshow :: DescribeModelResponse -> String
showsPrec :: Int -> DescribeModelResponse -> ShowS
$cshowsPrec :: Int -> DescribeModelResponse -> ShowS
Prelude.Show, (forall x. DescribeModelResponse -> Rep DescribeModelResponse x)
-> (forall x. Rep DescribeModelResponse x -> DescribeModelResponse)
-> Generic DescribeModelResponse
forall x. Rep DescribeModelResponse x -> DescribeModelResponse
forall x. DescribeModelResponse -> Rep DescribeModelResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeModelResponse x -> DescribeModelResponse
$cfrom :: forall x. DescribeModelResponse -> Rep DescribeModelResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeModelResponse' 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:
--
-- 'modelDescription', 'describeModelResponse_modelDescription' - Contains the description of the model.
--
-- 'httpStatus', 'describeModelResponse_httpStatus' - The response's http status code.
newDescribeModelResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeModelResponse
newDescribeModelResponse :: Int -> DescribeModelResponse
newDescribeModelResponse Int
pHttpStatus_ =
  DescribeModelResponse' :: Maybe ModelDescription -> Int -> DescribeModelResponse
DescribeModelResponse'
    { $sel:modelDescription:DescribeModelResponse' :: Maybe ModelDescription
modelDescription =
        Maybe ModelDescription
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeModelResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Contains the description of the model.
describeModelResponse_modelDescription :: Lens.Lens' DescribeModelResponse (Prelude.Maybe ModelDescription)
describeModelResponse_modelDescription :: (Maybe ModelDescription -> f (Maybe ModelDescription))
-> DescribeModelResponse -> f DescribeModelResponse
describeModelResponse_modelDescription = (DescribeModelResponse -> Maybe ModelDescription)
-> (DescribeModelResponse
    -> Maybe ModelDescription -> DescribeModelResponse)
-> Lens
     DescribeModelResponse
     DescribeModelResponse
     (Maybe ModelDescription)
     (Maybe ModelDescription)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeModelResponse' {Maybe ModelDescription
modelDescription :: Maybe ModelDescription
$sel:modelDescription:DescribeModelResponse' :: DescribeModelResponse -> Maybe ModelDescription
modelDescription} -> Maybe ModelDescription
modelDescription) (\s :: DescribeModelResponse
s@DescribeModelResponse' {} Maybe ModelDescription
a -> DescribeModelResponse
s {$sel:modelDescription:DescribeModelResponse' :: Maybe ModelDescription
modelDescription = Maybe ModelDescription
a} :: DescribeModelResponse)

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

instance Prelude.NFData DescribeModelResponse