{-# 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.MacieV2.Types.Occurrences
-- 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.MacieV2.Types.Occurrences where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MacieV2.Types.Cell
import Amazonka.MacieV2.Types.Page
import Amazonka.MacieV2.Types.Range
import Amazonka.MacieV2.Types.Record
import qualified Amazonka.Prelude as Prelude

-- | Specifies the location of 1-15 occurrences of sensitive data that was
-- detected by a managed data identifier or a custom data identifier and
-- produced a sensitive data finding.
--
-- /See:/ 'newOccurrences' smart constructor.
data Occurrences = Occurrences'
  { -- | An array of objects, one for each occurrence of sensitive data in a
    -- non-binary text file, such as an HTML, TXT, or XML file. Each Range
    -- object specifies a line or inclusive range of lines that contains the
    -- sensitive data, and the position of the data on the specified line or
    -- lines.
    --
    -- This value is often null for file types that are supported by Cell,
    -- Page, or Record objects. Exceptions are the location of sensitive data
    -- in: unstructured sections of an otherwise structured file, such as a
    -- comment in a file; a malformed file that Amazon Macie analyzes as plain
    -- text; and, a CSV or TSV file that has any column names that contain
    -- sensitive data.
    Occurrences -> Maybe [Range]
lineRanges :: Prelude.Maybe [Range],
    -- | An array of objects, one for each occurrence of sensitive data in a
    -- Microsoft Excel workbook, CSV file, or TSV file. This value is null for
    -- all other types of files.
    --
    -- Each Cell object specifies a cell or field that contains the sensitive
    -- data.
    Occurrences -> Maybe [Cell]
cells :: Prelude.Maybe [Cell],
    -- | An array of objects, one for each occurrence of sensitive data in an
    -- Adobe Portable Document Format file. This value is null for all other
    -- types of files.
    --
    -- Each Page object specifies a page that contains the sensitive data.
    Occurrences -> Maybe [Page]
pages :: Prelude.Maybe [Page],
    -- | An array of objects, one for each occurrence of sensitive data in an
    -- Apache Avro object container, Apache Parquet file, JSON file, or JSON
    -- Lines file. This value is null for all other types of files.
    --
    -- For an Avro object container or Parquet file, each Record object
    -- specifies a record index and the path to a field in a record that
    -- contains the sensitive data. For a JSON or JSON Lines file, each Record
    -- object specifies the path to a field or array that contains the
    -- sensitive data. For a JSON Lines file, it also specifies the index of
    -- the line that contains the data.
    Occurrences -> Maybe [Record]
records :: Prelude.Maybe [Record],
    -- | Reserved for future use.
    Occurrences -> Maybe [Range]
offsetRanges :: Prelude.Maybe [Range]
  }
  deriving (Occurrences -> Occurrences -> Bool
(Occurrences -> Occurrences -> Bool)
-> (Occurrences -> Occurrences -> Bool) -> Eq Occurrences
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Occurrences -> Occurrences -> Bool
$c/= :: Occurrences -> Occurrences -> Bool
== :: Occurrences -> Occurrences -> Bool
$c== :: Occurrences -> Occurrences -> Bool
Prelude.Eq, ReadPrec [Occurrences]
ReadPrec Occurrences
Int -> ReadS Occurrences
ReadS [Occurrences]
(Int -> ReadS Occurrences)
-> ReadS [Occurrences]
-> ReadPrec Occurrences
-> ReadPrec [Occurrences]
-> Read Occurrences
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Occurrences]
$creadListPrec :: ReadPrec [Occurrences]
readPrec :: ReadPrec Occurrences
$creadPrec :: ReadPrec Occurrences
readList :: ReadS [Occurrences]
$creadList :: ReadS [Occurrences]
readsPrec :: Int -> ReadS Occurrences
$creadsPrec :: Int -> ReadS Occurrences
Prelude.Read, Int -> Occurrences -> ShowS
[Occurrences] -> ShowS
Occurrences -> String
(Int -> Occurrences -> ShowS)
-> (Occurrences -> String)
-> ([Occurrences] -> ShowS)
-> Show Occurrences
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Occurrences] -> ShowS
$cshowList :: [Occurrences] -> ShowS
show :: Occurrences -> String
$cshow :: Occurrences -> String
showsPrec :: Int -> Occurrences -> ShowS
$cshowsPrec :: Int -> Occurrences -> ShowS
Prelude.Show, (forall x. Occurrences -> Rep Occurrences x)
-> (forall x. Rep Occurrences x -> Occurrences)
-> Generic Occurrences
forall x. Rep Occurrences x -> Occurrences
forall x. Occurrences -> Rep Occurrences x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Occurrences x -> Occurrences
$cfrom :: forall x. Occurrences -> Rep Occurrences x
Prelude.Generic)

-- |
-- Create a value of 'Occurrences' 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:
--
-- 'lineRanges', 'occurrences_lineRanges' - An array of objects, one for each occurrence of sensitive data in a
-- non-binary text file, such as an HTML, TXT, or XML file. Each Range
-- object specifies a line or inclusive range of lines that contains the
-- sensitive data, and the position of the data on the specified line or
-- lines.
--
-- This value is often null for file types that are supported by Cell,
-- Page, or Record objects. Exceptions are the location of sensitive data
-- in: unstructured sections of an otherwise structured file, such as a
-- comment in a file; a malformed file that Amazon Macie analyzes as plain
-- text; and, a CSV or TSV file that has any column names that contain
-- sensitive data.
--
-- 'cells', 'occurrences_cells' - An array of objects, one for each occurrence of sensitive data in a
-- Microsoft Excel workbook, CSV file, or TSV file. This value is null for
-- all other types of files.
--
-- Each Cell object specifies a cell or field that contains the sensitive
-- data.
--
-- 'pages', 'occurrences_pages' - An array of objects, one for each occurrence of sensitive data in an
-- Adobe Portable Document Format file. This value is null for all other
-- types of files.
--
-- Each Page object specifies a page that contains the sensitive data.
--
-- 'records', 'occurrences_records' - An array of objects, one for each occurrence of sensitive data in an
-- Apache Avro object container, Apache Parquet file, JSON file, or JSON
-- Lines file. This value is null for all other types of files.
--
-- For an Avro object container or Parquet file, each Record object
-- specifies a record index and the path to a field in a record that
-- contains the sensitive data. For a JSON or JSON Lines file, each Record
-- object specifies the path to a field or array that contains the
-- sensitive data. For a JSON Lines file, it also specifies the index of
-- the line that contains the data.
--
-- 'offsetRanges', 'occurrences_offsetRanges' - Reserved for future use.
newOccurrences ::
  Occurrences
newOccurrences :: Occurrences
newOccurrences =
  Occurrences' :: Maybe [Range]
-> Maybe [Cell]
-> Maybe [Page]
-> Maybe [Record]
-> Maybe [Range]
-> Occurrences
Occurrences'
    { $sel:lineRanges:Occurrences' :: Maybe [Range]
lineRanges = Maybe [Range]
forall a. Maybe a
Prelude.Nothing,
      $sel:cells:Occurrences' :: Maybe [Cell]
cells = Maybe [Cell]
forall a. Maybe a
Prelude.Nothing,
      $sel:pages:Occurrences' :: Maybe [Page]
pages = Maybe [Page]
forall a. Maybe a
Prelude.Nothing,
      $sel:records:Occurrences' :: Maybe [Record]
records = Maybe [Record]
forall a. Maybe a
Prelude.Nothing,
      $sel:offsetRanges:Occurrences' :: Maybe [Range]
offsetRanges = Maybe [Range]
forall a. Maybe a
Prelude.Nothing
    }

-- | An array of objects, one for each occurrence of sensitive data in a
-- non-binary text file, such as an HTML, TXT, or XML file. Each Range
-- object specifies a line or inclusive range of lines that contains the
-- sensitive data, and the position of the data on the specified line or
-- lines.
--
-- This value is often null for file types that are supported by Cell,
-- Page, or Record objects. Exceptions are the location of sensitive data
-- in: unstructured sections of an otherwise structured file, such as a
-- comment in a file; a malformed file that Amazon Macie analyzes as plain
-- text; and, a CSV or TSV file that has any column names that contain
-- sensitive data.
occurrences_lineRanges :: Lens.Lens' Occurrences (Prelude.Maybe [Range])
occurrences_lineRanges :: (Maybe [Range] -> f (Maybe [Range]))
-> Occurrences -> f Occurrences
occurrences_lineRanges = (Occurrences -> Maybe [Range])
-> (Occurrences -> Maybe [Range] -> Occurrences)
-> Lens Occurrences Occurrences (Maybe [Range]) (Maybe [Range])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Occurrences' {Maybe [Range]
lineRanges :: Maybe [Range]
$sel:lineRanges:Occurrences' :: Occurrences -> Maybe [Range]
lineRanges} -> Maybe [Range]
lineRanges) (\s :: Occurrences
s@Occurrences' {} Maybe [Range]
a -> Occurrences
s {$sel:lineRanges:Occurrences' :: Maybe [Range]
lineRanges = Maybe [Range]
a} :: Occurrences) ((Maybe [Range] -> f (Maybe [Range]))
 -> Occurrences -> f Occurrences)
-> ((Maybe [Range] -> f (Maybe [Range]))
    -> Maybe [Range] -> f (Maybe [Range]))
-> (Maybe [Range] -> f (Maybe [Range]))
-> Occurrences
-> f Occurrences
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Range] [Range] [Range] [Range]
-> Iso
     (Maybe [Range]) (Maybe [Range]) (Maybe [Range]) (Maybe [Range])
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 [Range] [Range] [Range] [Range]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An array of objects, one for each occurrence of sensitive data in a
-- Microsoft Excel workbook, CSV file, or TSV file. This value is null for
-- all other types of files.
--
-- Each Cell object specifies a cell or field that contains the sensitive
-- data.
occurrences_cells :: Lens.Lens' Occurrences (Prelude.Maybe [Cell])
occurrences_cells :: (Maybe [Cell] -> f (Maybe [Cell])) -> Occurrences -> f Occurrences
occurrences_cells = (Occurrences -> Maybe [Cell])
-> (Occurrences -> Maybe [Cell] -> Occurrences)
-> Lens Occurrences Occurrences (Maybe [Cell]) (Maybe [Cell])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Occurrences' {Maybe [Cell]
cells :: Maybe [Cell]
$sel:cells:Occurrences' :: Occurrences -> Maybe [Cell]
cells} -> Maybe [Cell]
cells) (\s :: Occurrences
s@Occurrences' {} Maybe [Cell]
a -> Occurrences
s {$sel:cells:Occurrences' :: Maybe [Cell]
cells = Maybe [Cell]
a} :: Occurrences) ((Maybe [Cell] -> f (Maybe [Cell]))
 -> Occurrences -> f Occurrences)
-> ((Maybe [Cell] -> f (Maybe [Cell]))
    -> Maybe [Cell] -> f (Maybe [Cell]))
-> (Maybe [Cell] -> f (Maybe [Cell]))
-> Occurrences
-> f Occurrences
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Cell] [Cell] [Cell] [Cell]
-> Iso (Maybe [Cell]) (Maybe [Cell]) (Maybe [Cell]) (Maybe [Cell])
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 [Cell] [Cell] [Cell] [Cell]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An array of objects, one for each occurrence of sensitive data in an
-- Adobe Portable Document Format file. This value is null for all other
-- types of files.
--
-- Each Page object specifies a page that contains the sensitive data.
occurrences_pages :: Lens.Lens' Occurrences (Prelude.Maybe [Page])
occurrences_pages :: (Maybe [Page] -> f (Maybe [Page])) -> Occurrences -> f Occurrences
occurrences_pages = (Occurrences -> Maybe [Page])
-> (Occurrences -> Maybe [Page] -> Occurrences)
-> Lens Occurrences Occurrences (Maybe [Page]) (Maybe [Page])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Occurrences' {Maybe [Page]
pages :: Maybe [Page]
$sel:pages:Occurrences' :: Occurrences -> Maybe [Page]
pages} -> Maybe [Page]
pages) (\s :: Occurrences
s@Occurrences' {} Maybe [Page]
a -> Occurrences
s {$sel:pages:Occurrences' :: Maybe [Page]
pages = Maybe [Page]
a} :: Occurrences) ((Maybe [Page] -> f (Maybe [Page]))
 -> Occurrences -> f Occurrences)
-> ((Maybe [Page] -> f (Maybe [Page]))
    -> Maybe [Page] -> f (Maybe [Page]))
-> (Maybe [Page] -> f (Maybe [Page]))
-> Occurrences
-> f Occurrences
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Page] [Page] [Page] [Page]
-> Iso (Maybe [Page]) (Maybe [Page]) (Maybe [Page]) (Maybe [Page])
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 [Page] [Page] [Page] [Page]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An array of objects, one for each occurrence of sensitive data in an
-- Apache Avro object container, Apache Parquet file, JSON file, or JSON
-- Lines file. This value is null for all other types of files.
--
-- For an Avro object container or Parquet file, each Record object
-- specifies a record index and the path to a field in a record that
-- contains the sensitive data. For a JSON or JSON Lines file, each Record
-- object specifies the path to a field or array that contains the
-- sensitive data. For a JSON Lines file, it also specifies the index of
-- the line that contains the data.
occurrences_records :: Lens.Lens' Occurrences (Prelude.Maybe [Record])
occurrences_records :: (Maybe [Record] -> f (Maybe [Record]))
-> Occurrences -> f Occurrences
occurrences_records = (Occurrences -> Maybe [Record])
-> (Occurrences -> Maybe [Record] -> Occurrences)
-> Lens Occurrences Occurrences (Maybe [Record]) (Maybe [Record])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Occurrences' {Maybe [Record]
records :: Maybe [Record]
$sel:records:Occurrences' :: Occurrences -> Maybe [Record]
records} -> Maybe [Record]
records) (\s :: Occurrences
s@Occurrences' {} Maybe [Record]
a -> Occurrences
s {$sel:records:Occurrences' :: Maybe [Record]
records = Maybe [Record]
a} :: Occurrences) ((Maybe [Record] -> f (Maybe [Record]))
 -> Occurrences -> f Occurrences)
-> ((Maybe [Record] -> f (Maybe [Record]))
    -> Maybe [Record] -> f (Maybe [Record]))
-> (Maybe [Record] -> f (Maybe [Record]))
-> Occurrences
-> f Occurrences
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Record] [Record] [Record] [Record]
-> Iso
     (Maybe [Record]) (Maybe [Record]) (Maybe [Record]) (Maybe [Record])
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 [Record] [Record] [Record] [Record]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Reserved for future use.
occurrences_offsetRanges :: Lens.Lens' Occurrences (Prelude.Maybe [Range])
occurrences_offsetRanges :: (Maybe [Range] -> f (Maybe [Range]))
-> Occurrences -> f Occurrences
occurrences_offsetRanges = (Occurrences -> Maybe [Range])
-> (Occurrences -> Maybe [Range] -> Occurrences)
-> Lens Occurrences Occurrences (Maybe [Range]) (Maybe [Range])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Occurrences' {Maybe [Range]
offsetRanges :: Maybe [Range]
$sel:offsetRanges:Occurrences' :: Occurrences -> Maybe [Range]
offsetRanges} -> Maybe [Range]
offsetRanges) (\s :: Occurrences
s@Occurrences' {} Maybe [Range]
a -> Occurrences
s {$sel:offsetRanges:Occurrences' :: Maybe [Range]
offsetRanges = Maybe [Range]
a} :: Occurrences) ((Maybe [Range] -> f (Maybe [Range]))
 -> Occurrences -> f Occurrences)
-> ((Maybe [Range] -> f (Maybe [Range]))
    -> Maybe [Range] -> f (Maybe [Range]))
-> (Maybe [Range] -> f (Maybe [Range]))
-> Occurrences
-> f Occurrences
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Range] [Range] [Range] [Range]
-> Iso
     (Maybe [Range]) (Maybe [Range]) (Maybe [Range]) (Maybe [Range])
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 [Range] [Range] [Range] [Range]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON Occurrences where
  parseJSON :: Value -> Parser Occurrences
parseJSON =
    String
-> (Object -> Parser Occurrences) -> Value -> Parser Occurrences
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Occurrences"
      ( \Object
x ->
          Maybe [Range]
-> Maybe [Cell]
-> Maybe [Page]
-> Maybe [Record]
-> Maybe [Range]
-> Occurrences
Occurrences'
            (Maybe [Range]
 -> Maybe [Cell]
 -> Maybe [Page]
 -> Maybe [Record]
 -> Maybe [Range]
 -> Occurrences)
-> Parser (Maybe [Range])
-> Parser
     (Maybe [Cell]
      -> Maybe [Page] -> Maybe [Record] -> Maybe [Range] -> Occurrences)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Range]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lineRanges" Parser (Maybe (Maybe [Range]))
-> Maybe [Range] -> Parser (Maybe [Range])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Range]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe [Cell]
   -> Maybe [Page] -> Maybe [Record] -> Maybe [Range] -> Occurrences)
-> Parser (Maybe [Cell])
-> Parser
     (Maybe [Page] -> Maybe [Record] -> Maybe [Range] -> Occurrences)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Cell]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"cells" Parser (Maybe (Maybe [Cell]))
-> Maybe [Cell] -> Parser (Maybe [Cell])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Cell]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe [Page] -> Maybe [Record] -> Maybe [Range] -> Occurrences)
-> Parser (Maybe [Page])
-> Parser (Maybe [Record] -> Maybe [Range] -> Occurrences)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Page]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"pages" Parser (Maybe (Maybe [Page]))
-> Maybe [Page] -> Parser (Maybe [Page])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Page]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe [Record] -> Maybe [Range] -> Occurrences)
-> Parser (Maybe [Record]) -> Parser (Maybe [Range] -> Occurrences)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Record]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"records" Parser (Maybe (Maybe [Record]))
-> Maybe [Record] -> Parser (Maybe [Record])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Record]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe [Range] -> Occurrences)
-> Parser (Maybe [Range]) -> Parser Occurrences
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Range]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"offsetRanges" Parser (Maybe (Maybe [Range]))
-> Maybe [Range] -> Parser (Maybe [Range])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Range]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable Occurrences

instance Prelude.NFData Occurrences