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