{-# 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.OpenSearch.Types.AutoTuneMaintenanceSchedule
-- 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.OpenSearch.Types.AutoTuneMaintenanceSchedule where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpenSearch.Types.Duration
import qualified Amazonka.Prelude as Prelude

-- | Specifies the Auto-Tune maintenance schedule. See
-- <https://docs.aws.amazon.com/opensearch-service/latest/developerguide/auto-tune.html Auto-Tune for Amazon OpenSearch Service>
-- for more information.
--
-- /See:/ 'newAutoTuneMaintenanceSchedule' smart constructor.
data AutoTuneMaintenanceSchedule = AutoTuneMaintenanceSchedule'
  { -- | The timestamp at which the Auto-Tune maintenance schedule starts.
    AutoTuneMaintenanceSchedule -> Maybe POSIX
startAt :: Prelude.Maybe Core.POSIX,
    -- | A cron expression for a recurring maintenance schedule. See
    -- <https://docs.aws.amazon.com/opensearch-service/latest/developerguide/auto-tune.html Auto-Tune for Amazon OpenSearch Service>
    -- for more information.
    AutoTuneMaintenanceSchedule -> Maybe Text
cronExpressionForRecurrence :: Prelude.Maybe Prelude.Text,
    -- | Specifies maintenance schedule duration: duration value and duration
    -- unit. See
    -- <https://docs.aws.amazon.com/opensearch-service/latest/developerguide/auto-tune.html Auto-Tune for Amazon OpenSearch Service>
    -- for more information.
    AutoTuneMaintenanceSchedule -> Maybe Duration
duration :: Prelude.Maybe Duration
  }
  deriving (AutoTuneMaintenanceSchedule -> AutoTuneMaintenanceSchedule -> Bool
(AutoTuneMaintenanceSchedule
 -> AutoTuneMaintenanceSchedule -> Bool)
-> (AutoTuneMaintenanceSchedule
    -> AutoTuneMaintenanceSchedule -> Bool)
-> Eq AutoTuneMaintenanceSchedule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutoTuneMaintenanceSchedule -> AutoTuneMaintenanceSchedule -> Bool
$c/= :: AutoTuneMaintenanceSchedule -> AutoTuneMaintenanceSchedule -> Bool
== :: AutoTuneMaintenanceSchedule -> AutoTuneMaintenanceSchedule -> Bool
$c== :: AutoTuneMaintenanceSchedule -> AutoTuneMaintenanceSchedule -> Bool
Prelude.Eq, ReadPrec [AutoTuneMaintenanceSchedule]
ReadPrec AutoTuneMaintenanceSchedule
Int -> ReadS AutoTuneMaintenanceSchedule
ReadS [AutoTuneMaintenanceSchedule]
(Int -> ReadS AutoTuneMaintenanceSchedule)
-> ReadS [AutoTuneMaintenanceSchedule]
-> ReadPrec AutoTuneMaintenanceSchedule
-> ReadPrec [AutoTuneMaintenanceSchedule]
-> Read AutoTuneMaintenanceSchedule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AutoTuneMaintenanceSchedule]
$creadListPrec :: ReadPrec [AutoTuneMaintenanceSchedule]
readPrec :: ReadPrec AutoTuneMaintenanceSchedule
$creadPrec :: ReadPrec AutoTuneMaintenanceSchedule
readList :: ReadS [AutoTuneMaintenanceSchedule]
$creadList :: ReadS [AutoTuneMaintenanceSchedule]
readsPrec :: Int -> ReadS AutoTuneMaintenanceSchedule
$creadsPrec :: Int -> ReadS AutoTuneMaintenanceSchedule
Prelude.Read, Int -> AutoTuneMaintenanceSchedule -> ShowS
[AutoTuneMaintenanceSchedule] -> ShowS
AutoTuneMaintenanceSchedule -> String
(Int -> AutoTuneMaintenanceSchedule -> ShowS)
-> (AutoTuneMaintenanceSchedule -> String)
-> ([AutoTuneMaintenanceSchedule] -> ShowS)
-> Show AutoTuneMaintenanceSchedule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutoTuneMaintenanceSchedule] -> ShowS
$cshowList :: [AutoTuneMaintenanceSchedule] -> ShowS
show :: AutoTuneMaintenanceSchedule -> String
$cshow :: AutoTuneMaintenanceSchedule -> String
showsPrec :: Int -> AutoTuneMaintenanceSchedule -> ShowS
$cshowsPrec :: Int -> AutoTuneMaintenanceSchedule -> ShowS
Prelude.Show, (forall x.
 AutoTuneMaintenanceSchedule -> Rep AutoTuneMaintenanceSchedule x)
-> (forall x.
    Rep AutoTuneMaintenanceSchedule x -> AutoTuneMaintenanceSchedule)
-> Generic AutoTuneMaintenanceSchedule
forall x.
Rep AutoTuneMaintenanceSchedule x -> AutoTuneMaintenanceSchedule
forall x.
AutoTuneMaintenanceSchedule -> Rep AutoTuneMaintenanceSchedule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AutoTuneMaintenanceSchedule x -> AutoTuneMaintenanceSchedule
$cfrom :: forall x.
AutoTuneMaintenanceSchedule -> Rep AutoTuneMaintenanceSchedule x
Prelude.Generic)

-- |
-- Create a value of 'AutoTuneMaintenanceSchedule' 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:
--
-- 'startAt', 'autoTuneMaintenanceSchedule_startAt' - The timestamp at which the Auto-Tune maintenance schedule starts.
--
-- 'cronExpressionForRecurrence', 'autoTuneMaintenanceSchedule_cronExpressionForRecurrence' - A cron expression for a recurring maintenance schedule. See
-- <https://docs.aws.amazon.com/opensearch-service/latest/developerguide/auto-tune.html Auto-Tune for Amazon OpenSearch Service>
-- for more information.
--
-- 'duration', 'autoTuneMaintenanceSchedule_duration' - Specifies maintenance schedule duration: duration value and duration
-- unit. See
-- <https://docs.aws.amazon.com/opensearch-service/latest/developerguide/auto-tune.html Auto-Tune for Amazon OpenSearch Service>
-- for more information.
newAutoTuneMaintenanceSchedule ::
  AutoTuneMaintenanceSchedule
newAutoTuneMaintenanceSchedule :: AutoTuneMaintenanceSchedule
newAutoTuneMaintenanceSchedule =
  AutoTuneMaintenanceSchedule' :: Maybe POSIX
-> Maybe Text -> Maybe Duration -> AutoTuneMaintenanceSchedule
AutoTuneMaintenanceSchedule'
    { $sel:startAt:AutoTuneMaintenanceSchedule' :: Maybe POSIX
startAt =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:cronExpressionForRecurrence:AutoTuneMaintenanceSchedule' :: Maybe Text
cronExpressionForRecurrence = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:duration:AutoTuneMaintenanceSchedule' :: Maybe Duration
duration = Maybe Duration
forall a. Maybe a
Prelude.Nothing
    }

-- | The timestamp at which the Auto-Tune maintenance schedule starts.
autoTuneMaintenanceSchedule_startAt :: Lens.Lens' AutoTuneMaintenanceSchedule (Prelude.Maybe Prelude.UTCTime)
autoTuneMaintenanceSchedule_startAt :: (Maybe UTCTime -> f (Maybe UTCTime))
-> AutoTuneMaintenanceSchedule -> f AutoTuneMaintenanceSchedule
autoTuneMaintenanceSchedule_startAt = (AutoTuneMaintenanceSchedule -> Maybe POSIX)
-> (AutoTuneMaintenanceSchedule
    -> Maybe POSIX -> AutoTuneMaintenanceSchedule)
-> Lens
     AutoTuneMaintenanceSchedule
     AutoTuneMaintenanceSchedule
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoTuneMaintenanceSchedule' {Maybe POSIX
startAt :: Maybe POSIX
$sel:startAt:AutoTuneMaintenanceSchedule' :: AutoTuneMaintenanceSchedule -> Maybe POSIX
startAt} -> Maybe POSIX
startAt) (\s :: AutoTuneMaintenanceSchedule
s@AutoTuneMaintenanceSchedule' {} Maybe POSIX
a -> AutoTuneMaintenanceSchedule
s {$sel:startAt:AutoTuneMaintenanceSchedule' :: Maybe POSIX
startAt = Maybe POSIX
a} :: AutoTuneMaintenanceSchedule) ((Maybe POSIX -> f (Maybe POSIX))
 -> AutoTuneMaintenanceSchedule -> f AutoTuneMaintenanceSchedule)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> AutoTuneMaintenanceSchedule
-> f AutoTuneMaintenanceSchedule
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | A cron expression for a recurring maintenance schedule. See
-- <https://docs.aws.amazon.com/opensearch-service/latest/developerguide/auto-tune.html Auto-Tune for Amazon OpenSearch Service>
-- for more information.
autoTuneMaintenanceSchedule_cronExpressionForRecurrence :: Lens.Lens' AutoTuneMaintenanceSchedule (Prelude.Maybe Prelude.Text)
autoTuneMaintenanceSchedule_cronExpressionForRecurrence :: (Maybe Text -> f (Maybe Text))
-> AutoTuneMaintenanceSchedule -> f AutoTuneMaintenanceSchedule
autoTuneMaintenanceSchedule_cronExpressionForRecurrence = (AutoTuneMaintenanceSchedule -> Maybe Text)
-> (AutoTuneMaintenanceSchedule
    -> Maybe Text -> AutoTuneMaintenanceSchedule)
-> Lens
     AutoTuneMaintenanceSchedule
     AutoTuneMaintenanceSchedule
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoTuneMaintenanceSchedule' {Maybe Text
cronExpressionForRecurrence :: Maybe Text
$sel:cronExpressionForRecurrence:AutoTuneMaintenanceSchedule' :: AutoTuneMaintenanceSchedule -> Maybe Text
cronExpressionForRecurrence} -> Maybe Text
cronExpressionForRecurrence) (\s :: AutoTuneMaintenanceSchedule
s@AutoTuneMaintenanceSchedule' {} Maybe Text
a -> AutoTuneMaintenanceSchedule
s {$sel:cronExpressionForRecurrence:AutoTuneMaintenanceSchedule' :: Maybe Text
cronExpressionForRecurrence = Maybe Text
a} :: AutoTuneMaintenanceSchedule)

-- | Specifies maintenance schedule duration: duration value and duration
-- unit. See
-- <https://docs.aws.amazon.com/opensearch-service/latest/developerguide/auto-tune.html Auto-Tune for Amazon OpenSearch Service>
-- for more information.
autoTuneMaintenanceSchedule_duration :: Lens.Lens' AutoTuneMaintenanceSchedule (Prelude.Maybe Duration)
autoTuneMaintenanceSchedule_duration :: (Maybe Duration -> f (Maybe Duration))
-> AutoTuneMaintenanceSchedule -> f AutoTuneMaintenanceSchedule
autoTuneMaintenanceSchedule_duration = (AutoTuneMaintenanceSchedule -> Maybe Duration)
-> (AutoTuneMaintenanceSchedule
    -> Maybe Duration -> AutoTuneMaintenanceSchedule)
-> Lens
     AutoTuneMaintenanceSchedule
     AutoTuneMaintenanceSchedule
     (Maybe Duration)
     (Maybe Duration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoTuneMaintenanceSchedule' {Maybe Duration
duration :: Maybe Duration
$sel:duration:AutoTuneMaintenanceSchedule' :: AutoTuneMaintenanceSchedule -> Maybe Duration
duration} -> Maybe Duration
duration) (\s :: AutoTuneMaintenanceSchedule
s@AutoTuneMaintenanceSchedule' {} Maybe Duration
a -> AutoTuneMaintenanceSchedule
s {$sel:duration:AutoTuneMaintenanceSchedule' :: Maybe Duration
duration = Maybe Duration
a} :: AutoTuneMaintenanceSchedule)

instance Core.FromJSON AutoTuneMaintenanceSchedule where
  parseJSON :: Value -> Parser AutoTuneMaintenanceSchedule
parseJSON =
    String
-> (Object -> Parser AutoTuneMaintenanceSchedule)
-> Value
-> Parser AutoTuneMaintenanceSchedule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AutoTuneMaintenanceSchedule"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Text -> Maybe Duration -> AutoTuneMaintenanceSchedule
AutoTuneMaintenanceSchedule'
            (Maybe POSIX
 -> Maybe Text -> Maybe Duration -> AutoTuneMaintenanceSchedule)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text -> Maybe Duration -> AutoTuneMaintenanceSchedule)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StartAt")
            Parser
  (Maybe Text -> Maybe Duration -> AutoTuneMaintenanceSchedule)
-> Parser (Maybe Text)
-> Parser (Maybe Duration -> AutoTuneMaintenanceSchedule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CronExpressionForRecurrence")
            Parser (Maybe Duration -> AutoTuneMaintenanceSchedule)
-> Parser (Maybe Duration) -> Parser AutoTuneMaintenanceSchedule
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Duration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Duration")
      )

instance Prelude.Hashable AutoTuneMaintenanceSchedule

instance Prelude.NFData AutoTuneMaintenanceSchedule

instance Core.ToJSON AutoTuneMaintenanceSchedule where
  toJSON :: AutoTuneMaintenanceSchedule -> Value
toJSON AutoTuneMaintenanceSchedule' {Maybe Text
Maybe POSIX
Maybe Duration
duration :: Maybe Duration
cronExpressionForRecurrence :: Maybe Text
startAt :: Maybe POSIX
$sel:duration:AutoTuneMaintenanceSchedule' :: AutoTuneMaintenanceSchedule -> Maybe Duration
$sel:cronExpressionForRecurrence:AutoTuneMaintenanceSchedule' :: AutoTuneMaintenanceSchedule -> Maybe Text
$sel:startAt:AutoTuneMaintenanceSchedule' :: AutoTuneMaintenanceSchedule -> Maybe POSIX
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"StartAt" Text -> POSIX -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (POSIX -> Pair) -> Maybe POSIX -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe POSIX
startAt,
            (Text
"CronExpressionForRecurrence" 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
cronExpressionForRecurrence,
            (Text
"Duration" Text -> Duration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Duration -> Pair) -> Maybe Duration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Duration
duration
          ]
      )