diff --git a/api/src/com/cloud/api/Implementation.java b/api/src/com/cloud/api/Implementation.java index 8a6aa4abb19..b6719b64351 100644 --- a/api/src/com/cloud/api/Implementation.java +++ b/api/src/com/cloud/api/Implementation.java @@ -11,4 +11,5 @@ import java.lang.annotation.Target; public @interface Implementation { Class responseObject(); String description() default ""; + boolean includeInApiDoc() default true; } diff --git a/api/src/com/cloud/api/Parameter.java b/api/src/com/cloud/api/Parameter.java index 4ccf2e4e146..ea49def1495 100644 --- a/api/src/com/cloud/api/Parameter.java +++ b/api/src/com/cloud/api/Parameter.java @@ -35,5 +35,6 @@ public @interface Parameter { CommandType type() default CommandType.OBJECT; CommandType collectionType() default CommandType.OBJECT; boolean expose() default true; + boolean includeInApiDoc() default true; } diff --git a/api/src/com/cloud/api/commands/CreateSSHKeyPairCmd.java b/api/src/com/cloud/api/commands/CreateSSHKeyPairCmd.java index db95a7269e4..dc435b1ad57 100644 --- a/api/src/com/cloud/api/commands/CreateSSHKeyPairCmd.java +++ b/api/src/com/cloud/api/commands/CreateSSHKeyPairCmd.java @@ -11,7 +11,7 @@ import com.cloud.user.Account; import com.cloud.user.SSHKeyPair; import com.cloud.user.UserContext; -@Implementation(description="Create a new keypair and returns the private key", responseObject=SSHKeyPairResponse.class) +@Implementation(description="Create a new keypair and returns the private key", responseObject=SSHKeyPairResponse.class, includeInApiDoc=false) public class CreateSSHKeyPairCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateSSHKeyPairCmd.class.getName()); private static final String s_name = "createkeypairresponse"; diff --git a/api/src/com/cloud/api/commands/DeleteSSHKeyPairCmd.java b/api/src/com/cloud/api/commands/DeleteSSHKeyPairCmd.java index 318646be7b4..0731860e6c8 100644 --- a/api/src/com/cloud/api/commands/DeleteSSHKeyPairCmd.java +++ b/api/src/com/cloud/api/commands/DeleteSSHKeyPairCmd.java @@ -10,7 +10,7 @@ import com.cloud.api.response.SuccessResponse; import com.cloud.user.Account; import com.cloud.user.UserContext; -@Implementation(description="Deletes a keypair by name", responseObject=SuccessResponse.class) +@Implementation(description="Deletes a keypair by name", responseObject=SuccessResponse.class, includeInApiDoc=false) public class DeleteSSHKeyPairCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(CreateSSHKeyPairCmd.class.getName()); private static final String s_name = "deletekeypairresponse"; diff --git a/api/src/com/cloud/api/commands/DeployVMCmd.java b/api/src/com/cloud/api/commands/DeployVMCmd.java index 735eda8dd6a..8a7f3e10e03 100644 --- a/api/src/com/cloud/api/commands/DeployVMCmd.java +++ b/api/src/com/cloud/api/commands/DeployVMCmd.java @@ -100,7 +100,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd { @Parameter(name=ApiConstants.USER_DATA, type=CommandType.STRING, description="an optional binary data that can be sent to the virtual machine upon a successful deployment. This binary data must be base64 encoded before adding it to the request. Currently only HTTP GET is supported. Using HTTP GET (via querystring), you can send up to 2KB of data after base64 encoding.") private String userData; - @Parameter(name=ApiConstants.SSH_KEYPAIR, type=CommandType.STRING, description="name of the ssh key pair used to login to the virtual machine") + @Parameter(name=ApiConstants.SSH_KEYPAIR, type=CommandType.STRING, description="name of the ssh key pair used to login to the virtual machine", includeInApiDoc=false) private String sshKeyPairName; ///////////////////////////////////////////////////// diff --git a/api/src/com/cloud/api/commands/GetVMPasswordCmd.java b/api/src/com/cloud/api/commands/GetVMPasswordCmd.java index c41ca77c836..40dc6246a5e 100644 --- a/api/src/com/cloud/api/commands/GetVMPasswordCmd.java +++ b/api/src/com/cloud/api/commands/GetVMPasswordCmd.java @@ -12,7 +12,7 @@ import com.cloud.api.response.GetVMPasswordResponse; import com.cloud.user.Account; import com.cloud.uservm.UserVm; -@Implementation(responseObject=GetVMPasswordResponse.class, description="Returns an encrypted password for the VM") +@Implementation(responseObject=GetVMPasswordResponse.class, description="Returns an encrypted password for the VM", includeInApiDoc=false) public class GetVMPasswordCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(GetVMPasswordCmd.class.getName()); private static final String s_name = "getvmpasswordresponse"; diff --git a/api/src/com/cloud/api/commands/ListSSHKeyPairsCmd.java b/api/src/com/cloud/api/commands/ListSSHKeyPairsCmd.java index 2cf696489ab..84886859b19 100644 --- a/api/src/com/cloud/api/commands/ListSSHKeyPairsCmd.java +++ b/api/src/com/cloud/api/commands/ListSSHKeyPairsCmd.java @@ -13,7 +13,7 @@ import com.cloud.api.response.ListResponse; import com.cloud.api.response.SSHKeyPairResponse; import com.cloud.user.SSHKeyPair; -@Implementation(description="List registered keypairs", responseObject=SSHKeyPairResponse.class) +@Implementation(description="List registered keypairs", responseObject=SSHKeyPairResponse.class, includeInApiDoc=false) public class ListSSHKeyPairsCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(ListSSHKeyPairsCmd.class.getName()); private static final String s_name = "listsshkeypairsresponse"; diff --git a/api/src/com/cloud/api/commands/RegisterSSHKeyPairCmd.java b/api/src/com/cloud/api/commands/RegisterSSHKeyPairCmd.java index c8ea6c2517b..992d2a260e4 100644 --- a/api/src/com/cloud/api/commands/RegisterSSHKeyPairCmd.java +++ b/api/src/com/cloud/api/commands/RegisterSSHKeyPairCmd.java @@ -11,7 +11,7 @@ import com.cloud.user.Account; import com.cloud.user.SSHKeyPair; import com.cloud.user.UserContext; -@Implementation(description="Register a public key in a keypair under a certain name", responseObject=SSHKeyPairResponse.class) +@Implementation(description="Register a public key in a keypair under a certain name", responseObject=SSHKeyPairResponse.class, includeInApiDoc=false) public class RegisterSSHKeyPairCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(RegisterSSHKeyPairCmd.class.getName()); private static final String s_name = "registerkeypairresponse"; diff --git a/server/src/com/cloud/api/doc/ApiXmlDocWriter.java b/server/src/com/cloud/api/doc/ApiXmlDocWriter.java index e5bd38ad8f0..fdf7993893d 100644 --- a/server/src/com/cloud/api/doc/ApiXmlDocWriter.java +++ b/server/src/com/cloud/api/doc/ApiXmlDocWriter.java @@ -287,49 +287,55 @@ public class ApiXmlDocWriter { apiCommand.setName(command); Implementation impl = (Implementation)clas.getAnnotation(Implementation.class); - if (impl == null) + if (impl == null) { impl = (Implementation)clas.getSuperclass().getAnnotation(Implementation.class); - String commandDescription = impl.description(); - if (commandDescription != null) - apiCommand.setDescription(commandDescription); - else - System.out.println("Command " + apiCommand.getName() + " misses description"); - - //Set request parameters - Field[] fields = clas.getDeclaredFields(); - - //Get fields from superclass - Class superClass = clas.getSuperclass(); - String superName = superClass.getName(); - if (!superName.equals(BaseCmd.class.getName()) && !superName.equals(BaseAsyncCmd.class.getName()) && !superName.equals(BaseAsyncCreateCmd.class.getName())) { - Field[] superClassFields = superClass.getDeclaredFields(); - if (superClassFields != null && !superClass.getName().equals(BaseListCmd.class.getName())) { - Field[] tmpFields = new Field[fields.length + superClassFields.length]; - System.arraycopy(fields, 0, tmpFields, 0, fields.length); - System.arraycopy(superClassFields, 0, tmpFields, fields.length, superClassFields.length); - fields = tmpFields; + } + + if (impl.includeInApiDoc()) { + String commandDescription = impl.description(); + if (commandDescription != null) + apiCommand.setDescription(commandDescription); + else + System.out.println("Command " + apiCommand.getName() + " misses description"); + + //Set request parameters + Field[] fields = clas.getDeclaredFields(); + + //Get fields from superclass + Class superClass = clas.getSuperclass(); + String superName = superClass.getName(); + if (!superName.equals(BaseCmd.class.getName()) && !superName.equals(BaseAsyncCmd.class.getName()) && !superName.equals(BaseAsyncCreateCmd.class.getName())) { + Field[] superClassFields = superClass.getDeclaredFields(); + if (superClassFields != null && !superClass.getName().equals(BaseListCmd.class.getName())) { + Field[] tmpFields = new Field[fields.length + superClassFields.length]; + System.arraycopy(fields, 0, tmpFields, 0, fields.length); + System.arraycopy(superClassFields, 0, tmpFields, fields.length, superClassFields.length); + fields = tmpFields; + } + superClass = superClass.getSuperclass(); } - superClass = superClass.getSuperclass(); - } - request = setRequestFields(fields); - - - //Set Async information for the command - if (superName.equals(BaseAsyncCmd.class.getName()) || superName.equals(BaseAsyncCreateCmd.class.getName())) { - apiCommand.setAsync(true); + request = setRequestFields(fields); + + + //Set Async information for the command + if (superName.equals(BaseAsyncCmd.class.getName()) || superName.equals(BaseAsyncCreateCmd.class.getName())) { + apiCommand.setAsync(true); + } else { + apiCommand.setAsync(false); + } + + //Get response parameters + Class responseClas = impl.responseObject(); + Field[] responseFields = responseClas.getDeclaredFields(); + response = setResponseFields(responseFields); + + apiCommand.setRequest(request); + apiCommand.setResponse(response); + + out.writeObject(apiCommand); } else { - apiCommand.setAsync(false); + s_logger.debug("Command " + command + " is not exposed in api doc"); } - - //Get response parameters - Class responseClas = impl.responseObject(); - Field[] responseFields = responseClas.getDeclaredFields(); - response = setResponseFields(responseFields); - - apiCommand.setRequest(request); - apiCommand.setResponse(response); - - out.writeObject(apiCommand); } private static void writeLoginCommand(ObjectOutputStream out) throws ClassNotFoundException, IOException{ @@ -394,7 +400,7 @@ public class ApiXmlDocWriter { Argument id = null; for (Field f : fields) { Parameter parameterAnnotation = f.getAnnotation(Parameter.class); - if (parameterAnnotation != null && parameterAnnotation.expose()) { + if (parameterAnnotation != null && parameterAnnotation.expose() && parameterAnnotation.includeInApiDoc()) { Argument reqArg = new Argument(parameterAnnotation.name()); reqArg.setRequired(parameterAnnotation.required()); if (!parameterAnnotation.description().isEmpty()) {