{-# 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.ServiceQuotas.Types.QuotaPeriod
-- 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.ServiceQuotas.Types.QuotaPeriod 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
import Amazonka.ServiceQuotas.Types.PeriodUnit

-- | Information about the quota period.
--
-- /See:/ 'newQuotaPeriod' smart constructor.
data QuotaPeriod = QuotaPeriod'
  { -- | The time unit.
    QuotaPeriod -> Maybe PeriodUnit
periodUnit :: Prelude.Maybe PeriodUnit,
    -- | The value.
    QuotaPeriod -> Maybe Int
periodValue :: Prelude.Maybe Prelude.Int
  }
  deriving (QuotaPeriod -> QuotaPeriod -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QuotaPeriod -> QuotaPeriod -> Bool
$c/= :: QuotaPeriod -> QuotaPeriod -> Bool
== :: QuotaPeriod -> QuotaPeriod -> Bool
$c== :: QuotaPeriod -> QuotaPeriod -> Bool
Prelude.Eq, ReadPrec [QuotaPeriod]
ReadPrec QuotaPeriod
Int -> ReadS QuotaPeriod
ReadS [QuotaPeriod]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [QuotaPeriod]
$creadListPrec :: ReadPrec [QuotaPeriod]
readPrec :: ReadPrec QuotaPeriod
$creadPrec :: ReadPrec QuotaPeriod
readList :: ReadS [QuotaPeriod]
$creadList :: ReadS [QuotaPeriod]
readsPrec :: Int -> ReadS QuotaPeriod
$creadsPrec :: Int -> ReadS QuotaPeriod
Prelude.Read, Int -> QuotaPeriod -> ShowS
[QuotaPeriod] -> ShowS
QuotaPeriod -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [QuotaPeriod] -> ShowS
$cshowList :: [QuotaPeriod] -> ShowS
show :: QuotaPeriod -> String
$cshow :: QuotaPeriod -> String
showsPrec :: Int -> QuotaPeriod -> ShowS
$cshowsPrec :: Int -> QuotaPeriod -> ShowS
Prelude.Show, forall x. Rep QuotaPeriod x -> QuotaPeriod
forall x. QuotaPeriod -> Rep QuotaPeriod x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep QuotaPeriod x -> QuotaPeriod
$cfrom :: forall x. QuotaPeriod -> Rep QuotaPeriod x
Prelude.Generic)

-- |
-- Create a value of 'QuotaPeriod' 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:
--
-- 'periodUnit', 'quotaPeriod_periodUnit' - The time unit.
--
-- 'periodValue', 'quotaPeriod_periodValue' - The value.
newQuotaPeriod ::
  QuotaPeriod
newQuotaPeriod :: QuotaPeriod
newQuotaPeriod =
  QuotaPeriod'
    { $sel:periodUnit:QuotaPeriod' :: Maybe PeriodUnit
periodUnit = forall a. Maybe a
Prelude.Nothing,
      $sel:periodValue:QuotaPeriod' :: Maybe Int
periodValue = forall a. Maybe a
Prelude.Nothing
    }

-- | The time unit.
quotaPeriod_periodUnit :: Lens.Lens' QuotaPeriod (Prelude.Maybe PeriodUnit)
quotaPeriod_periodUnit :: Lens' QuotaPeriod (Maybe PeriodUnit)
quotaPeriod_periodUnit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QuotaPeriod' {Maybe PeriodUnit
periodUnit :: Maybe PeriodUnit
$sel:periodUnit:QuotaPeriod' :: QuotaPeriod -> Maybe PeriodUnit
periodUnit} -> Maybe PeriodUnit
periodUnit) (\s :: QuotaPeriod
s@QuotaPeriod' {} Maybe PeriodUnit
a -> QuotaPeriod
s {$sel:periodUnit:QuotaPeriod' :: Maybe PeriodUnit
periodUnit = Maybe PeriodUnit
a} :: QuotaPeriod)

-- | The value.
quotaPeriod_periodValue :: Lens.Lens' QuotaPeriod (Prelude.Maybe Prelude.Int)
quotaPeriod_periodValue :: Lens' QuotaPeriod (Maybe Int)
quotaPeriod_periodValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\QuotaPeriod' {Maybe Int
periodValue :: Maybe Int
$sel:periodValue:QuotaPeriod' :: QuotaPeriod -> Maybe Int
periodValue} -> Maybe Int
periodValue) (\s :: QuotaPeriod
s@QuotaPeriod' {} Maybe Int
a -> QuotaPeriod
s {$sel:periodValue:QuotaPeriod' :: Maybe Int
periodValue = Maybe Int
a} :: QuotaPeriod)

instance Data.FromJSON QuotaPeriod where
  parseJSON :: Value -> Parser QuotaPeriod
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"QuotaPeriod"
      ( \Object
x ->
          Maybe PeriodUnit -> Maybe Int -> QuotaPeriod
QuotaPeriod'
            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
"PeriodUnit")
            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
"PeriodValue")
      )

instance Prelude.Hashable QuotaPeriod where
  hashWithSalt :: Int -> QuotaPeriod -> Int
hashWithSalt Int
_salt QuotaPeriod' {Maybe Int
Maybe PeriodUnit
periodValue :: Maybe Int
periodUnit :: Maybe PeriodUnit
$sel:periodValue:QuotaPeriod' :: QuotaPeriod -> Maybe Int
$sel:periodUnit:QuotaPeriod' :: QuotaPeriod -> Maybe PeriodUnit
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe PeriodUnit
periodUnit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
periodValue

instance Prelude.NFData QuotaPeriod where
  rnf :: QuotaPeriod -> ()
rnf QuotaPeriod' {Maybe Int
Maybe PeriodUnit
periodValue :: Maybe Int
periodUnit :: Maybe PeriodUnit
$sel:periodValue:QuotaPeriod' :: QuotaPeriod -> Maybe Int
$sel:periodUnit:QuotaPeriod' :: QuotaPeriod -> Maybe PeriodUnit
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe PeriodUnit
periodUnit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
periodValue