{-# 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.Textract.Types.DocumentMetadata
-- 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.Textract.Types.DocumentMetadata where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about the input document.
--
-- /See:/ 'newDocumentMetadata' smart constructor.
data DocumentMetadata = DocumentMetadata'
  { -- | The number of pages that are detected in the document.
    DocumentMetadata -> Maybe Natural
pages :: Prelude.Maybe Prelude.Natural
  }
  deriving (DocumentMetadata -> DocumentMetadata -> Bool
(DocumentMetadata -> DocumentMetadata -> Bool)
-> (DocumentMetadata -> DocumentMetadata -> Bool)
-> Eq DocumentMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentMetadata -> DocumentMetadata -> Bool
$c/= :: DocumentMetadata -> DocumentMetadata -> Bool
== :: DocumentMetadata -> DocumentMetadata -> Bool
$c== :: DocumentMetadata -> DocumentMetadata -> Bool
Prelude.Eq, ReadPrec [DocumentMetadata]
ReadPrec DocumentMetadata
Int -> ReadS DocumentMetadata
ReadS [DocumentMetadata]
(Int -> ReadS DocumentMetadata)
-> ReadS [DocumentMetadata]
-> ReadPrec DocumentMetadata
-> ReadPrec [DocumentMetadata]
-> Read DocumentMetadata
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentMetadata]
$creadListPrec :: ReadPrec [DocumentMetadata]
readPrec :: ReadPrec DocumentMetadata
$creadPrec :: ReadPrec DocumentMetadata
readList :: ReadS [DocumentMetadata]
$creadList :: ReadS [DocumentMetadata]
readsPrec :: Int -> ReadS DocumentMetadata
$creadsPrec :: Int -> ReadS DocumentMetadata
Prelude.Read, Int -> DocumentMetadata -> ShowS
[DocumentMetadata] -> ShowS
DocumentMetadata -> String
(Int -> DocumentMetadata -> ShowS)
-> (DocumentMetadata -> String)
-> ([DocumentMetadata] -> ShowS)
-> Show DocumentMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentMetadata] -> ShowS
$cshowList :: [DocumentMetadata] -> ShowS
show :: DocumentMetadata -> String
$cshow :: DocumentMetadata -> String
showsPrec :: Int -> DocumentMetadata -> ShowS
$cshowsPrec :: Int -> DocumentMetadata -> ShowS
Prelude.Show, (forall x. DocumentMetadata -> Rep DocumentMetadata x)
-> (forall x. Rep DocumentMetadata x -> DocumentMetadata)
-> Generic DocumentMetadata
forall x. Rep DocumentMetadata x -> DocumentMetadata
forall x. DocumentMetadata -> Rep DocumentMetadata x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DocumentMetadata x -> DocumentMetadata
$cfrom :: forall x. DocumentMetadata -> Rep DocumentMetadata x
Prelude.Generic)

-- |
-- Create a value of 'DocumentMetadata' 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:
--
-- 'pages', 'documentMetadata_pages' - The number of pages that are detected in the document.
newDocumentMetadata ::
  DocumentMetadata
newDocumentMetadata :: DocumentMetadata
newDocumentMetadata =
  DocumentMetadata' :: Maybe Natural -> DocumentMetadata
DocumentMetadata' {$sel:pages:DocumentMetadata' :: Maybe Natural
pages = Maybe Natural
forall a. Maybe a
Prelude.Nothing}

-- | The number of pages that are detected in the document.
documentMetadata_pages :: Lens.Lens' DocumentMetadata (Prelude.Maybe Prelude.Natural)
documentMetadata_pages :: (Maybe Natural -> f (Maybe Natural))
-> DocumentMetadata -> f DocumentMetadata
documentMetadata_pages = (DocumentMetadata -> Maybe Natural)
-> (DocumentMetadata -> Maybe Natural -> DocumentMetadata)
-> Lens
     DocumentMetadata DocumentMetadata (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentMetadata' {Maybe Natural
pages :: Maybe Natural
$sel:pages:DocumentMetadata' :: DocumentMetadata -> Maybe Natural
pages} -> Maybe Natural
pages) (\s :: DocumentMetadata
s@DocumentMetadata' {} Maybe Natural
a -> DocumentMetadata
s {$sel:pages:DocumentMetadata' :: Maybe Natural
pages = Maybe Natural
a} :: DocumentMetadata)

instance Core.FromJSON DocumentMetadata where
  parseJSON :: Value -> Parser DocumentMetadata
parseJSON =
    String
-> (Object -> Parser DocumentMetadata)
-> Value
-> Parser DocumentMetadata
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DocumentMetadata"
      ( \Object
x ->
          Maybe Natural -> DocumentMetadata
DocumentMetadata' (Maybe Natural -> DocumentMetadata)
-> Parser (Maybe Natural) -> Parser DocumentMetadata
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Pages")
      )

instance Prelude.Hashable DocumentMetadata

instance Prelude.NFData DocumentMetadata