{-# 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 #-}
module Amazonka.MacieV2.GetFindings
(
GetFindings (..),
newGetFindings,
getFindings_sortCriteria,
getFindings_findingIds,
GetFindingsResponse (..),
newGetFindingsResponse,
getFindingsResponse_findings,
getFindingsResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MacieV2.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data GetFindings = GetFindings'
{
GetFindings -> Maybe SortCriteria
sortCriteria :: Prelude.Maybe SortCriteria,
GetFindings -> [Text]
findingIds :: [Prelude.Text]
}
deriving (GetFindings -> GetFindings -> Bool
(GetFindings -> GetFindings -> Bool)
-> (GetFindings -> GetFindings -> Bool) -> Eq GetFindings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetFindings -> GetFindings -> Bool
$c/= :: GetFindings -> GetFindings -> Bool
== :: GetFindings -> GetFindings -> Bool
$c== :: GetFindings -> GetFindings -> Bool
Prelude.Eq, ReadPrec [GetFindings]
ReadPrec GetFindings
Int -> ReadS GetFindings
ReadS [GetFindings]
(Int -> ReadS GetFindings)
-> ReadS [GetFindings]
-> ReadPrec GetFindings
-> ReadPrec [GetFindings]
-> Read GetFindings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetFindings]
$creadListPrec :: ReadPrec [GetFindings]
readPrec :: ReadPrec GetFindings
$creadPrec :: ReadPrec GetFindings
readList :: ReadS [GetFindings]
$creadList :: ReadS [GetFindings]
readsPrec :: Int -> ReadS GetFindings
$creadsPrec :: Int -> ReadS GetFindings
Prelude.Read, Int -> GetFindings -> ShowS
[GetFindings] -> ShowS
GetFindings -> String
(Int -> GetFindings -> ShowS)
-> (GetFindings -> String)
-> ([GetFindings] -> ShowS)
-> Show GetFindings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetFindings] -> ShowS
$cshowList :: [GetFindings] -> ShowS
show :: GetFindings -> String
$cshow :: GetFindings -> String
showsPrec :: Int -> GetFindings -> ShowS
$cshowsPrec :: Int -> GetFindings -> ShowS
Prelude.Show, (forall x. GetFindings -> Rep GetFindings x)
-> (forall x. Rep GetFindings x -> GetFindings)
-> Generic GetFindings
forall x. Rep GetFindings x -> GetFindings
forall x. GetFindings -> Rep GetFindings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetFindings x -> GetFindings
$cfrom :: forall x. GetFindings -> Rep GetFindings x
Prelude.Generic)
newGetFindings ::
GetFindings
newGetFindings :: GetFindings
newGetFindings =
GetFindings' :: Maybe SortCriteria -> [Text] -> GetFindings
GetFindings'
{ $sel:sortCriteria:GetFindings' :: Maybe SortCriteria
sortCriteria = Maybe SortCriteria
forall a. Maybe a
Prelude.Nothing,
$sel:findingIds:GetFindings' :: [Text]
findingIds = [Text]
forall a. Monoid a => a
Prelude.mempty
}
getFindings_sortCriteria :: Lens.Lens' GetFindings (Prelude.Maybe SortCriteria)
getFindings_sortCriteria :: (Maybe SortCriteria -> f (Maybe SortCriteria))
-> GetFindings -> f GetFindings
getFindings_sortCriteria = (GetFindings -> Maybe SortCriteria)
-> (GetFindings -> Maybe SortCriteria -> GetFindings)
-> Lens
GetFindings GetFindings (Maybe SortCriteria) (Maybe SortCriteria)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFindings' {Maybe SortCriteria
sortCriteria :: Maybe SortCriteria
$sel:sortCriteria:GetFindings' :: GetFindings -> Maybe SortCriteria
sortCriteria} -> Maybe SortCriteria
sortCriteria) (\s :: GetFindings
s@GetFindings' {} Maybe SortCriteria
a -> GetFindings
s {$sel:sortCriteria:GetFindings' :: Maybe SortCriteria
sortCriteria = Maybe SortCriteria
a} :: GetFindings)
getFindings_findingIds :: Lens.Lens' GetFindings [Prelude.Text]
getFindings_findingIds :: ([Text] -> f [Text]) -> GetFindings -> f GetFindings
getFindings_findingIds = (GetFindings -> [Text])
-> (GetFindings -> [Text] -> GetFindings)
-> Lens GetFindings GetFindings [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFindings' {[Text]
findingIds :: [Text]
$sel:findingIds:GetFindings' :: GetFindings -> [Text]
findingIds} -> [Text]
findingIds) (\s :: GetFindings
s@GetFindings' {} [Text]
a -> GetFindings
s {$sel:findingIds:GetFindings' :: [Text]
findingIds = [Text]
a} :: GetFindings) (([Text] -> f [Text]) -> GetFindings -> f GetFindings)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> GetFindings
-> f GetFindings
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 Core.AWSRequest GetFindings where
type AWSResponse GetFindings = GetFindingsResponse
request :: GetFindings -> Request GetFindings
request = Service -> GetFindings -> Request GetFindings
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetFindings
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetFindings)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetFindings))
-> Logger
-> Service
-> Proxy GetFindings
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetFindings)))
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 [Finding] -> Int -> GetFindingsResponse
GetFindingsResponse'
(Maybe [Finding] -> Int -> GetFindingsResponse)
-> Either String (Maybe [Finding])
-> Either String (Int -> GetFindingsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Finding]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"findings" Either String (Maybe (Maybe [Finding]))
-> Maybe [Finding] -> Either String (Maybe [Finding])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Finding]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> GetFindingsResponse)
-> Either String Int -> Either String GetFindingsResponse
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))
)
instance Prelude.Hashable GetFindings
instance Prelude.NFData GetFindings
instance Core.ToHeaders GetFindings where
toHeaders :: GetFindings -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetFindings -> 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 GetFindings where
toJSON :: GetFindings -> Value
toJSON GetFindings' {[Text]
Maybe SortCriteria
findingIds :: [Text]
sortCriteria :: Maybe SortCriteria
$sel:findingIds:GetFindings' :: GetFindings -> [Text]
$sel:sortCriteria:GetFindings' :: GetFindings -> Maybe SortCriteria
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (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,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"findingIds" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
findingIds)
]
)
instance Core.ToPath GetFindings where
toPath :: GetFindings -> ByteString
toPath = ByteString -> GetFindings -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/findings/describe"
instance Core.ToQuery GetFindings where
toQuery :: GetFindings -> QueryString
toQuery = QueryString -> GetFindings -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetFindingsResponse = GetFindingsResponse'
{
GetFindingsResponse -> Maybe [Finding]
findings :: Prelude.Maybe [Finding],
GetFindingsResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetFindingsResponse -> GetFindingsResponse -> Bool
(GetFindingsResponse -> GetFindingsResponse -> Bool)
-> (GetFindingsResponse -> GetFindingsResponse -> Bool)
-> Eq GetFindingsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetFindingsResponse -> GetFindingsResponse -> Bool
$c/= :: GetFindingsResponse -> GetFindingsResponse -> Bool
== :: GetFindingsResponse -> GetFindingsResponse -> Bool
$c== :: GetFindingsResponse -> GetFindingsResponse -> Bool
Prelude.Eq, ReadPrec [GetFindingsResponse]
ReadPrec GetFindingsResponse
Int -> ReadS GetFindingsResponse
ReadS [GetFindingsResponse]
(Int -> ReadS GetFindingsResponse)
-> ReadS [GetFindingsResponse]
-> ReadPrec GetFindingsResponse
-> ReadPrec [GetFindingsResponse]
-> Read GetFindingsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetFindingsResponse]
$creadListPrec :: ReadPrec [GetFindingsResponse]
readPrec :: ReadPrec GetFindingsResponse
$creadPrec :: ReadPrec GetFindingsResponse
readList :: ReadS [GetFindingsResponse]
$creadList :: ReadS [GetFindingsResponse]
readsPrec :: Int -> ReadS GetFindingsResponse
$creadsPrec :: Int -> ReadS GetFindingsResponse
Prelude.Read, Int -> GetFindingsResponse -> ShowS
[GetFindingsResponse] -> ShowS
GetFindingsResponse -> String
(Int -> GetFindingsResponse -> ShowS)
-> (GetFindingsResponse -> String)
-> ([GetFindingsResponse] -> ShowS)
-> Show GetFindingsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetFindingsResponse] -> ShowS
$cshowList :: [GetFindingsResponse] -> ShowS
show :: GetFindingsResponse -> String
$cshow :: GetFindingsResponse -> String
showsPrec :: Int -> GetFindingsResponse -> ShowS
$cshowsPrec :: Int -> GetFindingsResponse -> ShowS
Prelude.Show, (forall x. GetFindingsResponse -> Rep GetFindingsResponse x)
-> (forall x. Rep GetFindingsResponse x -> GetFindingsResponse)
-> Generic GetFindingsResponse
forall x. Rep GetFindingsResponse x -> GetFindingsResponse
forall x. GetFindingsResponse -> Rep GetFindingsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetFindingsResponse x -> GetFindingsResponse
$cfrom :: forall x. GetFindingsResponse -> Rep GetFindingsResponse x
Prelude.Generic)
newGetFindingsResponse ::
Prelude.Int ->
GetFindingsResponse
newGetFindingsResponse :: Int -> GetFindingsResponse
newGetFindingsResponse Int
pHttpStatus_ =
GetFindingsResponse' :: Maybe [Finding] -> Int -> GetFindingsResponse
GetFindingsResponse'
{ $sel:findings:GetFindingsResponse' :: Maybe [Finding]
findings = Maybe [Finding]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetFindingsResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getFindingsResponse_findings :: Lens.Lens' GetFindingsResponse (Prelude.Maybe [Finding])
getFindingsResponse_findings :: (Maybe [Finding] -> f (Maybe [Finding]))
-> GetFindingsResponse -> f GetFindingsResponse
getFindingsResponse_findings = (GetFindingsResponse -> Maybe [Finding])
-> (GetFindingsResponse -> Maybe [Finding] -> GetFindingsResponse)
-> Lens
GetFindingsResponse
GetFindingsResponse
(Maybe [Finding])
(Maybe [Finding])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFindingsResponse' {Maybe [Finding]
findings :: Maybe [Finding]
$sel:findings:GetFindingsResponse' :: GetFindingsResponse -> Maybe [Finding]
findings} -> Maybe [Finding]
findings) (\s :: GetFindingsResponse
s@GetFindingsResponse' {} Maybe [Finding]
a -> GetFindingsResponse
s {$sel:findings:GetFindingsResponse' :: Maybe [Finding]
findings = Maybe [Finding]
a} :: GetFindingsResponse) ((Maybe [Finding] -> f (Maybe [Finding]))
-> GetFindingsResponse -> f GetFindingsResponse)
-> ((Maybe [Finding] -> f (Maybe [Finding]))
-> Maybe [Finding] -> f (Maybe [Finding]))
-> (Maybe [Finding] -> f (Maybe [Finding]))
-> GetFindingsResponse
-> f GetFindingsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Finding] [Finding] [Finding] [Finding]
-> Iso
(Maybe [Finding])
(Maybe [Finding])
(Maybe [Finding])
(Maybe [Finding])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Finding] [Finding] [Finding] [Finding]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
getFindingsResponse_httpStatus :: Lens.Lens' GetFindingsResponse Prelude.Int
getFindingsResponse_httpStatus :: (Int -> f Int) -> GetFindingsResponse -> f GetFindingsResponse
getFindingsResponse_httpStatus = (GetFindingsResponse -> Int)
-> (GetFindingsResponse -> Int -> GetFindingsResponse)
-> Lens GetFindingsResponse GetFindingsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetFindingsResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetFindingsResponse' :: GetFindingsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetFindingsResponse
s@GetFindingsResponse' {} Int
a -> GetFindingsResponse
s {$sel:httpStatus:GetFindingsResponse' :: Int
httpStatus = Int
a} :: GetFindingsResponse)
instance Prelude.NFData GetFindingsResponse