{-# 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.Lightsail.Types.AutoSnapshotAddOnRequest
-- 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.Lightsail.Types.AutoSnapshotAddOnRequest where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes a request to enable or modify the automatic snapshot add-on
-- for an Amazon Lightsail instance or disk.
--
-- When you modify the automatic snapshot time for a resource, it is
-- typically effective immediately except under the following conditions:
--
-- -   If an automatic snapshot has been created for the current day, and
--     you change the snapshot time to a later time of day, then the new
--     snapshot time will be effective the following day. This ensures that
--     two snapshots are not created for the current day.
--
-- -   If an automatic snapshot has not yet been created for the current
--     day, and you change the snapshot time to an earlier time of day,
--     then the new snapshot time will be effective the following day and a
--     snapshot is automatically created at the previously set time for the
--     current day. This ensures that a snapshot is created for the current
--     day.
--
-- -   If an automatic snapshot has not yet been created for the current
--     day, and you change the snapshot time to a time that is within 30
--     minutes from your current time, then the new snapshot time will be
--     effective the following day and a snapshot is automatically created
--     at the previously set time for the current day. This ensures that a
--     snapshot is created for the current day, because 30 minutes is
--     required between your current time and the new snapshot time that
--     you specify.
--
-- -   If an automatic snapshot is scheduled to be created within 30
--     minutes from your current time and you change the snapshot time,
--     then the new snapshot time will be effective the following day and a
--     snapshot is automatically created at the previously set time for the
--     current day. This ensures that a snapshot is created for the current
--     day, because 30 minutes is required between your current time and
--     the new snapshot time that you specify.
--
-- /See:/ 'newAutoSnapshotAddOnRequest' smart constructor.
data AutoSnapshotAddOnRequest = AutoSnapshotAddOnRequest'
  { -- | The daily time when an automatic snapshot will be created.
    --
    -- Constraints:
    --
    -- -   Must be in @HH:00@ format, and in an hourly increment.
    --
    -- -   Specified in Coordinated Universal Time (UTC).
    --
    -- -   The snapshot will be automatically created between the time
    --     specified and up to 45 minutes after.
    AutoSnapshotAddOnRequest -> Maybe Text
snapshotTimeOfDay :: Prelude.Maybe Prelude.Text
  }
  deriving (AutoSnapshotAddOnRequest -> AutoSnapshotAddOnRequest -> Bool
(AutoSnapshotAddOnRequest -> AutoSnapshotAddOnRequest -> Bool)
-> (AutoSnapshotAddOnRequest -> AutoSnapshotAddOnRequest -> Bool)
-> Eq AutoSnapshotAddOnRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutoSnapshotAddOnRequest -> AutoSnapshotAddOnRequest -> Bool
$c/= :: AutoSnapshotAddOnRequest -> AutoSnapshotAddOnRequest -> Bool
== :: AutoSnapshotAddOnRequest -> AutoSnapshotAddOnRequest -> Bool
$c== :: AutoSnapshotAddOnRequest -> AutoSnapshotAddOnRequest -> Bool
Prelude.Eq, ReadPrec [AutoSnapshotAddOnRequest]
ReadPrec AutoSnapshotAddOnRequest
Int -> ReadS AutoSnapshotAddOnRequest
ReadS [AutoSnapshotAddOnRequest]
(Int -> ReadS AutoSnapshotAddOnRequest)
-> ReadS [AutoSnapshotAddOnRequest]
-> ReadPrec AutoSnapshotAddOnRequest
-> ReadPrec [AutoSnapshotAddOnRequest]
-> Read AutoSnapshotAddOnRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AutoSnapshotAddOnRequest]
$creadListPrec :: ReadPrec [AutoSnapshotAddOnRequest]
readPrec :: ReadPrec AutoSnapshotAddOnRequest
$creadPrec :: ReadPrec AutoSnapshotAddOnRequest
readList :: ReadS [AutoSnapshotAddOnRequest]
$creadList :: ReadS [AutoSnapshotAddOnRequest]
readsPrec :: Int -> ReadS AutoSnapshotAddOnRequest
$creadsPrec :: Int -> ReadS AutoSnapshotAddOnRequest
Prelude.Read, Int -> AutoSnapshotAddOnRequest -> ShowS
[AutoSnapshotAddOnRequest] -> ShowS
AutoSnapshotAddOnRequest -> String
(Int -> AutoSnapshotAddOnRequest -> ShowS)
-> (AutoSnapshotAddOnRequest -> String)
-> ([AutoSnapshotAddOnRequest] -> ShowS)
-> Show AutoSnapshotAddOnRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutoSnapshotAddOnRequest] -> ShowS
$cshowList :: [AutoSnapshotAddOnRequest] -> ShowS
show :: AutoSnapshotAddOnRequest -> String
$cshow :: AutoSnapshotAddOnRequest -> String
showsPrec :: Int -> AutoSnapshotAddOnRequest -> ShowS
$cshowsPrec :: Int -> AutoSnapshotAddOnRequest -> ShowS
Prelude.Show, (forall x.
 AutoSnapshotAddOnRequest -> Rep AutoSnapshotAddOnRequest x)
-> (forall x.
    Rep AutoSnapshotAddOnRequest x -> AutoSnapshotAddOnRequest)
-> Generic AutoSnapshotAddOnRequest
forall x.
Rep AutoSnapshotAddOnRequest x -> AutoSnapshotAddOnRequest
forall x.
AutoSnapshotAddOnRequest -> Rep AutoSnapshotAddOnRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AutoSnapshotAddOnRequest x -> AutoSnapshotAddOnRequest
$cfrom :: forall x.
AutoSnapshotAddOnRequest -> Rep AutoSnapshotAddOnRequest x
Prelude.Generic)

-- |
-- Create a value of 'AutoSnapshotAddOnRequest' 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:
--
-- 'snapshotTimeOfDay', 'autoSnapshotAddOnRequest_snapshotTimeOfDay' - The daily time when an automatic snapshot will be created.
--
-- Constraints:
--
-- -   Must be in @HH:00@ format, and in an hourly increment.
--
-- -   Specified in Coordinated Universal Time (UTC).
--
-- -   The snapshot will be automatically created between the time
--     specified and up to 45 minutes after.
newAutoSnapshotAddOnRequest ::
  AutoSnapshotAddOnRequest
newAutoSnapshotAddOnRequest :: AutoSnapshotAddOnRequest
newAutoSnapshotAddOnRequest =
  AutoSnapshotAddOnRequest' :: Maybe Text -> AutoSnapshotAddOnRequest
AutoSnapshotAddOnRequest'
    { $sel:snapshotTimeOfDay:AutoSnapshotAddOnRequest' :: Maybe Text
snapshotTimeOfDay =
        Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The daily time when an automatic snapshot will be created.
--
-- Constraints:
--
-- -   Must be in @HH:00@ format, and in an hourly increment.
--
-- -   Specified in Coordinated Universal Time (UTC).
--
-- -   The snapshot will be automatically created between the time
--     specified and up to 45 minutes after.
autoSnapshotAddOnRequest_snapshotTimeOfDay :: Lens.Lens' AutoSnapshotAddOnRequest (Prelude.Maybe Prelude.Text)
autoSnapshotAddOnRequest_snapshotTimeOfDay :: (Maybe Text -> f (Maybe Text))
-> AutoSnapshotAddOnRequest -> f AutoSnapshotAddOnRequest
autoSnapshotAddOnRequest_snapshotTimeOfDay = (AutoSnapshotAddOnRequest -> Maybe Text)
-> (AutoSnapshotAddOnRequest
    -> Maybe Text -> AutoSnapshotAddOnRequest)
-> Lens
     AutoSnapshotAddOnRequest
     AutoSnapshotAddOnRequest
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoSnapshotAddOnRequest' {Maybe Text
snapshotTimeOfDay :: Maybe Text
$sel:snapshotTimeOfDay:AutoSnapshotAddOnRequest' :: AutoSnapshotAddOnRequest -> Maybe Text
snapshotTimeOfDay} -> Maybe Text
snapshotTimeOfDay) (\s :: AutoSnapshotAddOnRequest
s@AutoSnapshotAddOnRequest' {} Maybe Text
a -> AutoSnapshotAddOnRequest
s {$sel:snapshotTimeOfDay:AutoSnapshotAddOnRequest' :: Maybe Text
snapshotTimeOfDay = Maybe Text
a} :: AutoSnapshotAddOnRequest)

instance Prelude.Hashable AutoSnapshotAddOnRequest

instance Prelude.NFData AutoSnapshotAddOnRequest

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