hup-0.1.0.0: Upload packages or documentation to a hackage server

Safe HaskellNone
LanguageHaskell2010

Distribution.Hup.Upload

Description

Handle uploading to a hackage server, using the HTTP API described in the Hackage server documentation.

Synopsis

Documentation

type WResponse = Response Source #

Alias for wreq's Response type.

data Upload Source #

Bundle together information useful for an upload.

Constructors

Upload 

Fields

Instances

defaultOptions :: Maybe Auth -> Options Source #

returns default options to use with a request.

We try to request plain text where possible; and we allow non-success statuses to still return normally (rather than throwing an exception)

mkAuth :: String -> String -> Maybe Auth Source #

pack a name and password into an Auth structure

>>> mkAuth "myname" "mypassword"

getUploadUrl :: String -> Upload -> String Source #

work out what URL to upload a .tgz file to. getUploadUrl server upload returns a URL.

>>> getUploadUrl "http://localhost:8080/" $ Upload (Package "foo" "0.1.0.0") "./hup-0.1.0.0.tar.gz" IsDocumentation CandidatePkg
"http://localhost:8080/package/foo-0.1.0.0/candidate/docs"

upload :: String -> Upload -> Maybe Auth -> IO (WResponse ByteString) Source #

upload serverUrl upl userAuth - upload some package (details packed into upl to the server at serverUrl, using the credentials in userAuth.

data Response Source #

Relevant bits of server response, packed into a record for those who don't want to deal with wreq's Response type.

postPkg :: String -> FilePath -> Maybe Auth -> IO (WResponse ByteString) Source #

Do a POST request to upload a package.

postPkg url fileName userAuth will try to upload the file given by fileName to the URL at url, using the user authentication userAuth.

putDocs :: String -> FilePath -> Maybe Auth -> IO (WResponse ByteString) Source #

Do a PUT request to upload package documentation.

postPkg url fileName userAuth will try to upload the file given by fileName to the URL at url, using the user authentication userAuth.

data Auth :: * #

Supported authentication types.

Do not use HTTP authentication unless you are using TLS encryption. These authentication tokens can easily be captured and reused by an attacker if transmitted in the clear.

Constructors

BasicAuth ByteString ByteString

Basic authentication. This consists of a plain username and password.

OAuth2Bearer ByteString

An OAuth2 bearer token. This is treated by many services as the equivalent of a username and password.

OAuth2Token ByteString

A not-quite-standard OAuth2 bearer token (that seems to be used only by GitHub). This is treated by whoever accepts it as the equivalent of a username and password.

AWSAuth AWSAuthVersion ByteString ByteString

Amazon Web Services request signing AWSAuthVersion key secret

OAuth1 ByteString ByteString ByteString ByteString

OAuth1 request signing OAuth1 consumerToken consumerSecret token secret

Instances

Eq Auth 

Methods

(==) :: Auth -> Auth -> Bool #

(/=) :: Auth -> Auth -> Bool #

Show Auth 

Methods

showsPrec :: Int -> Auth -> ShowS #

show :: Auth -> String #

showList :: [Auth] -> ShowS #