{-# 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.MediaPackage.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) -- -- Returns a collection of Channels. -- -- This operation returns paginated results. module Amazonka.MediaPackage.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.MediaPackage.Types import qualified Amazonka.Prelude as Prelude import qualified Amazonka.Request as Request import qualified Amazonka.Response as Response -- | /See:/ 'newListChannels' smart constructor. data ListChannels = ListChannels' { -- | Upper bound on number of records to return. maxResults :: Prelude.Maybe Prelude.Natural, -- | A token used to resume pagination from the end of a previous request. nextToken :: Prelude.Maybe Prelude.Text } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListChannels' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'maxResults', 'listChannels_maxResults' - Upper bound on number of records to return. -- -- 'nextToken', 'listChannels_nextToken' - A token used to resume pagination from the end of a previous request. newListChannels :: ListChannels newListChannels = ListChannels' { maxResults = Prelude.Nothing, nextToken = Prelude.Nothing } -- | Upper bound on number of records to return. listChannels_maxResults :: Lens.Lens' ListChannels (Prelude.Maybe Prelude.Natural) listChannels_maxResults = Lens.lens (\ListChannels' {maxResults} -> maxResults) (\s@ListChannels' {} a -> s {maxResults = a} :: ListChannels) -- | A token used to resume pagination from the end of a previous request. listChannels_nextToken :: Lens.Lens' ListChannels (Prelude.Maybe Prelude.Text) listChannels_nextToken = Lens.lens (\ListChannels' {nextToken} -> nextToken) (\s@ListChannels' {} a -> s {nextToken = a} :: ListChannels) instance Core.AWSPager ListChannels where page rq rs | Core.stop ( rs Lens.^? listChannelsResponse_nextToken Prelude.. Lens._Just ) = Prelude.Nothing | Core.stop ( rs Lens.^? listChannelsResponse_channels Prelude.. Lens._Just ) = Prelude.Nothing | Prelude.otherwise = Prelude.Just Prelude.$ rq Prelude.& listChannels_nextToken Lens..~ rs Lens.^? listChannelsResponse_nextToken Prelude.. Lens._Just instance Core.AWSRequest ListChannels where type AWSResponse ListChannels = ListChannelsResponse request overrides = Request.get (overrides defaultService) response = Response.receiveJSON ( \s h x -> ListChannelsResponse' Prelude.<$> (x Data..?> "channels" Core..!@ Prelude.mempty) Prelude.<*> (x Data..?> "nextToken") Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable ListChannels where hashWithSalt _salt ListChannels' {..} = _salt `Prelude.hashWithSalt` maxResults `Prelude.hashWithSalt` nextToken instance Prelude.NFData ListChannels where rnf ListChannels' {..} = Prelude.rnf maxResults `Prelude.seq` Prelude.rnf nextToken instance Data.ToHeaders ListChannels where toHeaders = Prelude.const ( Prelude.mconcat [ "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToPath ListChannels where toPath = Prelude.const "/channels" instance Data.ToQuery ListChannels where toQuery ListChannels' {..} = Prelude.mconcat [ "maxResults" Data.=: maxResults, "nextToken" Data.=: nextToken ] -- | /See:/ 'newListChannelsResponse' smart constructor. data ListChannelsResponse = ListChannelsResponse' { -- | A list of Channel records. channels :: Prelude.Maybe [Channel], -- | A token that can be used to resume pagination from the end of the -- collection. nextToken :: Prelude.Maybe Prelude.Text, -- | The response's http status code. httpStatus :: Prelude.Int } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListChannelsResponse' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'channels', 'listChannelsResponse_channels' - A list of Channel records. -- -- 'nextToken', 'listChannelsResponse_nextToken' - A token that can be used to resume pagination from the end of the -- collection. -- -- 'httpStatus', 'listChannelsResponse_httpStatus' - The response's http status code. newListChannelsResponse :: -- | 'httpStatus' Prelude.Int -> ListChannelsResponse newListChannelsResponse pHttpStatus_ = ListChannelsResponse' { channels = Prelude.Nothing, nextToken = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | A list of Channel records. listChannelsResponse_channels :: Lens.Lens' ListChannelsResponse (Prelude.Maybe [Channel]) listChannelsResponse_channels = Lens.lens (\ListChannelsResponse' {channels} -> channels) (\s@ListChannelsResponse' {} a -> s {channels = a} :: ListChannelsResponse) Prelude.. Lens.mapping Lens.coerced -- | A token that can be used to resume pagination from the end of the -- collection. listChannelsResponse_nextToken :: Lens.Lens' ListChannelsResponse (Prelude.Maybe Prelude.Text) listChannelsResponse_nextToken = Lens.lens (\ListChannelsResponse' {nextToken} -> nextToken) (\s@ListChannelsResponse' {} a -> s {nextToken = a} :: ListChannelsResponse) -- | The response's http status code. listChannelsResponse_httpStatus :: Lens.Lens' ListChannelsResponse Prelude.Int listChannelsResponse_httpStatus = Lens.lens (\ListChannelsResponse' {httpStatus} -> httpStatus) (\s@ListChannelsResponse' {} a -> s {httpStatus = a} :: ListChannelsResponse) instance Prelude.NFData ListChannelsResponse where rnf ListChannelsResponse' {..} = Prelude.rnf channels `Prelude.seq` Prelude.rnf nextToken `Prelude.seq` Prelude.rnf httpStatus