module Cvprac::Api::Task
CVP Task
api methods
Public Instance Methods
add_note_to_task(task_id, note)
click to toggle source
Add note to CVP task by taskID
@param [String] task_id The id of the task to execute @param [String] note Content of the note
@return [Hash] request body
# File lib/cvprac/api/task.rb, line 89 def add_note_to_task(task_id, note) log(Logger::DEBUG) do "add_note_to_task: task_id: #{task_id}, note: [#{note}]" end @clnt.post('/task/addNoteToTask.do', data: { workOrderId: task_id, note: note }) end
execute_task(task_id)
click to toggle source
Execute CVP task by taskID
@param [String] task_id The id of the task to execute
@return [Hash] request body
# File lib/cvprac/api/task.rb, line 102 def execute_task(task_id) log(Logger::DEBUG) { "execute_task: task_id: #{task_id}" } @clnt.post('/task/executeTask.do', body: { data: [task_id] }) end
get_pending_tasks_by_device(device)
click to toggle source
Get task data by device name (FQDN)
@param [String] device Name (FQDN) of a device
@return [Hash] request body rubocop:disable Metrics/MethodLength
# File lib/cvprac/api/task.rb, line 66 def get_pending_tasks_by_device(device) log(Logger::DEBUG) { "#{__method__}: device: #{device}" } begin task = @clnt.get('/task/getTasks.do', data: { queryparam: 'Pending', startIndex: 0, endIndex: 0 }) rescue CvpApiError => e if e.to_s.include?('Invalid WorkOrderId') || e.to_s.include?('Entity does not exist') return nil end end # TODO: filter tasks by device task['data'] end
get_task_by_id(task_id)
click to toggle source
Get task data by ID
@param [String] task_id The id of the task to execute
@return [Hash] request body
# File lib/cvprac/api/task.rb, line 47 def get_task_by_id(task_id) log(Logger::DEBUG) { "#{__method__}: task_id: #{task_id}" } begin task = @clnt.get('/task/getTaskById.do', data: { taskId: task_id }) rescue CvpApiError => e if e.to_s.include?('Invalid WorkOrderId') || e.to_s.include?('Entity does not exist') return nil end end task end