{-# 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.WorkDocs.Types.StorageRuleType
-- 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.WorkDocs.Types.StorageRuleType where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.WorkDocs.Types.StorageType

-- | Describes the storage for a user.
--
-- /See:/ 'newStorageRuleType' smart constructor.
data StorageRuleType = StorageRuleType'
  { -- | The amount of storage allocated, in bytes.
    StorageRuleType -> Maybe Natural
storageAllocatedInBytes :: Prelude.Maybe Prelude.Natural,
    -- | The type of storage.
    StorageRuleType -> Maybe StorageType
storageType :: Prelude.Maybe StorageType
  }
  deriving (StorageRuleType -> StorageRuleType -> Bool
(StorageRuleType -> StorageRuleType -> Bool)
-> (StorageRuleType -> StorageRuleType -> Bool)
-> Eq StorageRuleType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StorageRuleType -> StorageRuleType -> Bool
$c/= :: StorageRuleType -> StorageRuleType -> Bool
== :: StorageRuleType -> StorageRuleType -> Bool
$c== :: StorageRuleType -> StorageRuleType -> Bool
Prelude.Eq, ReadPrec [StorageRuleType]
ReadPrec StorageRuleType
Int -> ReadS StorageRuleType
ReadS [StorageRuleType]
(Int -> ReadS StorageRuleType)
-> ReadS [StorageRuleType]
-> ReadPrec StorageRuleType
-> ReadPrec [StorageRuleType]
-> Read StorageRuleType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StorageRuleType]
$creadListPrec :: ReadPrec [StorageRuleType]
readPrec :: ReadPrec StorageRuleType
$creadPrec :: ReadPrec StorageRuleType
readList :: ReadS [StorageRuleType]
$creadList :: ReadS [StorageRuleType]
readsPrec :: Int -> ReadS StorageRuleType
$creadsPrec :: Int -> ReadS StorageRuleType
Prelude.Read, Int -> StorageRuleType -> ShowS
[StorageRuleType] -> ShowS
StorageRuleType -> String
(Int -> StorageRuleType -> ShowS)
-> (StorageRuleType -> String)
-> ([StorageRuleType] -> ShowS)
-> Show StorageRuleType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StorageRuleType] -> ShowS
$cshowList :: [StorageRuleType] -> ShowS
show :: StorageRuleType -> String
$cshow :: StorageRuleType -> String
showsPrec :: Int -> StorageRuleType -> ShowS
$cshowsPrec :: Int -> StorageRuleType -> ShowS
Prelude.Show, (forall x. StorageRuleType -> Rep StorageRuleType x)
-> (forall x. Rep StorageRuleType x -> StorageRuleType)
-> Generic StorageRuleType
forall x. Rep StorageRuleType x -> StorageRuleType
forall x. StorageRuleType -> Rep StorageRuleType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StorageRuleType x -> StorageRuleType
$cfrom :: forall x. StorageRuleType -> Rep StorageRuleType x
Prelude.Generic)

-- |
-- Create a value of 'StorageRuleType' 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:
--
-- 'storageAllocatedInBytes', 'storageRuleType_storageAllocatedInBytes' - The amount of storage allocated, in bytes.
--
-- 'storageType', 'storageRuleType_storageType' - The type of storage.
newStorageRuleType ::
  StorageRuleType
newStorageRuleType :: StorageRuleType
newStorageRuleType =
  StorageRuleType' :: Maybe Natural -> Maybe StorageType -> StorageRuleType
StorageRuleType'
    { $sel:storageAllocatedInBytes:StorageRuleType' :: Maybe Natural
storageAllocatedInBytes =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:storageType:StorageRuleType' :: Maybe StorageType
storageType = Maybe StorageType
forall a. Maybe a
Prelude.Nothing
    }

-- | The amount of storage allocated, in bytes.
storageRuleType_storageAllocatedInBytes :: Lens.Lens' StorageRuleType (Prelude.Maybe Prelude.Natural)
storageRuleType_storageAllocatedInBytes :: (Maybe Natural -> f (Maybe Natural))
-> StorageRuleType -> f StorageRuleType
storageRuleType_storageAllocatedInBytes = (StorageRuleType -> Maybe Natural)
-> (StorageRuleType -> Maybe Natural -> StorageRuleType)
-> Lens
     StorageRuleType StorageRuleType (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StorageRuleType' {Maybe Natural
storageAllocatedInBytes :: Maybe Natural
$sel:storageAllocatedInBytes:StorageRuleType' :: StorageRuleType -> Maybe Natural
storageAllocatedInBytes} -> Maybe Natural
storageAllocatedInBytes) (\s :: StorageRuleType
s@StorageRuleType' {} Maybe Natural
a -> StorageRuleType
s {$sel:storageAllocatedInBytes:StorageRuleType' :: Maybe Natural
storageAllocatedInBytes = Maybe Natural
a} :: StorageRuleType)

-- | The type of storage.
storageRuleType_storageType :: Lens.Lens' StorageRuleType (Prelude.Maybe StorageType)
storageRuleType_storageType :: (Maybe StorageType -> f (Maybe StorageType))
-> StorageRuleType -> f StorageRuleType
storageRuleType_storageType = (StorageRuleType -> Maybe StorageType)
-> (StorageRuleType -> Maybe StorageType -> StorageRuleType)
-> Lens
     StorageRuleType
     StorageRuleType
     (Maybe StorageType)
     (Maybe StorageType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StorageRuleType' {Maybe StorageType
storageType :: Maybe StorageType
$sel:storageType:StorageRuleType' :: StorageRuleType -> Maybe StorageType
storageType} -> Maybe StorageType
storageType) (\s :: StorageRuleType
s@StorageRuleType' {} Maybe StorageType
a -> StorageRuleType
s {$sel:storageType:StorageRuleType' :: Maybe StorageType
storageType = Maybe StorageType
a} :: StorageRuleType)

instance Core.FromJSON StorageRuleType where
  parseJSON :: Value -> Parser StorageRuleType
parseJSON =
    String
-> (Object -> Parser StorageRuleType)
-> Value
-> Parser StorageRuleType
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StorageRuleType"
      ( \Object
x ->
          Maybe Natural -> Maybe StorageType -> StorageRuleType
StorageRuleType'
            (Maybe Natural -> Maybe StorageType -> StorageRuleType)
-> Parser (Maybe Natural)
-> Parser (Maybe StorageType -> StorageRuleType)
forall (f :: * -> *) a b. Functor 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
"StorageAllocatedInBytes")
            Parser (Maybe StorageType -> StorageRuleType)
-> Parser (Maybe StorageType) -> Parser StorageRuleType
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe StorageType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StorageType")
      )

instance Prelude.Hashable StorageRuleType

instance Prelude.NFData StorageRuleType

instance Core.ToJSON StorageRuleType where
  toJSON :: StorageRuleType -> Value
toJSON StorageRuleType' {Maybe Natural
Maybe StorageType
storageType :: Maybe StorageType
storageAllocatedInBytes :: Maybe Natural
$sel:storageType:StorageRuleType' :: StorageRuleType -> Maybe StorageType
$sel:storageAllocatedInBytes:StorageRuleType' :: StorageRuleType -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"StorageAllocatedInBytes" 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
storageAllocatedInBytes,
            (Text
"StorageType" Text -> StorageType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (StorageType -> Pair) -> Maybe StorageType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StorageType
storageType
          ]
      )