{-# 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.Lambda.Types.AccountUsage
-- 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.Lambda.Types.AccountUsage where

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

-- | The number of functions and amount of storage in use.
--
-- /See:/ 'newAccountUsage' smart constructor.
data AccountUsage = AccountUsage'
  { -- | The amount of storage space, in bytes, that\'s being used by deployment
    -- packages and layer archives.
    AccountUsage -> Maybe Integer
totalCodeSize :: Prelude.Maybe Prelude.Integer,
    -- | The number of Lambda functions.
    AccountUsage -> Maybe Integer
functionCount :: Prelude.Maybe Prelude.Integer
  }
  deriving (AccountUsage -> AccountUsage -> Bool
(AccountUsage -> AccountUsage -> Bool)
-> (AccountUsage -> AccountUsage -> Bool) -> Eq AccountUsage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccountUsage -> AccountUsage -> Bool
$c/= :: AccountUsage -> AccountUsage -> Bool
== :: AccountUsage -> AccountUsage -> Bool
$c== :: AccountUsage -> AccountUsage -> Bool
Prelude.Eq, ReadPrec [AccountUsage]
ReadPrec AccountUsage
Int -> ReadS AccountUsage
ReadS [AccountUsage]
(Int -> ReadS AccountUsage)
-> ReadS [AccountUsage]
-> ReadPrec AccountUsage
-> ReadPrec [AccountUsage]
-> Read AccountUsage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AccountUsage]
$creadListPrec :: ReadPrec [AccountUsage]
readPrec :: ReadPrec AccountUsage
$creadPrec :: ReadPrec AccountUsage
readList :: ReadS [AccountUsage]
$creadList :: ReadS [AccountUsage]
readsPrec :: Int -> ReadS AccountUsage
$creadsPrec :: Int -> ReadS AccountUsage
Prelude.Read, Int -> AccountUsage -> ShowS
[AccountUsage] -> ShowS
AccountUsage -> String
(Int -> AccountUsage -> ShowS)
-> (AccountUsage -> String)
-> ([AccountUsage] -> ShowS)
-> Show AccountUsage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccountUsage] -> ShowS
$cshowList :: [AccountUsage] -> ShowS
show :: AccountUsage -> String
$cshow :: AccountUsage -> String
showsPrec :: Int -> AccountUsage -> ShowS
$cshowsPrec :: Int -> AccountUsage -> ShowS
Prelude.Show, (forall x. AccountUsage -> Rep AccountUsage x)
-> (forall x. Rep AccountUsage x -> AccountUsage)
-> Generic AccountUsage
forall x. Rep AccountUsage x -> AccountUsage
forall x. AccountUsage -> Rep AccountUsage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AccountUsage x -> AccountUsage
$cfrom :: forall x. AccountUsage -> Rep AccountUsage x
Prelude.Generic)

-- |
-- Create a value of 'AccountUsage' 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:
--
-- 'totalCodeSize', 'accountUsage_totalCodeSize' - The amount of storage space, in bytes, that\'s being used by deployment
-- packages and layer archives.
--
-- 'functionCount', 'accountUsage_functionCount' - The number of Lambda functions.
newAccountUsage ::
  AccountUsage
newAccountUsage :: AccountUsage
newAccountUsage =
  AccountUsage' :: Maybe Integer -> Maybe Integer -> AccountUsage
AccountUsage'
    { $sel:totalCodeSize:AccountUsage' :: Maybe Integer
totalCodeSize = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:functionCount:AccountUsage' :: Maybe Integer
functionCount = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | The amount of storage space, in bytes, that\'s being used by deployment
-- packages and layer archives.
accountUsage_totalCodeSize :: Lens.Lens' AccountUsage (Prelude.Maybe Prelude.Integer)
accountUsage_totalCodeSize :: (Maybe Integer -> f (Maybe Integer))
-> AccountUsage -> f AccountUsage
accountUsage_totalCodeSize = (AccountUsage -> Maybe Integer)
-> (AccountUsage -> Maybe Integer -> AccountUsage)
-> Lens AccountUsage AccountUsage (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccountUsage' {Maybe Integer
totalCodeSize :: Maybe Integer
$sel:totalCodeSize:AccountUsage' :: AccountUsage -> Maybe Integer
totalCodeSize} -> Maybe Integer
totalCodeSize) (\s :: AccountUsage
s@AccountUsage' {} Maybe Integer
a -> AccountUsage
s {$sel:totalCodeSize:AccountUsage' :: Maybe Integer
totalCodeSize = Maybe Integer
a} :: AccountUsage)

-- | The number of Lambda functions.
accountUsage_functionCount :: Lens.Lens' AccountUsage (Prelude.Maybe Prelude.Integer)
accountUsage_functionCount :: (Maybe Integer -> f (Maybe Integer))
-> AccountUsage -> f AccountUsage
accountUsage_functionCount = (AccountUsage -> Maybe Integer)
-> (AccountUsage -> Maybe Integer -> AccountUsage)
-> Lens AccountUsage AccountUsage (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AccountUsage' {Maybe Integer
functionCount :: Maybe Integer
$sel:functionCount:AccountUsage' :: AccountUsage -> Maybe Integer
functionCount} -> Maybe Integer
functionCount) (\s :: AccountUsage
s@AccountUsage' {} Maybe Integer
a -> AccountUsage
s {$sel:functionCount:AccountUsage' :: Maybe Integer
functionCount = Maybe Integer
a} :: AccountUsage)

instance Core.FromJSON AccountUsage where
  parseJSON :: Value -> Parser AccountUsage
parseJSON =
    String
-> (Object -> Parser AccountUsage) -> Value -> Parser AccountUsage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AccountUsage"
      ( \Object
x ->
          Maybe Integer -> Maybe Integer -> AccountUsage
AccountUsage'
            (Maybe Integer -> Maybe Integer -> AccountUsage)
-> Parser (Maybe Integer) -> Parser (Maybe Integer -> AccountUsage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TotalCodeSize")
            Parser (Maybe Integer -> AccountUsage)
-> Parser (Maybe Integer) -> Parser AccountUsage
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FunctionCount")
      )

instance Prelude.Hashable AccountUsage

instance Prelude.NFData AccountUsage