{-# 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.FragmentSelector
-- 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.FragmentSelector where

import qualified Amazonka.Core as Core
import Amazonka.KinesisVideoArchivedMedia.Types.FragmentSelectorType
import Amazonka.KinesisVideoArchivedMedia.Types.TimestampRange
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the timestamp range and timestamp origin of a range of
-- fragments.
--
-- Only fragments with a start timestamp greater than or equal to the given
-- start time and less than or equal to the end time are returned. For
-- example, if a stream contains fragments with the following start
-- timestamps:
--
-- -   00:00:00
--
-- -   00:00:02
--
-- -   00:00:04
--
-- -   00:00:06
--
-- A fragment selector range with a start time of 00:00:01 and end time of
-- 00:00:04 would return the fragments with start times of 00:00:02 and
-- 00:00:04.
--
-- /See:/ 'newFragmentSelector' smart constructor.
data FragmentSelector = FragmentSelector'
  { -- | The origin of the timestamps to use (Server or Producer).
    FragmentSelector -> FragmentSelectorType
fragmentSelectorType :: FragmentSelectorType,
    -- | The range of timestamps to return.
    FragmentSelector -> TimestampRange
timestampRange :: TimestampRange
  }
  deriving (FragmentSelector -> FragmentSelector -> Bool
(FragmentSelector -> FragmentSelector -> Bool)
-> (FragmentSelector -> FragmentSelector -> Bool)
-> Eq FragmentSelector
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FragmentSelector -> FragmentSelector -> Bool
$c/= :: FragmentSelector -> FragmentSelector -> Bool
== :: FragmentSelector -> FragmentSelector -> Bool
$c== :: FragmentSelector -> FragmentSelector -> Bool
Prelude.Eq, ReadPrec [FragmentSelector]
ReadPrec FragmentSelector
Int -> ReadS FragmentSelector
ReadS [FragmentSelector]
(Int -> ReadS FragmentSelector)
-> ReadS [FragmentSelector]
-> ReadPrec FragmentSelector
-> ReadPrec [FragmentSelector]
-> Read FragmentSelector
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FragmentSelector]
$creadListPrec :: ReadPrec [FragmentSelector]
readPrec :: ReadPrec FragmentSelector
$creadPrec :: ReadPrec FragmentSelector
readList :: ReadS [FragmentSelector]
$creadList :: ReadS [FragmentSelector]
readsPrec :: Int -> ReadS FragmentSelector
$creadsPrec :: Int -> ReadS FragmentSelector
Prelude.Read, Int -> FragmentSelector -> ShowS
[FragmentSelector] -> ShowS
FragmentSelector -> String
(Int -> FragmentSelector -> ShowS)
-> (FragmentSelector -> String)
-> ([FragmentSelector] -> ShowS)
-> Show FragmentSelector
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FragmentSelector] -> ShowS
$cshowList :: [FragmentSelector] -> ShowS
show :: FragmentSelector -> String
$cshow :: FragmentSelector -> String
showsPrec :: Int -> FragmentSelector -> ShowS
$cshowsPrec :: Int -> FragmentSelector -> ShowS
Prelude.Show, (forall x. FragmentSelector -> Rep FragmentSelector x)
-> (forall x. Rep FragmentSelector x -> FragmentSelector)
-> Generic FragmentSelector
forall x. Rep FragmentSelector x -> FragmentSelector
forall x. FragmentSelector -> Rep FragmentSelector x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FragmentSelector x -> FragmentSelector
$cfrom :: forall x. FragmentSelector -> Rep FragmentSelector x
Prelude.Generic)

-- |
-- Create a value of 'FragmentSelector' 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', 'fragmentSelector_fragmentSelectorType' - The origin of the timestamps to use (Server or Producer).
--
-- 'timestampRange', 'fragmentSelector_timestampRange' - The range of timestamps to return.
newFragmentSelector ::
  -- | 'fragmentSelectorType'
  FragmentSelectorType ->
  -- | 'timestampRange'
  TimestampRange ->
  FragmentSelector
newFragmentSelector :: FragmentSelectorType -> TimestampRange -> FragmentSelector
newFragmentSelector
  FragmentSelectorType
pFragmentSelectorType_
  TimestampRange
pTimestampRange_ =
    FragmentSelector' :: FragmentSelectorType -> TimestampRange -> FragmentSelector
FragmentSelector'
      { $sel:fragmentSelectorType:FragmentSelector' :: FragmentSelectorType
fragmentSelectorType =
          FragmentSelectorType
pFragmentSelectorType_,
        $sel:timestampRange:FragmentSelector' :: TimestampRange
timestampRange = TimestampRange
pTimestampRange_
      }

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

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

instance Prelude.Hashable FragmentSelector

instance Prelude.NFData FragmentSelector

instance Core.ToJSON FragmentSelector where
  toJSON :: FragmentSelector -> Value
toJSON FragmentSelector' {FragmentSelectorType
TimestampRange
timestampRange :: TimestampRange
fragmentSelectorType :: FragmentSelectorType
$sel:timestampRange:FragmentSelector' :: FragmentSelector -> TimestampRange
$sel:fragmentSelectorType:FragmentSelector' :: FragmentSelector -> FragmentSelectorType
..} =
    [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 -> FragmentSelectorType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= FragmentSelectorType
fragmentSelectorType
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"TimestampRange" Text -> TimestampRange -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TimestampRange
timestampRange)
          ]
      )