CpuID / pve2-api-php-client

Proxmox 2.0 API Client for PHP
MIT License
93 stars 62 forks source link

no support for optional settings in GET request #8

Open naja7host opened 9 years ago

naja7host commented 9 years ago

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

danhunsaker commented 9 years ago

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 commented 9 years ago

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

CpuID commented 9 years ago

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 commented 9 years ago

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

naja7host commented 9 years ago

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 .

danhunsaker commented 9 years ago

@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.

naja7host commented 9 years ago

i have tested it , work like a charm :)

edit : not working the paramaitre

naja7host commented 9 years ago

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 commented 9 years ago

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