{-# 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.ECR.GetAuthorizationToken
(
GetAuthorizationToken (..),
newGetAuthorizationToken,
getAuthorizationToken_registryIds,
GetAuthorizationTokenResponse (..),
newGetAuthorizationTokenResponse,
getAuthorizationTokenResponse_authorizationData,
getAuthorizationTokenResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import Amazonka.ECR.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 GetAuthorizationToken = GetAuthorizationToken'
{
GetAuthorizationToken -> Maybe (NonEmpty Text)
registryIds :: Prelude.Maybe (Prelude.NonEmpty 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 ::
GetAuthorizationToken
newGetAuthorizationToken :: GetAuthorizationToken
newGetAuthorizationToken =
GetAuthorizationToken' :: Maybe (NonEmpty Text) -> GetAuthorizationToken
GetAuthorizationToken'
{ $sel:registryIds:GetAuthorizationToken' :: Maybe (NonEmpty Text)
registryIds =
Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing
}
getAuthorizationToken_registryIds :: Lens.Lens' GetAuthorizationToken (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
getAuthorizationToken_registryIds :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> GetAuthorizationToken -> f GetAuthorizationToken
getAuthorizationToken_registryIds = (GetAuthorizationToken -> Maybe (NonEmpty Text))
-> (GetAuthorizationToken
-> Maybe (NonEmpty Text) -> GetAuthorizationToken)
-> Lens
GetAuthorizationToken
GetAuthorizationToken
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAuthorizationToken' {Maybe (NonEmpty Text)
registryIds :: Maybe (NonEmpty Text)
$sel:registryIds:GetAuthorizationToken' :: GetAuthorizationToken -> Maybe (NonEmpty Text)
registryIds} -> Maybe (NonEmpty Text)
registryIds) (\s :: GetAuthorizationToken
s@GetAuthorizationToken' {} Maybe (NonEmpty Text)
a -> GetAuthorizationToken
s {$sel:registryIds:GetAuthorizationToken' :: Maybe (NonEmpty Text)
registryIds = Maybe (NonEmpty Text)
a} :: GetAuthorizationToken) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> GetAuthorizationToken -> f GetAuthorizationToken)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> GetAuthorizationToken
-> f GetAuthorizationToken
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
(NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
(Maybe (NonEmpty Text))
(Maybe (NonEmpty 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
(NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
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 [AuthorizationData] -> Int -> GetAuthorizationTokenResponse
GetAuthorizationTokenResponse'
(Maybe [AuthorizationData] -> Int -> GetAuthorizationTokenResponse)
-> Either String (Maybe [AuthorizationData])
-> Either String (Int -> GetAuthorizationTokenResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Either String (Maybe (Maybe [AuthorizationData]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"authorizationData"
Either String (Maybe (Maybe [AuthorizationData]))
-> Maybe [AuthorizationData]
-> Either String (Maybe [AuthorizationData])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [AuthorizationData]
forall a. Monoid a => a
Prelude.mempty
)
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
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AmazonEC2ContainerRegistry_V20150921.GetAuthorizationToken" ::
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 GetAuthorizationToken where
toJSON :: GetAuthorizationToken -> Value
toJSON GetAuthorizationToken' {Maybe (NonEmpty Text)
registryIds :: Maybe (NonEmpty Text)
$sel:registryIds:GetAuthorizationToken' :: GetAuthorizationToken -> Maybe (NonEmpty Text)
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[(Text
"registryIds" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (NonEmpty Text -> Pair) -> Maybe (NonEmpty Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty Text)
registryIds]
)
instance Core.ToPath GetAuthorizationToken where
toPath :: GetAuthorizationToken -> ByteString
toPath = ByteString -> GetAuthorizationToken -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery GetAuthorizationToken where
toQuery :: GetAuthorizationToken -> QueryString
toQuery = QueryString -> GetAuthorizationToken -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data GetAuthorizationTokenResponse = GetAuthorizationTokenResponse'
{
GetAuthorizationTokenResponse -> Maybe [AuthorizationData]
authorizationData :: Prelude.Maybe [AuthorizationData],
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 [AuthorizationData] -> Int -> GetAuthorizationTokenResponse
GetAuthorizationTokenResponse'
{ $sel:authorizationData:GetAuthorizationTokenResponse' :: Maybe [AuthorizationData]
authorizationData =
Maybe [AuthorizationData]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:GetAuthorizationTokenResponse' :: Int
httpStatus = Int
pHttpStatus_
}
getAuthorizationTokenResponse_authorizationData :: Lens.Lens' GetAuthorizationTokenResponse (Prelude.Maybe [AuthorizationData])
getAuthorizationTokenResponse_authorizationData :: (Maybe [AuthorizationData] -> f (Maybe [AuthorizationData]))
-> GetAuthorizationTokenResponse -> f GetAuthorizationTokenResponse
getAuthorizationTokenResponse_authorizationData = (GetAuthorizationTokenResponse -> Maybe [AuthorizationData])
-> (GetAuthorizationTokenResponse
-> Maybe [AuthorizationData] -> GetAuthorizationTokenResponse)
-> Lens
GetAuthorizationTokenResponse
GetAuthorizationTokenResponse
(Maybe [AuthorizationData])
(Maybe [AuthorizationData])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetAuthorizationTokenResponse' {Maybe [AuthorizationData]
authorizationData :: Maybe [AuthorizationData]
$sel:authorizationData:GetAuthorizationTokenResponse' :: GetAuthorizationTokenResponse -> Maybe [AuthorizationData]
authorizationData} -> Maybe [AuthorizationData]
authorizationData) (\s :: GetAuthorizationTokenResponse
s@GetAuthorizationTokenResponse' {} Maybe [AuthorizationData]
a -> GetAuthorizationTokenResponse
s {$sel:authorizationData:GetAuthorizationTokenResponse' :: Maybe [AuthorizationData]
authorizationData = Maybe [AuthorizationData]
a} :: GetAuthorizationTokenResponse) ((Maybe [AuthorizationData] -> f (Maybe [AuthorizationData]))
-> GetAuthorizationTokenResponse
-> f GetAuthorizationTokenResponse)
-> ((Maybe [AuthorizationData] -> f (Maybe [AuthorizationData]))
-> Maybe [AuthorizationData] -> f (Maybe [AuthorizationData]))
-> (Maybe [AuthorizationData] -> f (Maybe [AuthorizationData]))
-> GetAuthorizationTokenResponse
-> f GetAuthorizationTokenResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[AuthorizationData]
[AuthorizationData]
[AuthorizationData]
[AuthorizationData]
-> Iso
(Maybe [AuthorizationData])
(Maybe [AuthorizationData])
(Maybe [AuthorizationData])
(Maybe [AuthorizationData])
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
[AuthorizationData]
[AuthorizationData]
[AuthorizationData]
[AuthorizationData]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
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