Move schema validation to load schema.
Issue-Id: CLI-25
Change-Id: I68855caf80cf1b55b41916e124a53b53e7af93d3
Signed-off-by: Subhash Kumar Singh <Subhash.Kumar.Singh@huawei.com>
.classpath
.class
.checkstyle
+*.iml
+*.log
+.idea
*/
public class Constants {
+ // schema validation
+ public static final String TOP_LEVEL_PARAMS_LIST ="cli.schema.top_level_params_list";
+ public static final String TOP_LEVEL_MANDATORY_LIST ="cli.schema.top_level_mandatory_list";
+ public static final String SERVICE_PARAMS_LIST ="cli.schema.service_params_list";
+ public static final String SERVICE_PARAMS_MANDATORY_LIST ="cli.schema.service_params_mandatory_list";
+ public static final String INPUT_PARAMS_LIST ="cli.schema.input_params_list";
+ public static final String INPUT_PARAMS_MANDATORY_LIST ="cli.schema.input_params_mandatory_list";
+ public static final String RESULT_PARAMS_LIST ="cli.schema.result_params_list";
+ public static final String RESULT_PARAMS_MANDATORY_LIST ="cli.schema.result_params_mandatory_list";
+ public static final String HTTP_SECTIONS ="cli.schema.http_sections";
+ public static final String HTTP_MANDATORY_SECTIONS ="cli.schema.http_mandatory_sections";
+ public static final String HTTP_REQUEST_PARAMS ="cli.schema.http_request_params";
+ public static final String HTTP_REQUEST_MANDATORY_PARAMS ="cli.schema.http_request_mandatory_params";
+ public static final String HTTP_METHODS ="cli.schema.http_methods";
+ public static final String BOOLEAN_VALUE ="cli.schema.boolean_values";
+ public static final String AUTH_VALUES="cli.schema.auth_values";
+ public static final String MODE_VALUES="cli.schema.mode_values";
+
+
public static final String SSLCONTEST_TLS = "TLSV1.2";
public static final String APPLICATION_JSON = "application/json";
public static final String X_AUTH_TOKEN = "x-auth-token";
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
return Arrays.stream(prps.getProperty(Constants.NO_AUTH_ENABLE_INCLUDE_PARAMS_EXTERNAL_CMD)
.split(",")).map(String::trim).collect(Collectors.toSet());
}
+
+ public static List<String> getSchemaAttrInfo(String key) {
+ return Arrays.stream(prps.getProperty(key).split(",")).map(String::trim).collect(Collectors.toList());
+ }
+
}
--- /dev/null
+/*
+ * Copyright 2017 Huawei Technologies Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.cli.fw.error;
+
+import java.util.List;
+
+/**
+ * Invalid result map in HTTP section.
+ *
+ */
+public class OnapCommandHttpInvalidResultMap extends OnapCommandException {
+
+ private static final long serialVersionUID = 6676137916023457963L;
+
+ public OnapCommandHttpInvalidResultMap(List<String> invalidParams) {
+ super("0x0028", "Invalide result map parameters : " + invalidParams.toString());
+ }
+}
cli.http.basic.common_headers.x-app-id.value=onap-cli
#TODO mrkanag add support for aaf like defined above for basic
-#cli.service.auth=aaf
\ No newline at end of file
+#cli.service.auth=aaf
+
+#schema validation
+cli.schema.top_level_params_list=onap_cmd_schema_version,name,description,service,parameters,results,http
+cli.schema.top_level_mandatory_list=onap_cmd_schema_version
+
+cli.schema.service_params_list=name,version,auth,mode
+cli.schema.service_params_mandatory_list=name,version
+
+cli.schema.input_params_list=name,description,type,short_option,long_option, is_optional,default_value,is_secured
+cli.schema.input_params_mandatory_list=name,description,type
+
+cli.schema.result_params_list=name,description,scope,type,is_secured
+cli.schema.result_params_mandatory_list=name, description, type
+
+cli.schema.http_sections=request,success_codes,result_map,sample_response
+cli.schema.http_mandatory_sections=equest, success_codes
+
+cli.schema.http_request_params=uri,method,body,headers,queries
+cli.schema.http_request_mandatory_params=uri,method
+
+cli.schema.http_methods=post,get,delete,put,head
+
+cli.schema.boolean_values=true,false
+cli.schema.auth_values=none,basic
+cli.schema.mode_values=direct,catalog
\ No newline at end of file
cli.http.basic.common_headers.x-app-id.value=onap-cli
#TODO mrkanag add support for aaf like defined above for basic
-#cli.service.auth=aaf
\ No newline at end of file
+#cli.service.auth=aaf
+
+#schema validation
+cli.schema.top_level_params_list=onap_cmd_schema_version,name,description,service,parameters,results,http
+cli.schema.top_level_mandatory_list=onap_cmd_schema_version
+
+cli.schema.service_params_list=name,version,auth,mode
+cli.schema.service_params_mandatory_list=name,version
+
+cli.schema.input_params_list=name,description,type,short_option,long_option, is_optional,default_value,is_secured
+cli.schema.input_params_mandatory_list=name,description,type
+
+cli.schema.result_params_list=name,description,scope,type,is_secured
+cli.schema.result_params_mandatory_list=name, description, type
+
+cli.schema.http_sections=request,success_codes,result_map,sample_response
+cli.schema.http_mandatory_sections=equest, success_codes
+
+cli.schema.http_request_params=uri,method,body,headers,queries
+cli.schema.http_request_mandatory_params=uri,method
+
+cli.schema.http_methods=post,get,delete,put,head
+
+cli.schema.boolean_values=true,false
+cli.schema.auth_values=none,basic
+cli.schema.mode_values=direct,catalog
\ No newline at end of file