amazonka-inspector-2.0: gen/Amazonka/Inspector/ListFindings.hs
{-# 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.Inspector.ListFindings
-- 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 findings that are generated by the assessment runs that are
-- specified by the ARNs of the assessment runs.
--
-- This operation returns paginated results.
module Amazonka.Inspector.ListFindings
( -- * Creating a Request
ListFindings (..),
newListFindings,
-- * Request Lenses
listFindings_assessmentRunArns,
listFindings_filter,
listFindings_maxResults,
listFindings_nextToken,
-- * Destructuring the Response
ListFindingsResponse (..),
newListFindingsResponse,
-- * Response Lenses
listFindingsResponse_nextToken,
listFindingsResponse_httpStatus,
listFindingsResponse_findingArns,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Inspector.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
-- | /See:/ 'newListFindings' smart constructor.
data ListFindings = ListFindings'
{ -- | The ARNs of the assessment runs that generate the findings that you want
-- to list.
assessmentRunArns :: Prelude.Maybe [Prelude.Text],
-- | You can use this parameter to specify a subset of data to be included in
-- the action\'s response.
--
-- For a record to match a filter, all specified filter attributes must
-- match. When multiple values are specified for a filter attribute, any of
-- the values can match.
filter' :: Prelude.Maybe FindingFilter,
-- | You can use this parameter to indicate the maximum number of items you
-- want in the response. The default value is 10. The maximum value is 500.
maxResults :: Prelude.Maybe Prelude.Int,
-- | You can use this parameter when paginating results. Set the value of
-- this parameter to null on your first call to the __ListFindings__
-- action. Subsequent calls to the action fill __nextToken__ in the request
-- with the value of __NextToken__ from the previous response to continue
-- listing data.
nextToken :: Prelude.Maybe Prelude.Text
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'ListFindings' 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:
--
-- 'assessmentRunArns', 'listFindings_assessmentRunArns' - The ARNs of the assessment runs that generate the findings that you want
-- to list.
--
-- 'filter'', 'listFindings_filter' - You can use this parameter to specify a subset of data to be included in
-- the action\'s response.
--
-- For a record to match a filter, all specified filter attributes must
-- match. When multiple values are specified for a filter attribute, any of
-- the values can match.
--
-- 'maxResults', 'listFindings_maxResults' - You can use this parameter to indicate the maximum number of items you
-- want in the response. The default value is 10. The maximum value is 500.
--
-- 'nextToken', 'listFindings_nextToken' - You can use this parameter when paginating results. Set the value of
-- this parameter to null on your first call to the __ListFindings__
-- action. Subsequent calls to the action fill __nextToken__ in the request
-- with the value of __NextToken__ from the previous response to continue
-- listing data.
newListFindings ::
ListFindings
newListFindings =
ListFindings'
{ assessmentRunArns = Prelude.Nothing,
filter' = Prelude.Nothing,
maxResults = Prelude.Nothing,
nextToken = Prelude.Nothing
}
-- | The ARNs of the assessment runs that generate the findings that you want
-- to list.
listFindings_assessmentRunArns :: Lens.Lens' ListFindings (Prelude.Maybe [Prelude.Text])
listFindings_assessmentRunArns = Lens.lens (\ListFindings' {assessmentRunArns} -> assessmentRunArns) (\s@ListFindings' {} a -> s {assessmentRunArns = a} :: ListFindings) Prelude.. Lens.mapping Lens.coerced
-- | You can use this parameter to specify a subset of data to be included in
-- the action\'s response.
--
-- For a record to match a filter, all specified filter attributes must
-- match. When multiple values are specified for a filter attribute, any of
-- the values can match.
listFindings_filter :: Lens.Lens' ListFindings (Prelude.Maybe FindingFilter)
listFindings_filter = Lens.lens (\ListFindings' {filter'} -> filter') (\s@ListFindings' {} a -> s {filter' = a} :: ListFindings)
-- | You can use this parameter to indicate the maximum number of items you
-- want in the response. The default value is 10. The maximum value is 500.
listFindings_maxResults :: Lens.Lens' ListFindings (Prelude.Maybe Prelude.Int)
listFindings_maxResults = Lens.lens (\ListFindings' {maxResults} -> maxResults) (\s@ListFindings' {} a -> s {maxResults = a} :: ListFindings)
-- | You can use this parameter when paginating results. Set the value of
-- this parameter to null on your first call to the __ListFindings__
-- action. Subsequent calls to the action fill __nextToken__ in the request
-- with the value of __NextToken__ from the previous response to continue
-- listing data.
listFindings_nextToken :: Lens.Lens' ListFindings (Prelude.Maybe Prelude.Text)
listFindings_nextToken = Lens.lens (\ListFindings' {nextToken} -> nextToken) (\s@ListFindings' {} a -> s {nextToken = a} :: ListFindings)
instance Core.AWSPager ListFindings where
page rq rs
| Core.stop
( rs
Lens.^? listFindingsResponse_nextToken
Prelude.. Lens._Just
) =
Prelude.Nothing
| Core.stop
(rs Lens.^. listFindingsResponse_findingArns) =
Prelude.Nothing
| Prelude.otherwise =
Prelude.Just
Prelude.$ rq
Prelude.& listFindings_nextToken
Lens..~ rs
Lens.^? listFindingsResponse_nextToken
Prelude.. Lens._Just
instance Core.AWSRequest ListFindings where
type AWSResponse ListFindings = ListFindingsResponse
request overrides =
Request.postJSON (overrides defaultService)
response =
Response.receiveJSON
( \s h x ->
ListFindingsResponse'
Prelude.<$> (x Data..?> "nextToken")
Prelude.<*> (Prelude.pure (Prelude.fromEnum s))
Prelude.<*> (x Data..?> "findingArns" Core..!@ Prelude.mempty)
)
instance Prelude.Hashable ListFindings where
hashWithSalt _salt ListFindings' {..} =
_salt
`Prelude.hashWithSalt` assessmentRunArns
`Prelude.hashWithSalt` filter'
`Prelude.hashWithSalt` maxResults
`Prelude.hashWithSalt` nextToken
instance Prelude.NFData ListFindings where
rnf ListFindings' {..} =
Prelude.rnf assessmentRunArns
`Prelude.seq` Prelude.rnf filter'
`Prelude.seq` Prelude.rnf maxResults
`Prelude.seq` Prelude.rnf nextToken
instance Data.ToHeaders ListFindings where
toHeaders =
Prelude.const
( Prelude.mconcat
[ "X-Amz-Target"
Data.=# ( "InspectorService.ListFindings" ::
Prelude.ByteString
),
"Content-Type"
Data.=# ( "application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON ListFindings where
toJSON ListFindings' {..} =
Data.object
( Prelude.catMaybes
[ ("assessmentRunArns" Data..=)
Prelude.<$> assessmentRunArns,
("filter" Data..=) Prelude.<$> filter',
("maxResults" Data..=) Prelude.<$> maxResults,
("nextToken" Data..=) Prelude.<$> nextToken
]
)
instance Data.ToPath ListFindings where
toPath = Prelude.const "/"
instance Data.ToQuery ListFindings where
toQuery = Prelude.const Prelude.mempty
-- | /See:/ 'newListFindingsResponse' smart constructor.
data ListFindingsResponse = ListFindingsResponse'
{ -- | When a response is generated, if there is more data to be listed, this
-- parameter is present in the response and contains the value to use for
-- the __nextToken__ parameter in a subsequent pagination request. If there
-- is no more data to be listed, this parameter is set to null.
nextToken :: Prelude.Maybe Prelude.Text,
-- | The response's http status code.
httpStatus :: Prelude.Int,
-- | A list of ARNs that specifies the findings returned by the action.
findingArns :: [Prelude.Text]
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'ListFindingsResponse' 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:
--
-- 'nextToken', 'listFindingsResponse_nextToken' - When a response is generated, if there is more data to be listed, this
-- parameter is present in the response and contains the value to use for
-- the __nextToken__ parameter in a subsequent pagination request. If there
-- is no more data to be listed, this parameter is set to null.
--
-- 'httpStatus', 'listFindingsResponse_httpStatus' - The response's http status code.
--
-- 'findingArns', 'listFindingsResponse_findingArns' - A list of ARNs that specifies the findings returned by the action.
newListFindingsResponse ::
-- | 'httpStatus'
Prelude.Int ->
ListFindingsResponse
newListFindingsResponse pHttpStatus_ =
ListFindingsResponse'
{ nextToken = Prelude.Nothing,
httpStatus = pHttpStatus_,
findingArns = Prelude.mempty
}
-- | When a response is generated, if there is more data to be listed, this
-- parameter is present in the response and contains the value to use for
-- the __nextToken__ parameter in a subsequent pagination request. If there
-- is no more data to be listed, this parameter is set to null.
listFindingsResponse_nextToken :: Lens.Lens' ListFindingsResponse (Prelude.Maybe Prelude.Text)
listFindingsResponse_nextToken = Lens.lens (\ListFindingsResponse' {nextToken} -> nextToken) (\s@ListFindingsResponse' {} a -> s {nextToken = a} :: ListFindingsResponse)
-- | The response's http status code.
listFindingsResponse_httpStatus :: Lens.Lens' ListFindingsResponse Prelude.Int
listFindingsResponse_httpStatus = Lens.lens (\ListFindingsResponse' {httpStatus} -> httpStatus) (\s@ListFindingsResponse' {} a -> s {httpStatus = a} :: ListFindingsResponse)
-- | A list of ARNs that specifies the findings returned by the action.
listFindingsResponse_findingArns :: Lens.Lens' ListFindingsResponse [Prelude.Text]
listFindingsResponse_findingArns = Lens.lens (\ListFindingsResponse' {findingArns} -> findingArns) (\s@ListFindingsResponse' {} a -> s {findingArns = a} :: ListFindingsResponse) Prelude.. Lens.coerced
instance Prelude.NFData ListFindingsResponse where
rnf ListFindingsResponse' {..} =
Prelude.rnf nextToken
`Prelude.seq` Prelude.rnf httpStatus
`Prelude.seq` Prelude.rnf findingArns