{-# 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.MediaTailor.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) -- -- Retrieves information about the channels that are associated with the -- current AWS account. -- -- This operation returns paginated results. module Amazonka.MediaTailor.ListChannels ( -- * Creating a Request ListChannels (..), newListChannels, -- * Request Lenses listChannels_maxResults, listChannels_nextToken, -- * Destructuring the Response ListChannelsResponse (..), newListChannelsResponse, -- * Response Lenses listChannelsResponse_items, 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.MediaTailor.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' { -- | The maximum number of channels that you want MediaTailor to return in -- response to the current request. If there are more than @MaxResults@ -- channels, use the value of @NextToken@ in the response to get the next -- page of results. maxResults :: Prelude.Maybe Prelude.Natural, -- | Pagination token returned by the list request when results exceed the -- maximum allowed. Use the token to fetch the next page of results. 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' - The maximum number of channels that you want MediaTailor to return in -- response to the current request. If there are more than @MaxResults@ -- channels, use the value of @NextToken@ in the response to get the next -- page of results. -- -- 'nextToken', 'listChannels_nextToken' - Pagination token returned by the list request when results exceed the -- maximum allowed. Use the token to fetch the next page of results. newListChannels :: ListChannels newListChannels = ListChannels' { maxResults = Prelude.Nothing, nextToken = Prelude.Nothing } -- | The maximum number of channels that you want MediaTailor to return in -- response to the current request. If there are more than @MaxResults@ -- channels, use the value of @NextToken@ in the response to get the next -- page of results. listChannels_maxResults :: Lens.Lens' ListChannels (Prelude.Maybe Prelude.Natural) listChannels_maxResults = Lens.lens (\ListChannels' {maxResults} -> maxResults) (\s@ListChannels' {} a -> s {maxResults = a} :: ListChannels) -- | Pagination token returned by the list request when results exceed the -- maximum allowed. Use the token to fetch the next page of results. 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_items 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..?> "Items" 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 channels that are associated with this account. items :: Prelude.Maybe [Channel], -- | Pagination token returned by the list request when results exceed the -- maximum allowed. Use the token to fetch the next page of results. 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: -- -- 'items', 'listChannelsResponse_items' - A list of channels that are associated with this account. -- -- 'nextToken', 'listChannelsResponse_nextToken' - Pagination token returned by the list request when results exceed the -- maximum allowed. Use the token to fetch the next page of results. -- -- 'httpStatus', 'listChannelsResponse_httpStatus' - The response's http status code. newListChannelsResponse :: -- | 'httpStatus' Prelude.Int -> ListChannelsResponse newListChannelsResponse pHttpStatus_ = ListChannelsResponse' { items = Prelude.Nothing, nextToken = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | A list of channels that are associated with this account. listChannelsResponse_items :: Lens.Lens' ListChannelsResponse (Prelude.Maybe [Channel]) listChannelsResponse_items = Lens.lens (\ListChannelsResponse' {items} -> items) (\s@ListChannelsResponse' {} a -> s {items = a} :: ListChannelsResponse) Prelude.. Lens.mapping Lens.coerced -- | Pagination token returned by the list request when results exceed the -- maximum allowed. Use the token to fetch the next page of results. 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 items `Prelude.seq` Prelude.rnf nextToken `Prelude.seq` Prelude.rnf httpStatus