{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Rekognition.StartStreamProcessor
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Starts processing a stream processor. You create a stream processor by
-- calling CreateStreamProcessor. To tell @StartStreamProcessor@ which
-- stream processor to start, use the value of the @Name@ field specified
-- in the call to @CreateStreamProcessor@.
--
-- If you are using a label detection stream processor to detect labels,
-- you need to provide a @Start selector@ and a @Stop selector@ to
-- determine the length of the stream processing time.
module Amazonka.Rekognition.StartStreamProcessor
  ( -- * Creating a Request
    StartStreamProcessor (..),
    newStartStreamProcessor,

    -- * Request Lenses
    startStreamProcessor_startSelector,
    startStreamProcessor_stopSelector,
    startStreamProcessor_name,

    -- * Destructuring the Response
    StartStreamProcessorResponse (..),
    newStartStreamProcessorResponse,

    -- * Response Lenses
    startStreamProcessorResponse_sessionId,
    startStreamProcessorResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.Rekognition.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newStartStreamProcessor' smart constructor.
data StartStreamProcessor = StartStreamProcessor'
  { -- | Specifies the starting point in the Kinesis stream to start processing.
    -- You can use the producer timestamp or the fragment number. If you use
    -- the producer timestamp, you must put the time in milliseconds. For more
    -- information about fragment numbers, see
    -- <https://docs.aws.amazon.com/kinesisvideostreams/latest/dg/API_reader_Fragment.html Fragment>.
    --
    -- This is a required parameter for label detection stream processors and
    -- should not be used to start a face search stream processor.
    StartStreamProcessor -> Maybe StreamProcessingStartSelector
startSelector :: Prelude.Maybe StreamProcessingStartSelector,
    -- | Specifies when to stop processing the stream. You can specify a maximum
    -- amount of time to process the video.
    --
    -- This is a required parameter for label detection stream processors and
    -- should not be used to start a face search stream processor.
    StartStreamProcessor -> Maybe StreamProcessingStopSelector
stopSelector :: Prelude.Maybe StreamProcessingStopSelector,
    -- | The name of the stream processor to start processing.
    StartStreamProcessor -> Text
name :: Prelude.Text
  }
  deriving (StartStreamProcessor -> StartStreamProcessor -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartStreamProcessor -> StartStreamProcessor -> Bool
$c/= :: StartStreamProcessor -> StartStreamProcessor -> Bool
== :: StartStreamProcessor -> StartStreamProcessor -> Bool
$c== :: StartStreamProcessor -> StartStreamProcessor -> Bool
Prelude.Eq, ReadPrec [StartStreamProcessor]
ReadPrec StartStreamProcessor
Int -> ReadS StartStreamProcessor
ReadS [StartStreamProcessor]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartStreamProcessor]
$creadListPrec :: ReadPrec [StartStreamProcessor]
readPrec :: ReadPrec StartStreamProcessor
$creadPrec :: ReadPrec StartStreamProcessor
readList :: ReadS [StartStreamProcessor]
$creadList :: ReadS [StartStreamProcessor]
readsPrec :: Int -> ReadS StartStreamProcessor
$creadsPrec :: Int -> ReadS StartStreamProcessor
Prelude.Read, Int -> StartStreamProcessor -> ShowS
[StartStreamProcessor] -> ShowS
StartStreamProcessor -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartStreamProcessor] -> ShowS
$cshowList :: [StartStreamProcessor] -> ShowS
show :: StartStreamProcessor -> String
$cshow :: StartStreamProcessor -> String
showsPrec :: Int -> StartStreamProcessor -> ShowS
$cshowsPrec :: Int -> StartStreamProcessor -> ShowS
Prelude.Show, forall x. Rep StartStreamProcessor x -> StartStreamProcessor
forall x. StartStreamProcessor -> Rep StartStreamProcessor x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StartStreamProcessor x -> StartStreamProcessor
$cfrom :: forall x. StartStreamProcessor -> Rep StartStreamProcessor x
Prelude.Generic)

-- |
-- Create a value of 'StartStreamProcessor' 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:
--
-- 'startSelector', 'startStreamProcessor_startSelector' - Specifies the starting point in the Kinesis stream to start processing.
-- You can use the producer timestamp or the fragment number. If you use
-- the producer timestamp, you must put the time in milliseconds. For more
-- information about fragment numbers, see
-- <https://docs.aws.amazon.com/kinesisvideostreams/latest/dg/API_reader_Fragment.html Fragment>.
--
-- This is a required parameter for label detection stream processors and
-- should not be used to start a face search stream processor.
--
-- 'stopSelector', 'startStreamProcessor_stopSelector' - Specifies when to stop processing the stream. You can specify a maximum
-- amount of time to process the video.
--
-- This is a required parameter for label detection stream processors and
-- should not be used to start a face search stream processor.
--
-- 'name', 'startStreamProcessor_name' - The name of the stream processor to start processing.
newStartStreamProcessor ::
  -- | 'name'
  Prelude.Text ->
  StartStreamProcessor
newStartStreamProcessor :: Text -> StartStreamProcessor
newStartStreamProcessor Text
pName_ =
  StartStreamProcessor'
    { $sel:startSelector:StartStreamProcessor' :: Maybe StreamProcessingStartSelector
startSelector =
        forall a. Maybe a
Prelude.Nothing,
      $sel:stopSelector:StartStreamProcessor' :: Maybe StreamProcessingStopSelector
stopSelector = forall a. Maybe a
Prelude.Nothing,
      $sel:name:StartStreamProcessor' :: Text
name = Text
pName_
    }

-- | Specifies the starting point in the Kinesis stream to start processing.
-- You can use the producer timestamp or the fragment number. If you use
-- the producer timestamp, you must put the time in milliseconds. For more
-- information about fragment numbers, see
-- <https://docs.aws.amazon.com/kinesisvideostreams/latest/dg/API_reader_Fragment.html Fragment>.
--
-- This is a required parameter for label detection stream processors and
-- should not be used to start a face search stream processor.
startStreamProcessor_startSelector :: Lens.Lens' StartStreamProcessor (Prelude.Maybe StreamProcessingStartSelector)
startStreamProcessor_startSelector :: Lens' StartStreamProcessor (Maybe StreamProcessingStartSelector)
startStreamProcessor_startSelector = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartStreamProcessor' {Maybe StreamProcessingStartSelector
startSelector :: Maybe StreamProcessingStartSelector
$sel:startSelector:StartStreamProcessor' :: StartStreamProcessor -> Maybe StreamProcessingStartSelector
startSelector} -> Maybe StreamProcessingStartSelector
startSelector) (\s :: StartStreamProcessor
s@StartStreamProcessor' {} Maybe StreamProcessingStartSelector
a -> StartStreamProcessor
s {$sel:startSelector:StartStreamProcessor' :: Maybe StreamProcessingStartSelector
startSelector = Maybe StreamProcessingStartSelector
a} :: StartStreamProcessor)

-- | Specifies when to stop processing the stream. You can specify a maximum
-- amount of time to process the video.
--
-- This is a required parameter for label detection stream processors and
-- should not be used to start a face search stream processor.
startStreamProcessor_stopSelector :: Lens.Lens' StartStreamProcessor (Prelude.Maybe StreamProcessingStopSelector)
startStreamProcessor_stopSelector :: Lens' StartStreamProcessor (Maybe StreamProcessingStopSelector)
startStreamProcessor_stopSelector = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartStreamProcessor' {Maybe StreamProcessingStopSelector
stopSelector :: Maybe StreamProcessingStopSelector
$sel:stopSelector:StartStreamProcessor' :: StartStreamProcessor -> Maybe StreamProcessingStopSelector
stopSelector} -> Maybe StreamProcessingStopSelector
stopSelector) (\s :: StartStreamProcessor
s@StartStreamProcessor' {} Maybe StreamProcessingStopSelector
a -> StartStreamProcessor
s {$sel:stopSelector:StartStreamProcessor' :: Maybe StreamProcessingStopSelector
stopSelector = Maybe StreamProcessingStopSelector
a} :: StartStreamProcessor)

-- | The name of the stream processor to start processing.
startStreamProcessor_name :: Lens.Lens' StartStreamProcessor Prelude.Text
startStreamProcessor_name :: Lens' StartStreamProcessor Text
startStreamProcessor_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartStreamProcessor' {Text
name :: Text
$sel:name:StartStreamProcessor' :: StartStreamProcessor -> Text
name} -> Text
name) (\s :: StartStreamProcessor
s@StartStreamProcessor' {} Text
a -> StartStreamProcessor
s {$sel:name:StartStreamProcessor' :: Text
name = Text
a} :: StartStreamProcessor)

instance Core.AWSRequest StartStreamProcessor where
  type
    AWSResponse StartStreamProcessor =
      StartStreamProcessorResponse
  request :: (Service -> Service)
-> StartStreamProcessor -> Request StartStreamProcessor
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy StartStreamProcessor
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartStreamProcessor)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> StartStreamProcessorResponse
StartStreamProcessorResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"SessionId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable StartStreamProcessor where
  hashWithSalt :: Int -> StartStreamProcessor -> Int
hashWithSalt Int
_salt StartStreamProcessor' {Maybe StreamProcessingStartSelector
Maybe StreamProcessingStopSelector
Text
name :: Text
stopSelector :: Maybe StreamProcessingStopSelector
startSelector :: Maybe StreamProcessingStartSelector
$sel:name:StartStreamProcessor' :: StartStreamProcessor -> Text
$sel:stopSelector:StartStreamProcessor' :: StartStreamProcessor -> Maybe StreamProcessingStopSelector
$sel:startSelector:StartStreamProcessor' :: StartStreamProcessor -> Maybe StreamProcessingStartSelector
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StreamProcessingStartSelector
startSelector
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StreamProcessingStopSelector
stopSelector
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData StartStreamProcessor where
  rnf :: StartStreamProcessor -> ()
rnf StartStreamProcessor' {Maybe StreamProcessingStartSelector
Maybe StreamProcessingStopSelector
Text
name :: Text
stopSelector :: Maybe StreamProcessingStopSelector
startSelector :: Maybe StreamProcessingStartSelector
$sel:name:StartStreamProcessor' :: StartStreamProcessor -> Text
$sel:stopSelector:StartStreamProcessor' :: StartStreamProcessor -> Maybe StreamProcessingStopSelector
$sel:startSelector:StartStreamProcessor' :: StartStreamProcessor -> Maybe StreamProcessingStartSelector
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe StreamProcessingStartSelector
startSelector
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe StreamProcessingStopSelector
stopSelector
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToHeaders StartStreamProcessor where
  toHeaders :: StartStreamProcessor -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"RekognitionService.StartStreamProcessor" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON StartStreamProcessor where
  toJSON :: StartStreamProcessor -> Value
toJSON StartStreamProcessor' {Maybe StreamProcessingStartSelector
Maybe StreamProcessingStopSelector
Text
name :: Text
stopSelector :: Maybe StreamProcessingStopSelector
startSelector :: Maybe StreamProcessingStartSelector
$sel:name:StartStreamProcessor' :: StartStreamProcessor -> Text
$sel:stopSelector:StartStreamProcessor' :: StartStreamProcessor -> Maybe StreamProcessingStopSelector
$sel:startSelector:StartStreamProcessor' :: StartStreamProcessor -> Maybe StreamProcessingStartSelector
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"StartSelector" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StreamProcessingStartSelector
startSelector,
            (Key
"StopSelector" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StreamProcessingStopSelector
stopSelector,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)
          ]
      )

instance Data.ToPath StartStreamProcessor where
  toPath :: StartStreamProcessor -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery StartStreamProcessor where
  toQuery :: StartStreamProcessor -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newStartStreamProcessorResponse' smart constructor.
data StartStreamProcessorResponse = StartStreamProcessorResponse'
  { -- | A unique identifier for the stream processing session.
    StartStreamProcessorResponse -> Maybe Text
sessionId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    StartStreamProcessorResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StartStreamProcessorResponse
-> StartStreamProcessorResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StartStreamProcessorResponse
-> StartStreamProcessorResponse -> Bool
$c/= :: StartStreamProcessorResponse
-> StartStreamProcessorResponse -> Bool
== :: StartStreamProcessorResponse
-> StartStreamProcessorResponse -> Bool
$c== :: StartStreamProcessorResponse
-> StartStreamProcessorResponse -> Bool
Prelude.Eq, ReadPrec [StartStreamProcessorResponse]
ReadPrec StartStreamProcessorResponse
Int -> ReadS StartStreamProcessorResponse
ReadS [StartStreamProcessorResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StartStreamProcessorResponse]
$creadListPrec :: ReadPrec [StartStreamProcessorResponse]
readPrec :: ReadPrec StartStreamProcessorResponse
$creadPrec :: ReadPrec StartStreamProcessorResponse
readList :: ReadS [StartStreamProcessorResponse]
$creadList :: ReadS [StartStreamProcessorResponse]
readsPrec :: Int -> ReadS StartStreamProcessorResponse
$creadsPrec :: Int -> ReadS StartStreamProcessorResponse
Prelude.Read, Int -> StartStreamProcessorResponse -> ShowS
[StartStreamProcessorResponse] -> ShowS
StartStreamProcessorResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StartStreamProcessorResponse] -> ShowS
$cshowList :: [StartStreamProcessorResponse] -> ShowS
show :: StartStreamProcessorResponse -> String
$cshow :: StartStreamProcessorResponse -> String
showsPrec :: Int -> StartStreamProcessorResponse -> ShowS
$cshowsPrec :: Int -> StartStreamProcessorResponse -> ShowS
Prelude.Show, forall x.
Rep StartStreamProcessorResponse x -> StartStreamProcessorResponse
forall x.
StartStreamProcessorResponse -> Rep StartStreamProcessorResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StartStreamProcessorResponse x -> StartStreamProcessorResponse
$cfrom :: forall x.
StartStreamProcessorResponse -> Rep StartStreamProcessorResponse x
Prelude.Generic)

-- |
-- Create a value of 'StartStreamProcessorResponse' 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:
--
-- 'sessionId', 'startStreamProcessorResponse_sessionId' - A unique identifier for the stream processing session.
--
-- 'httpStatus', 'startStreamProcessorResponse_httpStatus' - The response's http status code.
newStartStreamProcessorResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartStreamProcessorResponse
newStartStreamProcessorResponse :: Int -> StartStreamProcessorResponse
newStartStreamProcessorResponse Int
pHttpStatus_ =
  StartStreamProcessorResponse'
    { $sel:sessionId:StartStreamProcessorResponse' :: Maybe Text
sessionId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:StartStreamProcessorResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A unique identifier for the stream processing session.
startStreamProcessorResponse_sessionId :: Lens.Lens' StartStreamProcessorResponse (Prelude.Maybe Prelude.Text)
startStreamProcessorResponse_sessionId :: Lens' StartStreamProcessorResponse (Maybe Text)
startStreamProcessorResponse_sessionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartStreamProcessorResponse' {Maybe Text
sessionId :: Maybe Text
$sel:sessionId:StartStreamProcessorResponse' :: StartStreamProcessorResponse -> Maybe Text
sessionId} -> Maybe Text
sessionId) (\s :: StartStreamProcessorResponse
s@StartStreamProcessorResponse' {} Maybe Text
a -> StartStreamProcessorResponse
s {$sel:sessionId:StartStreamProcessorResponse' :: Maybe Text
sessionId = Maybe Text
a} :: StartStreamProcessorResponse)

-- | The response's http status code.
startStreamProcessorResponse_httpStatus :: Lens.Lens' StartStreamProcessorResponse Prelude.Int
startStreamProcessorResponse_httpStatus :: Lens' StartStreamProcessorResponse Int
startStreamProcessorResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartStreamProcessorResponse' {Int
httpStatus :: Int
$sel:httpStatus:StartStreamProcessorResponse' :: StartStreamProcessorResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: StartStreamProcessorResponse
s@StartStreamProcessorResponse' {} Int
a -> StartStreamProcessorResponse
s {$sel:httpStatus:StartStreamProcessorResponse' :: Int
httpStatus = Int
a} :: StartStreamProcessorResponse)

instance Prelude.NFData StartStreamProcessorResponse where
  rnf :: StartStreamProcessorResponse -> ()
rnf StartStreamProcessorResponse' {Int
Maybe Text
httpStatus :: Int
sessionId :: Maybe Text
$sel:httpStatus:StartStreamProcessorResponse' :: StartStreamProcessorResponse -> Int
$sel:sessionId:StartStreamProcessorResponse' :: StartStreamProcessorResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sessionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus