aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--framework/src/main/java/org/onap/cli/fw/conf/Constants.java2
-rw-r--r--framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java583
-rw-r--r--plugins/aai/src/main/resources/onap-cli-schema/customer/customer-delete-schema.yaml29
-rw-r--r--plugins/aai/src/main/resources/onap-cli-schema/customer/customer-list-schema.yaml5
-rw-r--r--plugins/aai/src/main/resources/onap-cli-schema/service-type/service-type-delete-schema.yaml33
-rw-r--r--plugins/aai/src/main/resources/onap-cli-schema/service-type/service-type-list-schema.yaml5
-rw-r--r--pom.xml8
7 files changed, 404 insertions, 261 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/conf/Constants.java b/framework/src/main/java/org/onap/cli/fw/conf/Constants.java
index d559f7aa..a3724275 100644
--- a/framework/src/main/java/org/onap/cli/fw/conf/Constants.java
+++ b/framework/src/main/java/org/onap/cli/fw/conf/Constants.java
@@ -57,7 +57,7 @@ public class Constants {
//http
public static final String URI = "uri";
public static final String BODY = "body";
- public static final String MERHOD = "method";
+ public static final String METHOD_TYPE = "method";
public static final String HEADERS = "headers";
public static final String QUERIES = "queries";
public static final String COOKIES = "cookies";
diff --git a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
index b6e64f2a..9b56dece 100644
--- a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
+++ b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
@@ -25,7 +25,6 @@ import org.onap.cli.fw.ad.OnapCredentials;
import org.onap.cli.fw.ad.OnapService;
import org.onap.cli.fw.cmd.OnapHttpCommand;
import org.onap.cli.fw.cmd.OnapSwaggerCommand;
-import org.onap.cli.fw.conf.Constants;
import org.onap.cli.fw.conf.OnapCommandConfg;
import org.onap.cli.fw.error.OnapCommandDiscoveryFailed;
import org.onap.cli.fw.error.OnapCommandException;
@@ -119,7 +118,7 @@ import static org.onap.cli.fw.conf.Constants.INPUT_PARAMS_MANDATORY_LIST;
import static org.onap.cli.fw.conf.Constants.IS_OPTIONAL;
import static org.onap.cli.fw.conf.Constants.IS_SECURED;
import static org.onap.cli.fw.conf.Constants.LONG_OPTION;
-import static org.onap.cli.fw.conf.Constants.MERHOD;
+import static org.onap.cli.fw.conf.Constants.METHOD_TYPE;
import static org.onap.cli.fw.conf.Constants.METHOD;
import static org.onap.cli.fw.conf.Constants.MODE;
import static org.onap.cli.fw.conf.Constants.MODE_VALUES;
@@ -364,276 +363,324 @@ public class OnapCommandUtils {
for (String key : sections) {
- if (NAME.equals(key) && values.containsKey(key)) {
- Object val = values.get(key);
- if (val != null) {
- cmd.setName(val.toString());
- }
- } else if (DESCRIPTION.equals(key) && values.containsKey(key)) {
- Object val = values.get(key);
- if (val != null) {
- cmd.setDescription(val.toString());
- }
- } else if (SERVICE.equals(key) && values.containsKey(key)) {
- Map<String, String> map = (Map<String, String>) values.get(key);
+ switch (key) {
+ case NAME:
+ Object val = values.get(key);
+ if (val != null) {
+ cmd.setName(val.toString());
+ }
+ break;
- if (validate) {
- validateTags(exceptionList, (Map<String, Object>)values.get(key),
- OnapCommandConfg.getSchemaAttrInfo(SERVICE_PARAMS_LIST),
- OnapCommandConfg.getSchemaAttrInfo(SERVICE_PARAMS_MANDATORY_LIST), SERVICE);
-
- HashMap<String, String> validationMap = new HashMap<>();
- validationMap.put(AUTH, AUTH_VALUES);
- validationMap.put(MODE, MODE_VALUES);
-
- for (String secKey : validationMap.keySet()) {
- if (map.containsKey(secKey)) {
- Object obj = map.get(secKey);
- if (obj == null) {
- exceptionList.add("Attribute '" + secKey + "' under '" + SERVICE + "' is empty");
- } else {
- String value = String.valueOf(obj);
- if (!OnapCommandConfg.getSchemaAttrInfo(validationMap.get(secKey)).contains(value)) {
- exceptionList.add("Attribute '" + secKey + "' contains invalid value. Valide values are "
- + OnapCommandConfg.getSchemaAttrInfo(validationMap.get(key))); //
+ case DESCRIPTION:
+ Object description = values.get(key);
+ if (description != null) {
+ cmd.setDescription(description.toString());
+ }
+ break;
+
+ case SERVICE:
+ Map<String, String> serviceMap = (Map<String, String>) values.get(key);
+
+ if (serviceMap != null) {
+ if (validate) {
+ validateTags(exceptionList, (Map<String, Object>) values.get(key),
+ OnapCommandConfg.getSchemaAttrInfo(SERVICE_PARAMS_LIST),
+ OnapCommandConfg.getSchemaAttrInfo(SERVICE_PARAMS_MANDATORY_LIST), SERVICE);
+
+ HashMap<String, String> validationMap = new HashMap<>();
+ validationMap.put(AUTH, AUTH_VALUES);
+ validationMap.put(MODE, MODE_VALUES);
+
+ for (String secKey : validationMap.keySet()) {
+ if (serviceMap.containsKey(secKey)) {
+ Object obj = serviceMap.get(secKey);
+ if (obj == null) {
+ exceptionList.add("Attribute '" + secKey + "' under '" + SERVICE + "' is empty");
+ } else {
+ String value = String.valueOf(obj);
+ if (!OnapCommandConfg.getSchemaAttrInfo(validationMap.get(secKey)).contains(value)) {
+ exceptionList.add("Attribute '" + secKey + "' contains invalid value. Valide values are "
+ + OnapCommandConfg.getSchemaAttrInfo(validationMap.get(key))); //
+ }
+ }
}
}
}
- }
- }
- if (map != null) {
- OnapService srv = new OnapService();
-
- for (Map.Entry<String, String> entry1 : map.entrySet()) {
- String key1 = entry1.getKey();
-
- if (NAME.equals(key1)) {
- srv.setName(map.get(key1));
- } else if (VERSION.equals(key1)) {
- srv.setVersion(map.get(key1));
- } else if (AUTH.equals(key1)) {
- Object obj = map.get(key1);
- srv.setAuthType(obj.toString());
- } else if (Constants.MODE.equals(key1)) {
- Object obj = map.get(key1);
- srv.setMode(obj.toString());
- }
- }
+ OnapService srv = new OnapService();
- cmd.setService(srv);
- }
- } else if (DEFAULT_PARAMETERS.equals(key)) {
+ for (Map.Entry<String, String> entry1 : serviceMap.entrySet()) {
+ String key1 = entry1.getKey();
- Map<String, List<String>> defParameters = (Map) values.get(DEFAULT_PARAMETERS);
- List<String> includeParams = new ArrayList<>();
- List<String> excludeParams = new ArrayList<>();
+ switch (key1) {
+ case NAME:
+ srv.setName(serviceMap.get(key1));
+ break;
- if (values.containsKey(DEFAULT_PARAMETERS) && defParameters == null) {
- // if default parameter section is available then it must have either include
- // or exclude sub-section.
- throwOrCollect(new OnapCommandInvalidSchema(SCHEMA_INVALID_DEFAULT_PARAMS_SECTION),
- exceptionList, validate);
- }
+ case VERSION:
+ srv.setVersion(serviceMap.get(key1));
+ break;
+ case AUTH:
+ Object obj = serviceMap.get(key1);
+ srv.setAuthType(obj.toString());
+ break;
- if (defParameters != null) {
- // validate default parameters
- if (defParameters.containsKey(DEFAULT_PARAMETERS_INCLUDE)) {
- includeParams = defParameters.get(DEFAULT_PARAMETERS_INCLUDE);
+ case MODE:
+ Object mode = serviceMap.get(key1);
+ srv.setMode(mode.toString());
+ break;
+ }
+ }
+ cmd.setService(srv);
}
+ break;
- List<String> invInclude = includeParams.stream()
- .filter(p -> !defaultParamNames.contains(p))
- .collect(Collectors.toList());
+ case DEFAULT_PARAMETERS:
+ Map<String, List<String>> defParameters = (Map) values.get(DEFAULT_PARAMETERS);
+ List<String> includeParams = new ArrayList<>();
+ List<String> excludeParams = new ArrayList<>();
- if (defParameters.containsKey(DEFAULT_PARAMETERS_EXCLUDE)) {
- excludeParams = defParameters.get(DEFAULT_PARAMETERS_EXCLUDE);
+ if (values.containsKey(DEFAULT_PARAMETERS) && defParameters == null) {
+ // if default parameter section is available then it must have either include
+ // or exclude sub-section.
+ throwOrCollect(new OnapCommandInvalidSchema(SCHEMA_INVALID_DEFAULT_PARAMS_SECTION),
+ exceptionList, validate);
}
- List<String> invExclude = excludeParams.stream().filter(p -> !defaultParamNames.contains(p))
- .collect(Collectors.toList());
+ if (defParameters != null) {
+ // validate default parameters
+ if (defParameters.containsKey(DEFAULT_PARAMETERS_INCLUDE)) {
+ includeParams = defParameters.get(DEFAULT_PARAMETERS_INCLUDE);
+ }
- if (!invExclude.isEmpty() || !invInclude.isEmpty()) {
+ List<String> invInclude = includeParams.stream()
+ .filter(p -> !defaultParamNames.contains(p))
+ .collect(Collectors.toList());
- throwOrCollect(new OnapCommandInvalidDefaultParameter(Stream.concat(invInclude.stream(),
- invExclude.stream()).collect(Collectors.toList())),
- exceptionList, validate);
- }
+ if (defParameters.containsKey(DEFAULT_PARAMETERS_EXCLUDE)) {
+ excludeParams = defParameters.get(DEFAULT_PARAMETERS_EXCLUDE);
+ }
- if (!includeParams.isEmpty()) {
- filteredDefaultParams.addAll(includeParams);
- } else if (!excludeParams.isEmpty()) {
- List<String> finalExcludeParams = excludeParams;
- defaultParamNames.stream().filter(p -> !finalExcludeParams.contains(p))
- .forEach(filteredDefaultParams::add);
- }
- } else {
- filteredDefaultParams.addAll(defaultParamNames);
- }
- try {
- processNoAuth(filteredDefaultParams, cmd, includeParams, excludeParams);
- } catch (OnapCommandException e) {
- throwOrCollect(e, exceptionList, validate);
- }
- } else if (PARAMETERS.equals(key) && values.containsKey(key)) {
+ List<String> invExclude = excludeParams.stream().filter(p -> !defaultParamNames.contains(p))
+ .collect(Collectors.toList());
- List<Map<String, String>> parameters = (List) values.get(key);
- if (parameters != null) {
- Set<String> names = new HashSet<>();
- Set<String> inputShortOptions = new HashSet<>();
- Set<String> inputLongOptions = new HashSet<>();
+ if (!invExclude.isEmpty() || !invInclude.isEmpty()) {
- for (Map<String, String> map : parameters) {
- OnapCommandParameter param = new OnapCommandParameter();
+ throwOrCollect(new OnapCommandInvalidDefaultParameter(Stream.concat(invInclude.stream(),
+ invExclude.stream()).collect(Collectors.toList())),
+ exceptionList, validate);
+ }
- if (validate) {
- validateTags(exceptionList, map, OnapCommandConfg.getSchemaAttrInfo(INPUT_PARAMS_LIST),
- OnapCommandConfg.getSchemaAttrInfo(INPUT_PARAMS_MANDATORY_LIST), PARAMETERS);
+ if (!includeParams.isEmpty()) {
+ filteredDefaultParams.addAll(includeParams);
+ } else if (!excludeParams.isEmpty()) {
+ List<String> finalExcludeParams = excludeParams;
+ defaultParamNames.stream().filter(p -> !finalExcludeParams.contains(p))
+ .forEach(filteredDefaultParams::add);
}
+ } else {
+ filteredDefaultParams.addAll(defaultParamNames);
+ }
+ try {
+ processNoAuth(filteredDefaultParams, cmd, includeParams, excludeParams);
+ } catch (OnapCommandException e) {
+ throwOrCollect(e, exceptionList, validate);
+ }
+ break;
- for (Map.Entry<String, String> entry1 : map.entrySet()) {
- String key2 = entry1.getKey();
+ case PARAMETERS:
- if (NAME.equals(key2)) {
- if (names.contains(map.get(key2))) {
- throwOrCollect(new OnapCommandParameterNameConflict(map.get(key2)), exceptionList, validate);
- }
- names.add(map.get(key2));
- param.setName(map.get(key2));
- } else if (DESCRIPTION.equals(key2)) {
- param.setDescription(map.get(key2));
- } else if (SHORT_OPTION.equals(key2)) {
- if (shortOptions.contains(map.get(key2))) {
- throwOrCollect(new OnapCommandParameterOptionConflict(map.get(key2)), exceptionList, validate);
- }
- shortOptions.add(map.get(key2));
- param.setShortOption(map.get(key2));
- } else if (LONG_OPTION.equals(key2)) {
- if (longOptions.contains(map.get(key2))) {
- throwOrCollect(new OnapCommandParameterOptionConflict(map.get(key2)), exceptionList, validate);
- }
- longOptions.add(map.get(key2));
- param.setLongOption(map.get(key2));
- } else if (DEFAULT_VALUE.equals(key2)) {
- Object obj = map.get(key2);
- param.setDefaultValue(obj.toString());
- } else if (TYPE.equals(key2)) {
- try {
- param.setParameterType(ParameterType.get(map.get(key2)));
- } catch (OnapCommandException ex) {
- throwOrCollect(ex, exceptionList, validate);
- }
- } else if (IS_OPTIONAL.equals(key2)) {
- if (validate) {
- if (!validateBoolean(String.valueOf(map.get(key2)))) {
- exceptionList.add(invalidBooleanValueMessage(map.get(NAME),
- IS_SECURED, map.get(key2)));
- }
- }
- if ("true".equalsIgnoreCase(String.valueOf(map.get(key2)))) {
- param.setOptional(true);
- } else {
- param.setOptional(false);
- }
- } else if (IS_SECURED.equals(key2)) {
- if (validate) {
- if (!validateBoolean(String.valueOf(map.get(key2)))) {
- exceptionList.add(invalidBooleanValueMessage(map.get(NAME),
- IS_SECURED, map.get(key2)));
- }
- }
+ List<Map<String, String>> parameters = (List) values.get(key);
- if ("true".equalsIgnoreCase(String.valueOf(map.get(key2)))) {
- param.setSecured(true);
- } else {
- param.setSecured(false);
- }
- }
- }
+ if (parameters != null) {
+ Set<String> names = new HashSet<>();
+ Set<String> inputShortOptions = new HashSet<>();
+ Set<String> inputLongOptions = new HashSet<>();
- // Add the element to command :
- // 1. if parameter is available in filtered parameter list.
- // 2. otherwise, parameter p is available in command yaml file.
- if (filteredDefaultParams.contains(param.getName()) || !defaultParamNames.contains(param.getName())) {
- cmd.getParameters().add(param);
- }
- }
- }
- } else if (RESULTS.equals(key) && values.containsKey(key)) {
- Map<String, ?> valueMap = (Map<String, ?>) values.get(key);
- if (valueMap != null) {
- OnapCommandResult result = new OnapCommandResult();
- for (Map.Entry<String, ?> entry1 : valueMap.entrySet()) {
- String key3 = entry1.getKey();
-
- if (DIRECTION.equals(key3)) {
- try {
- result.setPrintDirection(PrintDirection.get((String) valueMap.get(key3)));
- } catch (OnapCommandException ex) {
- throwOrCollect(ex, exceptionList, validate);
+ for (Map<String, String> parameter : parameters) {
+ OnapCommandParameter param = new OnapCommandParameter();
+
+ if (validate) {
+ validateTags(exceptionList, parameter, OnapCommandConfg.getSchemaAttrInfo(INPUT_PARAMS_LIST),
+ OnapCommandConfg.getSchemaAttrInfo(INPUT_PARAMS_MANDATORY_LIST), PARAMETERS);
}
- } else if (ATTRIBUTES.equals(key3)) {
- List<Map<String, String>> attrs = (ArrayList) valueMap.get(key3);
-
- for (Map<String, String> map : attrs) {
- OnapCommandResultAttribute attr = new OnapCommandResultAttribute();
- if (validate) {
- validateTags(exceptionList, map, OnapCommandConfg.getSchemaAttrInfo(RESULT_PARAMS_LIST),
- OnapCommandConfg.getSchemaAttrInfo(RESULT_PARAMS_MANDATORY_LIST), ATTRIBUTES);
- }
- Set<String> resultParamNames = new HashSet<>();
+ for (Map.Entry<String, String> entry1 : parameter.entrySet()) {
+ String key2 = entry1.getKey();
- for (Map.Entry<String, String> entry4 : map.entrySet()) {
- String key4 = entry4.getKey();
+ switch (key2) {
+ case NAME:
+ if (names.contains(parameter.get(key2))) {
+ throwOrCollect(new OnapCommandParameterNameConflict(parameter.get(key2)), exceptionList, validate);
+ }
+ names.add(parameter.get(key2));
+ param.setName(parameter.get(key2));
+ break;
- if (NAME.equals(key4)) {
- if (resultParamNames.contains(map.get(key4))) {
- exceptionList.add("Attribute name='" + map.get(key4) + "' under '"
- + ATTRIBUTES + ":' is already used, Take different one.");
+ case DESCRIPTION:
+ param.setDescription(parameter.get(key2));
+ break;
- } else {
- attr.setName(map.get(key4));
- resultParamNames.add(map.get(key4));
+ case SHORT_OPTION:
+ if (shortOptions.contains(parameter.get(key2))) {
+ throwOrCollect(new OnapCommandParameterOptionConflict(parameter.get(key2)), exceptionList, validate);
}
- } else if (DESCRIPTION.equals(key4)) {
- attr.setDescription(map.get(key4));
- } else if (SCOPE.equals(key4)) {
- try {
- attr.setScope(OnapCommandResultAttributeScope.get(map.get(key4)));
- } catch (OnapCommandException ex) {
- throwOrCollect(ex, exceptionList, validate);
+ shortOptions.add(parameter.get(key2));
+ param.setShortOption(parameter.get(key2));
+ break;
+
+ case LONG_OPTION:
+ if (longOptions.contains(parameter.get(key2))) {
+ throwOrCollect(new OnapCommandParameterOptionConflict(parameter.get(key2)), exceptionList, validate);
}
- } else if (TYPE.equals(key4)) {
+ longOptions.add(parameter.get(key2));
+ param.setLongOption(parameter.get(key2));
+ break;
+
+ case DEFAULT_VALUE:
+ Object obj = parameter.get(key2);
+ param.setDefaultValue(obj.toString());
+ break;
+
+ case TYPE:
try {
- attr.setType(ParameterType.get(map.get(key4)));
+ param.setParameterType(ParameterType.get(parameter.get(key2)));
} catch (OnapCommandException ex) {
throwOrCollect(ex, exceptionList, validate);
}
- } else if (IS_SECURED.equals(key4)) {
+ break;
+
+ case IS_OPTIONAL:
if (validate) {
- if (!validateBoolean(String.valueOf(map.get(key4)))) {
- exceptionList.add(invalidBooleanValueMessage(ATTRIBUTES,
- IS_SECURED, map.get(key4)));
+ if (!validateBoolean(String.valueOf(parameter.get(key2)))) {
+ exceptionList.add(invalidBooleanValueMessage(parameter.get(NAME),
+ IS_SECURED, parameter.get(key2)));
}
}
- if ("true".equals(String.valueOf(map.get(key4)))) {
- attr.setSecured(true);
+ if ("true".equalsIgnoreCase(String.valueOf(parameter.get(key2)))) {
+ param.setOptional(true);
} else {
- attr.setSecured(false);
+ param.setOptional(false);
}
- }
+ break;
+ case IS_SECURED:
+ if (validate) {
+ if (!validateBoolean(String.valueOf(parameter.get(key2)))) {
+ exceptionList.add(invalidBooleanValueMessage(parameter.get(NAME),
+ IS_SECURED, parameter.get(key2)));
+ }
+ }
+
+ if ("true".equalsIgnoreCase(String.valueOf(parameter.get(key2)))) {
+ param.setSecured(true);
+ } else {
+ param.setSecured(false);
+ }
+ break;
}
- result.getRecords().add(attr);
+ }
+
+ // Add the element to command :
+ // 1. if parameter is available in filtered parameter list.
+ // 2. otherwise, parameter p is available in command yaml file.
+ if (filteredDefaultParams.contains(param.getName()) || !defaultParamNames.contains(param.getName())) {
+ cmd.getParameters().add(param);
}
}
}
- cmd.setResult(result);
- }
+ break;
+
+ case RESULTS:
+ Map<String, ?> valueMap = (Map<String, ?>) values.get(key);
+ if (valueMap != null) {
+ OnapCommandResult result = new OnapCommandResult();
+ for (Map.Entry<String, ?> entry1 : valueMap.entrySet()) {
+ String key3 = entry1.getKey();
+
+ switch (key3) {
+ case DIRECTION:
+ try {
+ result.setPrintDirection(PrintDirection.get((String) valueMap.get(key3)));
+ } catch (OnapCommandException ex) {
+ throwOrCollect(ex, exceptionList, validate);
+ }
+ break;
+
+ case ATTRIBUTES:
+ List<Map<String, String>> attrs = (ArrayList) valueMap.get(key3);
+
+ for (Map<String, String> map : attrs) {
+ OnapCommandResultAttribute attr = new OnapCommandResultAttribute();
+ if (validate) {
+ validateTags(exceptionList, map, OnapCommandConfg.getSchemaAttrInfo(RESULT_PARAMS_LIST),
+ OnapCommandConfg.getSchemaAttrInfo(RESULT_PARAMS_MANDATORY_LIST), ATTRIBUTES);
+ }
+
+ Set<String> resultParamNames = new HashSet<>();
+
+ for (Map.Entry<String, String> entry4 : map.entrySet()) {
+ String key4 = entry4.getKey();
+
+ switch (key4) {
+ case NAME:
+ if (resultParamNames.contains(map.get(key4))) {
+ exceptionList.add("Attribute name='" + map.get(key4) + "' under '"
+ + ATTRIBUTES + ":' is already used, Take different one.");
+
+ } else {
+ attr.setName(map.get(key4));
+ resultParamNames.add(map.get(key4));
+ }
+ break;
+
+ case DESCRIPTION:
+ attr.setDescription(map.get(key4));
+ break;
+
+ case SCOPE:
+ try {
+ attr.setScope(OnapCommandResultAttributeScope.get(map.get(key4)));
+ } catch (OnapCommandException ex) {
+ throwOrCollect(ex, exceptionList, validate);
+ }
+ break;
+
+ case TYPE:
+ try {
+ attr.setType(ParameterType.get(map.get(key4)));
+ } catch (OnapCommandException ex) {
+ throwOrCollect(ex, exceptionList, validate);
+ }
+ break;
+
+ case IS_SECURED:
+ if (validate) {
+ if (!validateBoolean(String.valueOf(map.get(key4)))) {
+ exceptionList.add(invalidBooleanValueMessage(ATTRIBUTES,
+ IS_SECURED, map.get(key4)));
+ }
+ }
+ if ("true".equals(String.valueOf(map.get(key4)))) {
+ attr.setSecured(true);
+ } else {
+ attr.setSecured(false);
+ }
+ break;
+ }
+
+ }
+ result.getRecords().add(attr);
+ }
+ break;
+ }
+ }
+ cmd.setResult(result);
+ }
+ break;
}
}
return exceptionList;
@@ -837,45 +884,61 @@ public class OnapCommandUtils {
}
for (Map.Entry<String, ?> entry1 : valMap.entrySet()) {
String key1 = entry1.getKey();
- if (REQUEST.equals(key1)) {
- Map<String, ?> map = (Map<String, ?>) valMap.get(key1);
-
- for (Map.Entry<String, ?> entry2 : map.entrySet()) {
- try {
- String key2 = entry2.getKey();
- if (URI.equals(key2)) {
- Object obj = map.get(key2);
- cmd.getInput().setUri(obj.toString());
- } else if (MERHOD.equals(key2)) {
- Object obj = map.get(key2);
- cmd.getInput().setMethod(obj.toString());
- } else if (BODY.equals(key2)) {
- Object obj = map.get(key2);
- cmd.getInput().setBody(obj.toString());
- } else if (HEADERS.equals(key2)) {
- Map<String, String> head = (Map<String, String>) map.get(key2);
- cmd.getInput().setReqHeaders(head);
- } else if (QUERIES.equals(key2)) {
- Map<String, String> query = (Map<String, String>) map.get(key2);
-
- cmd.getInput().setReqQueries(query);
+
+ switch (key1) {
+ case REQUEST:
+ Map<String, ?> map = (Map<String, ?>) valMap.get(key1);
+
+ for (Map.Entry<String, ?> entry2 : map.entrySet()) {
+ try {
+ String key2 = entry2.getKey();
+
+ switch (key2) {
+ case URI:
+ Object obj = map.get(key2);
+ cmd.getInput().setUri(obj.toString());
+ break;
+ case METHOD_TYPE:
+ Object method = map.get(key2);
+ cmd.getInput().setMethod(method.toString());
+ break;
+ case BODY:
+ Object body = map.get(key2);
+ cmd.getInput().setBody(body.toString());
+ break;
+ case HEADERS:
+ Map<String, String> head = (Map<String, String>) map.get(key2);
+ cmd.getInput().setReqHeaders(head);
+ break;
+ case QUERIES:
+ Map<String, String> query = (Map<String, String>) map.get(key2);
+
+ cmd.getInput().setReqQueries(query);
+ break;
+ }
+ }catch (Exception ex) {
+ throwOrCollect(new OnapCommandInvalidSchema(schemaName, ex), errorList, validate);
}
- }catch (Exception ex) {
- throwOrCollect(new OnapCommandInvalidSchema(schemaName, ex), errorList, validate);
}
- }
- } else if (SUCCESS_CODES.equals(key1)) {
- if (validate) {
- validateHttpSccessCodes(errorList, (List<Object>) valMap.get(key1));
- }
- cmd.setSuccessStatusCodes((ArrayList) valMap.get(key1));
- } else if (RESULT_MAP.equals(key1)) {
- if (validate) {
- validateHttpResultMap(errorList, values);
- }
- cmd.setResultMap((Map<String, String>) valMap.get(key1));
- } else if (SAMPLE_RESPONSE.equals(key1)) {
- // (mrkanag) implement sample response handling
+ break;
+
+ case SUCCESS_CODES:
+ if (validate) {
+ validateHttpSccessCodes(errorList, (List<Object>) valMap.get(key1));
+ }
+ cmd.setSuccessStatusCodes((ArrayList) valMap.get(key1));
+ break;
+
+ case RESULT_MAP:
+ if (validate) {
+ validateHttpResultMap(errorList, values);
+ }
+ cmd.setResultMap((Map<String, String>) valMap.get(key1));
+ break;
+
+ case SAMPLE_RESPONSE:
+ // (mrkanag) implement sample response handling
+ break;
}
}
}
diff --git a/plugins/aai/src/main/resources/onap-cli-schema/customer/customer-delete-schema.yaml b/plugins/aai/src/main/resources/onap-cli-schema/customer/customer-delete-schema.yaml
new file mode 100644
index 00000000..4c3fe055
--- /dev/null
+++ b/plugins/aai/src/main/resources/onap-cli-schema/customer/customer-delete-schema.yaml
@@ -0,0 +1,29 @@
+onap_cmd_schema_version: 1.0
+name: customer-delete
+description: Delete a customer from Onap
+service:
+ name: aai
+ version: v8
+ auth: basic
+ mode: direct
+
+parameters:
+ - name: customer-name
+ description: Onap customer name
+ type: string
+ short_option: x
+ long_option: customer-name
+ is_optional: false
+ - name: resource-version
+ description: Onap customer resource version
+ type: uuid
+ short_option: y
+ long_option: resource-version
+ is_optional: true
+http:
+ request:
+ uri: /aai/v8/business/customers/customer/${customer-name}?resource-version=${resource-version}
+ method: DELETE
+ success_codes:
+ - 204
+ - 404
diff --git a/plugins/aai/src/main/resources/onap-cli-schema/customer/customer-list-schema.yaml b/plugins/aai/src/main/resources/onap-cli-schema/customer/customer-list-schema.yaml
index 3d81166a..a4f701b9 100644
--- a/plugins/aai/src/main/resources/onap-cli-schema/customer/customer-list-schema.yaml
+++ b/plugins/aai/src/main/resources/onap-cli-schema/customer/customer-list-schema.yaml
@@ -13,6 +13,10 @@ results:
description: Onap customer name
scope: short
type: string
+ - name: resource-version
+ description: Onap customer resource version
+ scope: short
+ type: string
http:
request:
uri: /aai/v8/business/customers
@@ -21,5 +25,6 @@ http:
- 200
result_map:
name: $b{customer.[*].global-customer-id}
+ resource-version: $b{customer.[*].resource-version}
sample_response:
body: '{"customer":[{"global-customer-id":"Demonstration","subscriber-name":"Demonstration","subscriber-type":"INFRA","resource-version":"1500729865","service-subscriptions":{"service-subscription":[{"service-type":"vFW","resource-version":"1500729865","relationship-list":{"relationship":[{"related-to":"tenant","related-link":"https://192.168.17.12:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/Rackspace/RegionOne/tenants/tenant/e69e6d64b44347509c3fc512391f34a6/","relationship-data":[{"relationship-key":"cloud-region.cloud-owner","relationship-value":"Rackspace"},{"relationship-key":"cloud-region.cloud-region-id","relationship-value":"RegionOne"},{"relationship-key":"tenant.tenant-id","relationship-value":"e69e6d64b44347509c3fc512391f34a6"}],"related-to-property":[{"property-key":"tenant.tenant-name","property-value":"onap"}]}]}},{"service-type":"vLB","resource-version":"1500729865","service-instances":{"service-instance":[{"service-instance-id":"d6167ea1-ff83-4236-9b32-37494dfb7537","service-instance-name":"demoVLB-1","persona-model-id":"af01a849-721b-407d-a880-be836e26ee81","persona-model-version":"1.0","resource-version":"1501154574","relationship-list":{"relationship":[{"related-to":"generic-vnf","related-link":"https://192.168.17.12:8443/aai/v8/network/generic-vnfs/generic-vnf/16c6d95d-44e3-4527-aa63-a495bf8e776e/","relationship-data":[{"relationship-key":"generic-vnf.vnf-id","relationship-value":"16c6d95d-44e3-4527-aa63-a495bf8e776e"}],"related-to-property":[{"property-key":"generic-vnf.vnf-name","property-value":"demoVLB-1-VNF-1"}]}]}}]},"relationship-list":{"relationship":[{"related-to":"tenant","related-link":"https://192.168.17.12:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/Rackspace/RegionOne/tenants/tenant/e69e6d64b44347509c3fc512391f34a6/","relationship-data":[{"relationship-key":"cloud-region.cloud-owner","relationship-value":"Rackspace"},{"relationship-key":"cloud-region.cloud-region-id","relationship-value":"RegionOne"},{"relationship-key":"tenant.tenant-id","relationship-value":"e69e6d64b44347509c3fc512391f34a6"}],"related-to-property":[{"property-key":"tenant.tenant-name","property-value":"onap"}]}]}}]}},{"global-customer-id":"Linan","subscriber-name":"Linan","subscriber-type":"INFRA","resource-version":"1501768482","service-subscriptions":{"service-subscription":[{"service-type":"vFW","resource-version":"1501768482","relationship-list":{"relationship":[{"related-to":"tenant","related-link":"https://192.168.17.12:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/Rackspace/RegionOne/tenants/tenant/e69e6d64b44347509c3fc512391f34a6/","relationship-data":[{"relationship-key":"cloud-region.cloud-owner","relationship-value":"Rackspace"},{"relationship-key":"cloud-region.cloud-region-id","relationship-value":"RegionOne"},{"relationship-key":"tenant.tenant-id","relationship-value":"e69e6d64b44347509c3fc512391f34a6"}],"related-to-property":[{"property-key":"tenant.tenant-name","property-value":"onap"}]}]}},{"service-type":"vLB","resource-version":"1501768482","relationship-list":{"relationship":[{"related-to":"tenant","related-link":"https://192.168.17.12:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/Rackspace/RegionOne/tenants/tenant/e69e6d64b44347509c3fc512391f34a6/","relationship-data":[{"relationship-key":"cloud-region.cloud-owner","relationship-value":"Rackspace"},{"relationship-key":"cloud-region.cloud-region-id","relationship-value":"RegionOne"},{"relationship-key":"tenant.tenant-id","relationship-value":"e69e6d64b44347509c3fc512391f34a6"}],"related-to-property":[{"property-key":"tenant.tenant-name","property-value":"onap"}]}]}}]}},{"global-customer-id":"DemoCust_7151e36a-1a57-4993-b513-54134f2b8f19","subscriber-name":"DemoCust_7151e36a-1a57-4993-b513-54134f2b8f19","subscriber-type":"INFRA","resource-version":"1501766760","service-subscriptions":{"service-subscription":[{"service-type":"vFW","resource-version":"1501766760","relationship-list":{"relationship":[{"related-to":"tenant","related-link":"https://192.168.17.12:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/Rackspace/RegionOne/tenants/tenant/e69e6d64b44347509c3fc512391f34a6/","relationship-data":[{"relationship-key":"cloud-region.cloud-owner","relationship-value":"Rackspace"},{"relationship-key":"cloud-region.cloud-region-id","relationship-value":"RegionOne"},{"relationship-key":"tenant.tenant-id","relationship-value":"e69e6d64b44347509c3fc512391f34a6"}],"related-to-property":[{"property-key":"tenant.tenant-name","property-value":"onap"}]}]}}]}}]}' \ No newline at end of file
diff --git a/plugins/aai/src/main/resources/onap-cli-schema/service-type/service-type-delete-schema.yaml b/plugins/aai/src/main/resources/onap-cli-schema/service-type/service-type-delete-schema.yaml
new file mode 100644
index 00000000..a2eecd93
--- /dev/null
+++ b/plugins/aai/src/main/resources/onap-cli-schema/service-type/service-type-delete-schema.yaml
@@ -0,0 +1,33 @@
+onap_cmd_schema_version: 1.0
+name: service-type-delete
+description: Delete a service type from Onap
+service:
+ name: aai
+ version: v8
+ auth: basic
+ mode: direct
+
+parameters:
+ - name: service-type-id
+ description: Onap service type uuid
+ type: uuid
+ short_option: x
+ long_option: service-type-id
+ is_optional: true
+ - name: resource-version
+ description: Onap service resource version
+ type: uuid
+ short_option: y
+ long_option: resource-version
+ is_optional: true
+http:
+ request:
+ uri: /aai/v8/service-design-and-creation/services/service/${service-type-id}?resource-version=${resource-version}
+ queries:
+ resource-version: ${resource-version}
+ method: DELETE
+ success_codes:
+ - 204
+ - 404
+ sample_response:
+ body: ''
diff --git a/plugins/aai/src/main/resources/onap-cli-schema/service-type/service-type-list-schema.yaml b/plugins/aai/src/main/resources/onap-cli-schema/service-type/service-type-list-schema.yaml
index fbf34291..7be38f1c 100644
--- a/plugins/aai/src/main/resources/onap-cli-schema/service-type/service-type-list-schema.yaml
+++ b/plugins/aai/src/main/resources/onap-cli-schema/service-type/service-type-list-schema.yaml
@@ -18,6 +18,10 @@ results:
description: Onap cloud service
scope: short
type: string
+ - name: resource-version
+ description: Onap cloud service resource version
+ scope: short
+ type: string
http:
request:
uri: /aai/v8/service-design-and-creation/services
@@ -27,5 +31,6 @@ http:
result_map:
service-type: $b{service.[*].service-description}
service-type-id: $b{service.[*].service-id}
+ resource-version: $b{service.[*].resource-version}
sample_response:
body: '{"service":[{"service-id":"db3403eb-5c94-4295-bb00-a9dba8964ab3","service-description":"vFW","resource-version":"1500729865"},{"service-id":"33737156-ff09-4b3d-884a-fe9a372afa4e","service-description":"vLB","resource-version":"1500729866"}]}'
diff --git a/pom.xml b/pom.xml
index 42c39487..46a4bf0c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -41,6 +41,14 @@
<module>main</module>
<module>deployment</module>
</modules>
+
+ <distributionManagement>
+ <site>
+ <id>ecomp-site</id>
+ <url>dav:${onap.nexus.url}${sitePath}</url>
+ </site>
+ </distributionManagement>
+
<build>
<pluginManagement>
<plugins>