{-# 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.IoTAnalytics.Types.VersioningConfiguration
-- 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.IoTAnalytics.Types.VersioningConfiguration 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

-- | Information about the versioning of dataset contents.
--
-- /See:/ 'newVersioningConfiguration' smart constructor.
data VersioningConfiguration = VersioningConfiguration'
  { -- | How many versions of dataset contents are kept. The @unlimited@
    -- parameter must be @false@.
    VersioningConfiguration -> Maybe Natural
maxVersions :: Prelude.Maybe Prelude.Natural,
    -- | If true, unlimited versions of dataset contents are kept.
    VersioningConfiguration -> Maybe Bool
unlimited :: Prelude.Maybe Prelude.Bool
  }
  deriving (VersioningConfiguration -> VersioningConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VersioningConfiguration -> VersioningConfiguration -> Bool
$c/= :: VersioningConfiguration -> VersioningConfiguration -> Bool
== :: VersioningConfiguration -> VersioningConfiguration -> Bool
$c== :: VersioningConfiguration -> VersioningConfiguration -> Bool
Prelude.Eq, ReadPrec [VersioningConfiguration]
ReadPrec VersioningConfiguration
Int -> ReadS VersioningConfiguration
ReadS [VersioningConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VersioningConfiguration]
$creadListPrec :: ReadPrec [VersioningConfiguration]
readPrec :: ReadPrec VersioningConfiguration
$creadPrec :: ReadPrec VersioningConfiguration
readList :: ReadS [VersioningConfiguration]
$creadList :: ReadS [VersioningConfiguration]
readsPrec :: Int -> ReadS VersioningConfiguration
$creadsPrec :: Int -> ReadS VersioningConfiguration
Prelude.Read, Int -> VersioningConfiguration -> ShowS
[VersioningConfiguration] -> ShowS
VersioningConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VersioningConfiguration] -> ShowS
$cshowList :: [VersioningConfiguration] -> ShowS
show :: VersioningConfiguration -> String
$cshow :: VersioningConfiguration -> String
showsPrec :: Int -> VersioningConfiguration -> ShowS
$cshowsPrec :: Int -> VersioningConfiguration -> ShowS
Prelude.Show, forall x. Rep VersioningConfiguration x -> VersioningConfiguration
forall x. VersioningConfiguration -> Rep VersioningConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VersioningConfiguration x -> VersioningConfiguration
$cfrom :: forall x. VersioningConfiguration -> Rep VersioningConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'VersioningConfiguration' 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:
--
-- 'maxVersions', 'versioningConfiguration_maxVersions' - How many versions of dataset contents are kept. The @unlimited@
-- parameter must be @false@.
--
-- 'unlimited', 'versioningConfiguration_unlimited' - If true, unlimited versions of dataset contents are kept.
newVersioningConfiguration ::
  VersioningConfiguration
newVersioningConfiguration :: VersioningConfiguration
newVersioningConfiguration =
  VersioningConfiguration'
    { $sel:maxVersions:VersioningConfiguration' :: Maybe Natural
maxVersions =
        forall a. Maybe a
Prelude.Nothing,
      $sel:unlimited:VersioningConfiguration' :: Maybe Bool
unlimited = forall a. Maybe a
Prelude.Nothing
    }

-- | How many versions of dataset contents are kept. The @unlimited@
-- parameter must be @false@.
versioningConfiguration_maxVersions :: Lens.Lens' VersioningConfiguration (Prelude.Maybe Prelude.Natural)
versioningConfiguration_maxVersions :: Lens' VersioningConfiguration (Maybe Natural)
versioningConfiguration_maxVersions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VersioningConfiguration' {Maybe Natural
maxVersions :: Maybe Natural
$sel:maxVersions:VersioningConfiguration' :: VersioningConfiguration -> Maybe Natural
maxVersions} -> Maybe Natural
maxVersions) (\s :: VersioningConfiguration
s@VersioningConfiguration' {} Maybe Natural
a -> VersioningConfiguration
s {$sel:maxVersions:VersioningConfiguration' :: Maybe Natural
maxVersions = Maybe Natural
a} :: VersioningConfiguration)

-- | If true, unlimited versions of dataset contents are kept.
versioningConfiguration_unlimited :: Lens.Lens' VersioningConfiguration (Prelude.Maybe Prelude.Bool)
versioningConfiguration_unlimited :: Lens' VersioningConfiguration (Maybe Bool)
versioningConfiguration_unlimited = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VersioningConfiguration' {Maybe Bool
unlimited :: Maybe Bool
$sel:unlimited:VersioningConfiguration' :: VersioningConfiguration -> Maybe Bool
unlimited} -> Maybe Bool
unlimited) (\s :: VersioningConfiguration
s@VersioningConfiguration' {} Maybe Bool
a -> VersioningConfiguration
s {$sel:unlimited:VersioningConfiguration' :: Maybe Bool
unlimited = Maybe Bool
a} :: VersioningConfiguration)

instance Data.FromJSON VersioningConfiguration where
  parseJSON :: Value -> Parser VersioningConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"VersioningConfiguration"
      ( \Object
x ->
          Maybe Natural -> Maybe Bool -> VersioningConfiguration
VersioningConfiguration'
            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
"maxVersions")
            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
"unlimited")
      )

instance Prelude.Hashable VersioningConfiguration where
  hashWithSalt :: Int -> VersioningConfiguration -> Int
hashWithSalt Int
_salt VersioningConfiguration' {Maybe Bool
Maybe Natural
unlimited :: Maybe Bool
maxVersions :: Maybe Natural
$sel:unlimited:VersioningConfiguration' :: VersioningConfiguration -> Maybe Bool
$sel:maxVersions:VersioningConfiguration' :: VersioningConfiguration -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxVersions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
unlimited

instance Prelude.NFData VersioningConfiguration where
  rnf :: VersioningConfiguration -> ()
rnf VersioningConfiguration' {Maybe Bool
Maybe Natural
unlimited :: Maybe Bool
maxVersions :: Maybe Natural
$sel:unlimited:VersioningConfiguration' :: VersioningConfiguration -> Maybe Bool
$sel:maxVersions:VersioningConfiguration' :: VersioningConfiguration -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxVersions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
unlimited

instance Data.ToJSON VersioningConfiguration where
  toJSON :: VersioningConfiguration -> Value
toJSON VersioningConfiguration' {Maybe Bool
Maybe Natural
unlimited :: Maybe Bool
maxVersions :: Maybe Natural
$sel:unlimited:VersioningConfiguration' :: VersioningConfiguration -> Maybe Bool
$sel:maxVersions:VersioningConfiguration' :: VersioningConfiguration -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"maxVersions" 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 Natural
maxVersions,
            (Key
"unlimited" 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 Bool
unlimited
          ]
      )