image_service_delete.py
2.1 KB
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
61
62
63
# coding=utf-8
#author: 4N
#createtime: 2021/9/17
#email: nheweijun@sina.com
from app.util.component.ApiTemplate import ApiTemplate
from app.util.component.StructurePrint import StructurePrint
import requests
from app.util.component.UserCheck import UserCheck
class Api(ApiTemplate):
api_name = "删除ImageService服务"
def process(self):
# 返回结果
res = {}
try:
user_req: requests.Response = requests.post("{}/API/Service/Info".format(self.para.get("url")),
data={"guid":self.para.get("guid")})
if user_req.status_code == 200:
if not user_req.json().get("result"):
raise Exception("服务不存在!")
else:
raise Exception("影像服务器连接失败!")
# 验证权限
UserCheck.verify(user_req.json().get("data").get("service").get("creator"))
url = "{}/API/Service/Delete".format(self.para.get("url"))
response:requests.Response = requests.post(url,data=self.para)
if response.status_code == 200:
if not response.json().get("result"):
raise Exception("由于{},影像地图删除失败!".format(response.json().get("msg")))
else:
raise Exception("影像服务器连接失败!")
res["result"] = True
except Exception as e:
raise e
return res
api_doc = {
"tags": ["影像服务接口"],
"parameters": [
{"name": "guid",
"in": "formData",
"type": "string",
"description": "guid"},
{"name": "url",
"in": "formData",
"type": "string",
"description": "url"},
],
"responses": {
200: {
"schema": {
"properties": {
}
}
}
}
}