{-# 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.CreateInsight
(
CreateInsight (..),
newCreateInsight,
createInsight_name,
createInsight_filters,
createInsight_groupByAttribute,
CreateInsightResponse (..),
newCreateInsightResponse,
createInsightResponse_httpStatus,
createInsightResponse_insightArn,
)
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 CreateInsight = CreateInsight'
{
CreateInsight -> Text
name :: Prelude.Text,
CreateInsight -> AwsSecurityFindingFilters
filters :: AwsSecurityFindingFilters,
CreateInsight -> Text
groupByAttribute :: Prelude.Text
}
deriving (CreateInsight -> CreateInsight -> Bool
(CreateInsight -> CreateInsight -> Bool)
-> (CreateInsight -> CreateInsight -> Bool) -> Eq CreateInsight
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateInsight -> CreateInsight -> Bool
$c/= :: CreateInsight -> CreateInsight -> Bool
== :: CreateInsight -> CreateInsight -> Bool
$c== :: CreateInsight -> CreateInsight -> Bool
Prelude.Eq, ReadPrec [CreateInsight]
ReadPrec CreateInsight
Int -> ReadS CreateInsight
ReadS [CreateInsight]
(Int -> ReadS CreateInsight)
-> ReadS [CreateInsight]
-> ReadPrec CreateInsight
-> ReadPrec [CreateInsight]
-> Read CreateInsight
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateInsight]
$creadListPrec :: ReadPrec [CreateInsight]
readPrec :: ReadPrec CreateInsight
$creadPrec :: ReadPrec CreateInsight
readList :: ReadS [CreateInsight]
$creadList :: ReadS [CreateInsight]
readsPrec :: Int -> ReadS CreateInsight
$creadsPrec :: Int -> ReadS CreateInsight
Prelude.Read, Int -> CreateInsight -> ShowS
[CreateInsight] -> ShowS
CreateInsight -> String
(Int -> CreateInsight -> ShowS)
-> (CreateInsight -> String)
-> ([CreateInsight] -> ShowS)
-> Show CreateInsight
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateInsight] -> ShowS
$cshowList :: [CreateInsight] -> ShowS
show :: CreateInsight -> String
$cshow :: CreateInsight -> String
showsPrec :: Int -> CreateInsight -> ShowS
$cshowsPrec :: Int -> CreateInsight -> ShowS
Prelude.Show, (forall x. CreateInsight -> Rep CreateInsight x)
-> (forall x. Rep CreateInsight x -> CreateInsight)
-> Generic CreateInsight
forall x. Rep CreateInsight x -> CreateInsight
forall x. CreateInsight -> Rep CreateInsight x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateInsight x -> CreateInsight
$cfrom :: forall x. CreateInsight -> Rep CreateInsight x
Prelude.Generic)
newCreateInsight ::
Prelude.Text ->
AwsSecurityFindingFilters ->
Prelude.Text ->
CreateInsight
newCreateInsight :: Text -> AwsSecurityFindingFilters -> Text -> CreateInsight
newCreateInsight Text
pName_ AwsSecurityFindingFilters
pFilters_ Text
pGroupByAttribute_ =
CreateInsight' :: Text -> AwsSecurityFindingFilters -> Text -> CreateInsight
CreateInsight'
{ $sel:name:CreateInsight' :: Text
name = Text
pName_,
$sel:filters:CreateInsight' :: AwsSecurityFindingFilters
filters = AwsSecurityFindingFilters
pFilters_,
$sel:groupByAttribute:CreateInsight' :: Text
groupByAttribute = Text
pGroupByAttribute_
}
createInsight_name :: Lens.Lens' CreateInsight Prelude.Text
createInsight_name :: (Text -> f Text) -> CreateInsight -> f CreateInsight
createInsight_name = (CreateInsight -> Text)
-> (CreateInsight -> Text -> CreateInsight)
-> Lens CreateInsight CreateInsight Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInsight' {Text
name :: Text
$sel:name:CreateInsight' :: CreateInsight -> Text
name} -> Text
name) (\s :: CreateInsight
s@CreateInsight' {} Text
a -> CreateInsight
s {$sel:name:CreateInsight' :: Text
name = Text
a} :: CreateInsight)
createInsight_filters :: Lens.Lens' CreateInsight AwsSecurityFindingFilters
createInsight_filters :: (AwsSecurityFindingFilters -> f AwsSecurityFindingFilters)
-> CreateInsight -> f CreateInsight
createInsight_filters = (CreateInsight -> AwsSecurityFindingFilters)
-> (CreateInsight -> AwsSecurityFindingFilters -> CreateInsight)
-> Lens
CreateInsight
CreateInsight
AwsSecurityFindingFilters
AwsSecurityFindingFilters
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInsight' {AwsSecurityFindingFilters
filters :: AwsSecurityFindingFilters
$sel:filters:CreateInsight' :: CreateInsight -> AwsSecurityFindingFilters
filters} -> AwsSecurityFindingFilters
filters) (\s :: CreateInsight
s@CreateInsight' {} AwsSecurityFindingFilters
a -> CreateInsight
s {$sel:filters:CreateInsight' :: AwsSecurityFindingFilters
filters = AwsSecurityFindingFilters
a} :: CreateInsight)
createInsight_groupByAttribute :: Lens.Lens' CreateInsight Prelude.Text
createInsight_groupByAttribute :: (Text -> f Text) -> CreateInsight -> f CreateInsight
createInsight_groupByAttribute = (CreateInsight -> Text)
-> (CreateInsight -> Text -> CreateInsight)
-> Lens CreateInsight CreateInsight Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInsight' {Text
groupByAttribute :: Text
$sel:groupByAttribute:CreateInsight' :: CreateInsight -> Text
groupByAttribute} -> Text
groupByAttribute) (\s :: CreateInsight
s@CreateInsight' {} Text
a -> CreateInsight
s {$sel:groupByAttribute:CreateInsight' :: Text
groupByAttribute = Text
a} :: CreateInsight)
instance Core.AWSRequest CreateInsight where
type
AWSResponse CreateInsight =
CreateInsightResponse
request :: CreateInsight -> Request CreateInsight
request = Service -> CreateInsight -> Request CreateInsight
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateInsight
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateInsight)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateInsight))
-> Logger
-> Service
-> Proxy CreateInsight
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateInsight)))
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 ->
Int -> Text -> CreateInsightResponse
CreateInsightResponse'
(Int -> Text -> CreateInsightResponse)
-> Either String Int
-> Either String (Text -> CreateInsightResponse)
forall (f :: * -> *) a b. Functor 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 -> CreateInsightResponse)
-> Either String Text -> Either String CreateInsightResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"InsightArn")
)
instance Prelude.Hashable CreateInsight
instance Prelude.NFData CreateInsight
instance Core.ToHeaders CreateInsight where
toHeaders :: CreateInsight -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateInsight -> 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 CreateInsight where
toJSON :: CreateInsight -> Value
toJSON CreateInsight' {Text
AwsSecurityFindingFilters
groupByAttribute :: Text
filters :: AwsSecurityFindingFilters
name :: Text
$sel:groupByAttribute:CreateInsight' :: CreateInsight -> Text
$sel:filters:CreateInsight' :: CreateInsight -> AwsSecurityFindingFilters
$sel:name:CreateInsight' :: CreateInsight -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Filters" Text -> AwsSecurityFindingFilters -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= AwsSecurityFindingFilters
filters),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"GroupByAttribute" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
groupByAttribute)
]
)
instance Core.ToPath CreateInsight where
toPath :: CreateInsight -> ByteString
toPath = ByteString -> CreateInsight -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/insights"
instance Core.ToQuery CreateInsight where
toQuery :: CreateInsight -> QueryString
toQuery = QueryString -> CreateInsight -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateInsightResponse = CreateInsightResponse'
{
CreateInsightResponse -> Int
httpStatus :: Prelude.Int,
CreateInsightResponse -> Text
insightArn :: Prelude.Text
}
deriving (CreateInsightResponse -> CreateInsightResponse -> Bool
(CreateInsightResponse -> CreateInsightResponse -> Bool)
-> (CreateInsightResponse -> CreateInsightResponse -> Bool)
-> Eq CreateInsightResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateInsightResponse -> CreateInsightResponse -> Bool
$c/= :: CreateInsightResponse -> CreateInsightResponse -> Bool
== :: CreateInsightResponse -> CreateInsightResponse -> Bool
$c== :: CreateInsightResponse -> CreateInsightResponse -> Bool
Prelude.Eq, ReadPrec [CreateInsightResponse]
ReadPrec CreateInsightResponse
Int -> ReadS CreateInsightResponse
ReadS [CreateInsightResponse]
(Int -> ReadS CreateInsightResponse)
-> ReadS [CreateInsightResponse]
-> ReadPrec CreateInsightResponse
-> ReadPrec [CreateInsightResponse]
-> Read CreateInsightResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateInsightResponse]
$creadListPrec :: ReadPrec [CreateInsightResponse]
readPrec :: ReadPrec CreateInsightResponse
$creadPrec :: ReadPrec CreateInsightResponse
readList :: ReadS [CreateInsightResponse]
$creadList :: ReadS [CreateInsightResponse]
readsPrec :: Int -> ReadS CreateInsightResponse
$creadsPrec :: Int -> ReadS CreateInsightResponse
Prelude.Read, Int -> CreateInsightResponse -> ShowS
[CreateInsightResponse] -> ShowS
CreateInsightResponse -> String
(Int -> CreateInsightResponse -> ShowS)
-> (CreateInsightResponse -> String)
-> ([CreateInsightResponse] -> ShowS)
-> Show CreateInsightResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateInsightResponse] -> ShowS
$cshowList :: [CreateInsightResponse] -> ShowS
show :: CreateInsightResponse -> String
$cshow :: CreateInsightResponse -> String
showsPrec :: Int -> CreateInsightResponse -> ShowS
$cshowsPrec :: Int -> CreateInsightResponse -> ShowS
Prelude.Show, (forall x. CreateInsightResponse -> Rep CreateInsightResponse x)
-> (forall x. Rep CreateInsightResponse x -> CreateInsightResponse)
-> Generic CreateInsightResponse
forall x. Rep CreateInsightResponse x -> CreateInsightResponse
forall x. CreateInsightResponse -> Rep CreateInsightResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateInsightResponse x -> CreateInsightResponse
$cfrom :: forall x. CreateInsightResponse -> Rep CreateInsightResponse x
Prelude.Generic)
newCreateInsightResponse ::
Prelude.Int ->
Prelude.Text ->
CreateInsightResponse
newCreateInsightResponse :: Int -> Text -> CreateInsightResponse
newCreateInsightResponse Int
pHttpStatus_ Text
pInsightArn_ =
CreateInsightResponse' :: Int -> Text -> CreateInsightResponse
CreateInsightResponse'
{ $sel:httpStatus:CreateInsightResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:insightArn:CreateInsightResponse' :: Text
insightArn = Text
pInsightArn_
}
createInsightResponse_httpStatus :: Lens.Lens' CreateInsightResponse Prelude.Int
createInsightResponse_httpStatus :: (Int -> f Int) -> CreateInsightResponse -> f CreateInsightResponse
createInsightResponse_httpStatus = (CreateInsightResponse -> Int)
-> (CreateInsightResponse -> Int -> CreateInsightResponse)
-> Lens CreateInsightResponse CreateInsightResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInsightResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateInsightResponse' :: CreateInsightResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateInsightResponse
s@CreateInsightResponse' {} Int
a -> CreateInsightResponse
s {$sel:httpStatus:CreateInsightResponse' :: Int
httpStatus = Int
a} :: CreateInsightResponse)
createInsightResponse_insightArn :: Lens.Lens' CreateInsightResponse Prelude.Text
createInsightResponse_insightArn :: (Text -> f Text)
-> CreateInsightResponse -> f CreateInsightResponse
createInsightResponse_insightArn = (CreateInsightResponse -> Text)
-> (CreateInsightResponse -> Text -> CreateInsightResponse)
-> Lens CreateInsightResponse CreateInsightResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateInsightResponse' {Text
insightArn :: Text
$sel:insightArn:CreateInsightResponse' :: CreateInsightResponse -> Text
insightArn} -> Text
insightArn) (\s :: CreateInsightResponse
s@CreateInsightResponse' {} Text
a -> CreateInsightResponse
s {$sel:insightArn:CreateInsightResponse' :: Text
insightArn = Text
a} :: CreateInsightResponse)
instance Prelude.NFData CreateInsightResponse