summaryrefslogtreecommitdiff
path: root/gitlab/client.py
diff options
context:
space:
mode:
Diffstat (limited to 'gitlab/client.py')
-rw-r--r--gitlab/client.py63
1 files changed, 50 insertions, 13 deletions
diff --git a/gitlab/client.py b/gitlab/client.py
index b791c8f..72e9816 100644
--- a/gitlab/client.py
+++ b/gitlab/client.py
@@ -18,6 +18,7 @@
import os
import time
+import warnings
from typing import Any, cast, Dict, List, Optional, Tuple, TYPE_CHECKING, Union
import requests
@@ -549,7 +550,7 @@ class Gitlab(object):
def _check_redirects(self, result: requests.Response) -> None:
# Check the requests history to detect 301/302 redirections.
- # If the initial verb is POST or PUT, the redirected request will use a
+ # If the initial method is POST or PUT, the redirected request will use a
# GET request, leading to unwanted behaviour.
# If we detect a redirection with a POST or a PUT request, we
# raise an exception with a useful error message.
@@ -618,10 +619,44 @@ class Gitlab(object):
max_retries: int = 10,
**kwargs: Any,
) -> requests.Response:
+ warnings.warn(
+ "The Gitlab.http_request() method is deprecated and will be removed in a "
+ "future version. This is a private method and should not be used.",
+ DeprecationWarning,
+ )
+ return self._http_request(
+ method=verb,
+ path=path,
+ query_data=query_data,
+ post_data=post_data,
+ raw=raw,
+ streamed=streamed,
+ files=files,
+ timeout=timeout,
+ obey_rate_limit=obey_rate_limit,
+ max_retries=max_retries,
+ **kwargs,
+ )
+
+ def _http_request(
+ self,
+ *,
+ method: str,
+ path: str,
+ query_data: Optional[Dict[str, Any]] = None,
+ post_data: Optional[Union[Dict[str, Any], bytes]] = None,
+ raw: bool = False,
+ streamed: bool = False,
+ files: Optional[Dict[str, Any]] = None,
+ timeout: Optional[float] = None,
+ obey_rate_limit: bool = True,
+ max_retries: int = 10,
+ **kwargs: Any,
+ ) -> requests.Response:
"""Make an HTTP request to the Gitlab server.
Args:
- verb: The HTTP method to call ('get', 'post', 'put', 'delete')
+ method: The HTTP method to call ('get', 'post', 'put', 'delete')
path: Path or full URL to query ('/projects' or
'http://whatever/v4/api/projecs')
query_data: Data to send as query parameters
@@ -678,7 +713,7 @@ class Gitlab(object):
cur_retries = 0
while True:
result = self.session.request(
- method=verb,
+ method=method,
url=url,
json=json,
data=data,
@@ -758,8 +793,8 @@ class Gitlab(object):
GitlabParsingError: If the json data could not be parsed
"""
query_data = query_data or {}
- result = self.http_request(
- "get", path, query_data=query_data, streamed=streamed, **kwargs
+ result = self._http_request(
+ method="get", path=path, query_data=query_data, streamed=streamed, **kwargs
)
if (
@@ -855,9 +890,9 @@ class Gitlab(object):
query_data = query_data or {}
post_data = post_data or {}
- result = self.http_request(
- "post",
- path,
+ result = self._http_request(
+ method="post",
+ path=path,
query_data=query_data,
post_data=post_data,
files=files,
@@ -903,9 +938,9 @@ class Gitlab(object):
query_data = query_data or {}
post_data = post_data or {}
- result = self.http_request(
- "put",
- path,
+ result = self._http_request(
+ method="put",
+ path=path,
query_data=query_data,
post_data=post_data,
files=files,
@@ -933,7 +968,7 @@ class Gitlab(object):
Raises:
GitlabHttpError: When the return code is not 2xx
"""
- return self.http_request("delete", path, **kwargs)
+ return self._http_request(method="delete", path=path, **kwargs)
@gitlab.exceptions.on_http_error(gitlab.exceptions.GitlabSearchError)
def search(
@@ -987,7 +1022,9 @@ class GitlabList(object):
self, url: str, query_data: Optional[Dict[str, Any]] = None, **kwargs: Any
) -> None:
query_data = query_data or {}
- result = self._gl.http_request("get", url, query_data=query_data, **kwargs)
+ result = self._gl._http_request(
+ method="get", path=url, query_data=query_data, **kwargs
+ )
try:
links = result.links
if links: