{-# 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.DeleteChannel
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes the specified channel and its associated stream keys.
--
-- If you try to delete a live channel, you will get an error (409
-- ConflictException). To delete a channel that is live, call StopStream,
-- wait for the Amazon EventBridge \"Stream End\" event (to verify that the
-- stream\'s state was changed from Live to Offline), then call
-- DeleteChannel. (See
-- <https://docs.aws.amazon.com/ivs/latest/userguide/eventbridge.html Using EventBridge with Amazon IVS>.)
module Amazonka.IVS.DeleteChannel
  ( -- * Creating a Request
    DeleteChannel (..),
    newDeleteChannel,

    -- * Request Lenses
    deleteChannel_arn,

    -- * Destructuring the Response
    DeleteChannelResponse (..),
    newDeleteChannelResponse,
  )
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:/ 'newDeleteChannel' smart constructor.
data DeleteChannel = DeleteChannel'
  { -- | ARN of the channel to be deleted.
    DeleteChannel -> Text
arn :: Prelude.Text
  }
  deriving (DeleteChannel -> DeleteChannel -> Bool
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]
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
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. 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:
--
-- 'arn', 'deleteChannel_arn' - ARN of the channel to be deleted.
newDeleteChannel ::
  -- | 'arn'
  Prelude.Text ->
  DeleteChannel
newDeleteChannel :: Text -> DeleteChannel
newDeleteChannel Text
pArn_ = DeleteChannel' {$sel:arn:DeleteChannel' :: Text
arn = Text
pArn_}

-- | ARN of the channel to be deleted.
deleteChannel_arn :: Lens.Lens' DeleteChannel Prelude.Text
deleteChannel_arn :: Lens' DeleteChannel Text
deleteChannel_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteChannel' {Text
arn :: Text
$sel:arn:DeleteChannel' :: DeleteChannel -> Text
arn} -> Text
arn) (\s :: DeleteChannel
s@DeleteChannel' {} Text
a -> DeleteChannel
s {$sel:arn:DeleteChannel' :: Text
arn = Text
a} :: DeleteChannel)

instance Core.AWSRequest DeleteChannel where
  type
    AWSResponse DeleteChannel =
      DeleteChannelResponse
  request :: (Service -> Service) -> DeleteChannel -> Request DeleteChannel
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 DeleteChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteChannel)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull DeleteChannelResponse
DeleteChannelResponse'

instance Prelude.Hashable DeleteChannel where
  hashWithSalt :: Int -> DeleteChannel -> Int
hashWithSalt Int
_salt DeleteChannel' {Text
arn :: Text
$sel:arn:DeleteChannel' :: DeleteChannel -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn

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

instance Data.ToHeaders DeleteChannel where
  toHeaders :: DeleteChannel -> [Header]
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 -> [Header]
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

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

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

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

-- | /See:/ 'newDeleteChannelResponse' smart constructor.
data DeleteChannelResponse = DeleteChannelResponse'
  {
  }
  deriving (DeleteChannelResponse -> DeleteChannelResponse -> Bool
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]
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
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. 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.
newDeleteChannelResponse ::
  DeleteChannelResponse
newDeleteChannelResponse :: DeleteChannelResponse
newDeleteChannelResponse = DeleteChannelResponse
DeleteChannelResponse'

instance Prelude.NFData DeleteChannelResponse where
  rnf :: DeleteChannelResponse -> ()
rnf DeleteChannelResponse
_ = ()