{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.KinesisVideoArchivedMedia.Types.ClipFragmentSelector where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.KinesisVideoArchivedMedia.Types.ClipFragmentSelectorType
import Amazonka.KinesisVideoArchivedMedia.Types.ClipTimestampRange
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
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]
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
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. 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'
      { $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 :: Lens' ClipFragmentSelector ClipFragmentSelectorType
clipFragmentSelector_fragmentSelectorType = 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 :: Lens' ClipFragmentSelector ClipTimestampRange
clipFragmentSelector_timestampRange = 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 where
  hashWithSalt :: Int -> ClipFragmentSelector -> Int
hashWithSalt Int
_salt ClipFragmentSelector' {ClipFragmentSelectorType
ClipTimestampRange
timestampRange :: ClipTimestampRange
fragmentSelectorType :: ClipFragmentSelectorType
$sel:timestampRange:ClipFragmentSelector' :: ClipFragmentSelector -> ClipTimestampRange
$sel:fragmentSelectorType:ClipFragmentSelector' :: ClipFragmentSelector -> ClipFragmentSelectorType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ClipFragmentSelectorType
fragmentSelectorType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ClipTimestampRange
timestampRange

instance Prelude.NFData ClipFragmentSelector where
  rnf :: ClipFragmentSelector -> ()
rnf ClipFragmentSelector' {ClipFragmentSelectorType
ClipTimestampRange
timestampRange :: ClipTimestampRange
fragmentSelectorType :: ClipFragmentSelectorType
$sel:timestampRange:ClipFragmentSelector' :: ClipFragmentSelector -> ClipTimestampRange
$sel:fragmentSelectorType:ClipFragmentSelector' :: ClipFragmentSelector -> ClipFragmentSelectorType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf ClipFragmentSelectorType
fragmentSelectorType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ClipTimestampRange
timestampRange

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"FragmentSelectorType"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ClipFragmentSelectorType
fragmentSelectorType
              ),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"TimestampRange" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ClipTimestampRange
timestampRange)
          ]
      )