반응형
◾ start
import sys, requests
if len(sys.argv) > 1:
job_id = sys.argv[1]
else :
print ("Please Input Job ID")
exit()
url = "http://cdsw.local.com/api/v1/projects/admin/python-example/jobs/" + job_id + "/start"
user = "ua64c7h1ghddrbyexf5rf9svbbwhnsl1"
password = ""
headers = {'Content-Type': 'application/json; charset=utf-8'}
r = requests.post(url, auth=(user,password), headers=headers)
if r.status_code == 200 :
print("Success Start Job")
else :
print("Fail Start Job")
◾ status
import sys, requests
if len(sys.argv) > 1:
job_id = sys.argv[1]
else :
print ("Please Input Job ID")
exit()
url = "http://cdsw.local.com/api/v1/projects/admin/python-example/jobs/" + job_id
user = "ua64c7h1ghddrbyexf5rf9svbbwhnsl1"
password = ""
r = requests.get(url, auth=(user, password))
json_data = r.json()
json_latest = json_data["latest"]
job_name = json_data["name"]
job_status = json_latest["status"]
print ("job name: " + job_name + " ,job_status: " + job_status)