{-# 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.ElasticSearch.Types.AutoTuneOptions
-- 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.ElasticSearch.Types.AutoTuneOptions where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ElasticSearch.Types.AutoTuneDesiredState
import Amazonka.ElasticSearch.Types.AutoTuneMaintenanceSchedule
import Amazonka.ElasticSearch.Types.RollbackOnDisable
import qualified Amazonka.Prelude as Prelude

-- | Specifies the Auto-Tune options: the Auto-Tune desired state for the
-- domain, rollback state when disabling Auto-Tune options and list of
-- maintenance schedules.
--
-- /See:/ 'newAutoTuneOptions' smart constructor.
data AutoTuneOptions = AutoTuneOptions'
  { -- | Specifies the Auto-Tune desired state. Valid values are ENABLED,
    -- DISABLED.
    AutoTuneOptions -> Maybe AutoTuneDesiredState
desiredState :: Prelude.Maybe AutoTuneDesiredState,
    -- | Specifies list of maitenance schedules. See the
    -- <https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/auto-tune.html Developer Guide>
    -- for more information.
    AutoTuneOptions -> Maybe [AutoTuneMaintenanceSchedule]
maintenanceSchedules :: Prelude.Maybe [AutoTuneMaintenanceSchedule],
    -- | Specifies the rollback state while disabling Auto-Tune for the domain.
    -- Valid values are NO_ROLLBACK, DEFAULT_ROLLBACK.
    AutoTuneOptions -> Maybe RollbackOnDisable
rollbackOnDisable :: Prelude.Maybe RollbackOnDisable
  }
  deriving (AutoTuneOptions -> AutoTuneOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutoTuneOptions -> AutoTuneOptions -> Bool
$c/= :: AutoTuneOptions -> AutoTuneOptions -> Bool
== :: AutoTuneOptions -> AutoTuneOptions -> Bool
$c== :: AutoTuneOptions -> AutoTuneOptions -> Bool
Prelude.Eq, ReadPrec [AutoTuneOptions]
ReadPrec AutoTuneOptions
Int -> ReadS AutoTuneOptions
ReadS [AutoTuneOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AutoTuneOptions]
$creadListPrec :: ReadPrec [AutoTuneOptions]
readPrec :: ReadPrec AutoTuneOptions
$creadPrec :: ReadPrec AutoTuneOptions
readList :: ReadS [AutoTuneOptions]
$creadList :: ReadS [AutoTuneOptions]
readsPrec :: Int -> ReadS AutoTuneOptions
$creadsPrec :: Int -> ReadS AutoTuneOptions
Prelude.Read, Int -> AutoTuneOptions -> ShowS
[AutoTuneOptions] -> ShowS
AutoTuneOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutoTuneOptions] -> ShowS
$cshowList :: [AutoTuneOptions] -> ShowS
show :: AutoTuneOptions -> String
$cshow :: AutoTuneOptions -> String
showsPrec :: Int -> AutoTuneOptions -> ShowS
$cshowsPrec :: Int -> AutoTuneOptions -> ShowS
Prelude.Show, forall x. Rep AutoTuneOptions x -> AutoTuneOptions
forall x. AutoTuneOptions -> Rep AutoTuneOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AutoTuneOptions x -> AutoTuneOptions
$cfrom :: forall x. AutoTuneOptions -> Rep AutoTuneOptions x
Prelude.Generic)

-- |
-- Create a value of 'AutoTuneOptions' 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:
--
-- 'desiredState', 'autoTuneOptions_desiredState' - Specifies the Auto-Tune desired state. Valid values are ENABLED,
-- DISABLED.
--
-- 'maintenanceSchedules', 'autoTuneOptions_maintenanceSchedules' - Specifies list of maitenance schedules. See the
-- <https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/auto-tune.html Developer Guide>
-- for more information.
--
-- 'rollbackOnDisable', 'autoTuneOptions_rollbackOnDisable' - Specifies the rollback state while disabling Auto-Tune for the domain.
-- Valid values are NO_ROLLBACK, DEFAULT_ROLLBACK.
newAutoTuneOptions ::
  AutoTuneOptions
newAutoTuneOptions :: AutoTuneOptions
newAutoTuneOptions =
  AutoTuneOptions'
    { $sel:desiredState:AutoTuneOptions' :: Maybe AutoTuneDesiredState
desiredState = forall a. Maybe a
Prelude.Nothing,
      $sel:maintenanceSchedules:AutoTuneOptions' :: Maybe [AutoTuneMaintenanceSchedule]
maintenanceSchedules = forall a. Maybe a
Prelude.Nothing,
      $sel:rollbackOnDisable:AutoTuneOptions' :: Maybe RollbackOnDisable
rollbackOnDisable = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the Auto-Tune desired state. Valid values are ENABLED,
-- DISABLED.
autoTuneOptions_desiredState :: Lens.Lens' AutoTuneOptions (Prelude.Maybe AutoTuneDesiredState)
autoTuneOptions_desiredState :: Lens' AutoTuneOptions (Maybe AutoTuneDesiredState)
autoTuneOptions_desiredState = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoTuneOptions' {Maybe AutoTuneDesiredState
desiredState :: Maybe AutoTuneDesiredState
$sel:desiredState:AutoTuneOptions' :: AutoTuneOptions -> Maybe AutoTuneDesiredState
desiredState} -> Maybe AutoTuneDesiredState
desiredState) (\s :: AutoTuneOptions
s@AutoTuneOptions' {} Maybe AutoTuneDesiredState
a -> AutoTuneOptions
s {$sel:desiredState:AutoTuneOptions' :: Maybe AutoTuneDesiredState
desiredState = Maybe AutoTuneDesiredState
a} :: AutoTuneOptions)

-- | Specifies list of maitenance schedules. See the
-- <https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/auto-tune.html Developer Guide>
-- for more information.
autoTuneOptions_maintenanceSchedules :: Lens.Lens' AutoTuneOptions (Prelude.Maybe [AutoTuneMaintenanceSchedule])
autoTuneOptions_maintenanceSchedules :: Lens' AutoTuneOptions (Maybe [AutoTuneMaintenanceSchedule])
autoTuneOptions_maintenanceSchedules = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoTuneOptions' {Maybe [AutoTuneMaintenanceSchedule]
maintenanceSchedules :: Maybe [AutoTuneMaintenanceSchedule]
$sel:maintenanceSchedules:AutoTuneOptions' :: AutoTuneOptions -> Maybe [AutoTuneMaintenanceSchedule]
maintenanceSchedules} -> Maybe [AutoTuneMaintenanceSchedule]
maintenanceSchedules) (\s :: AutoTuneOptions
s@AutoTuneOptions' {} Maybe [AutoTuneMaintenanceSchedule]
a -> AutoTuneOptions
s {$sel:maintenanceSchedules:AutoTuneOptions' :: Maybe [AutoTuneMaintenanceSchedule]
maintenanceSchedules = Maybe [AutoTuneMaintenanceSchedule]
a} :: AutoTuneOptions) 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

-- | Specifies the rollback state while disabling Auto-Tune for the domain.
-- Valid values are NO_ROLLBACK, DEFAULT_ROLLBACK.
autoTuneOptions_rollbackOnDisable :: Lens.Lens' AutoTuneOptions (Prelude.Maybe RollbackOnDisable)
autoTuneOptions_rollbackOnDisable :: Lens' AutoTuneOptions (Maybe RollbackOnDisable)
autoTuneOptions_rollbackOnDisable = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoTuneOptions' {Maybe RollbackOnDisable
rollbackOnDisable :: Maybe RollbackOnDisable
$sel:rollbackOnDisable:AutoTuneOptions' :: AutoTuneOptions -> Maybe RollbackOnDisable
rollbackOnDisable} -> Maybe RollbackOnDisable
rollbackOnDisable) (\s :: AutoTuneOptions
s@AutoTuneOptions' {} Maybe RollbackOnDisable
a -> AutoTuneOptions
s {$sel:rollbackOnDisable:AutoTuneOptions' :: Maybe RollbackOnDisable
rollbackOnDisable = Maybe RollbackOnDisable
a} :: AutoTuneOptions)

instance Data.FromJSON AutoTuneOptions where
  parseJSON :: Value -> Parser AutoTuneOptions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AutoTuneOptions"
      ( \Object
x ->
          Maybe AutoTuneDesiredState
-> Maybe [AutoTuneMaintenanceSchedule]
-> Maybe RollbackOnDisable
-> AutoTuneOptions
AutoTuneOptions'
            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
"DesiredState")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"MaintenanceSchedules"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RollbackOnDisable")
      )

instance Prelude.Hashable AutoTuneOptions where
  hashWithSalt :: Int -> AutoTuneOptions -> Int
hashWithSalt Int
_salt AutoTuneOptions' {Maybe [AutoTuneMaintenanceSchedule]
Maybe AutoTuneDesiredState
Maybe RollbackOnDisable
rollbackOnDisable :: Maybe RollbackOnDisable
maintenanceSchedules :: Maybe [AutoTuneMaintenanceSchedule]
desiredState :: Maybe AutoTuneDesiredState
$sel:rollbackOnDisable:AutoTuneOptions' :: AutoTuneOptions -> Maybe RollbackOnDisable
$sel:maintenanceSchedules:AutoTuneOptions' :: AutoTuneOptions -> Maybe [AutoTuneMaintenanceSchedule]
$sel:desiredState:AutoTuneOptions' :: AutoTuneOptions -> Maybe AutoTuneDesiredState
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AutoTuneDesiredState
desiredState
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [AutoTuneMaintenanceSchedule]
maintenanceSchedules
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RollbackOnDisable
rollbackOnDisable

instance Prelude.NFData AutoTuneOptions where
  rnf :: AutoTuneOptions -> ()
rnf AutoTuneOptions' {Maybe [AutoTuneMaintenanceSchedule]
Maybe AutoTuneDesiredState
Maybe RollbackOnDisable
rollbackOnDisable :: Maybe RollbackOnDisable
maintenanceSchedules :: Maybe [AutoTuneMaintenanceSchedule]
desiredState :: Maybe AutoTuneDesiredState
$sel:rollbackOnDisable:AutoTuneOptions' :: AutoTuneOptions -> Maybe RollbackOnDisable
$sel:maintenanceSchedules:AutoTuneOptions' :: AutoTuneOptions -> Maybe [AutoTuneMaintenanceSchedule]
$sel:desiredState:AutoTuneOptions' :: AutoTuneOptions -> Maybe AutoTuneDesiredState
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AutoTuneDesiredState
desiredState
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [AutoTuneMaintenanceSchedule]
maintenanceSchedules
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RollbackOnDisable
rollbackOnDisable

instance Data.ToJSON AutoTuneOptions where
  toJSON :: AutoTuneOptions -> Value
toJSON AutoTuneOptions' {Maybe [AutoTuneMaintenanceSchedule]
Maybe AutoTuneDesiredState
Maybe RollbackOnDisable
rollbackOnDisable :: Maybe RollbackOnDisable
maintenanceSchedules :: Maybe [AutoTuneMaintenanceSchedule]
desiredState :: Maybe AutoTuneDesiredState
$sel:rollbackOnDisable:AutoTuneOptions' :: AutoTuneOptions -> Maybe RollbackOnDisable
$sel:maintenanceSchedules:AutoTuneOptions' :: AutoTuneOptions -> Maybe [AutoTuneMaintenanceSchedule]
$sel:desiredState:AutoTuneOptions' :: AutoTuneOptions -> Maybe AutoTuneDesiredState
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DesiredState" 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 AutoTuneDesiredState
desiredState,
            (Key
"MaintenanceSchedules" 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 [AutoTuneMaintenanceSchedule]
maintenanceSchedules,
            (Key
"RollbackOnDisable" 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 RollbackOnDisable
rollbackOnDisable
          ]
      )