{-# 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.GetPreset
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieve the JSON for a specific preset.
module Amazonka.MediaConvert.GetPreset
  ( -- * Creating a Request
    GetPreset (..),
    newGetPreset,

    -- * Request Lenses
    getPreset_name,

    -- * Destructuring the Response
    GetPresetResponse (..),
    newGetPresetResponse,

    -- * Response Lenses
    getPresetResponse_preset,
    getPresetResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetPreset' smart constructor.
data GetPreset = GetPreset'
  { -- | The name of the preset.
    GetPreset -> Text
name :: Prelude.Text
  }
  deriving (GetPreset -> GetPreset -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetPreset -> GetPreset -> Bool
$c/= :: GetPreset -> GetPreset -> Bool
== :: GetPreset -> GetPreset -> Bool
$c== :: GetPreset -> GetPreset -> Bool
Prelude.Eq, ReadPrec [GetPreset]
ReadPrec GetPreset
Int -> ReadS GetPreset
ReadS [GetPreset]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetPreset]
$creadListPrec :: ReadPrec [GetPreset]
readPrec :: ReadPrec GetPreset
$creadPrec :: ReadPrec GetPreset
readList :: ReadS [GetPreset]
$creadList :: ReadS [GetPreset]
readsPrec :: Int -> ReadS GetPreset
$creadsPrec :: Int -> ReadS GetPreset
Prelude.Read, Int -> GetPreset -> ShowS
[GetPreset] -> ShowS
GetPreset -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetPreset] -> ShowS
$cshowList :: [GetPreset] -> ShowS
show :: GetPreset -> String
$cshow :: GetPreset -> String
showsPrec :: Int -> GetPreset -> ShowS
$cshowsPrec :: Int -> GetPreset -> ShowS
Prelude.Show, forall x. Rep GetPreset x -> GetPreset
forall x. GetPreset -> Rep GetPreset x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetPreset x -> GetPreset
$cfrom :: forall x. GetPreset -> Rep GetPreset x
Prelude.Generic)

-- |
-- Create a value of 'GetPreset' 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', 'getPreset_name' - The name of the preset.
newGetPreset ::
  -- | 'name'
  Prelude.Text ->
  GetPreset
newGetPreset :: Text -> GetPreset
newGetPreset Text
pName_ = GetPreset' {$sel:name:GetPreset' :: Text
name = Text
pName_}

-- | The name of the preset.
getPreset_name :: Lens.Lens' GetPreset Prelude.Text
getPreset_name :: Lens' GetPreset Text
getPreset_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPreset' {Text
name :: Text
$sel:name:GetPreset' :: GetPreset -> Text
name} -> Text
name) (\s :: GetPreset
s@GetPreset' {} Text
a -> GetPreset
s {$sel:name:GetPreset' :: Text
name = Text
a} :: GetPreset)

instance Core.AWSRequest GetPreset where
  type AWSResponse GetPreset = GetPresetResponse
  request :: (Service -> Service) -> GetPreset -> Request GetPreset
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetPreset
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetPreset)))
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 Preset -> Int -> GetPresetResponse
GetPresetResponse'
            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
"preset")
            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 GetPreset where
  hashWithSalt :: Int -> GetPreset -> Int
hashWithSalt Int
_salt GetPreset' {Text
name :: Text
$sel:name:GetPreset' :: GetPreset -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData GetPreset where
  rnf :: GetPreset -> ()
rnf GetPreset' {Text
name :: Text
$sel:name:GetPreset' :: GetPreset -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToHeaders GetPreset where
  toHeaders :: GetPreset -> 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.ToPath GetPreset where
  toPath :: GetPreset -> ByteString
toPath GetPreset' {Text
name :: Text
$sel:name:GetPreset' :: GetPreset -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/2017-08-29/presets/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
name]

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

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

-- |
-- Create a value of 'GetPresetResponse' 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', 'getPresetResponse_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', 'getPresetResponse_httpStatus' - The response's http status code.
newGetPresetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetPresetResponse
newGetPresetResponse :: Int -> GetPresetResponse
newGetPresetResponse Int
pHttpStatus_ =
  GetPresetResponse'
    { $sel:preset:GetPresetResponse' :: Maybe Preset
preset = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetPresetResponse' :: 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.
getPresetResponse_preset :: Lens.Lens' GetPresetResponse (Prelude.Maybe Preset)
getPresetResponse_preset :: Lens' GetPresetResponse (Maybe Preset)
getPresetResponse_preset = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPresetResponse' {Maybe Preset
preset :: Maybe Preset
$sel:preset:GetPresetResponse' :: GetPresetResponse -> Maybe Preset
preset} -> Maybe Preset
preset) (\s :: GetPresetResponse
s@GetPresetResponse' {} Maybe Preset
a -> GetPresetResponse
s {$sel:preset:GetPresetResponse' :: Maybe Preset
preset = Maybe Preset
a} :: GetPresetResponse)

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

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