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

    -- * Request Lenses
    updateMultiplex'_multiplexSettings,
    updateMultiplex'_name,
    updateMultiplex'_multiplexId,

    -- * Destructuring the Response
    UpdateMultiplexResponse (..),
    newUpdateMultiplexResponse,

    -- * Response Lenses
    updateMultiplexResponse_multiplex,
    updateMultiplexResponse_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 multiplex.
--
-- /See:/ 'newUpdateMultiplex'' smart constructor.
data UpdateMultiplex' = UpdateMultiplex''
  { -- | The new settings for a multiplex.
    UpdateMultiplex' -> Maybe MultiplexSettings
multiplexSettings :: Prelude.Maybe MultiplexSettings,
    -- | Name of the multiplex.
    UpdateMultiplex' -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | ID of the multiplex to update.
    UpdateMultiplex' -> Text
multiplexId :: Prelude.Text
  }
  deriving (UpdateMultiplex' -> UpdateMultiplex' -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateMultiplex' -> UpdateMultiplex' -> Bool
$c/= :: UpdateMultiplex' -> UpdateMultiplex' -> Bool
== :: UpdateMultiplex' -> UpdateMultiplex' -> Bool
$c== :: UpdateMultiplex' -> UpdateMultiplex' -> Bool
Prelude.Eq, ReadPrec [UpdateMultiplex']
ReadPrec UpdateMultiplex'
Int -> ReadS UpdateMultiplex'
ReadS [UpdateMultiplex']
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateMultiplex']
$creadListPrec :: ReadPrec [UpdateMultiplex']
readPrec :: ReadPrec UpdateMultiplex'
$creadPrec :: ReadPrec UpdateMultiplex'
readList :: ReadS [UpdateMultiplex']
$creadList :: ReadS [UpdateMultiplex']
readsPrec :: Int -> ReadS UpdateMultiplex'
$creadsPrec :: Int -> ReadS UpdateMultiplex'
Prelude.Read, Int -> UpdateMultiplex' -> ShowS
[UpdateMultiplex'] -> ShowS
UpdateMultiplex' -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateMultiplex'] -> ShowS
$cshowList :: [UpdateMultiplex'] -> ShowS
show :: UpdateMultiplex' -> String
$cshow :: UpdateMultiplex' -> String
showsPrec :: Int -> UpdateMultiplex' -> ShowS
$cshowsPrec :: Int -> UpdateMultiplex' -> ShowS
Prelude.Show, forall x. Rep UpdateMultiplex' x -> UpdateMultiplex'
forall x. UpdateMultiplex' -> Rep UpdateMultiplex' x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateMultiplex' x -> UpdateMultiplex'
$cfrom :: forall x. UpdateMultiplex' -> Rep UpdateMultiplex' x
Prelude.Generic)

-- |
-- Create a value of 'UpdateMultiplex'' 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:
--
-- 'multiplexSettings', 'updateMultiplex'_multiplexSettings' - The new settings for a multiplex.
--
-- 'name', 'updateMultiplex'_name' - Name of the multiplex.
--
-- 'multiplexId', 'updateMultiplex'_multiplexId' - ID of the multiplex to update.
newUpdateMultiplex' ::
  -- | 'multiplexId'
  Prelude.Text ->
  UpdateMultiplex'
newUpdateMultiplex' :: Text -> UpdateMultiplex'
newUpdateMultiplex' Text
pMultiplexId_ =
  UpdateMultiplex''
    { $sel:multiplexSettings:UpdateMultiplex'' :: Maybe MultiplexSettings
multiplexSettings =
        forall a. Maybe a
Prelude.Nothing,
      $sel:name:UpdateMultiplex'' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:multiplexId:UpdateMultiplex'' :: Text
multiplexId = Text
pMultiplexId_
    }

-- | The new settings for a multiplex.
updateMultiplex'_multiplexSettings :: Lens.Lens' UpdateMultiplex' (Prelude.Maybe MultiplexSettings)
updateMultiplex'_multiplexSettings :: Lens' UpdateMultiplex' (Maybe MultiplexSettings)
updateMultiplex'_multiplexSettings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMultiplex'' {Maybe MultiplexSettings
multiplexSettings :: Maybe MultiplexSettings
$sel:multiplexSettings:UpdateMultiplex'' :: UpdateMultiplex' -> Maybe MultiplexSettings
multiplexSettings} -> Maybe MultiplexSettings
multiplexSettings) (\s :: UpdateMultiplex'
s@UpdateMultiplex'' {} Maybe MultiplexSettings
a -> UpdateMultiplex'
s {$sel:multiplexSettings:UpdateMultiplex'' :: Maybe MultiplexSettings
multiplexSettings = Maybe MultiplexSettings
a} :: UpdateMultiplex')

-- | Name of the multiplex.
updateMultiplex'_name :: Lens.Lens' UpdateMultiplex' (Prelude.Maybe Prelude.Text)
updateMultiplex'_name :: Lens' UpdateMultiplex' (Maybe Text)
updateMultiplex'_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMultiplex'' {Maybe Text
name :: Maybe Text
$sel:name:UpdateMultiplex'' :: UpdateMultiplex' -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateMultiplex'
s@UpdateMultiplex'' {} Maybe Text
a -> UpdateMultiplex'
s {$sel:name:UpdateMultiplex'' :: Maybe Text
name = Maybe Text
a} :: UpdateMultiplex')

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

instance Core.AWSRequest UpdateMultiplex' where
  type
    AWSResponse UpdateMultiplex' =
      UpdateMultiplexResponse
  request :: (Service -> Service)
-> UpdateMultiplex' -> Request UpdateMultiplex'
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 UpdateMultiplex'
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateMultiplex')))
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 Multiplex -> Int -> UpdateMultiplexResponse
UpdateMultiplexResponse'
            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
"multiplex")
            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 UpdateMultiplex' where
  hashWithSalt :: Int -> UpdateMultiplex' -> Int
hashWithSalt Int
_salt UpdateMultiplex'' {Maybe Text
Maybe MultiplexSettings
Text
multiplexId :: Text
name :: Maybe Text
multiplexSettings :: Maybe MultiplexSettings
$sel:multiplexId:UpdateMultiplex'' :: UpdateMultiplex' -> Text
$sel:name:UpdateMultiplex'' :: UpdateMultiplex' -> Maybe Text
$sel:multiplexSettings:UpdateMultiplex'' :: UpdateMultiplex' -> Maybe MultiplexSettings
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe MultiplexSettings
multiplexSettings
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
multiplexId

instance Prelude.NFData UpdateMultiplex' where
  rnf :: UpdateMultiplex' -> ()
rnf UpdateMultiplex'' {Maybe Text
Maybe MultiplexSettings
Text
multiplexId :: Text
name :: Maybe Text
multiplexSettings :: Maybe MultiplexSettings
$sel:multiplexId:UpdateMultiplex'' :: UpdateMultiplex' -> Text
$sel:name:UpdateMultiplex'' :: UpdateMultiplex' -> Maybe Text
$sel:multiplexSettings:UpdateMultiplex'' :: UpdateMultiplex' -> Maybe MultiplexSettings
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe MultiplexSettings
multiplexSettings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
multiplexId

instance Data.ToHeaders UpdateMultiplex' where
  toHeaders :: UpdateMultiplex' -> 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 UpdateMultiplex' where
  toJSON :: UpdateMultiplex' -> Value
toJSON UpdateMultiplex'' {Maybe Text
Maybe MultiplexSettings
Text
multiplexId :: Text
name :: Maybe Text
multiplexSettings :: Maybe MultiplexSettings
$sel:multiplexId:UpdateMultiplex'' :: UpdateMultiplex' -> Text
$sel:name:UpdateMultiplex'' :: UpdateMultiplex' -> Maybe Text
$sel:multiplexSettings:UpdateMultiplex'' :: UpdateMultiplex' -> Maybe MultiplexSettings
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"multiplexSettings" 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 MultiplexSettings
multiplexSettings,
            (Key
"name" 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 Text
name
          ]
      )

instance Data.ToPath UpdateMultiplex' where
  toPath :: UpdateMultiplex' -> ByteString
toPath UpdateMultiplex'' {Maybe Text
Maybe MultiplexSettings
Text
multiplexId :: Text
name :: Maybe Text
multiplexSettings :: Maybe MultiplexSettings
$sel:multiplexId:UpdateMultiplex'' :: UpdateMultiplex' -> Text
$sel:name:UpdateMultiplex'' :: UpdateMultiplex' -> Maybe Text
$sel:multiplexSettings:UpdateMultiplex'' :: UpdateMultiplex' -> Maybe MultiplexSettings
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/prod/multiplexes/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
multiplexId]

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

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

-- |
-- Create a value of 'UpdateMultiplexResponse' 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:
--
-- 'multiplex', 'updateMultiplexResponse_multiplex' - The updated multiplex.
--
-- 'httpStatus', 'updateMultiplexResponse_httpStatus' - The response's http status code.
newUpdateMultiplexResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateMultiplexResponse
newUpdateMultiplexResponse :: Int -> UpdateMultiplexResponse
newUpdateMultiplexResponse Int
pHttpStatus_ =
  UpdateMultiplexResponse'
    { $sel:multiplex:UpdateMultiplexResponse' :: Maybe Multiplex
multiplex =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateMultiplexResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The updated multiplex.
updateMultiplexResponse_multiplex :: Lens.Lens' UpdateMultiplexResponse (Prelude.Maybe Multiplex)
updateMultiplexResponse_multiplex :: Lens' UpdateMultiplexResponse (Maybe Multiplex)
updateMultiplexResponse_multiplex = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateMultiplexResponse' {Maybe Multiplex
multiplex :: Maybe Multiplex
$sel:multiplex:UpdateMultiplexResponse' :: UpdateMultiplexResponse -> Maybe Multiplex
multiplex} -> Maybe Multiplex
multiplex) (\s :: UpdateMultiplexResponse
s@UpdateMultiplexResponse' {} Maybe Multiplex
a -> UpdateMultiplexResponse
s {$sel:multiplex:UpdateMultiplexResponse' :: Maybe Multiplex
multiplex = Maybe Multiplex
a} :: UpdateMultiplexResponse)

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

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