libjenkins-0.5.0: Jenkins API interface

Safe HaskellNone
LanguageHaskell2010

Jenkins.Rest.Method

Contents

Description

Jenkins REST API method construction

Synopsis

Types

data Method :: Type -> Format -> * Source

Jenkins RESTFul API method encoding

Instances

(~) Type t Complete => Pythony (Method t) 
(~) Type t Complete => XMLy (Method t) 
(~) Type t Complete => JSONy (Method t) 
(~) Type t Complete => Num (Method t f)

Only to support number literals

Show (As f) => Show (Method t f) 
IsString (Method Complete f) 
IsString (Method Query f) 

data Type Source

Method types

Constructors

Query 
Complete 

data Format Source

Response formats

data As :: Format -> * Source

Response format singleton type

Instances

Pythony As 
XMLy As 
JSONy As 
Eq (As f) 
Show (As f) 

Method construction

(-?-) :: Method Complete f -> Method Query f -> Method Complete f infix 1 Source

Combine path and query

(-/-) :: Method Complete f -> Method Complete f -> Method Complete f infixr 5 Source

Combine 2 paths

(-=-) :: Text -> Text -> Method Query f infix 7 Source

Make a field-value pair

(-&-) :: Method Query f -> Method Query f -> Method Query f infixr 5 Source

Combine 2 queries

query :: [(Text, Maybe Text)] -> Method Query f Source

List-to-query convenience combinator

>>> render (query [("foo", Nothing), ("bar", Just "baz"), ("quux", Nothing)])
"foo&bar=baz&quux"
>>> render (query [])
""

as :: Method Complete f -> As f -> Method Complete f infix 3 Source

Choose response format

class JSONy t where Source

JSON response format

Methods

json :: t JSON Source

Instances

JSONy As 
(~) Type t Complete => JSONy (Method t) 

class XMLy t where Source

XML response format

Methods

xml :: t XML Source

Instances

XMLy As 
(~) Type t Complete => XMLy (Method t) 

class Pythony t where Source

Python response format

Methods

python :: t Python Source

Instances

Shortcuts

job :: Text -> Method Complete f Source

Job API method

>>> render (job "name" `as` json)
"job/name/api/json"

build :: Integral a => Text -> a -> Method Complete f Source

Job build API method

>>> render (build "name" 4 `as` json)
"job/name/4/api/json"

view :: Text -> Method Complete f Source

View API method

>>> render (view "name" `as` xml)
"view/name/api/xml"

queue :: Method Complete f Source

Queue API method

>>> render (queue `as` python)
"queue/api/python"

overallLoad :: Method Complete f Source

Statistics API method

>>> render (overallLoad `as` xml)
"overallLoad/api/xml"

computer :: Method Complete f Source

Node API method

>>> render (computer `as` python)
"computer/api/python"

Rendering

render :: Method t f -> ByteString Source

Render Method to something that can be sent over the wire

>>> render ("" `as` xml)
"api/xml"
>>> render xml
"api/xml"
>>> render ("job" -/- 7 `as` xml)
"job/7/api/xml"
>>> render ("job" -/- 7 `as` xml)
"job/7/api/xml"
>>> render ("job" -/- 7 `as` json)
"job/7/api/json"
>>> render (text "restart")
"restart"
>>> render ("job" -?- "name" -=- "foo" -&- "title" -=- "bar")
"job?name=foo&title=bar"
>>> render ("job" -?- "name" -&- "title" -=- "bar")
"job?name&title=bar"
>>> render ("job" -/- 7 `as` json -?- "name" -&- "title" -=- "bar")
"job/7/api/json?name&title=bar"
>>> render ("job" -/- "ДМИТРИЙ" `as` xml)
"job/%D0%94%D0%9C%D0%98%D0%A2%D0%A0%D0%98%D0%99/api/xml"

slash :: (IsString m, Monoid m) => m -> m -> m Source

Insert "/" between two String-like things and concatenate everything.