|
| 1 | +package org.zstack.sdk; |
| 2 | + |
| 3 | +import java.util.HashMap; |
| 4 | +import java.util.Map; |
| 5 | +import org.zstack.sdk.*; |
| 6 | + |
| 7 | +public class AddBareMetal2DpuChassisAction 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.AddBareMetal2ChassisResult value; |
| 16 | + |
| 17 | + public Result throwExceptionIfError() { |
| 18 | + if (error != null) { |
| 19 | + throw new ApiException( |
| 20 | + String.format("error[code: %s, description: %s, details: %s, globalErrorCode: %s]", error.code, error.description, error.details, error.globalErrorCode) |
| 21 | + ); |
| 22 | + } |
| 23 | + |
| 24 | + return this; |
| 25 | + } |
| 26 | + } |
| 27 | + |
| 28 | + @Param(required = true, maxLength = 2048, nonempty = false, nullElements = false, emptyString = true, noTrim = false) |
| 29 | + public java.lang.String url; |
| 30 | + |
| 31 | + @Param(required = true, maxLength = 255, nonempty = false, nullElements = false, emptyString = true, noTrim = false) |
| 32 | + public java.lang.String vendorType; |
| 33 | + |
| 34 | + @Param(required = false, nonempty = false, nullElements = false, emptyString = true, noTrim = false) |
| 35 | + public java.lang.String config; |
| 36 | + |
| 37 | + @Param(required = true, maxLength = 255, nonempty = false, nullElements = false, emptyString = false, noTrim = false) |
| 38 | + public java.lang.String name; |
| 39 | + |
| 40 | + @Param(required = false, maxLength = 2048, nonempty = false, nullElements = false, emptyString = true, noTrim = false) |
| 41 | + public java.lang.String description; |
| 42 | + |
| 43 | + @Param(required = true, nonempty = false, nullElements = false, emptyString = true, noTrim = false) |
| 44 | + public java.lang.String clusterUuid; |
| 45 | + |
| 46 | + @Param(required = false, validValues = {"Remote","Local","Direct"}, nonempty = false, nullElements = false, emptyString = true, noTrim = false) |
| 47 | + public java.lang.String provisionType = "Remote"; |
| 48 | + |
| 49 | + @Param(required = false) |
| 50 | + public java.lang.String resourceUuid; |
| 51 | + |
| 52 | + @Param(required = false, nonempty = false, nullElements = false, emptyString = true, noTrim = false) |
| 53 | + public java.util.List tagUuids; |
| 54 | + |
| 55 | + @Param(required = false) |
| 56 | + public java.util.List systemTags; |
| 57 | + |
| 58 | + @Param(required = false) |
| 59 | + public java.util.List userTags; |
| 60 | + |
| 61 | + @Param(required = false) |
| 62 | + public String sessionId; |
| 63 | + |
| 64 | + @Param(required = false) |
| 65 | + public String accessKeyId; |
| 66 | + |
| 67 | + @Param(required = false) |
| 68 | + public String accessKeySecret; |
| 69 | + |
| 70 | + @Param(required = false) |
| 71 | + public String requestIp; |
| 72 | + |
| 73 | + @NonAPIParam |
| 74 | + public long timeout = -1; |
| 75 | + |
| 76 | + @NonAPIParam |
| 77 | + public long pollingInterval = -1; |
| 78 | + |
| 79 | + |
| 80 | + private Result makeResult(ApiResult res) { |
| 81 | + Result ret = new Result(); |
| 82 | + if (res.error != null) { |
| 83 | + ret.error = res.error; |
| 84 | + return ret; |
| 85 | + } |
| 86 | + |
| 87 | + org.zstack.sdk.AddBareMetal2ChassisResult value = res.getResult(org.zstack.sdk.AddBareMetal2ChassisResult.class); |
| 88 | + ret.value = value == null ? new org.zstack.sdk.AddBareMetal2ChassisResult() : value; |
| 89 | + |
| 90 | + return ret; |
| 91 | + } |
| 92 | + |
| 93 | + public Result call() { |
| 94 | + ApiResult res = ZSClient.call(this); |
| 95 | + return makeResult(res); |
| 96 | + } |
| 97 | + |
| 98 | + public void call(final Completion<Result> completion) { |
| 99 | + ZSClient.call(this, new InternalCompletion() { |
| 100 | + @Override |
| 101 | + public void complete(ApiResult res) { |
| 102 | + completion.complete(makeResult(res)); |
| 103 | + } |
| 104 | + }); |
| 105 | + } |
| 106 | + |
| 107 | + protected Map<String, Parameter> getParameterMap() { |
| 108 | + return parameterMap; |
| 109 | + } |
| 110 | + |
| 111 | + protected Map<String, Parameter> getNonAPIParameterMap() { |
| 112 | + return nonAPIParameterMap; |
| 113 | + } |
| 114 | + |
| 115 | + protected RestInfo getRestInfo() { |
| 116 | + RestInfo info = new RestInfo(); |
| 117 | + info.httpMethod = "POST"; |
| 118 | + info.path = "/baremetal2/chassis/dpu"; |
| 119 | + info.needSession = true; |
| 120 | + info.needPoll = true; |
| 121 | + info.parameterName = "params"; |
| 122 | + return info; |
| 123 | + } |
| 124 | + |
| 125 | +} |
0 commit comments