{-# 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-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)
--
-- 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 Amazonka.IVS.Types
import qualified Amazonka.Lens as Lens
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
(StopStream -> StopStream -> Bool)
-> (StopStream -> StopStream -> Bool) -> Eq StopStream
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]
(Int -> ReadS StopStream)
-> ReadS [StopStream]
-> ReadPrec StopStream
-> ReadPrec [StopStream]
-> Read 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
(Int -> StopStream -> ShowS)
-> (StopStream -> String)
-> ([StopStream] -> ShowS)
-> Show StopStream
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. StopStream -> Rep StopStream x)
-> (forall x. Rep StopStream x -> StopStream) -> Generic StopStream
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' :: Text -> StopStream
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 :: (Text -> f Text) -> StopStream -> f StopStream
stopStream_channelArn = (StopStream -> Text)
-> (StopStream -> Text -> StopStream)
-> Lens StopStream StopStream Text Text
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 :: StopStream -> Request StopStream
request = Service -> StopStream -> Request StopStream
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopStream
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopStream)))
response =
    (Int
 -> ResponseHeaders -> () -> Either String (AWSResponse StopStream))
-> Logger
-> Service
-> Proxy StopStream
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopStream)))
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 -> StopStreamResponse
StopStreamResponse'
            (Int -> StopStreamResponse)
-> Either String Int -> Either String StopStreamResponse
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 StopStream

instance Prelude.NFData StopStream

instance Core.ToHeaders StopStream where
  toHeaders :: StopStream -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StopStream -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 StopStream where
  toJSON :: StopStream -> Value
toJSON StopStream' {Text
channelArn :: Text
$sel:channelArn:StopStream' :: StopStream -> 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
"channelArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
channelArn)]
      )

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

instance Core.ToQuery StopStream where
  toQuery :: StopStream -> QueryString
toQuery = QueryString -> StopStream -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(StopStreamResponse -> StopStreamResponse -> Bool)
-> (StopStreamResponse -> StopStreamResponse -> Bool)
-> Eq StopStreamResponse
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]
(Int -> ReadS StopStreamResponse)
-> ReadS [StopStreamResponse]
-> ReadPrec StopStreamResponse
-> ReadPrec [StopStreamResponse]
-> Read 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
(Int -> StopStreamResponse -> ShowS)
-> (StopStreamResponse -> String)
-> ([StopStreamResponse] -> ShowS)
-> Show StopStreamResponse
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. StopStreamResponse -> Rep StopStreamResponse x)
-> (forall x. Rep StopStreamResponse x -> StopStreamResponse)
-> Generic StopStreamResponse
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' :: Int -> StopStreamResponse
StopStreamResponse' {$sel:httpStatus:StopStreamResponse' :: Int
httpStatus = Int
pHttpStatus_}

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