{-# 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.ListMultiplexes
-- 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 a list of the existing multiplexes.
--
-- This operation returns paginated results.
module Amazonka.MediaLive.ListMultiplexes
  ( -- * Creating a Request
    ListMultiplexes (..),
    newListMultiplexes,

    -- * Request Lenses
    listMultiplexes_maxResults,
    listMultiplexes_nextToken,

    -- * Destructuring the Response
    ListMultiplexesResponse (..),
    newListMultiplexesResponse,

    -- * Response Lenses
    listMultiplexesResponse_multiplexes,
    listMultiplexesResponse_nextToken,
    listMultiplexesResponse_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

-- | Placeholder documentation for ListMultiplexesRequest
--
-- /See:/ 'newListMultiplexes' smart constructor.
data ListMultiplexes = ListMultiplexes'
  { -- | The maximum number of items to return.
    ListMultiplexes -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token to retrieve the next page of results.
    ListMultiplexes -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListMultiplexes -> ListMultiplexes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListMultiplexes -> ListMultiplexes -> Bool
$c/= :: ListMultiplexes -> ListMultiplexes -> Bool
== :: ListMultiplexes -> ListMultiplexes -> Bool
$c== :: ListMultiplexes -> ListMultiplexes -> Bool
Prelude.Eq, ReadPrec [ListMultiplexes]
ReadPrec ListMultiplexes
Int -> ReadS ListMultiplexes
ReadS [ListMultiplexes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListMultiplexes]
$creadListPrec :: ReadPrec [ListMultiplexes]
readPrec :: ReadPrec ListMultiplexes
$creadPrec :: ReadPrec ListMultiplexes
readList :: ReadS [ListMultiplexes]
$creadList :: ReadS [ListMultiplexes]
readsPrec :: Int -> ReadS ListMultiplexes
$creadsPrec :: Int -> ReadS ListMultiplexes
Prelude.Read, Int -> ListMultiplexes -> ShowS
[ListMultiplexes] -> ShowS
ListMultiplexes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListMultiplexes] -> ShowS
$cshowList :: [ListMultiplexes] -> ShowS
show :: ListMultiplexes -> String
$cshow :: ListMultiplexes -> String
showsPrec :: Int -> ListMultiplexes -> ShowS
$cshowsPrec :: Int -> ListMultiplexes -> ShowS
Prelude.Show, forall x. Rep ListMultiplexes x -> ListMultiplexes
forall x. ListMultiplexes -> Rep ListMultiplexes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListMultiplexes x -> ListMultiplexes
$cfrom :: forall x. ListMultiplexes -> Rep ListMultiplexes x
Prelude.Generic)

-- |
-- Create a value of 'ListMultiplexes' 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:
--
-- 'maxResults', 'listMultiplexes_maxResults' - The maximum number of items to return.
--
-- 'nextToken', 'listMultiplexes_nextToken' - The token to retrieve the next page of results.
newListMultiplexes ::
  ListMultiplexes
newListMultiplexes :: ListMultiplexes
newListMultiplexes =
  ListMultiplexes'
    { $sel:maxResults:ListMultiplexes' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListMultiplexes' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of items to return.
listMultiplexes_maxResults :: Lens.Lens' ListMultiplexes (Prelude.Maybe Prelude.Natural)
listMultiplexes_maxResults :: Lens' ListMultiplexes (Maybe Natural)
listMultiplexes_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListMultiplexes' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListMultiplexes' :: ListMultiplexes -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListMultiplexes
s@ListMultiplexes' {} Maybe Natural
a -> ListMultiplexes
s {$sel:maxResults:ListMultiplexes' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListMultiplexes)

-- | The token to retrieve the next page of results.
listMultiplexes_nextToken :: Lens.Lens' ListMultiplexes (Prelude.Maybe Prelude.Text)
listMultiplexes_nextToken :: Lens' ListMultiplexes (Maybe Text)
listMultiplexes_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListMultiplexes' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListMultiplexes' :: ListMultiplexes -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListMultiplexes
s@ListMultiplexes' {} Maybe Text
a -> ListMultiplexes
s {$sel:nextToken:ListMultiplexes' :: Maybe Text
nextToken = Maybe Text
a} :: ListMultiplexes)

instance Core.AWSPager ListMultiplexes where
  page :: ListMultiplexes
-> AWSResponse ListMultiplexes -> Maybe ListMultiplexes
page ListMultiplexes
rq AWSResponse ListMultiplexes
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListMultiplexes
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListMultiplexesResponse (Maybe Text)
listMultiplexesResponse_nextToken
            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 ListMultiplexes
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListMultiplexesResponse (Maybe [MultiplexSummary])
listMultiplexesResponse_multiplexes
            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.$ ListMultiplexes
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListMultiplexes (Maybe Text)
listMultiplexes_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListMultiplexes
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListMultiplexesResponse (Maybe Text)
listMultiplexesResponse_nextToken
          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 ListMultiplexes where
  type
    AWSResponse ListMultiplexes =
      ListMultiplexesResponse
  request :: (Service -> Service) -> ListMultiplexes -> Request ListMultiplexes
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 ListMultiplexes
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListMultiplexes)))
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 [MultiplexSummary]
-> Maybe Text -> Int -> ListMultiplexesResponse
ListMultiplexesResponse'
            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
"multiplexes" 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.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"nextToken")
            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 ListMultiplexes where
  hashWithSalt :: Int -> ListMultiplexes -> Int
hashWithSalt Int
_salt ListMultiplexes' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListMultiplexes' :: ListMultiplexes -> Maybe Text
$sel:maxResults:ListMultiplexes' :: ListMultiplexes -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken

instance Prelude.NFData ListMultiplexes where
  rnf :: ListMultiplexes -> ()
rnf ListMultiplexes' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListMultiplexes' :: ListMultiplexes -> Maybe Text
$sel:maxResults:ListMultiplexes' :: ListMultiplexes -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken

instance Data.ToHeaders ListMultiplexes where
  toHeaders :: ListMultiplexes -> 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 ListMultiplexes where
  toPath :: ListMultiplexes -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/prod/multiplexes"

instance Data.ToQuery ListMultiplexes where
  toQuery :: ListMultiplexes -> QueryString
toQuery ListMultiplexes' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListMultiplexes' :: ListMultiplexes -> Maybe Text
$sel:maxResults:ListMultiplexes' :: ListMultiplexes -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | Placeholder documentation for ListMultiplexesResponse
--
-- /See:/ 'newListMultiplexesResponse' smart constructor.
data ListMultiplexesResponse = ListMultiplexesResponse'
  { -- | List of multiplexes.
    ListMultiplexesResponse -> Maybe [MultiplexSummary]
multiplexes :: Prelude.Maybe [MultiplexSummary],
    -- | Token for the next ListMultiplexes request.
    ListMultiplexesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListMultiplexesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListMultiplexesResponse -> ListMultiplexesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListMultiplexesResponse -> ListMultiplexesResponse -> Bool
$c/= :: ListMultiplexesResponse -> ListMultiplexesResponse -> Bool
== :: ListMultiplexesResponse -> ListMultiplexesResponse -> Bool
$c== :: ListMultiplexesResponse -> ListMultiplexesResponse -> Bool
Prelude.Eq, ReadPrec [ListMultiplexesResponse]
ReadPrec ListMultiplexesResponse
Int -> ReadS ListMultiplexesResponse
ReadS [ListMultiplexesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListMultiplexesResponse]
$creadListPrec :: ReadPrec [ListMultiplexesResponse]
readPrec :: ReadPrec ListMultiplexesResponse
$creadPrec :: ReadPrec ListMultiplexesResponse
readList :: ReadS [ListMultiplexesResponse]
$creadList :: ReadS [ListMultiplexesResponse]
readsPrec :: Int -> ReadS ListMultiplexesResponse
$creadsPrec :: Int -> ReadS ListMultiplexesResponse
Prelude.Read, Int -> ListMultiplexesResponse -> ShowS
[ListMultiplexesResponse] -> ShowS
ListMultiplexesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListMultiplexesResponse] -> ShowS
$cshowList :: [ListMultiplexesResponse] -> ShowS
show :: ListMultiplexesResponse -> String
$cshow :: ListMultiplexesResponse -> String
showsPrec :: Int -> ListMultiplexesResponse -> ShowS
$cshowsPrec :: Int -> ListMultiplexesResponse -> ShowS
Prelude.Show, forall x. Rep ListMultiplexesResponse x -> ListMultiplexesResponse
forall x. ListMultiplexesResponse -> Rep ListMultiplexesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListMultiplexesResponse x -> ListMultiplexesResponse
$cfrom :: forall x. ListMultiplexesResponse -> Rep ListMultiplexesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListMultiplexesResponse' 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:
--
-- 'multiplexes', 'listMultiplexesResponse_multiplexes' - List of multiplexes.
--
-- 'nextToken', 'listMultiplexesResponse_nextToken' - Token for the next ListMultiplexes request.
--
-- 'httpStatus', 'listMultiplexesResponse_httpStatus' - The response's http status code.
newListMultiplexesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListMultiplexesResponse
newListMultiplexesResponse :: Int -> ListMultiplexesResponse
newListMultiplexesResponse Int
pHttpStatus_ =
  ListMultiplexesResponse'
    { $sel:multiplexes:ListMultiplexesResponse' :: Maybe [MultiplexSummary]
multiplexes =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListMultiplexesResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListMultiplexesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | List of multiplexes.
listMultiplexesResponse_multiplexes :: Lens.Lens' ListMultiplexesResponse (Prelude.Maybe [MultiplexSummary])
listMultiplexesResponse_multiplexes :: Lens' ListMultiplexesResponse (Maybe [MultiplexSummary])
listMultiplexesResponse_multiplexes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListMultiplexesResponse' {Maybe [MultiplexSummary]
multiplexes :: Maybe [MultiplexSummary]
$sel:multiplexes:ListMultiplexesResponse' :: ListMultiplexesResponse -> Maybe [MultiplexSummary]
multiplexes} -> Maybe [MultiplexSummary]
multiplexes) (\s :: ListMultiplexesResponse
s@ListMultiplexesResponse' {} Maybe [MultiplexSummary]
a -> ListMultiplexesResponse
s {$sel:multiplexes:ListMultiplexesResponse' :: Maybe [MultiplexSummary]
multiplexes = Maybe [MultiplexSummary]
a} :: ListMultiplexesResponse) 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

-- | Token for the next ListMultiplexes request.
listMultiplexesResponse_nextToken :: Lens.Lens' ListMultiplexesResponse (Prelude.Maybe Prelude.Text)
listMultiplexesResponse_nextToken :: Lens' ListMultiplexesResponse (Maybe Text)
listMultiplexesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListMultiplexesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListMultiplexesResponse' :: ListMultiplexesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListMultiplexesResponse
s@ListMultiplexesResponse' {} Maybe Text
a -> ListMultiplexesResponse
s {$sel:nextToken:ListMultiplexesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListMultiplexesResponse)

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

instance Prelude.NFData ListMultiplexesResponse where
  rnf :: ListMultiplexesResponse -> ()
rnf ListMultiplexesResponse' {Int
Maybe [MultiplexSummary]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
multiplexes :: Maybe [MultiplexSummary]
$sel:httpStatus:ListMultiplexesResponse' :: ListMultiplexesResponse -> Int
$sel:nextToken:ListMultiplexesResponse' :: ListMultiplexesResponse -> Maybe Text
$sel:multiplexes:ListMultiplexesResponse' :: ListMultiplexesResponse -> Maybe [MultiplexSummary]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [MultiplexSummary]
multiplexes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus