{-# 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.MediaTailor.StopChannel
-- 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)
--
-- Stops a specific channel.
module Amazonka.MediaTailor.StopChannel
  ( -- * Creating a Request
    StopChannel (..),
    newStopChannel,

    -- * Request Lenses
    stopChannel_channelName,

    -- * Destructuring the Response
    StopChannelResponse (..),
    newStopChannelResponse,

    -- * Response Lenses
    stopChannelResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaTailor.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newStopChannel' smart constructor.
data StopChannel = StopChannel'
  { -- | The identifier for the channel you are working on.
    StopChannel -> Text
channelName :: Prelude.Text
  }
  deriving (StopChannel -> StopChannel -> Bool
(StopChannel -> StopChannel -> Bool)
-> (StopChannel -> StopChannel -> Bool) -> Eq StopChannel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StopChannel -> StopChannel -> Bool
$c/= :: StopChannel -> StopChannel -> Bool
== :: StopChannel -> StopChannel -> Bool
$c== :: StopChannel -> StopChannel -> Bool
Prelude.Eq, ReadPrec [StopChannel]
ReadPrec StopChannel
Int -> ReadS StopChannel
ReadS [StopChannel]
(Int -> ReadS StopChannel)
-> ReadS [StopChannel]
-> ReadPrec StopChannel
-> ReadPrec [StopChannel]
-> Read StopChannel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StopChannel]
$creadListPrec :: ReadPrec [StopChannel]
readPrec :: ReadPrec StopChannel
$creadPrec :: ReadPrec StopChannel
readList :: ReadS [StopChannel]
$creadList :: ReadS [StopChannel]
readsPrec :: Int -> ReadS StopChannel
$creadsPrec :: Int -> ReadS StopChannel
Prelude.Read, Int -> StopChannel -> ShowS
[StopChannel] -> ShowS
StopChannel -> String
(Int -> StopChannel -> ShowS)
-> (StopChannel -> String)
-> ([StopChannel] -> ShowS)
-> Show StopChannel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StopChannel] -> ShowS
$cshowList :: [StopChannel] -> ShowS
show :: StopChannel -> String
$cshow :: StopChannel -> String
showsPrec :: Int -> StopChannel -> ShowS
$cshowsPrec :: Int -> StopChannel -> ShowS
Prelude.Show, (forall x. StopChannel -> Rep StopChannel x)
-> (forall x. Rep StopChannel x -> StopChannel)
-> Generic StopChannel
forall x. Rep StopChannel x -> StopChannel
forall x. StopChannel -> Rep StopChannel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StopChannel x -> StopChannel
$cfrom :: forall x. StopChannel -> Rep StopChannel x
Prelude.Generic)

-- |
-- Create a value of 'StopChannel' 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:
--
-- 'channelName', 'stopChannel_channelName' - The identifier for the channel you are working on.
newStopChannel ::
  -- | 'channelName'
  Prelude.Text ->
  StopChannel
newStopChannel :: Text -> StopChannel
newStopChannel Text
pChannelName_ =
  StopChannel' :: Text -> StopChannel
StopChannel' {$sel:channelName:StopChannel' :: Text
channelName = Text
pChannelName_}

-- | The identifier for the channel you are working on.
stopChannel_channelName :: Lens.Lens' StopChannel Prelude.Text
stopChannel_channelName :: (Text -> f Text) -> StopChannel -> f StopChannel
stopChannel_channelName = (StopChannel -> Text)
-> (StopChannel -> Text -> StopChannel)
-> Lens StopChannel StopChannel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StopChannel' {Text
channelName :: Text
$sel:channelName:StopChannel' :: StopChannel -> Text
channelName} -> Text
channelName) (\s :: StopChannel
s@StopChannel' {} Text
a -> StopChannel
s {$sel:channelName:StopChannel' :: Text
channelName = Text
a} :: StopChannel)

instance Core.AWSRequest StopChannel where
  type AWSResponse StopChannel = StopChannelResponse
  request :: StopChannel -> Request StopChannel
request = Service -> StopChannel -> Request StopChannel
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StopChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopChannel)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse StopChannel))
-> Logger
-> Service
-> Proxy StopChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StopChannel)))
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 -> StopChannelResponse
StopChannelResponse'
            (Int -> StopChannelResponse)
-> Either String Int -> Either String StopChannelResponse
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 StopChannel

instance Prelude.NFData StopChannel

instance Core.ToHeaders StopChannel where
  toHeaders :: StopChannel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> StopChannel -> 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 StopChannel where
  toJSON :: StopChannel -> Value
toJSON = Value -> StopChannel -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

instance Core.ToPath StopChannel where
  toPath :: StopChannel -> ByteString
toPath StopChannel' {Text
channelName :: Text
$sel:channelName:StopChannel' :: StopChannel -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/channel/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
channelName, ByteString
"/stop"]

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

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

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

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

instance Prelude.NFData StopChannelResponse