{-# 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.ElasticTranscoder.Types.Clip
-- 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.ElasticTranscoder.Types.Clip where

import qualified Amazonka.Core as Core
import Amazonka.ElasticTranscoder.Types.TimeSpan
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Settings for one clip in a composition. All jobs in a playlist must have
-- the same clip settings.
--
-- /See:/ 'newClip' smart constructor.
data Clip = Clip'
  { -- | Settings that determine when a clip begins and how long it lasts.
    Clip -> Maybe TimeSpan
timeSpan :: Prelude.Maybe TimeSpan
  }
  deriving (Clip -> Clip -> Bool
(Clip -> Clip -> Bool) -> (Clip -> Clip -> Bool) -> Eq Clip
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Clip -> Clip -> Bool
$c/= :: Clip -> Clip -> Bool
== :: Clip -> Clip -> Bool
$c== :: Clip -> Clip -> Bool
Prelude.Eq, ReadPrec [Clip]
ReadPrec Clip
Int -> ReadS Clip
ReadS [Clip]
(Int -> ReadS Clip)
-> ReadS [Clip] -> ReadPrec Clip -> ReadPrec [Clip] -> Read Clip
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Clip]
$creadListPrec :: ReadPrec [Clip]
readPrec :: ReadPrec Clip
$creadPrec :: ReadPrec Clip
readList :: ReadS [Clip]
$creadList :: ReadS [Clip]
readsPrec :: Int -> ReadS Clip
$creadsPrec :: Int -> ReadS Clip
Prelude.Read, Int -> Clip -> ShowS
[Clip] -> ShowS
Clip -> String
(Int -> Clip -> ShowS)
-> (Clip -> String) -> ([Clip] -> ShowS) -> Show Clip
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Clip] -> ShowS
$cshowList :: [Clip] -> ShowS
show :: Clip -> String
$cshow :: Clip -> String
showsPrec :: Int -> Clip -> ShowS
$cshowsPrec :: Int -> Clip -> ShowS
Prelude.Show, (forall x. Clip -> Rep Clip x)
-> (forall x. Rep Clip x -> Clip) -> Generic Clip
forall x. Rep Clip x -> Clip
forall x. Clip -> Rep Clip x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Clip x -> Clip
$cfrom :: forall x. Clip -> Rep Clip x
Prelude.Generic)

-- |
-- Create a value of 'Clip' 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:
--
-- 'timeSpan', 'clip_timeSpan' - Settings that determine when a clip begins and how long it lasts.
newClip ::
  Clip
newClip :: Clip
newClip = Clip' :: Maybe TimeSpan -> Clip
Clip' {$sel:timeSpan:Clip' :: Maybe TimeSpan
timeSpan = Maybe TimeSpan
forall a. Maybe a
Prelude.Nothing}

-- | Settings that determine when a clip begins and how long it lasts.
clip_timeSpan :: Lens.Lens' Clip (Prelude.Maybe TimeSpan)
clip_timeSpan :: (Maybe TimeSpan -> f (Maybe TimeSpan)) -> Clip -> f Clip
clip_timeSpan = (Clip -> Maybe TimeSpan)
-> (Clip -> Maybe TimeSpan -> Clip)
-> Lens Clip Clip (Maybe TimeSpan) (Maybe TimeSpan)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Clip' {Maybe TimeSpan
timeSpan :: Maybe TimeSpan
$sel:timeSpan:Clip' :: Clip -> Maybe TimeSpan
timeSpan} -> Maybe TimeSpan
timeSpan) (\s :: Clip
s@Clip' {} Maybe TimeSpan
a -> Clip
s {$sel:timeSpan:Clip' :: Maybe TimeSpan
timeSpan = Maybe TimeSpan
a} :: Clip)

instance Core.FromJSON Clip where
  parseJSON :: Value -> Parser Clip
parseJSON =
    String -> (Object -> Parser Clip) -> Value -> Parser Clip
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Clip"
      (\Object
x -> Maybe TimeSpan -> Clip
Clip' (Maybe TimeSpan -> Clip) -> Parser (Maybe TimeSpan) -> Parser Clip
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe TimeSpan)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TimeSpan"))

instance Prelude.Hashable Clip

instance Prelude.NFData Clip

instance Core.ToJSON Clip where
  toJSON :: Clip -> Value
toJSON Clip' {Maybe TimeSpan
timeSpan :: Maybe TimeSpan
$sel:timeSpan:Clip' :: Clip -> Maybe TimeSpan
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"TimeSpan" Text -> TimeSpan -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TimeSpan -> Pair) -> Maybe TimeSpan -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TimeSpan
timeSpan]
      )