{-# 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.KMS.ListGrants
(
ListGrants (..),
newListGrants,
listGrants_grantId,
listGrants_granteePrincipal,
listGrants_marker,
listGrants_limit,
listGrants_keyId,
ListGrantsResponse (..),
newListGrantsResponse,
listGrantsResponse_truncated,
listGrantsResponse_grants,
listGrantsResponse_nextMarker,
)
where
import qualified Amazonka.Core as Core
import Amazonka.KMS.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 ListGrants = ListGrants'
{
ListGrants -> Maybe Text
grantId :: Prelude.Maybe Prelude.Text,
ListGrants -> Maybe Text
granteePrincipal :: Prelude.Maybe Prelude.Text,
ListGrants -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
ListGrants -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
ListGrants -> Text
keyId :: Prelude.Text
}
deriving (ListGrants -> ListGrants -> Bool
(ListGrants -> ListGrants -> Bool)
-> (ListGrants -> ListGrants -> Bool) -> Eq ListGrants
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListGrants -> ListGrants -> Bool
$c/= :: ListGrants -> ListGrants -> Bool
== :: ListGrants -> ListGrants -> Bool
$c== :: ListGrants -> ListGrants -> Bool
Prelude.Eq, ReadPrec [ListGrants]
ReadPrec ListGrants
Int -> ReadS ListGrants
ReadS [ListGrants]
(Int -> ReadS ListGrants)
-> ReadS [ListGrants]
-> ReadPrec ListGrants
-> ReadPrec [ListGrants]
-> Read ListGrants
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListGrants]
$creadListPrec :: ReadPrec [ListGrants]
readPrec :: ReadPrec ListGrants
$creadPrec :: ReadPrec ListGrants
readList :: ReadS [ListGrants]
$creadList :: ReadS [ListGrants]
readsPrec :: Int -> ReadS ListGrants
$creadsPrec :: Int -> ReadS ListGrants
Prelude.Read, Int -> ListGrants -> ShowS
[ListGrants] -> ShowS
ListGrants -> String
(Int -> ListGrants -> ShowS)
-> (ListGrants -> String)
-> ([ListGrants] -> ShowS)
-> Show ListGrants
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListGrants] -> ShowS
$cshowList :: [ListGrants] -> ShowS
show :: ListGrants -> String
$cshow :: ListGrants -> String
showsPrec :: Int -> ListGrants -> ShowS
$cshowsPrec :: Int -> ListGrants -> ShowS
Prelude.Show, (forall x. ListGrants -> Rep ListGrants x)
-> (forall x. Rep ListGrants x -> ListGrants) -> Generic ListGrants
forall x. Rep ListGrants x -> ListGrants
forall x. ListGrants -> Rep ListGrants x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListGrants x -> ListGrants
$cfrom :: forall x. ListGrants -> Rep ListGrants x
Prelude.Generic)
newListGrants ::
Prelude.Text ->
ListGrants
newListGrants :: Text -> ListGrants
newListGrants Text
pKeyId_ =
ListGrants' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Natural -> Text -> ListGrants
ListGrants'
{ $sel:grantId:ListGrants' :: Maybe Text
grantId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:granteePrincipal:ListGrants' :: Maybe Text
granteePrincipal = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:marker:ListGrants' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:limit:ListGrants' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:keyId:ListGrants' :: Text
keyId = Text
pKeyId_
}
listGrants_grantId :: Lens.Lens' ListGrants (Prelude.Maybe Prelude.Text)
listGrants_grantId :: (Maybe Text -> f (Maybe Text)) -> ListGrants -> f ListGrants
listGrants_grantId = (ListGrants -> Maybe Text)
-> (ListGrants -> Maybe Text -> ListGrants)
-> Lens ListGrants ListGrants (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGrants' {Maybe Text
grantId :: Maybe Text
$sel:grantId:ListGrants' :: ListGrants -> Maybe Text
grantId} -> Maybe Text
grantId) (\s :: ListGrants
s@ListGrants' {} Maybe Text
a -> ListGrants
s {$sel:grantId:ListGrants' :: Maybe Text
grantId = Maybe Text
a} :: ListGrants)
listGrants_granteePrincipal :: Lens.Lens' ListGrants (Prelude.Maybe Prelude.Text)
listGrants_granteePrincipal :: (Maybe Text -> f (Maybe Text)) -> ListGrants -> f ListGrants
listGrants_granteePrincipal = (ListGrants -> Maybe Text)
-> (ListGrants -> Maybe Text -> ListGrants)
-> Lens ListGrants ListGrants (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGrants' {Maybe Text
granteePrincipal :: Maybe Text
$sel:granteePrincipal:ListGrants' :: ListGrants -> Maybe Text
granteePrincipal} -> Maybe Text
granteePrincipal) (\s :: ListGrants
s@ListGrants' {} Maybe Text
a -> ListGrants
s {$sel:granteePrincipal:ListGrants' :: Maybe Text
granteePrincipal = Maybe Text
a} :: ListGrants)
listGrants_marker :: Lens.Lens' ListGrants (Prelude.Maybe Prelude.Text)
listGrants_marker :: (Maybe Text -> f (Maybe Text)) -> ListGrants -> f ListGrants
listGrants_marker = (ListGrants -> Maybe Text)
-> (ListGrants -> Maybe Text -> ListGrants)
-> Lens ListGrants ListGrants (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGrants' {Maybe Text
marker :: Maybe Text
$sel:marker:ListGrants' :: ListGrants -> Maybe Text
marker} -> Maybe Text
marker) (\s :: ListGrants
s@ListGrants' {} Maybe Text
a -> ListGrants
s {$sel:marker:ListGrants' :: Maybe Text
marker = Maybe Text
a} :: ListGrants)
listGrants_limit :: Lens.Lens' ListGrants (Prelude.Maybe Prelude.Natural)
listGrants_limit :: (Maybe Natural -> f (Maybe Natural)) -> ListGrants -> f ListGrants
listGrants_limit = (ListGrants -> Maybe Natural)
-> (ListGrants -> Maybe Natural -> ListGrants)
-> Lens ListGrants ListGrants (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGrants' {Maybe Natural
limit :: Maybe Natural
$sel:limit:ListGrants' :: ListGrants -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: ListGrants
s@ListGrants' {} Maybe Natural
a -> ListGrants
s {$sel:limit:ListGrants' :: Maybe Natural
limit = Maybe Natural
a} :: ListGrants)
listGrants_keyId :: Lens.Lens' ListGrants Prelude.Text
listGrants_keyId :: (Text -> f Text) -> ListGrants -> f ListGrants
listGrants_keyId = (ListGrants -> Text)
-> (ListGrants -> Text -> ListGrants)
-> Lens ListGrants ListGrants Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGrants' {Text
keyId :: Text
$sel:keyId:ListGrants' :: ListGrants -> Text
keyId} -> Text
keyId) (\s :: ListGrants
s@ListGrants' {} Text
a -> ListGrants
s {$sel:keyId:ListGrants' :: Text
keyId = Text
a} :: ListGrants)
instance Core.AWSPager ListGrants where
page :: ListGrants -> AWSResponse ListGrants -> Maybe ListGrants
page ListGrants
rq AWSResponse ListGrants
rs
| Maybe Bool -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
( AWSResponse ListGrants
ListGrantsResponse
rs
ListGrantsResponse
-> Getting (First Bool) ListGrantsResponse Bool -> Maybe Bool
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Bool -> Const (First Bool) (Maybe Bool))
-> ListGrantsResponse -> Const (First Bool) ListGrantsResponse
Lens' ListGrantsResponse (Maybe Bool)
listGrantsResponse_truncated ((Maybe Bool -> Const (First Bool) (Maybe Bool))
-> ListGrantsResponse -> Const (First Bool) ListGrantsResponse)
-> ((Bool -> Const (First Bool) Bool)
-> Maybe Bool -> Const (First Bool) (Maybe Bool))
-> Getting (First Bool) ListGrantsResponse Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Bool -> Const (First Bool) Bool)
-> Maybe Bool -> Const (First Bool) (Maybe Bool)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
Maybe ListGrants
forall a. Maybe a
Prelude.Nothing
| Maybe Text -> Bool
forall a. Maybe a -> Bool
Prelude.isNothing
( AWSResponse ListGrants
ListGrantsResponse
rs
ListGrantsResponse
-> Getting (First Text) ListGrantsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListGrantsResponse -> Const (First Text) ListGrantsResponse
Lens' ListGrantsResponse (Maybe Text)
listGrantsResponse_nextMarker ((Maybe Text -> Const (First Text) (Maybe Text))
-> ListGrantsResponse -> Const (First Text) ListGrantsResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListGrantsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
) =
Maybe ListGrants
forall a. Maybe a
Prelude.Nothing
| Bool
Prelude.otherwise =
ListGrants -> Maybe ListGrants
forall a. a -> Maybe a
Prelude.Just (ListGrants -> Maybe ListGrants) -> ListGrants -> Maybe ListGrants
forall a b. (a -> b) -> a -> b
Prelude.$
ListGrants
rq
ListGrants -> (ListGrants -> ListGrants) -> ListGrants
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListGrants -> Identity ListGrants
Lens ListGrants ListGrants (Maybe Text) (Maybe Text)
listGrants_marker
((Maybe Text -> Identity (Maybe Text))
-> ListGrants -> Identity ListGrants)
-> Maybe Text -> ListGrants -> ListGrants
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListGrants
ListGrantsResponse
rs
ListGrantsResponse
-> Getting (First Text) ListGrantsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListGrantsResponse -> Const (First Text) ListGrantsResponse
Lens' ListGrantsResponse (Maybe Text)
listGrantsResponse_nextMarker ((Maybe Text -> Const (First Text) (Maybe Text))
-> ListGrantsResponse -> Const (First Text) ListGrantsResponse)
-> ((Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListGrantsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
instance Core.AWSRequest ListGrants where
type AWSResponse ListGrants = ListGrantsResponse
request :: ListGrants -> Request ListGrants
request = Service -> ListGrants -> Request ListGrants
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy ListGrants
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListGrants)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse ListGrants))
-> Logger
-> Service
-> Proxy ListGrants
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListGrants)))
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 -> Object -> Either String ListGrantsResponse
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
instance Prelude.Hashable ListGrants
instance Prelude.NFData ListGrants
instance Core.ToHeaders ListGrants where
toHeaders :: ListGrants -> ResponseHeaders
toHeaders =
ResponseHeaders -> ListGrants -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"TrentService.ListGrants" :: Prelude.ByteString),
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 ListGrants where
toJSON :: ListGrants -> Value
toJSON ListGrants' {Maybe Natural
Maybe Text
Text
keyId :: Text
limit :: Maybe Natural
marker :: Maybe Text
granteePrincipal :: Maybe Text
grantId :: Maybe Text
$sel:keyId:ListGrants' :: ListGrants -> Text
$sel:limit:ListGrants' :: ListGrants -> Maybe Natural
$sel:marker:ListGrants' :: ListGrants -> Maybe Text
$sel:granteePrincipal:ListGrants' :: ListGrants -> Maybe Text
$sel:grantId:ListGrants' :: ListGrants -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"GrantId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
grantId,
(Text
"GranteePrincipal" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
granteePrincipal,
(Text
"Marker" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
marker,
(Text
"Limit" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
limit,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"KeyId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
keyId)
]
)
instance Core.ToPath ListGrants where
toPath :: ListGrants -> ByteString
toPath = ByteString -> ListGrants -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery ListGrants where
toQuery :: ListGrants -> QueryString
toQuery = QueryString -> ListGrants -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty