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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.OpenSearch.Types.AutoTuneDesiredState
import Amazonka.OpenSearch.Types.AutoTuneMaintenanceSchedule
import Amazonka.OpenSearch.Types.RollbackOnDisable
import qualified Amazonka.Prelude as Prelude

-- | 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'
  { -- | The Auto-Tune desired state. Valid values are ENABLED and DISABLED.
    AutoTuneOptions -> Maybe AutoTuneDesiredState
desiredState :: Prelude.Maybe AutoTuneDesiredState,
    -- | The rollback state while disabling Auto-Tune for the domain. Valid
    -- values are NO_ROLLBACK and DEFAULT_ROLLBACK.
    AutoTuneOptions -> Maybe RollbackOnDisable
rollbackOnDisable :: Prelude.Maybe RollbackOnDisable,
    -- | A list of maintenance schedules. See
    -- <https://docs.aws.amazon.com/opensearch-service/latest/developerguide/auto-tune.html Auto-Tune for Amazon OpenSearch Service>
    -- for more information.
    AutoTuneOptions -> Maybe [AutoTuneMaintenanceSchedule]
maintenanceSchedules :: Prelude.Maybe [AutoTuneMaintenanceSchedule]
  }
  deriving (AutoTuneOptions -> AutoTuneOptions -> Bool
(AutoTuneOptions -> AutoTuneOptions -> Bool)
-> (AutoTuneOptions -> AutoTuneOptions -> Bool)
-> Eq AutoTuneOptions
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]
(Int -> ReadS AutoTuneOptions)
-> ReadS [AutoTuneOptions]
-> ReadPrec AutoTuneOptions
-> ReadPrec [AutoTuneOptions]
-> Read 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
(Int -> AutoTuneOptions -> ShowS)
-> (AutoTuneOptions -> String)
-> ([AutoTuneOptions] -> ShowS)
-> Show AutoTuneOptions
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. AutoTuneOptions -> Rep AutoTuneOptions x)
-> (forall x. Rep AutoTuneOptions x -> AutoTuneOptions)
-> Generic AutoTuneOptions
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' - The Auto-Tune desired state. Valid values are ENABLED and DISABLED.
--
-- 'rollbackOnDisable', 'autoTuneOptions_rollbackOnDisable' - The rollback state while disabling Auto-Tune for the domain. Valid
-- values are NO_ROLLBACK and DEFAULT_ROLLBACK.
--
-- 'maintenanceSchedules', 'autoTuneOptions_maintenanceSchedules' - A list of maintenance schedules. See
-- <https://docs.aws.amazon.com/opensearch-service/latest/developerguide/auto-tune.html Auto-Tune for Amazon OpenSearch Service>
-- for more information.
newAutoTuneOptions ::
  AutoTuneOptions
newAutoTuneOptions :: AutoTuneOptions
newAutoTuneOptions =
  AutoTuneOptions' :: Maybe AutoTuneDesiredState
-> Maybe RollbackOnDisable
-> Maybe [AutoTuneMaintenanceSchedule]
-> AutoTuneOptions
AutoTuneOptions'
    { $sel:desiredState:AutoTuneOptions' :: Maybe AutoTuneDesiredState
desiredState = Maybe AutoTuneDesiredState
forall a. Maybe a
Prelude.Nothing,
      $sel:rollbackOnDisable:AutoTuneOptions' :: Maybe RollbackOnDisable
rollbackOnDisable = Maybe RollbackOnDisable
forall a. Maybe a
Prelude.Nothing,
      $sel:maintenanceSchedules:AutoTuneOptions' :: Maybe [AutoTuneMaintenanceSchedule]
maintenanceSchedules = Maybe [AutoTuneMaintenanceSchedule]
forall a. Maybe a
Prelude.Nothing
    }

-- | The Auto-Tune desired state. Valid values are ENABLED and DISABLED.
autoTuneOptions_desiredState :: Lens.Lens' AutoTuneOptions (Prelude.Maybe AutoTuneDesiredState)
autoTuneOptions_desiredState :: (Maybe AutoTuneDesiredState -> f (Maybe AutoTuneDesiredState))
-> AutoTuneOptions -> f AutoTuneOptions
autoTuneOptions_desiredState = (AutoTuneOptions -> Maybe AutoTuneDesiredState)
-> (AutoTuneOptions
    -> Maybe AutoTuneDesiredState -> AutoTuneOptions)
-> Lens
     AutoTuneOptions
     AutoTuneOptions
     (Maybe AutoTuneDesiredState)
     (Maybe AutoTuneDesiredState)
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)

-- | The rollback state while disabling Auto-Tune for the domain. Valid
-- values are NO_ROLLBACK and DEFAULT_ROLLBACK.
autoTuneOptions_rollbackOnDisable :: Lens.Lens' AutoTuneOptions (Prelude.Maybe RollbackOnDisable)
autoTuneOptions_rollbackOnDisable :: (Maybe RollbackOnDisable -> f (Maybe RollbackOnDisable))
-> AutoTuneOptions -> f AutoTuneOptions
autoTuneOptions_rollbackOnDisable = (AutoTuneOptions -> Maybe RollbackOnDisable)
-> (AutoTuneOptions -> Maybe RollbackOnDisable -> AutoTuneOptions)
-> Lens
     AutoTuneOptions
     AutoTuneOptions
     (Maybe RollbackOnDisable)
     (Maybe 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)

-- | A list of maintenance schedules. See
-- <https://docs.aws.amazon.com/opensearch-service/latest/developerguide/auto-tune.html Auto-Tune for Amazon OpenSearch Service>
-- for more information.
autoTuneOptions_maintenanceSchedules :: Lens.Lens' AutoTuneOptions (Prelude.Maybe [AutoTuneMaintenanceSchedule])
autoTuneOptions_maintenanceSchedules :: (Maybe [AutoTuneMaintenanceSchedule]
 -> f (Maybe [AutoTuneMaintenanceSchedule]))
-> AutoTuneOptions -> f AutoTuneOptions
autoTuneOptions_maintenanceSchedules = (AutoTuneOptions -> Maybe [AutoTuneMaintenanceSchedule])
-> (AutoTuneOptions
    -> Maybe [AutoTuneMaintenanceSchedule] -> AutoTuneOptions)
-> Lens
     AutoTuneOptions
     AutoTuneOptions
     (Maybe [AutoTuneMaintenanceSchedule])
     (Maybe [AutoTuneMaintenanceSchedule])
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) ((Maybe [AutoTuneMaintenanceSchedule]
  -> f (Maybe [AutoTuneMaintenanceSchedule]))
 -> AutoTuneOptions -> f AutoTuneOptions)
-> ((Maybe [AutoTuneMaintenanceSchedule]
     -> f (Maybe [AutoTuneMaintenanceSchedule]))
    -> Maybe [AutoTuneMaintenanceSchedule]
    -> f (Maybe [AutoTuneMaintenanceSchedule]))
-> (Maybe [AutoTuneMaintenanceSchedule]
    -> f (Maybe [AutoTuneMaintenanceSchedule]))
-> AutoTuneOptions
-> f AutoTuneOptions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AutoTuneMaintenanceSchedule]
  [AutoTuneMaintenanceSchedule]
  [AutoTuneMaintenanceSchedule]
  [AutoTuneMaintenanceSchedule]
-> Iso
     (Maybe [AutoTuneMaintenanceSchedule])
     (Maybe [AutoTuneMaintenanceSchedule])
     (Maybe [AutoTuneMaintenanceSchedule])
     (Maybe [AutoTuneMaintenanceSchedule])
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
  [AutoTuneMaintenanceSchedule]
  [AutoTuneMaintenanceSchedule]
  [AutoTuneMaintenanceSchedule]
  [AutoTuneMaintenanceSchedule]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON AutoTuneOptions where
  parseJSON :: Value -> Parser AutoTuneOptions
parseJSON =
    String
-> (Object -> Parser AutoTuneOptions)
-> Value
-> Parser AutoTuneOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AutoTuneOptions"
      ( \Object
x ->
          Maybe AutoTuneDesiredState
-> Maybe RollbackOnDisable
-> Maybe [AutoTuneMaintenanceSchedule]
-> AutoTuneOptions
AutoTuneOptions'
            (Maybe AutoTuneDesiredState
 -> Maybe RollbackOnDisable
 -> Maybe [AutoTuneMaintenanceSchedule]
 -> AutoTuneOptions)
-> Parser (Maybe AutoTuneDesiredState)
-> Parser
     (Maybe RollbackOnDisable
      -> Maybe [AutoTuneMaintenanceSchedule] -> AutoTuneOptions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe AutoTuneDesiredState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"DesiredState")
            Parser
  (Maybe RollbackOnDisable
   -> Maybe [AutoTuneMaintenanceSchedule] -> AutoTuneOptions)
-> Parser (Maybe RollbackOnDisable)
-> Parser (Maybe [AutoTuneMaintenanceSchedule] -> AutoTuneOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe RollbackOnDisable)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RollbackOnDisable")
            Parser (Maybe [AutoTuneMaintenanceSchedule] -> AutoTuneOptions)
-> Parser (Maybe [AutoTuneMaintenanceSchedule])
-> Parser AutoTuneOptions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text -> Parser (Maybe (Maybe [AutoTuneMaintenanceSchedule]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MaintenanceSchedules"
                            Parser (Maybe (Maybe [AutoTuneMaintenanceSchedule]))
-> Maybe [AutoTuneMaintenanceSchedule]
-> Parser (Maybe [AutoTuneMaintenanceSchedule])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [AutoTuneMaintenanceSchedule]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable AutoTuneOptions

instance Prelude.NFData AutoTuneOptions

instance Core.ToJSON AutoTuneOptions where
  toJSON :: AutoTuneOptions -> Value
toJSON AutoTuneOptions' {Maybe [AutoTuneMaintenanceSchedule]
Maybe AutoTuneDesiredState
Maybe RollbackOnDisable
maintenanceSchedules :: Maybe [AutoTuneMaintenanceSchedule]
rollbackOnDisable :: Maybe RollbackOnDisable
desiredState :: Maybe AutoTuneDesiredState
$sel:maintenanceSchedules:AutoTuneOptions' :: AutoTuneOptions -> Maybe [AutoTuneMaintenanceSchedule]
$sel:rollbackOnDisable:AutoTuneOptions' :: AutoTuneOptions -> Maybe RollbackOnDisable
$sel:desiredState:AutoTuneOptions' :: AutoTuneOptions -> Maybe AutoTuneDesiredState
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DesiredState" Text -> AutoTuneDesiredState -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (AutoTuneDesiredState -> Pair)
-> Maybe AutoTuneDesiredState -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AutoTuneDesiredState
desiredState,
            (Text
"RollbackOnDisable" Text -> RollbackOnDisable -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (RollbackOnDisable -> Pair)
-> Maybe RollbackOnDisable -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RollbackOnDisable
rollbackOnDisable,
            (Text
"MaintenanceSchedules" Text -> [AutoTuneMaintenanceSchedule] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([AutoTuneMaintenanceSchedule] -> Pair)
-> Maybe [AutoTuneMaintenanceSchedule] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AutoTuneMaintenanceSchedule]
maintenanceSchedules
          ]
      )