{-# 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.Translate.GetTerminology
-- 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)
--
-- Retrieves a custom terminology.
module Amazonka.Translate.GetTerminology
  ( -- * Creating a Request
    GetTerminology (..),
    newGetTerminology,

    -- * Request Lenses
    getTerminology_name,
    getTerminology_terminologyDataFormat,

    -- * Destructuring the Response
    GetTerminologyResponse (..),
    newGetTerminologyResponse,

    -- * Response Lenses
    getTerminologyResponse_terminologyProperties,
    getTerminologyResponse_terminologyDataLocation,
    getTerminologyResponse_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.Translate.Types

-- | /See:/ 'newGetTerminology' smart constructor.
data GetTerminology = GetTerminology'
  { -- | The name of the custom terminology being retrieved.
    GetTerminology -> Text
name :: Prelude.Text,
    -- | The data format of the custom terminology being retrieved, either CSV or
    -- TMX.
    GetTerminology -> TerminologyDataFormat
terminologyDataFormat :: TerminologyDataFormat
  }
  deriving (GetTerminology -> GetTerminology -> Bool
(GetTerminology -> GetTerminology -> Bool)
-> (GetTerminology -> GetTerminology -> Bool) -> Eq GetTerminology
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetTerminology -> GetTerminology -> Bool
$c/= :: GetTerminology -> GetTerminology -> Bool
== :: GetTerminology -> GetTerminology -> Bool
$c== :: GetTerminology -> GetTerminology -> Bool
Prelude.Eq, ReadPrec [GetTerminology]
ReadPrec GetTerminology
Int -> ReadS GetTerminology
ReadS [GetTerminology]
(Int -> ReadS GetTerminology)
-> ReadS [GetTerminology]
-> ReadPrec GetTerminology
-> ReadPrec [GetTerminology]
-> Read GetTerminology
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetTerminology]
$creadListPrec :: ReadPrec [GetTerminology]
readPrec :: ReadPrec GetTerminology
$creadPrec :: ReadPrec GetTerminology
readList :: ReadS [GetTerminology]
$creadList :: ReadS [GetTerminology]
readsPrec :: Int -> ReadS GetTerminology
$creadsPrec :: Int -> ReadS GetTerminology
Prelude.Read, Int -> GetTerminology -> ShowS
[GetTerminology] -> ShowS
GetTerminology -> String
(Int -> GetTerminology -> ShowS)
-> (GetTerminology -> String)
-> ([GetTerminology] -> ShowS)
-> Show GetTerminology
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetTerminology] -> ShowS
$cshowList :: [GetTerminology] -> ShowS
show :: GetTerminology -> String
$cshow :: GetTerminology -> String
showsPrec :: Int -> GetTerminology -> ShowS
$cshowsPrec :: Int -> GetTerminology -> ShowS
Prelude.Show, (forall x. GetTerminology -> Rep GetTerminology x)
-> (forall x. Rep GetTerminology x -> GetTerminology)
-> Generic GetTerminology
forall x. Rep GetTerminology x -> GetTerminology
forall x. GetTerminology -> Rep GetTerminology x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetTerminology x -> GetTerminology
$cfrom :: forall x. GetTerminology -> Rep GetTerminology x
Prelude.Generic)

-- |
-- Create a value of 'GetTerminology' 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:
--
-- 'name', 'getTerminology_name' - The name of the custom terminology being retrieved.
--
-- 'terminologyDataFormat', 'getTerminology_terminologyDataFormat' - The data format of the custom terminology being retrieved, either CSV or
-- TMX.
newGetTerminology ::
  -- | 'name'
  Prelude.Text ->
  -- | 'terminologyDataFormat'
  TerminologyDataFormat ->
  GetTerminology
newGetTerminology :: Text -> TerminologyDataFormat -> GetTerminology
newGetTerminology Text
pName_ TerminologyDataFormat
pTerminologyDataFormat_ =
  GetTerminology' :: Text -> TerminologyDataFormat -> GetTerminology
GetTerminology'
    { $sel:name:GetTerminology' :: Text
name = Text
pName_,
      $sel:terminologyDataFormat:GetTerminology' :: TerminologyDataFormat
terminologyDataFormat = TerminologyDataFormat
pTerminologyDataFormat_
    }

-- | The name of the custom terminology being retrieved.
getTerminology_name :: Lens.Lens' GetTerminology Prelude.Text
getTerminology_name :: (Text -> f Text) -> GetTerminology -> f GetTerminology
getTerminology_name = (GetTerminology -> Text)
-> (GetTerminology -> Text -> GetTerminology)
-> Lens GetTerminology GetTerminology Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTerminology' {Text
name :: Text
$sel:name:GetTerminology' :: GetTerminology -> Text
name} -> Text
name) (\s :: GetTerminology
s@GetTerminology' {} Text
a -> GetTerminology
s {$sel:name:GetTerminology' :: Text
name = Text
a} :: GetTerminology)

-- | The data format of the custom terminology being retrieved, either CSV or
-- TMX.
getTerminology_terminologyDataFormat :: Lens.Lens' GetTerminology TerminologyDataFormat
getTerminology_terminologyDataFormat :: (TerminologyDataFormat -> f TerminologyDataFormat)
-> GetTerminology -> f GetTerminology
getTerminology_terminologyDataFormat = (GetTerminology -> TerminologyDataFormat)
-> (GetTerminology -> TerminologyDataFormat -> GetTerminology)
-> Lens
     GetTerminology
     GetTerminology
     TerminologyDataFormat
     TerminologyDataFormat
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTerminology' {TerminologyDataFormat
terminologyDataFormat :: TerminologyDataFormat
$sel:terminologyDataFormat:GetTerminology' :: GetTerminology -> TerminologyDataFormat
terminologyDataFormat} -> TerminologyDataFormat
terminologyDataFormat) (\s :: GetTerminology
s@GetTerminology' {} TerminologyDataFormat
a -> GetTerminology
s {$sel:terminologyDataFormat:GetTerminology' :: TerminologyDataFormat
terminologyDataFormat = TerminologyDataFormat
a} :: GetTerminology)

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

instance Prelude.NFData GetTerminology

instance Core.ToHeaders GetTerminology where
  toHeaders :: GetTerminology -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetTerminology -> 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
"AWSShineFrontendService_20170701.GetTerminology" ::
                          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 GetTerminology where
  toJSON :: GetTerminology -> Value
toJSON GetTerminology' {Text
TerminologyDataFormat
terminologyDataFormat :: TerminologyDataFormat
name :: Text
$sel:terminologyDataFormat:GetTerminology' :: GetTerminology -> TerminologyDataFormat
$sel:name:GetTerminology' :: GetTerminology -> 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
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"TerminologyDataFormat"
                  Text -> TerminologyDataFormat -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TerminologyDataFormat
terminologyDataFormat
              )
          ]
      )

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

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

-- | /See:/ 'newGetTerminologyResponse' smart constructor.
data GetTerminologyResponse = GetTerminologyResponse'
  { -- | The properties of the custom terminology being retrieved.
    GetTerminologyResponse -> Maybe TerminologyProperties
terminologyProperties :: Prelude.Maybe TerminologyProperties,
    -- | The data location of the custom terminology being retrieved. The custom
    -- terminology file is returned in a presigned url that has a 30 minute
    -- expiration.
    GetTerminologyResponse -> Maybe TerminologyDataLocation
terminologyDataLocation :: Prelude.Maybe TerminologyDataLocation,
    -- | The response's http status code.
    GetTerminologyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetTerminologyResponse -> GetTerminologyResponse -> Bool
(GetTerminologyResponse -> GetTerminologyResponse -> Bool)
-> (GetTerminologyResponse -> GetTerminologyResponse -> Bool)
-> Eq GetTerminologyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetTerminologyResponse -> GetTerminologyResponse -> Bool
$c/= :: GetTerminologyResponse -> GetTerminologyResponse -> Bool
== :: GetTerminologyResponse -> GetTerminologyResponse -> Bool
$c== :: GetTerminologyResponse -> GetTerminologyResponse -> Bool
Prelude.Eq, ReadPrec [GetTerminologyResponse]
ReadPrec GetTerminologyResponse
Int -> ReadS GetTerminologyResponse
ReadS [GetTerminologyResponse]
(Int -> ReadS GetTerminologyResponse)
-> ReadS [GetTerminologyResponse]
-> ReadPrec GetTerminologyResponse
-> ReadPrec [GetTerminologyResponse]
-> Read GetTerminologyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetTerminologyResponse]
$creadListPrec :: ReadPrec [GetTerminologyResponse]
readPrec :: ReadPrec GetTerminologyResponse
$creadPrec :: ReadPrec GetTerminologyResponse
readList :: ReadS [GetTerminologyResponse]
$creadList :: ReadS [GetTerminologyResponse]
readsPrec :: Int -> ReadS GetTerminologyResponse
$creadsPrec :: Int -> ReadS GetTerminologyResponse
Prelude.Read, Int -> GetTerminologyResponse -> ShowS
[GetTerminologyResponse] -> ShowS
GetTerminologyResponse -> String
(Int -> GetTerminologyResponse -> ShowS)
-> (GetTerminologyResponse -> String)
-> ([GetTerminologyResponse] -> ShowS)
-> Show GetTerminologyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetTerminologyResponse] -> ShowS
$cshowList :: [GetTerminologyResponse] -> ShowS
show :: GetTerminologyResponse -> String
$cshow :: GetTerminologyResponse -> String
showsPrec :: Int -> GetTerminologyResponse -> ShowS
$cshowsPrec :: Int -> GetTerminologyResponse -> ShowS
Prelude.Show, (forall x. GetTerminologyResponse -> Rep GetTerminologyResponse x)
-> (forall x.
    Rep GetTerminologyResponse x -> GetTerminologyResponse)
-> Generic GetTerminologyResponse
forall x. Rep GetTerminologyResponse x -> GetTerminologyResponse
forall x. GetTerminologyResponse -> Rep GetTerminologyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetTerminologyResponse x -> GetTerminologyResponse
$cfrom :: forall x. GetTerminologyResponse -> Rep GetTerminologyResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetTerminologyResponse' 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:
--
-- 'terminologyProperties', 'getTerminologyResponse_terminologyProperties' - The properties of the custom terminology being retrieved.
--
-- 'terminologyDataLocation', 'getTerminologyResponse_terminologyDataLocation' - The data location of the custom terminology being retrieved. The custom
-- terminology file is returned in a presigned url that has a 30 minute
-- expiration.
--
-- 'httpStatus', 'getTerminologyResponse_httpStatus' - The response's http status code.
newGetTerminologyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetTerminologyResponse
newGetTerminologyResponse :: Int -> GetTerminologyResponse
newGetTerminologyResponse Int
pHttpStatus_ =
  GetTerminologyResponse' :: Maybe TerminologyProperties
-> Maybe TerminologyDataLocation -> Int -> GetTerminologyResponse
GetTerminologyResponse'
    { $sel:terminologyProperties:GetTerminologyResponse' :: Maybe TerminologyProperties
terminologyProperties =
        Maybe TerminologyProperties
forall a. Maybe a
Prelude.Nothing,
      $sel:terminologyDataLocation:GetTerminologyResponse' :: Maybe TerminologyDataLocation
terminologyDataLocation = Maybe TerminologyDataLocation
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetTerminologyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The properties of the custom terminology being retrieved.
getTerminologyResponse_terminologyProperties :: Lens.Lens' GetTerminologyResponse (Prelude.Maybe TerminologyProperties)
getTerminologyResponse_terminologyProperties :: (Maybe TerminologyProperties -> f (Maybe TerminologyProperties))
-> GetTerminologyResponse -> f GetTerminologyResponse
getTerminologyResponse_terminologyProperties = (GetTerminologyResponse -> Maybe TerminologyProperties)
-> (GetTerminologyResponse
    -> Maybe TerminologyProperties -> GetTerminologyResponse)
-> Lens
     GetTerminologyResponse
     GetTerminologyResponse
     (Maybe TerminologyProperties)
     (Maybe TerminologyProperties)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTerminologyResponse' {Maybe TerminologyProperties
terminologyProperties :: Maybe TerminologyProperties
$sel:terminologyProperties:GetTerminologyResponse' :: GetTerminologyResponse -> Maybe TerminologyProperties
terminologyProperties} -> Maybe TerminologyProperties
terminologyProperties) (\s :: GetTerminologyResponse
s@GetTerminologyResponse' {} Maybe TerminologyProperties
a -> GetTerminologyResponse
s {$sel:terminologyProperties:GetTerminologyResponse' :: Maybe TerminologyProperties
terminologyProperties = Maybe TerminologyProperties
a} :: GetTerminologyResponse)

-- | The data location of the custom terminology being retrieved. The custom
-- terminology file is returned in a presigned url that has a 30 minute
-- expiration.
getTerminologyResponse_terminologyDataLocation :: Lens.Lens' GetTerminologyResponse (Prelude.Maybe TerminologyDataLocation)
getTerminologyResponse_terminologyDataLocation :: (Maybe TerminologyDataLocation
 -> f (Maybe TerminologyDataLocation))
-> GetTerminologyResponse -> f GetTerminologyResponse
getTerminologyResponse_terminologyDataLocation = (GetTerminologyResponse -> Maybe TerminologyDataLocation)
-> (GetTerminologyResponse
    -> Maybe TerminologyDataLocation -> GetTerminologyResponse)
-> Lens
     GetTerminologyResponse
     GetTerminologyResponse
     (Maybe TerminologyDataLocation)
     (Maybe TerminologyDataLocation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetTerminologyResponse' {Maybe TerminologyDataLocation
terminologyDataLocation :: Maybe TerminologyDataLocation
$sel:terminologyDataLocation:GetTerminologyResponse' :: GetTerminologyResponse -> Maybe TerminologyDataLocation
terminologyDataLocation} -> Maybe TerminologyDataLocation
terminologyDataLocation) (\s :: GetTerminologyResponse
s@GetTerminologyResponse' {} Maybe TerminologyDataLocation
a -> GetTerminologyResponse
s {$sel:terminologyDataLocation:GetTerminologyResponse' :: Maybe TerminologyDataLocation
terminologyDataLocation = Maybe TerminologyDataLocation
a} :: GetTerminologyResponse)

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

instance Prelude.NFData GetTerminologyResponse