{-# 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.SecurityHub.BatchImportFindings
(
BatchImportFindings (..),
newBatchImportFindings,
batchImportFindings_findings,
BatchImportFindingsResponse (..),
newBatchImportFindingsResponse,
batchImportFindingsResponse_failedFindings,
batchImportFindingsResponse_httpStatus,
batchImportFindingsResponse_failedCount,
batchImportFindingsResponse_successCount,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SecurityHub.Types
data BatchImportFindings = BatchImportFindings'
{
BatchImportFindings -> NonEmpty AwsSecurityFinding
findings :: Prelude.NonEmpty AwsSecurityFinding
}
deriving (BatchImportFindings -> BatchImportFindings -> Bool
(BatchImportFindings -> BatchImportFindings -> Bool)
-> (BatchImportFindings -> BatchImportFindings -> Bool)
-> Eq BatchImportFindings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchImportFindings -> BatchImportFindings -> Bool
$c/= :: BatchImportFindings -> BatchImportFindings -> Bool
== :: BatchImportFindings -> BatchImportFindings -> Bool
$c== :: BatchImportFindings -> BatchImportFindings -> Bool
Prelude.Eq, ReadPrec [BatchImportFindings]
ReadPrec BatchImportFindings
Int -> ReadS BatchImportFindings
ReadS [BatchImportFindings]
(Int -> ReadS BatchImportFindings)
-> ReadS [BatchImportFindings]
-> ReadPrec BatchImportFindings
-> ReadPrec [BatchImportFindings]
-> Read BatchImportFindings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchImportFindings]
$creadListPrec :: ReadPrec [BatchImportFindings]
readPrec :: ReadPrec BatchImportFindings
$creadPrec :: ReadPrec BatchImportFindings
readList :: ReadS [BatchImportFindings]
$creadList :: ReadS [BatchImportFindings]
readsPrec :: Int -> ReadS BatchImportFindings
$creadsPrec :: Int -> ReadS BatchImportFindings
Prelude.Read, Int -> BatchImportFindings -> ShowS
[BatchImportFindings] -> ShowS
BatchImportFindings -> String
(Int -> BatchImportFindings -> ShowS)
-> (BatchImportFindings -> String)
-> ([BatchImportFindings] -> ShowS)
-> Show BatchImportFindings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchImportFindings] -> ShowS
$cshowList :: [BatchImportFindings] -> ShowS
show :: BatchImportFindings -> String
$cshow :: BatchImportFindings -> String
showsPrec :: Int -> BatchImportFindings -> ShowS
$cshowsPrec :: Int -> BatchImportFindings -> ShowS
Prelude.Show, (forall x. BatchImportFindings -> Rep BatchImportFindings x)
-> (forall x. Rep BatchImportFindings x -> BatchImportFindings)
-> Generic BatchImportFindings
forall x. Rep BatchImportFindings x -> BatchImportFindings
forall x. BatchImportFindings -> Rep BatchImportFindings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchImportFindings x -> BatchImportFindings
$cfrom :: forall x. BatchImportFindings -> Rep BatchImportFindings x
Prelude.Generic)
newBatchImportFindings ::
Prelude.NonEmpty AwsSecurityFinding ->
BatchImportFindings
newBatchImportFindings :: NonEmpty AwsSecurityFinding -> BatchImportFindings
newBatchImportFindings NonEmpty AwsSecurityFinding
pFindings_ =
BatchImportFindings' :: NonEmpty AwsSecurityFinding -> BatchImportFindings
BatchImportFindings'
{ $sel:findings:BatchImportFindings' :: NonEmpty AwsSecurityFinding
findings =
Tagged
(NonEmpty AwsSecurityFinding)
(Identity (NonEmpty AwsSecurityFinding))
-> Tagged
(NonEmpty AwsSecurityFinding)
(Identity (NonEmpty AwsSecurityFinding))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
(NonEmpty AwsSecurityFinding)
(Identity (NonEmpty AwsSecurityFinding))
-> Tagged
(NonEmpty AwsSecurityFinding)
(Identity (NonEmpty AwsSecurityFinding)))
-> NonEmpty AwsSecurityFinding -> NonEmpty AwsSecurityFinding
forall t b. AReview t b -> b -> t
Lens.# NonEmpty AwsSecurityFinding
pFindings_
}
batchImportFindings_findings :: Lens.Lens' BatchImportFindings (Prelude.NonEmpty AwsSecurityFinding)
batchImportFindings_findings :: (NonEmpty AwsSecurityFinding -> f (NonEmpty AwsSecurityFinding))
-> BatchImportFindings -> f BatchImportFindings
batchImportFindings_findings = (BatchImportFindings -> NonEmpty AwsSecurityFinding)
-> (BatchImportFindings
-> NonEmpty AwsSecurityFinding -> BatchImportFindings)
-> Lens
BatchImportFindings
BatchImportFindings
(NonEmpty AwsSecurityFinding)
(NonEmpty AwsSecurityFinding)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchImportFindings' {NonEmpty AwsSecurityFinding
findings :: NonEmpty AwsSecurityFinding
$sel:findings:BatchImportFindings' :: BatchImportFindings -> NonEmpty AwsSecurityFinding
findings} -> NonEmpty AwsSecurityFinding
findings) (\s :: BatchImportFindings
s@BatchImportFindings' {} NonEmpty AwsSecurityFinding
a -> BatchImportFindings
s {$sel:findings:BatchImportFindings' :: NonEmpty AwsSecurityFinding
findings = NonEmpty AwsSecurityFinding
a} :: BatchImportFindings) ((NonEmpty AwsSecurityFinding -> f (NonEmpty AwsSecurityFinding))
-> BatchImportFindings -> f BatchImportFindings)
-> ((NonEmpty AwsSecurityFinding
-> f (NonEmpty AwsSecurityFinding))
-> NonEmpty AwsSecurityFinding -> f (NonEmpty AwsSecurityFinding))
-> (NonEmpty AwsSecurityFinding -> f (NonEmpty AwsSecurityFinding))
-> BatchImportFindings
-> f BatchImportFindings
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty AwsSecurityFinding -> f (NonEmpty AwsSecurityFinding))
-> NonEmpty AwsSecurityFinding -> f (NonEmpty AwsSecurityFinding)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest BatchImportFindings where
type
AWSResponse BatchImportFindings =
BatchImportFindingsResponse
request :: BatchImportFindings -> Request BatchImportFindings
request = Service -> BatchImportFindings -> Request BatchImportFindings
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy BatchImportFindings
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse BatchImportFindings)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse BatchImportFindings))
-> Logger
-> Service
-> Proxy BatchImportFindings
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse BatchImportFindings)))
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 [ImportFindingsError]
-> Int -> Int -> Int -> BatchImportFindingsResponse
BatchImportFindingsResponse'
(Maybe [ImportFindingsError]
-> Int -> Int -> Int -> BatchImportFindingsResponse)
-> Either String (Maybe [ImportFindingsError])
-> Either String (Int -> Int -> Int -> BatchImportFindingsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Key -> Either String (Maybe (Maybe [ImportFindingsError]))
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"FailedFindings" Either String (Maybe (Maybe [ImportFindingsError]))
-> Maybe [ImportFindingsError]
-> Either String (Maybe [ImportFindingsError])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [ImportFindingsError]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> Int -> Int -> BatchImportFindingsResponse)
-> Either String Int
-> Either String (Int -> Int -> BatchImportFindingsResponse)
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 (Int -> Int -> BatchImportFindingsResponse)
-> Either String Int
-> Either String (Int -> BatchImportFindingsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Key -> Either String Int
forall a. FromJSON a => Object -> Key -> Either String a
Core..:> Key
"FailedCount")
Either String (Int -> BatchImportFindingsResponse)
-> Either String Int -> Either String BatchImportFindingsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Key -> Either String Int
forall a. FromJSON a => Object -> Key -> Either String a
Core..:> Key
"SuccessCount")
)
instance Prelude.Hashable BatchImportFindings
instance Prelude.NFData BatchImportFindings
instance Core.ToHeaders BatchImportFindings where
toHeaders :: BatchImportFindings -> ResponseHeaders
toHeaders =
ResponseHeaders -> BatchImportFindings -> 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 BatchImportFindings where
toJSON :: BatchImportFindings -> Value
toJSON BatchImportFindings' {NonEmpty AwsSecurityFinding
findings :: NonEmpty AwsSecurityFinding
$sel:findings:BatchImportFindings' :: BatchImportFindings -> NonEmpty AwsSecurityFinding
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Key
"Findings" Key -> NonEmpty AwsSecurityFinding -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..= NonEmpty AwsSecurityFinding
findings)]
)
instance Core.ToPath BatchImportFindings where
toPath :: BatchImportFindings -> ByteString
toPath = ByteString -> BatchImportFindings -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/findings/import"
instance Core.ToQuery BatchImportFindings where
toQuery :: BatchImportFindings -> QueryString
toQuery = QueryString -> BatchImportFindings -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data BatchImportFindingsResponse = BatchImportFindingsResponse'
{
BatchImportFindingsResponse -> Maybe [ImportFindingsError]
failedFindings :: Prelude.Maybe [ImportFindingsError],
BatchImportFindingsResponse -> Int
httpStatus :: Prelude.Int,
BatchImportFindingsResponse -> Int
failedCount :: Prelude.Int,
BatchImportFindingsResponse -> Int
successCount :: Prelude.Int
}
deriving (BatchImportFindingsResponse -> BatchImportFindingsResponse -> Bool
(BatchImportFindingsResponse
-> BatchImportFindingsResponse -> Bool)
-> (BatchImportFindingsResponse
-> BatchImportFindingsResponse -> Bool)
-> Eq BatchImportFindingsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchImportFindingsResponse -> BatchImportFindingsResponse -> Bool
$c/= :: BatchImportFindingsResponse -> BatchImportFindingsResponse -> Bool
== :: BatchImportFindingsResponse -> BatchImportFindingsResponse -> Bool
$c== :: BatchImportFindingsResponse -> BatchImportFindingsResponse -> Bool
Prelude.Eq, ReadPrec [BatchImportFindingsResponse]
ReadPrec BatchImportFindingsResponse
Int -> ReadS BatchImportFindingsResponse
ReadS [BatchImportFindingsResponse]
(Int -> ReadS BatchImportFindingsResponse)
-> ReadS [BatchImportFindingsResponse]
-> ReadPrec BatchImportFindingsResponse
-> ReadPrec [BatchImportFindingsResponse]
-> Read BatchImportFindingsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchImportFindingsResponse]
$creadListPrec :: ReadPrec [BatchImportFindingsResponse]
readPrec :: ReadPrec BatchImportFindingsResponse
$creadPrec :: ReadPrec BatchImportFindingsResponse
readList :: ReadS [BatchImportFindingsResponse]
$creadList :: ReadS [BatchImportFindingsResponse]
readsPrec :: Int -> ReadS BatchImportFindingsResponse
$creadsPrec :: Int -> ReadS BatchImportFindingsResponse
Prelude.Read, Int -> BatchImportFindingsResponse -> ShowS
[BatchImportFindingsResponse] -> ShowS
BatchImportFindingsResponse -> String
(Int -> BatchImportFindingsResponse -> ShowS)
-> (BatchImportFindingsResponse -> String)
-> ([BatchImportFindingsResponse] -> ShowS)
-> Show BatchImportFindingsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchImportFindingsResponse] -> ShowS
$cshowList :: [BatchImportFindingsResponse] -> ShowS
show :: BatchImportFindingsResponse -> String
$cshow :: BatchImportFindingsResponse -> String
showsPrec :: Int -> BatchImportFindingsResponse -> ShowS
$cshowsPrec :: Int -> BatchImportFindingsResponse -> ShowS
Prelude.Show, (forall x.
BatchImportFindingsResponse -> Rep BatchImportFindingsResponse x)
-> (forall x.
Rep BatchImportFindingsResponse x -> BatchImportFindingsResponse)
-> Generic BatchImportFindingsResponse
forall x.
Rep BatchImportFindingsResponse x -> BatchImportFindingsResponse
forall x.
BatchImportFindingsResponse -> Rep BatchImportFindingsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchImportFindingsResponse x -> BatchImportFindingsResponse
$cfrom :: forall x.
BatchImportFindingsResponse -> Rep BatchImportFindingsResponse x
Prelude.Generic)
newBatchImportFindingsResponse ::
Prelude.Int ->
Prelude.Int ->
Prelude.Int ->
BatchImportFindingsResponse
newBatchImportFindingsResponse :: Int -> Int -> Int -> BatchImportFindingsResponse
newBatchImportFindingsResponse
Int
pHttpStatus_
Int
pFailedCount_
Int
pSuccessCount_ =
BatchImportFindingsResponse' :: Maybe [ImportFindingsError]
-> Int -> Int -> Int -> BatchImportFindingsResponse
BatchImportFindingsResponse'
{ $sel:failedFindings:BatchImportFindingsResponse' :: Maybe [ImportFindingsError]
failedFindings =
Maybe [ImportFindingsError]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:BatchImportFindingsResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:failedCount:BatchImportFindingsResponse' :: Int
failedCount = Int
pFailedCount_,
$sel:successCount:BatchImportFindingsResponse' :: Int
successCount = Int
pSuccessCount_
}
batchImportFindingsResponse_failedFindings :: Lens.Lens' BatchImportFindingsResponse (Prelude.Maybe [ImportFindingsError])
batchImportFindingsResponse_failedFindings :: (Maybe [ImportFindingsError] -> f (Maybe [ImportFindingsError]))
-> BatchImportFindingsResponse -> f BatchImportFindingsResponse
batchImportFindingsResponse_failedFindings = (BatchImportFindingsResponse -> Maybe [ImportFindingsError])
-> (BatchImportFindingsResponse
-> Maybe [ImportFindingsError] -> BatchImportFindingsResponse)
-> Lens
BatchImportFindingsResponse
BatchImportFindingsResponse
(Maybe [ImportFindingsError])
(Maybe [ImportFindingsError])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchImportFindingsResponse' {Maybe [ImportFindingsError]
failedFindings :: Maybe [ImportFindingsError]
$sel:failedFindings:BatchImportFindingsResponse' :: BatchImportFindingsResponse -> Maybe [ImportFindingsError]
failedFindings} -> Maybe [ImportFindingsError]
failedFindings) (\s :: BatchImportFindingsResponse
s@BatchImportFindingsResponse' {} Maybe [ImportFindingsError]
a -> BatchImportFindingsResponse
s {$sel:failedFindings:BatchImportFindingsResponse' :: Maybe [ImportFindingsError]
failedFindings = Maybe [ImportFindingsError]
a} :: BatchImportFindingsResponse) ((Maybe [ImportFindingsError] -> f (Maybe [ImportFindingsError]))
-> BatchImportFindingsResponse -> f BatchImportFindingsResponse)
-> ((Maybe [ImportFindingsError]
-> f (Maybe [ImportFindingsError]))
-> Maybe [ImportFindingsError] -> f (Maybe [ImportFindingsError]))
-> (Maybe [ImportFindingsError] -> f (Maybe [ImportFindingsError]))
-> BatchImportFindingsResponse
-> f BatchImportFindingsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[ImportFindingsError]
[ImportFindingsError]
[ImportFindingsError]
[ImportFindingsError]
-> Iso
(Maybe [ImportFindingsError])
(Maybe [ImportFindingsError])
(Maybe [ImportFindingsError])
(Maybe [ImportFindingsError])
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
[ImportFindingsError]
[ImportFindingsError]
[ImportFindingsError]
[ImportFindingsError]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
batchImportFindingsResponse_httpStatus :: Lens.Lens' BatchImportFindingsResponse Prelude.Int
batchImportFindingsResponse_httpStatus :: (Int -> f Int)
-> BatchImportFindingsResponse -> f BatchImportFindingsResponse
batchImportFindingsResponse_httpStatus = (BatchImportFindingsResponse -> Int)
-> (BatchImportFindingsResponse
-> Int -> BatchImportFindingsResponse)
-> Lens
BatchImportFindingsResponse BatchImportFindingsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchImportFindingsResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchImportFindingsResponse' :: BatchImportFindingsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchImportFindingsResponse
s@BatchImportFindingsResponse' {} Int
a -> BatchImportFindingsResponse
s {$sel:httpStatus:BatchImportFindingsResponse' :: Int
httpStatus = Int
a} :: BatchImportFindingsResponse)
batchImportFindingsResponse_failedCount :: Lens.Lens' BatchImportFindingsResponse Prelude.Int
batchImportFindingsResponse_failedCount :: (Int -> f Int)
-> BatchImportFindingsResponse -> f BatchImportFindingsResponse
batchImportFindingsResponse_failedCount = (BatchImportFindingsResponse -> Int)
-> (BatchImportFindingsResponse
-> Int -> BatchImportFindingsResponse)
-> Lens
BatchImportFindingsResponse BatchImportFindingsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchImportFindingsResponse' {Int
failedCount :: Int
$sel:failedCount:BatchImportFindingsResponse' :: BatchImportFindingsResponse -> Int
failedCount} -> Int
failedCount) (\s :: BatchImportFindingsResponse
s@BatchImportFindingsResponse' {} Int
a -> BatchImportFindingsResponse
s {$sel:failedCount:BatchImportFindingsResponse' :: Int
failedCount = Int
a} :: BatchImportFindingsResponse)
batchImportFindingsResponse_successCount :: Lens.Lens' BatchImportFindingsResponse Prelude.Int
batchImportFindingsResponse_successCount :: (Int -> f Int)
-> BatchImportFindingsResponse -> f BatchImportFindingsResponse
batchImportFindingsResponse_successCount = (BatchImportFindingsResponse -> Int)
-> (BatchImportFindingsResponse
-> Int -> BatchImportFindingsResponse)
-> Lens
BatchImportFindingsResponse BatchImportFindingsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchImportFindingsResponse' {Int
successCount :: Int
$sel:successCount:BatchImportFindingsResponse' :: BatchImportFindingsResponse -> Int
successCount} -> Int
successCount) (\s :: BatchImportFindingsResponse
s@BatchImportFindingsResponse' {} Int
a -> BatchImportFindingsResponse
s {$sel:successCount:BatchImportFindingsResponse' :: Int
successCount = Int
a} :: BatchImportFindingsResponse)
instance Prelude.NFData BatchImportFindingsResponse