{-# 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.MediaLive.UpdateMultiplexProgram
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Update a program in a multiplex.
module Amazonka.MediaLive.UpdateMultiplexProgram
  ( -- * Creating a Request
    UpdateMultiplexProgram' (..),
    newUpdateMultiplexProgram',

    -- * Request Lenses
    updateMultiplexProgram'_multiplexProgramSettings,
    updateMultiplexProgram'_multiplexId,
    updateMultiplexProgram'_programName,

    -- * Destructuring the Response
    UpdateMultiplexProgramResponse (..),
    newUpdateMultiplexProgramResponse,

    -- * Response Lenses
    updateMultiplexProgramResponse_multiplexProgram,
    updateMultiplexProgramResponse_httpStatus,
  )
where

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

-- | A request to update a program in a multiplex.
--
-- /See:/ 'newUpdateMultiplexProgram'' smart constructor.
data UpdateMultiplexProgram' = UpdateMultiplexProgram''
  { -- | The new settings for a multiplex program.
    UpdateMultiplexProgram' -> Maybe MultiplexProgramSettings
multiplexProgramSettings :: Prelude.Maybe MultiplexProgramSettings,
    -- | The ID of the multiplex of the program to update.
    UpdateMultiplexProgram' -> Text
multiplexId :: Prelude.Text,
    -- | The name of the program to update.
    UpdateMultiplexProgram' -> Text
programName :: Prelude.Text
  }
  deriving (UpdateMultiplexProgram' -> UpdateMultiplexProgram' -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateMultiplexProgram' -> UpdateMultiplexProgram' -> Bool
$c/= :: UpdateMultiplexProgram' -> UpdateMultiplexProgram' -> Bool
== :: UpdateMultiplexProgram' -> UpdateMultiplexProgram' -> Bool
$c== :: UpdateMultiplexProgram' -> UpdateMultiplexProgram' -> Bool
Prelude.Eq, ReadPrec [UpdateMultiplexProgram']
ReadPrec UpdateMultiplexProgram'
Int -> ReadS UpdateMultiplexProgram'
ReadS [UpdateMultiplexProgram']
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateMultiplexProgram']
$creadListPrec :: ReadPrec [UpdateMultiplexProgram']
readPrec :: ReadPrec UpdateMultiplexProgram'
$creadPrec :: ReadPrec UpdateMultiplexProgram'
readList :: ReadS [UpdateMultiplexProgram']
$creadList :: ReadS [UpdateMultiplexProgram']
readsPrec :: Int -> ReadS UpdateMultiplexProgram'
$creadsPrec :: Int -> ReadS UpdateMultiplexProgram'
Prelude.Read, Int -> UpdateMultiplexProgram' -> ShowS
[UpdateMultiplexProgram'] -> ShowS
UpdateMultiplexProgram' -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateMultiplexProgram'] -> ShowS
$cshowList :: [UpdateMultiplexProgram'] -> ShowS
show :: UpdateMultiplexProgram' -> String
$cshow :: UpdateMultiplexProgram' -> String
showsPrec :: Int -> UpdateMultiplexProgram' -> ShowS
$cshowsPrec :: Int -> UpdateMultiplexProgram' -> ShowS
Prelude.Show, forall x. Rep UpdateMultiplexProgram' x -> UpdateMultiplexProgram'
forall x. UpdateMultiplexProgram' -> Rep UpdateMultiplexProgram' x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateMultiplexProgram' x -> UpdateMultiplexProgram'
$cfrom :: forall x. UpdateMultiplexProgram' -> Rep UpdateMultiplexProgram' x
Prelude.Generic)

-- |
-- Create a value of 'UpdateMultiplexProgram'' 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:
--
-- 'multiplexProgramSettings', 'updateMultiplexProgram'_multiplexProgramSettings' - The new settings for a multiplex program.
--
-- 'multiplexId', 'updateMultiplexProgram'_multiplexId' - The ID of the multiplex of the program to update.
--
-- 'programName', 'updateMultiplexProgram'_programName' - The name of the program to update.
newUpdateMultiplexProgram' ::
  -- | 'multiplexId'
  Prelude.Text ->
  -- | 'programName'
  Prelude.Text ->
  UpdateMultiplexProgram'
newUpdateMultiplexProgram' :: Text -> Text -> UpdateMultiplexProgram'
newUpdateMultiplexProgram'
  Text
pMultiplexId_
  Text
pProgramName_ =
    UpdateMultiplexProgram''
      { $sel:multiplexProgramSettings:UpdateMultiplexProgram'' :: Maybe MultiplexProgramSettings
multiplexProgramSettings =
          forall a. Maybe a
Prelude.Nothing,
        $sel:multiplexId:UpdateMultiplexProgram'' :: Text
multiplexId = Text
pMultiplexId_,
        $sel:programName:UpdateMultiplexProgram'' :: Text
programName = Text
pProgramName_
      }

-- | The new settings for a multiplex program.
updateMultiplexProgram'_multiplexProgramSettings :: Lens.Lens' UpdateMultiplexProgram' (Prelude.Maybe MultiplexProgramSettings)
updateMultiplexProgram'_multiplexProgramSettings :: Lens' UpdateMultiplexProgram' (Maybe MultiplexProgramSettings)
updateMultiplexProgram'_multiplexProgramSettings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMultiplexProgram'' {Maybe MultiplexProgramSettings
multiplexProgramSettings :: Maybe MultiplexProgramSettings
$sel:multiplexProgramSettings:UpdateMultiplexProgram'' :: UpdateMultiplexProgram' -> Maybe MultiplexProgramSettings
multiplexProgramSettings} -> Maybe MultiplexProgramSettings
multiplexProgramSettings) (\s :: UpdateMultiplexProgram'
s@UpdateMultiplexProgram'' {} Maybe MultiplexProgramSettings
a -> UpdateMultiplexProgram'
s {$sel:multiplexProgramSettings:UpdateMultiplexProgram'' :: Maybe MultiplexProgramSettings
multiplexProgramSettings = Maybe MultiplexProgramSettings
a} :: UpdateMultiplexProgram')

-- | The ID of the multiplex of the program to update.
updateMultiplexProgram'_multiplexId :: Lens.Lens' UpdateMultiplexProgram' Prelude.Text
updateMultiplexProgram'_multiplexId :: Lens' UpdateMultiplexProgram' Text
updateMultiplexProgram'_multiplexId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMultiplexProgram'' {Text
multiplexId :: Text
$sel:multiplexId:UpdateMultiplexProgram'' :: UpdateMultiplexProgram' -> Text
multiplexId} -> Text
multiplexId) (\s :: UpdateMultiplexProgram'
s@UpdateMultiplexProgram'' {} Text
a -> UpdateMultiplexProgram'
s {$sel:multiplexId:UpdateMultiplexProgram'' :: Text
multiplexId = Text
a} :: UpdateMultiplexProgram')

-- | The name of the program to update.
updateMultiplexProgram'_programName :: Lens.Lens' UpdateMultiplexProgram' Prelude.Text
updateMultiplexProgram'_programName :: Lens' UpdateMultiplexProgram' Text
updateMultiplexProgram'_programName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMultiplexProgram'' {Text
programName :: Text
$sel:programName:UpdateMultiplexProgram'' :: UpdateMultiplexProgram' -> Text
programName} -> Text
programName) (\s :: UpdateMultiplexProgram'
s@UpdateMultiplexProgram'' {} Text
a -> UpdateMultiplexProgram'
s {$sel:programName:UpdateMultiplexProgram'' :: Text
programName = Text
a} :: UpdateMultiplexProgram')

instance Core.AWSRequest UpdateMultiplexProgram' where
  type
    AWSResponse UpdateMultiplexProgram' =
      UpdateMultiplexProgramResponse
  request :: (Service -> Service)
-> UpdateMultiplexProgram' -> Request UpdateMultiplexProgram'
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 UpdateMultiplexProgram'
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateMultiplexProgram')))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe MultiplexProgram -> Int -> UpdateMultiplexProgramResponse
UpdateMultiplexProgramResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"multiplexProgram")
            forall (f :: * -> *) a b. Applicative f => 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 UpdateMultiplexProgram' where
  hashWithSalt :: Int -> UpdateMultiplexProgram' -> Int
hashWithSalt Int
_salt UpdateMultiplexProgram'' {Maybe MultiplexProgramSettings
Text
programName :: Text
multiplexId :: Text
multiplexProgramSettings :: Maybe MultiplexProgramSettings
$sel:programName:UpdateMultiplexProgram'' :: UpdateMultiplexProgram' -> Text
$sel:multiplexId:UpdateMultiplexProgram'' :: UpdateMultiplexProgram' -> Text
$sel:multiplexProgramSettings:UpdateMultiplexProgram'' :: UpdateMultiplexProgram' -> Maybe MultiplexProgramSettings
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MultiplexProgramSettings
multiplexProgramSettings
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
multiplexId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
programName

instance Prelude.NFData UpdateMultiplexProgram' where
  rnf :: UpdateMultiplexProgram' -> ()
rnf UpdateMultiplexProgram'' {Maybe MultiplexProgramSettings
Text
programName :: Text
multiplexId :: Text
multiplexProgramSettings :: Maybe MultiplexProgramSettings
$sel:programName:UpdateMultiplexProgram'' :: UpdateMultiplexProgram' -> Text
$sel:multiplexId:UpdateMultiplexProgram'' :: UpdateMultiplexProgram' -> Text
$sel:multiplexProgramSettings:UpdateMultiplexProgram'' :: UpdateMultiplexProgram' -> Maybe MultiplexProgramSettings
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe MultiplexProgramSettings
multiplexProgramSettings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
multiplexId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
programName

instance Data.ToHeaders UpdateMultiplexProgram' where
  toHeaders :: UpdateMultiplexProgram' -> 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 UpdateMultiplexProgram' where
  toJSON :: UpdateMultiplexProgram' -> Value
toJSON UpdateMultiplexProgram'' {Maybe MultiplexProgramSettings
Text
programName :: Text
multiplexId :: Text
multiplexProgramSettings :: Maybe MultiplexProgramSettings
$sel:programName:UpdateMultiplexProgram'' :: UpdateMultiplexProgram' -> Text
$sel:multiplexId:UpdateMultiplexProgram'' :: UpdateMultiplexProgram' -> Text
$sel:multiplexProgramSettings:UpdateMultiplexProgram'' :: UpdateMultiplexProgram' -> Maybe MultiplexProgramSettings
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"multiplexProgramSettings" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MultiplexProgramSettings
multiplexProgramSettings
          ]
      )

instance Data.ToPath UpdateMultiplexProgram' where
  toPath :: UpdateMultiplexProgram' -> ByteString
toPath UpdateMultiplexProgram'' {Maybe MultiplexProgramSettings
Text
programName :: Text
multiplexId :: Text
multiplexProgramSettings :: Maybe MultiplexProgramSettings
$sel:programName:UpdateMultiplexProgram'' :: UpdateMultiplexProgram' -> Text
$sel:multiplexId:UpdateMultiplexProgram'' :: UpdateMultiplexProgram' -> Text
$sel:multiplexProgramSettings:UpdateMultiplexProgram'' :: UpdateMultiplexProgram' -> Maybe MultiplexProgramSettings
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/prod/multiplexes/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
multiplexId,
        ByteString
"/programs/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
programName
      ]

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

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

-- |
-- Create a value of 'UpdateMultiplexProgramResponse' 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:
--
-- 'multiplexProgram', 'updateMultiplexProgramResponse_multiplexProgram' - The updated multiplex program.
--
-- 'httpStatus', 'updateMultiplexProgramResponse_httpStatus' - The response's http status code.
newUpdateMultiplexProgramResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateMultiplexProgramResponse
newUpdateMultiplexProgramResponse :: Int -> UpdateMultiplexProgramResponse
newUpdateMultiplexProgramResponse Int
pHttpStatus_ =
  UpdateMultiplexProgramResponse'
    { $sel:multiplexProgram:UpdateMultiplexProgramResponse' :: Maybe MultiplexProgram
multiplexProgram =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateMultiplexProgramResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The updated multiplex program.
updateMultiplexProgramResponse_multiplexProgram :: Lens.Lens' UpdateMultiplexProgramResponse (Prelude.Maybe MultiplexProgram)
updateMultiplexProgramResponse_multiplexProgram :: Lens' UpdateMultiplexProgramResponse (Maybe MultiplexProgram)
updateMultiplexProgramResponse_multiplexProgram = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMultiplexProgramResponse' {Maybe MultiplexProgram
multiplexProgram :: Maybe MultiplexProgram
$sel:multiplexProgram:UpdateMultiplexProgramResponse' :: UpdateMultiplexProgramResponse -> Maybe MultiplexProgram
multiplexProgram} -> Maybe MultiplexProgram
multiplexProgram) (\s :: UpdateMultiplexProgramResponse
s@UpdateMultiplexProgramResponse' {} Maybe MultiplexProgram
a -> UpdateMultiplexProgramResponse
s {$sel:multiplexProgram:UpdateMultiplexProgramResponse' :: Maybe MultiplexProgram
multiplexProgram = Maybe MultiplexProgram
a} :: UpdateMultiplexProgramResponse)

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

instance
  Prelude.NFData
    UpdateMultiplexProgramResponse
  where
  rnf :: UpdateMultiplexProgramResponse -> ()
rnf UpdateMultiplexProgramResponse' {Int
Maybe MultiplexProgram
httpStatus :: Int
multiplexProgram :: Maybe MultiplexProgram
$sel:httpStatus:UpdateMultiplexProgramResponse' :: UpdateMultiplexProgramResponse -> Int
$sel:multiplexProgram:UpdateMultiplexProgramResponse' :: UpdateMultiplexProgramResponse -> Maybe MultiplexProgram
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe MultiplexProgram
multiplexProgram
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus