{-# 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.ListChannels
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Produces list of channels that have been created
--
-- This operation returns paginated results.
module Amazonka.MediaLive.ListChannels
  ( -- * Creating a Request
    ListChannels (..),
    newListChannels,

    -- * Request Lenses
    listChannels_maxResults,
    listChannels_nextToken,

    -- * Destructuring the Response
    ListChannelsResponse (..),
    newListChannelsResponse,

    -- * Response Lenses
    listChannelsResponse_channels,
    listChannelsResponse_nextToken,
    listChannelsResponse_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 ListChannelsRequest
--
-- /See:/ 'newListChannels' smart constructor.
data ListChannels = ListChannels'
  { ListChannels -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    ListChannels -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListChannels -> ListChannels -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListChannels -> ListChannels -> Bool
$c/= :: ListChannels -> ListChannels -> Bool
== :: ListChannels -> ListChannels -> Bool
$c== :: ListChannels -> ListChannels -> Bool
Prelude.Eq, ReadPrec [ListChannels]
ReadPrec ListChannels
Int -> ReadS ListChannels
ReadS [ListChannels]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListChannels]
$creadListPrec :: ReadPrec [ListChannels]
readPrec :: ReadPrec ListChannels
$creadPrec :: ReadPrec ListChannels
readList :: ReadS [ListChannels]
$creadList :: ReadS [ListChannels]
readsPrec :: Int -> ReadS ListChannels
$creadsPrec :: Int -> ReadS ListChannels
Prelude.Read, Int -> ListChannels -> ShowS
[ListChannels] -> ShowS
ListChannels -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListChannels] -> ShowS
$cshowList :: [ListChannels] -> ShowS
show :: ListChannels -> String
$cshow :: ListChannels -> String
showsPrec :: Int -> ListChannels -> ShowS
$cshowsPrec :: Int -> ListChannels -> ShowS
Prelude.Show, forall x. Rep ListChannels x -> ListChannels
forall x. ListChannels -> Rep ListChannels x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListChannels x -> ListChannels
$cfrom :: forall x. ListChannels -> Rep ListChannels x
Prelude.Generic)

-- |
-- Create a value of 'ListChannels' 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', 'listChannels_maxResults' - Undocumented member.
--
-- 'nextToken', 'listChannels_nextToken' - Undocumented member.
newListChannels ::
  ListChannels
newListChannels :: ListChannels
newListChannels =
  ListChannels'
    { $sel:maxResults:ListChannels' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListChannels' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
listChannels_maxResults :: Lens.Lens' ListChannels (Prelude.Maybe Prelude.Natural)
listChannels_maxResults :: Lens' ListChannels (Maybe Natural)
listChannels_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListChannels' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListChannels' :: ListChannels -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListChannels
s@ListChannels' {} Maybe Natural
a -> ListChannels
s {$sel:maxResults:ListChannels' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListChannels)

-- | Undocumented member.
listChannels_nextToken :: Lens.Lens' ListChannels (Prelude.Maybe Prelude.Text)
listChannels_nextToken :: Lens' ListChannels (Maybe Text)
listChannels_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListChannels' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListChannels' :: ListChannels -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListChannels
s@ListChannels' {} Maybe Text
a -> ListChannels
s {$sel:nextToken:ListChannels' :: Maybe Text
nextToken = Maybe Text
a} :: ListChannels)

instance Core.AWSPager ListChannels where
  page :: ListChannels -> AWSResponse ListChannels -> Maybe ListChannels
page ListChannels
rq AWSResponse ListChannels
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListChannels
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListChannelsResponse (Maybe Text)
listChannelsResponse_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 ListChannels
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListChannelsResponse (Maybe [ChannelSummary])
listChannelsResponse_channels
            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.$ ListChannels
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListChannels (Maybe Text)
listChannels_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListChannels
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListChannelsResponse (Maybe Text)
listChannelsResponse_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 ListChannels where
  type AWSResponse ListChannels = ListChannelsResponse
  request :: (Service -> Service) -> ListChannels -> Request ListChannels
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 ListChannels
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListChannels)))
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 [ChannelSummary] -> Maybe Text -> Int -> ListChannelsResponse
ListChannelsResponse'
            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
"channels" 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 ListChannels where
  hashWithSalt :: Int -> ListChannels -> Int
hashWithSalt Int
_salt ListChannels' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListChannels' :: ListChannels -> Maybe Text
$sel:maxResults:ListChannels' :: ListChannels -> 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 ListChannels where
  rnf :: ListChannels -> ()
rnf ListChannels' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListChannels' :: ListChannels -> Maybe Text
$sel:maxResults:ListChannels' :: ListChannels -> 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 ListChannels where
  toHeaders :: ListChannels -> 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 ListChannels where
  toPath :: ListChannels -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/prod/channels"

instance Data.ToQuery ListChannels where
  toQuery :: ListChannels -> QueryString
toQuery ListChannels' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListChannels' :: ListChannels -> Maybe Text
$sel:maxResults:ListChannels' :: ListChannels -> 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 ListChannelsResponse
--
-- /See:/ 'newListChannelsResponse' smart constructor.
data ListChannelsResponse = ListChannelsResponse'
  { ListChannelsResponse -> Maybe [ChannelSummary]
channels :: Prelude.Maybe [ChannelSummary],
    ListChannelsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListChannelsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListChannelsResponse -> ListChannelsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListChannelsResponse -> ListChannelsResponse -> Bool
$c/= :: ListChannelsResponse -> ListChannelsResponse -> Bool
== :: ListChannelsResponse -> ListChannelsResponse -> Bool
$c== :: ListChannelsResponse -> ListChannelsResponse -> Bool
Prelude.Eq, ReadPrec [ListChannelsResponse]
ReadPrec ListChannelsResponse
Int -> ReadS ListChannelsResponse
ReadS [ListChannelsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListChannelsResponse]
$creadListPrec :: ReadPrec [ListChannelsResponse]
readPrec :: ReadPrec ListChannelsResponse
$creadPrec :: ReadPrec ListChannelsResponse
readList :: ReadS [ListChannelsResponse]
$creadList :: ReadS [ListChannelsResponse]
readsPrec :: Int -> ReadS ListChannelsResponse
$creadsPrec :: Int -> ReadS ListChannelsResponse
Prelude.Read, Int -> ListChannelsResponse -> ShowS
[ListChannelsResponse] -> ShowS
ListChannelsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListChannelsResponse] -> ShowS
$cshowList :: [ListChannelsResponse] -> ShowS
show :: ListChannelsResponse -> String
$cshow :: ListChannelsResponse -> String
showsPrec :: Int -> ListChannelsResponse -> ShowS
$cshowsPrec :: Int -> ListChannelsResponse -> ShowS
Prelude.Show, forall x. Rep ListChannelsResponse x -> ListChannelsResponse
forall x. ListChannelsResponse -> Rep ListChannelsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListChannelsResponse x -> ListChannelsResponse
$cfrom :: forall x. ListChannelsResponse -> Rep ListChannelsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListChannelsResponse' 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:
--
-- 'channels', 'listChannelsResponse_channels' - Undocumented member.
--
-- 'nextToken', 'listChannelsResponse_nextToken' - Undocumented member.
--
-- 'httpStatus', 'listChannelsResponse_httpStatus' - The response's http status code.
newListChannelsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListChannelsResponse
newListChannelsResponse :: Int -> ListChannelsResponse
newListChannelsResponse Int
pHttpStatus_ =
  ListChannelsResponse'
    { $sel:channels:ListChannelsResponse' :: Maybe [ChannelSummary]
channels = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListChannelsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListChannelsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
listChannelsResponse_channels :: Lens.Lens' ListChannelsResponse (Prelude.Maybe [ChannelSummary])
listChannelsResponse_channels :: Lens' ListChannelsResponse (Maybe [ChannelSummary])
listChannelsResponse_channels = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListChannelsResponse' {Maybe [ChannelSummary]
channels :: Maybe [ChannelSummary]
$sel:channels:ListChannelsResponse' :: ListChannelsResponse -> Maybe [ChannelSummary]
channels} -> Maybe [ChannelSummary]
channels) (\s :: ListChannelsResponse
s@ListChannelsResponse' {} Maybe [ChannelSummary]
a -> ListChannelsResponse
s {$sel:channels:ListChannelsResponse' :: Maybe [ChannelSummary]
channels = Maybe [ChannelSummary]
a} :: ListChannelsResponse) 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

-- | Undocumented member.
listChannelsResponse_nextToken :: Lens.Lens' ListChannelsResponse (Prelude.Maybe Prelude.Text)
listChannelsResponse_nextToken :: Lens' ListChannelsResponse (Maybe Text)
listChannelsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListChannelsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListChannelsResponse' :: ListChannelsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListChannelsResponse
s@ListChannelsResponse' {} Maybe Text
a -> ListChannelsResponse
s {$sel:nextToken:ListChannelsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListChannelsResponse)

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

instance Prelude.NFData ListChannelsResponse where
  rnf :: ListChannelsResponse -> ()
rnf ListChannelsResponse' {Int
Maybe [ChannelSummary]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
channels :: Maybe [ChannelSummary]
$sel:httpStatus:ListChannelsResponse' :: ListChannelsResponse -> Int
$sel:nextToken:ListChannelsResponse' :: ListChannelsResponse -> Maybe Text
$sel:channels:ListChannelsResponse' :: ListChannelsResponse -> Maybe [ChannelSummary]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ChannelSummary]
channels
      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