Merge pull request #486 from wotschel/master

Added example for checking sync servers
pull/487/head
Raphaël Vinot 2019-10-30 11:46:03 +01:00 committed by GitHub
commit 086f44d8f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,32 @@
#!/usr/bin/env python
import requests
import json
# Suppress those "Unverified HTTPS request is being made"
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
from keys import misp_url, misp_key, misp_verifycert
proxies = {
}
'''
Checks if the connection to a sync server works
returns json object
'''
def check_connection(connection_number):
misp_headers = {'Content-Type': 'application/json', 'Accept': 'application/json', 'Authorization': misp_key}
req = requests.get(misp_url + 'servers/testConnection/{}'.format(connection_number), verify=misp_verifycert, headers=misp_headers, proxies=proxies)
result = json.loads(req.text)
return(result)
if __name__ == "__main__":
result = check_connection(1)
print(result)