{-# 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.GuardDuty.CreateMembers
(
CreateMembers (..),
newCreateMembers,
createMembers_detectorId,
createMembers_accountDetails,
CreateMembersResponse (..),
newCreateMembersResponse,
createMembersResponse_httpStatus,
createMembersResponse_unprocessedAccounts,
)
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
data CreateMembers = CreateMembers'
{
CreateMembers -> Text
detectorId :: Prelude.Text,
CreateMembers -> NonEmpty AccountDetail
accountDetails :: Prelude.NonEmpty AccountDetail
}
deriving (CreateMembers -> CreateMembers -> Bool
(CreateMembers -> CreateMembers -> Bool)
-> (CreateMembers -> CreateMembers -> Bool) -> Eq CreateMembers
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateMembers -> CreateMembers -> Bool
$c/= :: CreateMembers -> CreateMembers -> Bool
== :: CreateMembers -> CreateMembers -> Bool
$c== :: CreateMembers -> CreateMembers -> Bool
Prelude.Eq, ReadPrec [CreateMembers]
ReadPrec CreateMembers
Int -> ReadS CreateMembers
ReadS [CreateMembers]
(Int -> ReadS CreateMembers)
-> ReadS [CreateMembers]
-> ReadPrec CreateMembers
-> ReadPrec [CreateMembers]
-> Read CreateMembers
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateMembers]
$creadListPrec :: ReadPrec [CreateMembers]
readPrec :: ReadPrec CreateMembers
$creadPrec :: ReadPrec CreateMembers
readList :: ReadS [CreateMembers]
$creadList :: ReadS [CreateMembers]
readsPrec :: Int -> ReadS CreateMembers
$creadsPrec :: Int -> ReadS CreateMembers
Prelude.Read, Int -> CreateMembers -> ShowS
[CreateMembers] -> ShowS
CreateMembers -> String
(Int -> CreateMembers -> ShowS)
-> (CreateMembers -> String)
-> ([CreateMembers] -> ShowS)
-> Show CreateMembers
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateMembers] -> ShowS
$cshowList :: [CreateMembers] -> ShowS
show :: CreateMembers -> String
$cshow :: CreateMembers -> String
showsPrec :: Int -> CreateMembers -> ShowS
$cshowsPrec :: Int -> CreateMembers -> ShowS
Prelude.Show, (forall x. CreateMembers -> Rep CreateMembers x)
-> (forall x. Rep CreateMembers x -> CreateMembers)
-> Generic CreateMembers
forall x. Rep CreateMembers x -> CreateMembers
forall x. CreateMembers -> Rep CreateMembers x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateMembers x -> CreateMembers
$cfrom :: forall x. CreateMembers -> Rep CreateMembers x
Prelude.Generic)
newCreateMembers ::
Prelude.Text ->
Prelude.NonEmpty AccountDetail ->
CreateMembers
newCreateMembers :: Text -> NonEmpty AccountDetail -> CreateMembers
newCreateMembers Text
pDetectorId_ NonEmpty AccountDetail
pAccountDetails_ =
CreateMembers' :: Text -> NonEmpty AccountDetail -> CreateMembers
CreateMembers'
{ $sel:detectorId:CreateMembers' :: Text
detectorId = Text
pDetectorId_,
$sel:accountDetails:CreateMembers' :: NonEmpty AccountDetail
accountDetails =
Tagged (NonEmpty AccountDetail) (Identity (NonEmpty AccountDetail))
-> Tagged
(NonEmpty AccountDetail) (Identity (NonEmpty AccountDetail))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged
(NonEmpty AccountDetail) (Identity (NonEmpty AccountDetail))
-> Tagged
(NonEmpty AccountDetail) (Identity (NonEmpty AccountDetail)))
-> NonEmpty AccountDetail -> NonEmpty AccountDetail
forall t b. AReview t b -> b -> t
Lens.# NonEmpty AccountDetail
pAccountDetails_
}
createMembers_detectorId :: Lens.Lens' CreateMembers Prelude.Text
createMembers_detectorId :: (Text -> f Text) -> CreateMembers -> f CreateMembers
createMembers_detectorId = (CreateMembers -> Text)
-> (CreateMembers -> Text -> CreateMembers)
-> Lens CreateMembers CreateMembers Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateMembers' {Text
detectorId :: Text
$sel:detectorId:CreateMembers' :: CreateMembers -> Text
detectorId} -> Text
detectorId) (\s :: CreateMembers
s@CreateMembers' {} Text
a -> CreateMembers
s {$sel:detectorId:CreateMembers' :: Text
detectorId = Text
a} :: CreateMembers)
createMembers_accountDetails :: Lens.Lens' CreateMembers (Prelude.NonEmpty AccountDetail)
createMembers_accountDetails :: (NonEmpty AccountDetail -> f (NonEmpty AccountDetail))
-> CreateMembers -> f CreateMembers
createMembers_accountDetails = (CreateMembers -> NonEmpty AccountDetail)
-> (CreateMembers -> NonEmpty AccountDetail -> CreateMembers)
-> Lens
CreateMembers
CreateMembers
(NonEmpty AccountDetail)
(NonEmpty AccountDetail)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateMembers' {NonEmpty AccountDetail
accountDetails :: NonEmpty AccountDetail
$sel:accountDetails:CreateMembers' :: CreateMembers -> NonEmpty AccountDetail
accountDetails} -> NonEmpty AccountDetail
accountDetails) (\s :: CreateMembers
s@CreateMembers' {} NonEmpty AccountDetail
a -> CreateMembers
s {$sel:accountDetails:CreateMembers' :: NonEmpty AccountDetail
accountDetails = NonEmpty AccountDetail
a} :: CreateMembers) ((NonEmpty AccountDetail -> f (NonEmpty AccountDetail))
-> CreateMembers -> f CreateMembers)
-> ((NonEmpty AccountDetail -> f (NonEmpty AccountDetail))
-> NonEmpty AccountDetail -> f (NonEmpty AccountDetail))
-> (NonEmpty AccountDetail -> f (NonEmpty AccountDetail))
-> CreateMembers
-> f CreateMembers
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty AccountDetail -> f (NonEmpty AccountDetail))
-> NonEmpty AccountDetail -> f (NonEmpty AccountDetail)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Core.AWSRequest CreateMembers where
type
AWSResponse CreateMembers =
CreateMembersResponse
request :: CreateMembers -> Request CreateMembers
request = Service -> CreateMembers -> Request CreateMembers
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateMembers
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateMembers)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateMembers))
-> Logger
-> Service
-> Proxy CreateMembers
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateMembers)))
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 -> [UnprocessedAccount] -> CreateMembersResponse
CreateMembersResponse'
(Int -> [UnprocessedAccount] -> CreateMembersResponse)
-> Either String Int
-> Either String ([UnprocessedAccount] -> CreateMembersResponse)
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 ([UnprocessedAccount] -> CreateMembersResponse)
-> Either String [UnprocessedAccount]
-> Either String CreateMembersResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Either String (Maybe [UnprocessedAccount])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"unprocessedAccounts"
Either String (Maybe [UnprocessedAccount])
-> [UnprocessedAccount] -> Either String [UnprocessedAccount]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [UnprocessedAccount]
forall a. Monoid a => a
Prelude.mempty
)
)
instance Prelude.Hashable CreateMembers
instance Prelude.NFData CreateMembers
instance Core.ToHeaders CreateMembers where
toHeaders :: CreateMembers -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateMembers -> 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 CreateMembers where
toJSON :: CreateMembers -> Value
toJSON CreateMembers' {NonEmpty AccountDetail
Text
accountDetails :: NonEmpty AccountDetail
detectorId :: Text
$sel:accountDetails:CreateMembers' :: CreateMembers -> NonEmpty AccountDetail
$sel:detectorId:CreateMembers' :: CreateMembers -> 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
"accountDetails" Text -> NonEmpty AccountDetail -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty AccountDetail
accountDetails)
]
)
instance Core.ToPath CreateMembers where
toPath :: CreateMembers -> ByteString
toPath CreateMembers' {NonEmpty AccountDetail
Text
accountDetails :: NonEmpty AccountDetail
detectorId :: Text
$sel:accountDetails:CreateMembers' :: CreateMembers -> NonEmpty AccountDetail
$sel:detectorId:CreateMembers' :: CreateMembers -> Text
..} =
[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
"/member"]
instance Core.ToQuery CreateMembers where
toQuery :: CreateMembers -> QueryString
toQuery = QueryString -> CreateMembers -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateMembersResponse = CreateMembersResponse'
{
CreateMembersResponse -> Int
httpStatus :: Prelude.Int,
CreateMembersResponse -> [UnprocessedAccount]
unprocessedAccounts :: [UnprocessedAccount]
}
deriving (CreateMembersResponse -> CreateMembersResponse -> Bool
(CreateMembersResponse -> CreateMembersResponse -> Bool)
-> (CreateMembersResponse -> CreateMembersResponse -> Bool)
-> Eq CreateMembersResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateMembersResponse -> CreateMembersResponse -> Bool
$c/= :: CreateMembersResponse -> CreateMembersResponse -> Bool
== :: CreateMembersResponse -> CreateMembersResponse -> Bool
$c== :: CreateMembersResponse -> CreateMembersResponse -> Bool
Prelude.Eq, ReadPrec [CreateMembersResponse]
ReadPrec CreateMembersResponse
Int -> ReadS CreateMembersResponse
ReadS [CreateMembersResponse]
(Int -> ReadS CreateMembersResponse)
-> ReadS [CreateMembersResponse]
-> ReadPrec CreateMembersResponse
-> ReadPrec [CreateMembersResponse]
-> Read CreateMembersResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateMembersResponse]
$creadListPrec :: ReadPrec [CreateMembersResponse]
readPrec :: ReadPrec CreateMembersResponse
$creadPrec :: ReadPrec CreateMembersResponse
readList :: ReadS [CreateMembersResponse]
$creadList :: ReadS [CreateMembersResponse]
readsPrec :: Int -> ReadS CreateMembersResponse
$creadsPrec :: Int -> ReadS CreateMembersResponse
Prelude.Read, Int -> CreateMembersResponse -> ShowS
[CreateMembersResponse] -> ShowS
CreateMembersResponse -> String
(Int -> CreateMembersResponse -> ShowS)
-> (CreateMembersResponse -> String)
-> ([CreateMembersResponse] -> ShowS)
-> Show CreateMembersResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateMembersResponse] -> ShowS
$cshowList :: [CreateMembersResponse] -> ShowS
show :: CreateMembersResponse -> String
$cshow :: CreateMembersResponse -> String
showsPrec :: Int -> CreateMembersResponse -> ShowS
$cshowsPrec :: Int -> CreateMembersResponse -> ShowS
Prelude.Show, (forall x. CreateMembersResponse -> Rep CreateMembersResponse x)
-> (forall x. Rep CreateMembersResponse x -> CreateMembersResponse)
-> Generic CreateMembersResponse
forall x. Rep CreateMembersResponse x -> CreateMembersResponse
forall x. CreateMembersResponse -> Rep CreateMembersResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateMembersResponse x -> CreateMembersResponse
$cfrom :: forall x. CreateMembersResponse -> Rep CreateMembersResponse x
Prelude.Generic)
newCreateMembersResponse ::
Prelude.Int ->
CreateMembersResponse
newCreateMembersResponse :: Int -> CreateMembersResponse
newCreateMembersResponse Int
pHttpStatus_ =
CreateMembersResponse' :: Int -> [UnprocessedAccount] -> CreateMembersResponse
CreateMembersResponse'
{ $sel:httpStatus:CreateMembersResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:unprocessedAccounts:CreateMembersResponse' :: [UnprocessedAccount]
unprocessedAccounts = [UnprocessedAccount]
forall a. Monoid a => a
Prelude.mempty
}
createMembersResponse_httpStatus :: Lens.Lens' CreateMembersResponse Prelude.Int
createMembersResponse_httpStatus :: (Int -> f Int) -> CreateMembersResponse -> f CreateMembersResponse
createMembersResponse_httpStatus = (CreateMembersResponse -> Int)
-> (CreateMembersResponse -> Int -> CreateMembersResponse)
-> Lens CreateMembersResponse CreateMembersResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateMembersResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateMembersResponse' :: CreateMembersResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateMembersResponse
s@CreateMembersResponse' {} Int
a -> CreateMembersResponse
s {$sel:httpStatus:CreateMembersResponse' :: Int
httpStatus = Int
a} :: CreateMembersResponse)
createMembersResponse_unprocessedAccounts :: Lens.Lens' CreateMembersResponse [UnprocessedAccount]
createMembersResponse_unprocessedAccounts :: ([UnprocessedAccount] -> f [UnprocessedAccount])
-> CreateMembersResponse -> f CreateMembersResponse
createMembersResponse_unprocessedAccounts = (CreateMembersResponse -> [UnprocessedAccount])
-> (CreateMembersResponse
-> [UnprocessedAccount] -> CreateMembersResponse)
-> Lens
CreateMembersResponse
CreateMembersResponse
[UnprocessedAccount]
[UnprocessedAccount]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateMembersResponse' {[UnprocessedAccount]
unprocessedAccounts :: [UnprocessedAccount]
$sel:unprocessedAccounts:CreateMembersResponse' :: CreateMembersResponse -> [UnprocessedAccount]
unprocessedAccounts} -> [UnprocessedAccount]
unprocessedAccounts) (\s :: CreateMembersResponse
s@CreateMembersResponse' {} [UnprocessedAccount]
a -> CreateMembersResponse
s {$sel:unprocessedAccounts:CreateMembersResponse' :: [UnprocessedAccount]
unprocessedAccounts = [UnprocessedAccount]
a} :: CreateMembersResponse) (([UnprocessedAccount] -> f [UnprocessedAccount])
-> CreateMembersResponse -> f CreateMembersResponse)
-> (([UnprocessedAccount] -> f [UnprocessedAccount])
-> [UnprocessedAccount] -> f [UnprocessedAccount])
-> ([UnprocessedAccount] -> f [UnprocessedAccount])
-> CreateMembersResponse
-> f CreateMembersResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([UnprocessedAccount] -> f [UnprocessedAccount])
-> [UnprocessedAccount] -> f [UnprocessedAccount]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Prelude.NFData CreateMembersResponse