{-# 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.CodeArtifact.GetAuthorizationToken
(
GetAuthorizationToken (..),
newGetAuthorizationToken,
getAuthorizationToken_domainOwner,
getAuthorizationToken_durationSeconds,
getAuthorizationToken_domain,
GetAuthorizationTokenResponse (..),
newGetAuthorizationTokenResponse,
getAuthorizationTokenResponse_expiration,
getAuthorizationTokenResponse_authorizationToken,
getAuthorizationTokenResponse_httpStatus,
)
where
import Amazonka.CodeArtifact.Types
import qualified Amazonka.Core as Core
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 GetAuthorizationToken = GetAuthorizationToken'
{
GetAuthorizationToken -> Maybe Text
domainOwner :: Prelude.Maybe Prelude.Text,
GetAuthorizationToken -> Maybe Natural
durationSeconds :: Prelude.Maybe Prelude.Natural,
GetAuthorizationToken -> Text
domain :: Prelude.Text
}
deriving (GetAuthorizationToken -> GetAuthorizationToken -> Bool
(GetAuthorizationToken -> GetAuthorizationToken -> Bool)
-> (GetAuthorizationToken -> GetAuthorizationToken -> Bool)
-> Eq GetAuthorizationToken
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAuthorizationToken -> GetAuthorizationToken -> Bool
$c/= :: GetAuthorizationToken -> GetAuthorizationToken -> Bool
== :: GetAuthorizationToken -> GetAuthorizationToken -> Bool
$c== :: GetAuthorizationToken -> GetAuthorizationToken -> Bool
Prelude.Eq, ReadPrec [GetAuthorizationToken]
ReadPrec GetAuthorizationToken
Int -> ReadS GetAuthorizationToken
ReadS [GetAuthorizationToken]
(Int -> ReadS GetAuthorizationToken)
-> ReadS [GetAuthorizationToken]
-> ReadPrec GetAuthorizationToken
-> ReadPrec [GetAuthorizationToken]
-> Read GetAuthorizationToken
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAuthorizationToken]
$creadListPrec :: ReadPrec [GetAuthorizationToken]
readPrec :: ReadPrec GetAuthorizationToken
$creadPrec :: ReadPrec GetAuthorizationToken
readList :: ReadS [GetAuthorizationToken]
$creadList :: ReadS [GetAuthorizationToken]
readsPrec :: Int -> ReadS GetAuthorizationToken
$creadsPrec :: Int -> ReadS GetAuthorizationToken
Prelude.Read, Int -> GetAuthorizationToken -> ShowS
[GetAuthorizationToken] -> ShowS
GetAuthorizationToken -> String
(Int -> GetAuthorizationToken -> ShowS)
-> (GetAuthorizationToken -> String)
-> ([GetAuthorizationToken] -> ShowS)
-> Show GetAuthorizationToken
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAuthorizationToken] -> ShowS
$cshowList :: [GetAuthorizationToken] -> ShowS
show :: GetAuthorizationToken -> String
$cshow :: GetAuthorizationToken -> String
showsPrec :: Int -> GetAuthorizationToken -> ShowS
$cshowsPrec :: Int -> GetAuthorizationToken -> ShowS
Prelude.Show, (forall x. GetAuthorizationToken -> Rep GetAuthorizationToken x)
-> (forall x. Rep GetAuthorizationToken x -> GetAuthorizationToken)
-> Generic GetAuthorizationToken
forall x. Rep GetAuthorizationToken x -> GetAuthorizationToken
forall x. GetAuthorizationToken -> Rep GetAuthorizationToken x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetAuthorizationToken x -> GetAuthorizationToken
$cfrom :: forall x. GetAuthorizationToken -> Rep GetAuthorizationToken x
Prelude.Generic)
newGetAuthorizationToken ::
Prelude.Text ->
GetAuthorizationToken
newGetAuthorizationToken :: Text -> GetAuthorizationToken
newGetAuthorizationToken Text
pDomain_ =
GetAuthorizationToken' :: Maybe Text -> Maybe Natural -> Text -> GetAuthorizationToken
GetAuthorizationToken'
{ $sel:domainOwner:GetAuthorizationToken' :: Maybe Text
domainOwner =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:durationSeconds:GetAuthorizationToken' :: Maybe Natural
durationSeconds = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:domain:GetAuthorizationToken' :: Text
domain = Text
pDomain_
}
getAuthorizationToken_domainOwner :: Lens.Lens' GetAuthorizationToken (Prelude.Maybe Prelude.Text)
getAuthorizationToken_domainOwner :: (Maybe Text -> f (Maybe Text))
-> GetAuthorizationToken -> f GetAuthorizationToken
getAuthorizationToken_domainOwner = (GetAuthorizationToken -> Maybe Text)
-> (GetAuthorizationToken -> Maybe Text -> GetAuthorizationToken)
-> Lens
GetAuthorizationToken
GetAuthorizationToken
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAuthorizationToken' {Maybe Text
domainOwner :: Maybe Text
$sel:domainOwner:GetAuthorizationToken' :: GetAuthorizationToken -> Maybe Text
domainOwner} -> Maybe Text
domainOwner) (\s :: GetAuthorizationToken
s@GetAuthorizationToken' {} Maybe Text
a -> GetAuthorizationToken
s {$sel:domainOwner:GetAuthorizationToken' :: Maybe Text
domainOwner = Maybe Text
a} :: GetAuthorizationToken)
getAuthorizationToken_durationSeconds :: Lens.Lens' GetAuthorizationToken (Prelude.Maybe Prelude.Natural)
getAuthorizationToken_durationSeconds :: (Maybe Natural -> f (Maybe Natural))
-> GetAuthorizationToken -> f GetAuthorizationToken
getAuthorizationToken_durationSeconds = (GetAuthorizationToken -> Maybe Natural)
-> (GetAuthorizationToken
-> Maybe Natural -> GetAuthorizationToken)
-> Lens
GetAuthorizationToken
GetAuthorizationToken
(Maybe Natural)
(Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAuthorizationToken' {Maybe Natural
durationSeconds :: Maybe Natural
$sel:durationSeconds:GetAuthorizationToken' :: GetAuthorizationToken -> Maybe Natural
durationSeconds} -> Maybe Natural
durationSeconds) (\s :: GetAuthorizationToken
s@GetAuthorizationToken' {} Maybe Natural
a -> GetAuthorizationToken
s {$sel:durationSeconds:GetAuthorizationToken' :: Maybe Natural
durationSeconds = Maybe Natural
a} :: GetAuthorizationToken)
getAuthorizationToken_domain :: Lens.Lens' GetAuthorizationToken Prelude.Text
getAuthorizationToken_domain :: (Text -> f Text)
-> GetAuthorizationToken -> f GetAuthorizationToken
getAuthorizationToken_domain = (GetAuthorizationToken -> Text)
-> (GetAuthorizationToken -> Text -> GetAuthorizationToken)
-> Lens GetAuthorizationToken GetAuthorizationToken Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAuthorizationToken' {Text
domain :: Text
$sel:domain:GetAuthorizationToken' :: GetAuthorizationToken -> Text
domain} -> Text
domain) (\s :: GetAuthorizationToken
s@GetAuthorizationToken' {} Text
a -> GetAuthorizationToken
s {$sel:domain:GetAuthorizationToken' :: Text
domain = Text
a} :: GetAuthorizationToken)
instance Core.AWSRequest GetAuthorizationToken where
type
AWSResponse GetAuthorizationToken =
GetAuthorizationTokenResponse
request :: GetAuthorizationToken -> Request GetAuthorizationToken
request = Service -> GetAuthorizationToken -> Request GetAuthorizationToken
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy GetAuthorizationToken
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse GetAuthorizationToken)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetAuthorizationToken))
-> Logger
-> Service
-> Proxy GetAuthorizationToken
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse GetAuthorizationToken)))
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 POSIX -> Maybe Text -> Int -> GetAuthorizationTokenResponse
GetAuthorizationTokenResponse'
(Maybe POSIX -> Maybe Text -> Int -> GetAuthorizationTokenResponse)
-> Either String (Maybe POSIX)
-> Either
String (Maybe Text -> Int -> GetAuthorizationTokenResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"expiration")
Either String (Maybe Text -> Int -> GetAuthorizationTokenResponse)
-> Either String (Maybe Text)
-> Either String (Int -> GetAuthorizationTokenResponse)
forall (f :: * -> *) a b. Applicative f => 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
"authorizationToken")
Either String (Int -> GetAuthorizationTokenResponse)
-> Either String Int -> Either String GetAuthorizationTokenResponse
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 GetAuthorizationToken
instance Prelude.NFData GetAuthorizationToken
instance Core.ToHeaders GetAuthorizationToken where
toHeaders :: GetAuthorizationToken -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetAuthorizationToken -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ 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 GetAuthorizationToken where
toJSON :: GetAuthorizationToken -> Value
toJSON = Value -> GetAuthorizationToken -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)
instance Core.ToPath GetAuthorizationToken where
toPath :: GetAuthorizationToken -> ByteString
toPath = ByteString -> GetAuthorizationToken -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/v1/authorization-token"
instance Core.ToQuery GetAuthorizationToken where
toQuery :: GetAuthorizationToken -> QueryString
toQuery GetAuthorizationToken' {Maybe Natural
Maybe Text
Text
domain :: Text
durationSeconds :: Maybe Natural
domainOwner :: Maybe Text
$sel:domain:GetAuthorizationToken' :: GetAuthorizationToken -> Text
$sel:durationSeconds:GetAuthorizationToken' :: GetAuthorizationToken -> Maybe Natural
$sel:domainOwner:GetAuthorizationToken' :: GetAuthorizationToken -> Maybe Text
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"domain-owner" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
domainOwner,
ByteString
"duration" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
durationSeconds,
ByteString
"domain" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
domain
]
data GetAuthorizationTokenResponse = GetAuthorizationTokenResponse'
{
GetAuthorizationTokenResponse -> Maybe POSIX
expiration :: Prelude.Maybe Core.POSIX,
GetAuthorizationTokenResponse -> Maybe Text
authorizationToken :: Prelude.Maybe Prelude.Text,
GetAuthorizationTokenResponse -> Int
httpStatus :: Prelude.Int
}
deriving (GetAuthorizationTokenResponse
-> GetAuthorizationTokenResponse -> Bool
(GetAuthorizationTokenResponse
-> GetAuthorizationTokenResponse -> Bool)
-> (GetAuthorizationTokenResponse
-> GetAuthorizationTokenResponse -> Bool)
-> Eq GetAuthorizationTokenResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetAuthorizationTokenResponse
-> GetAuthorizationTokenResponse -> Bool
$c/= :: GetAuthorizationTokenResponse
-> GetAuthorizationTokenResponse -> Bool
== :: GetAuthorizationTokenResponse
-> GetAuthorizationTokenResponse -> Bool
$c== :: GetAuthorizationTokenResponse
-> GetAuthorizationTokenResponse -> Bool
Prelude.Eq, ReadPrec [GetAuthorizationTokenResponse]
ReadPrec GetAuthorizationTokenResponse
Int -> ReadS GetAuthorizationTokenResponse
ReadS [GetAuthorizationTokenResponse]
(Int -> ReadS GetAuthorizationTokenResponse)
-> ReadS [GetAuthorizationTokenResponse]
-> ReadPrec GetAuthorizationTokenResponse
-> ReadPrec [GetAuthorizationTokenResponse]
-> Read GetAuthorizationTokenResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetAuthorizationTokenResponse]
$creadListPrec :: ReadPrec [GetAuthorizationTokenResponse]
readPrec :: ReadPrec GetAuthorizationTokenResponse
$creadPrec :: ReadPrec GetAuthorizationTokenResponse
readList :: ReadS [GetAuthorizationTokenResponse]
$creadList :: ReadS [GetAuthorizationTokenResponse]
readsPrec :: Int -> ReadS GetAuthorizationTokenResponse
$creadsPrec :: Int -> ReadS GetAuthorizationTokenResponse
Prelude.Read, Int -> GetAuthorizationTokenResponse -> ShowS
[GetAuthorizationTokenResponse] -> ShowS
GetAuthorizationTokenResponse -> String
(Int -> GetAuthorizationTokenResponse -> ShowS)
-> (GetAuthorizationTokenResponse -> String)
-> ([GetAuthorizationTokenResponse] -> ShowS)
-> Show GetAuthorizationTokenResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetAuthorizationTokenResponse] -> ShowS
$cshowList :: [GetAuthorizationTokenResponse] -> ShowS
show :: GetAuthorizationTokenResponse -> String
$cshow :: GetAuthorizationTokenResponse -> String
showsPrec :: Int -> GetAuthorizationTokenResponse -> ShowS
$cshowsPrec :: Int -> GetAuthorizationTokenResponse -> ShowS
Prelude.Show, (forall x.
GetAuthorizationTokenResponse
-> Rep GetAuthorizationTokenResponse x)
-> (forall x.
Rep GetAuthorizationTokenResponse x
-> GetAuthorizationTokenResponse)
-> Generic GetAuthorizationTokenResponse
forall x.
Rep GetAuthorizationTokenResponse x
-> GetAuthorizationTokenResponse
forall x.
GetAuthorizationTokenResponse
-> Rep GetAuthorizationTokenResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetAuthorizationTokenResponse x
-> GetAuthorizationTokenResponse
$cfrom :: forall x.
GetAuthorizationTokenResponse
-> Rep GetAuthorizationTokenResponse x
Prelude.Generic)
newGetAuthorizationTokenResponse ::
Prelude.Int ->
GetAuthorizationTokenResponse
newGetAuthorizationTokenResponse :: Int -> GetAuthorizationTokenResponse
newGetAuthorizationTokenResponse Int
pHttpStatus_ =
GetAuthorizationTokenResponse' :: Maybe POSIX -> Maybe Text -> Int -> GetAuthorizationTokenResponse
GetAuthorizationTokenResponse'
{ $sel:expiration:GetAuthorizationTokenResponse' :: Maybe POSIX
expiration =
Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
$sel:authorizationToken:GetAuthorizationTokenResponse' :: Maybe Text
authorizationToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetAuthorizationTokenResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getAuthorizationTokenResponse_expiration :: Lens.Lens' GetAuthorizationTokenResponse (Prelude.Maybe Prelude.UTCTime)
getAuthorizationTokenResponse_expiration :: (Maybe UTCTime -> f (Maybe UTCTime))
-> GetAuthorizationTokenResponse -> f GetAuthorizationTokenResponse
getAuthorizationTokenResponse_expiration = (GetAuthorizationTokenResponse -> Maybe POSIX)
-> (GetAuthorizationTokenResponse
-> Maybe POSIX -> GetAuthorizationTokenResponse)
-> Lens
GetAuthorizationTokenResponse
GetAuthorizationTokenResponse
(Maybe POSIX)
(Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAuthorizationTokenResponse' {Maybe POSIX
expiration :: Maybe POSIX
$sel:expiration:GetAuthorizationTokenResponse' :: GetAuthorizationTokenResponse -> Maybe POSIX
expiration} -> Maybe POSIX
expiration) (\s :: GetAuthorizationTokenResponse
s@GetAuthorizationTokenResponse' {} Maybe POSIX
a -> GetAuthorizationTokenResponse
s {$sel:expiration:GetAuthorizationTokenResponse' :: Maybe POSIX
expiration = Maybe POSIX
a} :: GetAuthorizationTokenResponse) ((Maybe POSIX -> f (Maybe POSIX))
-> GetAuthorizationTokenResponse
-> f GetAuthorizationTokenResponse)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
-> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> GetAuthorizationTokenResponse
-> f GetAuthorizationTokenResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time
getAuthorizationTokenResponse_authorizationToken :: Lens.Lens' GetAuthorizationTokenResponse (Prelude.Maybe Prelude.Text)
getAuthorizationTokenResponse_authorizationToken :: (Maybe Text -> f (Maybe Text))
-> GetAuthorizationTokenResponse -> f GetAuthorizationTokenResponse
getAuthorizationTokenResponse_authorizationToken = (GetAuthorizationTokenResponse -> Maybe Text)
-> (GetAuthorizationTokenResponse
-> Maybe Text -> GetAuthorizationTokenResponse)
-> Lens
GetAuthorizationTokenResponse
GetAuthorizationTokenResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAuthorizationTokenResponse' {Maybe Text
authorizationToken :: Maybe Text
$sel:authorizationToken:GetAuthorizationTokenResponse' :: GetAuthorizationTokenResponse -> Maybe Text
authorizationToken} -> Maybe Text
authorizationToken) (\s :: GetAuthorizationTokenResponse
s@GetAuthorizationTokenResponse' {} Maybe Text
a -> GetAuthorizationTokenResponse
s {$sel:authorizationToken:GetAuthorizationTokenResponse' :: Maybe Text
authorizationToken = Maybe Text
a} :: GetAuthorizationTokenResponse)
getAuthorizationTokenResponse_httpStatus :: Lens.Lens' GetAuthorizationTokenResponse Prelude.Int
getAuthorizationTokenResponse_httpStatus :: (Int -> f Int)
-> GetAuthorizationTokenResponse -> f GetAuthorizationTokenResponse
getAuthorizationTokenResponse_httpStatus = (GetAuthorizationTokenResponse -> Int)
-> (GetAuthorizationTokenResponse
-> Int -> GetAuthorizationTokenResponse)
-> Lens
GetAuthorizationTokenResponse GetAuthorizationTokenResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAuthorizationTokenResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetAuthorizationTokenResponse' :: GetAuthorizationTokenResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetAuthorizationTokenResponse
s@GetAuthorizationTokenResponse' {} Int
a -> GetAuthorizationTokenResponse
s {$sel:httpStatus:GetAuthorizationTokenResponse' :: Int
httpStatus = Int
a} :: GetAuthorizationTokenResponse)
instance Prelude.NFData GetAuthorizationTokenResponse