Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions conf/db/upgrade/V5.6.0__schema_resource_lifecycle.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
CREATE TABLE IF NOT EXISTS `zstack`.`ResNotifySubscriptionVO` (
`uuid` VARCHAR(32) NOT NULL UNIQUE,
`name` VARCHAR(255) DEFAULT NULL,
`description` VARCHAR(2048) DEFAULT NULL,
`resourceTypes` VARCHAR(1024) DEFAULT NULL,
`eventTypes` VARCHAR(256) DEFAULT NULL,
`type` VARCHAR(32) NOT NULL DEFAULT 'WEBHOOK',
`state` VARCHAR(32) NOT NULL DEFAULT 'Enabled',
`lastOpDate` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`createDate` TIMESTAMP,
PRIMARY KEY (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `zstack`.`ResNotifyWebhookRefVO` (
`uuid` VARCHAR(32) NOT NULL UNIQUE,
`webhookUrl` VARCHAR(2048) NOT NULL,
`secret` VARCHAR(256) DEFAULT NULL,
`customHeaders` VARCHAR(2048) DEFAULT NULL,
`lastDeliveryTime` TIMESTAMP NULL DEFAULT NULL,
`consecutiveFailures` INT DEFAULT 0,
PRIMARY KEY (`uuid`),
CONSTRAINT `fk_ResNotifyWebhookRefVO_ResNotifySubscriptionVO`
FOREIGN KEY (`uuid`) REFERENCES `ResNotifySubscriptionVO`(`uuid`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
8 changes: 8 additions & 0 deletions sdk/src/main/java/SourceClassMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,10 @@ public class SourceClassMap {
put("org.zstack.zwatch.monitorgroup.entity.MonitorGroupTemplateRefInventory", "org.zstack.sdk.zwatch.monitorgroup.entity.MonitorGroupTemplateRefInventory");
put("org.zstack.zwatch.monitorgroup.entity.MonitorGroupTemplateRefVO", "org.zstack.sdk.zwatch.monitorgroup.entity.MonitorGroupTemplateRefVO");
put("org.zstack.zwatch.monitorgroup.entity.MonitorTemplateInventory", "org.zstack.sdk.zwatch.monitorgroup.entity.MonitorTemplateInventory");
put("org.zstack.zwatch.resnotify.ResNotifySubscriptionInventory", "org.zstack.sdk.zwatch.resnotify.ResNotifySubscriptionInventory");
put("org.zstack.zwatch.resnotify.ResNotifySubscriptionState", "org.zstack.sdk.zwatch.resnotify.ResNotifySubscriptionState");
put("org.zstack.zwatch.resnotify.ResNotifyType", "org.zstack.sdk.zwatch.resnotify.ResNotifyType");
put("org.zstack.zwatch.resnotify.ResNotifyWebhookRefInventory", "org.zstack.sdk.zwatch.resnotify.ResNotifyWebhookRefInventory");
put("org.zstack.zwatch.ruleengine.ComparisonOperator", "org.zstack.sdk.zwatch.ruleengine.ComparisonOperator");
put("org.zstack.zwatch.thirdparty.entity.SNSEndpointThirdpartyAlertHistoryInventory", "org.zstack.sdk.zwatch.thirdparty.entity.SNSEndpointThirdpartyAlertHistoryInventory");
put("org.zstack.zwatch.thirdparty.entity.ThirdpartyOriginalAlertInventory", "org.zstack.sdk.zwatch.thirdparty.entity.ThirdpartyOriginalAlertInventory");
Expand Down Expand Up @@ -1710,6 +1714,10 @@ public class SourceClassMap {
put("org.zstack.sdk.zwatch.monitorgroup.entity.MonitorGroupTemplateRefInventory", "org.zstack.zwatch.monitorgroup.entity.MonitorGroupTemplateRefInventory");
put("org.zstack.sdk.zwatch.monitorgroup.entity.MonitorGroupTemplateRefVO", "org.zstack.zwatch.monitorgroup.entity.MonitorGroupTemplateRefVO");
put("org.zstack.sdk.zwatch.monitorgroup.entity.MonitorTemplateInventory", "org.zstack.zwatch.monitorgroup.entity.MonitorTemplateInventory");
put("org.zstack.sdk.zwatch.resnotify.ResNotifySubscriptionInventory", "org.zstack.zwatch.resnotify.ResNotifySubscriptionInventory");
put("org.zstack.sdk.zwatch.resnotify.ResNotifySubscriptionState", "org.zstack.zwatch.resnotify.ResNotifySubscriptionState");
put("org.zstack.sdk.zwatch.resnotify.ResNotifyType", "org.zstack.zwatch.resnotify.ResNotifyType");
put("org.zstack.sdk.zwatch.resnotify.ResNotifyWebhookRefInventory", "org.zstack.zwatch.resnotify.ResNotifyWebhookRefInventory");
put("org.zstack.sdk.zwatch.ruleengine.ComparisonOperator", "org.zstack.zwatch.ruleengine.ComparisonOperator");
put("org.zstack.sdk.zwatch.thirdparty.entity.SNSEndpointThirdpartyAlertHistoryInventory", "org.zstack.zwatch.thirdparty.entity.SNSEndpointThirdpartyAlertHistoryInventory");
put("org.zstack.sdk.zwatch.thirdparty.entity.ThirdpartyOriginalAlertInventory", "org.zstack.zwatch.thirdparty.entity.ThirdpartyOriginalAlertInventory");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package org.zstack.sdk.zwatch.resnotify;

import java.util.HashMap;
import java.util.Map;
import org.zstack.sdk.*;

public class DeleteResNotifySubscriptionAction extends AbstractAction {

private static final HashMap<String, Parameter> parameterMap = new HashMap<>();

private static final HashMap<String, Parameter> nonAPIParameterMap = new HashMap<>();

public static class Result {
public ErrorCode error;
public org.zstack.sdk.zwatch.resnotify.DeleteResNotifySubscriptionResult value;

public Result throwExceptionIfError() {
if (error != null) {
throw new ApiException(
String.format("error[code: %s, description: %s, details: %s]", error.code, error.description, error.details)
);
}

return this;
}
}

@Param(required = true, nonempty = false, nullElements = false, emptyString = true, noTrim = false)
public java.lang.String uuid;

@Param(required = false)
public java.lang.String deleteMode = "Permissive";

@Param(required = false)
public java.util.List systemTags;

@Param(required = false)
public java.util.List userTags;

@Param(required = false)
public String sessionId;

@Param(required = false)
public String accessKeyId;

@Param(required = false)
public String accessKeySecret;

@Param(required = false)
public String requestIp;

@NonAPIParam
public long timeout = -1;

@NonAPIParam
public long pollingInterval = -1;


private Result makeResult(ApiResult res) {
Result ret = new Result();
if (res.error != null) {
ret.error = res.error;
return ret;
}

org.zstack.sdk.zwatch.resnotify.DeleteResNotifySubscriptionResult value = res.getResult(org.zstack.sdk.zwatch.resnotify.DeleteResNotifySubscriptionResult.class);
ret.value = value == null ? new org.zstack.sdk.zwatch.resnotify.DeleteResNotifySubscriptionResult() : value;

return ret;
}

public Result call() {
ApiResult res = ZSClient.call(this);
return makeResult(res);
}

public void call(final Completion<Result> completion) {
ZSClient.call(this, new InternalCompletion() {
@Override
public void complete(ApiResult res) {
completion.complete(makeResult(res));
}
});
}

protected Map<String, Parameter> getParameterMap() {
return parameterMap;
}

protected Map<String, Parameter> getNonAPIParameterMap() {
return nonAPIParameterMap;
}

protected RestInfo getRestInfo() {
RestInfo info = new RestInfo();
info.httpMethod = "DELETE";
info.path = "/zwatch/resnotify/subscriptions/{uuid}";
info.needSession = true;
info.needPoll = true;
info.parameterName = "";
return info;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.zstack.sdk.zwatch.resnotify;



public class DeleteResNotifySubscriptionResult {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package org.zstack.sdk.zwatch.resnotify;

import java.util.HashMap;
import java.util.Map;
import org.zstack.sdk.*;

public class QueryResNotifySubscriptionAction extends QueryAction {

private static final HashMap<String, Parameter> parameterMap = new HashMap<>();

private static final HashMap<String, Parameter> nonAPIParameterMap = new HashMap<>();

public static class Result {
public ErrorCode error;
public org.zstack.sdk.zwatch.resnotify.QueryResNotifySubscriptionResult value;

public Result throwExceptionIfError() {
if (error != null) {
throw new ApiException(
String.format("error[code: %s, description: %s, details: %s]", error.code, error.description, error.details)
);
}

return this;
}
}



private Result makeResult(ApiResult res) {
Result ret = new Result();
if (res.error != null) {
ret.error = res.error;
return ret;
}

org.zstack.sdk.zwatch.resnotify.QueryResNotifySubscriptionResult value = res.getResult(org.zstack.sdk.zwatch.resnotify.QueryResNotifySubscriptionResult.class);
ret.value = value == null ? new org.zstack.sdk.zwatch.resnotify.QueryResNotifySubscriptionResult() : value;

return ret;
}

public Result call() {
ApiResult res = ZSClient.call(this);
return makeResult(res);
}

public void call(final Completion<Result> completion) {
ZSClient.call(this, new InternalCompletion() {
@Override
public void complete(ApiResult res) {
completion.complete(makeResult(res));
}
});
}

protected Map<String, Parameter> getParameterMap() {
return parameterMap;
}

protected Map<String, Parameter> getNonAPIParameterMap() {
return nonAPIParameterMap;
}

protected RestInfo getRestInfo() {
RestInfo info = new RestInfo();
info.httpMethod = "GET";
info.path = "/zwatch/resnotify/subscriptions";
info.needSession = true;
info.needPoll = false;
info.parameterName = "";
return info;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.zstack.sdk.zwatch.resnotify;



public class QueryResNotifySubscriptionResult {
public java.util.List inventories;
public void setInventories(java.util.List inventories) {
this.inventories = inventories;
}
public java.util.List getInventories() {
return this.inventories;
}

public java.lang.Long total;
public void setTotal(java.lang.Long total) {
this.total = total;
}
public java.lang.Long getTotal() {
return this.total;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package org.zstack.sdk.zwatch.resnotify;

import org.zstack.sdk.zwatch.resnotify.ResNotifyType;
import org.zstack.sdk.zwatch.resnotify.ResNotifySubscriptionState;
import org.zstack.sdk.zwatch.resnotify.ResNotifyWebhookRefInventory;

public class ResNotifySubscriptionInventory {

public java.lang.String uuid;
public void setUuid(java.lang.String uuid) {
this.uuid = uuid;
}
public java.lang.String getUuid() {
return this.uuid;
}

public java.lang.String name;
public void setName(java.lang.String name) {
this.name = name;
}
public java.lang.String getName() {
return this.name;
}

public java.lang.String description;
public void setDescription(java.lang.String description) {
this.description = description;
}
public java.lang.String getDescription() {
return this.description;
}

public java.lang.String resourceTypes;
public void setResourceTypes(java.lang.String resourceTypes) {
this.resourceTypes = resourceTypes;
}
public java.lang.String getResourceTypes() {
return this.resourceTypes;
}

public java.lang.String eventTypes;
public void setEventTypes(java.lang.String eventTypes) {
this.eventTypes = eventTypes;
}
public java.lang.String getEventTypes() {
return this.eventTypes;
}

public ResNotifyType type;
public void setType(ResNotifyType type) {
this.type = type;
}
public ResNotifyType getType() {
return this.type;
}

public ResNotifySubscriptionState state;
public void setState(ResNotifySubscriptionState state) {
this.state = state;
}
public ResNotifySubscriptionState getState() {
return this.state;
}

public java.sql.Timestamp createDate;
public void setCreateDate(java.sql.Timestamp createDate) {
this.createDate = createDate;
}
public java.sql.Timestamp getCreateDate() {
return this.createDate;
}

public java.sql.Timestamp lastOpDate;
public void setLastOpDate(java.sql.Timestamp lastOpDate) {
this.lastOpDate = lastOpDate;
}
public java.sql.Timestamp getLastOpDate() {
return this.lastOpDate;
}

public ResNotifyWebhookRefInventory webhookRef;
public void setWebhookRef(ResNotifyWebhookRefInventory webhookRef) {
this.webhookRef = webhookRef;
}
public ResNotifyWebhookRefInventory getWebhookRef() {
return this.webhookRef;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.zstack.sdk.zwatch.resnotify;

public enum ResNotifySubscriptionState {
Enabled,
Disabled,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.zstack.sdk.zwatch.resnotify;

public enum ResNotifyType {
WEBHOOK,
WEBSOCKET,
}
Loading