{-# 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.LicenseUsage
-- 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.LicenseUsage where

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

-- | Describes the entitlement usage associated with a license.
--
-- /See:/ 'newLicenseUsage' smart constructor.
data LicenseUsage = LicenseUsage'
  { -- | License entitlement usages.
    LicenseUsage -> Maybe [EntitlementUsage]
entitlementUsages :: Prelude.Maybe [EntitlementUsage]
  }
  deriving (LicenseUsage -> LicenseUsage -> Bool
(LicenseUsage -> LicenseUsage -> Bool)
-> (LicenseUsage -> LicenseUsage -> Bool) -> Eq LicenseUsage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LicenseUsage -> LicenseUsage -> Bool
$c/= :: LicenseUsage -> LicenseUsage -> Bool
== :: LicenseUsage -> LicenseUsage -> Bool
$c== :: LicenseUsage -> LicenseUsage -> Bool
Prelude.Eq, ReadPrec [LicenseUsage]
ReadPrec LicenseUsage
Int -> ReadS LicenseUsage
ReadS [LicenseUsage]
(Int -> ReadS LicenseUsage)
-> ReadS [LicenseUsage]
-> ReadPrec LicenseUsage
-> ReadPrec [LicenseUsage]
-> Read LicenseUsage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LicenseUsage]
$creadListPrec :: ReadPrec [LicenseUsage]
readPrec :: ReadPrec LicenseUsage
$creadPrec :: ReadPrec LicenseUsage
readList :: ReadS [LicenseUsage]
$creadList :: ReadS [LicenseUsage]
readsPrec :: Int -> ReadS LicenseUsage
$creadsPrec :: Int -> ReadS LicenseUsage
Prelude.Read, Int -> LicenseUsage -> ShowS
[LicenseUsage] -> ShowS
LicenseUsage -> String
(Int -> LicenseUsage -> ShowS)
-> (LicenseUsage -> String)
-> ([LicenseUsage] -> ShowS)
-> Show LicenseUsage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LicenseUsage] -> ShowS
$cshowList :: [LicenseUsage] -> ShowS
show :: LicenseUsage -> String
$cshow :: LicenseUsage -> String
showsPrec :: Int -> LicenseUsage -> ShowS
$cshowsPrec :: Int -> LicenseUsage -> ShowS
Prelude.Show, (forall x. LicenseUsage -> Rep LicenseUsage x)
-> (forall x. Rep LicenseUsage x -> LicenseUsage)
-> Generic LicenseUsage
forall x. Rep LicenseUsage x -> LicenseUsage
forall x. LicenseUsage -> Rep LicenseUsage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LicenseUsage x -> LicenseUsage
$cfrom :: forall x. LicenseUsage -> Rep LicenseUsage x
Prelude.Generic)

-- |
-- Create a value of 'LicenseUsage' 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:
--
-- 'entitlementUsages', 'licenseUsage_entitlementUsages' - License entitlement usages.
newLicenseUsage ::
  LicenseUsage
newLicenseUsage :: LicenseUsage
newLicenseUsage =
  LicenseUsage' :: Maybe [EntitlementUsage] -> LicenseUsage
LicenseUsage' {$sel:entitlementUsages:LicenseUsage' :: Maybe [EntitlementUsage]
entitlementUsages = Maybe [EntitlementUsage]
forall a. Maybe a
Prelude.Nothing}

-- | License entitlement usages.
licenseUsage_entitlementUsages :: Lens.Lens' LicenseUsage (Prelude.Maybe [EntitlementUsage])
licenseUsage_entitlementUsages :: (Maybe [EntitlementUsage] -> f (Maybe [EntitlementUsage]))
-> LicenseUsage -> f LicenseUsage
licenseUsage_entitlementUsages = (LicenseUsage -> Maybe [EntitlementUsage])
-> (LicenseUsage -> Maybe [EntitlementUsage] -> LicenseUsage)
-> Lens
     LicenseUsage
     LicenseUsage
     (Maybe [EntitlementUsage])
     (Maybe [EntitlementUsage])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LicenseUsage' {Maybe [EntitlementUsage]
entitlementUsages :: Maybe [EntitlementUsage]
$sel:entitlementUsages:LicenseUsage' :: LicenseUsage -> Maybe [EntitlementUsage]
entitlementUsages} -> Maybe [EntitlementUsage]
entitlementUsages) (\s :: LicenseUsage
s@LicenseUsage' {} Maybe [EntitlementUsage]
a -> LicenseUsage
s {$sel:entitlementUsages:LicenseUsage' :: Maybe [EntitlementUsage]
entitlementUsages = Maybe [EntitlementUsage]
a} :: LicenseUsage) ((Maybe [EntitlementUsage] -> f (Maybe [EntitlementUsage]))
 -> LicenseUsage -> f LicenseUsage)
-> ((Maybe [EntitlementUsage] -> f (Maybe [EntitlementUsage]))
    -> Maybe [EntitlementUsage] -> f (Maybe [EntitlementUsage]))
-> (Maybe [EntitlementUsage] -> f (Maybe [EntitlementUsage]))
-> LicenseUsage
-> f LicenseUsage
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [EntitlementUsage]
  [EntitlementUsage]
  [EntitlementUsage]
  [EntitlementUsage]
-> Iso
     (Maybe [EntitlementUsage])
     (Maybe [EntitlementUsage])
     (Maybe [EntitlementUsage])
     (Maybe [EntitlementUsage])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [EntitlementUsage]
  [EntitlementUsage]
  [EntitlementUsage]
  [EntitlementUsage]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON LicenseUsage where
  parseJSON :: Value -> Parser LicenseUsage
parseJSON =
    String
-> (Object -> Parser LicenseUsage) -> Value -> Parser LicenseUsage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"LicenseUsage"
      ( \Object
x ->
          Maybe [EntitlementUsage] -> LicenseUsage
LicenseUsage'
            (Maybe [EntitlementUsage] -> LicenseUsage)
-> Parser (Maybe [EntitlementUsage]) -> Parser LicenseUsage
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [EntitlementUsage]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EntitlementUsages"
                            Parser (Maybe (Maybe [EntitlementUsage]))
-> Maybe [EntitlementUsage] -> Parser (Maybe [EntitlementUsage])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [EntitlementUsage]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable LicenseUsage

instance Prelude.NFData LicenseUsage