{-# 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.InitiateLayerUpload
(
InitiateLayerUpload (..),
newInitiateLayerUpload,
initiateLayerUpload_registryId,
initiateLayerUpload_repositoryName,
InitiateLayerUploadResponse (..),
newInitiateLayerUploadResponse,
initiateLayerUploadResponse_partSize,
initiateLayerUploadResponse_uploadId,
initiateLayerUploadResponse_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 InitiateLayerUpload = InitiateLayerUpload'
{
InitiateLayerUpload -> Maybe Text
registryId :: Prelude.Maybe Prelude.Text,
InitiateLayerUpload -> Text
repositoryName :: Prelude.Text
}
deriving (InitiateLayerUpload -> InitiateLayerUpload -> Bool
(InitiateLayerUpload -> InitiateLayerUpload -> Bool)
-> (InitiateLayerUpload -> InitiateLayerUpload -> Bool)
-> Eq InitiateLayerUpload
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InitiateLayerUpload -> InitiateLayerUpload -> Bool
$c/= :: InitiateLayerUpload -> InitiateLayerUpload -> Bool
== :: InitiateLayerUpload -> InitiateLayerUpload -> Bool
$c== :: InitiateLayerUpload -> InitiateLayerUpload -> Bool
Prelude.Eq, ReadPrec [InitiateLayerUpload]
ReadPrec InitiateLayerUpload
Int -> ReadS InitiateLayerUpload
ReadS [InitiateLayerUpload]
(Int -> ReadS InitiateLayerUpload)
-> ReadS [InitiateLayerUpload]
-> ReadPrec InitiateLayerUpload
-> ReadPrec [InitiateLayerUpload]
-> Read InitiateLayerUpload
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InitiateLayerUpload]
$creadListPrec :: ReadPrec [InitiateLayerUpload]
readPrec :: ReadPrec InitiateLayerUpload
$creadPrec :: ReadPrec InitiateLayerUpload
readList :: ReadS [InitiateLayerUpload]
$creadList :: ReadS [InitiateLayerUpload]
readsPrec :: Int -> ReadS InitiateLayerUpload
$creadsPrec :: Int -> ReadS InitiateLayerUpload
Prelude.Read, Int -> InitiateLayerUpload -> ShowS
[InitiateLayerUpload] -> ShowS
InitiateLayerUpload -> String
(Int -> InitiateLayerUpload -> ShowS)
-> (InitiateLayerUpload -> String)
-> ([InitiateLayerUpload] -> ShowS)
-> Show InitiateLayerUpload
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InitiateLayerUpload] -> ShowS
$cshowList :: [InitiateLayerUpload] -> ShowS
show :: InitiateLayerUpload -> String
$cshow :: InitiateLayerUpload -> String
showsPrec :: Int -> InitiateLayerUpload -> ShowS
$cshowsPrec :: Int -> InitiateLayerUpload -> ShowS
Prelude.Show, (forall x. InitiateLayerUpload -> Rep InitiateLayerUpload x)
-> (forall x. Rep InitiateLayerUpload x -> InitiateLayerUpload)
-> Generic InitiateLayerUpload
forall x. Rep InitiateLayerUpload x -> InitiateLayerUpload
forall x. InitiateLayerUpload -> Rep InitiateLayerUpload x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InitiateLayerUpload x -> InitiateLayerUpload
$cfrom :: forall x. InitiateLayerUpload -> Rep InitiateLayerUpload x
Prelude.Generic)
newInitiateLayerUpload ::
Prelude.Text ->
InitiateLayerUpload
newInitiateLayerUpload :: Text -> InitiateLayerUpload
newInitiateLayerUpload Text
pRepositoryName_ =
InitiateLayerUpload' :: Maybe Text -> Text -> InitiateLayerUpload
InitiateLayerUpload'
{ $sel:registryId:InitiateLayerUpload' :: Maybe Text
registryId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:repositoryName:InitiateLayerUpload' :: Text
repositoryName = Text
pRepositoryName_
}
initiateLayerUpload_registryId :: Lens.Lens' InitiateLayerUpload (Prelude.Maybe Prelude.Text)
initiateLayerUpload_registryId :: (Maybe Text -> f (Maybe Text))
-> InitiateLayerUpload -> f InitiateLayerUpload
initiateLayerUpload_registryId = (InitiateLayerUpload -> Maybe Text)
-> (InitiateLayerUpload -> Maybe Text -> InitiateLayerUpload)
-> Lens
InitiateLayerUpload InitiateLayerUpload (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitiateLayerUpload' {Maybe Text
registryId :: Maybe Text
$sel:registryId:InitiateLayerUpload' :: InitiateLayerUpload -> Maybe Text
registryId} -> Maybe Text
registryId) (\s :: InitiateLayerUpload
s@InitiateLayerUpload' {} Maybe Text
a -> InitiateLayerUpload
s {$sel:registryId:InitiateLayerUpload' :: Maybe Text
registryId = Maybe Text
a} :: InitiateLayerUpload)
initiateLayerUpload_repositoryName :: Lens.Lens' InitiateLayerUpload Prelude.Text
initiateLayerUpload_repositoryName :: (Text -> f Text) -> InitiateLayerUpload -> f InitiateLayerUpload
initiateLayerUpload_repositoryName = (InitiateLayerUpload -> Text)
-> (InitiateLayerUpload -> Text -> InitiateLayerUpload)
-> Lens InitiateLayerUpload InitiateLayerUpload Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitiateLayerUpload' {Text
repositoryName :: Text
$sel:repositoryName:InitiateLayerUpload' :: InitiateLayerUpload -> Text
repositoryName} -> Text
repositoryName) (\s :: InitiateLayerUpload
s@InitiateLayerUpload' {} Text
a -> InitiateLayerUpload
s {$sel:repositoryName:InitiateLayerUpload' :: Text
repositoryName = Text
a} :: InitiateLayerUpload)
instance Core.AWSRequest InitiateLayerUpload where
type
AWSResponse InitiateLayerUpload =
InitiateLayerUploadResponse
request :: InitiateLayerUpload -> Request InitiateLayerUpload
request = Service -> InitiateLayerUpload -> Request InitiateLayerUpload
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy InitiateLayerUpload
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse InitiateLayerUpload)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse InitiateLayerUpload))
-> Logger
-> Service
-> Proxy InitiateLayerUpload
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse InitiateLayerUpload)))
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 Natural -> Maybe Text -> Int -> InitiateLayerUploadResponse
InitiateLayerUploadResponse'
(Maybe Natural -> Maybe Text -> Int -> InitiateLayerUploadResponse)
-> Either String (Maybe Natural)
-> Either String (Maybe Text -> Int -> InitiateLayerUploadResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"partSize")
Either String (Maybe Text -> Int -> InitiateLayerUploadResponse)
-> Either String (Maybe Text)
-> Either String (Int -> InitiateLayerUploadResponse)
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
"uploadId")
Either String (Int -> InitiateLayerUploadResponse)
-> Either String Int -> Either String InitiateLayerUploadResponse
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 InitiateLayerUpload
instance Prelude.NFData InitiateLayerUpload
instance Core.ToHeaders InitiateLayerUpload where
toHeaders :: InitiateLayerUpload -> ResponseHeaders
toHeaders =
ResponseHeaders -> InitiateLayerUpload -> 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.InitiateLayerUpload" ::
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 InitiateLayerUpload where
toJSON :: InitiateLayerUpload -> Value
toJSON InitiateLayerUpload' {Maybe Text
Text
repositoryName :: Text
registryId :: Maybe Text
$sel:repositoryName:InitiateLayerUpload' :: InitiateLayerUpload -> Text
$sel:registryId:InitiateLayerUpload' :: InitiateLayerUpload -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"registryId" 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
registryId,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"repositoryName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
repositoryName)
]
)
instance Core.ToPath InitiateLayerUpload where
toPath :: InitiateLayerUpload -> ByteString
toPath = ByteString -> InitiateLayerUpload -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery InitiateLayerUpload where
toQuery :: InitiateLayerUpload -> QueryString
toQuery = QueryString -> InitiateLayerUpload -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data InitiateLayerUploadResponse = InitiateLayerUploadResponse'
{
InitiateLayerUploadResponse -> Maybe Natural
partSize :: Prelude.Maybe Prelude.Natural,
InitiateLayerUploadResponse -> Maybe Text
uploadId :: Prelude.Maybe Prelude.Text,
InitiateLayerUploadResponse -> Int
httpStatus :: Prelude.Int
}
deriving (InitiateLayerUploadResponse -> InitiateLayerUploadResponse -> Bool
(InitiateLayerUploadResponse
-> InitiateLayerUploadResponse -> Bool)
-> (InitiateLayerUploadResponse
-> InitiateLayerUploadResponse -> Bool)
-> Eq InitiateLayerUploadResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InitiateLayerUploadResponse -> InitiateLayerUploadResponse -> Bool
$c/= :: InitiateLayerUploadResponse -> InitiateLayerUploadResponse -> Bool
== :: InitiateLayerUploadResponse -> InitiateLayerUploadResponse -> Bool
$c== :: InitiateLayerUploadResponse -> InitiateLayerUploadResponse -> Bool
Prelude.Eq, ReadPrec [InitiateLayerUploadResponse]
ReadPrec InitiateLayerUploadResponse
Int -> ReadS InitiateLayerUploadResponse
ReadS [InitiateLayerUploadResponse]
(Int -> ReadS InitiateLayerUploadResponse)
-> ReadS [InitiateLayerUploadResponse]
-> ReadPrec InitiateLayerUploadResponse
-> ReadPrec [InitiateLayerUploadResponse]
-> Read InitiateLayerUploadResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InitiateLayerUploadResponse]
$creadListPrec :: ReadPrec [InitiateLayerUploadResponse]
readPrec :: ReadPrec InitiateLayerUploadResponse
$creadPrec :: ReadPrec InitiateLayerUploadResponse
readList :: ReadS [InitiateLayerUploadResponse]
$creadList :: ReadS [InitiateLayerUploadResponse]
readsPrec :: Int -> ReadS InitiateLayerUploadResponse
$creadsPrec :: Int -> ReadS InitiateLayerUploadResponse
Prelude.Read, Int -> InitiateLayerUploadResponse -> ShowS
[InitiateLayerUploadResponse] -> ShowS
InitiateLayerUploadResponse -> String
(Int -> InitiateLayerUploadResponse -> ShowS)
-> (InitiateLayerUploadResponse -> String)
-> ([InitiateLayerUploadResponse] -> ShowS)
-> Show InitiateLayerUploadResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InitiateLayerUploadResponse] -> ShowS
$cshowList :: [InitiateLayerUploadResponse] -> ShowS
show :: InitiateLayerUploadResponse -> String
$cshow :: InitiateLayerUploadResponse -> String
showsPrec :: Int -> InitiateLayerUploadResponse -> ShowS
$cshowsPrec :: Int -> InitiateLayerUploadResponse -> ShowS
Prelude.Show, (forall x.
InitiateLayerUploadResponse -> Rep InitiateLayerUploadResponse x)
-> (forall x.
Rep InitiateLayerUploadResponse x -> InitiateLayerUploadResponse)
-> Generic InitiateLayerUploadResponse
forall x.
Rep InitiateLayerUploadResponse x -> InitiateLayerUploadResponse
forall x.
InitiateLayerUploadResponse -> Rep InitiateLayerUploadResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InitiateLayerUploadResponse x -> InitiateLayerUploadResponse
$cfrom :: forall x.
InitiateLayerUploadResponse -> Rep InitiateLayerUploadResponse x
Prelude.Generic)
newInitiateLayerUploadResponse ::
Prelude.Int ->
InitiateLayerUploadResponse
newInitiateLayerUploadResponse :: Int -> InitiateLayerUploadResponse
newInitiateLayerUploadResponse Int
pHttpStatus_ =
InitiateLayerUploadResponse' :: Maybe Natural -> Maybe Text -> Int -> InitiateLayerUploadResponse
InitiateLayerUploadResponse'
{ $sel:partSize:InitiateLayerUploadResponse' :: Maybe Natural
partSize =
Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:uploadId:InitiateLayerUploadResponse' :: Maybe Text
uploadId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:InitiateLayerUploadResponse' :: Int
httpStatus = Int
pHttpStatus_
}
initiateLayerUploadResponse_partSize :: Lens.Lens' InitiateLayerUploadResponse (Prelude.Maybe Prelude.Natural)
initiateLayerUploadResponse_partSize :: (Maybe Natural -> f (Maybe Natural))
-> InitiateLayerUploadResponse -> f InitiateLayerUploadResponse
initiateLayerUploadResponse_partSize = (InitiateLayerUploadResponse -> Maybe Natural)
-> (InitiateLayerUploadResponse
-> Maybe Natural -> InitiateLayerUploadResponse)
-> Lens
InitiateLayerUploadResponse
InitiateLayerUploadResponse
(Maybe Natural)
(Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitiateLayerUploadResponse' {Maybe Natural
partSize :: Maybe Natural
$sel:partSize:InitiateLayerUploadResponse' :: InitiateLayerUploadResponse -> Maybe Natural
partSize} -> Maybe Natural
partSize) (\s :: InitiateLayerUploadResponse
s@InitiateLayerUploadResponse' {} Maybe Natural
a -> InitiateLayerUploadResponse
s {$sel:partSize:InitiateLayerUploadResponse' :: Maybe Natural
partSize = Maybe Natural
a} :: InitiateLayerUploadResponse)
initiateLayerUploadResponse_uploadId :: Lens.Lens' InitiateLayerUploadResponse (Prelude.Maybe Prelude.Text)
initiateLayerUploadResponse_uploadId :: (Maybe Text -> f (Maybe Text))
-> InitiateLayerUploadResponse -> f InitiateLayerUploadResponse
initiateLayerUploadResponse_uploadId = (InitiateLayerUploadResponse -> Maybe Text)
-> (InitiateLayerUploadResponse
-> Maybe Text -> InitiateLayerUploadResponse)
-> Lens
InitiateLayerUploadResponse
InitiateLayerUploadResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitiateLayerUploadResponse' {Maybe Text
uploadId :: Maybe Text
$sel:uploadId:InitiateLayerUploadResponse' :: InitiateLayerUploadResponse -> Maybe Text
uploadId} -> Maybe Text
uploadId) (\s :: InitiateLayerUploadResponse
s@InitiateLayerUploadResponse' {} Maybe Text
a -> InitiateLayerUploadResponse
s {$sel:uploadId:InitiateLayerUploadResponse' :: Maybe Text
uploadId = Maybe Text
a} :: InitiateLayerUploadResponse)
initiateLayerUploadResponse_httpStatus :: Lens.Lens' InitiateLayerUploadResponse Prelude.Int
initiateLayerUploadResponse_httpStatus :: (Int -> f Int)
-> InitiateLayerUploadResponse -> f InitiateLayerUploadResponse
initiateLayerUploadResponse_httpStatus = (InitiateLayerUploadResponse -> Int)
-> (InitiateLayerUploadResponse
-> Int -> InitiateLayerUploadResponse)
-> Lens
InitiateLayerUploadResponse InitiateLayerUploadResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InitiateLayerUploadResponse' {Int
httpStatus :: Int
$sel:httpStatus:InitiateLayerUploadResponse' :: InitiateLayerUploadResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: InitiateLayerUploadResponse
s@InitiateLayerUploadResponse' {} Int
a -> InitiateLayerUploadResponse
s {$sel:httpStatus:InitiateLayerUploadResponse' :: Int
httpStatus = Int
a} :: InitiateLayerUploadResponse)
instance Prelude.NFData InitiateLayerUploadResponse