marmalade-upload-0.10: Upload packages to Marmalade

Safe HaskellNone

Web.Marmalade

Contents

Description

Access to the API of Marmalade

Synopsis

The Marmalade Monad

data Marmalade a Source

The Marmalade monad.

This monad provides access to the Marmalade API.

runMarmaladeSource

Arguments

:: Text

The user agent sent to Marmalade

-> Auth

The authentication information

-> Marmalade a

The actions to run

-> IO a

The result of the actions, or any error thrown in the course of running the actions.

runMarmalade userAgent auth actions runs actions.

userAgent is sent as User-Agent header to Marmalade, and auth is the authentication information.

Marmalade requires a token to access most of its API, however clients can login with a username and a password to obtain their token.

runMarmaladeWithManagerSource

Arguments

:: Text

The user agent sent to Marmalade

-> Auth

The authentication information

-> Manager

The connection manager

-> Marmalade a

The actions to run

-> IO a

The result of the actions, or any error thrown in the course of running the actions.

'runMarmaladeWithManager userAgent auth manager actions' runs actions with the given connection manager.

Like runMarmalade, except that it lets you use your own connection manager.

Error handling

data MarmaladeError Source

Errors thrown by Marmalade.

Constructors

MarmaladeInvalidResponseStatus Status Text

An invalid response from Marmalade, with a status and probably an error message from Marmalade.

MarmaladeInvalidResponseBody ByteString

Invalid response body

MarmaladeBadRequest Text

A bad request error from Marmalade.

Marmalade raises this error for failed logins and for uploads of invalid packages (e.g. files without a version header)

MarmaladeInvalidPackage FilePath Text

An invalid package file, with a corresponding error message.

Authentication

newtype Username Source

The name of a user

Constructors

Username Text 

Instances

Eq Username 
Show Username 

newtype Token Source

An authentication token.

Constructors

Token Text 

Instances

data Auth Source

Authentication information for Marmalade.

Constructors

BasicAuth Username (Marmalade Text)

Authentication with a username and an action that returns a password to use

TokenAuth Username Token

Authentication with a username and a login token

login :: Marmalade (Username, Token)Source

login logs in to Marmalade to obtain the client's access token.

If the monad already uses token authentication this function is a no-op and merely returns the stored token. Otherwise it sends a login request to Marmalade to obtain the token and stores the token in the monad.

Generic types

newtype Message Source

Constructors

Message 

Instances

Package uploads

newtype Upload Source

The result of an upload.

Constructors

Upload 

Fields

uploadMessage :: Text

The message from Marmalade

Instances

uploadPackage :: FilePath -> Marmalade UploadSource

uploadPackage package uploads a package file to Marmalade.

Return the result of the upload, or throw an error if Marmalade refused to accept the upload.