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

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

-- | Specifies the configuration for cold storage options such as enabled
--
-- /See:/ 'newColdStorageOptions' smart constructor.
data ColdStorageOptions = ColdStorageOptions'
  { -- | Enable cold storage option. Accepted values true or false
    ColdStorageOptions -> Bool
enabled :: Prelude.Bool
  }
  deriving (ColdStorageOptions -> ColdStorageOptions -> Bool
(ColdStorageOptions -> ColdStorageOptions -> Bool)
-> (ColdStorageOptions -> ColdStorageOptions -> Bool)
-> Eq ColdStorageOptions
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]
(Int -> ReadS ColdStorageOptions)
-> ReadS [ColdStorageOptions]
-> ReadPrec ColdStorageOptions
-> ReadPrec [ColdStorageOptions]
-> Read 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
(Int -> ColdStorageOptions -> ShowS)
-> (ColdStorageOptions -> String)
-> ([ColdStorageOptions] -> ShowS)
-> Show ColdStorageOptions
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. ColdStorageOptions -> Rep ColdStorageOptions x)
-> (forall x. Rep ColdStorageOptions x -> ColdStorageOptions)
-> Generic ColdStorageOptions
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' - Enable cold storage option. Accepted values true or false
newColdStorageOptions ::
  -- | 'enabled'
  Prelude.Bool ->
  ColdStorageOptions
newColdStorageOptions :: Bool -> ColdStorageOptions
newColdStorageOptions Bool
pEnabled_ =
  ColdStorageOptions' :: Bool -> ColdStorageOptions
ColdStorageOptions' {$sel:enabled:ColdStorageOptions' :: Bool
enabled = Bool
pEnabled_}

-- | Enable cold storage option. Accepted values true or false
coldStorageOptions_enabled :: Lens.Lens' ColdStorageOptions Prelude.Bool
coldStorageOptions_enabled :: (Bool -> f Bool) -> ColdStorageOptions -> f ColdStorageOptions
coldStorageOptions_enabled = (ColdStorageOptions -> Bool)
-> (ColdStorageOptions -> Bool -> ColdStorageOptions)
-> Lens ColdStorageOptions ColdStorageOptions Bool Bool
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 Core.FromJSON ColdStorageOptions where
  parseJSON :: Value -> Parser ColdStorageOptions
parseJSON =
    String
-> (Object -> Parser ColdStorageOptions)
-> Value
-> Parser ColdStorageOptions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ColdStorageOptions"
      ( \Object
x ->
          Bool -> ColdStorageOptions
ColdStorageOptions'
            (Bool -> ColdStorageOptions)
-> Parser Bool -> Parser ColdStorageOptions
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Enabled")
      )

instance Prelude.Hashable ColdStorageOptions

instance Prelude.NFData ColdStorageOptions

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