-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCertRequester.py
More file actions
33 lines (23 loc) · 1.38 KB
/
CertRequester.py
File metadata and controls
33 lines (23 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
from pathlib import Path
from requests import Response
from AbstractRequester import AbstractRequester
class CertRequester(AbstractRequester):
def __init__(self, cert_path: Path, key_path: Path, first_part_url: str = ''):
super().__init__(first_part_url=first_part_url)
self.cert_path = cert_path
self.key_path = key_path
if not os.path.isfile(cert_path):
raise FileNotFoundError(f"{cert_path} is not a valid path. Cert file does not exist.")
if not os.path.isfile(key_path):
raise FileNotFoundError(f"{key_path} is not a valid path. Key file does not exist.")
def get(self, url: str = '', **kwargs) -> Response:
return super().get(url=url, cert=(str(self.cert_path), str(self.key_path)), **kwargs)
def post(self, url: str = '', **kwargs) -> Response:
return super().post(url=url, cert=(str(self.cert_path), str(self.key_path)), **kwargs)
def put(self, url: str = '', **kwargs) -> Response:
return super().put(url=url, cert=(str(self.cert_path), str(self.key_path)), **kwargs)
def patch(self, url: str = '', **kwargs) -> Response:
return super().patch(url=url, cert=(str(self.cert_path), str(self.key_path)), **kwargs)
def delete(self, url: str = '', **kwargs) -> Response:
return super().delete(url=url, cert=(str(self.cert_path), str(self.key_path)), **kwargs)