{-# 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.LicenseManager.Types.ConsumedLicenseSummary
-- 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.LicenseManager.Types.ConsumedLicenseSummary where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LicenseManager.Types.ResourceType
import qualified Amazonka.Prelude as Prelude

-- | Details about license consumption.
--
-- /See:/ 'newConsumedLicenseSummary' smart constructor.
data ConsumedLicenseSummary = ConsumedLicenseSummary'
  { -- | Resource type of the resource consuming a license.
    ConsumedLicenseSummary -> Maybe ResourceType
resourceType :: Prelude.Maybe ResourceType,
    -- | Number of licenses consumed by the resource.
    ConsumedLicenseSummary -> Maybe Integer
consumedLicenses :: Prelude.Maybe Prelude.Integer
  }
  deriving (ConsumedLicenseSummary -> ConsumedLicenseSummary -> Bool
(ConsumedLicenseSummary -> ConsumedLicenseSummary -> Bool)
-> (ConsumedLicenseSummary -> ConsumedLicenseSummary -> Bool)
-> Eq ConsumedLicenseSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConsumedLicenseSummary -> ConsumedLicenseSummary -> Bool
$c/= :: ConsumedLicenseSummary -> ConsumedLicenseSummary -> Bool
== :: ConsumedLicenseSummary -> ConsumedLicenseSummary -> Bool
$c== :: ConsumedLicenseSummary -> ConsumedLicenseSummary -> Bool
Prelude.Eq, ReadPrec [ConsumedLicenseSummary]
ReadPrec ConsumedLicenseSummary
Int -> ReadS ConsumedLicenseSummary
ReadS [ConsumedLicenseSummary]
(Int -> ReadS ConsumedLicenseSummary)
-> ReadS [ConsumedLicenseSummary]
-> ReadPrec ConsumedLicenseSummary
-> ReadPrec [ConsumedLicenseSummary]
-> Read ConsumedLicenseSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConsumedLicenseSummary]
$creadListPrec :: ReadPrec [ConsumedLicenseSummary]
readPrec :: ReadPrec ConsumedLicenseSummary
$creadPrec :: ReadPrec ConsumedLicenseSummary
readList :: ReadS [ConsumedLicenseSummary]
$creadList :: ReadS [ConsumedLicenseSummary]
readsPrec :: Int -> ReadS ConsumedLicenseSummary
$creadsPrec :: Int -> ReadS ConsumedLicenseSummary
Prelude.Read, Int -> ConsumedLicenseSummary -> ShowS
[ConsumedLicenseSummary] -> ShowS
ConsumedLicenseSummary -> String
(Int -> ConsumedLicenseSummary -> ShowS)
-> (ConsumedLicenseSummary -> String)
-> ([ConsumedLicenseSummary] -> ShowS)
-> Show ConsumedLicenseSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConsumedLicenseSummary] -> ShowS
$cshowList :: [ConsumedLicenseSummary] -> ShowS
show :: ConsumedLicenseSummary -> String
$cshow :: ConsumedLicenseSummary -> String
showsPrec :: Int -> ConsumedLicenseSummary -> ShowS
$cshowsPrec :: Int -> ConsumedLicenseSummary -> ShowS
Prelude.Show, (forall x. ConsumedLicenseSummary -> Rep ConsumedLicenseSummary x)
-> (forall x.
    Rep ConsumedLicenseSummary x -> ConsumedLicenseSummary)
-> Generic ConsumedLicenseSummary
forall x. Rep ConsumedLicenseSummary x -> ConsumedLicenseSummary
forall x. ConsumedLicenseSummary -> Rep ConsumedLicenseSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConsumedLicenseSummary x -> ConsumedLicenseSummary
$cfrom :: forall x. ConsumedLicenseSummary -> Rep ConsumedLicenseSummary x
Prelude.Generic)

-- |
-- Create a value of 'ConsumedLicenseSummary' 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:
--
-- 'resourceType', 'consumedLicenseSummary_resourceType' - Resource type of the resource consuming a license.
--
-- 'consumedLicenses', 'consumedLicenseSummary_consumedLicenses' - Number of licenses consumed by the resource.
newConsumedLicenseSummary ::
  ConsumedLicenseSummary
newConsumedLicenseSummary :: ConsumedLicenseSummary
newConsumedLicenseSummary =
  ConsumedLicenseSummary' :: Maybe ResourceType -> Maybe Integer -> ConsumedLicenseSummary
ConsumedLicenseSummary'
    { $sel:resourceType:ConsumedLicenseSummary' :: Maybe ResourceType
resourceType =
        Maybe ResourceType
forall a. Maybe a
Prelude.Nothing,
      $sel:consumedLicenses:ConsumedLicenseSummary' :: Maybe Integer
consumedLicenses = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | Resource type of the resource consuming a license.
consumedLicenseSummary_resourceType :: Lens.Lens' ConsumedLicenseSummary (Prelude.Maybe ResourceType)
consumedLicenseSummary_resourceType :: (Maybe ResourceType -> f (Maybe ResourceType))
-> ConsumedLicenseSummary -> f ConsumedLicenseSummary
consumedLicenseSummary_resourceType = (ConsumedLicenseSummary -> Maybe ResourceType)
-> (ConsumedLicenseSummary
    -> Maybe ResourceType -> ConsumedLicenseSummary)
-> Lens
     ConsumedLicenseSummary
     ConsumedLicenseSummary
     (Maybe ResourceType)
     (Maybe ResourceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConsumedLicenseSummary' {Maybe ResourceType
resourceType :: Maybe ResourceType
$sel:resourceType:ConsumedLicenseSummary' :: ConsumedLicenseSummary -> Maybe ResourceType
resourceType} -> Maybe ResourceType
resourceType) (\s :: ConsumedLicenseSummary
s@ConsumedLicenseSummary' {} Maybe ResourceType
a -> ConsumedLicenseSummary
s {$sel:resourceType:ConsumedLicenseSummary' :: Maybe ResourceType
resourceType = Maybe ResourceType
a} :: ConsumedLicenseSummary)

-- | Number of licenses consumed by the resource.
consumedLicenseSummary_consumedLicenses :: Lens.Lens' ConsumedLicenseSummary (Prelude.Maybe Prelude.Integer)
consumedLicenseSummary_consumedLicenses :: (Maybe Integer -> f (Maybe Integer))
-> ConsumedLicenseSummary -> f ConsumedLicenseSummary
consumedLicenseSummary_consumedLicenses = (ConsumedLicenseSummary -> Maybe Integer)
-> (ConsumedLicenseSummary
    -> Maybe Integer -> ConsumedLicenseSummary)
-> Lens
     ConsumedLicenseSummary
     ConsumedLicenseSummary
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConsumedLicenseSummary' {Maybe Integer
consumedLicenses :: Maybe Integer
$sel:consumedLicenses:ConsumedLicenseSummary' :: ConsumedLicenseSummary -> Maybe Integer
consumedLicenses} -> Maybe Integer
consumedLicenses) (\s :: ConsumedLicenseSummary
s@ConsumedLicenseSummary' {} Maybe Integer
a -> ConsumedLicenseSummary
s {$sel:consumedLicenses:ConsumedLicenseSummary' :: Maybe Integer
consumedLicenses = Maybe Integer
a} :: ConsumedLicenseSummary)

instance Core.FromJSON ConsumedLicenseSummary where
  parseJSON :: Value -> Parser ConsumedLicenseSummary
parseJSON =
    String
-> (Object -> Parser ConsumedLicenseSummary)
-> Value
-> Parser ConsumedLicenseSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ConsumedLicenseSummary"
      ( \Object
x ->
          Maybe ResourceType -> Maybe Integer -> ConsumedLicenseSummary
ConsumedLicenseSummary'
            (Maybe ResourceType -> Maybe Integer -> ConsumedLicenseSummary)
-> Parser (Maybe ResourceType)
-> Parser (Maybe Integer -> ConsumedLicenseSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe ResourceType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ResourceType")
            Parser (Maybe Integer -> ConsumedLicenseSummary)
-> Parser (Maybe Integer) -> Parser ConsumedLicenseSummary
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
"ConsumedLicenses")
      )

instance Prelude.Hashable ConsumedLicenseSummary

instance Prelude.NFData ConsumedLicenseSummary