libjenkins-0.4.2.0: Jenkins API interface

Safe HaskellNone

Jenkins.Rest

Contents

Description

Jenkins REST API interface

Synopsis

Query Jenkins

data Jenkins a Source

Jenkins REST API query sequence description

class HasConnectInfo t whereSource

Convenience class aimed at elimination of long chains of lenses to access jenkins connection configuration

For example, if you have a configuration record in your application:

 data Config = Config
   { ...
   , _jenkinsConnectInfo :: ConnectInfo
   , ...
   }

you can make it an instance of HasConnectInfo:

 instance HasConnectInfo Config where
   connectInfo f x = (p -> x { _jenkinsConnectInfo = p }) <$> f (_jenkinsConnectInfo x)

and then use e.g. view jenkinsUrl config to get the url part of the jenkins connection

data ConnectInfo Source

Jenkins connection settings

_jenkinsApiToken may be user's password, Jenkins does not make any distinction between these concepts

Constructors

ConnectInfo 

Fields

_jenkinsUrl :: String

Jenkins URL, e.g. http://example.com/jenkins

_jenkinsPort :: Int

Jenkins port, e.g. 8080

_jenkinsUser :: Text

Jenkins user, e.g. jenkins

_jenkinsApiToken :: Text

Jenkins user API token

defaultConnectInfo :: ConnectInfoSource

Default Jenkins connection settings

 defaultConnectInfo = ConnectInfo
   { _jenkinsUrl      = "http://example.com/jenkins"
   , _jenkinsPort     = 8080
   , _jenkinsUser     = "jenkins"
   , _jenkinsApiToken = ""
   }

data Result e v Source

The result of Jenkins REST API queries

Constructors

Error e

Exception e was thrown while querying

Disconnect

The client was explicitly disconnected

Result v

Querying successfully finished the with value v

Instances

Typeable2 Result 
(Eq e, Eq v) => Eq (Result e v) 
(Data e, Data v) => Data (Result e v) 
(Ord e, Ord v) => Ord (Result e v) 
(Show e, Show v) => Show (Result e v) 
Generic (Result e v) 

runJenkins :: HasConnectInfo t => t -> Jenkins a -> IO (Result HttpException a)Source

Query Jenkins API using Jenkins description

Successful result is either Disconnect or Result v

If HttpException was thrown by http-conduit, runJenkins catches it and wraps in Error. Other exceptions are not catched

runJenkinsThrowing :: HasConnectInfo t => t -> Jenkins a -> IO (Result e a)Source

Query Jenkins API using Jenkins description

Successful result is either Disconnect or Result v

No exceptions are catched, i.e.

 runJenkinsThrowing :: ConnectInfo -> Jenkins a -> IO (Result Void a)

is perfectly fine—Result won't ever be an Error

Combinators

post :: (forall f. Method Complete f) -> ByteString -> Jenkins ()Source

POST query (with a payload)

post_ :: (forall f. Method Complete f) -> Jenkins ()Source

POST query (without payload)

concurrently :: Jenkins a -> Jenkins b -> Jenkins (a, b)Source

Do both queries concurrently

io :: MonadIO m => IO a -> m aSource

Lift an arbitrary IO action to the Jenkins monad

 io :: IO a -> Jenkins a

disconnect :: Jenkins aSource

Disconnect from Jenkins

Any following queries won't be executed

with :: (Request -> Request) -> Jenkins a -> Jenkins aSource

Make local changes to the Request

Method

Convenience

postXML :: (forall f. Method Complete f) -> Document -> Jenkins ()Source

POST job's config.xml (or any other xml, really) in xml-conduit format

concurrentlys :: Foldable f => f (Jenkins a) -> Jenkins [a]Source

Send a list of queries concurrently

concurrentlys_ :: Foldable f => f (Jenkins a) -> Jenkins ()Source

Send a list of queries concurrently ignoring their results

Note: exceptions are still raised

reload :: Jenkins aSource

Reload jenkins configuration from disk

Calls /reload and disconnects

restart :: Jenkins aSource

Restart jenkins safely

Calls /safeRestart and disconnects

/safeRestart allows all running jobs to complete

forceRestart :: Jenkins aSource

Force jenkins to restart without waiting for running jobs to finish

Calls /restart and disconnects

Optics

jenkinsUrl :: HasConnectInfo t => Lens' t StringSource

A lens into Jenkins URL

jenkinsPort :: HasConnectInfo t => Lens' t IntSource

A lens into Jenkins port

jenkinsUser :: HasConnectInfo t => Lens' t TextSource

A lens into Jenkins user

jenkinsApiToken :: HasConnectInfo t => Lens' t TextSource

A lens into Jenkins user API token

jenkinsPassword :: HasConnectInfo t => Lens' t TextSource

A lens into Jenkins password

 jenkinsPassword = jenkinsApiToken

_Error :: Prism (Result e a) (Result e' a) e e'Source

A prism into Jenkins error

_Disconnect :: Prism' (Result e a) ()Source

A prism into disconnect

_Result :: Prism (Result e a) (Result e b) a bSource

A prism into result

Reexports

data Request

All information on how to connect to a host and what should be sent in the HTTP request.

If you simply wish to download from a URL, see parseUrl.

The constructor for this data type is not exposed. Instead, you should use either the def method to retrieve a default instance, or parseUrl to construct from a URL, and then use the records below to make modifications. This approach allows http-client to add configuration options without breaking backwards compatibility.

For example, to construct a POST request, you could do something like:

 initReq <- parseUrl "http://www.example.com/path"
 let req = initReq
             { method = "POST"
             }

For more information, please see http://www.yesodweb.com/book/settings-types.

Since 0.1.0