{-# 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.CloudDirectory.LookupPolicy
(
LookupPolicy (..),
newLookupPolicy,
lookupPolicy_maxResults,
lookupPolicy_nextToken,
lookupPolicy_directoryArn,
lookupPolicy_objectReference,
LookupPolicyResponse (..),
newLookupPolicyResponse,
lookupPolicyResponse_nextToken,
lookupPolicyResponse_policyToPathList,
lookupPolicyResponse_httpStatus,
)
where
import Amazonka.CloudDirectory.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data LookupPolicy = LookupPolicy'
{
LookupPolicy -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
LookupPolicy -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
LookupPolicy -> Text
directoryArn :: Prelude.Text,
LookupPolicy -> ObjectReference
objectReference :: ObjectReference
}
deriving (LookupPolicy -> LookupPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LookupPolicy -> LookupPolicy -> Bool
$c/= :: LookupPolicy -> LookupPolicy -> Bool
== :: LookupPolicy -> LookupPolicy -> Bool
$c== :: LookupPolicy -> LookupPolicy -> Bool
Prelude.Eq, ReadPrec [LookupPolicy]
ReadPrec LookupPolicy
Int -> ReadS LookupPolicy
ReadS [LookupPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LookupPolicy]
$creadListPrec :: ReadPrec [LookupPolicy]
readPrec :: ReadPrec LookupPolicy
$creadPrec :: ReadPrec LookupPolicy
readList :: ReadS [LookupPolicy]
$creadList :: ReadS [LookupPolicy]
readsPrec :: Int -> ReadS LookupPolicy
$creadsPrec :: Int -> ReadS LookupPolicy
Prelude.Read, Int -> LookupPolicy -> ShowS
[LookupPolicy] -> ShowS
LookupPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LookupPolicy] -> ShowS
$cshowList :: [LookupPolicy] -> ShowS
show :: LookupPolicy -> String
$cshow :: LookupPolicy -> String
showsPrec :: Int -> LookupPolicy -> ShowS
$cshowsPrec :: Int -> LookupPolicy -> ShowS
Prelude.Show, forall x. Rep LookupPolicy x -> LookupPolicy
forall x. LookupPolicy -> Rep LookupPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LookupPolicy x -> LookupPolicy
$cfrom :: forall x. LookupPolicy -> Rep LookupPolicy x
Prelude.Generic)
newLookupPolicy ::
Prelude.Text ->
ObjectReference ->
LookupPolicy
newLookupPolicy :: Text -> ObjectReference -> LookupPolicy
newLookupPolicy Text
pDirectoryArn_ ObjectReference
pObjectReference_ =
LookupPolicy'
{ $sel:maxResults:LookupPolicy' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
$sel:nextToken:LookupPolicy' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
$sel:directoryArn:LookupPolicy' :: Text
directoryArn = Text
pDirectoryArn_,
$sel:objectReference:LookupPolicy' :: ObjectReference
objectReference = ObjectReference
pObjectReference_
}
lookupPolicy_maxResults :: Lens.Lens' LookupPolicy (Prelude.Maybe Prelude.Natural)
lookupPolicy_maxResults :: Lens' LookupPolicy (Maybe Natural)
lookupPolicy_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LookupPolicy' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:LookupPolicy' :: LookupPolicy -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: LookupPolicy
s@LookupPolicy' {} Maybe Natural
a -> LookupPolicy
s {$sel:maxResults:LookupPolicy' :: Maybe Natural
maxResults = Maybe Natural
a} :: LookupPolicy)
lookupPolicy_nextToken :: Lens.Lens' LookupPolicy (Prelude.Maybe Prelude.Text)
lookupPolicy_nextToken :: Lens' LookupPolicy (Maybe Text)
lookupPolicy_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LookupPolicy' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:LookupPolicy' :: LookupPolicy -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: LookupPolicy
s@LookupPolicy' {} Maybe Text
a -> LookupPolicy
s {$sel:nextToken:LookupPolicy' :: Maybe Text
nextToken = Maybe Text
a} :: LookupPolicy)
lookupPolicy_directoryArn :: Lens.Lens' LookupPolicy Prelude.Text
lookupPolicy_directoryArn :: Lens' LookupPolicy Text
lookupPolicy_directoryArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LookupPolicy' {Text
directoryArn :: Text
$sel:directoryArn:LookupPolicy' :: LookupPolicy -> Text
directoryArn} -> Text
directoryArn) (\s :: LookupPolicy
s@LookupPolicy' {} Text
a -> LookupPolicy
s {$sel:directoryArn:LookupPolicy' :: Text
directoryArn = Text
a} :: LookupPolicy)
lookupPolicy_objectReference :: Lens.Lens' LookupPolicy ObjectReference
lookupPolicy_objectReference :: Lens' LookupPolicy ObjectReference
lookupPolicy_objectReference = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LookupPolicy' {ObjectReference
objectReference :: ObjectReference
$sel:objectReference:LookupPolicy' :: LookupPolicy -> ObjectReference
objectReference} -> ObjectReference
objectReference) (\s :: LookupPolicy
s@LookupPolicy' {} ObjectReference
a -> LookupPolicy
s {$sel:objectReference:LookupPolicy' :: ObjectReference
objectReference = ObjectReference
a} :: LookupPolicy)
instance Core.AWSPager LookupPolicy where
page :: LookupPolicy -> AWSResponse LookupPolicy -> Maybe LookupPolicy
page LookupPolicy
rq AWSResponse LookupPolicy
rs
| forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse LookupPolicy
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' LookupPolicyResponse (Maybe Text)
lookupPolicyResponse_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 LookupPolicy
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' LookupPolicyResponse (Maybe [PolicyToPath])
lookupPolicyResponse_policyToPathList
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.$ LookupPolicy
rq
forall a b. a -> (a -> b) -> b
Prelude.& Lens' LookupPolicy (Maybe Text)
lookupPolicy_nextToken
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse LookupPolicy
rs
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' LookupPolicyResponse (Maybe Text)
lookupPolicyResponse_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 LookupPolicy where
type AWSResponse LookupPolicy = LookupPolicyResponse
request :: (Service -> Service) -> LookupPolicy -> Request LookupPolicy
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 LookupPolicy
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse LookupPolicy)))
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 [PolicyToPath] -> Int -> LookupPolicyResponse
LookupPolicyResponse'
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
"PolicyToPathList"
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 LookupPolicy where
hashWithSalt :: Int -> LookupPolicy -> Int
hashWithSalt Int
_salt LookupPolicy' {Maybe Natural
Maybe Text
Text
ObjectReference
objectReference :: ObjectReference
directoryArn :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:objectReference:LookupPolicy' :: LookupPolicy -> ObjectReference
$sel:directoryArn:LookupPolicy' :: LookupPolicy -> Text
$sel:nextToken:LookupPolicy' :: LookupPolicy -> Maybe Text
$sel:maxResults:LookupPolicy' :: LookupPolicy -> 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
directoryArn
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ObjectReference
objectReference
instance Prelude.NFData LookupPolicy where
rnf :: LookupPolicy -> ()
rnf LookupPolicy' {Maybe Natural
Maybe Text
Text
ObjectReference
objectReference :: ObjectReference
directoryArn :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:objectReference:LookupPolicy' :: LookupPolicy -> ObjectReference
$sel:directoryArn:LookupPolicy' :: LookupPolicy -> Text
$sel:nextToken:LookupPolicy' :: LookupPolicy -> Maybe Text
$sel:maxResults:LookupPolicy' :: LookupPolicy -> 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
directoryArn
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf ObjectReference
objectReference
instance Data.ToHeaders LookupPolicy where
toHeaders :: LookupPolicy -> ResponseHeaders
toHeaders LookupPolicy' {Maybe Natural
Maybe Text
Text
ObjectReference
objectReference :: ObjectReference
directoryArn :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:objectReference:LookupPolicy' :: LookupPolicy -> ObjectReference
$sel:directoryArn:LookupPolicy' :: LookupPolicy -> Text
$sel:nextToken:LookupPolicy' :: LookupPolicy -> Maybe Text
$sel:maxResults:LookupPolicy' :: LookupPolicy -> Maybe Natural
..} =
forall a. Monoid a => [a] -> a
Prelude.mconcat
[HeaderName
"x-amz-data-partition" forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# Text
directoryArn]
instance Data.ToJSON LookupPolicy where
toJSON :: LookupPolicy -> Value
toJSON LookupPolicy' {Maybe Natural
Maybe Text
Text
ObjectReference
objectReference :: ObjectReference
directoryArn :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:objectReference:LookupPolicy' :: LookupPolicy -> ObjectReference
$sel:directoryArn:LookupPolicy' :: LookupPolicy -> Text
$sel:nextToken:LookupPolicy' :: LookupPolicy -> Maybe Text
$sel:maxResults:LookupPolicy' :: LookupPolicy -> 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
"ObjectReference" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ObjectReference
objectReference)
]
)
instance Data.ToPath LookupPolicy where
toPath :: LookupPolicy -> ByteString
toPath =
forall a b. a -> b -> a
Prelude.const
ByteString
"/amazonclouddirectory/2017-01-11/policy/lookup"
instance Data.ToQuery LookupPolicy where
toQuery :: LookupPolicy -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data LookupPolicyResponse = LookupPolicyResponse'
{
LookupPolicyResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
LookupPolicyResponse -> Maybe [PolicyToPath]
policyToPathList :: Prelude.Maybe [PolicyToPath],
LookupPolicyResponse -> Int
httpStatus :: Prelude.Int
}
deriving (LookupPolicyResponse -> LookupPolicyResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LookupPolicyResponse -> LookupPolicyResponse -> Bool
$c/= :: LookupPolicyResponse -> LookupPolicyResponse -> Bool
== :: LookupPolicyResponse -> LookupPolicyResponse -> Bool
$c== :: LookupPolicyResponse -> LookupPolicyResponse -> Bool
Prelude.Eq, ReadPrec [LookupPolicyResponse]
ReadPrec LookupPolicyResponse
Int -> ReadS LookupPolicyResponse
ReadS [LookupPolicyResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LookupPolicyResponse]
$creadListPrec :: ReadPrec [LookupPolicyResponse]
readPrec :: ReadPrec LookupPolicyResponse
$creadPrec :: ReadPrec LookupPolicyResponse
readList :: ReadS [LookupPolicyResponse]
$creadList :: ReadS [LookupPolicyResponse]
readsPrec :: Int -> ReadS LookupPolicyResponse
$creadsPrec :: Int -> ReadS LookupPolicyResponse
Prelude.Read, Int -> LookupPolicyResponse -> ShowS
[LookupPolicyResponse] -> ShowS
LookupPolicyResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LookupPolicyResponse] -> ShowS
$cshowList :: [LookupPolicyResponse] -> ShowS
show :: LookupPolicyResponse -> String
$cshow :: LookupPolicyResponse -> String
showsPrec :: Int -> LookupPolicyResponse -> ShowS
$cshowsPrec :: Int -> LookupPolicyResponse -> ShowS
Prelude.Show, forall x. Rep LookupPolicyResponse x -> LookupPolicyResponse
forall x. LookupPolicyResponse -> Rep LookupPolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LookupPolicyResponse x -> LookupPolicyResponse
$cfrom :: forall x. LookupPolicyResponse -> Rep LookupPolicyResponse x
Prelude.Generic)
newLookupPolicyResponse ::
Prelude.Int ->
LookupPolicyResponse
newLookupPolicyResponse :: Int -> LookupPolicyResponse
newLookupPolicyResponse Int
pHttpStatus_ =
LookupPolicyResponse'
{ $sel:nextToken:LookupPolicyResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
$sel:policyToPathList:LookupPolicyResponse' :: Maybe [PolicyToPath]
policyToPathList = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:LookupPolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
}
lookupPolicyResponse_nextToken :: Lens.Lens' LookupPolicyResponse (Prelude.Maybe Prelude.Text)
lookupPolicyResponse_nextToken :: Lens' LookupPolicyResponse (Maybe Text)
lookupPolicyResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LookupPolicyResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:LookupPolicyResponse' :: LookupPolicyResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: LookupPolicyResponse
s@LookupPolicyResponse' {} Maybe Text
a -> LookupPolicyResponse
s {$sel:nextToken:LookupPolicyResponse' :: Maybe Text
nextToken = Maybe Text
a} :: LookupPolicyResponse)
lookupPolicyResponse_policyToPathList :: Lens.Lens' LookupPolicyResponse (Prelude.Maybe [PolicyToPath])
lookupPolicyResponse_policyToPathList :: Lens' LookupPolicyResponse (Maybe [PolicyToPath])
lookupPolicyResponse_policyToPathList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LookupPolicyResponse' {Maybe [PolicyToPath]
policyToPathList :: Maybe [PolicyToPath]
$sel:policyToPathList:LookupPolicyResponse' :: LookupPolicyResponse -> Maybe [PolicyToPath]
policyToPathList} -> Maybe [PolicyToPath]
policyToPathList) (\s :: LookupPolicyResponse
s@LookupPolicyResponse' {} Maybe [PolicyToPath]
a -> LookupPolicyResponse
s {$sel:policyToPathList:LookupPolicyResponse' :: Maybe [PolicyToPath]
policyToPathList = Maybe [PolicyToPath]
a} :: LookupPolicyResponse) 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
lookupPolicyResponse_httpStatus :: Lens.Lens' LookupPolicyResponse Prelude.Int
lookupPolicyResponse_httpStatus :: Lens' LookupPolicyResponse Int
lookupPolicyResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\LookupPolicyResponse' {Int
httpStatus :: Int
$sel:httpStatus:LookupPolicyResponse' :: LookupPolicyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: LookupPolicyResponse
s@LookupPolicyResponse' {} Int
a -> LookupPolicyResponse
s {$sel:httpStatus:LookupPolicyResponse' :: Int
httpStatus = Int
a} :: LookupPolicyResponse)
instance Prelude.NFData LookupPolicyResponse where
rnf :: LookupPolicyResponse -> ()
rnf LookupPolicyResponse' {Int
Maybe [PolicyToPath]
Maybe Text
httpStatus :: Int
policyToPathList :: Maybe [PolicyToPath]
nextToken :: Maybe Text
$sel:httpStatus:LookupPolicyResponse' :: LookupPolicyResponse -> Int
$sel:policyToPathList:LookupPolicyResponse' :: LookupPolicyResponse -> Maybe [PolicyToPath]
$sel:nextToken:LookupPolicyResponse' :: LookupPolicyResponse -> 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 [PolicyToPath]
policyToPathList
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus