{-# 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.MonthlySchedule
-- 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.MonthlySchedule 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 a monthly recurrence pattern for running a classification job.
--
-- /See:/ 'newMonthlySchedule' smart constructor.
data MonthlySchedule = MonthlySchedule'
  { -- | The numeric day of the month when Amazon Macie runs the job. This value
    -- can be an integer from 1 through 31.
    --
    -- If this value exceeds the number of days in a certain month, Macie
    -- doesn\'t run the job that month. Macie runs the job only during months
    -- that have the specified day. For example, if this value is 31 and a
    -- month has only 30 days, Macie doesn\'t run the job that month. To run
    -- the job every month, specify a value that\'s less than 29.
    MonthlySchedule -> Maybe Int
dayOfMonth :: Prelude.Maybe Prelude.Int
  }
  deriving (MonthlySchedule -> MonthlySchedule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MonthlySchedule -> MonthlySchedule -> Bool
$c/= :: MonthlySchedule -> MonthlySchedule -> Bool
== :: MonthlySchedule -> MonthlySchedule -> Bool
$c== :: MonthlySchedule -> MonthlySchedule -> Bool
Prelude.Eq, ReadPrec [MonthlySchedule]
ReadPrec MonthlySchedule
Int -> ReadS MonthlySchedule
ReadS [MonthlySchedule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MonthlySchedule]
$creadListPrec :: ReadPrec [MonthlySchedule]
readPrec :: ReadPrec MonthlySchedule
$creadPrec :: ReadPrec MonthlySchedule
readList :: ReadS [MonthlySchedule]
$creadList :: ReadS [MonthlySchedule]
readsPrec :: Int -> ReadS MonthlySchedule
$creadsPrec :: Int -> ReadS MonthlySchedule
Prelude.Read, Int -> MonthlySchedule -> ShowS
[MonthlySchedule] -> ShowS
MonthlySchedule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MonthlySchedule] -> ShowS
$cshowList :: [MonthlySchedule] -> ShowS
show :: MonthlySchedule -> String
$cshow :: MonthlySchedule -> String
showsPrec :: Int -> MonthlySchedule -> ShowS
$cshowsPrec :: Int -> MonthlySchedule -> ShowS
Prelude.Show, forall x. Rep MonthlySchedule x -> MonthlySchedule
forall x. MonthlySchedule -> Rep MonthlySchedule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MonthlySchedule x -> MonthlySchedule
$cfrom :: forall x. MonthlySchedule -> Rep MonthlySchedule x
Prelude.Generic)

-- |
-- Create a value of 'MonthlySchedule' 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:
--
-- 'dayOfMonth', 'monthlySchedule_dayOfMonth' - The numeric day of the month when Amazon Macie runs the job. This value
-- can be an integer from 1 through 31.
--
-- If this value exceeds the number of days in a certain month, Macie
-- doesn\'t run the job that month. Macie runs the job only during months
-- that have the specified day. For example, if this value is 31 and a
-- month has only 30 days, Macie doesn\'t run the job that month. To run
-- the job every month, specify a value that\'s less than 29.
newMonthlySchedule ::
  MonthlySchedule
newMonthlySchedule :: MonthlySchedule
newMonthlySchedule =
  MonthlySchedule' {$sel:dayOfMonth:MonthlySchedule' :: Maybe Int
dayOfMonth = forall a. Maybe a
Prelude.Nothing}

-- | The numeric day of the month when Amazon Macie runs the job. This value
-- can be an integer from 1 through 31.
--
-- If this value exceeds the number of days in a certain month, Macie
-- doesn\'t run the job that month. Macie runs the job only during months
-- that have the specified day. For example, if this value is 31 and a
-- month has only 30 days, Macie doesn\'t run the job that month. To run
-- the job every month, specify a value that\'s less than 29.
monthlySchedule_dayOfMonth :: Lens.Lens' MonthlySchedule (Prelude.Maybe Prelude.Int)
monthlySchedule_dayOfMonth :: Lens' MonthlySchedule (Maybe Int)
monthlySchedule_dayOfMonth = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MonthlySchedule' {Maybe Int
dayOfMonth :: Maybe Int
$sel:dayOfMonth:MonthlySchedule' :: MonthlySchedule -> Maybe Int
dayOfMonth} -> Maybe Int
dayOfMonth) (\s :: MonthlySchedule
s@MonthlySchedule' {} Maybe Int
a -> MonthlySchedule
s {$sel:dayOfMonth:MonthlySchedule' :: Maybe Int
dayOfMonth = Maybe Int
a} :: MonthlySchedule)

instance Data.FromJSON MonthlySchedule where
  parseJSON :: Value -> Parser MonthlySchedule
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MonthlySchedule"
      ( \Object
x ->
          Maybe Int -> MonthlySchedule
MonthlySchedule'
            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
"dayOfMonth")
      )

instance Prelude.Hashable MonthlySchedule where
  hashWithSalt :: Int -> MonthlySchedule -> Int
hashWithSalt Int
_salt MonthlySchedule' {Maybe Int
dayOfMonth :: Maybe Int
$sel:dayOfMonth:MonthlySchedule' :: MonthlySchedule -> Maybe Int
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
dayOfMonth

instance Prelude.NFData MonthlySchedule where
  rnf :: MonthlySchedule -> ()
rnf MonthlySchedule' {Maybe Int
dayOfMonth :: Maybe Int
$sel:dayOfMonth:MonthlySchedule' :: MonthlySchedule -> Maybe Int
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
dayOfMonth

instance Data.ToJSON MonthlySchedule where
  toJSON :: MonthlySchedule -> Value
toJSON MonthlySchedule' {Maybe Int
dayOfMonth :: Maybe Int
$sel:dayOfMonth:MonthlySchedule' :: MonthlySchedule -> Maybe Int
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"dayOfMonth" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
dayOfMonth]
      )