{-# 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-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.ServiceQuotas.Types.QuotaPeriod where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(QuotaPeriod -> QuotaPeriod -> Bool)
-> (QuotaPeriod -> QuotaPeriod -> Bool) -> Eq QuotaPeriod
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]
(Int -> ReadS QuotaPeriod)
-> ReadS [QuotaPeriod]
-> ReadPrec QuotaPeriod
-> ReadPrec [QuotaPeriod]
-> Read 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
(Int -> QuotaPeriod -> ShowS)
-> (QuotaPeriod -> String)
-> ([QuotaPeriod] -> ShowS)
-> Show QuotaPeriod
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. QuotaPeriod -> Rep QuotaPeriod x)
-> (forall x. Rep QuotaPeriod x -> QuotaPeriod)
-> Generic QuotaPeriod
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' :: Maybe PeriodUnit -> Maybe Int -> QuotaPeriod
QuotaPeriod'
    { $sel:periodUnit:QuotaPeriod' :: Maybe PeriodUnit
periodUnit = Maybe PeriodUnit
forall a. Maybe a
Prelude.Nothing,
      $sel:periodValue:QuotaPeriod' :: Maybe Int
periodValue = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The time unit.
quotaPeriod_periodUnit :: Lens.Lens' QuotaPeriod (Prelude.Maybe PeriodUnit)
quotaPeriod_periodUnit :: (Maybe PeriodUnit -> f (Maybe PeriodUnit))
-> QuotaPeriod -> f QuotaPeriod
quotaPeriod_periodUnit = (QuotaPeriod -> Maybe PeriodUnit)
-> (QuotaPeriod -> Maybe PeriodUnit -> QuotaPeriod)
-> Lens
     QuotaPeriod QuotaPeriod (Maybe PeriodUnit) (Maybe 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 :: (Maybe Int -> f (Maybe Int)) -> QuotaPeriod -> f QuotaPeriod
quotaPeriod_periodValue = (QuotaPeriod -> Maybe Int)
-> (QuotaPeriod -> Maybe Int -> QuotaPeriod)
-> Lens QuotaPeriod QuotaPeriod (Maybe Int) (Maybe Int)
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 Core.FromJSON QuotaPeriod where
  parseJSON :: Value -> Parser QuotaPeriod
parseJSON =
    String
-> (Object -> Parser QuotaPeriod) -> Value -> Parser QuotaPeriod
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"QuotaPeriod"
      ( \Object
x ->
          Maybe PeriodUnit -> Maybe Int -> QuotaPeriod
QuotaPeriod'
            (Maybe PeriodUnit -> Maybe Int -> QuotaPeriod)
-> Parser (Maybe PeriodUnit) -> Parser (Maybe Int -> QuotaPeriod)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe PeriodUnit)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PeriodUnit")
            Parser (Maybe Int -> QuotaPeriod)
-> Parser (Maybe Int) -> Parser QuotaPeriod
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"PeriodValue")
      )

instance Prelude.Hashable QuotaPeriod

instance Prelude.NFData QuotaPeriod