{-# 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.SecurityHub.Types.Page
-- 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.SecurityHub.Types.Page where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.Range

-- | An occurrence of sensitive data in an Adobe Portable Document Format
-- (PDF) file.
--
-- /See:/ 'newPage' smart constructor.
data Page = Page'
  { -- | An occurrence of sensitive data detected in a binary text file.
    Page -> Maybe Range
offsetRange :: Prelude.Maybe Range,
    -- | An occurrence of sensitive data detected in a non-binary text file or a
    -- Microsoft Word file. Non-binary text files include files such as HTML,
    -- XML, JSON, and TXT files.
    Page -> Maybe Range
lineRange :: Prelude.Maybe Range,
    -- | The page number of the page that contains the sensitive data.
    Page -> Maybe Integer
pageNumber :: Prelude.Maybe Prelude.Integer
  }
  deriving (Page -> Page -> Bool
(Page -> Page -> Bool) -> (Page -> Page -> Bool) -> Eq Page
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Page -> Page -> Bool
$c/= :: Page -> Page -> Bool
== :: Page -> Page -> Bool
$c== :: Page -> Page -> Bool
Prelude.Eq, ReadPrec [Page]
ReadPrec Page
Int -> ReadS Page
ReadS [Page]
(Int -> ReadS Page)
-> ReadS [Page] -> ReadPrec Page -> ReadPrec [Page] -> Read Page
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Page]
$creadListPrec :: ReadPrec [Page]
readPrec :: ReadPrec Page
$creadPrec :: ReadPrec Page
readList :: ReadS [Page]
$creadList :: ReadS [Page]
readsPrec :: Int -> ReadS Page
$creadsPrec :: Int -> ReadS Page
Prelude.Read, Int -> Page -> ShowS
[Page] -> ShowS
Page -> String
(Int -> Page -> ShowS)
-> (Page -> String) -> ([Page] -> ShowS) -> Show Page
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Page] -> ShowS
$cshowList :: [Page] -> ShowS
show :: Page -> String
$cshow :: Page -> String
showsPrec :: Int -> Page -> ShowS
$cshowsPrec :: Int -> Page -> ShowS
Prelude.Show, (forall x. Page -> Rep Page x)
-> (forall x. Rep Page x -> Page) -> Generic Page
forall x. Rep Page x -> Page
forall x. Page -> Rep Page x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Page x -> Page
$cfrom :: forall x. Page -> Rep Page x
Prelude.Generic)

-- |
-- Create a value of 'Page' 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:
--
-- 'offsetRange', 'page_offsetRange' - An occurrence of sensitive data detected in a binary text file.
--
-- 'lineRange', 'page_lineRange' - An occurrence of sensitive data detected in a non-binary text file or a
-- Microsoft Word file. Non-binary text files include files such as HTML,
-- XML, JSON, and TXT files.
--
-- 'pageNumber', 'page_pageNumber' - The page number of the page that contains the sensitive data.
newPage ::
  Page
newPage :: Page
newPage =
  Page' :: Maybe Range -> Maybe Range -> Maybe Integer -> Page
Page'
    { $sel:offsetRange:Page' :: Maybe Range
offsetRange = Maybe Range
forall a. Maybe a
Prelude.Nothing,
      $sel:lineRange:Page' :: Maybe Range
lineRange = Maybe Range
forall a. Maybe a
Prelude.Nothing,
      $sel:pageNumber:Page' :: Maybe Integer
pageNumber = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | An occurrence of sensitive data detected in a binary text file.
page_offsetRange :: Lens.Lens' Page (Prelude.Maybe Range)
page_offsetRange :: (Maybe Range -> f (Maybe Range)) -> Page -> f Page
page_offsetRange = (Page -> Maybe Range)
-> (Page -> Maybe Range -> Page)
-> Lens Page Page (Maybe Range) (Maybe Range)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Page' {Maybe Range
offsetRange :: Maybe Range
$sel:offsetRange:Page' :: Page -> Maybe Range
offsetRange} -> Maybe Range
offsetRange) (\s :: Page
s@Page' {} Maybe Range
a -> Page
s {$sel:offsetRange:Page' :: Maybe Range
offsetRange = Maybe Range
a} :: Page)

-- | An occurrence of sensitive data detected in a non-binary text file or a
-- Microsoft Word file. Non-binary text files include files such as HTML,
-- XML, JSON, and TXT files.
page_lineRange :: Lens.Lens' Page (Prelude.Maybe Range)
page_lineRange :: (Maybe Range -> f (Maybe Range)) -> Page -> f Page
page_lineRange = (Page -> Maybe Range)
-> (Page -> Maybe Range -> Page)
-> Lens Page Page (Maybe Range) (Maybe Range)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Page' {Maybe Range
lineRange :: Maybe Range
$sel:lineRange:Page' :: Page -> Maybe Range
lineRange} -> Maybe Range
lineRange) (\s :: Page
s@Page' {} Maybe Range
a -> Page
s {$sel:lineRange:Page' :: Maybe Range
lineRange = Maybe Range
a} :: Page)

-- | The page number of the page that contains the sensitive data.
page_pageNumber :: Lens.Lens' Page (Prelude.Maybe Prelude.Integer)
page_pageNumber :: (Maybe Integer -> f (Maybe Integer)) -> Page -> f Page
page_pageNumber = (Page -> Maybe Integer)
-> (Page -> Maybe Integer -> Page)
-> Lens Page Page (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Page' {Maybe Integer
pageNumber :: Maybe Integer
$sel:pageNumber:Page' :: Page -> Maybe Integer
pageNumber} -> Maybe Integer
pageNumber) (\s :: Page
s@Page' {} Maybe Integer
a -> Page
s {$sel:pageNumber:Page' :: Maybe Integer
pageNumber = Maybe Integer
a} :: Page)

instance Core.FromJSON Page where
  parseJSON :: Value -> Parser Page
parseJSON =
    String -> (Object -> Parser Page) -> Value -> Parser Page
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Page"
      ( \Object
x ->
          Maybe Range -> Maybe Range -> Maybe Integer -> Page
Page'
            (Maybe Range -> Maybe Range -> Maybe Integer -> Page)
-> Parser (Maybe Range)
-> Parser (Maybe Range -> Maybe Integer -> Page)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Range)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"OffsetRange")
            Parser (Maybe Range -> Maybe Integer -> Page)
-> Parser (Maybe Range) -> Parser (Maybe Integer -> Page)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Range)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"LineRange")
            Parser (Maybe Integer -> Page)
-> Parser (Maybe Integer) -> Parser Page
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PageNumber")
      )

instance Prelude.Hashable Page

instance Prelude.NFData Page

instance Core.ToJSON Page where
  toJSON :: Page -> Value
toJSON Page' {Maybe Integer
Maybe Range
pageNumber :: Maybe Integer
lineRange :: Maybe Range
offsetRange :: Maybe Range
$sel:pageNumber:Page' :: Page -> Maybe Integer
$sel:lineRange:Page' :: Page -> Maybe Range
$sel:offsetRange:Page' :: Page -> Maybe Range
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"OffsetRange" Text -> Range -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Range -> Pair) -> Maybe Range -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Range
offsetRange,
            (Text
"LineRange" Text -> Range -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Range -> Pair) -> Maybe Range -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Range
lineRange,
            (Text
"PageNumber" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
pageNumber
          ]
      )