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

-- | 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
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]
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
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. 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'
    { $sel:jsonPath:Record' :: Maybe Text
jsonPath = forall a. Maybe a
Prelude.Nothing,
      $sel:recordIndex:Record' :: Maybe Integer
recordIndex = 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 :: Lens' Record (Maybe Text)
record_jsonPath = 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 :: Lens' Record (Maybe Integer)
record_recordIndex = 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 Data.FromJSON Record where
  parseJSON :: Value -> Parser Record
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Record"
      ( \Object
x ->
          Maybe Text -> Maybe Integer -> Record
Record'
            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
"jsonPath")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"recordIndex")
      )

instance Prelude.Hashable Record where
  hashWithSalt :: Int -> Record -> Int
hashWithSalt Int
_salt Record' {Maybe Integer
Maybe Text
recordIndex :: Maybe Integer
jsonPath :: Maybe Text
$sel:recordIndex:Record' :: Record -> Maybe Integer
$sel:jsonPath:Record' :: Record -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
jsonPath
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
recordIndex

instance Prelude.NFData Record where
  rnf :: Record -> ()
rnf Record' {Maybe Integer
Maybe Text
recordIndex :: Maybe Integer
jsonPath :: Maybe Text
$sel:recordIndex:Record' :: Record -> Maybe Integer
$sel:jsonPath:Record' :: Record -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
jsonPath
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
recordIndex