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

Support API's with non-integer versions #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion shoogle/commands/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ def add_parser(main_parser, name):

def run(options):
"""Run command execute."""
service_id, resource_name, method_name = lib.pad_list(options.api_path.split(".", 2), 3)
components = options.api_path.split(".")
if len(components) > 1 and components[1].isdigit():
components = [f"{components[0]}.{components[1]}"] + components[2:]
service_id, resource_name, method_name = lib.pad_list(components, 3)

request_fd = (sys.stdin if options.json_request == "-" else open(options.json_request))
method_options = lib.load_json(request_fd.read())
try:
Expand Down
5 changes: 4 additions & 1 deletion shoogle/commands/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ def add_parser(subparsers, name):
help="SERVICE:VERSION.RESOURCE.METHOD")

def run(options):
parts = options.api_path.split(".", 2)
parts = options.api_path.split(".")
if len(parts) >= 2 and parts[1].isdigit():
parts = [f"{parts[0]}.{parts[1]}"] + parts[2:]
service_id, resource_name, method_name = lib.pad_list(parts, 3)

if resource_name is None:
show_services(service_id, options)
elif method_name is None:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_shoogle.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ def test_main_execute_with_missing_parameter(self):
e = main(["execute", "tasks:v1.tasks.get", request_file])
self.assertEqual(0, e.status)
self.assertIn('Missing required parameter', e.err)

def test_main_show_with_fractional_version(self):
e = main(["show", "content:v2.1"])

self.assertTrue("content:v2.1" in e.out)

if __name__ == '__main__':
sys.exit(unittest.main())