{-# 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.Organizations.ListTargetsForPolicy
(
ListTargetsForPolicy (..),
newListTargetsForPolicy,
listTargetsForPolicy_maxResults,
listTargetsForPolicy_nextToken,
listTargetsForPolicy_policyId,
ListTargetsForPolicyResponse (..),
newListTargetsForPolicyResponse,
listTargetsForPolicyResponse_nextToken,
listTargetsForPolicyResponse_targets,
listTargetsForPolicyResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Organizations.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data ListTargetsForPolicy = ListTargetsForPolicy'
{
ListTargetsForPolicy -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
ListTargetsForPolicy -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListTargetsForPolicy -> Text
policyId :: Prelude.Text
}
deriving (ListTargetsForPolicy -> ListTargetsForPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTargetsForPolicy -> ListTargetsForPolicy -> Bool
$c/= :: ListTargetsForPolicy -> ListTargetsForPolicy -> Bool
== :: ListTargetsForPolicy -> ListTargetsForPolicy -> Bool
$c== :: ListTargetsForPolicy -> ListTargetsForPolicy -> Bool
Prelude.Eq, ReadPrec [ListTargetsForPolicy]
ReadPrec ListTargetsForPolicy
Int -> ReadS ListTargetsForPolicy
ReadS [ListTargetsForPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTargetsForPolicy]
$creadListPrec :: ReadPrec [ListTargetsForPolicy]
readPrec :: ReadPrec ListTargetsForPolicy
$creadPrec :: ReadPrec ListTargetsForPolicy
readList :: ReadS [ListTargetsForPolicy]
$creadList :: ReadS [ListTargetsForPolicy]
readsPrec :: Int -> ReadS ListTargetsForPolicy
$creadsPrec :: Int -> ReadS ListTargetsForPolicy
Prelude.Read, Int -> ListTargetsForPolicy -> ShowS
[ListTargetsForPolicy] -> ShowS
ListTargetsForPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTargetsForPolicy] -> ShowS
$cshowList :: [ListTargetsForPolicy] -> ShowS
show :: ListTargetsForPolicy -> String
$cshow :: ListTargetsForPolicy -> String
showsPrec :: Int -> ListTargetsForPolicy -> ShowS
$cshowsPrec :: Int -> ListTargetsForPolicy -> ShowS
Prelude.Show, forall x. Rep ListTargetsForPolicy x -> ListTargetsForPolicy
forall x. ListTargetsForPolicy -> Rep ListTargetsForPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTargetsForPolicy x -> ListTargetsForPolicy
$cfrom :: forall x. ListTargetsForPolicy -> Rep ListTargetsForPolicy x
Prelude.Generic)
newListTargetsForPolicy ::
Prelude.Text ->
ListTargetsForPolicy
newListTargetsForPolicy :: Text -> ListTargetsForPolicy
newListTargetsForPolicy Text
pPolicyId_ =
ListTargetsForPolicy'
{ $sel:maxResults:ListTargetsForPolicy' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
$sel:nextToken:ListTargetsForPolicy' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
$sel:policyId:ListTargetsForPolicy' :: Text
policyId = Text
pPolicyId_
}
listTargetsForPolicy_maxResults :: Lens.Lens' ListTargetsForPolicy (Prelude.Maybe Prelude.Natural)
listTargetsForPolicy_maxResults :: Lens' ListTargetsForPolicy (Maybe Natural)
listTargetsForPolicy_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsForPolicy' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListTargetsForPolicy
s@ListTargetsForPolicy' {} Maybe Natural
a -> ListTargetsForPolicy
s {$sel:maxResults:ListTargetsForPolicy' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListTargetsForPolicy)
listTargetsForPolicy_nextToken :: Lens.Lens' ListTargetsForPolicy (Prelude.Maybe Prelude.Text)
listTargetsForPolicy_nextToken :: Lens' ListTargetsForPolicy (Maybe Text)
listTargetsForPolicy_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsForPolicy' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTargetsForPolicy
s@ListTargetsForPolicy' {} Maybe Text
a -> ListTargetsForPolicy
s {$sel:nextToken:ListTargetsForPolicy' :: Maybe Text
nextToken = Maybe Text
a} :: ListTargetsForPolicy)
listTargetsForPolicy_policyId :: Lens.Lens' ListTargetsForPolicy Prelude.Text
listTargetsForPolicy_policyId :: Lens' ListTargetsForPolicy Text
listTargetsForPolicy_policyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsForPolicy' {Text
policyId :: Text
$sel:policyId:ListTargetsForPolicy' :: ListTargetsForPolicy -> Text
policyId} -> Text
policyId) (\s :: ListTargetsForPolicy
s@ListTargetsForPolicy' {} Text
a -> ListTargetsForPolicy
s {$sel:policyId:ListTargetsForPolicy' :: Text
policyId = Text
a} :: ListTargetsForPolicy)
instance Core.AWSPager ListTargetsForPolicy where
page :: ListTargetsForPolicy
-> AWSResponse ListTargetsForPolicy -> Maybe ListTargetsForPolicy
page ListTargetsForPolicy
rq AWSResponse ListTargetsForPolicy
rs
| forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListTargetsForPolicy
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListTargetsForPolicyResponse (Maybe Text)
listTargetsForPolicyResponse_nextToken
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
forall a. Maybe a
Prelude.Nothing
| forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListTargetsForPolicy
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListTargetsForPolicyResponse (Maybe [PolicyTargetSummary])
listTargetsForPolicyResponse_targets
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
forall a. a -> Maybe a
Prelude.Just
forall a b. (a -> b) -> a -> b
Prelude.$ ListTargetsForPolicy
rq
forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListTargetsForPolicy (Maybe Text)
listTargetsForPolicy_nextToken
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListTargetsForPolicy
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListTargetsForPolicyResponse (Maybe Text)
listTargetsForPolicyResponse_nextToken
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
instance Core.AWSRequest ListTargetsForPolicy where
type
AWSResponse ListTargetsForPolicy =
ListTargetsForPolicyResponse
request :: (Service -> Service)
-> ListTargetsForPolicy -> Request ListTargetsForPolicy
request Service -> Service
overrides =
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListTargetsForPolicy
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse ListTargetsForPolicy)))
response =
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe Text
-> Maybe [PolicyTargetSummary]
-> Int
-> ListTargetsForPolicyResponse
ListTargetsForPolicyResponse'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"NextToken")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Targets" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable ListTargetsForPolicy where
hashWithSalt :: Int -> ListTargetsForPolicy -> Int
hashWithSalt Int
_salt ListTargetsForPolicy' {Maybe Natural
Maybe Text
Text
policyId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:policyId:ListTargetsForPolicy' :: ListTargetsForPolicy -> Text
$sel:nextToken:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Text
$sel:maxResults:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Natural
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
policyId
instance Prelude.NFData ListTargetsForPolicy where
rnf :: ListTargetsForPolicy -> ()
rnf ListTargetsForPolicy' {Maybe Natural
Maybe Text
Text
policyId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:policyId:ListTargetsForPolicy' :: ListTargetsForPolicy -> Text
$sel:nextToken:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Text
$sel:maxResults:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Natural
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
policyId
instance Data.ToHeaders ListTargetsForPolicy where
toHeaders :: ListTargetsForPolicy -> ResponseHeaders
toHeaders =
forall a b. a -> b -> a
Prelude.const
( forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSOrganizationsV20161128.ListTargetsForPolicy" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Data.ToJSON ListTargetsForPolicy where
toJSON :: ListTargetsForPolicy -> Value
toJSON ListTargetsForPolicy' {Maybe Natural
Maybe Text
Text
policyId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:policyId:ListTargetsForPolicy' :: ListTargetsForPolicy -> Text
$sel:nextToken:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Text
$sel:maxResults:ListTargetsForPolicy' :: ListTargetsForPolicy -> Maybe Natural
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"MaxResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults,
(Key
"NextToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
nextToken,
forall a. a -> Maybe a
Prelude.Just (Key
"PolicyId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
policyId)
]
)
instance Data.ToPath ListTargetsForPolicy where
toPath :: ListTargetsForPolicy -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery ListTargetsForPolicy where
toQuery :: ListTargetsForPolicy -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data ListTargetsForPolicyResponse = ListTargetsForPolicyResponse'
{
ListTargetsForPolicyResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
ListTargetsForPolicyResponse -> Maybe [PolicyTargetSummary]
targets :: Prelude.Maybe [PolicyTargetSummary],
ListTargetsForPolicyResponse -> Int
httpStatus :: Prelude.Int
}
deriving (ListTargetsForPolicyResponse
-> ListTargetsForPolicyResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTargetsForPolicyResponse
-> ListTargetsForPolicyResponse -> Bool
$c/= :: ListTargetsForPolicyResponse
-> ListTargetsForPolicyResponse -> Bool
== :: ListTargetsForPolicyResponse
-> ListTargetsForPolicyResponse -> Bool
$c== :: ListTargetsForPolicyResponse
-> ListTargetsForPolicyResponse -> Bool
Prelude.Eq, ReadPrec [ListTargetsForPolicyResponse]
ReadPrec ListTargetsForPolicyResponse
Int -> ReadS ListTargetsForPolicyResponse
ReadS [ListTargetsForPolicyResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTargetsForPolicyResponse]
$creadListPrec :: ReadPrec [ListTargetsForPolicyResponse]
readPrec :: ReadPrec ListTargetsForPolicyResponse
$creadPrec :: ReadPrec ListTargetsForPolicyResponse
readList :: ReadS [ListTargetsForPolicyResponse]
$creadList :: ReadS [ListTargetsForPolicyResponse]
readsPrec :: Int -> ReadS ListTargetsForPolicyResponse
$creadsPrec :: Int -> ReadS ListTargetsForPolicyResponse
Prelude.Read, Int -> ListTargetsForPolicyResponse -> ShowS
[ListTargetsForPolicyResponse] -> ShowS
ListTargetsForPolicyResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTargetsForPolicyResponse] -> ShowS
$cshowList :: [ListTargetsForPolicyResponse] -> ShowS
show :: ListTargetsForPolicyResponse -> String
$cshow :: ListTargetsForPolicyResponse -> String
showsPrec :: Int -> ListTargetsForPolicyResponse -> ShowS
$cshowsPrec :: Int -> ListTargetsForPolicyResponse -> ShowS
Prelude.Show, forall x.
Rep ListTargetsForPolicyResponse x -> ListTargetsForPolicyResponse
forall x.
ListTargetsForPolicyResponse -> Rep ListTargetsForPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListTargetsForPolicyResponse x -> ListTargetsForPolicyResponse
$cfrom :: forall x.
ListTargetsForPolicyResponse -> Rep ListTargetsForPolicyResponse x
Prelude.Generic)
newListTargetsForPolicyResponse ::
Prelude.Int ->
ListTargetsForPolicyResponse
newListTargetsForPolicyResponse :: Int -> ListTargetsForPolicyResponse
newListTargetsForPolicyResponse Int
pHttpStatus_ =
ListTargetsForPolicyResponse'
{ $sel:nextToken:ListTargetsForPolicyResponse' :: Maybe Text
nextToken =
forall a. Maybe a
Prelude.Nothing,
$sel:targets:ListTargetsForPolicyResponse' :: Maybe [PolicyTargetSummary]
targets = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:ListTargetsForPolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
}
listTargetsForPolicyResponse_nextToken :: Lens.Lens' ListTargetsForPolicyResponse (Prelude.Maybe Prelude.Text)
listTargetsForPolicyResponse_nextToken :: Lens' ListTargetsForPolicyResponse (Maybe Text)
listTargetsForPolicyResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsForPolicyResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListTargetsForPolicyResponse' :: ListTargetsForPolicyResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListTargetsForPolicyResponse
s@ListTargetsForPolicyResponse' {} Maybe Text
a -> ListTargetsForPolicyResponse
s {$sel:nextToken:ListTargetsForPolicyResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListTargetsForPolicyResponse)
listTargetsForPolicyResponse_targets :: Lens.Lens' ListTargetsForPolicyResponse (Prelude.Maybe [PolicyTargetSummary])
listTargetsForPolicyResponse_targets :: Lens' ListTargetsForPolicyResponse (Maybe [PolicyTargetSummary])
listTargetsForPolicyResponse_targets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsForPolicyResponse' {Maybe [PolicyTargetSummary]
targets :: Maybe [PolicyTargetSummary]
$sel:targets:ListTargetsForPolicyResponse' :: ListTargetsForPolicyResponse -> Maybe [PolicyTargetSummary]
targets} -> Maybe [PolicyTargetSummary]
targets) (\s :: ListTargetsForPolicyResponse
s@ListTargetsForPolicyResponse' {} Maybe [PolicyTargetSummary]
a -> ListTargetsForPolicyResponse
s {$sel:targets:ListTargetsForPolicyResponse' :: Maybe [PolicyTargetSummary]
targets = Maybe [PolicyTargetSummary]
a} :: ListTargetsForPolicyResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
listTargetsForPolicyResponse_httpStatus :: Lens.Lens' ListTargetsForPolicyResponse Prelude.Int
listTargetsForPolicyResponse_httpStatus :: Lens' ListTargetsForPolicyResponse Int
listTargetsForPolicyResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTargetsForPolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListTargetsForPolicyResponse' :: ListTargetsForPolicyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListTargetsForPolicyResponse
s@ListTargetsForPolicyResponse' {} Int
a -> ListTargetsForPolicyResponse
s {$sel:httpStatus:ListTargetsForPolicyResponse' :: Int
httpStatus = Int
a} :: ListTargetsForPolicyResponse)
instance Prelude.NFData ListTargetsForPolicyResponse where
rnf :: ListTargetsForPolicyResponse -> ()
rnf ListTargetsForPolicyResponse' {Int
Maybe [PolicyTargetSummary]
Maybe Text
httpStatus :: Int
targets :: Maybe [PolicyTargetSummary]
nextToken :: Maybe Text
$sel:httpStatus:ListTargetsForPolicyResponse' :: ListTargetsForPolicyResponse -> Int
$sel:targets:ListTargetsForPolicyResponse' :: ListTargetsForPolicyResponse -> Maybe [PolicyTargetSummary]
$sel:nextToken:ListTargetsForPolicyResponse' :: ListTargetsForPolicyResponse -> Maybe Text
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [PolicyTargetSummary]
targets
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus