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

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

-- | Specifies a weekly recurrence pattern for running a classification job.
--
-- /See:/ 'newWeeklySchedule' smart constructor.
data WeeklySchedule = WeeklySchedule'
  { -- | The day of the week when Amazon Macie runs the job.
    WeeklySchedule -> Maybe DayOfWeek
dayOfWeek :: Prelude.Maybe DayOfWeek
  }
  deriving (WeeklySchedule -> WeeklySchedule -> Bool
(WeeklySchedule -> WeeklySchedule -> Bool)
-> (WeeklySchedule -> WeeklySchedule -> Bool) -> Eq WeeklySchedule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WeeklySchedule -> WeeklySchedule -> Bool
$c/= :: WeeklySchedule -> WeeklySchedule -> Bool
== :: WeeklySchedule -> WeeklySchedule -> Bool
$c== :: WeeklySchedule -> WeeklySchedule -> Bool
Prelude.Eq, ReadPrec [WeeklySchedule]
ReadPrec WeeklySchedule
Int -> ReadS WeeklySchedule
ReadS [WeeklySchedule]
(Int -> ReadS WeeklySchedule)
-> ReadS [WeeklySchedule]
-> ReadPrec WeeklySchedule
-> ReadPrec [WeeklySchedule]
-> Read WeeklySchedule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WeeklySchedule]
$creadListPrec :: ReadPrec [WeeklySchedule]
readPrec :: ReadPrec WeeklySchedule
$creadPrec :: ReadPrec WeeklySchedule
readList :: ReadS [WeeklySchedule]
$creadList :: ReadS [WeeklySchedule]
readsPrec :: Int -> ReadS WeeklySchedule
$creadsPrec :: Int -> ReadS WeeklySchedule
Prelude.Read, Int -> WeeklySchedule -> ShowS
[WeeklySchedule] -> ShowS
WeeklySchedule -> String
(Int -> WeeklySchedule -> ShowS)
-> (WeeklySchedule -> String)
-> ([WeeklySchedule] -> ShowS)
-> Show WeeklySchedule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WeeklySchedule] -> ShowS
$cshowList :: [WeeklySchedule] -> ShowS
show :: WeeklySchedule -> String
$cshow :: WeeklySchedule -> String
showsPrec :: Int -> WeeklySchedule -> ShowS
$cshowsPrec :: Int -> WeeklySchedule -> ShowS
Prelude.Show, (forall x. WeeklySchedule -> Rep WeeklySchedule x)
-> (forall x. Rep WeeklySchedule x -> WeeklySchedule)
-> Generic WeeklySchedule
forall x. Rep WeeklySchedule x -> WeeklySchedule
forall x. WeeklySchedule -> Rep WeeklySchedule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WeeklySchedule x -> WeeklySchedule
$cfrom :: forall x. WeeklySchedule -> Rep WeeklySchedule x
Prelude.Generic)

-- |
-- Create a value of 'WeeklySchedule' 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:
--
-- 'dayOfWeek', 'weeklySchedule_dayOfWeek' - The day of the week when Amazon Macie runs the job.
newWeeklySchedule ::
  WeeklySchedule
newWeeklySchedule :: WeeklySchedule
newWeeklySchedule =
  WeeklySchedule' :: Maybe DayOfWeek -> WeeklySchedule
WeeklySchedule' {$sel:dayOfWeek:WeeklySchedule' :: Maybe DayOfWeek
dayOfWeek = Maybe DayOfWeek
forall a. Maybe a
Prelude.Nothing}

-- | The day of the week when Amazon Macie runs the job.
weeklySchedule_dayOfWeek :: Lens.Lens' WeeklySchedule (Prelude.Maybe DayOfWeek)
weeklySchedule_dayOfWeek :: (Maybe DayOfWeek -> f (Maybe DayOfWeek))
-> WeeklySchedule -> f WeeklySchedule
weeklySchedule_dayOfWeek = (WeeklySchedule -> Maybe DayOfWeek)
-> (WeeklySchedule -> Maybe DayOfWeek -> WeeklySchedule)
-> Lens
     WeeklySchedule WeeklySchedule (Maybe DayOfWeek) (Maybe DayOfWeek)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WeeklySchedule' {Maybe DayOfWeek
dayOfWeek :: Maybe DayOfWeek
$sel:dayOfWeek:WeeklySchedule' :: WeeklySchedule -> Maybe DayOfWeek
dayOfWeek} -> Maybe DayOfWeek
dayOfWeek) (\s :: WeeklySchedule
s@WeeklySchedule' {} Maybe DayOfWeek
a -> WeeklySchedule
s {$sel:dayOfWeek:WeeklySchedule' :: Maybe DayOfWeek
dayOfWeek = Maybe DayOfWeek
a} :: WeeklySchedule)

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

instance Prelude.Hashable WeeklySchedule

instance Prelude.NFData WeeklySchedule

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