{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Comprehend.Types.BatchDetectEntitiesItemResult
-- 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)
module Amazonka.Comprehend.Types.BatchDetectEntitiesItemResult where

import Amazonka.Comprehend.Types.Entity
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The result of calling the operation. The operation returns one object
-- for each document that is successfully processed by the operation.
--
-- /See:/ 'newBatchDetectEntitiesItemResult' smart constructor.
data BatchDetectEntitiesItemResult = BatchDetectEntitiesItemResult'
  { -- | One or more Entity objects, one for each entity detected in the
    -- document.
    BatchDetectEntitiesItemResult -> Maybe [Entity]
entities :: Prelude.Maybe [Entity],
    -- | The zero-based index of the document in the input list.
    BatchDetectEntitiesItemResult -> Maybe Int
index :: Prelude.Maybe Prelude.Int
  }
  deriving (BatchDetectEntitiesItemResult
-> BatchDetectEntitiesItemResult -> Bool
(BatchDetectEntitiesItemResult
 -> BatchDetectEntitiesItemResult -> Bool)
-> (BatchDetectEntitiesItemResult
    -> BatchDetectEntitiesItemResult -> Bool)
-> Eq BatchDetectEntitiesItemResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchDetectEntitiesItemResult
-> BatchDetectEntitiesItemResult -> Bool
$c/= :: BatchDetectEntitiesItemResult
-> BatchDetectEntitiesItemResult -> Bool
== :: BatchDetectEntitiesItemResult
-> BatchDetectEntitiesItemResult -> Bool
$c== :: BatchDetectEntitiesItemResult
-> BatchDetectEntitiesItemResult -> Bool
Prelude.Eq, ReadPrec [BatchDetectEntitiesItemResult]
ReadPrec BatchDetectEntitiesItemResult
Int -> ReadS BatchDetectEntitiesItemResult
ReadS [BatchDetectEntitiesItemResult]
(Int -> ReadS BatchDetectEntitiesItemResult)
-> ReadS [BatchDetectEntitiesItemResult]
-> ReadPrec BatchDetectEntitiesItemResult
-> ReadPrec [BatchDetectEntitiesItemResult]
-> Read BatchDetectEntitiesItemResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchDetectEntitiesItemResult]
$creadListPrec :: ReadPrec [BatchDetectEntitiesItemResult]
readPrec :: ReadPrec BatchDetectEntitiesItemResult
$creadPrec :: ReadPrec BatchDetectEntitiesItemResult
readList :: ReadS [BatchDetectEntitiesItemResult]
$creadList :: ReadS [BatchDetectEntitiesItemResult]
readsPrec :: Int -> ReadS BatchDetectEntitiesItemResult
$creadsPrec :: Int -> ReadS BatchDetectEntitiesItemResult
Prelude.Read, Int -> BatchDetectEntitiesItemResult -> ShowS
[BatchDetectEntitiesItemResult] -> ShowS
BatchDetectEntitiesItemResult -> String
(Int -> BatchDetectEntitiesItemResult -> ShowS)
-> (BatchDetectEntitiesItemResult -> String)
-> ([BatchDetectEntitiesItemResult] -> ShowS)
-> Show BatchDetectEntitiesItemResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchDetectEntitiesItemResult] -> ShowS
$cshowList :: [BatchDetectEntitiesItemResult] -> ShowS
show :: BatchDetectEntitiesItemResult -> String
$cshow :: BatchDetectEntitiesItemResult -> String
showsPrec :: Int -> BatchDetectEntitiesItemResult -> ShowS
$cshowsPrec :: Int -> BatchDetectEntitiesItemResult -> ShowS
Prelude.Show, (forall x.
 BatchDetectEntitiesItemResult
 -> Rep BatchDetectEntitiesItemResult x)
-> (forall x.
    Rep BatchDetectEntitiesItemResult x
    -> BatchDetectEntitiesItemResult)
-> Generic BatchDetectEntitiesItemResult
forall x.
Rep BatchDetectEntitiesItemResult x
-> BatchDetectEntitiesItemResult
forall x.
BatchDetectEntitiesItemResult
-> Rep BatchDetectEntitiesItemResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchDetectEntitiesItemResult x
-> BatchDetectEntitiesItemResult
$cfrom :: forall x.
BatchDetectEntitiesItemResult
-> Rep BatchDetectEntitiesItemResult x
Prelude.Generic)

-- |
-- Create a value of 'BatchDetectEntitiesItemResult' 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:
--
-- 'entities', 'batchDetectEntitiesItemResult_entities' - One or more Entity objects, one for each entity detected in the
-- document.
--
-- 'index', 'batchDetectEntitiesItemResult_index' - The zero-based index of the document in the input list.
newBatchDetectEntitiesItemResult ::
  BatchDetectEntitiesItemResult
newBatchDetectEntitiesItemResult :: BatchDetectEntitiesItemResult
newBatchDetectEntitiesItemResult =
  BatchDetectEntitiesItemResult' :: Maybe [Entity] -> Maybe Int -> BatchDetectEntitiesItemResult
BatchDetectEntitiesItemResult'
    { $sel:entities:BatchDetectEntitiesItemResult' :: Maybe [Entity]
entities =
        Maybe [Entity]
forall a. Maybe a
Prelude.Nothing,
      $sel:index:BatchDetectEntitiesItemResult' :: Maybe Int
index = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | One or more Entity objects, one for each entity detected in the
-- document.
batchDetectEntitiesItemResult_entities :: Lens.Lens' BatchDetectEntitiesItemResult (Prelude.Maybe [Entity])
batchDetectEntitiesItemResult_entities :: (Maybe [Entity] -> f (Maybe [Entity]))
-> BatchDetectEntitiesItemResult -> f BatchDetectEntitiesItemResult
batchDetectEntitiesItemResult_entities = (BatchDetectEntitiesItemResult -> Maybe [Entity])
-> (BatchDetectEntitiesItemResult
    -> Maybe [Entity] -> BatchDetectEntitiesItemResult)
-> Lens
     BatchDetectEntitiesItemResult
     BatchDetectEntitiesItemResult
     (Maybe [Entity])
     (Maybe [Entity])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDetectEntitiesItemResult' {Maybe [Entity]
entities :: Maybe [Entity]
$sel:entities:BatchDetectEntitiesItemResult' :: BatchDetectEntitiesItemResult -> Maybe [Entity]
entities} -> Maybe [Entity]
entities) (\s :: BatchDetectEntitiesItemResult
s@BatchDetectEntitiesItemResult' {} Maybe [Entity]
a -> BatchDetectEntitiesItemResult
s {$sel:entities:BatchDetectEntitiesItemResult' :: Maybe [Entity]
entities = Maybe [Entity]
a} :: BatchDetectEntitiesItemResult) ((Maybe [Entity] -> f (Maybe [Entity]))
 -> BatchDetectEntitiesItemResult
 -> f BatchDetectEntitiesItemResult)
-> ((Maybe [Entity] -> f (Maybe [Entity]))
    -> Maybe [Entity] -> f (Maybe [Entity]))
-> (Maybe [Entity] -> f (Maybe [Entity]))
-> BatchDetectEntitiesItemResult
-> f BatchDetectEntitiesItemResult
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Entity] [Entity] [Entity] [Entity]
-> Iso
     (Maybe [Entity]) (Maybe [Entity]) (Maybe [Entity]) (Maybe [Entity])
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 [Entity] [Entity] [Entity] [Entity]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The zero-based index of the document in the input list.
batchDetectEntitiesItemResult_index :: Lens.Lens' BatchDetectEntitiesItemResult (Prelude.Maybe Prelude.Int)
batchDetectEntitiesItemResult_index :: (Maybe Int -> f (Maybe Int))
-> BatchDetectEntitiesItemResult -> f BatchDetectEntitiesItemResult
batchDetectEntitiesItemResult_index = (BatchDetectEntitiesItemResult -> Maybe Int)
-> (BatchDetectEntitiesItemResult
    -> Maybe Int -> BatchDetectEntitiesItemResult)
-> Lens
     BatchDetectEntitiesItemResult
     BatchDetectEntitiesItemResult
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDetectEntitiesItemResult' {Maybe Int
index :: Maybe Int
$sel:index:BatchDetectEntitiesItemResult' :: BatchDetectEntitiesItemResult -> Maybe Int
index} -> Maybe Int
index) (\s :: BatchDetectEntitiesItemResult
s@BatchDetectEntitiesItemResult' {} Maybe Int
a -> BatchDetectEntitiesItemResult
s {$sel:index:BatchDetectEntitiesItemResult' :: Maybe Int
index = Maybe Int
a} :: BatchDetectEntitiesItemResult)

instance Core.FromJSON BatchDetectEntitiesItemResult where
  parseJSON :: Value -> Parser BatchDetectEntitiesItemResult
parseJSON =
    String
-> (Object -> Parser BatchDetectEntitiesItemResult)
-> Value
-> Parser BatchDetectEntitiesItemResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"BatchDetectEntitiesItemResult"
      ( \Object
x ->
          Maybe [Entity] -> Maybe Int -> BatchDetectEntitiesItemResult
BatchDetectEntitiesItemResult'
            (Maybe [Entity] -> Maybe Int -> BatchDetectEntitiesItemResult)
-> Parser (Maybe [Entity])
-> Parser (Maybe Int -> BatchDetectEntitiesItemResult)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Entity]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Entities" Parser (Maybe (Maybe [Entity]))
-> Maybe [Entity] -> Parser (Maybe [Entity])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Entity]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Int -> BatchDetectEntitiesItemResult)
-> Parser (Maybe Int) -> Parser BatchDetectEntitiesItemResult
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Index")
      )

instance
  Prelude.Hashable
    BatchDetectEntitiesItemResult

instance Prelude.NFData BatchDetectEntitiesItemResult