{-# 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.MediaConvert.Types.AllowedRenditionSize
-- 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.MediaConvert.Types.AllowedRenditionSize where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MediaConvert.Types.RequiredFlag
import qualified Amazonka.Prelude as Prelude

-- | Use Allowed renditions to specify a list of possible resolutions in your
-- ABR stack. * MediaConvert will create an ABR stack exclusively from the
-- list of resolutions that you specify. * Some resolutions in the Allowed
-- renditions list may not be included, however you can force a resolution
-- to be included by setting Required to ENABLED. * You must specify at
-- least one resolution that is greater than or equal to any resolutions
-- that you specify in Min top rendition size or Min bottom rendition size.
-- * If you specify Allowed renditions, you must not specify a separate
-- rule for Force include renditions.
--
-- /See:/ 'newAllowedRenditionSize' smart constructor.
data AllowedRenditionSize = AllowedRenditionSize'
  { -- | Use Height to define the video resolution height, in pixels, for this
    -- rule.
    AllowedRenditionSize -> Maybe Natural
height :: Prelude.Maybe Prelude.Natural,
    -- | Set to ENABLED to force a rendition to be included.
    AllowedRenditionSize -> Maybe RequiredFlag
required :: Prelude.Maybe RequiredFlag,
    -- | Use Width to define the video resolution width, in pixels, for this
    -- rule.
    AllowedRenditionSize -> Maybe Natural
width :: Prelude.Maybe Prelude.Natural
  }
  deriving (AllowedRenditionSize -> AllowedRenditionSize -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AllowedRenditionSize -> AllowedRenditionSize -> Bool
$c/= :: AllowedRenditionSize -> AllowedRenditionSize -> Bool
== :: AllowedRenditionSize -> AllowedRenditionSize -> Bool
$c== :: AllowedRenditionSize -> AllowedRenditionSize -> Bool
Prelude.Eq, ReadPrec [AllowedRenditionSize]
ReadPrec AllowedRenditionSize
Int -> ReadS AllowedRenditionSize
ReadS [AllowedRenditionSize]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AllowedRenditionSize]
$creadListPrec :: ReadPrec [AllowedRenditionSize]
readPrec :: ReadPrec AllowedRenditionSize
$creadPrec :: ReadPrec AllowedRenditionSize
readList :: ReadS [AllowedRenditionSize]
$creadList :: ReadS [AllowedRenditionSize]
readsPrec :: Int -> ReadS AllowedRenditionSize
$creadsPrec :: Int -> ReadS AllowedRenditionSize
Prelude.Read, Int -> AllowedRenditionSize -> ShowS
[AllowedRenditionSize] -> ShowS
AllowedRenditionSize -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AllowedRenditionSize] -> ShowS
$cshowList :: [AllowedRenditionSize] -> ShowS
show :: AllowedRenditionSize -> String
$cshow :: AllowedRenditionSize -> String
showsPrec :: Int -> AllowedRenditionSize -> ShowS
$cshowsPrec :: Int -> AllowedRenditionSize -> ShowS
Prelude.Show, forall x. Rep AllowedRenditionSize x -> AllowedRenditionSize
forall x. AllowedRenditionSize -> Rep AllowedRenditionSize x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AllowedRenditionSize x -> AllowedRenditionSize
$cfrom :: forall x. AllowedRenditionSize -> Rep AllowedRenditionSize x
Prelude.Generic)

-- |
-- Create a value of 'AllowedRenditionSize' 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:
--
-- 'height', 'allowedRenditionSize_height' - Use Height to define the video resolution height, in pixels, for this
-- rule.
--
-- 'required', 'allowedRenditionSize_required' - Set to ENABLED to force a rendition to be included.
--
-- 'width', 'allowedRenditionSize_width' - Use Width to define the video resolution width, in pixels, for this
-- rule.
newAllowedRenditionSize ::
  AllowedRenditionSize
newAllowedRenditionSize :: AllowedRenditionSize
newAllowedRenditionSize =
  AllowedRenditionSize'
    { $sel:height:AllowedRenditionSize' :: Maybe Natural
height = forall a. Maybe a
Prelude.Nothing,
      $sel:required:AllowedRenditionSize' :: Maybe RequiredFlag
required = forall a. Maybe a
Prelude.Nothing,
      $sel:width:AllowedRenditionSize' :: Maybe Natural
width = forall a. Maybe a
Prelude.Nothing
    }

-- | Use Height to define the video resolution height, in pixels, for this
-- rule.
allowedRenditionSize_height :: Lens.Lens' AllowedRenditionSize (Prelude.Maybe Prelude.Natural)
allowedRenditionSize_height :: Lens' AllowedRenditionSize (Maybe Natural)
allowedRenditionSize_height = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AllowedRenditionSize' {Maybe Natural
height :: Maybe Natural
$sel:height:AllowedRenditionSize' :: AllowedRenditionSize -> Maybe Natural
height} -> Maybe Natural
height) (\s :: AllowedRenditionSize
s@AllowedRenditionSize' {} Maybe Natural
a -> AllowedRenditionSize
s {$sel:height:AllowedRenditionSize' :: Maybe Natural
height = Maybe Natural
a} :: AllowedRenditionSize)

-- | Set to ENABLED to force a rendition to be included.
allowedRenditionSize_required :: Lens.Lens' AllowedRenditionSize (Prelude.Maybe RequiredFlag)
allowedRenditionSize_required :: Lens' AllowedRenditionSize (Maybe RequiredFlag)
allowedRenditionSize_required = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AllowedRenditionSize' {Maybe RequiredFlag
required :: Maybe RequiredFlag
$sel:required:AllowedRenditionSize' :: AllowedRenditionSize -> Maybe RequiredFlag
required} -> Maybe RequiredFlag
required) (\s :: AllowedRenditionSize
s@AllowedRenditionSize' {} Maybe RequiredFlag
a -> AllowedRenditionSize
s {$sel:required:AllowedRenditionSize' :: Maybe RequiredFlag
required = Maybe RequiredFlag
a} :: AllowedRenditionSize)

-- | Use Width to define the video resolution width, in pixels, for this
-- rule.
allowedRenditionSize_width :: Lens.Lens' AllowedRenditionSize (Prelude.Maybe Prelude.Natural)
allowedRenditionSize_width :: Lens' AllowedRenditionSize (Maybe Natural)
allowedRenditionSize_width = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AllowedRenditionSize' {Maybe Natural
width :: Maybe Natural
$sel:width:AllowedRenditionSize' :: AllowedRenditionSize -> Maybe Natural
width} -> Maybe Natural
width) (\s :: AllowedRenditionSize
s@AllowedRenditionSize' {} Maybe Natural
a -> AllowedRenditionSize
s {$sel:width:AllowedRenditionSize' :: Maybe Natural
width = Maybe Natural
a} :: AllowedRenditionSize)

instance Data.FromJSON AllowedRenditionSize where
  parseJSON :: Value -> Parser AllowedRenditionSize
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AllowedRenditionSize"
      ( \Object
x ->
          Maybe Natural
-> Maybe RequiredFlag -> Maybe Natural -> AllowedRenditionSize
AllowedRenditionSize'
            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
"height")
            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
"required")
            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
"width")
      )

instance Prelude.Hashable AllowedRenditionSize where
  hashWithSalt :: Int -> AllowedRenditionSize -> Int
hashWithSalt Int
_salt AllowedRenditionSize' {Maybe Natural
Maybe RequiredFlag
width :: Maybe Natural
required :: Maybe RequiredFlag
height :: Maybe Natural
$sel:width:AllowedRenditionSize' :: AllowedRenditionSize -> Maybe Natural
$sel:required:AllowedRenditionSize' :: AllowedRenditionSize -> Maybe RequiredFlag
$sel:height:AllowedRenditionSize' :: AllowedRenditionSize -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
height
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RequiredFlag
required
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
width

instance Prelude.NFData AllowedRenditionSize where
  rnf :: AllowedRenditionSize -> ()
rnf AllowedRenditionSize' {Maybe Natural
Maybe RequiredFlag
width :: Maybe Natural
required :: Maybe RequiredFlag
height :: Maybe Natural
$sel:width:AllowedRenditionSize' :: AllowedRenditionSize -> Maybe Natural
$sel:required:AllowedRenditionSize' :: AllowedRenditionSize -> Maybe RequiredFlag
$sel:height:AllowedRenditionSize' :: AllowedRenditionSize -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
height
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RequiredFlag
required
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
width

instance Data.ToJSON AllowedRenditionSize where
  toJSON :: AllowedRenditionSize -> Value
toJSON AllowedRenditionSize' {Maybe Natural
Maybe RequiredFlag
width :: Maybe Natural
required :: Maybe RequiredFlag
height :: Maybe Natural
$sel:width:AllowedRenditionSize' :: AllowedRenditionSize -> Maybe Natural
$sel:required:AllowedRenditionSize' :: AllowedRenditionSize -> Maybe RequiredFlag
$sel:height:AllowedRenditionSize' :: AllowedRenditionSize -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"height" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
height,
            (Key
"required" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RequiredFlag
required,
            (Key
"width" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
width
          ]
      )