{-# 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.KinesisVideoArchivedMedia.Types.ClipFragmentSelector
-- 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.KinesisVideoArchivedMedia.Types.ClipFragmentSelector where

import qualified Amazonka.Core as Core
import Amazonka.KinesisVideoArchivedMedia.Types.ClipFragmentSelectorType
import Amazonka.KinesisVideoArchivedMedia.Types.ClipTimestampRange
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the timestamp range and timestamp origin of a range of
-- fragments.
--
-- Fragments that have duplicate producer timestamps are deduplicated. This
-- means that if producers are producing a stream of fragments with
-- producer timestamps that are approximately equal to the true clock time,
-- the clip will contain all of the fragments within the requested
-- timestamp range. If some fragments are ingested within the same time
-- range and very different points in time, only the oldest ingested
-- collection of fragments are returned.
--
-- /See:/ 'newClipFragmentSelector' smart constructor.
data ClipFragmentSelector = ClipFragmentSelector'
  { -- | The origin of the timestamps to use (Server or Producer).
    ClipFragmentSelector -> ClipFragmentSelectorType
fragmentSelectorType :: ClipFragmentSelectorType,
    -- | The range of timestamps to return.
    ClipFragmentSelector -> ClipTimestampRange
timestampRange :: ClipTimestampRange
  }
  deriving (ClipFragmentSelector -> ClipFragmentSelector -> Bool
(ClipFragmentSelector -> ClipFragmentSelector -> Bool)
-> (ClipFragmentSelector -> ClipFragmentSelector -> Bool)
-> Eq ClipFragmentSelector
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClipFragmentSelector -> ClipFragmentSelector -> Bool
$c/= :: ClipFragmentSelector -> ClipFragmentSelector -> Bool
== :: ClipFragmentSelector -> ClipFragmentSelector -> Bool
$c== :: ClipFragmentSelector -> ClipFragmentSelector -> Bool
Prelude.Eq, ReadPrec [ClipFragmentSelector]
ReadPrec ClipFragmentSelector
Int -> ReadS ClipFragmentSelector
ReadS [ClipFragmentSelector]
(Int -> ReadS ClipFragmentSelector)
-> ReadS [ClipFragmentSelector]
-> ReadPrec ClipFragmentSelector
-> ReadPrec [ClipFragmentSelector]
-> Read ClipFragmentSelector
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ClipFragmentSelector]
$creadListPrec :: ReadPrec [ClipFragmentSelector]
readPrec :: ReadPrec ClipFragmentSelector
$creadPrec :: ReadPrec ClipFragmentSelector
readList :: ReadS [ClipFragmentSelector]
$creadList :: ReadS [ClipFragmentSelector]
readsPrec :: Int -> ReadS ClipFragmentSelector
$creadsPrec :: Int -> ReadS ClipFragmentSelector
Prelude.Read, Int -> ClipFragmentSelector -> ShowS
[ClipFragmentSelector] -> ShowS
ClipFragmentSelector -> String
(Int -> ClipFragmentSelector -> ShowS)
-> (ClipFragmentSelector -> String)
-> ([ClipFragmentSelector] -> ShowS)
-> Show ClipFragmentSelector
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClipFragmentSelector] -> ShowS
$cshowList :: [ClipFragmentSelector] -> ShowS
show :: ClipFragmentSelector -> String
$cshow :: ClipFragmentSelector -> String
showsPrec :: Int -> ClipFragmentSelector -> ShowS
$cshowsPrec :: Int -> ClipFragmentSelector -> ShowS
Prelude.Show, (forall x. ClipFragmentSelector -> Rep ClipFragmentSelector x)
-> (forall x. Rep ClipFragmentSelector x -> ClipFragmentSelector)
-> Generic ClipFragmentSelector
forall x. Rep ClipFragmentSelector x -> ClipFragmentSelector
forall x. ClipFragmentSelector -> Rep ClipFragmentSelector x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ClipFragmentSelector x -> ClipFragmentSelector
$cfrom :: forall x. ClipFragmentSelector -> Rep ClipFragmentSelector x
Prelude.Generic)

-- |
-- Create a value of 'ClipFragmentSelector' 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:
--
-- 'fragmentSelectorType', 'clipFragmentSelector_fragmentSelectorType' - The origin of the timestamps to use (Server or Producer).
--
-- 'timestampRange', 'clipFragmentSelector_timestampRange' - The range of timestamps to return.
newClipFragmentSelector ::
  -- | 'fragmentSelectorType'
  ClipFragmentSelectorType ->
  -- | 'timestampRange'
  ClipTimestampRange ->
  ClipFragmentSelector
newClipFragmentSelector :: ClipFragmentSelectorType
-> ClipTimestampRange -> ClipFragmentSelector
newClipFragmentSelector
  ClipFragmentSelectorType
pFragmentSelectorType_
  ClipTimestampRange
pTimestampRange_ =
    ClipFragmentSelector' :: ClipFragmentSelectorType
-> ClipTimestampRange -> ClipFragmentSelector
ClipFragmentSelector'
      { $sel:fragmentSelectorType:ClipFragmentSelector' :: ClipFragmentSelectorType
fragmentSelectorType =
          ClipFragmentSelectorType
pFragmentSelectorType_,
        $sel:timestampRange:ClipFragmentSelector' :: ClipTimestampRange
timestampRange = ClipTimestampRange
pTimestampRange_
      }

-- | The origin of the timestamps to use (Server or Producer).
clipFragmentSelector_fragmentSelectorType :: Lens.Lens' ClipFragmentSelector ClipFragmentSelectorType
clipFragmentSelector_fragmentSelectorType :: (ClipFragmentSelectorType -> f ClipFragmentSelectorType)
-> ClipFragmentSelector -> f ClipFragmentSelector
clipFragmentSelector_fragmentSelectorType = (ClipFragmentSelector -> ClipFragmentSelectorType)
-> (ClipFragmentSelector
    -> ClipFragmentSelectorType -> ClipFragmentSelector)
-> Lens
     ClipFragmentSelector
     ClipFragmentSelector
     ClipFragmentSelectorType
     ClipFragmentSelectorType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClipFragmentSelector' {ClipFragmentSelectorType
fragmentSelectorType :: ClipFragmentSelectorType
$sel:fragmentSelectorType:ClipFragmentSelector' :: ClipFragmentSelector -> ClipFragmentSelectorType
fragmentSelectorType} -> ClipFragmentSelectorType
fragmentSelectorType) (\s :: ClipFragmentSelector
s@ClipFragmentSelector' {} ClipFragmentSelectorType
a -> ClipFragmentSelector
s {$sel:fragmentSelectorType:ClipFragmentSelector' :: ClipFragmentSelectorType
fragmentSelectorType = ClipFragmentSelectorType
a} :: ClipFragmentSelector)

-- | The range of timestamps to return.
clipFragmentSelector_timestampRange :: Lens.Lens' ClipFragmentSelector ClipTimestampRange
clipFragmentSelector_timestampRange :: (ClipTimestampRange -> f ClipTimestampRange)
-> ClipFragmentSelector -> f ClipFragmentSelector
clipFragmentSelector_timestampRange = (ClipFragmentSelector -> ClipTimestampRange)
-> (ClipFragmentSelector
    -> ClipTimestampRange -> ClipFragmentSelector)
-> Lens
     ClipFragmentSelector
     ClipFragmentSelector
     ClipTimestampRange
     ClipTimestampRange
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClipFragmentSelector' {ClipTimestampRange
timestampRange :: ClipTimestampRange
$sel:timestampRange:ClipFragmentSelector' :: ClipFragmentSelector -> ClipTimestampRange
timestampRange} -> ClipTimestampRange
timestampRange) (\s :: ClipFragmentSelector
s@ClipFragmentSelector' {} ClipTimestampRange
a -> ClipFragmentSelector
s {$sel:timestampRange:ClipFragmentSelector' :: ClipTimestampRange
timestampRange = ClipTimestampRange
a} :: ClipFragmentSelector)

instance Prelude.Hashable ClipFragmentSelector

instance Prelude.NFData ClipFragmentSelector

instance Core.ToJSON ClipFragmentSelector where
  toJSON :: ClipFragmentSelector -> Value
toJSON ClipFragmentSelector' {ClipFragmentSelectorType
ClipTimestampRange
timestampRange :: ClipTimestampRange
fragmentSelectorType :: ClipFragmentSelectorType
$sel:timestampRange:ClipFragmentSelector' :: ClipFragmentSelector -> ClipTimestampRange
$sel:fragmentSelectorType:ClipFragmentSelector' :: ClipFragmentSelector -> ClipFragmentSelectorType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"FragmentSelectorType"
                  Text -> ClipFragmentSelectorType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ClipFragmentSelectorType
fragmentSelectorType
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"TimestampRange" Text -> ClipTimestampRange -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ClipTimestampRange
timestampRange)
          ]
      )