Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no support for optional settings in GET request #8

Open
naja7host opened this issue Dec 8, 2014 · 9 comments
Open

no support for optional settings in GET request #8

naja7host opened this issue Dec 8, 2014 · 9 comments
Assignees

Comments

@naja7host
Copy link

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
Copy link
Collaborator

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
Copy link
Collaborator

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

@CpuID
Copy link
Owner

CpuID commented Feb 2, 2015

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
Copy link
Owner

CpuID commented Feb 2, 2015

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

@naja7host
Copy link
Author

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 added a commit to danhunsaker/pve2-api-php-client that referenced this issue Feb 3, 2015
Addresses GitHub Issue CpuID#8

- Set parameters as CURLOPT_POSTFIELDS, which cURL will automatically translate into the URL query string.
  This lets us pass the ?params versus &params logic off to cURL, which makes the code easier to maintain.
- Allow all parameters passed to be empty by making the argument optional on GET, POST, and PUT.
  This is mostly for consistency.

Signed-off-by: Daniel Hunsaker <danhunsaker@gmail.com>
danhunsaker added a commit to danhunsaker/pve2-api-php-client that referenced this issue Feb 3, 2015
Addresses GitHub issue CpuID#8

- cURL appears to not (or at least to no longer) actually support turning POSTFIELDS into query string parameters,
  so we have to build the query string ourselves.  This update does just that.

Signed-off-by: Daniel Hunsaker <danhunsaker@gmail.com>
@danhunsaker danhunsaker self-assigned this Feb 3, 2015
@danhunsaker
Copy link
Collaborator

@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
Copy link
Author

i have tested it , work like a charm :)

edit : not working the paramaitre

@naja7host
Copy link
Author

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
Copy link
Author

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

danhunsaker added a commit to danhunsaker/pve2-api-php-client that referenced this issue Jul 14, 2016
Addresses GitHub Issue CpuID#8

- Set parameters as CURLOPT_POSTFIELDS, which cURL will automatically translate into the URL query string.
  This lets us pass the ?params versus &params logic off to cURL, which makes the code easier to maintain.
- Allow all parameters passed to be empty by making the argument optional on GET, POST, and PUT.
  This is mostly for consistency.

Signed-off-by: Daniel Hunsaker <danhunsaker@gmail.com>
danhunsaker added a commit to danhunsaker/pve2-api-php-client that referenced this issue Jul 14, 2016
Addresses GitHub issue CpuID#8

- cURL appears to not (or at least to no longer) actually support turning POSTFIELDS into query string parameters,
  so we have to build the query string ourselves.  This update does just that.

Signed-off-by: Daniel Hunsaker <danhunsaker@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants