{-# 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-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)
--
-- Starts a specific channel.
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.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:/ 'newStartChannel' smart constructor.
data StartChannel = StartChannel'
  { -- | The identifier for the channel you are working on.
    StartChannel -> Text
channelName :: Prelude.Text
  }
  deriving (StartChannel -> StartChannel -> Bool
(StartChannel -> StartChannel -> Bool)
-> (StartChannel -> StartChannel -> Bool) -> Eq StartChannel
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]
(Int -> ReadS StartChannel)
-> ReadS [StartChannel]
-> ReadPrec StartChannel
-> ReadPrec [StartChannel]
-> Read 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
(Int -> StartChannel -> ShowS)
-> (StartChannel -> String)
-> ([StartChannel] -> ShowS)
-> Show StartChannel
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. StartChannel -> Rep StartChannel x)
-> (forall x. Rep StartChannel x -> StartChannel)
-> Generic StartChannel
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 identifier for the channel you are working on.
newStartChannel ::
  -- | 'channelName'
  Prelude.Text ->
  StartChannel
newStartChannel :: Text -> StartChannel
newStartChannel Text
pChannelName_ =
  StartChannel' :: Text -> StartChannel
StartChannel' {$sel:channelName:StartChannel' :: Text
channelName = Text
pChannelName_}

-- | The identifier for the channel you are working on.
startChannel_channelName :: Lens.Lens' StartChannel Prelude.Text
startChannel_channelName :: (Text -> f Text) -> StartChannel -> f StartChannel
startChannel_channelName = (StartChannel -> Text)
-> (StartChannel -> Text -> StartChannel)
-> Lens StartChannel StartChannel Text Text
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 :: StartChannel -> Request StartChannel
request = Service -> StartChannel -> Request StartChannel
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy StartChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StartChannel)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse StartChannel))
-> Logger
-> Service
-> Proxy StartChannel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse StartChannel)))
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 -> StartChannelResponse
StartChannelResponse'
            (Int -> StartChannelResponse)
-> Either String Int -> Either String StartChannelResponse
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 StartChannel

instance Prelude.NFData StartChannel

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

instance Core.ToPath StartChannel where
  toPath :: StartChannel -> ByteString
toPath StartChannel' {Text
channelName :: Text
$sel:channelName:StartChannel' :: StartChannel -> 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
"/start"]

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

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