${return} ${policyId} Run Keyword And Ignore Error Get From Dictionary ${policy} policyId
Run Keyword If "${opAction}"=="update" and "${return}"=="FAIL" Fail policyId is required when opAction is update
Run Keyword If "${opAction}"=="update" and "${policyId}"=="${EMPTY}" Fail policyId is required when opAction is update
Run Keyword If "${opAction}"=="disable" and "${return}"=="FAIL" Fail policyId is required when opAction is disable
Run Keyword If "${opAction}"=="disable" and "${policyId}"=="${EMPTY}" Fail policyId is required when opAction is disable
Run Keyword If "${opAction}"=="enable" and "${return}"=="FAIL" Fail policyId is required when opAction is enable
Run Keyword If "${opAction}"=="enable" and "${policyId}"=="${EMPTY}" Fail policyId is required when opAction is enable
${policyId} Run Keyword If "${opAction}"=="add" Set Variable ${EMPTY}
... ELSE Get From Dictionary ${policy} policyId
Set To Dictionary ${returnDict} policyId=${policyId}
${return} ${policyType} Run Keyword And Ignore Error Get From Dictionary ${policy} policyType
Run Keyword If "${return}"=="FAIL" or "${policyType}"=="${EMPTY}" Set To Dictionary ${returnDict} policyType=${Default_PolicyType}
... ELSE Set To Dictionary ${returnDict} policyType=${policyType}
#enable disable直接返回json
Run Keyword And Return If "${opAction}"=="enable" or "${opAction}"=="disable" ManagePolicyEnableAndDisable ${returnDict} ${opAction}
# 取可选参数,为传入设置默认值
${return} ${policyName} Run Keyword And Ignore Error Get From Dictionary ${policy} policyName
Run Keyword If "${return}"=="FAIL" or "${policyName}"=="${EMPTY}" Set To Dictionary ${returnDict} policyName=${Default_PolicyName}
... ELSE Set To Dictionary ${returnDict} policyName=${policyName}
#policyDesc 不是必填的选项
${return} ${policyDesc} Run Keyword And Ignore Error Get From Dictionary ${policy} policyDesc
Run Keyword If "${return}"=="FAIL" or "${policyDesc}"=="${EMPTY}" Set To Dictionary ${returnDict} policyDesc=${Default_PolicyDesc}
... ELSE Set To Dictionary ${returnDict} policyDesc=${policyDesc}
${return} ${action} Run Keyword And Ignore Error Get From Dictionary ${policy} action
Run Keyword If "${return}"=="FAIL" or "${action}"=="${EMPTY}" Set To Dictionary ${returnDict} action=${Default_Action}
... ELSE Set To Dictionary ${returnDict} action=${action}
#userTags 不是必填的选项
${return} ${userTags} Run Keyword And Ignore Error Get From Dictionary ${policy} userTags
Run Keyword If "${return}"=="FAIL" or "${userTags}"=="${EMPTY}" Set To Dictionary ${returnDict} userTags=${Default_UserTags}
... ELSE Set To Dictionary ${returnDict} userTags=${userTags}
${return} ${doLog} Run Keyword And Ignore Error Get From Dictionary ${policy} doLog
Run Keyword If "${return}"=="FAIL" or "${doLog}"=="${EMPTY}" Set To Dictionary ${returnDict} doLog=${Default_DoLog}
... ELSE Set To Dictionary ${returnDict} doLog=${doLog}
${return} ${isValid} Run Keyword And Ignore Error Get From Dictionary ${policy} isValid
Run Keyword If "${return}"=="FAIL" or "${isValid}"=="${EMPTY}" Set To Dictionary ${returnDict} isValid=${Default_IsValid}
... ELSE Set To Dictionary ${returnDict} isValid=${isValid}
${return} ${scheduleId} Run Keyword And Ignore Error Get From Dictionary ${policy} scheduleId
${scheduleIdV} Run Keyword If "${return}"!="FAIL" and "${scheduleId}"!="${EMPTY}" and "${scheduleId}"!="${None}" Evaluate list(map(int, re.split('[,]', '${scheduleId}'))) re
... ELSE Set Variable ${emptyList}
Set To Dictionary ${returnDict} scheduleId=${scheduleIdV}
${return} ${appObjectIdArray} Run Keyword If "${policyObjectVersion}"=="v1" Run Keyword And Ignore Error Get From Dictionary ${policy} appObjectIdArray
... ELSE Run Keyword And Ignore Error Get From Dictionary ${policy} appIdObjects
#${appObjectIdArrayV} Run Keyword If "${return}"=="FAIL" or "${appObjectIdArray}"=="${EMPTY}" Evaluate list(map(int, re.split('[,]', '${Default_AppObjectIdArray}'))) re
${appObjectIdArrayV} Run Keyword If "${return}"=="FAIL" or "${appObjectIdArray}"=="${EMPTY}" Evaluate ${Default_AppObjectIdArray} re
... ELSE Evaluate list(map(int, re.split('[,]', '${appObjectIdArray}'))) re
Run Keyword If "${policyObjectVersion}"=="v1" Set To Dictionary ${returnDict} appObjectIdArray=${appObjectIdArrayV}
... ELSE IF "${policyObjectVersion}"=="v2" Set To Dictionary ${returnDict} appIdObjects=${appObjectIdArrayV}
# 固定值
Set To Dictionary ${returnDict} doBlacklist=${0}
# 分别处理EffectiveRange、UserRegion和ReferenceObject参数
ProcessEffectiveRange ${policy} ${returnDict}
#WxManageUserRegion ${policy}
Run Keyword If "${policyObjectVersion}"=="v1" ProcessReferenceObject ${policy} ${returnDict}
... ELSE IF "${policyObjectVersion}"=="v2" ManageObjectV2 ${policy} ${returnDict}
#先取出useragion 再放回json
${return} ${userRegion} Run Keyword And Ignore Error Get From Dictionary ${policy} userRegion
Set To Dictionary ${returnDict} userRegion=${Default_UserRegion}
${userRegion} Run Keyword If "${return}"=="FAIL" or '${userRegion}'=="${EMPTY}" Set Variable ""
... ELSE Set Variable ${userRegion}
#针对主动防御特殊处理,主动防御不应用对象
${active_defence_emptyList} Create List
${return} ${policyType} Run Keyword And Ignore Error Get From Dictionary ${policy} policyType
Run Keyword If "${policyObjectVersion}"=="v1" and "${policyType}"=="active_defence" Set To Dictionary ${returnDict} referenceObject=${active_defence_emptyList}
Run Keyword If "${policyObjectVersion}"=="v1" and "${policyType}"=="active_defence" Set To Dictionary ${returnDict} appObjectIdArray=${active_defence_emptyList}
#v版本主动防御
Run Keyword If "${policyObjectVersion}"=="v2" and "${policyType}"=="active_defence" Set To Dictionary ${returnDict} source=${active_defence_emptyList}
Run Keyword If "${policyObjectVersion}"=="v2" and "${policyType}"=="active_defence" Set To Dictionary ${returnDict} destination=${active_defence_emptyList}
Run Keyword If "${policyObjectVersion}"=="v2" and "${policyType}"=="active_defence" Set To Dictionary ${returnDict} filterList=${active_defence_emptyList}
Run Keyword If "${policyObjectVersion}"=="v2" and "${policyType}"=="active_defence" Set To Dictionary ${returnDict} appIdObjects=${active_defence_emptyList}
#针对WAN NAT特殊处理
${wannat_emptyList} Create List
${return} ${policyType} Run Keyword And Ignore Error Get From Dictionary ${policy} policyType
Run Keyword If "${policyObjectVersion}"=="v2" and "${policyType}"=="wannat" Set To Dictionary ${returnDict} appIdObjects=${wannat_emptyList}
Run Keyword If "${policyObjectVersion}"=="v2" and "${policyType}"=="wannat" Set To Dictionary ${returnDict} filterList=${wannat_emptyList}
Dictionary Should Contain Key ${policyObject} policyId
Dictionary Should Contain Key ${policyObject} policyType
${policyId} Get From Dictionary ${policyObject} policyId
Run Keyword If "${policyId}"=="${EMPTY}" Should Not Be Empty ${policyId}
${policyType} Get From Dictionary ${policyObject} policyType
Should Not Be Empty ${policyType}
${return} ${beforePolicyId} Run Keyword And Ignore Error Get From Dictionary ${policyObject} beforePolicyId
${return1} ${afterPolicyId} Run Keyword And Ignore Error Get From Dictionary ${policyObject} afterPolicyId
Run Keyword If "${return}"=="FAIL" and "${return1}"=="FAIL" Fail beforePolicyId和 afterPolicyId必须设置一个!
Run Keyword If "${return}"=="PASS" and "${return1}"=="PASS" and "${beforePolicyId}"=="${EMPTY}" and "${afterPolicyId}"=="${EMPTY}" Fail beforePolicyId和 afterPolicyId不能同时为空!