-
Notifications
You must be signed in to change notification settings - Fork 0
<feature>[kms]: support kms trust API #3397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package org.zstack.sdk; | ||
|
|
||
|
|
||
|
|
||
| public class CertificateInfo { | ||
|
|
||
| public java.lang.String subject; | ||
| public void setSubject(java.lang.String subject) { | ||
| this.subject = subject; | ||
| } | ||
| public java.lang.String getSubject() { | ||
| return this.subject; | ||
| } | ||
|
|
||
| public java.lang.String issuer; | ||
| public void setIssuer(java.lang.String issuer) { | ||
| this.issuer = issuer; | ||
| } | ||
| public java.lang.String getIssuer() { | ||
| return this.issuer; | ||
| } | ||
|
|
||
| public java.lang.String commonName; | ||
| public void setCommonName(java.lang.String commonName) { | ||
| this.commonName = commonName; | ||
| } | ||
| public java.lang.String getCommonName() { | ||
| return this.commonName; | ||
| } | ||
|
|
||
| public java.util.List subjectAltNamesDns; | ||
| public void setSubjectAltNamesDns(java.util.List subjectAltNamesDns) { | ||
| this.subjectAltNamesDns = subjectAltNamesDns; | ||
| } | ||
| public java.util.List getSubjectAltNamesDns() { | ||
| return this.subjectAltNamesDns; | ||
| } | ||
|
|
||
| public java.util.List subjectAltNamesIp; | ||
| public void setSubjectAltNamesIp(java.util.List subjectAltNamesIp) { | ||
| this.subjectAltNamesIp = subjectAltNamesIp; | ||
| } | ||
| public java.util.List getSubjectAltNamesIp() { | ||
| return this.subjectAltNamesIp; | ||
| } | ||
|
|
||
| public java.sql.Timestamp expiredDate; | ||
| public void setExpiredDate(java.sql.Timestamp expiredDate) { | ||
| this.expiredDate = expiredDate; | ||
| } | ||
| public java.sql.Timestamp getExpiredDate() { | ||
| return this.expiredDate; | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| package org.zstack.sdk; | ||
|
|
||
| import org.zstack.sdk.CertificateInfo; | ||
| import org.zstack.sdk.KmsIdentityInventory; | ||
|
|
||
| public class KmsInventory extends org.zstack.sdk.KeyProviderInventory { | ||
|
|
@@ -52,12 +53,20 @@ public java.lang.String getActiveIdentityUuid() { | |
| return this.activeIdentityUuid; | ||
| } | ||
|
|
||
| public java.sql.Timestamp serverCertExpiredDate; | ||
| public void setServerCertExpiredDate(java.sql.Timestamp serverCertExpiredDate) { | ||
| this.serverCertExpiredDate = serverCertExpiredDate; | ||
| public java.lang.String serverCertPem; | ||
| public void setServerCertPem(java.lang.String serverCertPem) { | ||
| this.serverCertPem = serverCertPem; | ||
| } | ||
| public java.sql.Timestamp getServerCertExpiredDate() { | ||
| return this.serverCertExpiredDate; | ||
| public java.lang.String getServerCertPem() { | ||
| return this.serverCertPem; | ||
| } | ||
|
|
||
| public CertificateInfo serverCertInfo; | ||
| public void setServerCertInfo(CertificateInfo serverCertInfo) { | ||
| this.serverCertInfo = serverCertInfo; | ||
| } | ||
| public CertificateInfo getServerCertInfo() { | ||
| return this.serverCertInfo; | ||
| } | ||
|
Comment on lines
+56
to
70
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 替换证书字段会引入 SDK 向后兼容风险。 这里将旧的过期时间表达迁移为 🔧 建议的兼容层补丁(过渡期)+ /**
+ * `@deprecated` 请改用 getServerCertInfo().getExpiredDate()
+ */
+ `@Deprecated`
+ public java.sql.Timestamp getServerCertExpiredDate() {
+ return this.serverCertInfo == null ? null : this.serverCertInfo.getExpiredDate();
+ }
+
+ /**
+ * `@deprecated` 请改用 setServerCertInfo()
+ */
+ `@Deprecated`
+ public void setServerCertExpiredDate(java.sql.Timestamp serverCertExpiredDate) {
+ if (this.serverCertInfo == null) {
+ this.serverCertInfo = new CertificateInfo();
+ }
+ this.serverCertInfo.setExpiredDate(serverCertExpiredDate);
+ }🤖 Prompt for AI Agents |
||
|
|
||
| public KmsIdentityInventory activeIdentity; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| package org.zstack.sdk.keyprovider.kms.api; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import org.zstack.sdk.*; | ||
|
|
||
| public class GetKmsServerCertFromKmsAction extends AbstractAction { | ||
|
|
||
| private static final HashMap<String, Parameter> parameterMap = new HashMap<>(); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment from zhijian.liu: 这里多个非必要的空格,定义变量直接函数内部第一行,相同的变量之间也没必要空格
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment from tao.yang: sdk脚本自动生成的内容 |
||
|
|
||
| private static final HashMap<String, Parameter> nonAPIParameterMap = new HashMap<>(); | ||
|
|
||
| public static class Result { | ||
| public ErrorCode error; | ||
| public org.zstack.sdk.keyprovider.kms.api.GetKmsServerCertFromKmsResult 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 = false, noTrim = false) | ||
| public java.lang.String uuid; | ||
|
|
||
| @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.keyprovider.kms.api.GetKmsServerCertFromKmsResult value = res.getResult(org.zstack.sdk.keyprovider.kms.api.GetKmsServerCertFromKmsResult.class); | ||
| ret.value = value == null ? new org.zstack.sdk.keyprovider.kms.api.GetKmsServerCertFromKmsResult() : 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 = "PUT"; | ||
| info.path = "/key-providers/kms/{uuid}/actions"; | ||
| info.needSession = true; | ||
| info.needPoll = true; | ||
| info.parameterName = "getKmsServerCertFromKms"; | ||
| return info; | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package org.zstack.sdk.keyprovider.kms.api; | ||
|
|
||
| import org.zstack.sdk.CertificateInfo; | ||
|
|
||
| public class GetKmsServerCertFromKmsResult { | ||
| public java.lang.String serverCertPem; | ||
| public void setServerCertPem(java.lang.String serverCertPem) { | ||
| this.serverCertPem = serverCertPem; | ||
| } | ||
| public java.lang.String getServerCertPem() { | ||
| return this.serverCertPem; | ||
| } | ||
|
|
||
| public boolean selfSigned; | ||
| public void setSelfSigned(boolean selfSigned) { | ||
| this.selfSigned = selfSigned; | ||
| } | ||
| public boolean getSelfSigned() { | ||
| return this.selfSigned; | ||
| } | ||
|
|
||
| public CertificateInfo serverCertInfo; | ||
| public void setServerCertInfo(CertificateInfo serverCertInfo) { | ||
| this.serverCertInfo = serverCertInfo; | ||
| } | ||
| public CertificateInfo getServerCertInfo() { | ||
| return this.serverCertInfo; | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| package org.zstack.sdk.keyprovider.kms.api; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import org.zstack.sdk.*; | ||
|
|
||
| public class UploadKmsClientCsrAction 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.keyprovider.kms.api.UploadKmsClientCsrResult 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 = false, noTrim = false) | ||
| public java.lang.String uuid; | ||
|
|
||
| @Param(required = true, nonempty = false, nullElements = false, emptyString = false, noTrim = false) | ||
| public java.lang.String csrPem; | ||
|
|
||
| @Param(required = true, nonempty = false, nullElements = false, emptyString = false, noTrim = false) | ||
| public java.lang.String csrKeyPem; | ||
|
|
||
| @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.keyprovider.kms.api.UploadKmsClientCsrResult value = res.getResult(org.zstack.sdk.keyprovider.kms.api.UploadKmsClientCsrResult.class); | ||
| ret.value = value == null ? new org.zstack.sdk.keyprovider.kms.api.UploadKmsClientCsrResult() : 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 = "PUT"; | ||
| info.path = "/key-providers/kms/{uuid}/actions"; | ||
| info.needSession = true; | ||
| info.needPoll = true; | ||
| info.parameterName = "uploadKmsClientCsr"; | ||
| return info; | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package org.zstack.sdk.keyprovider.kms.api; | ||
|
|
||
| import org.zstack.sdk.KmsIdentityInventory; | ||
|
|
||
| public class UploadKmsClientCsrResult { | ||
| public KmsIdentityInventory inventory; | ||
| public void setInventory(KmsIdentityInventory inventory) { | ||
| this.inventory = inventory; | ||
| } | ||
| public KmsIdentityInventory getInventory() { | ||
| return this.inventory; | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment from zhijian.liu:
最好能够指定泛型
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment from tao.yang:
sdk脚本自动生成的内容