diff --git a/pom.xml b/pom.xml
index bf621d4..f89b936 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
com.yunionyun.mcp
mcclient
- 3.2.5
+ 3.2.6
jar
${project.groupId}:${project.artifactId}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/Client.java b/src/main/java/com/yunionyun/mcp/mcclient/Client.java
index 4248c54..8900270 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/Client.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/Client.java
@@ -430,4 +430,8 @@ public String joinUrl(String endpoint, String path) {
}
return String.format("%s%s", endpoint, path);
}
+
+ public String getAuthUrl() {
+ return this.authUrl;
+ }
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/EndpointType.java b/src/main/java/com/yunionyun/mcp/mcclient/EndpointType.java
index 7d3b900..a1dde4c 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/EndpointType.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/EndpointType.java
@@ -7,11 +7,13 @@ public class EndpointType extends BaseEnumConstants {
public static final EndpointType InternalURL;
public static final EndpointType PublicURL;
public static final EndpointType AdminURL;
+ public static final EndpointType ApigatewayURL;
static {
InternalURL = new EndpointType("internalURL");
PublicURL = new EndpointType("PublicURL");
AdminURL = new EndpointType("AdminURL");
+ ApigatewayURL = new EndpointType("apigateway");
}
private EndpointType(String rep) {
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/Session.java b/src/main/java/com/yunionyun/mcp/mcclient/Session.java
index 71d9bc6..901d30a 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/Session.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/Session.java
@@ -49,7 +49,15 @@ public String getHeader(String key) {
return this.headers.get(key);
}
- private String getServiceType(String service, String apiVersion) {
+ private String getApiVersionByServiceType(String service) {
+ if (service.equals("compute")) {
+ return "v2";
+ }
+ return null;
+ }
+
+ private String getServiceType(String service) {
+ String apiVersion = this.getApiVersionByServiceType(service);
if (apiVersion != null
&& apiVersion.length() > 0
&& !apiVersion.equals(DEFAULT_API_VERSION)) {
@@ -58,36 +66,89 @@ private String getServiceType(String service, String apiVersion) {
return service;
}
- public String getServiceUrl(String service, String apiVersion, EndpointType endpointType)
+ public String getServiceUrl(String service, EndpointType endpointType)
throws McClientJavaBizException {
- if (this.endpointType != null) {
- endpointType = this.endpointType;
+ String[] candidates = this.getServiceUrls(service, endpointType);
+ int randidx = (int) (Math.random() * candidates.length);
+ if (candidates.length != 0) {
+ return candidates[randidx];
+ } else {
+ // 此种情况是服务端目录列表中没有对应的url与配置文件中传入的url进行匹配
+ throw new McClientJavaBizException("服务端目录列表中没有" + service + "对应的url");
}
- // logger.debug("getServiceUrl " + service + " epType " + endpointType);
- return this.token.getServiceUrl(
- this.getServiceType(service, apiVersion), this.region, this.zone, endpointType);
}
- public String[] getServiceUrls(String service, String apiVersion, EndpointType endpointType)
+ public String[] getApigatewayServiceUrls(String service, String region, String zone, EndpointType endpointType)
+ throws McClientJavaBizException {
+ String[] urls = this.getServiceVersionUrls(service, region, zone, EndpointType.InternalURL);
+ if (urls.length == 0) {
+ // 此种情况是服务端目录列表中没有对应的url与配置文件中传入的url进行匹配
+ throw new McClientJavaBizException("服务端目录列表中没有" + service + "对应的url");
+ }
+
+ // replace URLs with authUrl prefix
+ // find the common prefix
+ String prefix = this.client.getAuthUrl();
+ int lastSlashPos = prefix.lastIndexOf("/api/s/identity");
+ if (lastSlashPos <= 0) {
+ throw new McClientJavaBizException("invalue auth_url " + this.client.getAuthUrl() + ", should be url of apigateway endpoint, e.g. https:///api/s/identity/v3");
+ }
+ String hostPart = prefix.substring(0, lastSlashPos);
+ while (hostPart.endsWith("/")) {
+ hostPart = hostPart.substring(0, hostPart.length()-1);
+ }
+ prefix = hostPart + "/api/s/" + service;
+ if (region != null && region.length() > 0) {
+ prefix += "/r/" + region;
+ if (zone != null && zone.length() > 0) {
+ prefix += "/z/" + zone;
+ }
+ }
+ String[] rets = new String[urls.length];
+ for (int i = 0; i < urls.length; i++) {
+ String url = urls[i];
+ if (url == null || url.length() < 9) {
+ continue;
+ }
+ int slashPos = url.indexOf("/", 9);
+ if (slashPos > 0) {
+ rets[i] = prefix + url.substring(slashPos);
+ } else {
+ rets[i] = prefix;
+ }
+ }
+ return rets;
+ }
+
+ public String[] getServiceVersionUrls(String service, String region, String zone, EndpointType endpointType)
+ throws McClientJavaBizException {
+ return this.token.getServiceUrls(service, region, zone, endpointType);
+ }
+
+ public String[] getServiceUrls(String service, EndpointType endpointType)
throws McClientJavaBizException {
if (this.endpointType != null) {
endpointType = this.endpointType;
}
- // logger.debug("getServiceUrl " + service + " epType " + endpointType);
- return this.token.getServiceUrls(
- this.getServiceType(service, apiVersion), this.region, this.zone, endpointType);
+ service = this.getServiceType(service);
+ if (endpointType.equals(EndpointType.ApigatewayURL)) {
+ System.out.println("getApigatewayServiceUrls");
+ return this.getApigatewayServiceUrls(service, this.region, this.zone, endpointType);
+ } else {
+ System.out.println("getServiceVersionUrls");
+ return this.getServiceVersionUrls(service, this.region, this.zone, endpointType);
+ }
}
public JSONObject jsonRequest(
String service,
- String apiVersion,
EndpointType endpointType,
String method,
String url,
HttpHeaders headers,
JSONObject jsonBody)
throws McClientJavaBizException, IOException, JSONClientException {
- String baseurl = Utils.stripURLVersion(this.getServiceUrl(service, apiVersion, endpointType));
+ String baseurl = Utils.stripURLVersion(this.getServiceUrl(service, endpointType));
logger.debug("jsonRequest " + baseurl + " token " + this.token.getToken());
HttpHeaders tmpHdr = new HttpHeaders();
if (headers != null) {
@@ -97,8 +158,8 @@ public JSONObject jsonRequest(
return this.client.jsonRequest(baseurl, this.token.getToken(), method, url, tmpHdr, jsonBody);
}
- public JSONArray jsonRequestArray(String service, String apiVersion, EndpointType endpointType, String method, String url, HttpHeaders headers, JSONObject jsonBody) throws Exception {
- String baseurl = Utils.stripURLVersion(this.getServiceUrl(service, apiVersion, endpointType));
+ public JSONArray jsonRequestArray(String service, EndpointType endpointType, String method, String url, HttpHeaders headers, JSONObject jsonBody) throws Exception {
+ String baseurl = Utils.stripURLVersion(this.getServiceUrl(service, endpointType));
logger.debug("jsonRequestArray " + baseurl + " token " + this.token.getToken());
HttpHeaders tmpHdr = new HttpHeaders();
if (headers != null) {
@@ -129,9 +190,8 @@ public void clearTaskNotifyUrl() {
this.removeHeader(TASK_NOTIFY_URL_HEAD);
}
- public JSONObject rowRequest(
+ public JSONObject rawRequest(
String service,
- String apiVersion,
EndpointType endpointType,
String method,
String url,
@@ -139,7 +199,7 @@ public JSONObject rowRequest(
InputStream body)
throws NoSuchAlgorithmException, McClientJavaBizException, IOException,
KeyManagementException, JSONClientException {
- String baseurl = Utils.stripURLVersion(this.getServiceUrl(service, apiVersion, endpointType));
+ String baseurl = Utils.stripURLVersion(this.getServiceUrl(service, endpointType));
if (this.headers != null) {
headers.update(this.headers);
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/keystone/Service.java b/src/main/java/com/yunionyun/mcp/mcclient/keystone/Service.java
index a782e4a..ccdebbb 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/keystone/Service.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/keystone/Service.java
@@ -72,7 +72,7 @@ public String[] getServiceUrls(String region, String zone, EndpointType endpoint
}
}
- public String getServiceUrl(String region, String zone, EndpointType endpointType)
+ /*public String getServiceUrl(String region, String zone, EndpointType endpointType)
throws McClientJavaBizException {
String[] candidates = this.getServiceUrls(region, zone, endpointType);
int randidx = (int) (Math.random() * candidates.length);
@@ -82,5 +82,5 @@ public String getServiceUrl(String region, String zone, EndpointType endpointTyp
// 此种情况是服务端目录列表中没有对应的url与配置文件中传入的url进行匹配
throw new McClientJavaBizException("服务端目录列表中没有" + this.type + "对应的url");
}
- }
+ }*/
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/keystone/TokenCredential.java b/src/main/java/com/yunionyun/mcp/mcclient/keystone/TokenCredential.java
index 757dfaf..eada292 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/keystone/TokenCredential.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/keystone/TokenCredential.java
@@ -138,7 +138,7 @@ public String[] getServiceUrls(
+ Endpoint.RegionID(region, zone));
}
- public String getServiceUrl(String service, String region, String zone, EndpointType endpointType)
+ /*public String getServiceUrl(String service, String region, String zone, EndpointType endpointType)
throws McClientJavaBizException {
for (int i = 0; i < this.services.length; ++i) {
if (this.services[i].getType().equals(service)) {
@@ -153,7 +153,7 @@ public String getServiceUrl(String service, String region, String zone, Endpoint
+ endpointType
+ " "
+ Endpoint.RegionID(region, zone));
- }
+ }*/
public boolean isAdmin() {
String[] roles = this.getRoles();
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/AnsibleManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/AnsibleManager.java
index 2180d7f..0df62e1 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/AnsibleManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/AnsibleManager.java
@@ -13,6 +13,6 @@ public AnsibleManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("ansible", null, endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
+ super("ansible", endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseAutoUpdateManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseAutoUpdateManager.java
index 21ed28e..431d74e 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseAutoUpdateManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseAutoUpdateManager.java
@@ -20,6 +20,6 @@ public BaseAutoUpdateManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("autoupdate", null, endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
+ super("autoupdate", endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseCloudIdManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseCloudIdManager.java
index be17d51..3addb54 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseCloudIdManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseCloudIdManager.java
@@ -20,6 +20,6 @@ public BaseCloudIdManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("cloudid", null, endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
+ super("cloudid", endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseCloudeventManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseCloudeventManager.java
index dece41c..0f71b25 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseCloudeventManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseCloudeventManager.java
@@ -20,6 +20,6 @@ public BaseCloudeventManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("cloudevent", null, endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
+ super("cloudevent", endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseDevtoolManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseDevtoolManager.java
index 4753790..f12aad6 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseDevtoolManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseDevtoolManager.java
@@ -20,6 +20,6 @@ public BaseDevtoolManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("devtool", null, endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
+ super("devtool", endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseITSMManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseITSMManager.java
index 554fcc3..5fe7076 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseITSMManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseITSMManager.java
@@ -20,6 +20,6 @@ public BaseITSMManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("itsm", null, endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
+ super("itsm", endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseLogActionManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseLogActionManager.java
index 29575e8..82aba47 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseLogActionManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseLogActionManager.java
@@ -16,6 +16,6 @@ public BaseLogActionManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("log", null, endpointType, "v1", columns, adminColumns, keyword, keywordPlural, null);
+ super("log", endpointType, "v1", columns, adminColumns, keyword, keywordPlural, null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseManager.java
index 286f879..524a1dc 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseManager.java
@@ -19,18 +19,15 @@ public class BaseManager {
String[] colums;
String[] adminColums;
String[] allColumns;
- String apiVersion;
public BaseManager(
String serviceType,
- String apiVersion,
EndpointType endpointType,
String version,
String[] columns,
String[] adminColumns) {
this.serviceType = serviceType;
this.endpointType = endpointType;
- this.apiVersion = apiVersion;
this.version = version;
this.colums = columns;
this.adminColums = adminColumns;
@@ -73,7 +70,7 @@ public String getUrl(String url) {
protected JSONObject jsonRequest(
Session s, String method, String url, HttpHeaders headers, JSONObject body)
throws McClientJavaBizException, IOException, JSONClientException {
- return s.jsonRequest(this.serviceType, this.apiVersion, this.endpointType, method, this.getUrl(url), headers, body);
+ return s.jsonRequest(this.serviceType, this.endpointType, method, this.getUrl(url), headers, body);
}
public ListResult _list(Session s, String url, String respKey)
@@ -85,7 +82,7 @@ public ListResult _list(Session s, String url, String respKey)
}
public JSONArray _listRaw(Session s, String url) throws Exception {
- return s.jsonRequestArray(this.serviceType, this.apiVersion, this.endpointType, "GET", url, (HttpHeaders) null, (JSONObject) null);
+ return s.jsonRequestArray(this.serviceType, this.endpointType, "GET", url, (HttpHeaders) null, (JSONObject) null);
}
public JSONObject _get(Session s, String url, String respKey)
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseMeterAlertManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseMeterAlertManager.java
index 9004365..a467185 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseMeterAlertManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseMeterAlertManager.java
@@ -20,6 +20,6 @@ public BaseMeterAlertManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("meteralert", null, endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
+ super("meteralert", endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseNotifyManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseNotifyManager.java
index 2c438c3..0437c3c 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseNotifyManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseNotifyManager.java
@@ -16,6 +16,6 @@ public BaseNotifyManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("notify", null, endpointType, "v2", columns, adminColumns, keyword, keywordPlural, null);
+ super("notify", endpointType, "v2", columns, adminColumns, keyword, keywordPlural, null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseSchedulerManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseSchedulerManager.java
index 5aa61f4..c373332 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseSchedulerManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseSchedulerManager.java
@@ -20,6 +20,6 @@ public BaseSchedulerManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("scheduler", null, endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
+ super("scheduler", endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseVNCProxyManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseVNCProxyManager.java
index cf50441..7dd8970 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseVNCProxyManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseVNCProxyManager.java
@@ -20,6 +20,6 @@ public BaseVNCProxyManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("vncproxy", null, endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
+ super("vncproxy", endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseWebConsoleManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseWebConsoleManager.java
index df454c4..b09f340 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseWebConsoleManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseWebConsoleManager.java
@@ -20,6 +20,6 @@ public BaseWebConsoleManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("webconsole", null, endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
+ super("webconsole", endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseWebsocketManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseWebsocketManager.java
index ece264f..04a3531 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseWebsocketManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/BaseWebsocketManager.java
@@ -16,6 +16,6 @@ public BaseWebsocketManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("websocket", null, endpointType, "v1", columns, adminColumns, keyword, keywordPlural, null);
+ super("websocket", endpointType, "v1", columns, adminColumns, keyword, keywordPlural, null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/BastionhostManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/BastionhostManager.java
index 76e17a1..d5e78a0 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/BastionhostManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/BastionhostManager.java
@@ -9,6 +9,6 @@ public BastionhostManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("bastionhost", null, endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
+ super("bastionhost", endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/CloudIdJointManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/CloudIdJointManager.java
index 59736a3..cc3bb6c 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/CloudIdJointManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/CloudIdJointManager.java
@@ -22,7 +22,6 @@ public CloudIdJointManager(
BaseCloudIdManager slave) {
super(
"cloudid",
- null,
endpointType,
null,
columns,
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/ComputeJointManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/ComputeJointManager.java
index fc9db40..f39ae8a 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/ComputeJointManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/ComputeJointManager.java
@@ -22,7 +22,6 @@ public ComputeJointManager(
ComputeManager slave) {
super(
"compute",
- "v2",
endpointType,
null,
columns,
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/ComputeManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/ComputeManager.java
index 22f1de1..a680aa8 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/ComputeManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/ComputeManager.java
@@ -16,6 +16,6 @@ public ComputeManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("compute", "v2", endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
+ super("compute", endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/ConfigManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/ConfigManager.java
index 17f29c5..8a0f05b 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/ConfigManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/ConfigManager.java
@@ -17,6 +17,6 @@ public ConfigManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("yunionconf", null, endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
+ super("yunionconf", endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/GlanceManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/GlanceManager.java
index 31c1ed4..26bc987 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/GlanceManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/GlanceManager.java
@@ -17,6 +17,6 @@ public GlanceManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("image", null, endpointType, "v1", columns, adminColumns, keyword, keywordPlural, (String) null);
+ super("image", endpointType, "v1", columns, adminColumns, keyword, keywordPlural, (String) null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/GnocchiManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/GnocchiManager.java
index f135604..1c39d17 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/GnocchiManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/GnocchiManager.java
@@ -8,6 +8,6 @@
*/
public class GnocchiManager extends ResourceManager {
public GnocchiManager(String keyword, String keywordPlural, EndpointType endpointType, String[] columns, String[] adminColumns) {
- super("metric", null, EndpointType.AdminURL, "v3", columns, adminColumns, keyword, keywordPlural, (String) null);
+ super("metric", EndpointType.AdminURL, "v3", columns, adminColumns, keyword, keywordPlural, (String) null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/JointResourceManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/JointResourceManager.java
index 951869e..4a3ef43 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/JointResourceManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/JointResourceManager.java
@@ -15,7 +15,6 @@ public class JointResourceManager extends ResourceManager {
public JointResourceManager(
String serviceType,
- String apiVersion,
EndpointType endpointType,
String version,
String[] columns,
@@ -25,7 +24,7 @@ public JointResourceManager(
String context,
ResourceManager master,
ResourceManager slave) {
- super(serviceType, apiVersion, endpointType, version, columns, adminColumns, keyword, keywordPlural, context);
+ super(serviceType, endpointType, version, columns, adminColumns, keyword, keywordPlural, context);
this.master = master;
this.slave = slave;
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/KeystoneManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/KeystoneManager.java
index 1ba956f..9957a51 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/KeystoneManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/KeystoneManager.java
@@ -17,6 +17,6 @@ public KeystoneManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("identity", null, endpointType, "v3", columns, adminColumns, keyword, keywordPlural, null);
+ super("identity", endpointType, "v3", columns, adminColumns, keyword, keywordPlural, null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/MeterManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/MeterManager.java
index d29a849..ee5cf5c 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/MeterManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/MeterManager.java
@@ -17,6 +17,6 @@ public MeterManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("meter", null, endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
+ super("meter", endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/MonitorManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/MonitorManager.java
index 4550cba..a245a08 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/MonitorManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/MonitorManager.java
@@ -17,6 +17,6 @@ public MonitorManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("monitor", null, endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
+ super("monitor", endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/ResourceManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/ResourceManager.java
index 9138eb6..e80d728 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/ResourceManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/ResourceManager.java
@@ -17,7 +17,6 @@ public class ResourceManager extends BaseManager {
public ResourceManager(
String serviceType,
- String apiVersion,
EndpointType endpointType,
String version,
String[] columns,
@@ -25,7 +24,7 @@ public ResourceManager(
String keyword,
String keywordPlural,
String context) {
- super(serviceType, apiVersion, endpointType, version, columns, adminColumns);
+ super(serviceType, endpointType, version, columns, adminColumns);
this.context = context;
this.keyword = keyword;
this.keywordPlural = keywordPlural;
@@ -358,6 +357,6 @@ public JSONObject Delete(Session s, String id)
public JSONObject upload(Session session, String path, HttpHeaders headers, InputStream body)
throws KeyManagementException, NoSuchAlgorithmException, McClientJavaBizException,
IOException, JSONClientException {
- return session.rowRequest(this.serviceType, this.apiVersion, this.endpointType, "POST", path, headers, body);
+ return session.rawRequest(this.serviceType, this.endpointType, "POST", path, headers, body);
}
}
diff --git a/src/main/java/com/yunionyun/mcp/mcclient/managers/YunionAgentManager.java b/src/main/java/com/yunionyun/mcp/mcclient/managers/YunionAgentManager.java
index 8a53275..3706420 100644
--- a/src/main/java/com/yunionyun/mcp/mcclient/managers/YunionAgentManager.java
+++ b/src/main/java/com/yunionyun/mcp/mcclient/managers/YunionAgentManager.java
@@ -21,6 +21,6 @@ public YunionAgentManager(
EndpointType endpointType,
String[] columns,
String[] adminColumns) {
- super("yunionagent", null, endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
+ super("yunionagent", endpointType, null, columns, adminColumns, keyword, keywordPlural, null);
}
}
diff --git a/src/test/java/com/yunionyun/mcp/mcclient/ApigatewayTest.java b/src/test/java/com/yunionyun/mcp/mcclient/ApigatewayTest.java
new file mode 100644
index 0000000..3756ff6
--- /dev/null
+++ b/src/test/java/com/yunionyun/mcp/mcclient/ApigatewayTest.java
@@ -0,0 +1,39 @@
+package com.yunionyun.mcp.mcclient;
+
+import com.alibaba.fastjson.JSONObject;
+import com.yunionyun.mcp.mcclient.keystone.TokenCredential;
+import com.yunionyun.mcp.mcclient.managers.ListResult;
+import com.yunionyun.mcp.mcclient.managers.impl.keystone.EndpointsV3Manager;
+import junit.framework.TestCase;
+
+/**
+ * @author zxc
+ * @date 2020/10/28
+ */
+public class ApigatewayTest extends TestCase {
+ public void test() {
+ Client cli = new Client("https://192.168.2.1/api/s/identity/v3", 500, true, true);
+ TokenCredential token = null;
+ try {
+ token = cli.Authenticate("admin", "", "Yunion", "system", "Default");
+ Session s = cli.newSession("region0", null, EndpointType.ApigatewayURL, token);
+ EndpointsV3Manager manager = new EndpointsV3Manager();
+ JSONObject query = new JSONObject();
+ query.put("details", true);
+ query.put("limit", 0);
+ System.out.println("start to query");
+ ListResult list = manager.List(s, query);
+ System.out.println("end of query");
+ if (list != null) {
+ System.out.println("results: " + list.getDataSize());
+ JSONObject[] endpoints = list.getData();
+ for (int i = 0; i < endpoints.length; i++) {
+ System.out.println(endpoints[i]);
+ }
+ }
+
+ } catch (Exception e) {
+ System.err.println("Exception" + e);
+ }
+ }
+}