### Examples using ruby restclient ###
> gem install rest-client
> export PATH=$PATH:/var/lib/gems/1.8/bin
> restclient http://localhost/oarapi-debug

# Getting resources infos
  # in JSON
irb(main):004:0> puts get('/resources.json')
  # in YAML
irb(main):005:0> puts get('/resources.yaml')
  # Same thing
irb(main):050:0> puts get('/resources', :accept=>"text/yaml")
  # Specifying the "oar" data structure
irb(main):050:0> puts get('/resources.json?structure=oar')
  # Specifying the "simple" data structure
irb(main):050:0> puts get('/resources.json?structure=simple')
  # Details about a resource
irb(main):008:0> puts get('/resources/1.yaml')
  # Details and resources of a node
irb(main):007:0> puts get('/resources/nodes/liza-1.yaml')
  # Details of all the resources (expansion)
irb(main):007:0> puts get('/resources/all.yaml')

# Getting jobs infos
irb(main):006:0> puts get('/jobs.yaml')
irb(main):009:0> puts get('/jobs/12.yaml')

# Submiting a job (using JSON format)
irb(main):010:0> require 'json'
irb(main):012:0> j={ 'resource' => '/nodes=2/cpu=1', 'script_path' => '/usr/bin/id' }
irb(main):015:0> job=post('/jobs' , j.to_json , :content_type => 'application/json')

# Getting details about the previously submited job

irb(main):035:0> puts get(JSON.parse(job)['uri'])

# Submitting a job using JSON format, but requiring the result in YAML
irb(main):037:0> job=post('/jobs.yaml' , j.to_json , :content_type => 'application/json')

# Submitting a job with a provided inline script
irb(main):024:0> script="#!/bin/bash
irb(main):025:0" echo \"Hello world\"
irb(main):026:0" whoami
irb(main):027:0" sleep 300
irb(main):028:0" "
irb(main):029:0> j={ 'resource' => '/nodes=2/cpu=1', 'script' => script , 'workdir' => '~bzizou/tmp'}
irb(main):030:0> job=post('/jobs' , j.to_json , :content_type => 'application/json')

# Deleting a job
irb(main):111:0> delete("/jobs/#{JSON.parse(job)['id']}.yaml")

# Send the checkpoint signal to a job
irb(main):102:0> puts post('/jobs/292','{"method":"checkpoint"}',:content_type => "application/json")

# Suspending/resuming a job
irb(main):102:0> puts post('/jobs/292','{"method":"hold"}',:content_type => "application/json")
irb(main):103:0> puts post('/jobs/292','{"method":"resume"}',:content_type => "application/json")

# Adding a new resource (oar user only)
irb(main):078:0> r={ 'hostname'=>'test2', 'properties'=> { 'besteffort'=>'NO' , 'cpu' => '10' } }
irb(main):078:0> puts post('/resources', r.to_json , :content_type => 'application/json')

# Deleting a resource by id (oar user only)
irb(main):079:0> puts delete('/resources/8')

# Deleting a resource by node/cpuset (oar user only)
irb(main):080:0> puts delete('/resources/test2-p/1')


### Example using curl ###

curl -i -X POST http://www/oarapi/jobs.json -H'Content-Type: application/json' -d '{"resource":"/nodes=1,walltime=00:10:00", "script_path":"\"sleep 600\"", "type":"inner=986078"}'

