Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eacb9635c0 | ||
|
|
0371ae9175 |
48
api/datasync/cli.py
Normal file
48
api/datasync/cli.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import json
|
||||||
|
import os
|
||||||
|
import requests
|
||||||
|
|
||||||
|
class Data_sync:
|
||||||
|
"""
|
||||||
|
## Data Sync
|
||||||
|
---
|
||||||
|
?
|
||||||
|
"""
|
||||||
|
|
||||||
|
ep: str = ""
|
||||||
|
|
||||||
|
def __init__ (self):
|
||||||
|
self.ep = "https://localhost:8443"
|
||||||
|
|
||||||
|
def __request_json_post__ (self, path: str, object: dict):
|
||||||
|
|
||||||
|
"""
|
||||||
|
## HTTP JSON POST
|
||||||
|
---
|
||||||
|
Este método é responsável por realizar requisições HTTP do tipo POST para objetos JSON.
|
||||||
|
|
||||||
|
Ele retorna o corpo de resposta da requisição, ou uma mensagem de erro, que indica qual foi a irregularidade ocorrida ao chamar a API.
|
||||||
|
"""
|
||||||
|
|
||||||
|
url = self.ep + path
|
||||||
|
print("Calling: " + url)
|
||||||
|
|
||||||
|
apikey = os.environ.get('REPLAY_APIKEY')
|
||||||
|
headers = {"X-API-KEY": apikey}
|
||||||
|
res = requests.post(url, json = object, headers = headers, verify = False)
|
||||||
|
|
||||||
|
if res.status_code >= 400:
|
||||||
|
raise Exception(f"HTTP ERROR: {str(res.status_code)} - {res.text}")
|
||||||
|
if res.headers.get("Content-Type") != None and res.headers.get("Content-Type").find("json") != -1:
|
||||||
|
return json.loads(res.text)
|
||||||
|
else:
|
||||||
|
return res.text
|
||||||
|
|
||||||
|
|
||||||
|
def new (self, data_sync_report: dict):
|
||||||
|
"""
|
||||||
|
???
|
||||||
|
"""
|
||||||
|
|
||||||
|
return self.__request_json_post__("/ipc/datasyncreportmgr/new", data_sync_report)
|
||||||
|
|
||||||
0
api/datasync/features/data_sync.feature
Normal file
0
api/datasync/features/data_sync.feature
Normal file
0
api/datasync/features/steps/steps.py
Normal file
0
api/datasync/features/steps/steps.py
Normal file
Loading…
x
Reference in New Issue
Block a user