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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(MonthlySchedule -> MonthlySchedule -> Bool)
-> (MonthlySchedule -> MonthlySchedule -> Bool)
-> Eq MonthlySchedule
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]
(Int -> ReadS MonthlySchedule)
-> ReadS [MonthlySchedule]
-> ReadPrec MonthlySchedule
-> ReadPrec [MonthlySchedule]
-> Read 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
(Int -> MonthlySchedule -> ShowS)
-> (MonthlySchedule -> String)
-> ([MonthlySchedule] -> ShowS)
-> Show MonthlySchedule
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. MonthlySchedule -> Rep MonthlySchedule x)
-> (forall x. Rep MonthlySchedule x -> MonthlySchedule)
-> Generic MonthlySchedule
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' :: Maybe Int -> MonthlySchedule
MonthlySchedule' {$sel:dayOfMonth:MonthlySchedule' :: Maybe Int
dayOfMonth = Maybe Int
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 :: (Maybe Int -> f (Maybe Int))
-> MonthlySchedule -> f MonthlySchedule
monthlySchedule_dayOfMonth = (MonthlySchedule -> Maybe Int)
-> (MonthlySchedule -> Maybe Int -> MonthlySchedule)
-> Lens MonthlySchedule MonthlySchedule (Maybe Int) (Maybe Int)
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 Core.FromJSON MonthlySchedule where
  parseJSON :: Value -> Parser MonthlySchedule
parseJSON =
    String
-> (Object -> Parser MonthlySchedule)
-> Value
-> Parser MonthlySchedule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MonthlySchedule"
      ( \Object
x ->
          Maybe Int -> MonthlySchedule
MonthlySchedule'
            (Maybe Int -> MonthlySchedule)
-> Parser (Maybe Int) -> Parser MonthlySchedule
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"dayOfMonth")
      )

instance Prelude.Hashable MonthlySchedule

instance Prelude.NFData MonthlySchedule

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