{-# 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.CloudTrail.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) -- -- Lists the channels in the current account, and their source names. -- Amazon Web Services services create service-linked channels get -- information about CloudTrail events on your behalf. For more information -- about service-linked channels, see -- . module Amazonka.CloudTrail.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 Amazonka.CloudTrail.Types import qualified Amazonka.Core as Core import qualified Amazonka.Core.Lens.Internal as Lens import qualified Amazonka.Data as Data 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 CloudTrail channels to display on a single page. maxResults :: Prelude.Maybe Prelude.Natural, -- | The token to use to get the next page of results after a previous API -- call. This token must be passed in with the same parameters that were -- specified in the original call. For example, if the original call -- specified an AttributeKey of \'Username\' with a value of \'root\', the -- call with NextToken should include those same parameters. 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 CloudTrail channels to display on a single page. -- -- 'nextToken', 'listChannels_nextToken' - The token to use to get the next page of results after a previous API -- call. This token must be passed in with the same parameters that were -- specified in the original call. For example, if the original call -- specified an AttributeKey of \'Username\' with a value of \'root\', the -- call with NextToken should include those same parameters. newListChannels :: ListChannels newListChannels = ListChannels' { maxResults = Prelude.Nothing, nextToken = Prelude.Nothing } -- | The maximum number of CloudTrail channels to display on a single page. listChannels_maxResults :: Lens.Lens' ListChannels (Prelude.Maybe Prelude.Natural) listChannels_maxResults = Lens.lens (\ListChannels' {maxResults} -> maxResults) (\s@ListChannels' {} a -> s {maxResults = a} :: ListChannels) -- | The token to use to get the next page of results after a previous API -- call. This token must be passed in with the same parameters that were -- specified in the original call. For example, if the original call -- specified an AttributeKey of \'Username\' with a value of \'root\', the -- call with NextToken should include those same parameters. 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.AWSRequest ListChannels where type AWSResponse ListChannels = ListChannelsResponse request overrides = Request.postJSON (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 [ "X-Amz-Target" Data.=# ( "com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101.ListChannels" :: Prelude.ByteString ), "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToJSON ListChannels where toJSON ListChannels' {..} = Data.object ( Prelude.catMaybes [ ("MaxResults" Data..=) Prelude.<$> maxResults, ("NextToken" Data..=) Prelude.<$> nextToken ] ) instance Data.ToPath ListChannels where toPath = Prelude.const "/" instance Data.ToQuery ListChannels where toQuery = Prelude.const Prelude.mempty -- | /See:/ 'newListChannelsResponse' smart constructor. data ListChannelsResponse = ListChannelsResponse' { -- | The list of channels in the account. channels :: Prelude.Maybe [Channel], -- | The token to use to get the next page of results after a previous API -- call. 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' - The list of channels in the account. -- -- 'nextToken', 'listChannelsResponse_nextToken' - The token to use to get the next page of results after a previous API -- call. -- -- '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_ } -- | The list of channels in the account. 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 -- | The token to use to get the next page of results after a previous API -- call. 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