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

Add rdctl api command #1903

Closed
Tracked by #1896
jandubois opened this issue Mar 26, 2022 · 4 comments · Fixed by #1946
Closed
Tracked by #1896

Add rdctl api command #1903

jandubois opened this issue Mar 26, 2022 · 4 comments · Fixed by #1946
Assignees
Labels
kind/enhancement New feature or request kind/quality quality improvements, refactoring, Automation via CI, E2E, Integration, CLI or REST API
Milestone

Comments

@jandubois
Copy link
Member

jandubois commented Mar 26, 2022

This command provides a convenient way to call an rd-engine API, like gh api for the Github API.

For example rdctl api list-settings would perform the same function as:

USER=$(jq -r .user ~/Library/Application\ Support/rancher-desktop/rd-engine.json)
PASS=$(jq -r .password ~/Library/Application\ Support/rancher-desktop/rd-engine.json)
PORT=$(jq -r .port ~/Library/Application\ Support/rancher-desktop/rd-engine.json)
curl -u $USER:$PASS localhost:$PORT/v0/list-settings

If the argument specifies an absolute path (like /v0/list-settings), then it will not be prefixed with the API version.

We should use the -f/--raw-field and -F/--field parameter semantics from gh api to switch to the POST method and add the fields to the request body.

We can add additional options later; just -f and -F should be enough for the initial version. Maybe support --input if time allows.

In a later version it would also take care of mTLS as well.

@jandubois jandubois mentioned this issue Mar 26, 2022
11 tasks
@jandubois jandubois added kind/enhancement New feature or request kind/quality quality improvements, refactoring, Automation via CI, E2E, Integration, CLI or REST API labels Mar 26, 2022
@jandubois jandubois added this to the Next milestone Mar 26, 2022
@ericpromislow
Copy link
Contributor

I want to add rdctl api / and rdctl api /vX to list all the endpoints globally, and in the specified version respectively.

@jandubois
Copy link
Member Author

I want to add rdctl api / and rdctl api /vX to list all the endpoints globally, and in the specified version respectively.

👍 Sounds good!

We should also copy the gh api behaviour when an error occurs: Create a JSON object with a "message" property on STDOUT, and a regular text message on STDERR:

$ gh api xxx; echo $?
{
  "message": "Not Found",
  "documentation_url": "https://docs.github.com/rest"
}
gh: Not Found (HTTP 404)
1

@ericpromislow
Copy link
Contributor

Given that the PR for the finished work from the original story is over 300 lines, I'm going to move both items (GET / and output formats) to new issues.

@ericpromislow
Copy link
Contributor

I'm going to put the fields (both raw and cooked) on hold, because looking at the gh api documentation, they're for named parameters, and we don't really have any of those yet. For now I'm going to assume that the PUT /settings endpoint will continue to take a JSON request body as its input, and will support that.

Later we can add these fields. Otherwise it's too loosely specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request kind/quality quality improvements, refactoring, Automation via CI, E2E, Integration, CLI or REST API
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants