{-# 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.MediaConvert.UpdatePreset
-- 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)
--
-- Modify one of your existing presets.
module Amazonka.MediaConvert.UpdatePreset
  ( -- * Creating a Request
    UpdatePreset (..),
    newUpdatePreset,

    -- * Request Lenses
    updatePreset_settings,
    updatePreset_category,
    updatePreset_description,
    updatePreset_name,

    -- * Destructuring the Response
    UpdatePresetResponse (..),
    newUpdatePresetResponse,

    -- * Response Lenses
    updatePresetResponse_preset,
    updatePresetResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaConvert.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdatePreset' smart constructor.
data UpdatePreset = UpdatePreset'
  { -- | Settings for preset
    UpdatePreset -> Maybe PresetSettings
settings :: Prelude.Maybe PresetSettings,
    -- | The new category for the preset, if you are changing it.
    UpdatePreset -> Maybe Text
category :: Prelude.Maybe Prelude.Text,
    -- | The new description for the preset, if you are changing it.
    UpdatePreset -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The name of the preset you are modifying.
    UpdatePreset -> Text
name :: Prelude.Text
  }
  deriving (UpdatePreset -> UpdatePreset -> Bool
(UpdatePreset -> UpdatePreset -> Bool)
-> (UpdatePreset -> UpdatePreset -> Bool) -> Eq UpdatePreset
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePreset -> UpdatePreset -> Bool
$c/= :: UpdatePreset -> UpdatePreset -> Bool
== :: UpdatePreset -> UpdatePreset -> Bool
$c== :: UpdatePreset -> UpdatePreset -> Bool
Prelude.Eq, ReadPrec [UpdatePreset]
ReadPrec UpdatePreset
Int -> ReadS UpdatePreset
ReadS [UpdatePreset]
(Int -> ReadS UpdatePreset)
-> ReadS [UpdatePreset]
-> ReadPrec UpdatePreset
-> ReadPrec [UpdatePreset]
-> Read UpdatePreset
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdatePreset]
$creadListPrec :: ReadPrec [UpdatePreset]
readPrec :: ReadPrec UpdatePreset
$creadPrec :: ReadPrec UpdatePreset
readList :: ReadS [UpdatePreset]
$creadList :: ReadS [UpdatePreset]
readsPrec :: Int -> ReadS UpdatePreset
$creadsPrec :: Int -> ReadS UpdatePreset
Prelude.Read, Int -> UpdatePreset -> ShowS
[UpdatePreset] -> ShowS
UpdatePreset -> String
(Int -> UpdatePreset -> ShowS)
-> (UpdatePreset -> String)
-> ([UpdatePreset] -> ShowS)
-> Show UpdatePreset
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePreset] -> ShowS
$cshowList :: [UpdatePreset] -> ShowS
show :: UpdatePreset -> String
$cshow :: UpdatePreset -> String
showsPrec :: Int -> UpdatePreset -> ShowS
$cshowsPrec :: Int -> UpdatePreset -> ShowS
Prelude.Show, (forall x. UpdatePreset -> Rep UpdatePreset x)
-> (forall x. Rep UpdatePreset x -> UpdatePreset)
-> Generic UpdatePreset
forall x. Rep UpdatePreset x -> UpdatePreset
forall x. UpdatePreset -> Rep UpdatePreset x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdatePreset x -> UpdatePreset
$cfrom :: forall x. UpdatePreset -> Rep UpdatePreset x
Prelude.Generic)

-- |
-- Create a value of 'UpdatePreset' 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:
--
-- 'settings', 'updatePreset_settings' - Settings for preset
--
-- 'category', 'updatePreset_category' - The new category for the preset, if you are changing it.
--
-- 'description', 'updatePreset_description' - The new description for the preset, if you are changing it.
--
-- 'name', 'updatePreset_name' - The name of the preset you are modifying.
newUpdatePreset ::
  -- | 'name'
  Prelude.Text ->
  UpdatePreset
newUpdatePreset :: Text -> UpdatePreset
newUpdatePreset Text
pName_ =
  UpdatePreset' :: Maybe PresetSettings
-> Maybe Text -> Maybe Text -> Text -> UpdatePreset
UpdatePreset'
    { $sel:settings:UpdatePreset' :: Maybe PresetSettings
settings = Maybe PresetSettings
forall a. Maybe a
Prelude.Nothing,
      $sel:category:UpdatePreset' :: Maybe Text
category = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:description:UpdatePreset' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:UpdatePreset' :: Text
name = Text
pName_
    }

-- | Settings for preset
updatePreset_settings :: Lens.Lens' UpdatePreset (Prelude.Maybe PresetSettings)
updatePreset_settings :: (Maybe PresetSettings -> f (Maybe PresetSettings))
-> UpdatePreset -> f UpdatePreset
updatePreset_settings = (UpdatePreset -> Maybe PresetSettings)
-> (UpdatePreset -> Maybe PresetSettings -> UpdatePreset)
-> Lens
     UpdatePreset
     UpdatePreset
     (Maybe PresetSettings)
     (Maybe PresetSettings)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePreset' {Maybe PresetSettings
settings :: Maybe PresetSettings
$sel:settings:UpdatePreset' :: UpdatePreset -> Maybe PresetSettings
settings} -> Maybe PresetSettings
settings) (\s :: UpdatePreset
s@UpdatePreset' {} Maybe PresetSettings
a -> UpdatePreset
s {$sel:settings:UpdatePreset' :: Maybe PresetSettings
settings = Maybe PresetSettings
a} :: UpdatePreset)

-- | The new category for the preset, if you are changing it.
updatePreset_category :: Lens.Lens' UpdatePreset (Prelude.Maybe Prelude.Text)
updatePreset_category :: (Maybe Text -> f (Maybe Text)) -> UpdatePreset -> f UpdatePreset
updatePreset_category = (UpdatePreset -> Maybe Text)
-> (UpdatePreset -> Maybe Text -> UpdatePreset)
-> Lens UpdatePreset UpdatePreset (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePreset' {Maybe Text
category :: Maybe Text
$sel:category:UpdatePreset' :: UpdatePreset -> Maybe Text
category} -> Maybe Text
category) (\s :: UpdatePreset
s@UpdatePreset' {} Maybe Text
a -> UpdatePreset
s {$sel:category:UpdatePreset' :: Maybe Text
category = Maybe Text
a} :: UpdatePreset)

-- | The new description for the preset, if you are changing it.
updatePreset_description :: Lens.Lens' UpdatePreset (Prelude.Maybe Prelude.Text)
updatePreset_description :: (Maybe Text -> f (Maybe Text)) -> UpdatePreset -> f UpdatePreset
updatePreset_description = (UpdatePreset -> Maybe Text)
-> (UpdatePreset -> Maybe Text -> UpdatePreset)
-> Lens UpdatePreset UpdatePreset (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePreset' {Maybe Text
description :: Maybe Text
$sel:description:UpdatePreset' :: UpdatePreset -> Maybe Text
description} -> Maybe Text
description) (\s :: UpdatePreset
s@UpdatePreset' {} Maybe Text
a -> UpdatePreset
s {$sel:description:UpdatePreset' :: Maybe Text
description = Maybe Text
a} :: UpdatePreset)

-- | The name of the preset you are modifying.
updatePreset_name :: Lens.Lens' UpdatePreset Prelude.Text
updatePreset_name :: (Text -> f Text) -> UpdatePreset -> f UpdatePreset
updatePreset_name = (UpdatePreset -> Text)
-> (UpdatePreset -> Text -> UpdatePreset)
-> Lens UpdatePreset UpdatePreset Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePreset' {Text
name :: Text
$sel:name:UpdatePreset' :: UpdatePreset -> Text
name} -> Text
name) (\s :: UpdatePreset
s@UpdatePreset' {} Text
a -> UpdatePreset
s {$sel:name:UpdatePreset' :: Text
name = Text
a} :: UpdatePreset)

instance Core.AWSRequest UpdatePreset where
  type AWSResponse UpdatePreset = UpdatePresetResponse
  request :: UpdatePreset -> Request UpdatePreset
request = Service -> UpdatePreset -> Request UpdatePreset
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdatePreset
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdatePreset)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdatePreset))
-> Logger
-> Service
-> Proxy UpdatePreset
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdatePreset)))
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 Preset -> Int -> UpdatePresetResponse
UpdatePresetResponse'
            (Maybe Preset -> Int -> UpdatePresetResponse)
-> Either String (Maybe Preset)
-> Either String (Int -> UpdatePresetResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Preset)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"preset")
            Either String (Int -> UpdatePresetResponse)
-> Either String Int -> Either String UpdatePresetResponse
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 UpdatePreset

instance Prelude.NFData UpdatePreset

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

instance Core.ToPath UpdatePreset where
  toPath :: UpdatePreset -> ByteString
toPath UpdatePreset' {Maybe Text
Maybe PresetSettings
Text
name :: Text
description :: Maybe Text
category :: Maybe Text
settings :: Maybe PresetSettings
$sel:name:UpdatePreset' :: UpdatePreset -> Text
$sel:description:UpdatePreset' :: UpdatePreset -> Maybe Text
$sel:category:UpdatePreset' :: UpdatePreset -> Maybe Text
$sel:settings:UpdatePreset' :: UpdatePreset -> Maybe PresetSettings
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/2017-08-29/presets/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
name]

instance Core.ToQuery UpdatePreset where
  toQuery :: UpdatePreset -> QueryString
toQuery = QueryString -> UpdatePreset -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newUpdatePresetResponse' smart constructor.
data UpdatePresetResponse = UpdatePresetResponse'
  { -- | A preset is a collection of preconfigured media conversion settings that
    -- you want MediaConvert to apply to the output during the conversion
    -- process.
    UpdatePresetResponse -> Maybe Preset
preset :: Prelude.Maybe Preset,
    -- | The response's http status code.
    UpdatePresetResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdatePresetResponse -> UpdatePresetResponse -> Bool
(UpdatePresetResponse -> UpdatePresetResponse -> Bool)
-> (UpdatePresetResponse -> UpdatePresetResponse -> Bool)
-> Eq UpdatePresetResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdatePresetResponse -> UpdatePresetResponse -> Bool
$c/= :: UpdatePresetResponse -> UpdatePresetResponse -> Bool
== :: UpdatePresetResponse -> UpdatePresetResponse -> Bool
$c== :: UpdatePresetResponse -> UpdatePresetResponse -> Bool
Prelude.Eq, ReadPrec [UpdatePresetResponse]
ReadPrec UpdatePresetResponse
Int -> ReadS UpdatePresetResponse
ReadS [UpdatePresetResponse]
(Int -> ReadS UpdatePresetResponse)
-> ReadS [UpdatePresetResponse]
-> ReadPrec UpdatePresetResponse
-> ReadPrec [UpdatePresetResponse]
-> Read UpdatePresetResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdatePresetResponse]
$creadListPrec :: ReadPrec [UpdatePresetResponse]
readPrec :: ReadPrec UpdatePresetResponse
$creadPrec :: ReadPrec UpdatePresetResponse
readList :: ReadS [UpdatePresetResponse]
$creadList :: ReadS [UpdatePresetResponse]
readsPrec :: Int -> ReadS UpdatePresetResponse
$creadsPrec :: Int -> ReadS UpdatePresetResponse
Prelude.Read, Int -> UpdatePresetResponse -> ShowS
[UpdatePresetResponse] -> ShowS
UpdatePresetResponse -> String
(Int -> UpdatePresetResponse -> ShowS)
-> (UpdatePresetResponse -> String)
-> ([UpdatePresetResponse] -> ShowS)
-> Show UpdatePresetResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdatePresetResponse] -> ShowS
$cshowList :: [UpdatePresetResponse] -> ShowS
show :: UpdatePresetResponse -> String
$cshow :: UpdatePresetResponse -> String
showsPrec :: Int -> UpdatePresetResponse -> ShowS
$cshowsPrec :: Int -> UpdatePresetResponse -> ShowS
Prelude.Show, (forall x. UpdatePresetResponse -> Rep UpdatePresetResponse x)
-> (forall x. Rep UpdatePresetResponse x -> UpdatePresetResponse)
-> Generic UpdatePresetResponse
forall x. Rep UpdatePresetResponse x -> UpdatePresetResponse
forall x. UpdatePresetResponse -> Rep UpdatePresetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdatePresetResponse x -> UpdatePresetResponse
$cfrom :: forall x. UpdatePresetResponse -> Rep UpdatePresetResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdatePresetResponse' 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:
--
-- 'preset', 'updatePresetResponse_preset' - A preset is a collection of preconfigured media conversion settings that
-- you want MediaConvert to apply to the output during the conversion
-- process.
--
-- 'httpStatus', 'updatePresetResponse_httpStatus' - The response's http status code.
newUpdatePresetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdatePresetResponse
newUpdatePresetResponse :: Int -> UpdatePresetResponse
newUpdatePresetResponse Int
pHttpStatus_ =
  UpdatePresetResponse' :: Maybe Preset -> Int -> UpdatePresetResponse
UpdatePresetResponse'
    { $sel:preset:UpdatePresetResponse' :: Maybe Preset
preset = Maybe Preset
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdatePresetResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A preset is a collection of preconfigured media conversion settings that
-- you want MediaConvert to apply to the output during the conversion
-- process.
updatePresetResponse_preset :: Lens.Lens' UpdatePresetResponse (Prelude.Maybe Preset)
updatePresetResponse_preset :: (Maybe Preset -> f (Maybe Preset))
-> UpdatePresetResponse -> f UpdatePresetResponse
updatePresetResponse_preset = (UpdatePresetResponse -> Maybe Preset)
-> (UpdatePresetResponse -> Maybe Preset -> UpdatePresetResponse)
-> Lens
     UpdatePresetResponse
     UpdatePresetResponse
     (Maybe Preset)
     (Maybe Preset)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdatePresetResponse' {Maybe Preset
preset :: Maybe Preset
$sel:preset:UpdatePresetResponse' :: UpdatePresetResponse -> Maybe Preset
preset} -> Maybe Preset
preset) (\s :: UpdatePresetResponse
s@UpdatePresetResponse' {} Maybe Preset
a -> UpdatePresetResponse
s {$sel:preset:UpdatePresetResponse' :: Maybe Preset
preset = Maybe Preset
a} :: UpdatePresetResponse)

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

instance Prelude.NFData UpdatePresetResponse