metal-cli icon indicating copy to clipboard operation
metal-cli copied to clipboard

want ability to make raw api calls

Open bahamat opened this issue 5 years ago • 4 comments

What problem are you facing?

I want to be able to perform actions that don't yet have high level subcommands

How could the Equinix Metal CLI help solve this problem?

Allow me to pass arbitrary API calls on the command line.

e.g., the following would be equivalent:

packet project get -i {id} -j
packet api /projects/{id}

Additionally, I'd like to be able to specify the request method (e.g., like curl -X POST) and request data (e.g., like curl -d '{"someJson":true}).

bahamat avatar Jan 05 '21 01:01 bahamat

For GET and DELETE requests this is fairly straightforward. For POST, PUT, PATCH request types we would likely eschew endpoint specific options for a raw body field, as you suggest.

Perhaps the command's naming convention could fit more closely with the existing commands as: packet raw create, packet raw get, etc. And perhaps raw is as descriptive as api.

Our table output format is not prepared for arbitrary field results, so may have to require json or yaml output modes in this case.

displague avatar Jan 11 '21 18:01 displague

As the requestor, I'd be fine with having raw api calls always return json. I.e., -j is always implied.

I'm also interested in being able to call endpoints that have not yet been implemented in the cli client. Being able to pass an explicit query string would allow me to do that.

bahamat avatar Jan 11 '21 23:01 bahamat

@bahamat until that's done in packet-cli, checkout https://github.com/t0mk/packetjq you can even process the JSON with jq like expressions

t0mk avatar Jan 12 '21 09:01 t0mk

Nice, I was just thinking I'd like to see this too. I really like how the gh cli has this escape hatch. Its also nice that there's an easy to use arg to handle pagination and I'd like to see it in metal too.

My vote is for metal api like gh, feels right.

mmlb avatar Oct 24 '22 20:10 mmlb