pve2-api-php-client icon indicating copy to clipboard operation
pve2-api-php-client copied to clipboard

no support for optional settings in GET request

Open naja7host opened this issue 10 years ago • 9 comments

some GET request support additional setting , but in the class no support for this .

GET exemple with additional setting

pvesh get /cluster/resources -type vm pvesh get /nodes/localhost/storage/local/content -content vztmpl pvesh get /nodes/localhost/bootlog -limit 3 -start 5 pvesh get /nodes/localhost/rrd -cf average

naja7host avatar Dec 08 '14 03:12 naja7host

The workaround for this is to add such arguments to the query string:

$pve2->get("/cluster/resources?type=vm");
$pve2->get("/nodes/localhost/storage/local/content?content=vztmpl");
$pve2->get("/nodes/localhost/bootlog?limit=3&start=5");
$pve2->get("/nodes/localhost/rrd?cf=average");

But yes, this should be handled internally.

danhunsaker avatar Dec 08 '14 22:12 danhunsaker

@CpuID - Want me to tackle this one, or do you have it covered?

danhunsaker avatar Feb 02 '15 11:02 danhunsaker

My gut feeling is just appending to the ->get() call first parameter makes sense here? I can understand the elegance of having it natively supported for example as a second optional array parameter to function get (), but it feels like it may blow out logic wise...? Chances are the only thing you would do within the get() function is append to action_path before sending to ->action() anyway...?

CpuID avatar Feb 02 '15 12:02 CpuID

@danhunsaker - I'll let you tackle it if you like :)

CpuID avatar Feb 02 '15 12:02 CpuID

make it as the put function , in my own script , i just used the same logic of put postfields before sending the request .

any way if is implemented it will be a good option .

naja7host avatar Feb 02 '15 14:02 naja7host

@naja7host, @CpuID - I've submitted a PR for this (#12) if you would be willing to check it out. I'll merge it in a few days if there's no feedback suggesting otherwise.

danhunsaker avatar Feb 03 '15 20:02 danhunsaker

i have tested it , work like a charm :)

edit : not working the paramaitre

naja7host avatar Feb 04 '15 01:02 naja7host

it not working , because the class send the first request $action_path before the the switch case .

so the get parametre is set later , and it should build with the $action_path before it sended .

moving the line to the end of switch case , do the trick .

curl_setopt($prox_ch, CURLOPT_URL, "https://{$this->hostname}:{$this->port}/api2/json{$action_path}");

naja7host avatar Feb 10 '15 18:02 naja7host

is still not working , any one tested the optional settings in GET request ?

naja7host avatar Sep 23 '15 13:09 naja7host