{-# 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.IVS.StopStream
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Disconnects the incoming RTMPS stream for the specified channel. Can be
-- used in conjunction with DeleteStreamKey to prevent further streaming to
-- a channel.
--
-- Many streaming client-software libraries automatically reconnect a
-- dropped RTMPS session, so to stop the stream permanently, you may want
-- to first revoke the @streamKey@ attached to the channel.
module Amazonka.IVS.StopStream
  ( -- * Creating a Request
    StopStream (..),
    newStopStream,

    -- * Request Lenses
    stopStream_channelArn,

    -- * Destructuring the Response
    StopStreamResponse (..),
    newStopStreamResponse,

    -- * Response Lenses
    stopStreamResponse_httpStatus,
  )
where

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

-- | /See:/ 'newStopStream' smart constructor.
data StopStream = StopStream'
  { -- | ARN of the channel for which the stream is to be stopped.
    StopStream -> Text
channelArn :: Prelude.Text
  }
  deriving (StopStream -> StopStream -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopStream -> StopStream -> Bool
$c/= :: StopStream -> StopStream -> Bool
== :: StopStream -> StopStream -> Bool
$c== :: StopStream -> StopStream -> Bool
Prelude.Eq, ReadPrec [StopStream]
ReadPrec StopStream
Int -> ReadS StopStream
ReadS [StopStream]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopStream]
$creadListPrec :: ReadPrec [StopStream]
readPrec :: ReadPrec StopStream
$creadPrec :: ReadPrec StopStream
readList :: ReadS [StopStream]
$creadList :: ReadS [StopStream]
readsPrec :: Int -> ReadS StopStream
$creadsPrec :: Int -> ReadS StopStream
Prelude.Read, Int -> StopStream -> ShowS
[StopStream] -> ShowS
StopStream -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopStream] -> ShowS
$cshowList :: [StopStream] -> ShowS
show :: StopStream -> String
$cshow :: StopStream -> String
showsPrec :: Int -> StopStream -> ShowS
$cshowsPrec :: Int -> StopStream -> ShowS
Prelude.Show, forall x. Rep StopStream x -> StopStream
forall x. StopStream -> Rep StopStream x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopStream x -> StopStream
$cfrom :: forall x. StopStream -> Rep StopStream x
Prelude.Generic)

-- |
-- Create a value of 'StopStream' 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:
--
-- 'channelArn', 'stopStream_channelArn' - ARN of the channel for which the stream is to be stopped.
newStopStream ::
  -- | 'channelArn'
  Prelude.Text ->
  StopStream
newStopStream :: Text -> StopStream
newStopStream Text
pChannelArn_ =
  StopStream' {$sel:channelArn:StopStream' :: Text
channelArn = Text
pChannelArn_}

-- | ARN of the channel for which the stream is to be stopped.
stopStream_channelArn :: Lens.Lens' StopStream Prelude.Text
stopStream_channelArn :: Lens' StopStream Text
stopStream_channelArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopStream' {Text
channelArn :: Text
$sel:channelArn:StopStream' :: StopStream -> Text
channelArn} -> Text
channelArn) (\s :: StopStream
s@StopStream' {} Text
a -> StopStream
s {$sel:channelArn:StopStream' :: Text
channelArn = Text
a} :: StopStream)

instance Core.AWSRequest StopStream where
  type AWSResponse StopStream = StopStreamResponse
  request :: (Service -> Service) -> StopStream -> Request StopStream
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 StopStream
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopStream)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> StopStreamResponse
StopStreamResponse'
            forall (f :: * -> *) a b. Functor 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 StopStream where
  hashWithSalt :: Int -> StopStream -> Int
hashWithSalt Int
_salt StopStream' {Text
channelArn :: Text
$sel:channelArn:StopStream' :: StopStream -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
channelArn

instance Prelude.NFData StopStream where
  rnf :: StopStream -> ()
rnf StopStream' {Text
channelArn :: Text
$sel:channelArn:StopStream' :: StopStream -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
channelArn

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

instance Data.ToJSON StopStream where
  toJSON :: StopStream -> Value
toJSON StopStream' {Text
channelArn :: Text
$sel:channelArn:StopStream' :: StopStream -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"channelArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
channelArn)]
      )

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

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

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

-- |
-- Create a value of 'StopStreamResponse' 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', 'stopStreamResponse_httpStatus' - The response's http status code.
newStopStreamResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  StopStreamResponse
newStopStreamResponse :: Int -> StopStreamResponse
newStopStreamResponse Int
pHttpStatus_ =
  StopStreamResponse' {$sel:httpStatus:StopStreamResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData StopStreamResponse where
  rnf :: StopStreamResponse -> ()
rnf StopStreamResponse' {Int
httpStatus :: Int
$sel:httpStatus:StopStreamResponse' :: StopStreamResponse -> Int
..} = forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus