package org.zstack.header.vm;

import org.springframework.http.HttpMethod;
import org.zstack.header.identity.Action;
import org.zstack.header.message.APIEvent;
import org.zstack.header.message.APIMessage;
import org.zstack.header.message.APIParam;
import org.zstack.header.network.l3.L3NetworkVO;
import org.zstack.header.other.APIAuditor;
import org.zstack.header.rest.APINoSee;
import org.zstack.header.rest.RestRequest;

/**
 * Created by frank on 7/18/2015.
 */
@Action(category = VmInstanceConstant.ACTION_CATEGORY)
@RestRequest(
        path = "/vm-instances/nics/{vmNicUuid}",
        method = HttpMethod.DELETE,
        responseClass = APIDetachL3NetworkFromVmEvent.class
)
public class APIDetachL3NetworkFromVmMsg extends APIMessage implements VmInstanceMessage, APIAuditor {
    @APIParam(resourceType = VmNicVO.class, checkAccount = true, operationTarget = true)
    private String vmNicUuid;
    @APINoSee
    private String vmInstanceUuid;

    // for audit purpose only
    @APINoSee
    public String l3Uuid;

    public String getVmNicUuid() {
        return vmNicUuid;
    }

    public void setVmNicUuid(String vmNicUuid) {
        this.vmNicUuid = vmNicUuid;
    }

    @Override
    public String getVmInstanceUuid() {
        return vmInstanceUuid;
    }

    public void setVmInstanceUuid(String vmInstanceUuid) {
        this.vmInstanceUuid = vmInstanceUuid;
    }
 
    public static APIDetachL3NetworkFromVmMsg __example__() {
        APIDetachL3NetworkFromVmMsg msg = new APIDetachL3NetworkFromVmMsg();
        msg.vmNicUuid = uuid();
        return msg;
    }

    @Override
    public Result audit(APIMessage msg, APIEvent rsp) {
        return new Result(((APIDetachL3NetworkFromVmMsg)msg).l3Uuid, L3NetworkVO.class);
    }
}

@@ -333,16 +333,64 @@
 uditor;%0A
+import org.zstack.header.other.APIMultiAuditor;%0A
 import o
@@ -465,16 +465,68 @@
 quest;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.List;%0A%0A
 /**%0A * C
@@ -868,16 +868,21 @@
 age, API
+Multi
 Auditor 
@@ -1056,38 +1056,8 @@
 d;%0A%0A
-    // for audit purpose only%0A
     
@@ -1456,17 +1456,16 @@
 ;%0A    %7D%0A
- 
 %0A    pub
@@ -1684,16 +1684,38 @@
 lic 
-Result a
+List%3CAPIAuditor.Result%3E multiA
 udit
@@ -1759,27 +1759,43 @@
     
-return new Result((
+APIDetachL3NetworkFromVmMsg amsg = 
 (API
@@ -1823,12 +1823,199 @@
 Msg)
+ 
 msg
-)
+;%0A        List%3CAPIAuditor.Result%3E res = new ArrayList%3C%3E();%0A        res.add(new APIAuditor.Result(amsg.getVmInstanceUuid(), VmInstanceVO.class));%0A        res.add(new APIAuditor.Result(amsg
 .l3U
@@ -2037,16 +2037,38 @@
 O.class)
+);%0A%0A        return res
 ;%0A    %7D%0A

Fix Bug :卸载云主机网卡时云主机没有审计记录