package org.zstack.header.message;

import org.zstack.header.errorcode.ErrorCode;
import org.zstack.header.rest.APINoSee;

public class APIEvent extends Event {
    /**
     * @ignore
     */
	public static final String API_EVENT = "API_EVENT";

    /**
     * @ignore
     */
	@APINoSee
    @NoJsonSchema
    private Type type = null;
    /**
     * @ignore
     */
	@APINoSee
    protected final String apiId;
    /**
     * @desc indicate the failure or success. Client should evaluate this field before evaluating
     * inventory field
     * @choices true false
     */
    protected boolean success;
    /**
     * @desc indicate the reason of api failure. It presents only if success = false
     * @nullable
     */
    @NoJsonSchema
    protected ErrorCode error;

    @Override
    public final Type getType() {
        if (type == null) {
            type = new Type(Event.Category.API, getSubCategory());
        }
        return type;
    }
    
    public APIEvent() {
        apiId = null;
    }
    
    public APIEvent(String apiId) {
    	this.apiId = apiId;
    	this.success = true;
    }

	public String getApiId() {
    	return apiId;
    }

	public boolean isSuccess() {
    	return success;
    }

	public void setSuccess(boolean isSuccess) {
    	this.success = isSuccess;
    }

	
	public ErrorCode getErrorCode() {
    	return error;
    }

	public void setErrorCode(ErrorCode errorCode) {
	    this.success = false;
    	this.error = errorCode;
    }

	@Override
    public final String getSubCategory() {
	    return API_EVENT;
    }
}

@@ -718,34 +718,16 @@
      */%0A
-    @NoJsonSchema%0A
     prot

drop NoJsonSchema in APIEvent