Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Add 'iml debugapi' to iml cli #2132

Merged
merged 11 commits into from
Aug 7, 2020
Merged

Add 'iml debugapi' to iml cli #2132

merged 11 commits into from
Aug 7, 2020

Conversation

utopiabound
Copy link
Contributor

@utopiabound utopiabound commented Aug 5, 2020

debugapi does not show up in help as it's for test/debug

Related #1832

Signed-off-by: Nathaniel Clark nclark@whamcloud.com


This change is Reviewable

debugapi does not show up in help as it's for test/debug

Signed-off-by: Nathaniel Clark <nclark@whamcloud.com>
@utopiabound
Copy link
Contributor Author

[root@adm ~]# iml debugapi get target
{"meta":{"limit":20,"next":null,"offset":0,"previous":null,"total_count":0},"objects":[]}

Signed-off-by: Nathaniel Clark <nclark@whamcloud.com>
@ip1981
Copy link
Member

ip1981 commented Aug 5, 2020

How is it better than curl? :)

# curl http://127.0.0.1:8001/api/filesystem/
{"meta": {"limit": 20, "next": null, "offset": 0, "previous": null, "total_count": 1}, "objects": [{"cdt_mdt": "/api/target/2/", ...

iml-manager-cli/src/api.rs Outdated Show resolved Hide resolved
jgrund
jgrund previously approved these changes Aug 5, 2020
ip1981
ip1981 previously approved these changes Aug 5, 2020
@jgrund
Copy link
Member

jgrund commented Aug 5, 2020

How is it better than curl? :)

API may be setup as read-only and certain verbs (POST, PUT, ...) are usually protected via auth

Signed-off-by: Nathaniel Clark <nclark@whamcloud.com>
@utopiabound utopiabound dismissed stale reviews from ip1981 and jgrund via 84edc25 August 5, 2020 16:51
iml-manager-cli/src/api.rs Outdated Show resolved Hide resolved
jgrund
jgrund previously approved these changes Aug 5, 2020
@utopiabound utopiabound requested a review from ip1981 August 5, 2020 20:01
Signed-off-by: Nathaniel Clark <nclark@whamcloud.com>
Signed-off-by: Nathaniel Clark <nclark@whamcloud.com>
Signed-off-by: Nathaniel Clark <nclark@whamcloud.com>
@utopiabound utopiabound requested a review from jgrund August 5, 2020 20:45
@utopiabound
Copy link
Contributor Author

POST tested and works

Signed-off-by: Nathaniel Clark <nclark@whamcloud.com>
iml-manager-cli/src/api.rs Outdated Show resolved Hide resolved
iml-manager-cli/src/api.rs Outdated Show resolved Hide resolved
Signed-off-by: Nathaniel Clark <nclark@whamcloud.com>
iml-manager-cli/src/api.rs Outdated Show resolved Hide resolved
Signed-off-by: Nathaniel Clark <nclark@whamcloud.com>
iml-manager-cli/src/api.rs Outdated Show resolved Hide resolved
This rounds out the methods that reqwest supports normally.

Signed-off-by: Nathaniel Clark <nclark@whamcloud.com>
@utopiabound utopiabound requested a review from ip1981 August 6, 2020 13:06
ip1981
ip1981 previously approved these changes Aug 6, 2020
Copy link
Member

@jgrund jgrund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any HTTP request could technically carry a body. In addition, a non-GET response could also have a body (and I think some of our API does this).

It's probably best to separate the body addition and response parsing out of each individual Verb, and add the request body / attempt at response body parsing after the match.

For response body, we can check both the content-type header on the return and the content length to decide whether we should decode to JSON.

Signed-off-by: Joe Grund <jgrund@whamcloud.io>
@jgrund jgrund requested a review from ip1981 August 6, 2020 18:23
@jgrund jgrund merged commit 2f5c61b into master Aug 7, 2020
@jgrund jgrund deleted the cli-debugapi branch August 7, 2020 13:29
Comment on lines +39 to +44
ApiMethod::Delete => client.delete(uri),
ApiMethod::Get => client.get(uri),
ApiMethod::Head => client.head(uri),
ApiMethod::Patch => client.patch(uri),
ApiMethod::Post => client.post(uri),
ApiMethod::Put => client.put(uri),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Headers and bodies are not supported, is it intentional?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bodies are supported here: https://github.com/whamcloud/integrated-manager-for-lustre/pull/2132/files#diff-f33d40dcab0b4085abfc004fe3408e29R50-R54

Headers generally aren't needed (currently) when using the ```iml_manager_client``

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants