package org.zstack.header.image;

import org.zstack.header.errorcode.ErrorCode;
import org.zstack.header.message.APIEvent;
import org.zstack.header.rest.RestResponse;
import org.zstack.header.rest.SDK;

import java.util.ArrayList;
import java.util.List;

/**
 */
@RestResponse(fieldsTo = {"inventory", "failures=failuresOnBackupStorage"})
public class APICreateRootVolumeTemplateFromVolumeSnapshotEvent extends APIEvent {
    @SDK(sdkClassName = "CreateRootVolumeTemplateFromVolumeSnapshotFailure")
    public static class Failure {
        public String backupStorageUuid;
        public ErrorCode error;
    }

    private ImageInventory inventory;
    private List<Failure> failuresOnBackupStorage;

    public void addFailure(Failure failure) {
        if (failuresOnBackupStorage == null) {
            failuresOnBackupStorage = new ArrayList<>();
        }
        failuresOnBackupStorage.add(failure);
    }

    public List<Failure> getFailuresOnBackupStorage() {
        return failuresOnBackupStorage;
    }

    public void setFailuresOnBackupStorage(List<Failure> failuresOnBackupStorage) {
        this.failuresOnBackupStorage = failuresOnBackupStorage;
    }

    public APICreateRootVolumeTemplateFromVolumeSnapshotEvent(String apiId) {
        super(apiId);
    }

    public APICreateRootVolumeTemplateFromVolumeSnapshotEvent() {
        super(null);
    }

    public ImageInventory getInventory() {
        return inventory;
    }

    public void setInventory(ImageInventory inventory) {
        this.inventory = inventory;
    }
}

@@ -598,16 +598,414 @@
 e error;
+%0A%0A        public String getBackupStorageUuid() %7B%0A            return backupStorageUuid;%0A        %7D%0A%0A        public void setBackupStorageUuid(String backupStorageUuid) %7B%0A            this.backupStorageUuid = backupStorageUuid;%0A        %7D%0A%0A        public ErrorCode getError() %7B%0A            return error;%0A        %7D%0A%0A        public void setError(ErrorCode error) %7B%0A            this.error = error;%0A        %7D
 %0A    %7D%0A%0A

fix unit test