aly revised this gist . Go to revision
1 file changed, 30 insertions
sfhttp.py(file created)
| @@ -0,0 +1,30 @@ | |||
| 1 | + | #!/usr/bin/env python3 | |
| 2 | + | from requests import post as _post | |
| 3 | + | import urllib3 | |
| 4 | + | urllib3.disable_warnings(category=urllib3.exceptions.InsecureRequestWarning) | |
| 5 | + | ||
| 6 | + | def post(*args, **kwargs): | |
| 7 | + | kwargs["verify"] = False | |
| 8 | + | # if not "headers" in kwargs: | |
| 9 | + | # kwargs["headers"] = {} | |
| 10 | + | # kwargs["headers"]["Content-Type"] = "application/json" | |
| 11 | + | return _post(*args, **kwargs) | |
| 12 | + | ||
| 13 | + | def query(host, port, function, data={}): | |
| 14 | + | if function == "HealthCheck": | |
| 15 | + | data = {"ClientCustomData": ""} | |
| 16 | + | return post(f"https://{host}:{port}/api/v1", json={"function": function, "data": data}).json() | |
| 17 | + | ||
| 18 | + | def main(): | |
| 19 | + | from argparse import ArgumentParser | |
| 20 | + | parser = ArgumentParser() | |
| 21 | + | parser.add_argument("host") | |
| 22 | + | parser.add_argument("function") | |
| 23 | + | parser.add_argument("--port", default=7777, type=int) | |
| 24 | + | args = parser.parse_args() | |
| 25 | + | print(query(args.host, args.port, args.function)) | |
| 26 | + | return 0 | |
| 27 | + | ||
| 28 | + | if __name__ == "__main__": | |
| 29 | + | from sys import exit | |
| 30 | + | exit(main()) | |
Newer
Older