Skip to content

Commit

Permalink
Update XmlModel.xml_request() to accept also headers argument
Browse files Browse the repository at this point in the history
  • Loading branch information
dmach committed Apr 26, 2024
1 parent f908092 commit 3c096b8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions osc/util/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,12 +756,20 @@ def from_xml(cls, root: ET.Element, *, apiurl: Optional[str] = None):
return obj

@classmethod
def xml_request(cls, method: str, apiurl: str, path: List[str], query: Optional[dict] = None, data: Optional[str] = None) -> urllib3.response.HTTPResponse:
def xml_request(
cls,
method: str,
apiurl: str,
path: List[str],
query: Optional[dict] = None,
headers: Optional[str] = None,
data: Optional[str] = None,
) -> urllib3.response.HTTPResponse:
from ..connection import http_request
from ..core import makeurl
url = makeurl(apiurl, path, query)
# TODO: catch HTTPError and return the wrapped response as XmlModel instance
return http_request(method, url, data=data)
return http_request(method, url, headers=headers, data=data)

def do_update(self, other: "XmlModel") -> None:
"""
Expand Down

0 comments on commit 3c096b8

Please sign in to comment.