{-# 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.ListTerminologies
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Provides a list of custom terminologies associated with your account.
--
-- This operation returns paginated results.
module Amazonka.Translate.ListTerminologies
  ( -- * Creating a Request
    ListTerminologies (..),
    newListTerminologies,

    -- * Request Lenses
    listTerminologies_maxResults,
    listTerminologies_nextToken,

    -- * Destructuring the Response
    ListTerminologiesResponse (..),
    newListTerminologiesResponse,

    -- * Response Lenses
    listTerminologiesResponse_nextToken,
    listTerminologiesResponse_terminologyPropertiesList,
    listTerminologiesResponse_httpStatus,
  )
where

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

-- | /See:/ 'newListTerminologies' smart constructor.
data ListTerminologies = ListTerminologies'
  { -- | The maximum number of custom terminologies returned per list request.
    ListTerminologies -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | If the result of the request to ListTerminologies was truncated, include
    -- the NextToken to fetch the next group of custom terminologies.
    ListTerminologies -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListTerminologies -> ListTerminologies -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTerminologies -> ListTerminologies -> Bool
$c/= :: ListTerminologies -> ListTerminologies -> Bool
== :: ListTerminologies -> ListTerminologies -> Bool
$c== :: ListTerminologies -> ListTerminologies -> Bool
Prelude.Eq, ReadPrec [ListTerminologies]
ReadPrec ListTerminologies
Int -> ReadS ListTerminologies
ReadS [ListTerminologies]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTerminologies]
$creadListPrec :: ReadPrec [ListTerminologies]
readPrec :: ReadPrec ListTerminologies
$creadPrec :: ReadPrec ListTerminologies
readList :: ReadS [ListTerminologies]
$creadList :: ReadS [ListTerminologies]
readsPrec :: Int -> ReadS ListTerminologies
$creadsPrec :: Int -> ReadS ListTerminologies
Prelude.Read, Int -> ListTerminologies -> ShowS
[ListTerminologies] -> ShowS
ListTerminologies -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTerminologies] -> ShowS
$cshowList :: [ListTerminologies] -> ShowS
show :: ListTerminologies -> String
$cshow :: ListTerminologies -> String
showsPrec :: Int -> ListTerminologies -> ShowS
$cshowsPrec :: Int -> ListTerminologies -> ShowS
Prelude.Show, forall x. Rep ListTerminologies x -> ListTerminologies
forall x. ListTerminologies -> Rep ListTerminologies x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTerminologies x -> ListTerminologies
$cfrom :: forall x. ListTerminologies -> Rep ListTerminologies x
Prelude.Generic)

-- |
-- Create a value of 'ListTerminologies' 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:
--
-- 'maxResults', 'listTerminologies_maxResults' - The maximum number of custom terminologies returned per list request.
--
-- 'nextToken', 'listTerminologies_nextToken' - If the result of the request to ListTerminologies was truncated, include
-- the NextToken to fetch the next group of custom terminologies.
newListTerminologies ::
  ListTerminologies
newListTerminologies :: ListTerminologies
newListTerminologies =
  ListTerminologies'
    { $sel:maxResults:ListTerminologies' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListTerminologies' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of custom terminologies returned per list request.
listTerminologies_maxResults :: Lens.Lens' ListTerminologies (Prelude.Maybe Prelude.Natural)
listTerminologies_maxResults :: Lens' ListTerminologies (Maybe Natural)
listTerminologies_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTerminologies' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListTerminologies' :: ListTerminologies -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListTerminologies
s@ListTerminologies' {} Maybe Natural
a -> ListTerminologies
s {$sel:maxResults:ListTerminologies' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListTerminologies)

-- | If the result of the request to ListTerminologies was truncated, include
-- the NextToken to fetch the next group of custom terminologies.
listTerminologies_nextToken :: Lens.Lens' ListTerminologies (Prelude.Maybe Prelude.Text)
listTerminologies_nextToken :: Lens' ListTerminologies (Maybe Text)
listTerminologies_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTerminologies' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTerminologies' :: ListTerminologies -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTerminologies
s@ListTerminologies' {} Maybe Text
a -> ListTerminologies
s {$sel:nextToken:ListTerminologies' :: Maybe Text
nextToken = Maybe Text
a} :: ListTerminologies)

instance Core.AWSPager ListTerminologies where
  page :: ListTerminologies
-> AWSResponse ListTerminologies -> Maybe ListTerminologies
page ListTerminologies
rq AWSResponse ListTerminologies
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListTerminologies
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListTerminologiesResponse (Maybe Text)
listTerminologiesResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListTerminologies
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListTerminologiesResponse (Maybe [TerminologyProperties])
listTerminologiesResponse_terminologyPropertiesList
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListTerminologies
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListTerminologies (Maybe Text)
listTerminologies_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListTerminologies
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListTerminologiesResponse (Maybe Text)
listTerminologiesResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListTerminologies where
  type
    AWSResponse ListTerminologies =
      ListTerminologiesResponse
  request :: (Service -> Service)
-> ListTerminologies -> Request ListTerminologies
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListTerminologies
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListTerminologies)))
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 [TerminologyProperties]
-> Int
-> ListTerminologiesResponse
ListTerminologiesResponse'
            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
"NextToken")
            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
"TerminologyPropertiesList"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            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 ListTerminologies where
  hashWithSalt :: Int -> ListTerminologies -> Int
hashWithSalt Int
_salt ListTerminologies' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListTerminologies' :: ListTerminologies -> Maybe Text
$sel:maxResults:ListTerminologies' :: ListTerminologies -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData ListTerminologies where
  rnf :: ListTerminologies -> ()
rnf ListTerminologies' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListTerminologies' :: ListTerminologies -> Maybe Text
$sel:maxResults:ListTerminologies' :: ListTerminologies -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

instance Data.ToHeaders ListTerminologies where
  toHeaders :: ListTerminologies -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSShineFrontendService_20170701.ListTerminologies" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON ListTerminologies where
  toJSON :: ListTerminologies -> Value
toJSON ListTerminologies' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListTerminologies' :: ListTerminologies -> Maybe Text
$sel:maxResults:ListTerminologies' :: ListTerminologies -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"MaxResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
            (Key
"NextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken
          ]
      )

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

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

-- | /See:/ 'newListTerminologiesResponse' smart constructor.
data ListTerminologiesResponse = ListTerminologiesResponse'
  { -- | If the response to the ListTerminologies was truncated, the NextToken
    -- fetches the next group of custom terminologies.
    ListTerminologiesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The properties list of the custom terminologies returned on the list
    -- request.
    ListTerminologiesResponse -> Maybe [TerminologyProperties]
terminologyPropertiesList :: Prelude.Maybe [TerminologyProperties],
    -- | The response's http status code.
    ListTerminologiesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListTerminologiesResponse -> ListTerminologiesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTerminologiesResponse -> ListTerminologiesResponse -> Bool
$c/= :: ListTerminologiesResponse -> ListTerminologiesResponse -> Bool
== :: ListTerminologiesResponse -> ListTerminologiesResponse -> Bool
$c== :: ListTerminologiesResponse -> ListTerminologiesResponse -> Bool
Prelude.Eq, ReadPrec [ListTerminologiesResponse]
ReadPrec ListTerminologiesResponse
Int -> ReadS ListTerminologiesResponse
ReadS [ListTerminologiesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTerminologiesResponse]
$creadListPrec :: ReadPrec [ListTerminologiesResponse]
readPrec :: ReadPrec ListTerminologiesResponse
$creadPrec :: ReadPrec ListTerminologiesResponse
readList :: ReadS [ListTerminologiesResponse]
$creadList :: ReadS [ListTerminologiesResponse]
readsPrec :: Int -> ReadS ListTerminologiesResponse
$creadsPrec :: Int -> ReadS ListTerminologiesResponse
Prelude.Read, Int -> ListTerminologiesResponse -> ShowS
[ListTerminologiesResponse] -> ShowS
ListTerminologiesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTerminologiesResponse] -> ShowS
$cshowList :: [ListTerminologiesResponse] -> ShowS
show :: ListTerminologiesResponse -> String
$cshow :: ListTerminologiesResponse -> String
showsPrec :: Int -> ListTerminologiesResponse -> ShowS
$cshowsPrec :: Int -> ListTerminologiesResponse -> ShowS
Prelude.Show, forall x.
Rep ListTerminologiesResponse x -> ListTerminologiesResponse
forall x.
ListTerminologiesResponse -> Rep ListTerminologiesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListTerminologiesResponse x -> ListTerminologiesResponse
$cfrom :: forall x.
ListTerminologiesResponse -> Rep ListTerminologiesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListTerminologiesResponse' 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:
--
-- 'nextToken', 'listTerminologiesResponse_nextToken' - If the response to the ListTerminologies was truncated, the NextToken
-- fetches the next group of custom terminologies.
--
-- 'terminologyPropertiesList', 'listTerminologiesResponse_terminologyPropertiesList' - The properties list of the custom terminologies returned on the list
-- request.
--
-- 'httpStatus', 'listTerminologiesResponse_httpStatus' - The response's http status code.
newListTerminologiesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListTerminologiesResponse
newListTerminologiesResponse :: Int -> ListTerminologiesResponse
newListTerminologiesResponse Int
pHttpStatus_ =
  ListTerminologiesResponse'
    { $sel:nextToken:ListTerminologiesResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:terminologyPropertiesList:ListTerminologiesResponse' :: Maybe [TerminologyProperties]
terminologyPropertiesList = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListTerminologiesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | If the response to the ListTerminologies was truncated, the NextToken
-- fetches the next group of custom terminologies.
listTerminologiesResponse_nextToken :: Lens.Lens' ListTerminologiesResponse (Prelude.Maybe Prelude.Text)
listTerminologiesResponse_nextToken :: Lens' ListTerminologiesResponse (Maybe Text)
listTerminologiesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTerminologiesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTerminologiesResponse' :: ListTerminologiesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTerminologiesResponse
s@ListTerminologiesResponse' {} Maybe Text
a -> ListTerminologiesResponse
s {$sel:nextToken:ListTerminologiesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListTerminologiesResponse)

-- | The properties list of the custom terminologies returned on the list
-- request.
listTerminologiesResponse_terminologyPropertiesList :: Lens.Lens' ListTerminologiesResponse (Prelude.Maybe [TerminologyProperties])
listTerminologiesResponse_terminologyPropertiesList :: Lens' ListTerminologiesResponse (Maybe [TerminologyProperties])
listTerminologiesResponse_terminologyPropertiesList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTerminologiesResponse' {Maybe [TerminologyProperties]
terminologyPropertiesList :: Maybe [TerminologyProperties]
$sel:terminologyPropertiesList:ListTerminologiesResponse' :: ListTerminologiesResponse -> Maybe [TerminologyProperties]
terminologyPropertiesList} -> Maybe [TerminologyProperties]
terminologyPropertiesList) (\s :: ListTerminologiesResponse
s@ListTerminologiesResponse' {} Maybe [TerminologyProperties]
a -> ListTerminologiesResponse
s {$sel:terminologyPropertiesList:ListTerminologiesResponse' :: Maybe [TerminologyProperties]
terminologyPropertiesList = Maybe [TerminologyProperties]
a} :: ListTerminologiesResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListTerminologiesResponse where
  rnf :: ListTerminologiesResponse -> ()
rnf ListTerminologiesResponse' {Int
Maybe [TerminologyProperties]
Maybe Text
httpStatus :: Int
terminologyPropertiesList :: Maybe [TerminologyProperties]
nextToken :: Maybe Text
$sel:httpStatus:ListTerminologiesResponse' :: ListTerminologiesResponse -> Int
$sel:terminologyPropertiesList:ListTerminologiesResponse' :: ListTerminologiesResponse -> Maybe [TerminologyProperties]
$sel:nextToken:ListTerminologiesResponse' :: ListTerminologiesResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [TerminologyProperties]
terminologyPropertiesList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus