1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Removes YAML body_format option

It would require adding a dependency to the YAML module while it might
not provide much benefit (has anybody seen a HTTP API taking YAML as
input ?)
This commit is contained in:
Sébastien Bocahu 2015-03-30 10:23:46 +02:00 committed by Matt Clay
parent 5de4c053b6
commit f88f895795

View file

@ -66,7 +66,7 @@ options:
default: null default: null
body_format: body_format:
description: description:
- The serialization format of the body. Either raw, json, or yaml. When set to json or yaml, encodes the body argument and automatically sets the Content-Type header accordingly. - The serialization format of the body. Either raw, or json. When set to json, encodes the body argument and automatically sets the Content-Type header accordingly.
required: false required: false
default: raw default: raw
method: method:
@ -340,7 +340,7 @@ def main():
user = dict(required=False, default=None), user = dict(required=False, default=None),
password = dict(required=False, default=None), password = dict(required=False, default=None),
body = dict(required=False, default=None), body = dict(required=False, default=None),
body_format = dict(required=False, default='raw', choices=['raw', 'json', 'yaml']), body_format = dict(required=False, default='raw', choices=['raw', 'json']),
method = dict(required=False, default='GET', choices=['GET', 'POST', 'PUT', 'HEAD', 'DELETE', 'OPTIONS', 'PATCH']), method = dict(required=False, default='GET', choices=['GET', 'POST', 'PUT', 'HEAD', 'DELETE', 'OPTIONS', 'PATCH']),
return_content = dict(required=False, default='no', type='bool'), return_content = dict(required=False, default='no', type='bool'),
force_basic_auth = dict(required=False, default='no', type='bool'), force_basic_auth = dict(required=False, default='no', type='bool'),
@ -376,13 +376,10 @@ def main():
dict_headers = {} dict_headers = {}
# If body_format is json or yaml, encore the body (wich can be a dict or a list) and automatically sets the Content-Type header # If body_format is json, encodes the body (wich can be a dict or a list) and automatically sets the Content-Type header
if body_format == 'json': if body_format == 'json':
body = json.dumps(body) body = json.dumps(body)
dict_headers['Content-Type'] = 'application/json' dict_headers['Content-Type'] = 'application/json'
elif body_format == 'yaml':
body = yaml.dump(body)
dict_headers['Content-Type'] = 'application/yaml'
# Grab all the http headers. Need this hack since passing multi-values is currently a bit ugly. (e.g. headers='{"Content-Type":"application/json"}') # Grab all the http headers. Need this hack since passing multi-values is currently a bit ugly. (e.g. headers='{"Content-Type":"application/json"}')