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

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

-- | Specifies the location of an occurrence of sensitive data in an Apache
-- Avro object container, Apache Parquet file, JSON file, or JSON Lines
-- file.
--
-- /See:/ 'newRecord' smart constructor.
data Record = Record'
  { -- | The path, as a JSONPath expression, to the sensitive data. For an Avro
    -- object container or Parquet file, this is the path to the field in the
    -- record (recordIndex) that contains the data. For a JSON or JSON Lines
    -- file, this is the path to the field or array that contains the data. If
    -- the data is a value in an array, the path also indicates which value
    -- contains the data.
    --
    -- If Amazon Macie detects sensitive data in the name of any element in the
    -- path, Macie omits this field. If the name of an element exceeds 20
    -- characters, Macie truncates the name by removing characters from the
    -- beginning of the name. If the resulting full path exceeds 250
    -- characters, Macie also truncates the path, starting with the first
    -- element in the path, until the path contains 250 or fewer characters.
    Record -> Maybe Text
jsonPath :: Prelude.Maybe Prelude.Text,
    -- | For an Avro object container or Parquet file, the record index, starting
    -- from 0, for the record that contains the sensitive data. For a JSON
    -- Lines file, the line index, starting from 0, for the line that contains
    -- the sensitive data. This value is always 0 for JSON files.
    Record -> Maybe Integer
recordIndex :: Prelude.Maybe Prelude.Integer
  }
  deriving (Record -> Record -> Bool
(Record -> Record -> Bool)
-> (Record -> Record -> Bool) -> Eq Record
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Record -> Record -> Bool
$c/= :: Record -> Record -> Bool
== :: Record -> Record -> Bool
$c== :: Record -> Record -> Bool
Prelude.Eq, ReadPrec [Record]
ReadPrec Record
Int -> ReadS Record
ReadS [Record]
(Int -> ReadS Record)
-> ReadS [Record]
-> ReadPrec Record
-> ReadPrec [Record]
-> Read Record
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Record]
$creadListPrec :: ReadPrec [Record]
readPrec :: ReadPrec Record
$creadPrec :: ReadPrec Record
readList :: ReadS [Record]
$creadList :: ReadS [Record]
readsPrec :: Int -> ReadS Record
$creadsPrec :: Int -> ReadS Record
Prelude.Read, Int -> Record -> ShowS
[Record] -> ShowS
Record -> String
(Int -> Record -> ShowS)
-> (Record -> String) -> ([Record] -> ShowS) -> Show Record
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Record] -> ShowS
$cshowList :: [Record] -> ShowS
show :: Record -> String
$cshow :: Record -> String
showsPrec :: Int -> Record -> ShowS
$cshowsPrec :: Int -> Record -> ShowS
Prelude.Show, (forall x. Record -> Rep Record x)
-> (forall x. Rep Record x -> Record) -> Generic Record
forall x. Rep Record x -> Record
forall x. Record -> Rep Record x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Record x -> Record
$cfrom :: forall x. Record -> Rep Record x
Prelude.Generic)

-- |
-- Create a value of 'Record' 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:
--
-- 'jsonPath', 'record_jsonPath' - The path, as a JSONPath expression, to the sensitive data. For an Avro
-- object container or Parquet file, this is the path to the field in the
-- record (recordIndex) that contains the data. For a JSON or JSON Lines
-- file, this is the path to the field or array that contains the data. If
-- the data is a value in an array, the path also indicates which value
-- contains the data.
--
-- If Amazon Macie detects sensitive data in the name of any element in the
-- path, Macie omits this field. If the name of an element exceeds 20
-- characters, Macie truncates the name by removing characters from the
-- beginning of the name. If the resulting full path exceeds 250
-- characters, Macie also truncates the path, starting with the first
-- element in the path, until the path contains 250 or fewer characters.
--
-- 'recordIndex', 'record_recordIndex' - For an Avro object container or Parquet file, the record index, starting
-- from 0, for the record that contains the sensitive data. For a JSON
-- Lines file, the line index, starting from 0, for the line that contains
-- the sensitive data. This value is always 0 for JSON files.
newRecord ::
  Record
newRecord :: Record
newRecord =
  Record' :: Maybe Text -> Maybe Integer -> Record
Record'
    { $sel:jsonPath:Record' :: Maybe Text
jsonPath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:recordIndex:Record' :: Maybe Integer
recordIndex = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | The path, as a JSONPath expression, to the sensitive data. For an Avro
-- object container or Parquet file, this is the path to the field in the
-- record (recordIndex) that contains the data. For a JSON or JSON Lines
-- file, this is the path to the field or array that contains the data. If
-- the data is a value in an array, the path also indicates which value
-- contains the data.
--
-- If Amazon Macie detects sensitive data in the name of any element in the
-- path, Macie omits this field. If the name of an element exceeds 20
-- characters, Macie truncates the name by removing characters from the
-- beginning of the name. If the resulting full path exceeds 250
-- characters, Macie also truncates the path, starting with the first
-- element in the path, until the path contains 250 or fewer characters.
record_jsonPath :: Lens.Lens' Record (Prelude.Maybe Prelude.Text)
record_jsonPath :: (Maybe Text -> f (Maybe Text)) -> Record -> f Record
record_jsonPath = (Record -> Maybe Text)
-> (Record -> Maybe Text -> Record)
-> Lens Record Record (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Record' {Maybe Text
jsonPath :: Maybe Text
$sel:jsonPath:Record' :: Record -> Maybe Text
jsonPath} -> Maybe Text
jsonPath) (\s :: Record
s@Record' {} Maybe Text
a -> Record
s {$sel:jsonPath:Record' :: Maybe Text
jsonPath = Maybe Text
a} :: Record)

-- | For an Avro object container or Parquet file, the record index, starting
-- from 0, for the record that contains the sensitive data. For a JSON
-- Lines file, the line index, starting from 0, for the line that contains
-- the sensitive data. This value is always 0 for JSON files.
record_recordIndex :: Lens.Lens' Record (Prelude.Maybe Prelude.Integer)
record_recordIndex :: (Maybe Integer -> f (Maybe Integer)) -> Record -> f Record
record_recordIndex = (Record -> Maybe Integer)
-> (Record -> Maybe Integer -> Record)
-> Lens Record Record (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Record' {Maybe Integer
recordIndex :: Maybe Integer
$sel:recordIndex:Record' :: Record -> Maybe Integer
recordIndex} -> Maybe Integer
recordIndex) (\s :: Record
s@Record' {} Maybe Integer
a -> Record
s {$sel:recordIndex:Record' :: Maybe Integer
recordIndex = Maybe Integer
a} :: Record)

instance Core.FromJSON Record where
  parseJSON :: Value -> Parser Record
parseJSON =
    String -> (Object -> Parser Record) -> Value -> Parser Record
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Record"
      ( \Object
x ->
          Maybe Text -> Maybe Integer -> Record
Record'
            (Maybe Text -> Maybe Integer -> Record)
-> Parser (Maybe Text) -> Parser (Maybe Integer -> Record)
forall (f :: * -> *) a b. Functor 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
"jsonPath")
            Parser (Maybe Integer -> Record)
-> Parser (Maybe Integer) -> Parser Record
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
"recordIndex")
      )

instance Prelude.Hashable Record

instance Prelude.NFData Record