{-# 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.Transcribe.DescribeLanguageModel
-- 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 information about a single custom language model. Use this
-- information to see details about the language model in your Amazon Web
-- Services account. You can also see whether the base language model used
-- to create your custom language model has been updated. If Amazon
-- Transcribe has updated the base model, you can create a new custom
-- language model using the updated base model. If the language model
-- wasn\'t created, you can use this operation to understand why Amazon
-- Transcribe couldn\'t create it.
module Amazonka.Transcribe.DescribeLanguageModel
  ( -- * Creating a Request
    DescribeLanguageModel (..),
    newDescribeLanguageModel,

    -- * Request Lenses
    describeLanguageModel_modelName,

    -- * Destructuring the Response
    DescribeLanguageModelResponse (..),
    newDescribeLanguageModelResponse,

    -- * Response Lenses
    describeLanguageModelResponse_languageModel,
    describeLanguageModelResponse_httpStatus,
  )
where

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
import Amazonka.Transcribe.Types

-- | /See:/ 'newDescribeLanguageModel' smart constructor.
data DescribeLanguageModel = DescribeLanguageModel'
  { -- | The name of the custom language model you submit to get more
    -- information.
    DescribeLanguageModel -> Text
modelName :: Prelude.Text
  }
  deriving (DescribeLanguageModel -> DescribeLanguageModel -> Bool
(DescribeLanguageModel -> DescribeLanguageModel -> Bool)
-> (DescribeLanguageModel -> DescribeLanguageModel -> Bool)
-> Eq DescribeLanguageModel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeLanguageModel -> DescribeLanguageModel -> Bool
$c/= :: DescribeLanguageModel -> DescribeLanguageModel -> Bool
== :: DescribeLanguageModel -> DescribeLanguageModel -> Bool
$c== :: DescribeLanguageModel -> DescribeLanguageModel -> Bool
Prelude.Eq, ReadPrec [DescribeLanguageModel]
ReadPrec DescribeLanguageModel
Int -> ReadS DescribeLanguageModel
ReadS [DescribeLanguageModel]
(Int -> ReadS DescribeLanguageModel)
-> ReadS [DescribeLanguageModel]
-> ReadPrec DescribeLanguageModel
-> ReadPrec [DescribeLanguageModel]
-> Read DescribeLanguageModel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeLanguageModel]
$creadListPrec :: ReadPrec [DescribeLanguageModel]
readPrec :: ReadPrec DescribeLanguageModel
$creadPrec :: ReadPrec DescribeLanguageModel
readList :: ReadS [DescribeLanguageModel]
$creadList :: ReadS [DescribeLanguageModel]
readsPrec :: Int -> ReadS DescribeLanguageModel
$creadsPrec :: Int -> ReadS DescribeLanguageModel
Prelude.Read, Int -> DescribeLanguageModel -> ShowS
[DescribeLanguageModel] -> ShowS
DescribeLanguageModel -> String
(Int -> DescribeLanguageModel -> ShowS)
-> (DescribeLanguageModel -> String)
-> ([DescribeLanguageModel] -> ShowS)
-> Show DescribeLanguageModel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeLanguageModel] -> ShowS
$cshowList :: [DescribeLanguageModel] -> ShowS
show :: DescribeLanguageModel -> String
$cshow :: DescribeLanguageModel -> String
showsPrec :: Int -> DescribeLanguageModel -> ShowS
$cshowsPrec :: Int -> DescribeLanguageModel -> ShowS
Prelude.Show, (forall x. DescribeLanguageModel -> Rep DescribeLanguageModel x)
-> (forall x. Rep DescribeLanguageModel x -> DescribeLanguageModel)
-> Generic DescribeLanguageModel
forall x. Rep DescribeLanguageModel x -> DescribeLanguageModel
forall x. DescribeLanguageModel -> Rep DescribeLanguageModel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeLanguageModel x -> DescribeLanguageModel
$cfrom :: forall x. DescribeLanguageModel -> Rep DescribeLanguageModel x
Prelude.Generic)

-- |
-- Create a value of 'DescribeLanguageModel' 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:
--
-- 'modelName', 'describeLanguageModel_modelName' - The name of the custom language model you submit to get more
-- information.
newDescribeLanguageModel ::
  -- | 'modelName'
  Prelude.Text ->
  DescribeLanguageModel
newDescribeLanguageModel :: Text -> DescribeLanguageModel
newDescribeLanguageModel Text
pModelName_ =
  DescribeLanguageModel' :: Text -> DescribeLanguageModel
DescribeLanguageModel' {$sel:modelName:DescribeLanguageModel' :: Text
modelName = Text
pModelName_}

-- | The name of the custom language model you submit to get more
-- information.
describeLanguageModel_modelName :: Lens.Lens' DescribeLanguageModel Prelude.Text
describeLanguageModel_modelName :: (Text -> f Text)
-> DescribeLanguageModel -> f DescribeLanguageModel
describeLanguageModel_modelName = (DescribeLanguageModel -> Text)
-> (DescribeLanguageModel -> Text -> DescribeLanguageModel)
-> Lens DescribeLanguageModel DescribeLanguageModel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLanguageModel' {Text
modelName :: Text
$sel:modelName:DescribeLanguageModel' :: DescribeLanguageModel -> Text
modelName} -> Text
modelName) (\s :: DescribeLanguageModel
s@DescribeLanguageModel' {} Text
a -> DescribeLanguageModel
s {$sel:modelName:DescribeLanguageModel' :: Text
modelName = Text
a} :: DescribeLanguageModel)

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

instance Prelude.NFData DescribeLanguageModel

instance Core.ToHeaders DescribeLanguageModel where
  toHeaders :: DescribeLanguageModel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeLanguageModel -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Transcribe.DescribeLanguageModel" ::
                          Prelude.ByteString
                      ),
            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.ToJSON DescribeLanguageModel where
  toJSON :: DescribeLanguageModel -> Value
toJSON DescribeLanguageModel' {Text
modelName :: Text
$sel:modelName:DescribeLanguageModel' :: DescribeLanguageModel -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ModelName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
modelName)]
      )

instance Core.ToPath DescribeLanguageModel where
  toPath :: DescribeLanguageModel -> ByteString
toPath = ByteString -> DescribeLanguageModel -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newDescribeLanguageModelResponse' smart constructor.
data DescribeLanguageModelResponse = DescribeLanguageModelResponse'
  { -- | The name of the custom language model you requested more information
    -- about.
    DescribeLanguageModelResponse -> Maybe LanguageModel
languageModel :: Prelude.Maybe LanguageModel,
    -- | The response's http status code.
    DescribeLanguageModelResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeLanguageModelResponse
-> DescribeLanguageModelResponse -> Bool
(DescribeLanguageModelResponse
 -> DescribeLanguageModelResponse -> Bool)
-> (DescribeLanguageModelResponse
    -> DescribeLanguageModelResponse -> Bool)
-> Eq DescribeLanguageModelResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeLanguageModelResponse
-> DescribeLanguageModelResponse -> Bool
$c/= :: DescribeLanguageModelResponse
-> DescribeLanguageModelResponse -> Bool
== :: DescribeLanguageModelResponse
-> DescribeLanguageModelResponse -> Bool
$c== :: DescribeLanguageModelResponse
-> DescribeLanguageModelResponse -> Bool
Prelude.Eq, ReadPrec [DescribeLanguageModelResponse]
ReadPrec DescribeLanguageModelResponse
Int -> ReadS DescribeLanguageModelResponse
ReadS [DescribeLanguageModelResponse]
(Int -> ReadS DescribeLanguageModelResponse)
-> ReadS [DescribeLanguageModelResponse]
-> ReadPrec DescribeLanguageModelResponse
-> ReadPrec [DescribeLanguageModelResponse]
-> Read DescribeLanguageModelResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeLanguageModelResponse]
$creadListPrec :: ReadPrec [DescribeLanguageModelResponse]
readPrec :: ReadPrec DescribeLanguageModelResponse
$creadPrec :: ReadPrec DescribeLanguageModelResponse
readList :: ReadS [DescribeLanguageModelResponse]
$creadList :: ReadS [DescribeLanguageModelResponse]
readsPrec :: Int -> ReadS DescribeLanguageModelResponse
$creadsPrec :: Int -> ReadS DescribeLanguageModelResponse
Prelude.Read, Int -> DescribeLanguageModelResponse -> ShowS
[DescribeLanguageModelResponse] -> ShowS
DescribeLanguageModelResponse -> String
(Int -> DescribeLanguageModelResponse -> ShowS)
-> (DescribeLanguageModelResponse -> String)
-> ([DescribeLanguageModelResponse] -> ShowS)
-> Show DescribeLanguageModelResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeLanguageModelResponse] -> ShowS
$cshowList :: [DescribeLanguageModelResponse] -> ShowS
show :: DescribeLanguageModelResponse -> String
$cshow :: DescribeLanguageModelResponse -> String
showsPrec :: Int -> DescribeLanguageModelResponse -> ShowS
$cshowsPrec :: Int -> DescribeLanguageModelResponse -> ShowS
Prelude.Show, (forall x.
 DescribeLanguageModelResponse
 -> Rep DescribeLanguageModelResponse x)
-> (forall x.
    Rep DescribeLanguageModelResponse x
    -> DescribeLanguageModelResponse)
-> Generic DescribeLanguageModelResponse
forall x.
Rep DescribeLanguageModelResponse x
-> DescribeLanguageModelResponse
forall x.
DescribeLanguageModelResponse
-> Rep DescribeLanguageModelResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeLanguageModelResponse x
-> DescribeLanguageModelResponse
$cfrom :: forall x.
DescribeLanguageModelResponse
-> Rep DescribeLanguageModelResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeLanguageModelResponse' 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:
--
-- 'languageModel', 'describeLanguageModelResponse_languageModel' - The name of the custom language model you requested more information
-- about.
--
-- 'httpStatus', 'describeLanguageModelResponse_httpStatus' - The response's http status code.
newDescribeLanguageModelResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeLanguageModelResponse
newDescribeLanguageModelResponse :: Int -> DescribeLanguageModelResponse
newDescribeLanguageModelResponse Int
pHttpStatus_ =
  DescribeLanguageModelResponse' :: Maybe LanguageModel -> Int -> DescribeLanguageModelResponse
DescribeLanguageModelResponse'
    { $sel:languageModel:DescribeLanguageModelResponse' :: Maybe LanguageModel
languageModel =
        Maybe LanguageModel
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeLanguageModelResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The name of the custom language model you requested more information
-- about.
describeLanguageModelResponse_languageModel :: Lens.Lens' DescribeLanguageModelResponse (Prelude.Maybe LanguageModel)
describeLanguageModelResponse_languageModel :: (Maybe LanguageModel -> f (Maybe LanguageModel))
-> DescribeLanguageModelResponse -> f DescribeLanguageModelResponse
describeLanguageModelResponse_languageModel = (DescribeLanguageModelResponse -> Maybe LanguageModel)
-> (DescribeLanguageModelResponse
    -> Maybe LanguageModel -> DescribeLanguageModelResponse)
-> Lens
     DescribeLanguageModelResponse
     DescribeLanguageModelResponse
     (Maybe LanguageModel)
     (Maybe LanguageModel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeLanguageModelResponse' {Maybe LanguageModel
languageModel :: Maybe LanguageModel
$sel:languageModel:DescribeLanguageModelResponse' :: DescribeLanguageModelResponse -> Maybe LanguageModel
languageModel} -> Maybe LanguageModel
languageModel) (\s :: DescribeLanguageModelResponse
s@DescribeLanguageModelResponse' {} Maybe LanguageModel
a -> DescribeLanguageModelResponse
s {$sel:languageModel:DescribeLanguageModelResponse' :: Maybe LanguageModel
languageModel = Maybe LanguageModel
a} :: DescribeLanguageModelResponse)

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

instance Prelude.NFData DescribeLanguageModelResponse