Skip to content

Commit

Permalink
Merge pull request #58 from zdaniel86/fmulti
Browse files Browse the repository at this point in the history
support body argument and response in other formats than json
  • Loading branch information
ptrakhtman authored Jan 31, 2022
2 parents d155c00 + 6a779fe commit 4adb546
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions alcli/alertlogic_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ def __call__(self, args, parsed_globals):
# Remove optional arguments that haven't been supplied
op_args = {k:self._encode(operation, k, v) for (k,v) in kwargs.items() if v is not None}
res = operation(**op_args)
if res.headers.get('content-type') == 'text/plain':
content_type = res.headers.get('content-type')
json_content_types = ['application/json', 'alertlogic/json']
if content_type and content_type not in json_content_types:
print(res.text)
else:
try:
Expand Down Expand Up @@ -307,7 +309,10 @@ def _encode(self, operation, param_name, param_value):
(m.groupdict()['key'], m.groupdict()['value'])
for m in regex.finditer(param_value)
)
return result
if result:
return result
else:
return param_value

# TODO Raise an exception if we can't build a dictionary from the provided input
return param_value
Expand Down

0 comments on commit 4adb546

Please sign in to comment.