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

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

-- | Specifies the time, in UTC format, when the service takes a daily
-- automated snapshot of the specified Elasticsearch domain. Default value
-- is @0@ hours.
--
-- /See:/ 'newSnapshotOptions' smart constructor.
data SnapshotOptions = SnapshotOptions'
  { -- | Specifies the time, in UTC format, when the service takes a daily
    -- automated snapshot of the specified Elasticsearch domain. Default value
    -- is @0@ hours.
    SnapshotOptions -> Maybe Int
automatedSnapshotStartHour :: Prelude.Maybe Prelude.Int
  }
  deriving (SnapshotOptions -> SnapshotOptions -> Bool
(SnapshotOptions -> SnapshotOptions -> Bool)
-> (SnapshotOptions -> SnapshotOptions -> Bool)
-> Eq SnapshotOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SnapshotOptions -> SnapshotOptions -> Bool
$c/= :: SnapshotOptions -> SnapshotOptions -> Bool
== :: SnapshotOptions -> SnapshotOptions -> Bool
$c== :: SnapshotOptions -> SnapshotOptions -> Bool
Prelude.Eq, ReadPrec [SnapshotOptions]
ReadPrec SnapshotOptions
Int -> ReadS SnapshotOptions
ReadS [SnapshotOptions]
(Int -> ReadS SnapshotOptions)
-> ReadS [SnapshotOptions]
-> ReadPrec SnapshotOptions
-> ReadPrec [SnapshotOptions]
-> Read SnapshotOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SnapshotOptions]
$creadListPrec :: ReadPrec [SnapshotOptions]
readPrec :: ReadPrec SnapshotOptions
$creadPrec :: ReadPrec SnapshotOptions
readList :: ReadS [SnapshotOptions]
$creadList :: ReadS [SnapshotOptions]
readsPrec :: Int -> ReadS SnapshotOptions
$creadsPrec :: Int -> ReadS SnapshotOptions
Prelude.Read, Int -> SnapshotOptions -> ShowS
[SnapshotOptions] -> ShowS
SnapshotOptions -> String
(Int -> SnapshotOptions -> ShowS)
-> (SnapshotOptions -> String)
-> ([SnapshotOptions] -> ShowS)
-> Show SnapshotOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SnapshotOptions] -> ShowS
$cshowList :: [SnapshotOptions] -> ShowS
show :: SnapshotOptions -> String
$cshow :: SnapshotOptions -> String
showsPrec :: Int -> SnapshotOptions -> ShowS
$cshowsPrec :: Int -> SnapshotOptions -> ShowS
Prelude.Show, (forall x. SnapshotOptions -> Rep SnapshotOptions x)
-> (forall x. Rep SnapshotOptions x -> SnapshotOptions)
-> Generic SnapshotOptions
forall x. Rep SnapshotOptions x -> SnapshotOptions
forall x. SnapshotOptions -> Rep SnapshotOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SnapshotOptions x -> SnapshotOptions
$cfrom :: forall x. SnapshotOptions -> Rep SnapshotOptions x
Prelude.Generic)

-- |
-- Create a value of 'SnapshotOptions' 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:
--
-- 'automatedSnapshotStartHour', 'snapshotOptions_automatedSnapshotStartHour' - Specifies the time, in UTC format, when the service takes a daily
-- automated snapshot of the specified Elasticsearch domain. Default value
-- is @0@ hours.
newSnapshotOptions ::
  SnapshotOptions
newSnapshotOptions :: SnapshotOptions
newSnapshotOptions =
  SnapshotOptions' :: Maybe Int -> SnapshotOptions
SnapshotOptions'
    { $sel:automatedSnapshotStartHour:SnapshotOptions' :: Maybe Int
automatedSnapshotStartHour =
        Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the time, in UTC format, when the service takes a daily
-- automated snapshot of the specified Elasticsearch domain. Default value
-- is @0@ hours.
snapshotOptions_automatedSnapshotStartHour :: Lens.Lens' SnapshotOptions (Prelude.Maybe Prelude.Int)
snapshotOptions_automatedSnapshotStartHour :: (Maybe Int -> f (Maybe Int))
-> SnapshotOptions -> f SnapshotOptions
snapshotOptions_automatedSnapshotStartHour = (SnapshotOptions -> Maybe Int)
-> (SnapshotOptions -> Maybe Int -> SnapshotOptions)
-> Lens SnapshotOptions SnapshotOptions (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SnapshotOptions' {Maybe Int
automatedSnapshotStartHour :: Maybe Int
$sel:automatedSnapshotStartHour:SnapshotOptions' :: SnapshotOptions -> Maybe Int
automatedSnapshotStartHour} -> Maybe Int
automatedSnapshotStartHour) (\s :: SnapshotOptions
s@SnapshotOptions' {} Maybe Int
a -> SnapshotOptions
s {$sel:automatedSnapshotStartHour:SnapshotOptions' :: Maybe Int
automatedSnapshotStartHour = Maybe Int
a} :: SnapshotOptions)

instance Core.FromJSON SnapshotOptions where
  parseJSON :: Value -> Parser SnapshotOptions
parseJSON =
    String
-> (Object -> Parser SnapshotOptions)
-> Value
-> Parser SnapshotOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SnapshotOptions"
      ( \Object
x ->
          Maybe Int -> SnapshotOptions
SnapshotOptions'
            (Maybe Int -> SnapshotOptions)
-> Parser (Maybe Int) -> Parser SnapshotOptions
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AutomatedSnapshotStartHour")
      )

instance Prelude.Hashable SnapshotOptions

instance Prelude.NFData SnapshotOptions

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