{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Textract.Types.DocumentMetadata 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

-- | 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
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]
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
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. 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' {$sel:pages:DocumentMetadata' :: Maybe Natural
pages = 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 :: Lens' DocumentMetadata (Maybe Natural)
documentMetadata_pages = 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 Data.FromJSON DocumentMetadata where
  parseJSON :: Value -> Parser DocumentMetadata
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DocumentMetadata"
      ( \Object
x ->
          Maybe Natural -> DocumentMetadata
DocumentMetadata' forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Pages")
      )

instance Prelude.Hashable DocumentMetadata where
  hashWithSalt :: Int -> DocumentMetadata -> Int
hashWithSalt Int
_salt DocumentMetadata' {Maybe Natural
pages :: Maybe Natural
$sel:pages:DocumentMetadata' :: DocumentMetadata -> Maybe Natural
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
pages

instance Prelude.NFData DocumentMetadata where
  rnf :: DocumentMetadata -> ()
rnf DocumentMetadata' {Maybe Natural
pages :: Maybe Natural
$sel:pages:DocumentMetadata' :: DocumentMetadata -> Maybe Natural
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
pages