{-# 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.MediaLive.Types.InputClippingSettings
-- 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.MediaLive.Types.InputClippingSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaLive.Types.InputTimecodeSource
import Amazonka.MediaLive.Types.StartTimecode
import Amazonka.MediaLive.Types.StopTimecode
import qualified Amazonka.Prelude as Prelude

-- | Settings to let you create a clip of the file input, in order to set up
-- the input to ingest only a portion of the file.
--
-- /See:/ 'newInputClippingSettings' smart constructor.
data InputClippingSettings = InputClippingSettings'
  { -- | Settings to identify the end of the clip.
    InputClippingSettings -> Maybe StopTimecode
stopTimecode :: Prelude.Maybe StopTimecode,
    -- | Settings to identify the start of the clip.
    InputClippingSettings -> Maybe StartTimecode
startTimecode :: Prelude.Maybe StartTimecode,
    -- | The source of the timecodes in the source being clipped.
    InputClippingSettings -> InputTimecodeSource
inputTimecodeSource :: InputTimecodeSource
  }
  deriving (InputClippingSettings -> InputClippingSettings -> Bool
(InputClippingSettings -> InputClippingSettings -> Bool)
-> (InputClippingSettings -> InputClippingSettings -> Bool)
-> Eq InputClippingSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputClippingSettings -> InputClippingSettings -> Bool
$c/= :: InputClippingSettings -> InputClippingSettings -> Bool
== :: InputClippingSettings -> InputClippingSettings -> Bool
$c== :: InputClippingSettings -> InputClippingSettings -> Bool
Prelude.Eq, ReadPrec [InputClippingSettings]
ReadPrec InputClippingSettings
Int -> ReadS InputClippingSettings
ReadS [InputClippingSettings]
(Int -> ReadS InputClippingSettings)
-> ReadS [InputClippingSettings]
-> ReadPrec InputClippingSettings
-> ReadPrec [InputClippingSettings]
-> Read InputClippingSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputClippingSettings]
$creadListPrec :: ReadPrec [InputClippingSettings]
readPrec :: ReadPrec InputClippingSettings
$creadPrec :: ReadPrec InputClippingSettings
readList :: ReadS [InputClippingSettings]
$creadList :: ReadS [InputClippingSettings]
readsPrec :: Int -> ReadS InputClippingSettings
$creadsPrec :: Int -> ReadS InputClippingSettings
Prelude.Read, Int -> InputClippingSettings -> ShowS
[InputClippingSettings] -> ShowS
InputClippingSettings -> String
(Int -> InputClippingSettings -> ShowS)
-> (InputClippingSettings -> String)
-> ([InputClippingSettings] -> ShowS)
-> Show InputClippingSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputClippingSettings] -> ShowS
$cshowList :: [InputClippingSettings] -> ShowS
show :: InputClippingSettings -> String
$cshow :: InputClippingSettings -> String
showsPrec :: Int -> InputClippingSettings -> ShowS
$cshowsPrec :: Int -> InputClippingSettings -> ShowS
Prelude.Show, (forall x. InputClippingSettings -> Rep InputClippingSettings x)
-> (forall x. Rep InputClippingSettings x -> InputClippingSettings)
-> Generic InputClippingSettings
forall x. Rep InputClippingSettings x -> InputClippingSettings
forall x. InputClippingSettings -> Rep InputClippingSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InputClippingSettings x -> InputClippingSettings
$cfrom :: forall x. InputClippingSettings -> Rep InputClippingSettings x
Prelude.Generic)

-- |
-- Create a value of 'InputClippingSettings' 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:
--
-- 'stopTimecode', 'inputClippingSettings_stopTimecode' - Settings to identify the end of the clip.
--
-- 'startTimecode', 'inputClippingSettings_startTimecode' - Settings to identify the start of the clip.
--
-- 'inputTimecodeSource', 'inputClippingSettings_inputTimecodeSource' - The source of the timecodes in the source being clipped.
newInputClippingSettings ::
  -- | 'inputTimecodeSource'
  InputTimecodeSource ->
  InputClippingSettings
newInputClippingSettings :: InputTimecodeSource -> InputClippingSettings
newInputClippingSettings InputTimecodeSource
pInputTimecodeSource_ =
  InputClippingSettings' :: Maybe StopTimecode
-> Maybe StartTimecode
-> InputTimecodeSource
-> InputClippingSettings
InputClippingSettings'
    { $sel:stopTimecode:InputClippingSettings' :: Maybe StopTimecode
stopTimecode =
        Maybe StopTimecode
forall a. Maybe a
Prelude.Nothing,
      $sel:startTimecode:InputClippingSettings' :: Maybe StartTimecode
startTimecode = Maybe StartTimecode
forall a. Maybe a
Prelude.Nothing,
      $sel:inputTimecodeSource:InputClippingSettings' :: InputTimecodeSource
inputTimecodeSource = InputTimecodeSource
pInputTimecodeSource_
    }

-- | Settings to identify the end of the clip.
inputClippingSettings_stopTimecode :: Lens.Lens' InputClippingSettings (Prelude.Maybe StopTimecode)
inputClippingSettings_stopTimecode :: (Maybe StopTimecode -> f (Maybe StopTimecode))
-> InputClippingSettings -> f InputClippingSettings
inputClippingSettings_stopTimecode = (InputClippingSettings -> Maybe StopTimecode)
-> (InputClippingSettings
    -> Maybe StopTimecode -> InputClippingSettings)
-> Lens
     InputClippingSettings
     InputClippingSettings
     (Maybe StopTimecode)
     (Maybe StopTimecode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputClippingSettings' {Maybe StopTimecode
stopTimecode :: Maybe StopTimecode
$sel:stopTimecode:InputClippingSettings' :: InputClippingSettings -> Maybe StopTimecode
stopTimecode} -> Maybe StopTimecode
stopTimecode) (\s :: InputClippingSettings
s@InputClippingSettings' {} Maybe StopTimecode
a -> InputClippingSettings
s {$sel:stopTimecode:InputClippingSettings' :: Maybe StopTimecode
stopTimecode = Maybe StopTimecode
a} :: InputClippingSettings)

-- | Settings to identify the start of the clip.
inputClippingSettings_startTimecode :: Lens.Lens' InputClippingSettings (Prelude.Maybe StartTimecode)
inputClippingSettings_startTimecode :: (Maybe StartTimecode -> f (Maybe StartTimecode))
-> InputClippingSettings -> f InputClippingSettings
inputClippingSettings_startTimecode = (InputClippingSettings -> Maybe StartTimecode)
-> (InputClippingSettings
    -> Maybe StartTimecode -> InputClippingSettings)
-> Lens
     InputClippingSettings
     InputClippingSettings
     (Maybe StartTimecode)
     (Maybe StartTimecode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputClippingSettings' {Maybe StartTimecode
startTimecode :: Maybe StartTimecode
$sel:startTimecode:InputClippingSettings' :: InputClippingSettings -> Maybe StartTimecode
startTimecode} -> Maybe StartTimecode
startTimecode) (\s :: InputClippingSettings
s@InputClippingSettings' {} Maybe StartTimecode
a -> InputClippingSettings
s {$sel:startTimecode:InputClippingSettings' :: Maybe StartTimecode
startTimecode = Maybe StartTimecode
a} :: InputClippingSettings)

-- | The source of the timecodes in the source being clipped.
inputClippingSettings_inputTimecodeSource :: Lens.Lens' InputClippingSettings InputTimecodeSource
inputClippingSettings_inputTimecodeSource :: (InputTimecodeSource -> f InputTimecodeSource)
-> InputClippingSettings -> f InputClippingSettings
inputClippingSettings_inputTimecodeSource = (InputClippingSettings -> InputTimecodeSource)
-> (InputClippingSettings
    -> InputTimecodeSource -> InputClippingSettings)
-> Lens
     InputClippingSettings
     InputClippingSettings
     InputTimecodeSource
     InputTimecodeSource
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputClippingSettings' {InputTimecodeSource
inputTimecodeSource :: InputTimecodeSource
$sel:inputTimecodeSource:InputClippingSettings' :: InputClippingSettings -> InputTimecodeSource
inputTimecodeSource} -> InputTimecodeSource
inputTimecodeSource) (\s :: InputClippingSettings
s@InputClippingSettings' {} InputTimecodeSource
a -> InputClippingSettings
s {$sel:inputTimecodeSource:InputClippingSettings' :: InputTimecodeSource
inputTimecodeSource = InputTimecodeSource
a} :: InputClippingSettings)

instance Core.FromJSON InputClippingSettings where
  parseJSON :: Value -> Parser InputClippingSettings
parseJSON =
    String
-> (Object -> Parser InputClippingSettings)
-> Value
-> Parser InputClippingSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InputClippingSettings"
      ( \Object
x ->
          Maybe StopTimecode
-> Maybe StartTimecode
-> InputTimecodeSource
-> InputClippingSettings
InputClippingSettings'
            (Maybe StopTimecode
 -> Maybe StartTimecode
 -> InputTimecodeSource
 -> InputClippingSettings)
-> Parser (Maybe StopTimecode)
-> Parser
     (Maybe StartTimecode
      -> InputTimecodeSource -> InputClippingSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe StopTimecode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"stopTimecode")
            Parser
  (Maybe StartTimecode
   -> InputTimecodeSource -> InputClippingSettings)
-> Parser (Maybe StartTimecode)
-> Parser (InputTimecodeSource -> InputClippingSettings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe StartTimecode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"startTimecode")
            Parser (InputTimecodeSource -> InputClippingSettings)
-> Parser InputTimecodeSource -> Parser InputClippingSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser InputTimecodeSource
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"inputTimecodeSource")
      )

instance Prelude.Hashable InputClippingSettings

instance Prelude.NFData InputClippingSettings

instance Core.ToJSON InputClippingSettings where
  toJSON :: InputClippingSettings -> Value
toJSON InputClippingSettings' {Maybe StartTimecode
Maybe StopTimecode
InputTimecodeSource
inputTimecodeSource :: InputTimecodeSource
startTimecode :: Maybe StartTimecode
stopTimecode :: Maybe StopTimecode
$sel:inputTimecodeSource:InputClippingSettings' :: InputClippingSettings -> InputTimecodeSource
$sel:startTimecode:InputClippingSettings' :: InputClippingSettings -> Maybe StartTimecode
$sel:stopTimecode:InputClippingSettings' :: InputClippingSettings -> Maybe StopTimecode
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"stopTimecode" Text -> StopTimecode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (StopTimecode -> Pair) -> Maybe StopTimecode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StopTimecode
stopTimecode,
            (Text
"startTimecode" Text -> StartTimecode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (StartTimecode -> Pair) -> Maybe StartTimecode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StartTimecode
startTimecode,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"inputTimecodeSource" Text -> InputTimecodeSource -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= InputTimecodeSource
inputTimecodeSource)
          ]
      )