
finished the necessary setups for the test case regarding the namespace and some HTTPS certificates Change-Id: I59c67de09a0799c733196f66b9e8028b9c4a36a4 Signed-off-by: Gabriel Calixto de Paula <gabrielcalixto9@gmail.com>
43 lines
1.4 KiB
Python
43 lines
1.4 KiB
Python
import requests
|
|
from urllib3.exceptions import InsecureRequestWarning
|
|
|
|
from framework.rest.rest_response import RestResponse
|
|
|
|
|
|
class RestClient:
|
|
"""
|
|
Rest client used for making any rest calls
|
|
"""
|
|
|
|
def __init__(self):
|
|
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
|
|
|
|
def get(self, url: str, headers: list[dict[str, str]] = None) -> RestResponse:
|
|
"""
|
|
Runs a get request with the given url and headers
|
|
|
|
Args:
|
|
url (str): The URL for the request.
|
|
headers (list[dict[str, str]], optional): A list of dictionaries containing header key-value pairs. Defaults to None.
|
|
|
|
Returns:
|
|
RestResponse: An object representing the response of the GET request.
|
|
"""
|
|
response = requests.get(url, headers=headers, verify=False)
|
|
return RestResponse(response)
|
|
|
|
def post(self, url: str, data, headers: list[dict[str, str]]) -> RestResponse:
|
|
"""
|
|
Runs a post request with the given url and headers
|
|
|
|
Args:
|
|
url (str): The URL for the request.
|
|
data: The data to be sent in the body of the request.
|
|
headers (list[dict[str, str]]): The headers to be used for the request.
|
|
|
|
Returns:
|
|
RestResponse: An object containing the response from the request.
|
|
"""
|
|
response = requests.post(url, headers=headers, data=data, verify=False)
|
|
return RestResponse(response)
|