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

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

-- | Container for the parameters required to enable cold storage for an
-- OpenSearch Service domain. For more information, see
-- <https://docs.aws.amazon.com/opensearch-service/latest/developerguide/cold-storage.html Cold storage for Amazon OpenSearch Service>.
--
-- /See:/ 'newColdStorageOptions' smart constructor.
data ColdStorageOptions = ColdStorageOptions'
  { -- | Whether to enable or disable cold storage on the domain.
    ColdStorageOptions -> Bool
enabled :: Prelude.Bool
  }
  deriving (ColdStorageOptions -> ColdStorageOptions -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ColdStorageOptions -> ColdStorageOptions -> Bool
$c/= :: ColdStorageOptions -> ColdStorageOptions -> Bool
== :: ColdStorageOptions -> ColdStorageOptions -> Bool
$c== :: ColdStorageOptions -> ColdStorageOptions -> Bool
Prelude.Eq, ReadPrec [ColdStorageOptions]
ReadPrec ColdStorageOptions
Int -> ReadS ColdStorageOptions
ReadS [ColdStorageOptions]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ColdStorageOptions]
$creadListPrec :: ReadPrec [ColdStorageOptions]
readPrec :: ReadPrec ColdStorageOptions
$creadPrec :: ReadPrec ColdStorageOptions
readList :: ReadS [ColdStorageOptions]
$creadList :: ReadS [ColdStorageOptions]
readsPrec :: Int -> ReadS ColdStorageOptions
$creadsPrec :: Int -> ReadS ColdStorageOptions
Prelude.Read, Int -> ColdStorageOptions -> ShowS
[ColdStorageOptions] -> ShowS
ColdStorageOptions -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ColdStorageOptions] -> ShowS
$cshowList :: [ColdStorageOptions] -> ShowS
show :: ColdStorageOptions -> String
$cshow :: ColdStorageOptions -> String
showsPrec :: Int -> ColdStorageOptions -> ShowS
$cshowsPrec :: Int -> ColdStorageOptions -> ShowS
Prelude.Show, forall x. Rep ColdStorageOptions x -> ColdStorageOptions
forall x. ColdStorageOptions -> Rep ColdStorageOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ColdStorageOptions x -> ColdStorageOptions
$cfrom :: forall x. ColdStorageOptions -> Rep ColdStorageOptions x
Prelude.Generic)

-- |
-- Create a value of 'ColdStorageOptions' 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:
--
-- 'enabled', 'coldStorageOptions_enabled' - Whether to enable or disable cold storage on the domain.
newColdStorageOptions ::
  -- | 'enabled'
  Prelude.Bool ->
  ColdStorageOptions
newColdStorageOptions :: Bool -> ColdStorageOptions
newColdStorageOptions Bool
pEnabled_ =
  ColdStorageOptions' {$sel:enabled:ColdStorageOptions' :: Bool
enabled = Bool
pEnabled_}

-- | Whether to enable or disable cold storage on the domain.
coldStorageOptions_enabled :: Lens.Lens' ColdStorageOptions Prelude.Bool
coldStorageOptions_enabled :: Lens' ColdStorageOptions Bool
coldStorageOptions_enabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ColdStorageOptions' {Bool
enabled :: Bool
$sel:enabled:ColdStorageOptions' :: ColdStorageOptions -> Bool
enabled} -> Bool
enabled) (\s :: ColdStorageOptions
s@ColdStorageOptions' {} Bool
a -> ColdStorageOptions
s {$sel:enabled:ColdStorageOptions' :: Bool
enabled = Bool
a} :: ColdStorageOptions)

instance Data.FromJSON ColdStorageOptions where
  parseJSON :: Value -> Parser ColdStorageOptions
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ColdStorageOptions"
      ( \Object
x ->
          Bool -> ColdStorageOptions
ColdStorageOptions'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Enabled")
      )

instance Prelude.Hashable ColdStorageOptions where
  hashWithSalt :: Int -> ColdStorageOptions -> Int
hashWithSalt Int
_salt ColdStorageOptions' {Bool
enabled :: Bool
$sel:enabled:ColdStorageOptions' :: ColdStorageOptions -> Bool
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
enabled

instance Prelude.NFData ColdStorageOptions where
  rnf :: ColdStorageOptions -> ()
rnf ColdStorageOptions' {Bool
enabled :: Bool
$sel:enabled:ColdStorageOptions' :: ColdStorageOptions -> Bool
..} = forall a. NFData a => a -> ()
Prelude.rnf Bool
enabled

instance Data.ToJSON ColdStorageOptions where
  toJSON :: ColdStorageOptions -> Value
toJSON ColdStorageOptions' {Bool
enabled :: Bool
$sel:enabled:ColdStorageOptions' :: ColdStorageOptions -> Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"Enabled" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Bool
enabled)]
      )