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

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

-- | Information about the versioning of dataset contents.
--
-- /See:/ 'newVersioningConfiguration' smart constructor.
data VersioningConfiguration = VersioningConfiguration'
  { -- | If true, unlimited versions of dataset contents are kept.
    VersioningConfiguration -> Maybe Bool
unlimited :: Prelude.Maybe Prelude.Bool,
    -- | How many versions of dataset contents are kept. The @unlimited@
    -- parameter must be @false@.
    VersioningConfiguration -> Maybe Natural
maxVersions :: Prelude.Maybe Prelude.Natural
  }
  deriving (VersioningConfiguration -> VersioningConfiguration -> Bool
(VersioningConfiguration -> VersioningConfiguration -> Bool)
-> (VersioningConfiguration -> VersioningConfiguration -> Bool)
-> Eq VersioningConfiguration
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]
(Int -> ReadS VersioningConfiguration)
-> ReadS [VersioningConfiguration]
-> ReadPrec VersioningConfiguration
-> ReadPrec [VersioningConfiguration]
-> Read 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
(Int -> VersioningConfiguration -> ShowS)
-> (VersioningConfiguration -> String)
-> ([VersioningConfiguration] -> ShowS)
-> Show VersioningConfiguration
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.
 VersioningConfiguration -> Rep VersioningConfiguration x)
-> (forall x.
    Rep VersioningConfiguration x -> VersioningConfiguration)
-> Generic VersioningConfiguration
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:
--
-- 'unlimited', 'versioningConfiguration_unlimited' - If true, unlimited versions of dataset contents are kept.
--
-- 'maxVersions', 'versioningConfiguration_maxVersions' - How many versions of dataset contents are kept. The @unlimited@
-- parameter must be @false@.
newVersioningConfiguration ::
  VersioningConfiguration
newVersioningConfiguration :: VersioningConfiguration
newVersioningConfiguration =
  VersioningConfiguration' :: Maybe Bool -> Maybe Natural -> VersioningConfiguration
VersioningConfiguration'
    { $sel:unlimited:VersioningConfiguration' :: Maybe Bool
unlimited =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:maxVersions:VersioningConfiguration' :: Maybe Natural
maxVersions = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | If true, unlimited versions of dataset contents are kept.
versioningConfiguration_unlimited :: Lens.Lens' VersioningConfiguration (Prelude.Maybe Prelude.Bool)
versioningConfiguration_unlimited :: (Maybe Bool -> f (Maybe Bool))
-> VersioningConfiguration -> f VersioningConfiguration
versioningConfiguration_unlimited = (VersioningConfiguration -> Maybe Bool)
-> (VersioningConfiguration
    -> Maybe Bool -> VersioningConfiguration)
-> Lens
     VersioningConfiguration
     VersioningConfiguration
     (Maybe Bool)
     (Maybe Bool)
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)

-- | 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 :: (Maybe Natural -> f (Maybe Natural))
-> VersioningConfiguration -> f VersioningConfiguration
versioningConfiguration_maxVersions = (VersioningConfiguration -> Maybe Natural)
-> (VersioningConfiguration
    -> Maybe Natural -> VersioningConfiguration)
-> Lens
     VersioningConfiguration
     VersioningConfiguration
     (Maybe Natural)
     (Maybe Natural)
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)

instance Core.FromJSON VersioningConfiguration where
  parseJSON :: Value -> Parser VersioningConfiguration
parseJSON =
    String
-> (Object -> Parser VersioningConfiguration)
-> Value
-> Parser VersioningConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VersioningConfiguration"
      ( \Object
x ->
          Maybe Bool -> Maybe Natural -> VersioningConfiguration
VersioningConfiguration'
            (Maybe Bool -> Maybe Natural -> VersioningConfiguration)
-> Parser (Maybe Bool)
-> Parser (Maybe Natural -> VersioningConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"unlimited")
            Parser (Maybe Natural -> VersioningConfiguration)
-> Parser (Maybe Natural) -> Parser VersioningConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"maxVersions")
      )

instance Prelude.Hashable VersioningConfiguration

instance Prelude.NFData VersioningConfiguration

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