{-# 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.LicenseManager.GetAccessToken
(
GetAccessToken (..),
newGetAccessToken,
getAccessToken_tokenProperties,
getAccessToken_token,
GetAccessTokenResponse (..),
newGetAccessTokenResponse,
getAccessTokenResponse_accessToken,
getAccessTokenResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LicenseManager.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data GetAccessToken = GetAccessToken'
{
GetAccessToken -> Maybe [Text]
tokenProperties :: Prelude.Maybe [Prelude.Text],
GetAccessToken -> Text
token :: Prelude.Text
}
deriving (GetAccessToken -> GetAccessToken -> Bool
(GetAccessToken -> GetAccessToken -> Bool)
-> (GetAccessToken -> GetAccessToken -> Bool) -> Eq GetAccessToken
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAccessToken -> GetAccessToken -> Bool
$c/= :: GetAccessToken -> GetAccessToken -> Bool
== :: GetAccessToken -> GetAccessToken -> Bool
$c== :: GetAccessToken -> GetAccessToken -> Bool
Prelude.Eq, ReadPrec [GetAccessToken]
ReadPrec GetAccessToken
Int -> ReadS GetAccessToken
ReadS [GetAccessToken]
(Int -> ReadS GetAccessToken)
-> ReadS [GetAccessToken]
-> ReadPrec GetAccessToken
-> ReadPrec [GetAccessToken]
-> Read GetAccessToken
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAccessToken]
$creadListPrec :: ReadPrec [GetAccessToken]
readPrec :: ReadPrec GetAccessToken
$creadPrec :: ReadPrec GetAccessToken
readList :: ReadS [GetAccessToken]
$creadList :: ReadS [GetAccessToken]
readsPrec :: Int -> ReadS GetAccessToken
$creadsPrec :: Int -> ReadS GetAccessToken
Prelude.Read, Int -> GetAccessToken -> ShowS
[GetAccessToken] -> ShowS
GetAccessToken -> String
(Int -> GetAccessToken -> ShowS)
-> (GetAccessToken -> String)
-> ([GetAccessToken] -> ShowS)
-> Show GetAccessToken
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAccessToken] -> ShowS
$cshowList :: [GetAccessToken] -> ShowS
show :: GetAccessToken -> String
$cshow :: GetAccessToken -> String
showsPrec :: Int -> GetAccessToken -> ShowS
$cshowsPrec :: Int -> GetAccessToken -> ShowS
Prelude.Show, (forall x. GetAccessToken -> Rep GetAccessToken x)
-> (forall x. Rep GetAccessToken x -> GetAccessToken)
-> Generic GetAccessToken
forall x. Rep GetAccessToken x -> GetAccessToken
forall x. GetAccessToken -> Rep GetAccessToken x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetAccessToken x -> GetAccessToken
$cfrom :: forall x. GetAccessToken -> Rep GetAccessToken x
Prelude.Generic)
newGetAccessToken ::
Prelude.Text ->
GetAccessToken
newGetAccessToken :: Text -> GetAccessToken
newGetAccessToken Text
pToken_ =
GetAccessToken' :: Maybe [Text] -> Text -> GetAccessToken
GetAccessToken'
{ $sel:tokenProperties:GetAccessToken' :: Maybe [Text]
tokenProperties = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
$sel:token:GetAccessToken' :: Text
token = Text
pToken_
}
getAccessToken_tokenProperties :: Lens.Lens' GetAccessToken (Prelude.Maybe [Prelude.Text])
getAccessToken_tokenProperties :: (Maybe [Text] -> f (Maybe [Text]))
-> GetAccessToken -> f GetAccessToken
getAccessToken_tokenProperties = (GetAccessToken -> Maybe [Text])
-> (GetAccessToken -> Maybe [Text] -> GetAccessToken)
-> Lens GetAccessToken GetAccessToken (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAccessToken' {Maybe [Text]
tokenProperties :: Maybe [Text]
$sel:tokenProperties:GetAccessToken' :: GetAccessToken -> Maybe [Text]
tokenProperties} -> Maybe [Text]
tokenProperties) (\s :: GetAccessToken
s@GetAccessToken' {} Maybe [Text]
a -> GetAccessToken
s {$sel:tokenProperties:GetAccessToken' :: Maybe [Text]
tokenProperties = Maybe [Text]
a} :: GetAccessToken) ((Maybe [Text] -> f (Maybe [Text]))
-> GetAccessToken -> f GetAccessToken)
-> ((Maybe [Text] -> f (Maybe [Text]))
-> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> GetAccessToken
-> f GetAccessToken
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
getAccessToken_token :: Lens.Lens' GetAccessToken Prelude.Text
getAccessToken_token :: (Text -> f Text) -> GetAccessToken -> f GetAccessToken
getAccessToken_token = (GetAccessToken -> Text)
-> (GetAccessToken -> Text -> GetAccessToken)
-> Lens GetAccessToken GetAccessToken Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAccessToken' {Text
token :: Text
$sel:token:GetAccessToken' :: GetAccessToken -> Text
token} -> Text
token) (\s :: GetAccessToken
s@GetAccessToken' {} Text
a -> GetAccessToken
s {$sel:token:GetAccessToken' :: Text
token = Text
a} :: GetAccessToken)
instance Core.AWSRequest GetAccessToken where
type
AWSResponse GetAccessToken =
GetAccessTokenResponse
request :: GetAccessToken -> Request GetAccessToken
request = Service -> GetAccessToken -> Request GetAccessToken
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetAccessToken
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAccessToken)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetAccessToken))
-> Logger
-> Service
-> Proxy GetAccessToken
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetAccessToken)))
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 Text -> Int -> GetAccessTokenResponse
GetAccessTokenResponse'
(Maybe Text -> Int -> GetAccessTokenResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetAccessTokenResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"AccessToken")
Either String (Int -> GetAccessTokenResponse)
-> Either String Int -> Either String GetAccessTokenResponse
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 GetAccessToken
instance Prelude.NFData GetAccessToken
instance Core.ToHeaders GetAccessToken where
toHeaders :: GetAccessToken -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetAccessToken -> 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
"AWSLicenseManager.GetAccessToken" ::
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 GetAccessToken where
toJSON :: GetAccessToken -> Value
toJSON GetAccessToken' {Maybe [Text]
Text
token :: Text
tokenProperties :: Maybe [Text]
$sel:token:GetAccessToken' :: GetAccessToken -> Text
$sel:tokenProperties:GetAccessToken' :: GetAccessToken -> Maybe [Text]
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"TokenProperties" 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]
tokenProperties,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Token" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
token)
]
)
instance Core.ToPath GetAccessToken where
toPath :: GetAccessToken -> ByteString
toPath = ByteString -> GetAccessToken -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetAccessToken where
toQuery :: GetAccessToken -> QueryString
toQuery = QueryString -> GetAccessToken -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetAccessTokenResponse = GetAccessTokenResponse'
{
GetAccessTokenResponse -> Maybe Text
accessToken :: Prelude.Maybe Prelude.Text,
GetAccessTokenResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetAccessTokenResponse -> GetAccessTokenResponse -> Bool
(GetAccessTokenResponse -> GetAccessTokenResponse -> Bool)
-> (GetAccessTokenResponse -> GetAccessTokenResponse -> Bool)
-> Eq GetAccessTokenResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAccessTokenResponse -> GetAccessTokenResponse -> Bool
$c/= :: GetAccessTokenResponse -> GetAccessTokenResponse -> Bool
== :: GetAccessTokenResponse -> GetAccessTokenResponse -> Bool
$c== :: GetAccessTokenResponse -> GetAccessTokenResponse -> Bool
Prelude.Eq, ReadPrec [GetAccessTokenResponse]
ReadPrec GetAccessTokenResponse
Int -> ReadS GetAccessTokenResponse
ReadS [GetAccessTokenResponse]
(Int -> ReadS GetAccessTokenResponse)
-> ReadS [GetAccessTokenResponse]
-> ReadPrec GetAccessTokenResponse
-> ReadPrec [GetAccessTokenResponse]
-> Read GetAccessTokenResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAccessTokenResponse]
$creadListPrec :: ReadPrec [GetAccessTokenResponse]
readPrec :: ReadPrec GetAccessTokenResponse
$creadPrec :: ReadPrec GetAccessTokenResponse
readList :: ReadS [GetAccessTokenResponse]
$creadList :: ReadS [GetAccessTokenResponse]
readsPrec :: Int -> ReadS GetAccessTokenResponse
$creadsPrec :: Int -> ReadS GetAccessTokenResponse
Prelude.Read, Int -> GetAccessTokenResponse -> ShowS
[GetAccessTokenResponse] -> ShowS
GetAccessTokenResponse -> String
(Int -> GetAccessTokenResponse -> ShowS)
-> (GetAccessTokenResponse -> String)
-> ([GetAccessTokenResponse] -> ShowS)
-> Show GetAccessTokenResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAccessTokenResponse] -> ShowS
$cshowList :: [GetAccessTokenResponse] -> ShowS
show :: GetAccessTokenResponse -> String
$cshow :: GetAccessTokenResponse -> String
showsPrec :: Int -> GetAccessTokenResponse -> ShowS
$cshowsPrec :: Int -> GetAccessTokenResponse -> ShowS
Prelude.Show, (forall x. GetAccessTokenResponse -> Rep GetAccessTokenResponse x)
-> (forall x.
Rep GetAccessTokenResponse x -> GetAccessTokenResponse)
-> Generic GetAccessTokenResponse
forall x. Rep GetAccessTokenResponse x -> GetAccessTokenResponse
forall x. GetAccessTokenResponse -> Rep GetAccessTokenResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetAccessTokenResponse x -> GetAccessTokenResponse
$cfrom :: forall x. GetAccessTokenResponse -> Rep GetAccessTokenResponse x
Prelude.Generic)
newGetAccessTokenResponse ::
Prelude.Int ->
GetAccessTokenResponse
newGetAccessTokenResponse :: Int -> GetAccessTokenResponse
newGetAccessTokenResponse Int
pHttpStatus_ =
GetAccessTokenResponse' :: Maybe Text -> Int -> GetAccessTokenResponse
GetAccessTokenResponse'
{ $sel:accessToken:GetAccessTokenResponse' :: Maybe Text
accessToken =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetAccessTokenResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getAccessTokenResponse_accessToken :: Lens.Lens' GetAccessTokenResponse (Prelude.Maybe Prelude.Text)
getAccessTokenResponse_accessToken :: (Maybe Text -> f (Maybe Text))
-> GetAccessTokenResponse -> f GetAccessTokenResponse
getAccessTokenResponse_accessToken = (GetAccessTokenResponse -> Maybe Text)
-> (GetAccessTokenResponse -> Maybe Text -> GetAccessTokenResponse)
-> Lens
GetAccessTokenResponse
GetAccessTokenResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAccessTokenResponse' {Maybe Text
accessToken :: Maybe Text
$sel:accessToken:GetAccessTokenResponse' :: GetAccessTokenResponse -> Maybe Text
accessToken} -> Maybe Text
accessToken) (\s :: GetAccessTokenResponse
s@GetAccessTokenResponse' {} Maybe Text
a -> GetAccessTokenResponse
s {$sel:accessToken:GetAccessTokenResponse' :: Maybe Text
accessToken = Maybe Text
a} :: GetAccessTokenResponse)
getAccessTokenResponse_httpStatus :: Lens.Lens' GetAccessTokenResponse Prelude.Int
getAccessTokenResponse_httpStatus :: (Int -> f Int)
-> GetAccessTokenResponse -> f GetAccessTokenResponse
getAccessTokenResponse_httpStatus = (GetAccessTokenResponse -> Int)
-> (GetAccessTokenResponse -> Int -> GetAccessTokenResponse)
-> Lens GetAccessTokenResponse GetAccessTokenResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAccessTokenResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetAccessTokenResponse' :: GetAccessTokenResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetAccessTokenResponse
s@GetAccessTokenResponse' {} Int
a -> GetAccessTokenResponse
s {$sel:httpStatus:GetAccessTokenResponse' :: Int
httpStatus = Int
a} :: GetAccessTokenResponse)
instance Prelude.NFData GetAccessTokenResponse