feat:(策略对象)1:策略对象删除;2:策略对象导入;3:策略对象导出

This commit is contained in:
wangxin
2020-06-28 17:35:34 +08:00
parent 8a58604003
commit d9c3832668
6 changed files with 101 additions and 2 deletions

View File

@@ -69,4 +69,61 @@ GetObjectItems
FOR ${item} IN @{data['list']}
Append To List ${itemIds} ${item['itemId']}
END
[Return] ${rescode} ${itemIds} ${data['list']}
[Return] ${rescode} ${itemIds} ${data['list']}
DeleteObjects
[Documentation]
... 删除策略对象
... params传入的删除字典
... 结构为[1,2,3]
[Arguments] ${objectIds}
${type} Evaluate isinstance(${objectIds},list)
Should Be True ${type}
${dict} Create Dictionary objectIds=${objectIds}
${json} json.Dumps ${dict} ensure_ascii=False
${response} BaseDeleteRequest /${version}${objectUrl} ${json}
${rescode} Set Variable ${response['code']}
Should Be Equal As Strings ${rescode} 200
[Return] ${rescode}
ImportObject
[Documentation]
... 策略对象导入
... filePath文件路径
... fileName文件名称
... objectType对象类型
... objectSubType对象子类型
... objectName对象名称
[Arguments] ${filePath} ${fileName} ${objectType} ${objectSubType} ${objectName}
Directory Should Exist ${path}
File Should Exist ${path}/${filePath}/${fileName}
File Should Not Be Empty ${path}/${filePath}/${fileName}
${size} Get File Size ${path}/${filePath}/${fileName}
Should Not Be Empty ${objectType}
${objectSubType} Run Keyword If "${objectType}"=="ip" and "${objectSubType}"=="${EMPTY}" Set Variable endpoint
... ELSE Set Variable ${objectSubType}
${subfix} Fetch From Right ${fileName} .
${binFile} Run Keyword If "${subfix}"=="txt" Evaluate (r'${fileName}',open(r"${path}/${filePath}/${fileName}",'rb'),'text/plain')
... ELSE IF "${subfix}"=="csv" Evaluate (r'${fileName}',open(r"${path}/${filePath}/${fileName}",'rb'),'application/vnd.ms-excel')
... ELSE ${EMPTY}
${data} Create Dictionary objectType=${objectType}
Run Keyword If "${objectSubType}"!="${EMPTY}" Set To Dictionary ${data} objectSubType=${objectSubType}
Run Keyword If "${objectName}"!="${EMPTY}" Set To Dictionary ${data} objectName=${objectName}
${file} Create Dictionary file=${binFile}
${response} BaseMultipartPostRequest ${objectUrl}/batch ${data} ${file} ${version}
${rescode} Set Variable ${response['code']}
Should Be Equal As Strings ${rescode} 200
[Return] ${rescode}
ExportObject
[Documentation]
... 策略对象导出
... objectType ip,url等
... objectSubType 子类型
... objectIds 1,2,3
... objectName 字符串
[Arguments] ${objectType} ${objectSubType} ${objectIds} ${objectName}
Should Not Be Empty ${objectType}
${params} Create Dictionary objectType=${objectType}
Run Keyword If "${objectSubType}"!="${EMPTY}" Set To Dictionary ${params} objectSubType=${objectSubType}
Run Keyword If "${objectIds}"!="${EMPTY}" Set To Dictionary ${params} objectIds=${objectIds}
Run Keyword If "${objectName}"!="${EMPTY}" Set To Dictionary ${params} objectName=${objectName}
${response} BaseGetRequestReturnBinary ${objectUrl}/batch ${params} ${version}
[Return] ${response}