/
1-create-task.py
60 lines (52 loc) · 1.31 KB
/
1-create-task.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import requests
my_host = "http://10.200.1.11"
my_auth = ('admin', 'password')
def create_task():
task = {
"rule": {
"name": "Workshop",
"comment": "",
"type": 36,
"sources": [
{
"file": {
"id": "/nfs-primary/bamfiles"
}
}
],
"destinations": [
{
"nas_pool": {
"id": 5,
}
}
],
"schedule": None,
"priority": 7,
"options": [
{
"type": 205,
"value": "1"
},
{
"type": 209,
"value": "1"
},
{
"type": 300,
"value": "1"
}
],
"metadata": {},
"file_action": 1
}
}
url = "{host}/api/rules".format(host=my_host)
resp = requests.post(url, json=task, auth=my_auth)
res = resp.json()
if res['code'] == 200:
return res['rule']['id']
else:
raise Exception(res)
task_id = create_task()
print("Task id is {}".format(task_id))