{-# 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.LicenseManagerLinuxSubscriptions.Types.Subscription
-- 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.LicenseManagerLinuxSubscriptions.Types.Subscription 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

-- | An object which details a discovered Linux subscription.
--
-- /See:/ 'newSubscription' smart constructor.
data Subscription = Subscription'
  { -- | The total amount of running instances using this subscription.
    Subscription -> Maybe Integer
instanceCount :: Prelude.Maybe Prelude.Integer,
    -- | The name of the subscription.
    Subscription -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The type of subscription. The type can be subscription-included with
    -- Amazon EC2, Bring Your Own Subscription model (BYOS), or from the Amazon
    -- Web Services Marketplace. Certain subscriptions may use licensing from
    -- the Amazon Web Services Marketplace as well as OS licensing from Amazon
    -- EC2 or BYOS.
    Subscription -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (Subscription -> Subscription -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Subscription -> Subscription -> Bool
$c/= :: Subscription -> Subscription -> Bool
== :: Subscription -> Subscription -> Bool
$c== :: Subscription -> Subscription -> Bool
Prelude.Eq, ReadPrec [Subscription]
ReadPrec Subscription
Int -> ReadS Subscription
ReadS [Subscription]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Subscription]
$creadListPrec :: ReadPrec [Subscription]
readPrec :: ReadPrec Subscription
$creadPrec :: ReadPrec Subscription
readList :: ReadS [Subscription]
$creadList :: ReadS [Subscription]
readsPrec :: Int -> ReadS Subscription
$creadsPrec :: Int -> ReadS Subscription
Prelude.Read, Int -> Subscription -> ShowS
[Subscription] -> ShowS
Subscription -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Subscription] -> ShowS
$cshowList :: [Subscription] -> ShowS
show :: Subscription -> String
$cshow :: Subscription -> String
showsPrec :: Int -> Subscription -> ShowS
$cshowsPrec :: Int -> Subscription -> ShowS
Prelude.Show, forall x. Rep Subscription x -> Subscription
forall x. Subscription -> Rep Subscription x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Subscription x -> Subscription
$cfrom :: forall x. Subscription -> Rep Subscription x
Prelude.Generic)

-- |
-- Create a value of 'Subscription' 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:
--
-- 'instanceCount', 'subscription_instanceCount' - The total amount of running instances using this subscription.
--
-- 'name', 'subscription_name' - The name of the subscription.
--
-- 'type'', 'subscription_type' - The type of subscription. The type can be subscription-included with
-- Amazon EC2, Bring Your Own Subscription model (BYOS), or from the Amazon
-- Web Services Marketplace. Certain subscriptions may use licensing from
-- the Amazon Web Services Marketplace as well as OS licensing from Amazon
-- EC2 or BYOS.
newSubscription ::
  Subscription
newSubscription :: Subscription
newSubscription =
  Subscription'
    { $sel:instanceCount:Subscription' :: Maybe Integer
instanceCount = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Subscription' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:type':Subscription' :: Maybe Text
type' = forall a. Maybe a
Prelude.Nothing
    }

-- | The total amount of running instances using this subscription.
subscription_instanceCount :: Lens.Lens' Subscription (Prelude.Maybe Prelude.Integer)
subscription_instanceCount :: Lens' Subscription (Maybe Integer)
subscription_instanceCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscription' {Maybe Integer
instanceCount :: Maybe Integer
$sel:instanceCount:Subscription' :: Subscription -> Maybe Integer
instanceCount} -> Maybe Integer
instanceCount) (\s :: Subscription
s@Subscription' {} Maybe Integer
a -> Subscription
s {$sel:instanceCount:Subscription' :: Maybe Integer
instanceCount = Maybe Integer
a} :: Subscription)

-- | The name of the subscription.
subscription_name :: Lens.Lens' Subscription (Prelude.Maybe Prelude.Text)
subscription_name :: Lens' Subscription (Maybe Text)
subscription_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscription' {Maybe Text
name :: Maybe Text
$sel:name:Subscription' :: Subscription -> Maybe Text
name} -> Maybe Text
name) (\s :: Subscription
s@Subscription' {} Maybe Text
a -> Subscription
s {$sel:name:Subscription' :: Maybe Text
name = Maybe Text
a} :: Subscription)

-- | The type of subscription. The type can be subscription-included with
-- Amazon EC2, Bring Your Own Subscription model (BYOS), or from the Amazon
-- Web Services Marketplace. Certain subscriptions may use licensing from
-- the Amazon Web Services Marketplace as well as OS licensing from Amazon
-- EC2 or BYOS.
subscription_type :: Lens.Lens' Subscription (Prelude.Maybe Prelude.Text)
subscription_type :: Lens' Subscription (Maybe Text)
subscription_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Subscription' {Maybe Text
type' :: Maybe Text
$sel:type':Subscription' :: Subscription -> Maybe Text
type'} -> Maybe Text
type') (\s :: Subscription
s@Subscription' {} Maybe Text
a -> Subscription
s {$sel:type':Subscription' :: Maybe Text
type' = Maybe Text
a} :: Subscription)

instance Data.FromJSON Subscription where
  parseJSON :: Value -> Parser Subscription
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Subscription"
      ( \Object
x ->
          Maybe Integer -> Maybe Text -> Maybe Text -> Subscription
Subscription'
            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
"InstanceCount")
            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
"Name")
            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
"Type")
      )

instance Prelude.Hashable Subscription where
  hashWithSalt :: Int -> Subscription -> Int
hashWithSalt Int
_salt Subscription' {Maybe Integer
Maybe Text
type' :: Maybe Text
name :: Maybe Text
instanceCount :: Maybe Integer
$sel:type':Subscription' :: Subscription -> Maybe Text
$sel:name:Subscription' :: Subscription -> Maybe Text
$sel:instanceCount:Subscription' :: Subscription -> Maybe Integer
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
instanceCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
type'

instance Prelude.NFData Subscription where
  rnf :: Subscription -> ()
rnf Subscription' {Maybe Integer
Maybe Text
type' :: Maybe Text
name :: Maybe Text
instanceCount :: Maybe Integer
$sel:type':Subscription' :: Subscription -> Maybe Text
$sel:name:Subscription' :: Subscription -> Maybe Text
$sel:instanceCount:Subscription' :: Subscription -> Maybe Integer
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
instanceCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
type'