mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-10 22:56:15 +01:00
Add _private.api.post() function
This commit is contained in:
parent
76b1821f19
commit
d81c688759
@ -33,6 +33,31 @@ def get(apiurl, path, query=None):
|
||||
return root
|
||||
|
||||
|
||||
def post(apiurl, path, query=None):
|
||||
"""
|
||||
Send a POST request to OBS.
|
||||
|
||||
:param apiurl: OBS apiurl.
|
||||
:type apiurl: str
|
||||
:param path: URL path segments.
|
||||
:type path: list(str)
|
||||
:param query: URL query values.
|
||||
:type query: dict(str, str)
|
||||
:returns: Parsed XML root.
|
||||
:rtype: xml.etree.ElementTree.Element
|
||||
"""
|
||||
assert apiurl
|
||||
assert path
|
||||
|
||||
if not isinstance(path, (list, tuple)):
|
||||
raise TypeError("Argument `path` expects a list of strings")
|
||||
|
||||
url = osc_core.makeurl(apiurl, path, query)
|
||||
with osc_connection.http_POST(url) as f:
|
||||
root = osc_core.ET.parse(f).getroot()
|
||||
return root
|
||||
|
||||
|
||||
def find_nodes(root, root_name, node_name):
|
||||
"""
|
||||
Find nodes with given `node_name`.
|
||||
|
Loading…
Reference in New Issue
Block a user