Add `api` command and options like `--get`, `--post`, `--put`, `--delete`, `--data=key1=value1` and `--header=headercontent`

Review Request #11479 — Created Feb. 21, 2021 and updated

qianxi
RBTools
master
rbtools

The reason why we need api command instead of api-get is simple: We need to do HTTP GET, POST, PUT, DELETE requests.
I created api command, with new options --get, --post, --put, --delete, --data=key1=value1, --header=headercontent , original --pretty option and server options still work.
I'll add support for file data POST and PUT later.
Please omit "Merge XDG project changes in local branch into local master" commit, I believe the commit content should be the same as https://reviews.reviewboard.org/r/11423/.

For api --get, --post, --put, --delete options, I did some basic testings using command line tools. They all work for non-existed urls and --get works for existing api resources. We can use --data=key1=value1 to add post data and use --header=headercontent to add customized headers. And --pretty option still works. I will do further testing later.

Summary
Merge XDG project changes in local branch into local master
[WIP]Add a new command called "api". Add option commands called "--get", "--post", "--delete". "api --get" option can substitute original "api-get" option now.
[WIP]Add api.py file, forget to stage this file in the last commit.
[WIP]Add "--put" option but still need to find out how to send post/put data. Add "--header" option, still need to find a way to combine our customized header with original data.
Refactor methods in api class. Now support use --header option to add customized header in a request.
[WIP]Allow basic HTTP GET, DELETE. Allow POST and PUT key value pairs. Still need further testings
Remove redundant print statements from api-get.py
Fix coding style problems.
Fix more coding style problems.
Add a newline character.
Description From Last Updated

E225 missing whitespace around operator

reviewbotreviewbot

W293 blank line contains whitespace

reviewbotreviewbot

W293 blank line contains whitespace

reviewbotreviewbot

W293 blank line contains whitespace

reviewbotreviewbot

W293 blank line contains whitespace

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

W293 blank line contains whitespace

reviewbotreviewbot

W293 blank line contains whitespace

reviewbotreviewbot

F401 'rbtools.commands.OptionGroup' imported but unused

reviewbotreviewbot

E302 expected 2 blank lines, found 1

reviewbotreviewbot

E128 continuation line under-indented for visual indent

reviewbotreviewbot

W503 line break before binary operator

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

E128 continuation line under-indented for visual indent

reviewbotreviewbot

W503 line break before binary operator

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

E231 missing whitespace after ':'

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

W293 blank line contains whitespace

reviewbotreviewbot

W391 blank line at end of file

reviewbotreviewbot

W293 blank line contains whitespace

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

W293 blank line contains whitespace

reviewbotreviewbot

W293 blank line contains whitespace

reviewbotreviewbot

W391 blank line at end of file

reviewbotreviewbot

W293 blank line contains whitespace

reviewbotreviewbot

W292 no newline at end of file

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

qianxi
Review request changed

Change Summary:

Fix coding style problems

Commits:

Summary
-
Merge XDG project changes in local branch into local master
-
[WIP]Add a new command called "api". Add option commands called "--get", "--post", "--delete". "api --get" option can substitute original "api-get" option now.
-
[WIP]Add api.py file, forget to stage this file in the last commit.
-
[WIP]Add "--put" option but still need to find out how to send post/put data. Add "--header" option, still need to find a way to combine our customized header with original data.
-
Refactor methods in api class. Now support use --header option to add customized header in a request.
-
[WIP]Allow basic HTTP GET, DELETE. Allow POST and PUT key value pairs. Still need further testings
-
Remove redundant print statements from api-get.py
+
Merge XDG project changes in local branch into local master
+
[WIP]Add a new command called "api". Add option commands called "--get", "--post", "--delete". "api --get" option can substitute original "api-get" option now.
+
[WIP]Add api.py file, forget to stage this file in the last commit.
+
[WIP]Add "--put" option but still need to find out how to send post/put data. Add "--header" option, still need to find a way to combine our customized header with original data.
+
Refactor methods in api class. Now support use --header option to add customized header in a request.
+
[WIP]Allow basic HTTP GET, DELETE. Allow POST and PUT key value pairs. Still need further testings
+
Remove redundant print statements from api-get.py
+
Fix coding style problems.

Diff:

Revision 2 (+1120 -218)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

qianxi
Review request changed

Change Summary:

Fix more coding style problems.

Commits:

Summary
-
Merge XDG project changes in local branch into local master
-
[WIP]Add a new command called "api". Add option commands called "--get", "--post", "--delete". "api --get" option can substitute original "api-get" option now.
-
[WIP]Add api.py file, forget to stage this file in the last commit.
-
[WIP]Add "--put" option but still need to find out how to send post/put data. Add "--header" option, still need to find a way to combine our customized header with original data.
-
Refactor methods in api class. Now support use --header option to add customized header in a request.
-
[WIP]Allow basic HTTP GET, DELETE. Allow POST and PUT key value pairs. Still need further testings
-
Remove redundant print statements from api-get.py
-
Fix coding style problems.
+
Merge XDG project changes in local branch into local master
+
[WIP]Add a new command called "api". Add option commands called "--get", "--post", "--delete". "api --get" option can substitute original "api-get" option now.
+
[WIP]Add api.py file, forget to stage this file in the last commit.
+
[WIP]Add "--put" option but still need to find out how to send post/put data. Add "--header" option, still need to find a way to combine our customized header with original data.
+
Refactor methods in api class. Now support use --header option to add customized header in a request.
+
[WIP]Allow basic HTTP GET, DELETE. Allow POST and PUT key value pairs. Still need further testings
+
Remove redundant print statements from api-get.py
+
Fix coding style problems.
+
Fix more coding style problems.

Diff:

Revision 3 (+1124 -226)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

qianxi
Review request changed

Change Summary:

Add a newline character

Commits:

Summary
-
Merge XDG project changes in local branch into local master
-
[WIP]Add a new command called "api". Add option commands called "--get", "--post", "--delete". "api --get" option can substitute original "api-get" option now.
-
[WIP]Add api.py file, forget to stage this file in the last commit.
-
[WIP]Add "--put" option but still need to find out how to send post/put data. Add "--header" option, still need to find a way to combine our customized header with original data.
-
Refactor methods in api class. Now support use --header option to add customized header in a request.
-
[WIP]Allow basic HTTP GET, DELETE. Allow POST and PUT key value pairs. Still need further testings
-
Remove redundant print statements from api-get.py
-
Fix coding style problems.
-
Fix more coding style problems.
+
Merge XDG project changes in local branch into local master
+
[WIP]Add a new command called "api". Add option commands called "--get", "--post", "--delete". "api --get" option can substitute original "api-get" option now.
+
[WIP]Add api.py file, forget to stage this file in the last commit.
+
[WIP]Add "--put" option but still need to find out how to send post/put data. Add "--header" option, still need to find a way to combine our customized header with original data.
+
Refactor methods in api class. Now support use --header option to add customized header in a request.
+
[WIP]Allow basic HTTP GET, DELETE. Allow POST and PUT key value pairs. Still need further testings
+
Remove redundant print statements from api-get.py
+
Fix coding style problems.
+
Fix more coding style problems.
+
Add a newline character.

Diff:

Revision 4 (+1125 -227)

Show changes

Checks run (2 succeeded)

flake8 passed.
JSHint passed.
Loading...