{-# 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.StartChannel
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Starts a channel. For information about MediaTailor channels, see
-- <https://docs.aws.amazon.com/mediatailor/latest/ug/channel-assembly-channels.html Working with channels>
-- in the /MediaTailor User Guide/.
module Amazonka.MediaTailor.StartChannel
  ( -- * Creating a Request
    StartChannel (..),
    newStartChannel,

    -- * Request Lenses
    startChannel_channelName,

    -- * Destructuring the Response
    StartChannelResponse (..),
    newStartChannelResponse,

    -- * Response Lenses
    startChannelResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'StartChannel' 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', 'startChannel_channelName' - The name of the channel.
newStartChannel ::
  -- | 'channelName'
  Prelude.Text ->
  StartChannel
newStartChannel :: Text -> StartChannel
newStartChannel Text
pChannelName_ =
  StartChannel' {$sel:channelName:StartChannel' :: Text
channelName = Text
pChannelName_}

-- | The name of the channel.
startChannel_channelName :: Lens.Lens' StartChannel Prelude.Text
startChannel_channelName :: Lens' StartChannel Text
startChannel_channelName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StartChannel' {Text
channelName :: Text
$sel:channelName:StartChannel' :: StartChannel -> Text
channelName} -> Text
channelName) (\s :: StartChannel
s@StartChannel' {} Text
a -> StartChannel
s {$sel:channelName:StartChannel' :: Text
channelName = Text
a} :: StartChannel)

instance Core.AWSRequest StartChannel where
  type AWSResponse StartChannel = StartChannelResponse
  request :: (Service -> Service) -> StartChannel -> Request StartChannel
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy StartChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StartChannel)))
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 -> StartChannelResponse
StartChannelResponse'
            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 StartChannel where
  hashWithSalt :: Int -> StartChannel -> Int
hashWithSalt Int
_salt StartChannel' {Text
channelName :: Text
$sel:channelName:StartChannel' :: StartChannel -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
channelName

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

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

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

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

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

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

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

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