{-# 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.DeleteChannel
-- 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)
--
-- Deletes a channel. You must stop the channel before it can be deleted.
module Amazonka.MediaTailor.DeleteChannel
  ( -- * Creating a Request
    DeleteChannel (..),
    newDeleteChannel,

    -- * Request Lenses
    deleteChannel_channelName,

    -- * Destructuring the Response
    DeleteChannelResponse (..),
    newDeleteChannelResponse,

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

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

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

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

instance Prelude.NFData DeleteChannel

instance Core.ToHeaders DeleteChannel where
  toHeaders :: DeleteChannel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteChannel -> 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.ToPath DeleteChannel where
  toPath :: DeleteChannel -> ByteString
toPath DeleteChannel' {Text
channelName :: Text
$sel:channelName:DeleteChannel' :: DeleteChannel -> 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]

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

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

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

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

instance Prelude.NFData DeleteChannelResponse