|
| 1 | +package org.zstack.sdk.zwatch.alarm; |
| 2 | + |
| 3 | +import java.util.HashMap; |
| 4 | +import java.util.Map; |
| 5 | +import org.zstack.sdk.*; |
| 6 | + |
| 7 | +public class AddLabelToEventSubscriptionAction extends AbstractAction { |
| 8 | + |
| 9 | + private static final HashMap<String, Parameter> parameterMap = new HashMap<>(); |
| 10 | + |
| 11 | + private static final HashMap<String, Parameter> nonAPIParameterMap = new HashMap<>(); |
| 12 | + |
| 13 | + public static class Result { |
| 14 | + public ErrorCode error; |
| 15 | + public org.zstack.sdk.zwatch.alarm.AddLabelToEventSubscriptionResult value; |
| 16 | + |
| 17 | + public Result throwExceptionIfError() { |
| 18 | + if (error != null) { |
| 19 | + throw new ApiException( |
| 20 | + String.format("error[code: %s, description: %s, details: %s]", error.code, error.description, error.details) |
| 21 | + ); |
| 22 | + } |
| 23 | + |
| 24 | + return this; |
| 25 | + } |
| 26 | + } |
| 27 | + |
| 28 | + @Param(required = true, nonempty = false, nullElements = false, emptyString = true, noTrim = false) |
| 29 | + public java.lang.String subscriptionUuid; |
| 30 | + |
| 31 | + @Param(required = true, maxLength = 1024, nonempty = false, nullElements = false, emptyString = true, noTrim = false) |
| 32 | + public java.lang.String key; |
| 33 | + |
| 34 | + @Param(required = true, nonempty = false, nullElements = false, emptyString = true, noTrim = false) |
| 35 | + public java.lang.String value; |
| 36 | + |
| 37 | + @Param(required = true, validValues = {"Regex","Equal"}, nonempty = false, nullElements = false, emptyString = true, noTrim = false) |
| 38 | + public java.lang.String operator; |
| 39 | + |
| 40 | + @Param(required = false) |
| 41 | + public java.lang.String resourceUuid; |
| 42 | + |
| 43 | + @Param(required = false) |
| 44 | + public java.util.List systemTags; |
| 45 | + |
| 46 | + @Param(required = false) |
| 47 | + public java.util.List userTags; |
| 48 | + |
| 49 | + @Param(required = true) |
| 50 | + public String sessionId; |
| 51 | + |
| 52 | + @NonAPIParam |
| 53 | + public long timeout = -1; |
| 54 | + |
| 55 | + @NonAPIParam |
| 56 | + public long pollingInterval = -1; |
| 57 | + |
| 58 | + |
| 59 | + private Result makeResult(ApiResult res) { |
| 60 | + Result ret = new Result(); |
| 61 | + if (res.error != null) { |
| 62 | + ret.error = res.error; |
| 63 | + return ret; |
| 64 | + } |
| 65 | + |
| 66 | + org.zstack.sdk.zwatch.alarm.AddLabelToEventSubscriptionResult value = res.getResult(org.zstack.sdk.zwatch.alarm.AddLabelToEventSubscriptionResult.class); |
| 67 | + ret.value = value == null ? new org.zstack.sdk.zwatch.alarm.AddLabelToEventSubscriptionResult() : value; |
| 68 | + |
| 69 | + return ret; |
| 70 | + } |
| 71 | + |
| 72 | + public Result call() { |
| 73 | + ApiResult res = ZSClient.call(this); |
| 74 | + return makeResult(res); |
| 75 | + } |
| 76 | + |
| 77 | + public void call(final Completion<Result> completion) { |
| 78 | + ZSClient.call(this, new InternalCompletion() { |
| 79 | + @Override |
| 80 | + public void complete(ApiResult res) { |
| 81 | + completion.complete(makeResult(res)); |
| 82 | + } |
| 83 | + }); |
| 84 | + } |
| 85 | + |
| 86 | + protected Map<String, Parameter> getParameterMap() { |
| 87 | + return parameterMap; |
| 88 | + } |
| 89 | + |
| 90 | + protected Map<String, Parameter> getNonAPIParameterMap() { |
| 91 | + return nonAPIParameterMap; |
| 92 | + } |
| 93 | + |
| 94 | + protected RestInfo getRestInfo() { |
| 95 | + RestInfo info = new RestInfo(); |
| 96 | + info.httpMethod = "POST"; |
| 97 | + info.path = "/zwatch/events/subscriptions/{subscriptionUuid}/labels"; |
| 98 | + info.needSession = true; |
| 99 | + info.needPoll = true; |
| 100 | + info.parameterName = "params"; |
| 101 | + return info; |
| 102 | + } |
| 103 | + |
| 104 | +} |
0 commit comments