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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MacieV2.Types.JobScopingBlock
import qualified Amazonka.Prelude as Prelude

-- | Specifies one or more property- and tag-based conditions that define
-- criteria for including or excluding S3 objects from a classification
-- job. Exclude conditions take precedence over include conditions.
--
-- /See:/ 'newScoping' smart constructor.
data Scoping = Scoping'
  { -- | The property- and tag-based conditions that determine which objects to
    -- include in the analysis.
    Scoping -> Maybe JobScopingBlock
includes :: Prelude.Maybe JobScopingBlock,
    -- | The property- and tag-based conditions that determine which objects to
    -- exclude from the analysis.
    Scoping -> Maybe JobScopingBlock
excludes :: Prelude.Maybe JobScopingBlock
  }
  deriving (Scoping -> Scoping -> Bool
(Scoping -> Scoping -> Bool)
-> (Scoping -> Scoping -> Bool) -> Eq Scoping
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Scoping -> Scoping -> Bool
$c/= :: Scoping -> Scoping -> Bool
== :: Scoping -> Scoping -> Bool
$c== :: Scoping -> Scoping -> Bool
Prelude.Eq, ReadPrec [Scoping]
ReadPrec Scoping
Int -> ReadS Scoping
ReadS [Scoping]
(Int -> ReadS Scoping)
-> ReadS [Scoping]
-> ReadPrec Scoping
-> ReadPrec [Scoping]
-> Read Scoping
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Scoping]
$creadListPrec :: ReadPrec [Scoping]
readPrec :: ReadPrec Scoping
$creadPrec :: ReadPrec Scoping
readList :: ReadS [Scoping]
$creadList :: ReadS [Scoping]
readsPrec :: Int -> ReadS Scoping
$creadsPrec :: Int -> ReadS Scoping
Prelude.Read, Int -> Scoping -> ShowS
[Scoping] -> ShowS
Scoping -> String
(Int -> Scoping -> ShowS)
-> (Scoping -> String) -> ([Scoping] -> ShowS) -> Show Scoping
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Scoping] -> ShowS
$cshowList :: [Scoping] -> ShowS
show :: Scoping -> String
$cshow :: Scoping -> String
showsPrec :: Int -> Scoping -> ShowS
$cshowsPrec :: Int -> Scoping -> ShowS
Prelude.Show, (forall x. Scoping -> Rep Scoping x)
-> (forall x. Rep Scoping x -> Scoping) -> Generic Scoping
forall x. Rep Scoping x -> Scoping
forall x. Scoping -> Rep Scoping x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Scoping x -> Scoping
$cfrom :: forall x. Scoping -> Rep Scoping x
Prelude.Generic)

-- |
-- Create a value of 'Scoping' 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:
--
-- 'includes', 'scoping_includes' - The property- and tag-based conditions that determine which objects to
-- include in the analysis.
--
-- 'excludes', 'scoping_excludes' - The property- and tag-based conditions that determine which objects to
-- exclude from the analysis.
newScoping ::
  Scoping
newScoping :: Scoping
newScoping =
  Scoping' :: Maybe JobScopingBlock -> Maybe JobScopingBlock -> Scoping
Scoping'
    { $sel:includes:Scoping' :: Maybe JobScopingBlock
includes = Maybe JobScopingBlock
forall a. Maybe a
Prelude.Nothing,
      $sel:excludes:Scoping' :: Maybe JobScopingBlock
excludes = Maybe JobScopingBlock
forall a. Maybe a
Prelude.Nothing
    }

-- | The property- and tag-based conditions that determine which objects to
-- include in the analysis.
scoping_includes :: Lens.Lens' Scoping (Prelude.Maybe JobScopingBlock)
scoping_includes :: (Maybe JobScopingBlock -> f (Maybe JobScopingBlock))
-> Scoping -> f Scoping
scoping_includes = (Scoping -> Maybe JobScopingBlock)
-> (Scoping -> Maybe JobScopingBlock -> Scoping)
-> Lens
     Scoping Scoping (Maybe JobScopingBlock) (Maybe JobScopingBlock)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Scoping' {Maybe JobScopingBlock
includes :: Maybe JobScopingBlock
$sel:includes:Scoping' :: Scoping -> Maybe JobScopingBlock
includes} -> Maybe JobScopingBlock
includes) (\s :: Scoping
s@Scoping' {} Maybe JobScopingBlock
a -> Scoping
s {$sel:includes:Scoping' :: Maybe JobScopingBlock
includes = Maybe JobScopingBlock
a} :: Scoping)

-- | The property- and tag-based conditions that determine which objects to
-- exclude from the analysis.
scoping_excludes :: Lens.Lens' Scoping (Prelude.Maybe JobScopingBlock)
scoping_excludes :: (Maybe JobScopingBlock -> f (Maybe JobScopingBlock))
-> Scoping -> f Scoping
scoping_excludes = (Scoping -> Maybe JobScopingBlock)
-> (Scoping -> Maybe JobScopingBlock -> Scoping)
-> Lens
     Scoping Scoping (Maybe JobScopingBlock) (Maybe JobScopingBlock)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Scoping' {Maybe JobScopingBlock
excludes :: Maybe JobScopingBlock
$sel:excludes:Scoping' :: Scoping -> Maybe JobScopingBlock
excludes} -> Maybe JobScopingBlock
excludes) (\s :: Scoping
s@Scoping' {} Maybe JobScopingBlock
a -> Scoping
s {$sel:excludes:Scoping' :: Maybe JobScopingBlock
excludes = Maybe JobScopingBlock
a} :: Scoping)

instance Core.FromJSON Scoping where
  parseJSON :: Value -> Parser Scoping
parseJSON =
    String -> (Object -> Parser Scoping) -> Value -> Parser Scoping
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Scoping"
      ( \Object
x ->
          Maybe JobScopingBlock -> Maybe JobScopingBlock -> Scoping
Scoping'
            (Maybe JobScopingBlock -> Maybe JobScopingBlock -> Scoping)
-> Parser (Maybe JobScopingBlock)
-> Parser (Maybe JobScopingBlock -> Scoping)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe JobScopingBlock)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"includes")
            Parser (Maybe JobScopingBlock -> Scoping)
-> Parser (Maybe JobScopingBlock) -> Parser Scoping
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe JobScopingBlock)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"excludes")
      )

instance Prelude.Hashable Scoping

instance Prelude.NFData Scoping

instance Core.ToJSON Scoping where
  toJSON :: Scoping -> Value
toJSON Scoping' {Maybe JobScopingBlock
excludes :: Maybe JobScopingBlock
includes :: Maybe JobScopingBlock
$sel:excludes:Scoping' :: Scoping -> Maybe JobScopingBlock
$sel:includes:Scoping' :: Scoping -> Maybe JobScopingBlock
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"includes" Text -> JobScopingBlock -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (JobScopingBlock -> Pair) -> Maybe JobScopingBlock -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe JobScopingBlock
includes,
            (Text
"excludes" Text -> JobScopingBlock -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (JobScopingBlock -> Pair) -> Maybe JobScopingBlock -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe JobScopingBlock
excludes
          ]
      )