{-# 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.Warning
-- 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.Warning where

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

-- | A warning about an issue that occurred during asynchronous text analysis
-- (StartDocumentAnalysis) or asynchronous document text detection
-- (StartDocumentTextDetection).
--
-- /See:/ 'newWarning' smart constructor.
data Warning = Warning'
  { -- | A list of the pages that the warning applies to.
    Warning -> Maybe [Natural]
pages :: Prelude.Maybe [Prelude.Natural],
    -- | The error code for the warning.
    Warning -> Maybe Text
errorCode :: Prelude.Maybe Prelude.Text
  }
  deriving (Warning -> Warning -> Bool
(Warning -> Warning -> Bool)
-> (Warning -> Warning -> Bool) -> Eq Warning
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Warning -> Warning -> Bool
$c/= :: Warning -> Warning -> Bool
== :: Warning -> Warning -> Bool
$c== :: Warning -> Warning -> Bool
Prelude.Eq, ReadPrec [Warning]
ReadPrec Warning
Int -> ReadS Warning
ReadS [Warning]
(Int -> ReadS Warning)
-> ReadS [Warning]
-> ReadPrec Warning
-> ReadPrec [Warning]
-> Read Warning
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Warning]
$creadListPrec :: ReadPrec [Warning]
readPrec :: ReadPrec Warning
$creadPrec :: ReadPrec Warning
readList :: ReadS [Warning]
$creadList :: ReadS [Warning]
readsPrec :: Int -> ReadS Warning
$creadsPrec :: Int -> ReadS Warning
Prelude.Read, Int -> Warning -> ShowS
[Warning] -> ShowS
Warning -> String
(Int -> Warning -> ShowS)
-> (Warning -> String) -> ([Warning] -> ShowS) -> Show Warning
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Warning] -> ShowS
$cshowList :: [Warning] -> ShowS
show :: Warning -> String
$cshow :: Warning -> String
showsPrec :: Int -> Warning -> ShowS
$cshowsPrec :: Int -> Warning -> ShowS
Prelude.Show, (forall x. Warning -> Rep Warning x)
-> (forall x. Rep Warning x -> Warning) -> Generic Warning
forall x. Rep Warning x -> Warning
forall x. Warning -> Rep Warning x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Warning x -> Warning
$cfrom :: forall x. Warning -> Rep Warning x
Prelude.Generic)

-- |
-- Create a value of 'Warning' 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', 'warning_pages' - A list of the pages that the warning applies to.
--
-- 'errorCode', 'warning_errorCode' - The error code for the warning.
newWarning ::
  Warning
newWarning :: Warning
newWarning =
  Warning' :: Maybe [Natural] -> Maybe Text -> Warning
Warning'
    { $sel:pages:Warning' :: Maybe [Natural]
pages = Maybe [Natural]
forall a. Maybe a
Prelude.Nothing,
      $sel:errorCode:Warning' :: Maybe Text
errorCode = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A list of the pages that the warning applies to.
warning_pages :: Lens.Lens' Warning (Prelude.Maybe [Prelude.Natural])
warning_pages :: (Maybe [Natural] -> f (Maybe [Natural])) -> Warning -> f Warning
warning_pages = (Warning -> Maybe [Natural])
-> (Warning -> Maybe [Natural] -> Warning)
-> Lens Warning Warning (Maybe [Natural]) (Maybe [Natural])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Warning' {Maybe [Natural]
pages :: Maybe [Natural]
$sel:pages:Warning' :: Warning -> Maybe [Natural]
pages} -> Maybe [Natural]
pages) (\s :: Warning
s@Warning' {} Maybe [Natural]
a -> Warning
s {$sel:pages:Warning' :: Maybe [Natural]
pages = Maybe [Natural]
a} :: Warning) ((Maybe [Natural] -> f (Maybe [Natural])) -> Warning -> f Warning)
-> ((Maybe [Natural] -> f (Maybe [Natural]))
    -> Maybe [Natural] -> f (Maybe [Natural]))
-> (Maybe [Natural] -> f (Maybe [Natural]))
-> Warning
-> f Warning
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Natural] [Natural] [Natural] [Natural]
-> Iso
     (Maybe [Natural])
     (Maybe [Natural])
     (Maybe [Natural])
     (Maybe [Natural])
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 [Natural] [Natural] [Natural] [Natural]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The error code for the warning.
warning_errorCode :: Lens.Lens' Warning (Prelude.Maybe Prelude.Text)
warning_errorCode :: (Maybe Text -> f (Maybe Text)) -> Warning -> f Warning
warning_errorCode = (Warning -> Maybe Text)
-> (Warning -> Maybe Text -> Warning)
-> Lens Warning Warning (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Warning' {Maybe Text
errorCode :: Maybe Text
$sel:errorCode:Warning' :: Warning -> Maybe Text
errorCode} -> Maybe Text
errorCode) (\s :: Warning
s@Warning' {} Maybe Text
a -> Warning
s {$sel:errorCode:Warning' :: Maybe Text
errorCode = Maybe Text
a} :: Warning)

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

instance Prelude.Hashable Warning

instance Prelude.NFData Warning