{-# 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.CreateVocabulary
-- 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)
--
-- Creates a new custom vocabulary that you can use to change the way
-- Amazon Transcribe handles transcription of an audio file.
module Amazonka.Transcribe.CreateVocabulary
  ( -- * Creating a Request
    CreateVocabulary (..),
    newCreateVocabulary,

    -- * Request Lenses
    createVocabulary_vocabularyFileUri,
    createVocabulary_phrases,
    createVocabulary_tags,
    createVocabulary_vocabularyName,
    createVocabulary_languageCode,

    -- * Destructuring the Response
    CreateVocabularyResponse (..),
    newCreateVocabularyResponse,

    -- * Response Lenses
    createVocabularyResponse_failureReason,
    createVocabularyResponse_languageCode,
    createVocabularyResponse_vocabularyName,
    createVocabularyResponse_lastModifiedTime,
    createVocabularyResponse_vocabularyState,
    createVocabularyResponse_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:/ 'newCreateVocabulary' smart constructor.
data CreateVocabulary = CreateVocabulary'
  { -- | The S3 location of the text file that contains the definition of the
    -- custom vocabulary. The URI must be in the same region as the API
    -- endpoint that you are calling. The general form is:
    --
    -- For more information about S3 object names, see
    -- <https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#object-keys Object Keys>
    -- in the /Amazon S3 Developer Guide/.
    --
    -- For more information about custom vocabularies, see
    -- <https://docs.aws.amazon.com/transcribe/latest/dg/how-vocabulary Custom vocabularies>.
    CreateVocabulary -> Maybe Text
vocabularyFileUri :: Prelude.Maybe Prelude.Text,
    -- | An array of strings that contains the vocabulary entries.
    CreateVocabulary -> Maybe [Text]
phrases :: Prelude.Maybe [Prelude.Text],
    -- | Adds one or more tags, each in the form of a key:value pair, to a new
    -- Amazon Transcribe vocabulary at the time you create this new vocabulary.
    CreateVocabulary -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag),
    -- | The name of the vocabulary. The name must be unique within an Amazon Web
    -- Services account. The name is case sensitive. If you try to create a
    -- vocabulary with the same name as a previous vocabulary you will receive
    -- a @ConflictException@ error.
    CreateVocabulary -> Text
vocabularyName :: Prelude.Text,
    -- | The language code of the vocabulary entries. For a list of languages and
    -- their corresponding language codes, see transcribe-whatis.
    CreateVocabulary -> LanguageCode
languageCode :: LanguageCode
  }
  deriving (CreateVocabulary -> CreateVocabulary -> Bool
(CreateVocabulary -> CreateVocabulary -> Bool)
-> (CreateVocabulary -> CreateVocabulary -> Bool)
-> Eq CreateVocabulary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateVocabulary -> CreateVocabulary -> Bool
$c/= :: CreateVocabulary -> CreateVocabulary -> Bool
== :: CreateVocabulary -> CreateVocabulary -> Bool
$c== :: CreateVocabulary -> CreateVocabulary -> Bool
Prelude.Eq, ReadPrec [CreateVocabulary]
ReadPrec CreateVocabulary
Int -> ReadS CreateVocabulary
ReadS [CreateVocabulary]
(Int -> ReadS CreateVocabulary)
-> ReadS [CreateVocabulary]
-> ReadPrec CreateVocabulary
-> ReadPrec [CreateVocabulary]
-> Read CreateVocabulary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateVocabulary]
$creadListPrec :: ReadPrec [CreateVocabulary]
readPrec :: ReadPrec CreateVocabulary
$creadPrec :: ReadPrec CreateVocabulary
readList :: ReadS [CreateVocabulary]
$creadList :: ReadS [CreateVocabulary]
readsPrec :: Int -> ReadS CreateVocabulary
$creadsPrec :: Int -> ReadS CreateVocabulary
Prelude.Read, Int -> CreateVocabulary -> ShowS
[CreateVocabulary] -> ShowS
CreateVocabulary -> String
(Int -> CreateVocabulary -> ShowS)
-> (CreateVocabulary -> String)
-> ([CreateVocabulary] -> ShowS)
-> Show CreateVocabulary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateVocabulary] -> ShowS
$cshowList :: [CreateVocabulary] -> ShowS
show :: CreateVocabulary -> String
$cshow :: CreateVocabulary -> String
showsPrec :: Int -> CreateVocabulary -> ShowS
$cshowsPrec :: Int -> CreateVocabulary -> ShowS
Prelude.Show, (forall x. CreateVocabulary -> Rep CreateVocabulary x)
-> (forall x. Rep CreateVocabulary x -> CreateVocabulary)
-> Generic CreateVocabulary
forall x. Rep CreateVocabulary x -> CreateVocabulary
forall x. CreateVocabulary -> Rep CreateVocabulary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateVocabulary x -> CreateVocabulary
$cfrom :: forall x. CreateVocabulary -> Rep CreateVocabulary x
Prelude.Generic)

-- |
-- Create a value of 'CreateVocabulary' 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:
--
-- 'vocabularyFileUri', 'createVocabulary_vocabularyFileUri' - The S3 location of the text file that contains the definition of the
-- custom vocabulary. The URI must be in the same region as the API
-- endpoint that you are calling. The general form is:
--
-- For more information about S3 object names, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#object-keys Object Keys>
-- in the /Amazon S3 Developer Guide/.
--
-- For more information about custom vocabularies, see
-- <https://docs.aws.amazon.com/transcribe/latest/dg/how-vocabulary Custom vocabularies>.
--
-- 'phrases', 'createVocabulary_phrases' - An array of strings that contains the vocabulary entries.
--
-- 'tags', 'createVocabulary_tags' - Adds one or more tags, each in the form of a key:value pair, to a new
-- Amazon Transcribe vocabulary at the time you create this new vocabulary.
--
-- 'vocabularyName', 'createVocabulary_vocabularyName' - The name of the vocabulary. The name must be unique within an Amazon Web
-- Services account. The name is case sensitive. If you try to create a
-- vocabulary with the same name as a previous vocabulary you will receive
-- a @ConflictException@ error.
--
-- 'languageCode', 'createVocabulary_languageCode' - The language code of the vocabulary entries. For a list of languages and
-- their corresponding language codes, see transcribe-whatis.
newCreateVocabulary ::
  -- | 'vocabularyName'
  Prelude.Text ->
  -- | 'languageCode'
  LanguageCode ->
  CreateVocabulary
newCreateVocabulary :: Text -> LanguageCode -> CreateVocabulary
newCreateVocabulary Text
pVocabularyName_ LanguageCode
pLanguageCode_ =
  CreateVocabulary' :: Maybe Text
-> Maybe [Text]
-> Maybe (NonEmpty Tag)
-> Text
-> LanguageCode
-> CreateVocabulary
CreateVocabulary'
    { $sel:vocabularyFileUri:CreateVocabulary' :: Maybe Text
vocabularyFileUri =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:phrases:CreateVocabulary' :: Maybe [Text]
phrases = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateVocabulary' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
forall a. Maybe a
Prelude.Nothing,
      $sel:vocabularyName:CreateVocabulary' :: Text
vocabularyName = Text
pVocabularyName_,
      $sel:languageCode:CreateVocabulary' :: LanguageCode
languageCode = LanguageCode
pLanguageCode_
    }

-- | The S3 location of the text file that contains the definition of the
-- custom vocabulary. The URI must be in the same region as the API
-- endpoint that you are calling. The general form is:
--
-- For more information about S3 object names, see
-- <https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html#object-keys Object Keys>
-- in the /Amazon S3 Developer Guide/.
--
-- For more information about custom vocabularies, see
-- <https://docs.aws.amazon.com/transcribe/latest/dg/how-vocabulary Custom vocabularies>.
createVocabulary_vocabularyFileUri :: Lens.Lens' CreateVocabulary (Prelude.Maybe Prelude.Text)
createVocabulary_vocabularyFileUri :: (Maybe Text -> f (Maybe Text))
-> CreateVocabulary -> f CreateVocabulary
createVocabulary_vocabularyFileUri = (CreateVocabulary -> Maybe Text)
-> (CreateVocabulary -> Maybe Text -> CreateVocabulary)
-> Lens CreateVocabulary CreateVocabulary (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVocabulary' {Maybe Text
vocabularyFileUri :: Maybe Text
$sel:vocabularyFileUri:CreateVocabulary' :: CreateVocabulary -> Maybe Text
vocabularyFileUri} -> Maybe Text
vocabularyFileUri) (\s :: CreateVocabulary
s@CreateVocabulary' {} Maybe Text
a -> CreateVocabulary
s {$sel:vocabularyFileUri:CreateVocabulary' :: Maybe Text
vocabularyFileUri = Maybe Text
a} :: CreateVocabulary)

-- | An array of strings that contains the vocabulary entries.
createVocabulary_phrases :: Lens.Lens' CreateVocabulary (Prelude.Maybe [Prelude.Text])
createVocabulary_phrases :: (Maybe [Text] -> f (Maybe [Text]))
-> CreateVocabulary -> f CreateVocabulary
createVocabulary_phrases = (CreateVocabulary -> Maybe [Text])
-> (CreateVocabulary -> Maybe [Text] -> CreateVocabulary)
-> Lens
     CreateVocabulary CreateVocabulary (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVocabulary' {Maybe [Text]
phrases :: Maybe [Text]
$sel:phrases:CreateVocabulary' :: CreateVocabulary -> Maybe [Text]
phrases} -> Maybe [Text]
phrases) (\s :: CreateVocabulary
s@CreateVocabulary' {} Maybe [Text]
a -> CreateVocabulary
s {$sel:phrases:CreateVocabulary' :: Maybe [Text]
phrases = Maybe [Text]
a} :: CreateVocabulary) ((Maybe [Text] -> f (Maybe [Text]))
 -> CreateVocabulary -> f CreateVocabulary)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateVocabulary
-> f CreateVocabulary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Adds one or more tags, each in the form of a key:value pair, to a new
-- Amazon Transcribe vocabulary at the time you create this new vocabulary.
createVocabulary_tags :: Lens.Lens' CreateVocabulary (Prelude.Maybe (Prelude.NonEmpty Tag))
createVocabulary_tags :: (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateVocabulary -> f CreateVocabulary
createVocabulary_tags = (CreateVocabulary -> Maybe (NonEmpty Tag))
-> (CreateVocabulary -> Maybe (NonEmpty Tag) -> CreateVocabulary)
-> Lens
     CreateVocabulary
     CreateVocabulary
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVocabulary' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:CreateVocabulary' :: CreateVocabulary -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: CreateVocabulary
s@CreateVocabulary' {} Maybe (NonEmpty Tag)
a -> CreateVocabulary
s {$sel:tags:CreateVocabulary' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: CreateVocabulary) ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
 -> CreateVocabulary -> f CreateVocabulary)
-> ((Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
    -> Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> (Maybe (NonEmpty Tag) -> f (Maybe (NonEmpty Tag)))
-> CreateVocabulary
-> f CreateVocabulary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
-> Iso
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
     (Maybe (NonEmpty Tag))
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 (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag) (NonEmpty Tag)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the vocabulary. The name must be unique within an Amazon Web
-- Services account. The name is case sensitive. If you try to create a
-- vocabulary with the same name as a previous vocabulary you will receive
-- a @ConflictException@ error.
createVocabulary_vocabularyName :: Lens.Lens' CreateVocabulary Prelude.Text
createVocabulary_vocabularyName :: (Text -> f Text) -> CreateVocabulary -> f CreateVocabulary
createVocabulary_vocabularyName = (CreateVocabulary -> Text)
-> (CreateVocabulary -> Text -> CreateVocabulary)
-> Lens CreateVocabulary CreateVocabulary Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVocabulary' {Text
vocabularyName :: Text
$sel:vocabularyName:CreateVocabulary' :: CreateVocabulary -> Text
vocabularyName} -> Text
vocabularyName) (\s :: CreateVocabulary
s@CreateVocabulary' {} Text
a -> CreateVocabulary
s {$sel:vocabularyName:CreateVocabulary' :: Text
vocabularyName = Text
a} :: CreateVocabulary)

-- | The language code of the vocabulary entries. For a list of languages and
-- their corresponding language codes, see transcribe-whatis.
createVocabulary_languageCode :: Lens.Lens' CreateVocabulary LanguageCode
createVocabulary_languageCode :: (LanguageCode -> f LanguageCode)
-> CreateVocabulary -> f CreateVocabulary
createVocabulary_languageCode = (CreateVocabulary -> LanguageCode)
-> (CreateVocabulary -> LanguageCode -> CreateVocabulary)
-> Lens CreateVocabulary CreateVocabulary LanguageCode LanguageCode
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVocabulary' {LanguageCode
languageCode :: LanguageCode
$sel:languageCode:CreateVocabulary' :: CreateVocabulary -> LanguageCode
languageCode} -> LanguageCode
languageCode) (\s :: CreateVocabulary
s@CreateVocabulary' {} LanguageCode
a -> CreateVocabulary
s {$sel:languageCode:CreateVocabulary' :: LanguageCode
languageCode = LanguageCode
a} :: CreateVocabulary)

instance Core.AWSRequest CreateVocabulary where
  type
    AWSResponse CreateVocabulary =
      CreateVocabularyResponse
  request :: CreateVocabulary -> Request CreateVocabulary
request = Service -> CreateVocabulary -> Request CreateVocabulary
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateVocabulary
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateVocabulary)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateVocabulary))
-> Logger
-> Service
-> Proxy CreateVocabulary
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateVocabulary)))
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 LanguageCode
-> Maybe Text
-> Maybe POSIX
-> Maybe VocabularyState
-> Int
-> CreateVocabularyResponse
CreateVocabularyResponse'
            (Maybe Text
 -> Maybe LanguageCode
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe VocabularyState
 -> Int
 -> CreateVocabularyResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe LanguageCode
      -> Maybe Text
      -> Maybe POSIX
      -> Maybe VocabularyState
      -> Int
      -> CreateVocabularyResponse)
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
"FailureReason")
            Either
  String
  (Maybe LanguageCode
   -> Maybe Text
   -> Maybe POSIX
   -> Maybe VocabularyState
   -> Int
   -> CreateVocabularyResponse)
-> Either String (Maybe LanguageCode)
-> Either
     String
     (Maybe Text
      -> Maybe POSIX
      -> Maybe VocabularyState
      -> Int
      -> CreateVocabularyResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe LanguageCode)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"LanguageCode")
            Either
  String
  (Maybe Text
   -> Maybe POSIX
   -> Maybe VocabularyState
   -> Int
   -> CreateVocabularyResponse)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe POSIX
      -> Maybe VocabularyState -> Int -> CreateVocabularyResponse)
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
"VocabularyName")
            Either
  String
  (Maybe POSIX
   -> Maybe VocabularyState -> Int -> CreateVocabularyResponse)
-> Either String (Maybe POSIX)
-> Either
     String (Maybe VocabularyState -> Int -> CreateVocabularyResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"LastModifiedTime")
            Either
  String (Maybe VocabularyState -> Int -> CreateVocabularyResponse)
-> Either String (Maybe VocabularyState)
-> Either String (Int -> CreateVocabularyResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe VocabularyState)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"VocabularyState")
            Either String (Int -> CreateVocabularyResponse)
-> Either String Int -> Either String CreateVocabularyResponse
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 CreateVocabulary

instance Prelude.NFData CreateVocabulary

instance Core.ToHeaders CreateVocabulary where
  toHeaders :: CreateVocabulary -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateVocabulary -> 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.CreateVocabulary" ::
                          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 CreateVocabulary where
  toJSON :: CreateVocabulary -> Value
toJSON CreateVocabulary' {Maybe [Text]
Maybe (NonEmpty Tag)
Maybe Text
Text
LanguageCode
languageCode :: LanguageCode
vocabularyName :: Text
tags :: Maybe (NonEmpty Tag)
phrases :: Maybe [Text]
vocabularyFileUri :: Maybe Text
$sel:languageCode:CreateVocabulary' :: CreateVocabulary -> LanguageCode
$sel:vocabularyName:CreateVocabulary' :: CreateVocabulary -> Text
$sel:tags:CreateVocabulary' :: CreateVocabulary -> Maybe (NonEmpty Tag)
$sel:phrases:CreateVocabulary' :: CreateVocabulary -> Maybe [Text]
$sel:vocabularyFileUri:CreateVocabulary' :: CreateVocabulary -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"VocabularyFileUri" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
vocabularyFileUri,
            (Text
"Phrases" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
phrases,
            (Text
"Tags" Text -> NonEmpty Tag -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Tag -> Pair) -> Maybe (NonEmpty Tag) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Tag)
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"VocabularyName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
vocabularyName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"LanguageCode" Text -> LanguageCode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= LanguageCode
languageCode)
          ]
      )

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

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

-- | /See:/ 'newCreateVocabularyResponse' smart constructor.
data CreateVocabularyResponse = CreateVocabularyResponse'
  { -- | If the @VocabularyState@ field is @FAILED@, this field contains
    -- information about why the job failed.
    CreateVocabularyResponse -> Maybe Text
failureReason :: Prelude.Maybe Prelude.Text,
    -- | The language code of the vocabulary entries.
    CreateVocabularyResponse -> Maybe LanguageCode
languageCode :: Prelude.Maybe LanguageCode,
    -- | The name of the vocabulary.
    CreateVocabularyResponse -> Maybe Text
vocabularyName :: Prelude.Maybe Prelude.Text,
    -- | The date and time that the vocabulary was created.
    CreateVocabularyResponse -> Maybe POSIX
lastModifiedTime :: Prelude.Maybe Core.POSIX,
    -- | The processing state of the vocabulary. When the @VocabularyState@ field
    -- contains @READY@ the vocabulary is ready to be used in a
    -- @StartTranscriptionJob@ request.
    CreateVocabularyResponse -> Maybe VocabularyState
vocabularyState :: Prelude.Maybe VocabularyState,
    -- | The response's http status code.
    CreateVocabularyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateVocabularyResponse -> CreateVocabularyResponse -> Bool
(CreateVocabularyResponse -> CreateVocabularyResponse -> Bool)
-> (CreateVocabularyResponse -> CreateVocabularyResponse -> Bool)
-> Eq CreateVocabularyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateVocabularyResponse -> CreateVocabularyResponse -> Bool
$c/= :: CreateVocabularyResponse -> CreateVocabularyResponse -> Bool
== :: CreateVocabularyResponse -> CreateVocabularyResponse -> Bool
$c== :: CreateVocabularyResponse -> CreateVocabularyResponse -> Bool
Prelude.Eq, ReadPrec [CreateVocabularyResponse]
ReadPrec CreateVocabularyResponse
Int -> ReadS CreateVocabularyResponse
ReadS [CreateVocabularyResponse]
(Int -> ReadS CreateVocabularyResponse)
-> ReadS [CreateVocabularyResponse]
-> ReadPrec CreateVocabularyResponse
-> ReadPrec [CreateVocabularyResponse]
-> Read CreateVocabularyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateVocabularyResponse]
$creadListPrec :: ReadPrec [CreateVocabularyResponse]
readPrec :: ReadPrec CreateVocabularyResponse
$creadPrec :: ReadPrec CreateVocabularyResponse
readList :: ReadS [CreateVocabularyResponse]
$creadList :: ReadS [CreateVocabularyResponse]
readsPrec :: Int -> ReadS CreateVocabularyResponse
$creadsPrec :: Int -> ReadS CreateVocabularyResponse
Prelude.Read, Int -> CreateVocabularyResponse -> ShowS
[CreateVocabularyResponse] -> ShowS
CreateVocabularyResponse -> String
(Int -> CreateVocabularyResponse -> ShowS)
-> (CreateVocabularyResponse -> String)
-> ([CreateVocabularyResponse] -> ShowS)
-> Show CreateVocabularyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateVocabularyResponse] -> ShowS
$cshowList :: [CreateVocabularyResponse] -> ShowS
show :: CreateVocabularyResponse -> String
$cshow :: CreateVocabularyResponse -> String
showsPrec :: Int -> CreateVocabularyResponse -> ShowS
$cshowsPrec :: Int -> CreateVocabularyResponse -> ShowS
Prelude.Show, (forall x.
 CreateVocabularyResponse -> Rep CreateVocabularyResponse x)
-> (forall x.
    Rep CreateVocabularyResponse x -> CreateVocabularyResponse)
-> Generic CreateVocabularyResponse
forall x.
Rep CreateVocabularyResponse x -> CreateVocabularyResponse
forall x.
CreateVocabularyResponse -> Rep CreateVocabularyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateVocabularyResponse x -> CreateVocabularyResponse
$cfrom :: forall x.
CreateVocabularyResponse -> Rep CreateVocabularyResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateVocabularyResponse' 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:
--
-- 'failureReason', 'createVocabularyResponse_failureReason' - If the @VocabularyState@ field is @FAILED@, this field contains
-- information about why the job failed.
--
-- 'languageCode', 'createVocabularyResponse_languageCode' - The language code of the vocabulary entries.
--
-- 'vocabularyName', 'createVocabularyResponse_vocabularyName' - The name of the vocabulary.
--
-- 'lastModifiedTime', 'createVocabularyResponse_lastModifiedTime' - The date and time that the vocabulary was created.
--
-- 'vocabularyState', 'createVocabularyResponse_vocabularyState' - The processing state of the vocabulary. When the @VocabularyState@ field
-- contains @READY@ the vocabulary is ready to be used in a
-- @StartTranscriptionJob@ request.
--
-- 'httpStatus', 'createVocabularyResponse_httpStatus' - The response's http status code.
newCreateVocabularyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateVocabularyResponse
newCreateVocabularyResponse :: Int -> CreateVocabularyResponse
newCreateVocabularyResponse Int
pHttpStatus_ =
  CreateVocabularyResponse' :: Maybe Text
-> Maybe LanguageCode
-> Maybe Text
-> Maybe POSIX
-> Maybe VocabularyState
-> Int
-> CreateVocabularyResponse
CreateVocabularyResponse'
    { $sel:failureReason:CreateVocabularyResponse' :: Maybe Text
failureReason =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:languageCode:CreateVocabularyResponse' :: Maybe LanguageCode
languageCode = Maybe LanguageCode
forall a. Maybe a
Prelude.Nothing,
      $sel:vocabularyName:CreateVocabularyResponse' :: Maybe Text
vocabularyName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:lastModifiedTime:CreateVocabularyResponse' :: Maybe POSIX
lastModifiedTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:vocabularyState:CreateVocabularyResponse' :: Maybe VocabularyState
vocabularyState = Maybe VocabularyState
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateVocabularyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | If the @VocabularyState@ field is @FAILED@, this field contains
-- information about why the job failed.
createVocabularyResponse_failureReason :: Lens.Lens' CreateVocabularyResponse (Prelude.Maybe Prelude.Text)
createVocabularyResponse_failureReason :: (Maybe Text -> f (Maybe Text))
-> CreateVocabularyResponse -> f CreateVocabularyResponse
createVocabularyResponse_failureReason = (CreateVocabularyResponse -> Maybe Text)
-> (CreateVocabularyResponse
    -> Maybe Text -> CreateVocabularyResponse)
-> Lens
     CreateVocabularyResponse
     CreateVocabularyResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVocabularyResponse' {Maybe Text
failureReason :: Maybe Text
$sel:failureReason:CreateVocabularyResponse' :: CreateVocabularyResponse -> Maybe Text
failureReason} -> Maybe Text
failureReason) (\s :: CreateVocabularyResponse
s@CreateVocabularyResponse' {} Maybe Text
a -> CreateVocabularyResponse
s {$sel:failureReason:CreateVocabularyResponse' :: Maybe Text
failureReason = Maybe Text
a} :: CreateVocabularyResponse)

-- | The language code of the vocabulary entries.
createVocabularyResponse_languageCode :: Lens.Lens' CreateVocabularyResponse (Prelude.Maybe LanguageCode)
createVocabularyResponse_languageCode :: (Maybe LanguageCode -> f (Maybe LanguageCode))
-> CreateVocabularyResponse -> f CreateVocabularyResponse
createVocabularyResponse_languageCode = (CreateVocabularyResponse -> Maybe LanguageCode)
-> (CreateVocabularyResponse
    -> Maybe LanguageCode -> CreateVocabularyResponse)
-> Lens
     CreateVocabularyResponse
     CreateVocabularyResponse
     (Maybe LanguageCode)
     (Maybe LanguageCode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVocabularyResponse' {Maybe LanguageCode
languageCode :: Maybe LanguageCode
$sel:languageCode:CreateVocabularyResponse' :: CreateVocabularyResponse -> Maybe LanguageCode
languageCode} -> Maybe LanguageCode
languageCode) (\s :: CreateVocabularyResponse
s@CreateVocabularyResponse' {} Maybe LanguageCode
a -> CreateVocabularyResponse
s {$sel:languageCode:CreateVocabularyResponse' :: Maybe LanguageCode
languageCode = Maybe LanguageCode
a} :: CreateVocabularyResponse)

-- | The name of the vocabulary.
createVocabularyResponse_vocabularyName :: Lens.Lens' CreateVocabularyResponse (Prelude.Maybe Prelude.Text)
createVocabularyResponse_vocabularyName :: (Maybe Text -> f (Maybe Text))
-> CreateVocabularyResponse -> f CreateVocabularyResponse
createVocabularyResponse_vocabularyName = (CreateVocabularyResponse -> Maybe Text)
-> (CreateVocabularyResponse
    -> Maybe Text -> CreateVocabularyResponse)
-> Lens
     CreateVocabularyResponse
     CreateVocabularyResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVocabularyResponse' {Maybe Text
vocabularyName :: Maybe Text
$sel:vocabularyName:CreateVocabularyResponse' :: CreateVocabularyResponse -> Maybe Text
vocabularyName} -> Maybe Text
vocabularyName) (\s :: CreateVocabularyResponse
s@CreateVocabularyResponse' {} Maybe Text
a -> CreateVocabularyResponse
s {$sel:vocabularyName:CreateVocabularyResponse' :: Maybe Text
vocabularyName = Maybe Text
a} :: CreateVocabularyResponse)

-- | The date and time that the vocabulary was created.
createVocabularyResponse_lastModifiedTime :: Lens.Lens' CreateVocabularyResponse (Prelude.Maybe Prelude.UTCTime)
createVocabularyResponse_lastModifiedTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> CreateVocabularyResponse -> f CreateVocabularyResponse
createVocabularyResponse_lastModifiedTime = (CreateVocabularyResponse -> Maybe POSIX)
-> (CreateVocabularyResponse
    -> Maybe POSIX -> CreateVocabularyResponse)
-> Lens
     CreateVocabularyResponse
     CreateVocabularyResponse
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVocabularyResponse' {Maybe POSIX
lastModifiedTime :: Maybe POSIX
$sel:lastModifiedTime:CreateVocabularyResponse' :: CreateVocabularyResponse -> Maybe POSIX
lastModifiedTime} -> Maybe POSIX
lastModifiedTime) (\s :: CreateVocabularyResponse
s@CreateVocabularyResponse' {} Maybe POSIX
a -> CreateVocabularyResponse
s {$sel:lastModifiedTime:CreateVocabularyResponse' :: Maybe POSIX
lastModifiedTime = Maybe POSIX
a} :: CreateVocabularyResponse) ((Maybe POSIX -> f (Maybe POSIX))
 -> CreateVocabularyResponse -> f CreateVocabularyResponse)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> CreateVocabularyResponse
-> f CreateVocabularyResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The processing state of the vocabulary. When the @VocabularyState@ field
-- contains @READY@ the vocabulary is ready to be used in a
-- @StartTranscriptionJob@ request.
createVocabularyResponse_vocabularyState :: Lens.Lens' CreateVocabularyResponse (Prelude.Maybe VocabularyState)
createVocabularyResponse_vocabularyState :: (Maybe VocabularyState -> f (Maybe VocabularyState))
-> CreateVocabularyResponse -> f CreateVocabularyResponse
createVocabularyResponse_vocabularyState = (CreateVocabularyResponse -> Maybe VocabularyState)
-> (CreateVocabularyResponse
    -> Maybe VocabularyState -> CreateVocabularyResponse)
-> Lens
     CreateVocabularyResponse
     CreateVocabularyResponse
     (Maybe VocabularyState)
     (Maybe VocabularyState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateVocabularyResponse' {Maybe VocabularyState
vocabularyState :: Maybe VocabularyState
$sel:vocabularyState:CreateVocabularyResponse' :: CreateVocabularyResponse -> Maybe VocabularyState
vocabularyState} -> Maybe VocabularyState
vocabularyState) (\s :: CreateVocabularyResponse
s@CreateVocabularyResponse' {} Maybe VocabularyState
a -> CreateVocabularyResponse
s {$sel:vocabularyState:CreateVocabularyResponse' :: Maybe VocabularyState
vocabularyState = Maybe VocabularyState
a} :: CreateVocabularyResponse)

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

instance Prelude.NFData CreateVocabularyResponse