summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author赵坤 <[email protected]>2023-10-08 03:07:25 +0000
committer赵坤 <[email protected]>2023-10-08 03:07:25 +0000
commit55a4de8579d42ab5b91893c3b6b445b3bb27d1eb (patch)
treeb931423a9efeb6c494e262daa09d696543750700
parentbd1fa68aa368260ce6a4d1923af260e30348eec6 (diff)
上传新文件
-rw-r--r--createIpObject.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/createIpObject.py b/createIpObject.py
new file mode 100644
index 0000000..ef0f1d0
--- /dev/null
+++ b/createIpObject.py
@@ -0,0 +1,55 @@
+#!/usr/bin/python3
+# coding=utf-8
+import time
+import requests
+import json
+
+class CreateIpObject():
+ def __init__(self, token, ip):
+ # self.headers = {"token": ""}
+ self.headers = {'Content-Type': 'application/x-www-form-urlencoded', 'token': token}
+ self.headers["token"] = token
+ self.ipJson = {
+ "opAction": "add",
+ "returnData": 1,
+ "objectList": [
+ {
+ "isExclusion": 0,
+ "objectId": "",
+ "objectName": "test",
+ "objectType": "ip",
+ "objectSubType": "endpoint",
+ "iconColor": "",
+ "objectDesc": "",
+ "subObjectList": [],
+ "SubObjectID": [],
+ "memberType": 1,
+ "addItemList": [
+ {
+ "ip": "1.1.1.1",
+ "port": "0-65535",
+ "isSession": "endpoint",
+ "errInfos": [],
+ "ip1": "1.1.1.1",
+ "ip2": "1.1.1.1",
+ "ipFormat": "range",
+ "addrType": 4,
+ "line": 0
+ }
+ ],
+ "updateItemList": [],
+ "deleteItemIds": []
+ }
+ ],
+ "vsysId": 1
+ }
+
+ def createIp(self):
+ url = "http://192.168.44.72/v1/policy/object"
+ response = requests.post(url, headers=self.headers, params=self.ipJson)
+ ipJsonData = json.loads(response.text)
+ return ipJsonData
+
+if __name__ == '__main__':
+ ipObject = CreateIpObject()
+ time.sleep(3) \ No newline at end of file