public String getServiceBasePath(OnapService srv) throws OnapCommandException {
if (srv.getName().equals(OnapCommandConfg.getApiGateway())) {
return this.getMsbUrl();
+ } else if (srv.isModeDirect()){
+ return this.creds.getMsbUrl();
}
+
HttpInput input = new HttpInput().setUri(this.creds.getMsbUrl()
+ String.format(Constants.MSB_SERVICE_URI, srv.getName(), srv.getVersion()));
HttpResult result = this.http.get(input);
package org.onap.cli.fw.ad;
+import org.onap.cli.fw.conf.Constants;
+
/**
- * Onap Service as reported in Onap MSB like msb v1 or /api/microservice/v1.
+ * Onap Service as reported in api catalog.
*/
public class OnapService {
/*
private String basePath;
+ /**
+ * Mode of service consideration. By default, it goes with
+ * 'catalog' mode, where basePath will be discovered by
+ * the framework using serviceName and serviceVersion
+ * Another mode is 'direct', in which bastPath will be
+ * same as OnapCredentails.ServiceUrl.
+ */
+ private String mode = Constants.MODE_CATALOG;
+
private boolean noAuth = false;
+ public String getMode() {
+ return mode;
+ }
+
+ public void setMode(String mode) {
+ this.mode = mode;
+ }
+
+ public boolean isModeDirect() {
+ return this.getMode().equals(Constants.MODE_DIRECT);
+ }
+
public boolean isNoAuth() {
return noAuth;
}
return this.getName() + " " + this.getVersion();
}
-}
+}
\ No newline at end of file
public static final String VERSION = "version";
public static final String BASE_PATH = "base_path";
public static final String NO_AUTH = "no-auth";
+ public static final String MODE = "mode";
+ public static final String MODE_DIRECT = "direct";
+ public static final String MODE_CATALOG = "catalog";
public static final String SHORT_OPTION = "short_option";
public static final String LONG_OPTION = "long_option";
} else if (Constants.NO_AUTH.equals(key1)) {
Object obj = map.get(key1);
srv.setNoAuth("true".equalsIgnoreCase(obj.toString()));
+ } else if (Constants.MODE.equals(key1)) {
+ Object obj = map.get(key1);
+ //TODO mrkanag Validate and raise exception for invalid case
+ srv.setMode(obj.toString());
}
}