Class: OpenTox::RestClientWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/rest_client_wrapper.rb

Class Method Summary collapse

Class Method Details

.delete(uri, headers = nil) ⇒ OpenTox::WrapperResult

performs a DELETE REST call raises OpenTox::Error if call fails (rescued in overwrite.rb -> halt 502)

Parameters:

  • uri (String)

    destination URI

  • headers (optional, Hash) (defaults to: nil)

    contains params like accept-header

Returns:



49
50
51
# File 'lib/rest_client_wrapper.rb', line 49

def self.delete(uri, headers=nil )
  execute( "delete", uri, nil, headers)
end

.get(uri, headers = {}, waiting_task = nil, wait = true) ⇒ OpenTox::WrapperResult

performs a GET REST call raises OpenTox::Error if call fails (rescued in overwrite.rb -> halt 502) per default: waits for Task to finish and returns result URI of Task

Parameters:

  • uri (String)

    destination URI

  • headers (optional, Hash) (defaults to: {})

    contains params like accept-header

  • waiting_task (optional, OpenTox::Task) (defaults to: nil)

    (can be a OpenTox::Subtask as well), progress is updated accordingly

  • wait (wait, Boolean) (defaults to: true)

    set to false to NOT wait for task if result is task

Returns:



17
18
19
# File 'lib/rest_client_wrapper.rb', line 17

def self.get(uri, headers={}, waiting_task=nil, wait=true )
  execute( "get", uri, nil, headers, waiting_task, wait)
end

.post(uri, payload = nil, headers = {}, waiting_task = nil, wait = true) ⇒ OpenTox::WrapperResult

performs a POST REST call raises OpenTox::Error if call fails (rescued in overwrite.rb -> halt 502) per default: waits for Task to finish and returns result URI of Task

Parameters:

  • uri (String)

    destination URI

  • payload (optional, String) (defaults to: nil)

    data posted to the service

  • headers (optional, Hash) (defaults to: {})

    contains params like accept-header

  • waiting_task (optional, OpenTox::Task) (defaults to: nil)

    (can be a OpenTox::Subtask as well), progress is updated accordingly

  • wait (wait, Boolean) (defaults to: true)

    set to false to NOT wait for task if result is task

Returns:



30
31
32
# File 'lib/rest_client_wrapper.rb', line 30

def self.post(uri, payload=nil, headers={}, waiting_task=nil, wait=true )
  execute( "post", uri, payload, headers, waiting_task, wait )
end

.put(uri, payload = nil, headers = {}) ⇒ OpenTox::WrapperResult

performs a PUT REST call raises OpenTox::Error if call fails (rescued in overwrite.rb -> halt 502)

Parameters:

  • uri (String)

    destination URI

  • headers (optional, Hash) (defaults to: {})

    contains params like accept-header

  • payload (optional, String) (defaults to: nil)

    data put to the service

Returns:



40
41
42
# File 'lib/rest_client_wrapper.rb', line 40

def self.put(uri, payload=nil, headers={} )
  execute( "put", uri, payload, headers )
end