{-# 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.Macie.Types.ClassificationType
-- 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.Macie.Types.ClassificationType where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Macie.Types.S3ContinuousClassificationType
import Amazonka.Macie.Types.S3OneTimeClassificationType
import qualified Amazonka.Prelude as Prelude

-- | The classification type that Amazon Macie Classic applies to the
-- associated S3 resources.
--
-- /See:/ 'newClassificationType' smart constructor.
data ClassificationType = ClassificationType'
  { -- | A one-time classification of all of the existing objects in a specified
    -- S3 bucket.
    ClassificationType -> S3OneTimeClassificationType
oneTime :: S3OneTimeClassificationType,
    -- | A continuous classification of the objects that are added to a specified
    -- S3 bucket. Amazon Macie Classic begins performing continuous
    -- classification after a bucket is successfully associated with Macie
    -- Classic.
    ClassificationType -> S3ContinuousClassificationType
continuous :: S3ContinuousClassificationType
  }
  deriving (ClassificationType -> ClassificationType -> Bool
(ClassificationType -> ClassificationType -> Bool)
-> (ClassificationType -> ClassificationType -> Bool)
-> Eq ClassificationType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClassificationType -> ClassificationType -> Bool
$c/= :: ClassificationType -> ClassificationType -> Bool
== :: ClassificationType -> ClassificationType -> Bool
$c== :: ClassificationType -> ClassificationType -> Bool
Prelude.Eq, ReadPrec [ClassificationType]
ReadPrec ClassificationType
Int -> ReadS ClassificationType
ReadS [ClassificationType]
(Int -> ReadS ClassificationType)
-> ReadS [ClassificationType]
-> ReadPrec ClassificationType
-> ReadPrec [ClassificationType]
-> Read ClassificationType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ClassificationType]
$creadListPrec :: ReadPrec [ClassificationType]
readPrec :: ReadPrec ClassificationType
$creadPrec :: ReadPrec ClassificationType
readList :: ReadS [ClassificationType]
$creadList :: ReadS [ClassificationType]
readsPrec :: Int -> ReadS ClassificationType
$creadsPrec :: Int -> ReadS ClassificationType
Prelude.Read, Int -> ClassificationType -> ShowS
[ClassificationType] -> ShowS
ClassificationType -> String
(Int -> ClassificationType -> ShowS)
-> (ClassificationType -> String)
-> ([ClassificationType] -> ShowS)
-> Show ClassificationType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClassificationType] -> ShowS
$cshowList :: [ClassificationType] -> ShowS
show :: ClassificationType -> String
$cshow :: ClassificationType -> String
showsPrec :: Int -> ClassificationType -> ShowS
$cshowsPrec :: Int -> ClassificationType -> ShowS
Prelude.Show, (forall x. ClassificationType -> Rep ClassificationType x)
-> (forall x. Rep ClassificationType x -> ClassificationType)
-> Generic ClassificationType
forall x. Rep ClassificationType x -> ClassificationType
forall x. ClassificationType -> Rep ClassificationType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ClassificationType x -> ClassificationType
$cfrom :: forall x. ClassificationType -> Rep ClassificationType x
Prelude.Generic)

-- |
-- Create a value of 'ClassificationType' 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:
--
-- 'oneTime', 'classificationType_oneTime' - A one-time classification of all of the existing objects in a specified
-- S3 bucket.
--
-- 'continuous', 'classificationType_continuous' - A continuous classification of the objects that are added to a specified
-- S3 bucket. Amazon Macie Classic begins performing continuous
-- classification after a bucket is successfully associated with Macie
-- Classic.
newClassificationType ::
  -- | 'oneTime'
  S3OneTimeClassificationType ->
  -- | 'continuous'
  S3ContinuousClassificationType ->
  ClassificationType
newClassificationType :: S3OneTimeClassificationType
-> S3ContinuousClassificationType -> ClassificationType
newClassificationType S3OneTimeClassificationType
pOneTime_ S3ContinuousClassificationType
pContinuous_ =
  ClassificationType' :: S3OneTimeClassificationType
-> S3ContinuousClassificationType -> ClassificationType
ClassificationType'
    { $sel:oneTime:ClassificationType' :: S3OneTimeClassificationType
oneTime = S3OneTimeClassificationType
pOneTime_,
      $sel:continuous:ClassificationType' :: S3ContinuousClassificationType
continuous = S3ContinuousClassificationType
pContinuous_
    }

-- | A one-time classification of all of the existing objects in a specified
-- S3 bucket.
classificationType_oneTime :: Lens.Lens' ClassificationType S3OneTimeClassificationType
classificationType_oneTime :: (S3OneTimeClassificationType -> f S3OneTimeClassificationType)
-> ClassificationType -> f ClassificationType
classificationType_oneTime = (ClassificationType -> S3OneTimeClassificationType)
-> (ClassificationType
    -> S3OneTimeClassificationType -> ClassificationType)
-> Lens
     ClassificationType
     ClassificationType
     S3OneTimeClassificationType
     S3OneTimeClassificationType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClassificationType' {S3OneTimeClassificationType
oneTime :: S3OneTimeClassificationType
$sel:oneTime:ClassificationType' :: ClassificationType -> S3OneTimeClassificationType
oneTime} -> S3OneTimeClassificationType
oneTime) (\s :: ClassificationType
s@ClassificationType' {} S3OneTimeClassificationType
a -> ClassificationType
s {$sel:oneTime:ClassificationType' :: S3OneTimeClassificationType
oneTime = S3OneTimeClassificationType
a} :: ClassificationType)

-- | A continuous classification of the objects that are added to a specified
-- S3 bucket. Amazon Macie Classic begins performing continuous
-- classification after a bucket is successfully associated with Macie
-- Classic.
classificationType_continuous :: Lens.Lens' ClassificationType S3ContinuousClassificationType
classificationType_continuous :: (S3ContinuousClassificationType
 -> f S3ContinuousClassificationType)
-> ClassificationType -> f ClassificationType
classificationType_continuous = (ClassificationType -> S3ContinuousClassificationType)
-> (ClassificationType
    -> S3ContinuousClassificationType -> ClassificationType)
-> Lens
     ClassificationType
     ClassificationType
     S3ContinuousClassificationType
     S3ContinuousClassificationType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClassificationType' {S3ContinuousClassificationType
continuous :: S3ContinuousClassificationType
$sel:continuous:ClassificationType' :: ClassificationType -> S3ContinuousClassificationType
continuous} -> S3ContinuousClassificationType
continuous) (\s :: ClassificationType
s@ClassificationType' {} S3ContinuousClassificationType
a -> ClassificationType
s {$sel:continuous:ClassificationType' :: S3ContinuousClassificationType
continuous = S3ContinuousClassificationType
a} :: ClassificationType)

instance Core.FromJSON ClassificationType where
  parseJSON :: Value -> Parser ClassificationType
parseJSON =
    String
-> (Object -> Parser ClassificationType)
-> Value
-> Parser ClassificationType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ClassificationType"
      ( \Object
x ->
          S3OneTimeClassificationType
-> S3ContinuousClassificationType -> ClassificationType
ClassificationType'
            (S3OneTimeClassificationType
 -> S3ContinuousClassificationType -> ClassificationType)
-> Parser S3OneTimeClassificationType
-> Parser (S3ContinuousClassificationType -> ClassificationType)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser S3OneTimeClassificationType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"oneTime")
            Parser (S3ContinuousClassificationType -> ClassificationType)
-> Parser S3ContinuousClassificationType
-> Parser ClassificationType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser S3ContinuousClassificationType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"continuous")
      )

instance Prelude.Hashable ClassificationType

instance Prelude.NFData ClassificationType

instance Core.ToJSON ClassificationType where
  toJSON :: ClassificationType -> Value
toJSON ClassificationType' {S3ContinuousClassificationType
S3OneTimeClassificationType
continuous :: S3ContinuousClassificationType
oneTime :: S3OneTimeClassificationType
$sel:continuous:ClassificationType' :: ClassificationType -> S3ContinuousClassificationType
$sel:oneTime:ClassificationType' :: ClassificationType -> S3OneTimeClassificationType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"oneTime" Text -> S3OneTimeClassificationType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= S3OneTimeClassificationType
oneTime),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"continuous" Text -> S3ContinuousClassificationType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= S3ContinuousClassificationType
continuous)
          ]
      )