Skip to content

Commit 8ee876a

Browse files
author
kishan
committed
bug 10405: Added annontation since for API Commands and request parameters. Whenever a new APi or parameter is added since=version should be added
status 10405: resolved fixed
1 parent 57ac507 commit 8ee876a

5 files changed

Lines changed: 31 additions & 2 deletions

File tree

‎api/src/com/cloud/api/Implementation.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@
3030
Class<?> responseObject();
3131
String description() default "";
3232
boolean includeInApiDoc() default true;
33+
String since() default "";
3334
}

‎api/src/com/cloud/api/Parameter.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@
3737
boolean expose() default true;
3838
boolean includeInApiDoc() default true;
3939
int length() default 255;
40+
String since() default "";
4041
}
4142

‎server/src/com/cloud/api/doc/ApiXmlDocWriter.java‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,11 @@ private static void writeCommand(ObjectOutputStream out, String command) throws
295295
else
296296
System.out.println("Command " + apiCommand.getName() + " misses description");
297297

298+
//Set version when the API is added
299+
if(!impl.since().isEmpty()){
300+
apiCommand.setSinceVersion(impl.since());
301+
}
302+
298303
// Set request parameters
299304
Field[] fields = clas.getDeclaredFields();
300305

@@ -319,7 +324,7 @@ private static void writeCommand(ObjectOutputStream out, String command) throws
319324
} else {
320325
apiCommand.setAsync(false);
321326
}
322-
327+
323328
// Get response parameters
324329
Class<?> responseClas = impl.responseObject();
325330
Field[] responseFields = responseClas.getDeclaredFields();
@@ -404,7 +409,11 @@ private static ArrayList<Argument> setRequestFields(Field[] fields) {
404409
if (parameterAnnotation.type() == BaseCmd.CommandType.LIST || parameterAnnotation.type() == BaseCmd.CommandType.MAP) {
405410
reqArg.setType(parameterAnnotation.type().toString().toLowerCase());
406411
}
407-
412+
413+
if(!parameterAnnotation.since().isEmpty()){
414+
reqArg.setSinceVersion(parameterAnnotation.since());
415+
}
416+
408417
if (reqArg.isRequired() == true) {
409418
if (parameterAnnotation.name().equals("id")) {
410419
id = reqArg;

‎server/src/com/cloud/api/doc/Argument.java‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class Argument implements Comparable{
2525
private String description;
2626
private Boolean required;
2727
private String type;
28+
private String sinceVersion = null;
2829
private List<Argument> arguments;
2930

3031
public Argument(String name) {
@@ -77,6 +78,14 @@ public void setArguments(List<Argument> arguments) {
7778
this.arguments = arguments;
7879
}
7980

81+
public String getSinceVersion() {
82+
return sinceVersion;
83+
}
84+
85+
public void setSinceVersion(String sinceVersion) {
86+
this.sinceVersion = sinceVersion;
87+
}
88+
8089
public int compareTo(Object anotherAgrument) throws ClassCastException {
8190
if (!(anotherAgrument instanceof Argument))
8291
throw new ClassCastException("An Argument object expected.");

‎server/src/com/cloud/api/doc/Command.java‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public class Command {
2525
private String name;
2626
private String description;
2727
private boolean isAsync;
28+
private String sinceVersion = null;
2829
private ArrayList<Argument> request;
2930
private ArrayList<Argument> response;
3031

@@ -75,6 +76,14 @@ public void setAsync(boolean isAsync) {
7576
this.isAsync = isAsync;
7677
}
7778

79+
public String getSinceVersion() {
80+
return sinceVersion;
81+
}
82+
83+
public void setSinceVersion(String sinceVersion) {
84+
this.sinceVersion = sinceVersion;
85+
}
86+
7887
public Argument getReqArgByName(String name){
7988
for (Argument a : this.getRequest()) {
8089
if (a.getName().equals(name)) {

0 commit comments

Comments
 (0)