{-# 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.GuardDuty.ListFindings
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists Amazon GuardDuty findings for the specified detector ID.
--
-- This operation returns paginated results.
module Amazonka.GuardDuty.ListFindings
  ( -- * Creating a Request
    ListFindings (..),
    newListFindings,

    -- * Request Lenses
    listFindings_findingCriteria,
    listFindings_sortCriteria,
    listFindings_nextToken,
    listFindings_maxResults,
    listFindings_detectorId,

    -- * Destructuring the Response
    ListFindingsResponse (..),
    newListFindingsResponse,

    -- * Response Lenses
    listFindingsResponse_nextToken,
    listFindingsResponse_httpStatus,
    listFindingsResponse_findingIds,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.GuardDuty.Types
import qualified Amazonka.Lens as Lens
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'
  { -- | Represents the criteria used for querying findings. Valid values
    -- include:
    --
    -- -   JSON field name
    --
    -- -   accountId
    --
    -- -   region
    --
    -- -   confidence
    --
    -- -   id
    --
    -- -   resource.accessKeyDetails.accessKeyId
    --
    -- -   resource.accessKeyDetails.principalId
    --
    -- -   resource.accessKeyDetails.userName
    --
    -- -   resource.accessKeyDetails.userType
    --
    -- -   resource.instanceDetails.iamInstanceProfile.id
    --
    -- -   resource.instanceDetails.imageId
    --
    -- -   resource.instanceDetails.instanceId
    --
    -- -   resource.instanceDetails.networkInterfaces.ipv6Addresses
    --
    -- -   resource.instanceDetails.networkInterfaces.privateIpAddresses.privateIpAddress
    --
    -- -   resource.instanceDetails.networkInterfaces.publicDnsName
    --
    -- -   resource.instanceDetails.networkInterfaces.publicIp
    --
    -- -   resource.instanceDetails.networkInterfaces.securityGroups.groupId
    --
    -- -   resource.instanceDetails.networkInterfaces.securityGroups.groupName
    --
    -- -   resource.instanceDetails.networkInterfaces.subnetId
    --
    -- -   resource.instanceDetails.networkInterfaces.vpcId
    --
    -- -   resource.instanceDetails.tags.key
    --
    -- -   resource.instanceDetails.tags.value
    --
    -- -   resource.resourceType
    --
    -- -   service.action.actionType
    --
    -- -   service.action.awsApiCallAction.api
    --
    -- -   service.action.awsApiCallAction.callerType
    --
    -- -   service.action.awsApiCallAction.remoteIpDetails.city.cityName
    --
    -- -   service.action.awsApiCallAction.remoteIpDetails.country.countryName
    --
    -- -   service.action.awsApiCallAction.remoteIpDetails.ipAddressV4
    --
    -- -   service.action.awsApiCallAction.remoteIpDetails.organization.asn
    --
    -- -   service.action.awsApiCallAction.remoteIpDetails.organization.asnOrg
    --
    -- -   service.action.awsApiCallAction.serviceName
    --
    -- -   service.action.dnsRequestAction.domain
    --
    -- -   service.action.networkConnectionAction.blocked
    --
    -- -   service.action.networkConnectionAction.connectionDirection
    --
    -- -   service.action.networkConnectionAction.localPortDetails.port
    --
    -- -   service.action.networkConnectionAction.protocol
    --
    -- -   service.action.networkConnectionAction.remoteIpDetails.city.cityName
    --
    -- -   service.action.networkConnectionAction.remoteIpDetails.country.countryName
    --
    -- -   service.action.networkConnectionAction.remoteIpDetails.ipAddressV4
    --
    -- -   service.action.networkConnectionAction.remoteIpDetails.organization.asn
    --
    -- -   service.action.networkConnectionAction.remoteIpDetails.organization.asnOrg
    --
    -- -   service.action.networkConnectionAction.remotePortDetails.port
    --
    -- -   service.additionalInfo.threatListName
    --
    -- -   service.archived
    --
    --     When this attribute is set to \'true\', only archived findings are
    --     listed. When it\'s set to \'false\', only unarchived findings are
    --     listed. When this attribute is not set, all existing findings are
    --     listed.
    --
    -- -   service.resourceRole
    --
    -- -   severity
    --
    -- -   type
    --
    -- -   updatedAt
    --
    --     Type: Timestamp in Unix Epoch millisecond format: 1486685375000
    ListFindings -> Maybe FindingCriteria
findingCriteria :: Prelude.Maybe FindingCriteria,
    -- | Represents the criteria used for sorting findings.
    ListFindings -> Maybe SortCriteria
sortCriteria :: Prelude.Maybe SortCriteria,
    -- | You can use this parameter when paginating results. Set the value of
    -- this parameter to null on your first call to the list action. For
    -- subsequent calls to the action, fill nextToken in the request with the
    -- value of NextToken from the previous response to continue listing data.
    ListFindings -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | You can use this parameter to indicate the maximum number of items you
    -- want in the response. The default value is 50. The maximum value is 50.
    ListFindings -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The ID of the detector that specifies the GuardDuty service whose
    -- findings you want to list.
    ListFindings -> Text
detectorId :: Prelude.Text
  }
  deriving (ListFindings -> ListFindings -> Bool
(ListFindings -> ListFindings -> Bool)
-> (ListFindings -> ListFindings -> Bool) -> Eq ListFindings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListFindings -> ListFindings -> Bool
$c/= :: ListFindings -> ListFindings -> Bool
== :: ListFindings -> ListFindings -> Bool
$c== :: ListFindings -> ListFindings -> Bool
Prelude.Eq, ReadPrec [ListFindings]
ReadPrec ListFindings
Int -> ReadS ListFindings
ReadS [ListFindings]
(Int -> ReadS ListFindings)
-> ReadS [ListFindings]
-> ReadPrec ListFindings
-> ReadPrec [ListFindings]
-> Read ListFindings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListFindings]
$creadListPrec :: ReadPrec [ListFindings]
readPrec :: ReadPrec ListFindings
$creadPrec :: ReadPrec ListFindings
readList :: ReadS [ListFindings]
$creadList :: ReadS [ListFindings]
readsPrec :: Int -> ReadS ListFindings
$creadsPrec :: Int -> ReadS ListFindings
Prelude.Read, Int -> ListFindings -> ShowS
[ListFindings] -> ShowS
ListFindings -> String
(Int -> ListFindings -> ShowS)
-> (ListFindings -> String)
-> ([ListFindings] -> ShowS)
-> Show ListFindings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListFindings] -> ShowS
$cshowList :: [ListFindings] -> ShowS
show :: ListFindings -> String
$cshow :: ListFindings -> String
showsPrec :: Int -> ListFindings -> ShowS
$cshowsPrec :: Int -> ListFindings -> ShowS
Prelude.Show, (forall x. ListFindings -> Rep ListFindings x)
-> (forall x. Rep ListFindings x -> ListFindings)
-> Generic ListFindings
forall x. Rep ListFindings x -> ListFindings
forall x. ListFindings -> Rep ListFindings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListFindings x -> ListFindings
$cfrom :: forall x. ListFindings -> Rep ListFindings x
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:
--
-- 'findingCriteria', 'listFindings_findingCriteria' - Represents the criteria used for querying findings. Valid values
-- include:
--
-- -   JSON field name
--
-- -   accountId
--
-- -   region
--
-- -   confidence
--
-- -   id
--
-- -   resource.accessKeyDetails.accessKeyId
--
-- -   resource.accessKeyDetails.principalId
--
-- -   resource.accessKeyDetails.userName
--
-- -   resource.accessKeyDetails.userType
--
-- -   resource.instanceDetails.iamInstanceProfile.id
--
-- -   resource.instanceDetails.imageId
--
-- -   resource.instanceDetails.instanceId
--
-- -   resource.instanceDetails.networkInterfaces.ipv6Addresses
--
-- -   resource.instanceDetails.networkInterfaces.privateIpAddresses.privateIpAddress
--
-- -   resource.instanceDetails.networkInterfaces.publicDnsName
--
-- -   resource.instanceDetails.networkInterfaces.publicIp
--
-- -   resource.instanceDetails.networkInterfaces.securityGroups.groupId
--
-- -   resource.instanceDetails.networkInterfaces.securityGroups.groupName
--
-- -   resource.instanceDetails.networkInterfaces.subnetId
--
-- -   resource.instanceDetails.networkInterfaces.vpcId
--
-- -   resource.instanceDetails.tags.key
--
-- -   resource.instanceDetails.tags.value
--
-- -   resource.resourceType
--
-- -   service.action.actionType
--
-- -   service.action.awsApiCallAction.api
--
-- -   service.action.awsApiCallAction.callerType
--
-- -   service.action.awsApiCallAction.remoteIpDetails.city.cityName
--
-- -   service.action.awsApiCallAction.remoteIpDetails.country.countryName
--
-- -   service.action.awsApiCallAction.remoteIpDetails.ipAddressV4
--
-- -   service.action.awsApiCallAction.remoteIpDetails.organization.asn
--
-- -   service.action.awsApiCallAction.remoteIpDetails.organization.asnOrg
--
-- -   service.action.awsApiCallAction.serviceName
--
-- -   service.action.dnsRequestAction.domain
--
-- -   service.action.networkConnectionAction.blocked
--
-- -   service.action.networkConnectionAction.connectionDirection
--
-- -   service.action.networkConnectionAction.localPortDetails.port
--
-- -   service.action.networkConnectionAction.protocol
--
-- -   service.action.networkConnectionAction.remoteIpDetails.city.cityName
--
-- -   service.action.networkConnectionAction.remoteIpDetails.country.countryName
--
-- -   service.action.networkConnectionAction.remoteIpDetails.ipAddressV4
--
-- -   service.action.networkConnectionAction.remoteIpDetails.organization.asn
--
-- -   service.action.networkConnectionAction.remoteIpDetails.organization.asnOrg
--
-- -   service.action.networkConnectionAction.remotePortDetails.port
--
-- -   service.additionalInfo.threatListName
--
-- -   service.archived
--
--     When this attribute is set to \'true\', only archived findings are
--     listed. When it\'s set to \'false\', only unarchived findings are
--     listed. When this attribute is not set, all existing findings are
--     listed.
--
-- -   service.resourceRole
--
-- -   severity
--
-- -   type
--
-- -   updatedAt
--
--     Type: Timestamp in Unix Epoch millisecond format: 1486685375000
--
-- 'sortCriteria', 'listFindings_sortCriteria' - Represents the criteria used for sorting findings.
--
-- '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 list action. For
-- subsequent calls to the action, fill nextToken in the request with the
-- value of NextToken from the previous response to continue listing data.
--
-- 'maxResults', 'listFindings_maxResults' - You can use this parameter to indicate the maximum number of items you
-- want in the response. The default value is 50. The maximum value is 50.
--
-- 'detectorId', 'listFindings_detectorId' - The ID of the detector that specifies the GuardDuty service whose
-- findings you want to list.
newListFindings ::
  -- | 'detectorId'
  Prelude.Text ->
  ListFindings
newListFindings :: Text -> ListFindings
newListFindings Text
pDetectorId_ =
  ListFindings' :: Maybe FindingCriteria
-> Maybe SortCriteria
-> Maybe Text
-> Maybe Natural
-> Text
-> ListFindings
ListFindings'
    { $sel:findingCriteria:ListFindings' :: Maybe FindingCriteria
findingCriteria = Maybe FindingCriteria
forall a. Maybe a
Prelude.Nothing,
      $sel:sortCriteria:ListFindings' :: Maybe SortCriteria
sortCriteria = Maybe SortCriteria
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListFindings' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListFindings' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:detectorId:ListFindings' :: Text
detectorId = Text
pDetectorId_
    }

-- | Represents the criteria used for querying findings. Valid values
-- include:
--
-- -   JSON field name
--
-- -   accountId
--
-- -   region
--
-- -   confidence
--
-- -   id
--
-- -   resource.accessKeyDetails.accessKeyId
--
-- -   resource.accessKeyDetails.principalId
--
-- -   resource.accessKeyDetails.userName
--
-- -   resource.accessKeyDetails.userType
--
-- -   resource.instanceDetails.iamInstanceProfile.id
--
-- -   resource.instanceDetails.imageId
--
-- -   resource.instanceDetails.instanceId
--
-- -   resource.instanceDetails.networkInterfaces.ipv6Addresses
--
-- -   resource.instanceDetails.networkInterfaces.privateIpAddresses.privateIpAddress
--
-- -   resource.instanceDetails.networkInterfaces.publicDnsName
--
-- -   resource.instanceDetails.networkInterfaces.publicIp
--
-- -   resource.instanceDetails.networkInterfaces.securityGroups.groupId
--
-- -   resource.instanceDetails.networkInterfaces.securityGroups.groupName
--
-- -   resource.instanceDetails.networkInterfaces.subnetId
--
-- -   resource.instanceDetails.networkInterfaces.vpcId
--
-- -   resource.instanceDetails.tags.key
--
-- -   resource.instanceDetails.tags.value
--
-- -   resource.resourceType
--
-- -   service.action.actionType
--
-- -   service.action.awsApiCallAction.api
--
-- -   service.action.awsApiCallAction.callerType
--
-- -   service.action.awsApiCallAction.remoteIpDetails.city.cityName
--
-- -   service.action.awsApiCallAction.remoteIpDetails.country.countryName
--
-- -   service.action.awsApiCallAction.remoteIpDetails.ipAddressV4
--
-- -   service.action.awsApiCallAction.remoteIpDetails.organization.asn
--
-- -   service.action.awsApiCallAction.remoteIpDetails.organization.asnOrg
--
-- -   service.action.awsApiCallAction.serviceName
--
-- -   service.action.dnsRequestAction.domain
--
-- -   service.action.networkConnectionAction.blocked
--
-- -   service.action.networkConnectionAction.connectionDirection
--
-- -   service.action.networkConnectionAction.localPortDetails.port
--
-- -   service.action.networkConnectionAction.protocol
--
-- -   service.action.networkConnectionAction.remoteIpDetails.city.cityName
--
-- -   service.action.networkConnectionAction.remoteIpDetails.country.countryName
--
-- -   service.action.networkConnectionAction.remoteIpDetails.ipAddressV4
--
-- -   service.action.networkConnectionAction.remoteIpDetails.organization.asn
--
-- -   service.action.networkConnectionAction.remoteIpDetails.organization.asnOrg
--
-- -   service.action.networkConnectionAction.remotePortDetails.port
--
-- -   service.additionalInfo.threatListName
--
-- -   service.archived
--
--     When this attribute is set to \'true\', only archived findings are
--     listed. When it\'s set to \'false\', only unarchived findings are
--     listed. When this attribute is not set, all existing findings are
--     listed.
--
-- -   service.resourceRole
--
-- -   severity
--
-- -   type
--
-- -   updatedAt
--
--     Type: Timestamp in Unix Epoch millisecond format: 1486685375000
listFindings_findingCriteria :: Lens.Lens' ListFindings (Prelude.Maybe FindingCriteria)
listFindings_findingCriteria :: (Maybe FindingCriteria -> f (Maybe FindingCriteria))
-> ListFindings -> f ListFindings
listFindings_findingCriteria = (ListFindings -> Maybe FindingCriteria)
-> (ListFindings -> Maybe FindingCriteria -> ListFindings)
-> Lens
     ListFindings
     ListFindings
     (Maybe FindingCriteria)
     (Maybe FindingCriteria)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFindings' {Maybe FindingCriteria
findingCriteria :: Maybe FindingCriteria
$sel:findingCriteria:ListFindings' :: ListFindings -> Maybe FindingCriteria
findingCriteria} -> Maybe FindingCriteria
findingCriteria) (\s :: ListFindings
s@ListFindings' {} Maybe FindingCriteria
a -> ListFindings
s {$sel:findingCriteria:ListFindings' :: Maybe FindingCriteria
findingCriteria = Maybe FindingCriteria
a} :: ListFindings)

-- | Represents the criteria used for sorting findings.
listFindings_sortCriteria :: Lens.Lens' ListFindings (Prelude.Maybe SortCriteria)
listFindings_sortCriteria :: (Maybe SortCriteria -> f (Maybe SortCriteria))
-> ListFindings -> f ListFindings
listFindings_sortCriteria = (ListFindings -> Maybe SortCriteria)
-> (ListFindings -> Maybe SortCriteria -> ListFindings)
-> Lens
     ListFindings ListFindings (Maybe SortCriteria) (Maybe SortCriteria)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFindings' {Maybe SortCriteria
sortCriteria :: Maybe SortCriteria
$sel:sortCriteria:ListFindings' :: ListFindings -> Maybe SortCriteria
sortCriteria} -> Maybe SortCriteria
sortCriteria) (\s :: ListFindings
s@ListFindings' {} Maybe SortCriteria
a -> ListFindings
s {$sel:sortCriteria:ListFindings' :: Maybe SortCriteria
sortCriteria = Maybe SortCriteria
a} :: ListFindings)

-- | You can use this parameter when paginating results. Set the value of
-- this parameter to null on your first call to the list action. For
-- 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 :: (Maybe Text -> f (Maybe Text)) -> ListFindings -> f ListFindings
listFindings_nextToken = (ListFindings -> Maybe Text)
-> (ListFindings -> Maybe Text -> ListFindings)
-> Lens ListFindings ListFindings (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFindings' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListFindings' :: ListFindings -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListFindings
s@ListFindings' {} Maybe Text
a -> ListFindings
s {$sel:nextToken:ListFindings' :: Maybe Text
nextToken = Maybe Text
a} :: ListFindings)

-- | You can use this parameter to indicate the maximum number of items you
-- want in the response. The default value is 50. The maximum value is 50.
listFindings_maxResults :: Lens.Lens' ListFindings (Prelude.Maybe Prelude.Natural)
listFindings_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> ListFindings -> f ListFindings
listFindings_maxResults = (ListFindings -> Maybe Natural)
-> (ListFindings -> Maybe Natural -> ListFindings)
-> Lens ListFindings ListFindings (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFindings' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListFindings' :: ListFindings -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListFindings
s@ListFindings' {} Maybe Natural
a -> ListFindings
s {$sel:maxResults:ListFindings' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListFindings)

-- | The ID of the detector that specifies the GuardDuty service whose
-- findings you want to list.
listFindings_detectorId :: Lens.Lens' ListFindings Prelude.Text
listFindings_detectorId :: (Text -> f Text) -> ListFindings -> f ListFindings
listFindings_detectorId = (ListFindings -> Text)
-> (ListFindings -> Text -> ListFindings)
-> Lens ListFindings ListFindings Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFindings' {Text
detectorId :: Text
$sel:detectorId:ListFindings' :: ListFindings -> Text
detectorId} -> Text
detectorId) (\s :: ListFindings
s@ListFindings' {} Text
a -> ListFindings
s {$sel:detectorId:ListFindings' :: Text
detectorId = Text
a} :: ListFindings)

instance Core.AWSPager ListFindings where
  page :: ListFindings -> AWSResponse ListFindings -> Maybe ListFindings
page ListFindings
rq AWSResponse ListFindings
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListFindings
ListFindingsResponse
rs
            ListFindingsResponse
-> Getting (First Text) ListFindingsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListFindingsResponse -> Const (First Text) ListFindingsResponse
Lens' ListFindingsResponse (Maybe Text)
listFindingsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListFindingsResponse -> Const (First Text) ListFindingsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListFindingsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListFindings
forall a. Maybe a
Prelude.Nothing
    | [Text] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        (AWSResponse ListFindings
ListFindingsResponse
rs ListFindingsResponse
-> Getting [Text] ListFindingsResponse [Text] -> [Text]
forall s a. s -> Getting a s a -> a
Lens.^. Getting [Text] ListFindingsResponse [Text]
Lens' ListFindingsResponse [Text]
listFindingsResponse_findingIds) =
      Maybe ListFindings
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListFindings -> Maybe ListFindings
forall a. a -> Maybe a
Prelude.Just (ListFindings -> Maybe ListFindings)
-> ListFindings -> Maybe ListFindings
forall a b. (a -> b) -> a -> b
Prelude.$
        ListFindings
rq
          ListFindings -> (ListFindings -> ListFindings) -> ListFindings
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListFindings -> Identity ListFindings
Lens ListFindings ListFindings (Maybe Text) (Maybe Text)
listFindings_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListFindings -> Identity ListFindings)
-> Maybe Text -> ListFindings -> ListFindings
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListFindings
ListFindingsResponse
rs
          ListFindingsResponse
-> Getting (First Text) ListFindingsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListFindingsResponse -> Const (First Text) ListFindingsResponse
Lens' ListFindingsResponse (Maybe Text)
listFindingsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListFindingsResponse -> Const (First Text) ListFindingsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListFindingsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListFindings where
  type AWSResponse ListFindings = ListFindingsResponse
  request :: ListFindings -> Request ListFindings
request = Service -> ListFindings -> Request ListFindings
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListFindings
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListFindings)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListFindings))
-> Logger
-> Service
-> Proxy ListFindings
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListFindings)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Int -> [Text] -> ListFindingsResponse
ListFindingsResponse'
            (Maybe Text -> Int -> [Text] -> ListFindingsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> [Text] -> ListFindingsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"nextToken")
            Either String (Int -> [Text] -> ListFindingsResponse)
-> Either String Int
-> Either String ([Text] -> ListFindingsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either String ([Text] -> ListFindingsResponse)
-> Either String [Text] -> Either String ListFindingsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe [Text])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"findingIds" Either String (Maybe [Text]) -> [Text] -> Either String [Text]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Text]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ListFindings

instance Prelude.NFData ListFindings

instance Core.ToHeaders ListFindings where
  toHeaders :: ListFindings -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListFindings -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON ListFindings where
  toJSON :: ListFindings -> Value
toJSON ListFindings' {Maybe Natural
Maybe Text
Maybe FindingCriteria
Maybe SortCriteria
Text
detectorId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
sortCriteria :: Maybe SortCriteria
findingCriteria :: Maybe FindingCriteria
$sel:detectorId:ListFindings' :: ListFindings -> Text
$sel:maxResults:ListFindings' :: ListFindings -> Maybe Natural
$sel:nextToken:ListFindings' :: ListFindings -> Maybe Text
$sel:sortCriteria:ListFindings' :: ListFindings -> Maybe SortCriteria
$sel:findingCriteria:ListFindings' :: ListFindings -> Maybe FindingCriteria
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"findingCriteria" Text -> FindingCriteria -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (FindingCriteria -> Pair) -> Maybe FindingCriteria -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FindingCriteria
findingCriteria,
            (Text
"sortCriteria" Text -> SortCriteria -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SortCriteria -> Pair) -> Maybe SortCriteria -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SortCriteria
sortCriteria,
            (Text
"nextToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
            (Text
"maxResults" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults
          ]
      )

instance Core.ToPath ListFindings where
  toPath :: ListFindings -> ByteString
toPath ListFindings' {Maybe Natural
Maybe Text
Maybe FindingCriteria
Maybe SortCriteria
Text
detectorId :: Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
sortCriteria :: Maybe SortCriteria
findingCriteria :: Maybe FindingCriteria
$sel:detectorId:ListFindings' :: ListFindings -> Text
$sel:maxResults:ListFindings' :: ListFindings -> Maybe Natural
$sel:nextToken:ListFindings' :: ListFindings -> Maybe Text
$sel:sortCriteria:ListFindings' :: ListFindings -> Maybe SortCriteria
$sel:findingCriteria:ListFindings' :: ListFindings -> Maybe FindingCriteria
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/detector/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
detectorId, ByteString
"/findings"]

instance Core.ToQuery ListFindings where
  toQuery :: ListFindings -> QueryString
toQuery = QueryString -> ListFindings -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newListFindingsResponse' smart constructor.
data ListFindingsResponse = ListFindingsResponse'
  { -- | The pagination parameter to be used on the next list operation to
    -- retrieve more items.
    ListFindingsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListFindingsResponse -> Int
httpStatus :: Prelude.Int,
    -- | The IDs of the findings that you\'re listing.
    ListFindingsResponse -> [Text]
findingIds :: [Prelude.Text]
  }
  deriving (ListFindingsResponse -> ListFindingsResponse -> Bool
(ListFindingsResponse -> ListFindingsResponse -> Bool)
-> (ListFindingsResponse -> ListFindingsResponse -> Bool)
-> Eq ListFindingsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListFindingsResponse -> ListFindingsResponse -> Bool
$c/= :: ListFindingsResponse -> ListFindingsResponse -> Bool
== :: ListFindingsResponse -> ListFindingsResponse -> Bool
$c== :: ListFindingsResponse -> ListFindingsResponse -> Bool
Prelude.Eq, ReadPrec [ListFindingsResponse]
ReadPrec ListFindingsResponse
Int -> ReadS ListFindingsResponse
ReadS [ListFindingsResponse]
(Int -> ReadS ListFindingsResponse)
-> ReadS [ListFindingsResponse]
-> ReadPrec ListFindingsResponse
-> ReadPrec [ListFindingsResponse]
-> Read ListFindingsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListFindingsResponse]
$creadListPrec :: ReadPrec [ListFindingsResponse]
readPrec :: ReadPrec ListFindingsResponse
$creadPrec :: ReadPrec ListFindingsResponse
readList :: ReadS [ListFindingsResponse]
$creadList :: ReadS [ListFindingsResponse]
readsPrec :: Int -> ReadS ListFindingsResponse
$creadsPrec :: Int -> ReadS ListFindingsResponse
Prelude.Read, Int -> ListFindingsResponse -> ShowS
[ListFindingsResponse] -> ShowS
ListFindingsResponse -> String
(Int -> ListFindingsResponse -> ShowS)
-> (ListFindingsResponse -> String)
-> ([ListFindingsResponse] -> ShowS)
-> Show ListFindingsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListFindingsResponse] -> ShowS
$cshowList :: [ListFindingsResponse] -> ShowS
show :: ListFindingsResponse -> String
$cshow :: ListFindingsResponse -> String
showsPrec :: Int -> ListFindingsResponse -> ShowS
$cshowsPrec :: Int -> ListFindingsResponse -> ShowS
Prelude.Show, (forall x. ListFindingsResponse -> Rep ListFindingsResponse x)
-> (forall x. Rep ListFindingsResponse x -> ListFindingsResponse)
-> Generic ListFindingsResponse
forall x. Rep ListFindingsResponse x -> ListFindingsResponse
forall x. ListFindingsResponse -> Rep ListFindingsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListFindingsResponse x -> ListFindingsResponse
$cfrom :: forall x. ListFindingsResponse -> Rep ListFindingsResponse x
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' - The pagination parameter to be used on the next list operation to
-- retrieve more items.
--
-- 'httpStatus', 'listFindingsResponse_httpStatus' - The response's http status code.
--
-- 'findingIds', 'listFindingsResponse_findingIds' - The IDs of the findings that you\'re listing.
newListFindingsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListFindingsResponse
newListFindingsResponse :: Int -> ListFindingsResponse
newListFindingsResponse Int
pHttpStatus_ =
  ListFindingsResponse' :: Maybe Text -> Int -> [Text] -> ListFindingsResponse
ListFindingsResponse'
    { $sel:nextToken:ListFindingsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListFindingsResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:findingIds:ListFindingsResponse' :: [Text]
findingIds = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The pagination parameter to be used on the next list operation to
-- retrieve more items.
listFindingsResponse_nextToken :: Lens.Lens' ListFindingsResponse (Prelude.Maybe Prelude.Text)
listFindingsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListFindingsResponse -> f ListFindingsResponse
listFindingsResponse_nextToken = (ListFindingsResponse -> Maybe Text)
-> (ListFindingsResponse -> Maybe Text -> ListFindingsResponse)
-> Lens' ListFindingsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFindingsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListFindingsResponse' :: ListFindingsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListFindingsResponse
s@ListFindingsResponse' {} Maybe Text
a -> ListFindingsResponse
s {$sel:nextToken:ListFindingsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListFindingsResponse)

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

-- | The IDs of the findings that you\'re listing.
listFindingsResponse_findingIds :: Lens.Lens' ListFindingsResponse [Prelude.Text]
listFindingsResponse_findingIds :: ([Text] -> f [Text])
-> ListFindingsResponse -> f ListFindingsResponse
listFindingsResponse_findingIds = (ListFindingsResponse -> [Text])
-> (ListFindingsResponse -> [Text] -> ListFindingsResponse)
-> Lens' ListFindingsResponse [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListFindingsResponse' {[Text]
findingIds :: [Text]
$sel:findingIds:ListFindingsResponse' :: ListFindingsResponse -> [Text]
findingIds} -> [Text]
findingIds) (\s :: ListFindingsResponse
s@ListFindingsResponse' {} [Text]
a -> ListFindingsResponse
s {$sel:findingIds:ListFindingsResponse' :: [Text]
findingIds = [Text]
a} :: ListFindingsResponse) (([Text] -> f [Text])
 -> ListFindingsResponse -> f ListFindingsResponse)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> ListFindingsResponse
-> f ListFindingsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData ListFindingsResponse