{-# 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.EC2.Types.ScheduledInstanceRecurrence
-- 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.EC2.Types.ScheduledInstanceRecurrence where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import qualified Amazonka.Prelude as Prelude

-- | Describes the recurring schedule for a Scheduled Instance.
--
-- /See:/ 'newScheduledInstanceRecurrence' smart constructor.
data ScheduledInstanceRecurrence = ScheduledInstanceRecurrence'
  { -- | The frequency (@Daily@, @Weekly@, or @Monthly@).
    ScheduledInstanceRecurrence -> Maybe Text
frequency :: Prelude.Maybe Prelude.Text,
    -- | The interval quantity. The interval unit depends on the value of
    -- @frequency@. For example, every 2 weeks or every 2 months.
    ScheduledInstanceRecurrence -> Maybe Int
interval :: Prelude.Maybe Prelude.Int,
    -- | The days. For a monthly schedule, this is one or more days of the month
    -- (1-31). For a weekly schedule, this is one or more days of the week
    -- (1-7, where 1 is Sunday).
    ScheduledInstanceRecurrence -> Maybe [Int]
occurrenceDaySet :: Prelude.Maybe [Prelude.Int],
    -- | Indicates whether the occurrence is relative to the end of the specified
    -- week or month.
    ScheduledInstanceRecurrence -> Maybe Bool
occurrenceRelativeToEnd :: Prelude.Maybe Prelude.Bool,
    -- | The unit for @occurrenceDaySet@ (@DayOfWeek@ or @DayOfMonth@).
    ScheduledInstanceRecurrence -> Maybe Text
occurrenceUnit :: Prelude.Maybe Prelude.Text
  }
  deriving (ScheduledInstanceRecurrence -> ScheduledInstanceRecurrence -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScheduledInstanceRecurrence -> ScheduledInstanceRecurrence -> Bool
$c/= :: ScheduledInstanceRecurrence -> ScheduledInstanceRecurrence -> Bool
== :: ScheduledInstanceRecurrence -> ScheduledInstanceRecurrence -> Bool
$c== :: ScheduledInstanceRecurrence -> ScheduledInstanceRecurrence -> Bool
Prelude.Eq, ReadPrec [ScheduledInstanceRecurrence]
ReadPrec ScheduledInstanceRecurrence
Int -> ReadS ScheduledInstanceRecurrence
ReadS [ScheduledInstanceRecurrence]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScheduledInstanceRecurrence]
$creadListPrec :: ReadPrec [ScheduledInstanceRecurrence]
readPrec :: ReadPrec ScheduledInstanceRecurrence
$creadPrec :: ReadPrec ScheduledInstanceRecurrence
readList :: ReadS [ScheduledInstanceRecurrence]
$creadList :: ReadS [ScheduledInstanceRecurrence]
readsPrec :: Int -> ReadS ScheduledInstanceRecurrence
$creadsPrec :: Int -> ReadS ScheduledInstanceRecurrence
Prelude.Read, Int -> ScheduledInstanceRecurrence -> ShowS
[ScheduledInstanceRecurrence] -> ShowS
ScheduledInstanceRecurrence -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScheduledInstanceRecurrence] -> ShowS
$cshowList :: [ScheduledInstanceRecurrence] -> ShowS
show :: ScheduledInstanceRecurrence -> String
$cshow :: ScheduledInstanceRecurrence -> String
showsPrec :: Int -> ScheduledInstanceRecurrence -> ShowS
$cshowsPrec :: Int -> ScheduledInstanceRecurrence -> ShowS
Prelude.Show, forall x.
Rep ScheduledInstanceRecurrence x -> ScheduledInstanceRecurrence
forall x.
ScheduledInstanceRecurrence -> Rep ScheduledInstanceRecurrence x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ScheduledInstanceRecurrence x -> ScheduledInstanceRecurrence
$cfrom :: forall x.
ScheduledInstanceRecurrence -> Rep ScheduledInstanceRecurrence x
Prelude.Generic)

-- |
-- Create a value of 'ScheduledInstanceRecurrence' 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:
--
-- 'frequency', 'scheduledInstanceRecurrence_frequency' - The frequency (@Daily@, @Weekly@, or @Monthly@).
--
-- 'interval', 'scheduledInstanceRecurrence_interval' - The interval quantity. The interval unit depends on the value of
-- @frequency@. For example, every 2 weeks or every 2 months.
--
-- 'occurrenceDaySet', 'scheduledInstanceRecurrence_occurrenceDaySet' - The days. For a monthly schedule, this is one or more days of the month
-- (1-31). For a weekly schedule, this is one or more days of the week
-- (1-7, where 1 is Sunday).
--
-- 'occurrenceRelativeToEnd', 'scheduledInstanceRecurrence_occurrenceRelativeToEnd' - Indicates whether the occurrence is relative to the end of the specified
-- week or month.
--
-- 'occurrenceUnit', 'scheduledInstanceRecurrence_occurrenceUnit' - The unit for @occurrenceDaySet@ (@DayOfWeek@ or @DayOfMonth@).
newScheduledInstanceRecurrence ::
  ScheduledInstanceRecurrence
newScheduledInstanceRecurrence :: ScheduledInstanceRecurrence
newScheduledInstanceRecurrence =
  ScheduledInstanceRecurrence'
    { $sel:frequency:ScheduledInstanceRecurrence' :: Maybe Text
frequency =
        forall a. Maybe a
Prelude.Nothing,
      $sel:interval:ScheduledInstanceRecurrence' :: Maybe Int
interval = forall a. Maybe a
Prelude.Nothing,
      $sel:occurrenceDaySet:ScheduledInstanceRecurrence' :: Maybe [Int]
occurrenceDaySet = forall a. Maybe a
Prelude.Nothing,
      $sel:occurrenceRelativeToEnd:ScheduledInstanceRecurrence' :: Maybe Bool
occurrenceRelativeToEnd = forall a. Maybe a
Prelude.Nothing,
      $sel:occurrenceUnit:ScheduledInstanceRecurrence' :: Maybe Text
occurrenceUnit = forall a. Maybe a
Prelude.Nothing
    }

-- | The frequency (@Daily@, @Weekly@, or @Monthly@).
scheduledInstanceRecurrence_frequency :: Lens.Lens' ScheduledInstanceRecurrence (Prelude.Maybe Prelude.Text)
scheduledInstanceRecurrence_frequency :: Lens' ScheduledInstanceRecurrence (Maybe Text)
scheduledInstanceRecurrence_frequency = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduledInstanceRecurrence' {Maybe Text
frequency :: Maybe Text
$sel:frequency:ScheduledInstanceRecurrence' :: ScheduledInstanceRecurrence -> Maybe Text
frequency} -> Maybe Text
frequency) (\s :: ScheduledInstanceRecurrence
s@ScheduledInstanceRecurrence' {} Maybe Text
a -> ScheduledInstanceRecurrence
s {$sel:frequency:ScheduledInstanceRecurrence' :: Maybe Text
frequency = Maybe Text
a} :: ScheduledInstanceRecurrence)

-- | The interval quantity. The interval unit depends on the value of
-- @frequency@. For example, every 2 weeks or every 2 months.
scheduledInstanceRecurrence_interval :: Lens.Lens' ScheduledInstanceRecurrence (Prelude.Maybe Prelude.Int)
scheduledInstanceRecurrence_interval :: Lens' ScheduledInstanceRecurrence (Maybe Int)
scheduledInstanceRecurrence_interval = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduledInstanceRecurrence' {Maybe Int
interval :: Maybe Int
$sel:interval:ScheduledInstanceRecurrence' :: ScheduledInstanceRecurrence -> Maybe Int
interval} -> Maybe Int
interval) (\s :: ScheduledInstanceRecurrence
s@ScheduledInstanceRecurrence' {} Maybe Int
a -> ScheduledInstanceRecurrence
s {$sel:interval:ScheduledInstanceRecurrence' :: Maybe Int
interval = Maybe Int
a} :: ScheduledInstanceRecurrence)

-- | The days. For a monthly schedule, this is one or more days of the month
-- (1-31). For a weekly schedule, this is one or more days of the week
-- (1-7, where 1 is Sunday).
scheduledInstanceRecurrence_occurrenceDaySet :: Lens.Lens' ScheduledInstanceRecurrence (Prelude.Maybe [Prelude.Int])
scheduledInstanceRecurrence_occurrenceDaySet :: Lens' ScheduledInstanceRecurrence (Maybe [Int])
scheduledInstanceRecurrence_occurrenceDaySet = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduledInstanceRecurrence' {Maybe [Int]
occurrenceDaySet :: Maybe [Int]
$sel:occurrenceDaySet:ScheduledInstanceRecurrence' :: ScheduledInstanceRecurrence -> Maybe [Int]
occurrenceDaySet} -> Maybe [Int]
occurrenceDaySet) (\s :: ScheduledInstanceRecurrence
s@ScheduledInstanceRecurrence' {} Maybe [Int]
a -> ScheduledInstanceRecurrence
s {$sel:occurrenceDaySet:ScheduledInstanceRecurrence' :: Maybe [Int]
occurrenceDaySet = Maybe [Int]
a} :: ScheduledInstanceRecurrence) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Indicates whether the occurrence is relative to the end of the specified
-- week or month.
scheduledInstanceRecurrence_occurrenceRelativeToEnd :: Lens.Lens' ScheduledInstanceRecurrence (Prelude.Maybe Prelude.Bool)
scheduledInstanceRecurrence_occurrenceRelativeToEnd :: Lens' ScheduledInstanceRecurrence (Maybe Bool)
scheduledInstanceRecurrence_occurrenceRelativeToEnd = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduledInstanceRecurrence' {Maybe Bool
occurrenceRelativeToEnd :: Maybe Bool
$sel:occurrenceRelativeToEnd:ScheduledInstanceRecurrence' :: ScheduledInstanceRecurrence -> Maybe Bool
occurrenceRelativeToEnd} -> Maybe Bool
occurrenceRelativeToEnd) (\s :: ScheduledInstanceRecurrence
s@ScheduledInstanceRecurrence' {} Maybe Bool
a -> ScheduledInstanceRecurrence
s {$sel:occurrenceRelativeToEnd:ScheduledInstanceRecurrence' :: Maybe Bool
occurrenceRelativeToEnd = Maybe Bool
a} :: ScheduledInstanceRecurrence)

-- | The unit for @occurrenceDaySet@ (@DayOfWeek@ or @DayOfMonth@).
scheduledInstanceRecurrence_occurrenceUnit :: Lens.Lens' ScheduledInstanceRecurrence (Prelude.Maybe Prelude.Text)
scheduledInstanceRecurrence_occurrenceUnit :: Lens' ScheduledInstanceRecurrence (Maybe Text)
scheduledInstanceRecurrence_occurrenceUnit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScheduledInstanceRecurrence' {Maybe Text
occurrenceUnit :: Maybe Text
$sel:occurrenceUnit:ScheduledInstanceRecurrence' :: ScheduledInstanceRecurrence -> Maybe Text
occurrenceUnit} -> Maybe Text
occurrenceUnit) (\s :: ScheduledInstanceRecurrence
s@ScheduledInstanceRecurrence' {} Maybe Text
a -> ScheduledInstanceRecurrence
s {$sel:occurrenceUnit:ScheduledInstanceRecurrence' :: Maybe Text
occurrenceUnit = Maybe Text
a} :: ScheduledInstanceRecurrence)

instance Data.FromXML ScheduledInstanceRecurrence where
  parseXML :: [Node] -> Either String ScheduledInstanceRecurrence
parseXML [Node]
x =
    Maybe Text
-> Maybe Int
-> Maybe [Int]
-> Maybe Bool
-> Maybe Text
-> ScheduledInstanceRecurrence
ScheduledInstanceRecurrence'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"frequency")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"interval")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"occurrenceDaySet"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"item")
                  )
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"occurrenceRelativeToEnd")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"occurrenceUnit")

instance Prelude.Hashable ScheduledInstanceRecurrence where
  hashWithSalt :: Int -> ScheduledInstanceRecurrence -> Int
hashWithSalt Int
_salt ScheduledInstanceRecurrence' {Maybe Bool
Maybe Int
Maybe [Int]
Maybe Text
occurrenceUnit :: Maybe Text
occurrenceRelativeToEnd :: Maybe Bool
occurrenceDaySet :: Maybe [Int]
interval :: Maybe Int
frequency :: Maybe Text
$sel:occurrenceUnit:ScheduledInstanceRecurrence' :: ScheduledInstanceRecurrence -> Maybe Text
$sel:occurrenceRelativeToEnd:ScheduledInstanceRecurrence' :: ScheduledInstanceRecurrence -> Maybe Bool
$sel:occurrenceDaySet:ScheduledInstanceRecurrence' :: ScheduledInstanceRecurrence -> Maybe [Int]
$sel:interval:ScheduledInstanceRecurrence' :: ScheduledInstanceRecurrence -> Maybe Int
$sel:frequency:ScheduledInstanceRecurrence' :: ScheduledInstanceRecurrence -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
frequency
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
interval
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Int]
occurrenceDaySet
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
occurrenceRelativeToEnd
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
occurrenceUnit

instance Prelude.NFData ScheduledInstanceRecurrence where
  rnf :: ScheduledInstanceRecurrence -> ()
rnf ScheduledInstanceRecurrence' {Maybe Bool
Maybe Int
Maybe [Int]
Maybe Text
occurrenceUnit :: Maybe Text
occurrenceRelativeToEnd :: Maybe Bool
occurrenceDaySet :: Maybe [Int]
interval :: Maybe Int
frequency :: Maybe Text
$sel:occurrenceUnit:ScheduledInstanceRecurrence' :: ScheduledInstanceRecurrence -> Maybe Text
$sel:occurrenceRelativeToEnd:ScheduledInstanceRecurrence' :: ScheduledInstanceRecurrence -> Maybe Bool
$sel:occurrenceDaySet:ScheduledInstanceRecurrence' :: ScheduledInstanceRecurrence -> Maybe [Int]
$sel:interval:ScheduledInstanceRecurrence' :: ScheduledInstanceRecurrence -> Maybe Int
$sel:frequency:ScheduledInstanceRecurrence' :: ScheduledInstanceRecurrence -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
frequency
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
interval
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Int]
occurrenceDaySet
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
occurrenceRelativeToEnd
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
occurrenceUnit