{-# 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.DescribeKey
(
DescribeKey (..),
newDescribeKey,
describeKey_grantTokens,
describeKey_keyId,
DescribeKeyResponse (..),
newDescribeKeyResponse,
describeKeyResponse_keyMetadata,
describeKeyResponse_httpStatus,
)
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 DescribeKey = DescribeKey'
{
DescribeKey -> Maybe [Text]
grantTokens :: Prelude.Maybe [Prelude.Text],
DescribeKey -> Text
keyId :: Prelude.Text
}
deriving (DescribeKey -> DescribeKey -> Bool
(DescribeKey -> DescribeKey -> Bool)
-> (DescribeKey -> DescribeKey -> Bool) -> Eq DescribeKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeKey -> DescribeKey -> Bool
$c/= :: DescribeKey -> DescribeKey -> Bool
== :: DescribeKey -> DescribeKey -> Bool
$c== :: DescribeKey -> DescribeKey -> Bool
Prelude.Eq, ReadPrec [DescribeKey]
ReadPrec DescribeKey
Int -> ReadS DescribeKey
ReadS [DescribeKey]
(Int -> ReadS DescribeKey)
-> ReadS [DescribeKey]
-> ReadPrec DescribeKey
-> ReadPrec [DescribeKey]
-> Read DescribeKey
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeKey]
$creadListPrec :: ReadPrec [DescribeKey]
readPrec :: ReadPrec DescribeKey
$creadPrec :: ReadPrec DescribeKey
readList :: ReadS [DescribeKey]
$creadList :: ReadS [DescribeKey]
readsPrec :: Int -> ReadS DescribeKey
$creadsPrec :: Int -> ReadS DescribeKey
Prelude.Read, Int -> DescribeKey -> ShowS
[DescribeKey] -> ShowS
DescribeKey -> String
(Int -> DescribeKey -> ShowS)
-> (DescribeKey -> String)
-> ([DescribeKey] -> ShowS)
-> Show DescribeKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeKey] -> ShowS
$cshowList :: [DescribeKey] -> ShowS
show :: DescribeKey -> String
$cshow :: DescribeKey -> String
showsPrec :: Int -> DescribeKey -> ShowS
$cshowsPrec :: Int -> DescribeKey -> ShowS
Prelude.Show, (forall x. DescribeKey -> Rep DescribeKey x)
-> (forall x. Rep DescribeKey x -> DescribeKey)
-> Generic DescribeKey
forall x. Rep DescribeKey x -> DescribeKey
forall x. DescribeKey -> Rep DescribeKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeKey x -> DescribeKey
$cfrom :: forall x. DescribeKey -> Rep DescribeKey x
Prelude.Generic)
newDescribeKey ::
Prelude.Text ->
DescribeKey
newDescribeKey :: Text -> DescribeKey
newDescribeKey Text
pKeyId_ =
DescribeKey' :: Maybe [Text] -> Text -> DescribeKey
DescribeKey'
{ $sel:grantTokens:DescribeKey' :: Maybe [Text]
grantTokens = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
$sel:keyId:DescribeKey' :: Text
keyId = Text
pKeyId_
}
describeKey_grantTokens :: Lens.Lens' DescribeKey (Prelude.Maybe [Prelude.Text])
describeKey_grantTokens :: (Maybe [Text] -> f (Maybe [Text])) -> DescribeKey -> f DescribeKey
describeKey_grantTokens = (DescribeKey -> Maybe [Text])
-> (DescribeKey -> Maybe [Text] -> DescribeKey)
-> Lens DescribeKey DescribeKey (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeKey' {Maybe [Text]
grantTokens :: Maybe [Text]
$sel:grantTokens:DescribeKey' :: DescribeKey -> Maybe [Text]
grantTokens} -> Maybe [Text]
grantTokens) (\s :: DescribeKey
s@DescribeKey' {} Maybe [Text]
a -> DescribeKey
s {$sel:grantTokens:DescribeKey' :: Maybe [Text]
grantTokens = Maybe [Text]
a} :: DescribeKey) ((Maybe [Text] -> f (Maybe [Text]))
-> DescribeKey -> f DescribeKey)
-> ((Maybe [Text] -> f (Maybe [Text]))
-> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeKey
-> f DescribeKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
describeKey_keyId :: Lens.Lens' DescribeKey Prelude.Text
describeKey_keyId :: (Text -> f Text) -> DescribeKey -> f DescribeKey
describeKey_keyId = (DescribeKey -> Text)
-> (DescribeKey -> Text -> DescribeKey)
-> Lens DescribeKey DescribeKey Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeKey' {Text
keyId :: Text
$sel:keyId:DescribeKey' :: DescribeKey -> Text
keyId} -> Text
keyId) (\s :: DescribeKey
s@DescribeKey' {} Text
a -> DescribeKey
s {$sel:keyId:DescribeKey' :: Text
keyId = Text
a} :: DescribeKey)
instance Core.AWSRequest DescribeKey where
type AWSResponse DescribeKey = DescribeKeyResponse
request :: DescribeKey -> Request DescribeKey
request = Service -> DescribeKey -> Request DescribeKey
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy DescribeKey
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeKey)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse DescribeKey))
-> Logger
-> Service
-> Proxy DescribeKey
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeKey)))
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 ->
Maybe KeyMetadata -> Int -> DescribeKeyResponse
DescribeKeyResponse'
(Maybe KeyMetadata -> Int -> DescribeKeyResponse)
-> Either String (Maybe KeyMetadata)
-> Either String (Int -> DescribeKeyResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe KeyMetadata)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"KeyMetadata")
Either String (Int -> DescribeKeyResponse)
-> Either String Int -> Either String DescribeKeyResponse
forall (f :: * -> *) a b. Applicative f => 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))
)
instance Prelude.Hashable DescribeKey
instance Prelude.NFData DescribeKey
instance Core.ToHeaders DescribeKey where
toHeaders :: DescribeKey -> ResponseHeaders
toHeaders =
ResponseHeaders -> DescribeKey -> 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.DescribeKey" :: 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 DescribeKey where
toJSON :: DescribeKey -> Value
toJSON DescribeKey' {Maybe [Text]
Text
keyId :: Text
grantTokens :: Maybe [Text]
$sel:keyId:DescribeKey' :: DescribeKey -> Text
$sel:grantTokens:DescribeKey' :: DescribeKey -> Maybe [Text]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"GrantTokens" 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]
grantTokens,
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 DescribeKey where
toPath :: DescribeKey -> ByteString
toPath = ByteString -> DescribeKey -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery DescribeKey where
toQuery :: DescribeKey -> QueryString
toQuery = QueryString -> DescribeKey -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data DescribeKeyResponse = DescribeKeyResponse'
{
DescribeKeyResponse -> Maybe KeyMetadata
keyMetadata :: Prelude.Maybe KeyMetadata,
DescribeKeyResponse -> Int
httpStatus :: Prelude.Int
}
deriving (DescribeKeyResponse -> DescribeKeyResponse -> Bool
(DescribeKeyResponse -> DescribeKeyResponse -> Bool)
-> (DescribeKeyResponse -> DescribeKeyResponse -> Bool)
-> Eq DescribeKeyResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeKeyResponse -> DescribeKeyResponse -> Bool
$c/= :: DescribeKeyResponse -> DescribeKeyResponse -> Bool
== :: DescribeKeyResponse -> DescribeKeyResponse -> Bool
$c== :: DescribeKeyResponse -> DescribeKeyResponse -> Bool
Prelude.Eq, ReadPrec [DescribeKeyResponse]
ReadPrec DescribeKeyResponse
Int -> ReadS DescribeKeyResponse
ReadS [DescribeKeyResponse]
(Int -> ReadS DescribeKeyResponse)
-> ReadS [DescribeKeyResponse]
-> ReadPrec DescribeKeyResponse
-> ReadPrec [DescribeKeyResponse]
-> Read DescribeKeyResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeKeyResponse]
$creadListPrec :: ReadPrec [DescribeKeyResponse]
readPrec :: ReadPrec DescribeKeyResponse
$creadPrec :: ReadPrec DescribeKeyResponse
readList :: ReadS [DescribeKeyResponse]
$creadList :: ReadS [DescribeKeyResponse]
readsPrec :: Int -> ReadS DescribeKeyResponse
$creadsPrec :: Int -> ReadS DescribeKeyResponse
Prelude.Read, Int -> DescribeKeyResponse -> ShowS
[DescribeKeyResponse] -> ShowS
DescribeKeyResponse -> String
(Int -> DescribeKeyResponse -> ShowS)
-> (DescribeKeyResponse -> String)
-> ([DescribeKeyResponse] -> ShowS)
-> Show DescribeKeyResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeKeyResponse] -> ShowS
$cshowList :: [DescribeKeyResponse] -> ShowS
show :: DescribeKeyResponse -> String
$cshow :: DescribeKeyResponse -> String
showsPrec :: Int -> DescribeKeyResponse -> ShowS
$cshowsPrec :: Int -> DescribeKeyResponse -> ShowS
Prelude.Show, (forall x. DescribeKeyResponse -> Rep DescribeKeyResponse x)
-> (forall x. Rep DescribeKeyResponse x -> DescribeKeyResponse)
-> Generic DescribeKeyResponse
forall x. Rep DescribeKeyResponse x -> DescribeKeyResponse
forall x. DescribeKeyResponse -> Rep DescribeKeyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeKeyResponse x -> DescribeKeyResponse
$cfrom :: forall x. DescribeKeyResponse -> Rep DescribeKeyResponse x
Prelude.Generic)
newDescribeKeyResponse ::
Prelude.Int ->
DescribeKeyResponse
newDescribeKeyResponse :: Int -> DescribeKeyResponse
newDescribeKeyResponse Int
pHttpStatus_ =
DescribeKeyResponse' :: Maybe KeyMetadata -> Int -> DescribeKeyResponse
DescribeKeyResponse'
{ $sel:keyMetadata:DescribeKeyResponse' :: Maybe KeyMetadata
keyMetadata = Maybe KeyMetadata
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:DescribeKeyResponse' :: Int
httpStatus = Int
pHttpStatus_
}
describeKeyResponse_keyMetadata :: Lens.Lens' DescribeKeyResponse (Prelude.Maybe KeyMetadata)
describeKeyResponse_keyMetadata :: (Maybe KeyMetadata -> f (Maybe KeyMetadata))
-> DescribeKeyResponse -> f DescribeKeyResponse
describeKeyResponse_keyMetadata = (DescribeKeyResponse -> Maybe KeyMetadata)
-> (DescribeKeyResponse
-> Maybe KeyMetadata -> DescribeKeyResponse)
-> Lens
DescribeKeyResponse
DescribeKeyResponse
(Maybe KeyMetadata)
(Maybe KeyMetadata)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeKeyResponse' {Maybe KeyMetadata
keyMetadata :: Maybe KeyMetadata
$sel:keyMetadata:DescribeKeyResponse' :: DescribeKeyResponse -> Maybe KeyMetadata
keyMetadata} -> Maybe KeyMetadata
keyMetadata) (\s :: DescribeKeyResponse
s@DescribeKeyResponse' {} Maybe KeyMetadata
a -> DescribeKeyResponse
s {$sel:keyMetadata:DescribeKeyResponse' :: Maybe KeyMetadata
keyMetadata = Maybe KeyMetadata
a} :: DescribeKeyResponse)
describeKeyResponse_httpStatus :: Lens.Lens' DescribeKeyResponse Prelude.Int
describeKeyResponse_httpStatus :: (Int -> f Int) -> DescribeKeyResponse -> f DescribeKeyResponse
describeKeyResponse_httpStatus = (DescribeKeyResponse -> Int)
-> (DescribeKeyResponse -> Int -> DescribeKeyResponse)
-> Lens DescribeKeyResponse DescribeKeyResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeKeyResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeKeyResponse' :: DescribeKeyResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeKeyResponse
s@DescribeKeyResponse' {} Int
a -> DescribeKeyResponse
s {$sel:httpStatus:DescribeKeyResponse' :: Int
httpStatus = Int
a} :: DescribeKeyResponse)
instance Prelude.NFData DescribeKeyResponse