-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmdb-1.py
More file actions
134 lines (80 loc) · 2.95 KB
/
cmdb-1.py
File metadata and controls
134 lines (80 loc) · 2.95 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# -*- coding:utf-8 -*-
import requests
import json
host = "http://172.16.228.114"
url =host+'/api/v3/biz/with_reduced?sort=bk_biz_name'
url = 'http://cmdb.bk.fsg.inner/api/v3/object/classification/0/objects'
headers ={"BK_USER":"sunxiaoning","HTTP_BLUEKING_SUPPLIER_ID": "0"}
params1 = {'bk_app_code':'bk_cmdb','bk_app_secret':'e4e5482a-2037-4a89-bc21-cf8ffd04883b',"bk_username":"admin","bk_biz_id":2,"job_instance_id":28659}
params ={
"bk_app_code": "bk_cmdb",
"bk_app_secret": "xxxxxxx",
"bk_username":"admin","bk_biz_id":2,
"bk_token": "",
"BK_USER":"admin",
"HTTP_BLUEKING_SUPPLIER_ID": 0,
"cc3": "MTU3OTA2MTkzM3xOd3dBTkZwTFdFZENTa00zU2xaQlZGTkVOMGswVUZJMFZWbEZOekpPVXpVMlNsTXpXVWhSTlUxRlJFb3lSRFZCV1U5VFFqUkVURUU9fC0lpyw0AsnBynithBEMWHPS3XJL"
}
resp =requests.get(url,params=params,headers=headers)
print (resp.content.decode('utf-8'))
url =host+'/api/v3/biz/simplify?sort=bk_biz_name'
params ={
"bk_supplier_account": "123456789",
"data": {
"bk_biz_name": "cc_app_test",
"bk_biz_maintainer": "admin",
"bk_biz_productor": "admin",
"bk_biz_developer": "admin",
"bk_biz_tester": "admin",
"time_zone": "Asia/Shanghai"
}
}
resp =requests.post(url,data=params,headers=headers)
print (resp.content.decode('utf-8'))
url =host+'/api/v3/biz/create_business'
params ={
"bk_supplier_account": "123456789",
"life_cycle": "2",
"language": "1",
"bk_biz_maintainer": "admin",
"bk_biz_name": "这个参数",
"time_zone": "Africa/Accra",
}
json = {
"bk_biz_name": "测试 录入",
"bk_biz_maintainer": "admin",
"bk_biz_productor": "admin",
"bk_biz_developer": "admin",
"bk_biz_tester": "admin",
"time_zone": "Africa/Accra",
"language": "1",
}
resp =requests.post(url,json=params, headers=headers)
print (resp.content.decode('utf-8'))
'''
result = json.loads(resp.content)
data =result["data"][0]["step_results"][0]["ip_logs"][0]["log_content"]
print (data)
'''
#发送get请求并得到结果
# url = 'http://api.nnzhp.cn/api/user/stu_info?stu_name=小黑马 '#请求接口
# req = requests.get(url)#发送请求
# print(req.text)#获取请求,得到的是json格式
# print(req.json())#获取请求,得到的是字典格式
# print(type(req.text))
# print(type(req.json()))
#发送post请求,注册接口
# url = 'http://api.nnzhp.cn/api/user/user_reg'
# data = {'username':'mpp0130','pwd':'Mp123456','cpwd':'Mp123456'}
# req = requests.post(url,data)#发送post请求,第一个参数是URL,第二个参数是请求数据
# print(req.json())
#入参是json
# url = 'http://api.nnzhp.cn/api/user/add_stu'
# data = {'name':'mapeipei','grade':'Mp123456','phone':15601301234}
# req = requests.post(url,json=data)
# print(req.json())
#添加header
# url = 'http://api.nnzhp.cn/api/user/all_stu'
# header = {'Referer':'http://api.nnzhp.cn/'}
# res = requests.get(url,headers=header)
# print(res.json())