diff options
Diffstat (limited to 'gitlab/client.py')
-rw-r--r-- | gitlab/client.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/gitlab/client.py b/gitlab/client.py index 5e6c71a..c3982f3 100644 --- a/gitlab/client.py +++ b/gitlab/client.py @@ -1094,6 +1094,54 @@ class Gitlab: error_message="Failed to parse the server message" ) from e + def http_patch( + self, + path: str, + *, + query_data: Optional[Dict[str, Any]] = None, + post_data: Optional[Union[Dict[str, Any], bytes]] = None, + raw: bool = False, + **kwargs: Any, + ) -> Union[Dict[str, Any], requests.Response]: + """Make a PATCH request to the Gitlab server. + + Args: + path: Path or full URL to query ('/projects' or + 'http://whatever/v4/api/projecs') + query_data: Data to send as query parameters + post_data: Data to send in the body (will be converted to + json by default) + raw: If True, do not convert post_data to json + **kwargs: Extra options to send to the server (e.g. sudo) + + Returns: + The parsed json returned by the server. + + Raises: + GitlabHttpError: When the return code is not 2xx + GitlabParsingError: If the json data could not be parsed + """ + query_data = query_data or {} + post_data = post_data or {} + + result = self.http_request( + "patch", + path, + query_data=query_data, + post_data=post_data, + raw=raw, + **kwargs, + ) + try: + json_result = result.json() + if TYPE_CHECKING: + assert isinstance(json_result, dict) + return json_result + except Exception as e: + raise gitlab.exceptions.GitlabParsingError( + error_message="Failed to parse the server message" + ) from e + def http_delete(self, path: str, **kwargs: Any) -> requests.Response: """Make a DELETE request to the Gitlab server. |