make the cert verification optional
This commit is contained in:
		
							parent
							
								
									9820bb5069
								
							
						
					
					
						commit
						9a135847b9
					
				@ -4,7 +4,7 @@ from requests import RequestException
 | 
			
		||||
from requests_oauthlib import OAuth2Session
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def api_client(call_dict):
 | 
			
		||||
def api_client(call_dict, verify_cert=False):
 | 
			
		||||
 | 
			
		||||
    url = call_dict["url"]
 | 
			
		||||
    headers = call_dict["headers"]
 | 
			
		||||
@ -15,15 +15,15 @@ def api_client(call_dict):
 | 
			
		||||
 | 
			
		||||
    try:
 | 
			
		||||
        if method == 'GET':
 | 
			
		||||
            response = client.get(url, headers=headers, params=body, verify=False)
 | 
			
		||||
            response = client.get(url, headers=headers, params=body, verify=verify_cert)
 | 
			
		||||
        elif method == 'POST':
 | 
			
		||||
            response = client.post(url, headers=headers, json=body, verify=False)
 | 
			
		||||
            response = client.post(url, headers=headers, json=body, verify=verify_cert)
 | 
			
		||||
        elif method == 'PUT':
 | 
			
		||||
            response = client.put(url, headers=headers, json=body, verify=False)
 | 
			
		||||
            response = client.put(url, headers=headers, json=body, verify=verify_cert)
 | 
			
		||||
        elif method == 'OPTIONS':
 | 
			
		||||
            response = client.options(url, headers=headers, json=body, verify=False)
 | 
			
		||||
            response = client.options(url, headers=headers, json=body, verify=verify_cert)
 | 
			
		||||
        elif method == 'DELETE':
 | 
			
		||||
            response = client.delete(url, verify=False)
 | 
			
		||||
            response = client.delete(url, verify=verify_cert)
 | 
			
		||||
        else:
 | 
			
		||||
            raise ValueError(f"Invalid method: {method}")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user