{-# 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.ElasticTranscoder.ListPresets
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- The ListPresets operation gets a list of the default presets included
-- with Elastic Transcoder and the presets that you\'ve added in an AWS
-- region.
--
-- This operation returns paginated results.
module Amazonka.ElasticTranscoder.ListPresets
  ( -- * Creating a Request
    ListPresets (..),
    newListPresets,

    -- * Request Lenses
    listPresets_ascending,
    listPresets_pageToken,

    -- * Destructuring the Response
    ListPresetsResponse (..),
    newListPresetsResponse,

    -- * Response Lenses
    listPresetsResponse_nextPageToken,
    listPresetsResponse_presets,
    listPresetsResponse_httpStatus,
  )
where

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

-- | The @ListPresetsRequest@ structure.
--
-- /See:/ 'newListPresets' smart constructor.
data ListPresets = ListPresets'
  { -- | To list presets in chronological order by the date and time that they
    -- were created, enter @true@. To list presets in reverse chronological
    -- order, enter @false@.
    ListPresets -> Maybe Text
ascending :: Prelude.Maybe Prelude.Text,
    -- | When Elastic Transcoder returns more than one page of results, use
    -- @pageToken@ in subsequent @GET@ requests to get each successive page of
    -- results.
    ListPresets -> Maybe Text
pageToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListPresets -> ListPresets -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPresets -> ListPresets -> Bool
$c/= :: ListPresets -> ListPresets -> Bool
== :: ListPresets -> ListPresets -> Bool
$c== :: ListPresets -> ListPresets -> Bool
Prelude.Eq, ReadPrec [ListPresets]
ReadPrec ListPresets
Int -> ReadS ListPresets
ReadS [ListPresets]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPresets]
$creadListPrec :: ReadPrec [ListPresets]
readPrec :: ReadPrec ListPresets
$creadPrec :: ReadPrec ListPresets
readList :: ReadS [ListPresets]
$creadList :: ReadS [ListPresets]
readsPrec :: Int -> ReadS ListPresets
$creadsPrec :: Int -> ReadS ListPresets
Prelude.Read, Int -> ListPresets -> ShowS
[ListPresets] -> ShowS
ListPresets -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPresets] -> ShowS
$cshowList :: [ListPresets] -> ShowS
show :: ListPresets -> String
$cshow :: ListPresets -> String
showsPrec :: Int -> ListPresets -> ShowS
$cshowsPrec :: Int -> ListPresets -> ShowS
Prelude.Show, forall x. Rep ListPresets x -> ListPresets
forall x. ListPresets -> Rep ListPresets x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPresets x -> ListPresets
$cfrom :: forall x. ListPresets -> Rep ListPresets x
Prelude.Generic)

-- |
-- Create a value of 'ListPresets' 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:
--
-- 'ascending', 'listPresets_ascending' - To list presets in chronological order by the date and time that they
-- were created, enter @true@. To list presets in reverse chronological
-- order, enter @false@.
--
-- 'pageToken', 'listPresets_pageToken' - When Elastic Transcoder returns more than one page of results, use
-- @pageToken@ in subsequent @GET@ requests to get each successive page of
-- results.
newListPresets ::
  ListPresets
newListPresets :: ListPresets
newListPresets =
  ListPresets'
    { $sel:ascending:ListPresets' :: Maybe Text
ascending = forall a. Maybe a
Prelude.Nothing,
      $sel:pageToken:ListPresets' :: Maybe Text
pageToken = forall a. Maybe a
Prelude.Nothing
    }

-- | To list presets in chronological order by the date and time that they
-- were created, enter @true@. To list presets in reverse chronological
-- order, enter @false@.
listPresets_ascending :: Lens.Lens' ListPresets (Prelude.Maybe Prelude.Text)
listPresets_ascending :: Lens' ListPresets (Maybe Text)
listPresets_ascending = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPresets' {Maybe Text
ascending :: Maybe Text
$sel:ascending:ListPresets' :: ListPresets -> Maybe Text
ascending} -> Maybe Text
ascending) (\s :: ListPresets
s@ListPresets' {} Maybe Text
a -> ListPresets
s {$sel:ascending:ListPresets' :: Maybe Text
ascending = Maybe Text
a} :: ListPresets)

-- | When Elastic Transcoder returns more than one page of results, use
-- @pageToken@ in subsequent @GET@ requests to get each successive page of
-- results.
listPresets_pageToken :: Lens.Lens' ListPresets (Prelude.Maybe Prelude.Text)
listPresets_pageToken :: Lens' ListPresets (Maybe Text)
listPresets_pageToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPresets' {Maybe Text
pageToken :: Maybe Text
$sel:pageToken:ListPresets' :: ListPresets -> Maybe Text
pageToken} -> Maybe Text
pageToken) (\s :: ListPresets
s@ListPresets' {} Maybe Text
a -> ListPresets
s {$sel:pageToken:ListPresets' :: Maybe Text
pageToken = Maybe Text
a} :: ListPresets)

instance Core.AWSPager ListPresets where
  page :: ListPresets -> AWSResponse ListPresets -> Maybe ListPresets
page ListPresets
rq AWSResponse ListPresets
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListPresets
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListPresetsResponse (Maybe Text)
listPresetsResponse_nextPageToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListPresets
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListPresetsResponse (Maybe [Preset])
listPresetsResponse_presets
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListPresets
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListPresets (Maybe Text)
listPresets_pageToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListPresets
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListPresetsResponse (Maybe Text)
listPresetsResponse_nextPageToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListPresets where
  type AWSResponse ListPresets = ListPresetsResponse
  request :: (Service -> Service) -> ListPresets -> Request ListPresets
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 ListPresets
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListPresets)))
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 Text -> Maybe [Preset] -> Int -> ListPresetsResponse
ListPresetsResponse'
            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
"NextPageToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Presets" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            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 ListPresets where
  hashWithSalt :: Int -> ListPresets -> Int
hashWithSalt Int
_salt ListPresets' {Maybe Text
pageToken :: Maybe Text
ascending :: Maybe Text
$sel:pageToken:ListPresets' :: ListPresets -> Maybe Text
$sel:ascending:ListPresets' :: ListPresets -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ascending
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
pageToken

instance Prelude.NFData ListPresets where
  rnf :: ListPresets -> ()
rnf ListPresets' {Maybe Text
pageToken :: Maybe Text
ascending :: Maybe Text
$sel:pageToken:ListPresets' :: ListPresets -> Maybe Text
$sel:ascending:ListPresets' :: ListPresets -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ascending
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
pageToken

instance Data.ToHeaders ListPresets where
  toHeaders :: ListPresets -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

instance Data.ToPath ListPresets where
  toPath :: ListPresets -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/2012-09-25/presets"

instance Data.ToQuery ListPresets where
  toQuery :: ListPresets -> QueryString
toQuery ListPresets' {Maybe Text
pageToken :: Maybe Text
ascending :: Maybe Text
$sel:pageToken:ListPresets' :: ListPresets -> Maybe Text
$sel:ascending:ListPresets' :: ListPresets -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Ascending" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
ascending,
        ByteString
"PageToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
pageToken
      ]

-- | The @ListPresetsResponse@ structure.
--
-- /See:/ 'newListPresetsResponse' smart constructor.
data ListPresetsResponse = ListPresetsResponse'
  { -- | A value that you use to access the second and subsequent pages of
    -- results, if any. When the presets fit on one page or when you\'ve
    -- reached the last page of results, the value of @NextPageToken@ is
    -- @null@.
    ListPresetsResponse -> Maybe Text
nextPageToken :: Prelude.Maybe Prelude.Text,
    -- | An array of @Preset@ objects.
    ListPresetsResponse -> Maybe [Preset]
presets :: Prelude.Maybe [Preset],
    -- | The response's http status code.
    ListPresetsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListPresetsResponse -> ListPresetsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPresetsResponse -> ListPresetsResponse -> Bool
$c/= :: ListPresetsResponse -> ListPresetsResponse -> Bool
== :: ListPresetsResponse -> ListPresetsResponse -> Bool
$c== :: ListPresetsResponse -> ListPresetsResponse -> Bool
Prelude.Eq, ReadPrec [ListPresetsResponse]
ReadPrec ListPresetsResponse
Int -> ReadS ListPresetsResponse
ReadS [ListPresetsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPresetsResponse]
$creadListPrec :: ReadPrec [ListPresetsResponse]
readPrec :: ReadPrec ListPresetsResponse
$creadPrec :: ReadPrec ListPresetsResponse
readList :: ReadS [ListPresetsResponse]
$creadList :: ReadS [ListPresetsResponse]
readsPrec :: Int -> ReadS ListPresetsResponse
$creadsPrec :: Int -> ReadS ListPresetsResponse
Prelude.Read, Int -> ListPresetsResponse -> ShowS
[ListPresetsResponse] -> ShowS
ListPresetsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPresetsResponse] -> ShowS
$cshowList :: [ListPresetsResponse] -> ShowS
show :: ListPresetsResponse -> String
$cshow :: ListPresetsResponse -> String
showsPrec :: Int -> ListPresetsResponse -> ShowS
$cshowsPrec :: Int -> ListPresetsResponse -> ShowS
Prelude.Show, forall x. Rep ListPresetsResponse x -> ListPresetsResponse
forall x. ListPresetsResponse -> Rep ListPresetsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPresetsResponse x -> ListPresetsResponse
$cfrom :: forall x. ListPresetsResponse -> Rep ListPresetsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListPresetsResponse' 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:
--
-- 'nextPageToken', 'listPresetsResponse_nextPageToken' - A value that you use to access the second and subsequent pages of
-- results, if any. When the presets fit on one page or when you\'ve
-- reached the last page of results, the value of @NextPageToken@ is
-- @null@.
--
-- 'presets', 'listPresetsResponse_presets' - An array of @Preset@ objects.
--
-- 'httpStatus', 'listPresetsResponse_httpStatus' - The response's http status code.
newListPresetsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListPresetsResponse
newListPresetsResponse :: Int -> ListPresetsResponse
newListPresetsResponse Int
pHttpStatus_ =
  ListPresetsResponse'
    { $sel:nextPageToken:ListPresetsResponse' :: Maybe Text
nextPageToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:presets:ListPresetsResponse' :: Maybe [Preset]
presets = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListPresetsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A value that you use to access the second and subsequent pages of
-- results, if any. When the presets fit on one page or when you\'ve
-- reached the last page of results, the value of @NextPageToken@ is
-- @null@.
listPresetsResponse_nextPageToken :: Lens.Lens' ListPresetsResponse (Prelude.Maybe Prelude.Text)
listPresetsResponse_nextPageToken :: Lens' ListPresetsResponse (Maybe Text)
listPresetsResponse_nextPageToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPresetsResponse' {Maybe Text
nextPageToken :: Maybe Text
$sel:nextPageToken:ListPresetsResponse' :: ListPresetsResponse -> Maybe Text
nextPageToken} -> Maybe Text
nextPageToken) (\s :: ListPresetsResponse
s@ListPresetsResponse' {} Maybe Text
a -> ListPresetsResponse
s {$sel:nextPageToken:ListPresetsResponse' :: Maybe Text
nextPageToken = Maybe Text
a} :: ListPresetsResponse)

-- | An array of @Preset@ objects.
listPresetsResponse_presets :: Lens.Lens' ListPresetsResponse (Prelude.Maybe [Preset])
listPresetsResponse_presets :: Lens' ListPresetsResponse (Maybe [Preset])
listPresetsResponse_presets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPresetsResponse' {Maybe [Preset]
presets :: Maybe [Preset]
$sel:presets:ListPresetsResponse' :: ListPresetsResponse -> Maybe [Preset]
presets} -> Maybe [Preset]
presets) (\s :: ListPresetsResponse
s@ListPresetsResponse' {} Maybe [Preset]
a -> ListPresetsResponse
s {$sel:presets:ListPresetsResponse' :: Maybe [Preset]
presets = Maybe [Preset]
a} :: ListPresetsResponse) 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

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

instance Prelude.NFData ListPresetsResponse where
  rnf :: ListPresetsResponse -> ()
rnf ListPresetsResponse' {Int
Maybe [Preset]
Maybe Text
httpStatus :: Int
presets :: Maybe [Preset]
nextPageToken :: Maybe Text
$sel:httpStatus:ListPresetsResponse' :: ListPresetsResponse -> Int
$sel:presets:ListPresetsResponse' :: ListPresetsResponse -> Maybe [Preset]
$sel:nextPageToken:ListPresetsResponse' :: ListPresetsResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextPageToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Preset]
presets
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus