Introduce the api-get command.
Review Request #4195 — Created June 2, 2013 and submitted
Introduce the api-get command. The new rbt api-get command takes a path to an api resource, requests the resource, and prints it as JSON. The path can either be rooted at the api level (e.g. '/review-requests/123/') or be a full url. Query arguments may also be specified for the request. Each query argument, appearing after '--', taking the form '--<query-arg>=<value>' will be added to the request. For example, 'rbt api-get /review-requests/ -- --counts-only=1' would result in a request to 'http://example.com/api/review-requests/?counts-only=1'. To support this new command, a new 'get_url' is now required for transports. This change provides the required method for the SyncTransport.
Requested a number of resources with different query arguments and observed the expected JSON output. Also tested some error conditions such as print the error payloads when requesting non-existent review-request resources (ids which don't exist).
Description | From | Last Updated |
---|---|---|
"URL" |
chipx86 | |
"URL". Same with other instances of "url." |
chipx86 | |
Comma after ``https://` |
chipx86 | |
This is kind of worded strangely. Maybe: "Each query argument appears after ``--`` on the command line and takes the … |
chipx86 | |
Maybe define this example as its own indented block. |
chipx86 | |
Should be "rbt api-get" |
chipx86 | |
This is too specific to this command. Maybe we start doing something like: command_options = { 'api-get': { 'PRETTY_PRINT': True, … |
chipx86 | |
"Retrieve" "URL" |
chipx86 | |
"URL" Maybe "The URL is not guaranteed to be part of the configured Review Board domain." |
chipx86 | |
Should ideally use endswith() for readability. |
chipx86 | |
"Retrieve" Maybe "Retrieve raw API resource payloads." |
chipx86 | |
"Pretty" should be capitalized, like the others. |
chipx86 | |
No need for the if statement. args is guaranteed to be iterable. |
chipx86 | |
"retrieve" |
chipx86 | |
This is repeated twice. Let's just make a self._dumps function that does this. |
chipx86 |
-
-
-
-
-
This is kind of worded strangely. Maybe: "Each query argument appears after ``--`` on the command line and takes the form of ``--<query-arg>=<value>``." I don't think you need the last "will be added to the request," since that's implied by the previous sentence.
-
-
-
This is too specific to this command. Maybe we start doing something like: command_options = { 'api-get': { 'PRETTY_PRINT': True, } } Or if that's too Pythonic or troublesome, maybe just API_GET_PRETTY_PRINT. Not sure.
-
-
-
-
-
-
-
-
-
This is a review from Review Bot. Tool: PEP8 Style Checker Processed Files: rbtools/api/client.py rbtools/api/resource.py rbtools/api/transport/__init__.py rbtools/commands/api_get.py rbtools/api/decode.py rbtools/api/transport/sync.py setup.py Ignored Files: docs/rbtools/rbt/commands/index.txt docs/rbtools/rbt/commands/api-get.txt