{-# 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-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)
--
-- 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@.
module Amazonka.Rekognition.StartStreamProcessor
  ( -- * Creating a Request
    StartStreamProcessor (..),
    newStartStreamProcessor,

    -- * Request Lenses
    startStreamProcessor_name,

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

    -- * Response Lenses
    startStreamProcessorResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | The name of the stream processor to start processing.
    StartStreamProcessor -> Text
name :: Prelude.Text
  }
  deriving (StartStreamProcessor -> StartStreamProcessor -> Bool
(StartStreamProcessor -> StartStreamProcessor -> Bool)
-> (StartStreamProcessor -> StartStreamProcessor -> Bool)
-> Eq StartStreamProcessor
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]
(Int -> ReadS StartStreamProcessor)
-> ReadS [StartStreamProcessor]
-> ReadPrec StartStreamProcessor
-> ReadPrec [StartStreamProcessor]
-> Read 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
(Int -> StartStreamProcessor -> ShowS)
-> (StartStreamProcessor -> String)
-> ([StartStreamProcessor] -> ShowS)
-> Show StartStreamProcessor
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. StartStreamProcessor -> Rep StartStreamProcessor x)
-> (forall x. Rep StartStreamProcessor x -> StartStreamProcessor)
-> Generic StartStreamProcessor
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:
--
-- 'name', 'startStreamProcessor_name' - The name of the stream processor to start processing.
newStartStreamProcessor ::
  -- | 'name'
  Prelude.Text ->
  StartStreamProcessor
newStartStreamProcessor :: Text -> StartStreamProcessor
newStartStreamProcessor Text
pName_ =
  StartStreamProcessor' :: Text -> StartStreamProcessor
StartStreamProcessor' {$sel:name:StartStreamProcessor' :: Text
name = Text
pName_}

-- | The name of the stream processor to start processing.
startStreamProcessor_name :: Lens.Lens' StartStreamProcessor Prelude.Text
startStreamProcessor_name :: (Text -> f Text) -> StartStreamProcessor -> f StartStreamProcessor
startStreamProcessor_name = (StartStreamProcessor -> Text)
-> (StartStreamProcessor -> Text -> StartStreamProcessor)
-> Lens StartStreamProcessor StartStreamProcessor Text Text
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 :: StartStreamProcessor -> Request StartStreamProcessor
request = Service -> StartStreamProcessor -> Request StartStreamProcessor
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StartStreamProcessor
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartStreamProcessor)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse StartStreamProcessor))
-> Logger
-> Service
-> Proxy StartStreamProcessor
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse StartStreamProcessor)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> StartStreamProcessorResponse
StartStreamProcessorResponse'
            (Int -> StartStreamProcessorResponse)
-> Either String Int -> Either String StartStreamProcessorResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable StartStreamProcessor

instance Prelude.NFData StartStreamProcessor

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

instance Core.ToJSON StartStreamProcessor where
  toJSON :: StartStreamProcessor -> Value
toJSON StartStreamProcessor' {Text
name :: Text
$sel:name:StartStreamProcessor' :: StartStreamProcessor -> Text
..} =
    [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
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)]
      )

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

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

-- | /See:/ 'newStartStreamProcessorResponse' smart constructor.
data StartStreamProcessorResponse = StartStreamProcessorResponse'
  { -- | The response's http status code.
    StartStreamProcessorResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (StartStreamProcessorResponse
-> StartStreamProcessorResponse -> Bool
(StartStreamProcessorResponse
 -> StartStreamProcessorResponse -> Bool)
-> (StartStreamProcessorResponse
    -> StartStreamProcessorResponse -> Bool)
-> Eq StartStreamProcessorResponse
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]
(Int -> ReadS StartStreamProcessorResponse)
-> ReadS [StartStreamProcessorResponse]
-> ReadPrec StartStreamProcessorResponse
-> ReadPrec [StartStreamProcessorResponse]
-> Read 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
(Int -> StartStreamProcessorResponse -> ShowS)
-> (StartStreamProcessorResponse -> String)
-> ([StartStreamProcessorResponse] -> ShowS)
-> Show StartStreamProcessorResponse
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.
 StartStreamProcessorResponse -> Rep StartStreamProcessorResponse x)
-> (forall x.
    Rep StartStreamProcessorResponse x -> StartStreamProcessorResponse)
-> Generic StartStreamProcessorResponse
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:
--
-- 'httpStatus', 'startStreamProcessorResponse_httpStatus' - The response's http status code.
newStartStreamProcessorResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StartStreamProcessorResponse
newStartStreamProcessorResponse :: Int -> StartStreamProcessorResponse
newStartStreamProcessorResponse Int
pHttpStatus_ =
  StartStreamProcessorResponse' :: Int -> StartStreamProcessorResponse
StartStreamProcessorResponse'
    { $sel:httpStatus:StartStreamProcessorResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
startStreamProcessorResponse_httpStatus :: Lens.Lens' StartStreamProcessorResponse Prelude.Int
startStreamProcessorResponse_httpStatus :: (Int -> f Int)
-> StartStreamProcessorResponse -> f StartStreamProcessorResponse
startStreamProcessorResponse_httpStatus = (StartStreamProcessorResponse -> Int)
-> (StartStreamProcessorResponse
    -> Int -> StartStreamProcessorResponse)
-> Lens
     StartStreamProcessorResponse StartStreamProcessorResponse Int Int
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