{-# 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-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)
--
-- Updates a multiplex.
module Amazonka.MediaLive.UpdateMultiplex
  ( -- * Creating a Request
    UpdateMultiplex' (..),
    newUpdateMultiplex',

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

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

    -- * Response Lenses
    updateMultiplexResponse_multiplex,
    updateMultiplexResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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''
  { -- | Name of the multiplex.
    UpdateMultiplex' -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The new settings for a multiplex.
    UpdateMultiplex' -> Maybe MultiplexSettings
multiplexSettings :: Prelude.Maybe MultiplexSettings,
    -- | ID of the multiplex to update.
    UpdateMultiplex' -> Text
multiplexId :: Prelude.Text
  }
  deriving (UpdateMultiplex' -> UpdateMultiplex' -> Bool
(UpdateMultiplex' -> UpdateMultiplex' -> Bool)
-> (UpdateMultiplex' -> UpdateMultiplex' -> Bool)
-> Eq UpdateMultiplex'
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']
(Int -> ReadS UpdateMultiplex')
-> ReadS [UpdateMultiplex']
-> ReadPrec UpdateMultiplex'
-> ReadPrec [UpdateMultiplex']
-> Read 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
(Int -> UpdateMultiplex' -> ShowS)
-> (UpdateMultiplex' -> String)
-> ([UpdateMultiplex'] -> ShowS)
-> Show UpdateMultiplex'
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. UpdateMultiplex' -> Rep UpdateMultiplex' x)
-> (forall x. Rep UpdateMultiplex' x -> UpdateMultiplex')
-> Generic UpdateMultiplex'
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:
--
-- 'name', 'updateMultiplex'_name' - Name of the multiplex.
--
-- 'multiplexSettings', 'updateMultiplex'_multiplexSettings' - The new settings for a multiplex.
--
-- 'multiplexId', 'updateMultiplex'_multiplexId' - ID of the multiplex to update.
newUpdateMultiplex' ::
  -- | 'multiplexId'
  Prelude.Text ->
  UpdateMultiplex'
newUpdateMultiplex' :: Text -> UpdateMultiplex'
newUpdateMultiplex' Text
pMultiplexId_ =
  UpdateMultiplex'' :: Maybe Text -> Maybe MultiplexSettings -> Text -> UpdateMultiplex'
UpdateMultiplex''
    { $sel:name:UpdateMultiplex'' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:multiplexSettings:UpdateMultiplex'' :: Maybe MultiplexSettings
multiplexSettings = Maybe MultiplexSettings
forall a. Maybe a
Prelude.Nothing,
      $sel:multiplexId:UpdateMultiplex'' :: Text
multiplexId = Text
pMultiplexId_
    }

-- | Name of the multiplex.
updateMultiplex'_name :: Lens.Lens' UpdateMultiplex' (Prelude.Maybe Prelude.Text)
updateMultiplex'_name :: (Maybe Text -> f (Maybe Text))
-> UpdateMultiplex' -> f UpdateMultiplex'
updateMultiplex'_name = (UpdateMultiplex' -> Maybe Text)
-> (UpdateMultiplex' -> Maybe Text -> UpdateMultiplex')
-> Lens UpdateMultiplex' UpdateMultiplex' (Maybe Text) (Maybe Text)
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')

-- | The new settings for a multiplex.
updateMultiplex'_multiplexSettings :: Lens.Lens' UpdateMultiplex' (Prelude.Maybe MultiplexSettings)
updateMultiplex'_multiplexSettings :: (Maybe MultiplexSettings -> f (Maybe MultiplexSettings))
-> UpdateMultiplex' -> f UpdateMultiplex'
updateMultiplex'_multiplexSettings = (UpdateMultiplex' -> Maybe MultiplexSettings)
-> (UpdateMultiplex'
    -> Maybe MultiplexSettings -> UpdateMultiplex')
-> Lens
     UpdateMultiplex'
     UpdateMultiplex'
     (Maybe MultiplexSettings)
     (Maybe 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')

-- | ID of the multiplex to update.
updateMultiplex'_multiplexId :: Lens.Lens' UpdateMultiplex' Prelude.Text
updateMultiplex'_multiplexId :: (Text -> f Text) -> UpdateMultiplex' -> f UpdateMultiplex'
updateMultiplex'_multiplexId = (UpdateMultiplex' -> Text)
-> (UpdateMultiplex' -> Text -> UpdateMultiplex')
-> Lens UpdateMultiplex' UpdateMultiplex' Text Text
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 :: UpdateMultiplex' -> Request UpdateMultiplex'
request = Service -> UpdateMultiplex' -> Request UpdateMultiplex'
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateMultiplex'
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateMultiplex')))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateMultiplex'))
-> Logger
-> Service
-> Proxy UpdateMultiplex'
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateMultiplex')))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Multiplex -> Int -> UpdateMultiplexResponse
UpdateMultiplexResponse'
            (Maybe Multiplex -> Int -> UpdateMultiplexResponse)
-> Either String (Maybe Multiplex)
-> Either String (Int -> UpdateMultiplexResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Multiplex)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"multiplex")
            Either String (Int -> UpdateMultiplexResponse)
-> Either String Int -> Either String UpdateMultiplexResponse
forall (f :: * -> *) a b. Applicative f => 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 UpdateMultiplex'

instance Prelude.NFData UpdateMultiplex'

instance Core.ToHeaders UpdateMultiplex' where
  toHeaders :: UpdateMultiplex' -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateMultiplex' -> 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 UpdateMultiplex' where
  toJSON :: UpdateMultiplex' -> Value
toJSON UpdateMultiplex'' {Maybe Text
Maybe MultiplexSettings
Text
multiplexId :: Text
multiplexSettings :: Maybe MultiplexSettings
name :: Maybe Text
$sel:multiplexId:UpdateMultiplex'' :: UpdateMultiplex' -> Text
$sel:multiplexSettings:UpdateMultiplex'' :: UpdateMultiplex' -> Maybe MultiplexSettings
$sel:name:UpdateMultiplex'' :: UpdateMultiplex' -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
            (Text
"multiplexSettings" Text -> MultiplexSettings -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (MultiplexSettings -> Pair)
-> Maybe MultiplexSettings -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MultiplexSettings
multiplexSettings
          ]
      )

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

instance Core.ToQuery UpdateMultiplex' where
  toQuery :: UpdateMultiplex' -> QueryString
toQuery = QueryString -> UpdateMultiplex' -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(UpdateMultiplexResponse -> UpdateMultiplexResponse -> Bool)
-> (UpdateMultiplexResponse -> UpdateMultiplexResponse -> Bool)
-> Eq UpdateMultiplexResponse
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]
(Int -> ReadS UpdateMultiplexResponse)
-> ReadS [UpdateMultiplexResponse]
-> ReadPrec UpdateMultiplexResponse
-> ReadPrec [UpdateMultiplexResponse]
-> Read 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
(Int -> UpdateMultiplexResponse -> ShowS)
-> (UpdateMultiplexResponse -> String)
-> ([UpdateMultiplexResponse] -> ShowS)
-> Show UpdateMultiplexResponse
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.
 UpdateMultiplexResponse -> Rep UpdateMultiplexResponse x)
-> (forall x.
    Rep UpdateMultiplexResponse x -> UpdateMultiplexResponse)
-> Generic UpdateMultiplexResponse
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' :: Maybe Multiplex -> Int -> UpdateMultiplexResponse
UpdateMultiplexResponse'
    { $sel:multiplex:UpdateMultiplexResponse' :: Maybe Multiplex
multiplex =
        Maybe 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 :: (Maybe Multiplex -> f (Maybe Multiplex))
-> UpdateMultiplexResponse -> f UpdateMultiplexResponse
updateMultiplexResponse_multiplex = (UpdateMultiplexResponse -> Maybe Multiplex)
-> (UpdateMultiplexResponse
    -> Maybe Multiplex -> UpdateMultiplexResponse)
-> Lens
     UpdateMultiplexResponse
     UpdateMultiplexResponse
     (Maybe Multiplex)
     (Maybe 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 :: (Int -> f Int)
-> UpdateMultiplexResponse -> f UpdateMultiplexResponse
updateMultiplexResponse_httpStatus = (UpdateMultiplexResponse -> Int)
-> (UpdateMultiplexResponse -> Int -> UpdateMultiplexResponse)
-> Lens UpdateMultiplexResponse UpdateMultiplexResponse Int Int
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