Class: Pvectl::Repositories::TaskList

Inherits:
Base
  • Object
show all
Defined in:
lib/pvectl/repositories/task_list.rb

Overview

Repository for listing tasks (async operations) on a node. Uses GET /nodes/node/tasks to fetch recent operations.

Instance Method Summary collapse

Methods inherited from Base

#get, #initialize

Constructor Details

This class inherits a constructor from Pvectl::Repositories::Base

Instance Method Details

#list(node:, vmid: nil, limit: 50, since: nil, until_time: nil, type_filter: nil, status_filter: nil) ⇒ Array<Models::TaskEntry>

Parameters:

  • node (String)

    node name (required)

  • vmid (Integer, nil) (defaults to: nil)

    filter by VMID

  • limit (Integer) (defaults to: 50)

    max entries (default 50)

  • since (Integer, nil) (defaults to: nil)

    start time (epoch)

  • until_time (Integer, nil) (defaults to: nil)

    end time (epoch)

  • type_filter (String, nil) (defaults to: nil)

    filter by task type

  • status_filter (String, nil) (defaults to: nil)

    filter by status

Returns:



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/pvectl/repositories/task_list.rb', line 16

def list(node:, vmid: nil, limit: 50, since: nil, until_time: nil,
         type_filter: nil, status_filter: nil)
  params = { limit: limit, source: "all" }
  params[:vmid] = vmid if vmid
  params[:since] = since if since
  params[:until] = until_time if until_time
  params[:typefilter] = type_filter if type_filter
  params[:statusfilter] = status_filter if status_filter

  response = connection.client["nodes/#{node}/tasks"].get(params: params)
  models_from(response, Models::TaskEntry)
end