{-# 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.Range
-- 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.Range 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 a
-- non-binary text file, such as an HTML, TXT, or XML file.
--
-- /See:/ 'newRange' smart constructor.
data Range = Range'
  { -- | The number of lines from the beginning of the file to the beginning of
    -- the sensitive data.
    Range -> Maybe Integer
start :: Prelude.Maybe Prelude.Integer,
    -- | The number of lines from the beginning of the file to the end of the
    -- sensitive data.
    Range -> Maybe Integer
end :: Prelude.Maybe Prelude.Integer,
    -- | The number of characters, with spaces and starting from 1, from the
    -- beginning of the first line that contains the sensitive data (start) to
    -- the beginning of the sensitive data.
    Range -> Maybe Integer
startColumn :: Prelude.Maybe Prelude.Integer
  }
  deriving (Range -> Range -> Bool
(Range -> Range -> Bool) -> (Range -> Range -> Bool) -> Eq Range
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Range -> Range -> Bool
$c/= :: Range -> Range -> Bool
== :: Range -> Range -> Bool
$c== :: Range -> Range -> Bool
Prelude.Eq, ReadPrec [Range]
ReadPrec Range
Int -> ReadS Range
ReadS [Range]
(Int -> ReadS Range)
-> ReadS [Range]
-> ReadPrec Range
-> ReadPrec [Range]
-> Read Range
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Range]
$creadListPrec :: ReadPrec [Range]
readPrec :: ReadPrec Range
$creadPrec :: ReadPrec Range
readList :: ReadS [Range]
$creadList :: ReadS [Range]
readsPrec :: Int -> ReadS Range
$creadsPrec :: Int -> ReadS Range
Prelude.Read, Int -> Range -> ShowS
[Range] -> ShowS
Range -> String
(Int -> Range -> ShowS)
-> (Range -> String) -> ([Range] -> ShowS) -> Show Range
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Range] -> ShowS
$cshowList :: [Range] -> ShowS
show :: Range -> String
$cshow :: Range -> String
showsPrec :: Int -> Range -> ShowS
$cshowsPrec :: Int -> Range -> ShowS
Prelude.Show, (forall x. Range -> Rep Range x)
-> (forall x. Rep Range x -> Range) -> Generic Range
forall x. Rep Range x -> Range
forall x. Range -> Rep Range x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Range x -> Range
$cfrom :: forall x. Range -> Rep Range x
Prelude.Generic)

-- |
-- Create a value of 'Range' 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:
--
-- 'start', 'range_start' - The number of lines from the beginning of the file to the beginning of
-- the sensitive data.
--
-- 'end', 'range_end' - The number of lines from the beginning of the file to the end of the
-- sensitive data.
--
-- 'startColumn', 'range_startColumn' - The number of characters, with spaces and starting from 1, from the
-- beginning of the first line that contains the sensitive data (start) to
-- the beginning of the sensitive data.
newRange ::
  Range
newRange :: Range
newRange =
  Range' :: Maybe Integer -> Maybe Integer -> Maybe Integer -> Range
Range'
    { $sel:start:Range' :: Maybe Integer
start = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:end:Range' :: Maybe Integer
end = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:startColumn:Range' :: Maybe Integer
startColumn = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | The number of lines from the beginning of the file to the beginning of
-- the sensitive data.
range_start :: Lens.Lens' Range (Prelude.Maybe Prelude.Integer)
range_start :: (Maybe Integer -> f (Maybe Integer)) -> Range -> f Range
range_start = (Range -> Maybe Integer)
-> (Range -> Maybe Integer -> Range)
-> Lens Range Range (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Range' {Maybe Integer
start :: Maybe Integer
$sel:start:Range' :: Range -> Maybe Integer
start} -> Maybe Integer
start) (\s :: Range
s@Range' {} Maybe Integer
a -> Range
s {$sel:start:Range' :: Maybe Integer
start = Maybe Integer
a} :: Range)

-- | The number of lines from the beginning of the file to the end of the
-- sensitive data.
range_end :: Lens.Lens' Range (Prelude.Maybe Prelude.Integer)
range_end :: (Maybe Integer -> f (Maybe Integer)) -> Range -> f Range
range_end = (Range -> Maybe Integer)
-> (Range -> Maybe Integer -> Range)
-> Lens Range Range (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Range' {Maybe Integer
end :: Maybe Integer
$sel:end:Range' :: Range -> Maybe Integer
end} -> Maybe Integer
end) (\s :: Range
s@Range' {} Maybe Integer
a -> Range
s {$sel:end:Range' :: Maybe Integer
end = Maybe Integer
a} :: Range)

-- | The number of characters, with spaces and starting from 1, from the
-- beginning of the first line that contains the sensitive data (start) to
-- the beginning of the sensitive data.
range_startColumn :: Lens.Lens' Range (Prelude.Maybe Prelude.Integer)
range_startColumn :: (Maybe Integer -> f (Maybe Integer)) -> Range -> f Range
range_startColumn = (Range -> Maybe Integer)
-> (Range -> Maybe Integer -> Range)
-> Lens Range Range (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Range' {Maybe Integer
startColumn :: Maybe Integer
$sel:startColumn:Range' :: Range -> Maybe Integer
startColumn} -> Maybe Integer
startColumn) (\s :: Range
s@Range' {} Maybe Integer
a -> Range
s {$sel:startColumn:Range' :: Maybe Integer
startColumn = Maybe Integer
a} :: Range)

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

instance Prelude.Hashable Range

instance Prelude.NFData Range