- public Operation build(){
- return spec;
- }
- }
-
- /**
- *
- */
- public static class Put{
- protected Operation spec;
- protected DataSchemaNode schemaNode;
- private final String METHOD_NAME = "PUT";
-
- public Put(DataSchemaNode node){
- this.schemaNode = node;
- spec = new Operation();
- spec.setType(node.getQName().getLocalName());
- spec.setNotes(node.getDescription());
+ public static final class Post extends Put {
+
+ public static final String METHOD_NAME = "POST";
+ private final DataNodeContainer dataNodeContainer;
+
+ public Post(final String nodeName, final String description, final DataNodeContainer dataNodeContainer) {
+ super(nodeName, description);
+ this.dataNodeContainer = dataNodeContainer;
+ spec.setType(CONFIG + nodeName + METHOD_NAME);
+ }
+
+ @Override
+ public Operation build() {
+ spec.setMethod(METHOD_NAME);
+ spec.setNickname(METHOD_NAME + "-" + nodeName);
+ return spec;
+ }
+
+ @Override
+ public Put pathParams(List<Parameter> params) {
+ List<Parameter> parameters = new ArrayList<>(params);
+ for (DataSchemaNode node : dataNodeContainer.getChildNodes()) {
+ if (node instanceof ListSchemaNode || node instanceof ContainerSchemaNode) {
+ Parameter payload = new Parameter();
+ payload.setParamType("body");
+ payload.setType(CONFIG + node.getQName().getLocalName());
+ payload.setName("**"+CONFIG + node.getQName().getLocalName());
+ parameters.add(payload);
+ }
+ }
+ spec.setParameters(parameters);
+ return this;
+
+ }
+
+ public Post summary(final String summary) {
+ spec.setSummary(summary);
+ return this;
+ }