{-# 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.UpdateChannelClass
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Changes the class of the channel.
module Amazonka.MediaLive.UpdateChannelClass
  ( -- * Creating a Request
    UpdateChannelClass' (..),
    newUpdateChannelClass',

    -- * Request Lenses
    updateChannelClass'_destinations,
    updateChannelClass'_channelId,
    updateChannelClass'_channelClass,

    -- * Destructuring the Response
    UpdateChannelClassResponse (..),
    newUpdateChannelClassResponse,

    -- * Response Lenses
    updateChannelClassResponse_channel,
    updateChannelClassResponse_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

-- | Channel class that the channel should be updated to.
--
-- /See:/ 'newUpdateChannelClass'' smart constructor.
data UpdateChannelClass' = UpdateChannelClass''
  { -- | A list of output destinations for this channel.
    UpdateChannelClass' -> Maybe [OutputDestination]
destinations :: Prelude.Maybe [OutputDestination],
    -- | Channel Id of the channel whose class should be updated.
    UpdateChannelClass' -> Text
channelId :: Prelude.Text,
    -- | The channel class that you wish to update this channel to use.
    UpdateChannelClass' -> ChannelClass
channelClass :: ChannelClass
  }
  deriving (UpdateChannelClass' -> UpdateChannelClass' -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateChannelClass' -> UpdateChannelClass' -> Bool
$c/= :: UpdateChannelClass' -> UpdateChannelClass' -> Bool
== :: UpdateChannelClass' -> UpdateChannelClass' -> Bool
$c== :: UpdateChannelClass' -> UpdateChannelClass' -> Bool
Prelude.Eq, ReadPrec [UpdateChannelClass']
ReadPrec UpdateChannelClass'
Int -> ReadS UpdateChannelClass'
ReadS [UpdateChannelClass']
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateChannelClass']
$creadListPrec :: ReadPrec [UpdateChannelClass']
readPrec :: ReadPrec UpdateChannelClass'
$creadPrec :: ReadPrec UpdateChannelClass'
readList :: ReadS [UpdateChannelClass']
$creadList :: ReadS [UpdateChannelClass']
readsPrec :: Int -> ReadS UpdateChannelClass'
$creadsPrec :: Int -> ReadS UpdateChannelClass'
Prelude.Read, Int -> UpdateChannelClass' -> ShowS
[UpdateChannelClass'] -> ShowS
UpdateChannelClass' -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateChannelClass'] -> ShowS
$cshowList :: [UpdateChannelClass'] -> ShowS
show :: UpdateChannelClass' -> String
$cshow :: UpdateChannelClass' -> String
showsPrec :: Int -> UpdateChannelClass' -> ShowS
$cshowsPrec :: Int -> UpdateChannelClass' -> ShowS
Prelude.Show, forall x. Rep UpdateChannelClass' x -> UpdateChannelClass'
forall x. UpdateChannelClass' -> Rep UpdateChannelClass' x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateChannelClass' x -> UpdateChannelClass'
$cfrom :: forall x. UpdateChannelClass' -> Rep UpdateChannelClass' x
Prelude.Generic)

-- |
-- Create a value of 'UpdateChannelClass'' 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:
--
-- 'destinations', 'updateChannelClass'_destinations' - A list of output destinations for this channel.
--
-- 'channelId', 'updateChannelClass'_channelId' - Channel Id of the channel whose class should be updated.
--
-- 'channelClass', 'updateChannelClass'_channelClass' - The channel class that you wish to update this channel to use.
newUpdateChannelClass' ::
  -- | 'channelId'
  Prelude.Text ->
  -- | 'channelClass'
  ChannelClass ->
  UpdateChannelClass'
newUpdateChannelClass' :: Text -> ChannelClass -> UpdateChannelClass'
newUpdateChannelClass' Text
pChannelId_ ChannelClass
pChannelClass_ =
  UpdateChannelClass''
    { $sel:destinations:UpdateChannelClass'' :: Maybe [OutputDestination]
destinations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:channelId:UpdateChannelClass'' :: Text
channelId = Text
pChannelId_,
      $sel:channelClass:UpdateChannelClass'' :: ChannelClass
channelClass = ChannelClass
pChannelClass_
    }

-- | A list of output destinations for this channel.
updateChannelClass'_destinations :: Lens.Lens' UpdateChannelClass' (Prelude.Maybe [OutputDestination])
updateChannelClass'_destinations :: Lens' UpdateChannelClass' (Maybe [OutputDestination])
updateChannelClass'_destinations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateChannelClass'' {Maybe [OutputDestination]
destinations :: Maybe [OutputDestination]
$sel:destinations:UpdateChannelClass'' :: UpdateChannelClass' -> Maybe [OutputDestination]
destinations} -> Maybe [OutputDestination]
destinations) (\s :: UpdateChannelClass'
s@UpdateChannelClass'' {} Maybe [OutputDestination]
a -> UpdateChannelClass'
s {$sel:destinations:UpdateChannelClass'' :: Maybe [OutputDestination]
destinations = Maybe [OutputDestination]
a} :: UpdateChannelClass') forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Channel Id of the channel whose class should be updated.
updateChannelClass'_channelId :: Lens.Lens' UpdateChannelClass' Prelude.Text
updateChannelClass'_channelId :: Lens' UpdateChannelClass' Text
updateChannelClass'_channelId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateChannelClass'' {Text
channelId :: Text
$sel:channelId:UpdateChannelClass'' :: UpdateChannelClass' -> Text
channelId} -> Text
channelId) (\s :: UpdateChannelClass'
s@UpdateChannelClass'' {} Text
a -> UpdateChannelClass'
s {$sel:channelId:UpdateChannelClass'' :: Text
channelId = Text
a} :: UpdateChannelClass')

-- | The channel class that you wish to update this channel to use.
updateChannelClass'_channelClass :: Lens.Lens' UpdateChannelClass' ChannelClass
updateChannelClass'_channelClass :: Lens' UpdateChannelClass' ChannelClass
updateChannelClass'_channelClass = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateChannelClass'' {ChannelClass
channelClass :: ChannelClass
$sel:channelClass:UpdateChannelClass'' :: UpdateChannelClass' -> ChannelClass
channelClass} -> ChannelClass
channelClass) (\s :: UpdateChannelClass'
s@UpdateChannelClass'' {} ChannelClass
a -> UpdateChannelClass'
s {$sel:channelClass:UpdateChannelClass'' :: ChannelClass
channelClass = ChannelClass
a} :: UpdateChannelClass')

instance Core.AWSRequest UpdateChannelClass' where
  type
    AWSResponse UpdateChannelClass' =
      UpdateChannelClassResponse
  request :: (Service -> Service)
-> UpdateChannelClass' -> Request UpdateChannelClass'
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 UpdateChannelClass'
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateChannelClass')))
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 Channel -> Int -> UpdateChannelClassResponse
UpdateChannelClassResponse'
            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
"channel")
            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 UpdateChannelClass' where
  hashWithSalt :: Int -> UpdateChannelClass' -> Int
hashWithSalt Int
_salt UpdateChannelClass'' {Maybe [OutputDestination]
Text
ChannelClass
channelClass :: ChannelClass
channelId :: Text
destinations :: Maybe [OutputDestination]
$sel:channelClass:UpdateChannelClass'' :: UpdateChannelClass' -> ChannelClass
$sel:channelId:UpdateChannelClass'' :: UpdateChannelClass' -> Text
$sel:destinations:UpdateChannelClass'' :: UpdateChannelClass' -> Maybe [OutputDestination]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [OutputDestination]
destinations
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
channelId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ChannelClass
channelClass

instance Prelude.NFData UpdateChannelClass' where
  rnf :: UpdateChannelClass' -> ()
rnf UpdateChannelClass'' {Maybe [OutputDestination]
Text
ChannelClass
channelClass :: ChannelClass
channelId :: Text
destinations :: Maybe [OutputDestination]
$sel:channelClass:UpdateChannelClass'' :: UpdateChannelClass' -> ChannelClass
$sel:channelId:UpdateChannelClass'' :: UpdateChannelClass' -> Text
$sel:destinations:UpdateChannelClass'' :: UpdateChannelClass' -> Maybe [OutputDestination]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [OutputDestination]
destinations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
channelId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ChannelClass
channelClass

instance Data.ToHeaders UpdateChannelClass' where
  toHeaders :: UpdateChannelClass' -> 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 UpdateChannelClass' where
  toJSON :: UpdateChannelClass' -> Value
toJSON UpdateChannelClass'' {Maybe [OutputDestination]
Text
ChannelClass
channelClass :: ChannelClass
channelId :: Text
destinations :: Maybe [OutputDestination]
$sel:channelClass:UpdateChannelClass'' :: UpdateChannelClass' -> ChannelClass
$sel:channelId:UpdateChannelClass'' :: UpdateChannelClass' -> Text
$sel:destinations:UpdateChannelClass'' :: UpdateChannelClass' -> Maybe [OutputDestination]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"destinations" 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 [OutputDestination]
destinations,
            forall a. a -> Maybe a
Prelude.Just (Key
"channelClass" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ChannelClass
channelClass)
          ]
      )

instance Data.ToPath UpdateChannelClass' where
  toPath :: UpdateChannelClass' -> ByteString
toPath UpdateChannelClass'' {Maybe [OutputDestination]
Text
ChannelClass
channelClass :: ChannelClass
channelId :: Text
destinations :: Maybe [OutputDestination]
$sel:channelClass:UpdateChannelClass'' :: UpdateChannelClass' -> ChannelClass
$sel:channelId:UpdateChannelClass'' :: UpdateChannelClass' -> Text
$sel:destinations:UpdateChannelClass'' :: UpdateChannelClass' -> Maybe [OutputDestination]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/prod/channels/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
channelId,
        ByteString
"/channelClass"
      ]

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

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

-- |
-- Create a value of 'UpdateChannelClassResponse' 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:
--
-- 'channel', 'updateChannelClassResponse_channel' - Undocumented member.
--
-- 'httpStatus', 'updateChannelClassResponse_httpStatus' - The response's http status code.
newUpdateChannelClassResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateChannelClassResponse
newUpdateChannelClassResponse :: Int -> UpdateChannelClassResponse
newUpdateChannelClassResponse Int
pHttpStatus_ =
  UpdateChannelClassResponse'
    { $sel:channel:UpdateChannelClassResponse' :: Maybe Channel
channel =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateChannelClassResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
updateChannelClassResponse_channel :: Lens.Lens' UpdateChannelClassResponse (Prelude.Maybe Channel)
updateChannelClassResponse_channel :: Lens' UpdateChannelClassResponse (Maybe Channel)
updateChannelClassResponse_channel = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateChannelClassResponse' {Maybe Channel
channel :: Maybe Channel
$sel:channel:UpdateChannelClassResponse' :: UpdateChannelClassResponse -> Maybe Channel
channel} -> Maybe Channel
channel) (\s :: UpdateChannelClassResponse
s@UpdateChannelClassResponse' {} Maybe Channel
a -> UpdateChannelClassResponse
s {$sel:channel:UpdateChannelClassResponse' :: Maybe Channel
channel = Maybe Channel
a} :: UpdateChannelClassResponse)

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

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