{-# 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.MediaConnect.Types.ResourceSpecification
-- 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.MediaConnect.Types.ResourceSpecification where

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

-- | A definition of what is being billed for, including the type and amount.
--
-- /See:/ 'newResourceSpecification' smart constructor.
data ResourceSpecification = ResourceSpecification'
  { -- | The amount of outbound bandwidth that is discounted in the offering.
    ResourceSpecification -> Maybe Int
reservedBitrate :: Prelude.Maybe Prelude.Int,
    -- | The type of resource and the unit that is being billed for.
    ResourceSpecification -> ResourceType
resourceType :: ResourceType
  }
  deriving (ResourceSpecification -> ResourceSpecification -> Bool
(ResourceSpecification -> ResourceSpecification -> Bool)
-> (ResourceSpecification -> ResourceSpecification -> Bool)
-> Eq ResourceSpecification
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceSpecification -> ResourceSpecification -> Bool
$c/= :: ResourceSpecification -> ResourceSpecification -> Bool
== :: ResourceSpecification -> ResourceSpecification -> Bool
$c== :: ResourceSpecification -> ResourceSpecification -> Bool
Prelude.Eq, ReadPrec [ResourceSpecification]
ReadPrec ResourceSpecification
Int -> ReadS ResourceSpecification
ReadS [ResourceSpecification]
(Int -> ReadS ResourceSpecification)
-> ReadS [ResourceSpecification]
-> ReadPrec ResourceSpecification
-> ReadPrec [ResourceSpecification]
-> Read ResourceSpecification
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceSpecification]
$creadListPrec :: ReadPrec [ResourceSpecification]
readPrec :: ReadPrec ResourceSpecification
$creadPrec :: ReadPrec ResourceSpecification
readList :: ReadS [ResourceSpecification]
$creadList :: ReadS [ResourceSpecification]
readsPrec :: Int -> ReadS ResourceSpecification
$creadsPrec :: Int -> ReadS ResourceSpecification
Prelude.Read, Int -> ResourceSpecification -> ShowS
[ResourceSpecification] -> ShowS
ResourceSpecification -> String
(Int -> ResourceSpecification -> ShowS)
-> (ResourceSpecification -> String)
-> ([ResourceSpecification] -> ShowS)
-> Show ResourceSpecification
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceSpecification] -> ShowS
$cshowList :: [ResourceSpecification] -> ShowS
show :: ResourceSpecification -> String
$cshow :: ResourceSpecification -> String
showsPrec :: Int -> ResourceSpecification -> ShowS
$cshowsPrec :: Int -> ResourceSpecification -> ShowS
Prelude.Show, (forall x. ResourceSpecification -> Rep ResourceSpecification x)
-> (forall x. Rep ResourceSpecification x -> ResourceSpecification)
-> Generic ResourceSpecification
forall x. Rep ResourceSpecification x -> ResourceSpecification
forall x. ResourceSpecification -> Rep ResourceSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceSpecification x -> ResourceSpecification
$cfrom :: forall x. ResourceSpecification -> Rep ResourceSpecification x
Prelude.Generic)

-- |
-- Create a value of 'ResourceSpecification' 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:
--
-- 'reservedBitrate', 'resourceSpecification_reservedBitrate' - The amount of outbound bandwidth that is discounted in the offering.
--
-- 'resourceType', 'resourceSpecification_resourceType' - The type of resource and the unit that is being billed for.
newResourceSpecification ::
  -- | 'resourceType'
  ResourceType ->
  ResourceSpecification
newResourceSpecification :: ResourceType -> ResourceSpecification
newResourceSpecification ResourceType
pResourceType_ =
  ResourceSpecification' :: Maybe Int -> ResourceType -> ResourceSpecification
ResourceSpecification'
    { $sel:reservedBitrate:ResourceSpecification' :: Maybe Int
reservedBitrate =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:ResourceSpecification' :: ResourceType
resourceType = ResourceType
pResourceType_
    }

-- | The amount of outbound bandwidth that is discounted in the offering.
resourceSpecification_reservedBitrate :: Lens.Lens' ResourceSpecification (Prelude.Maybe Prelude.Int)
resourceSpecification_reservedBitrate :: (Maybe Int -> f (Maybe Int))
-> ResourceSpecification -> f ResourceSpecification
resourceSpecification_reservedBitrate = (ResourceSpecification -> Maybe Int)
-> (ResourceSpecification -> Maybe Int -> ResourceSpecification)
-> Lens
     ResourceSpecification ResourceSpecification (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceSpecification' {Maybe Int
reservedBitrate :: Maybe Int
$sel:reservedBitrate:ResourceSpecification' :: ResourceSpecification -> Maybe Int
reservedBitrate} -> Maybe Int
reservedBitrate) (\s :: ResourceSpecification
s@ResourceSpecification' {} Maybe Int
a -> ResourceSpecification
s {$sel:reservedBitrate:ResourceSpecification' :: Maybe Int
reservedBitrate = Maybe Int
a} :: ResourceSpecification)

-- | The type of resource and the unit that is being billed for.
resourceSpecification_resourceType :: Lens.Lens' ResourceSpecification ResourceType
resourceSpecification_resourceType :: (ResourceType -> f ResourceType)
-> ResourceSpecification -> f ResourceSpecification
resourceSpecification_resourceType = (ResourceSpecification -> ResourceType)
-> (ResourceSpecification -> ResourceType -> ResourceSpecification)
-> Lens
     ResourceSpecification
     ResourceSpecification
     ResourceType
     ResourceType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceSpecification' {ResourceType
resourceType :: ResourceType
$sel:resourceType:ResourceSpecification' :: ResourceSpecification -> ResourceType
resourceType} -> ResourceType
resourceType) (\s :: ResourceSpecification
s@ResourceSpecification' {} ResourceType
a -> ResourceSpecification
s {$sel:resourceType:ResourceSpecification' :: ResourceType
resourceType = ResourceType
a} :: ResourceSpecification)

instance Core.FromJSON ResourceSpecification where
  parseJSON :: Value -> Parser ResourceSpecification
parseJSON =
    String
-> (Object -> Parser ResourceSpecification)
-> Value
-> Parser ResourceSpecification
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ResourceSpecification"
      ( \Object
x ->
          Maybe Int -> ResourceType -> ResourceSpecification
ResourceSpecification'
            (Maybe Int -> ResourceType -> ResourceSpecification)
-> Parser (Maybe Int)
-> Parser (ResourceType -> ResourceSpecification)
forall (f :: * -> *) a b. Functor 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
"reservedBitrate")
            Parser (ResourceType -> ResourceSpecification)
-> Parser ResourceType -> Parser ResourceSpecification
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ResourceType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"resourceType")
      )

instance Prelude.Hashable ResourceSpecification

instance Prelude.NFData ResourceSpecification