Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This document explains what conventions and coding guidelines to follow when writing new API(s) for CloudStack /or updating the existing ones.

...

Instructions

When you need to introduce a new API command to the CS, you will need to create a Request Class and a Response class (or re-use existing API Response class, if you are extending CS API functionality for which API response is already defined)

Writing CS API Request class

TBD

Writing CS API Response class

TBD

API placement and registration

...

  • Location: The request/response code should be placed in cloud-api package (src/org/apache/cloudstack/api)
  • Access permissions: The command's access control permissions (who is eligible to call  should be registered in commands.properties.in file
  • Command registration: The command should be added to the list of all APIs CS supports, returned by ManagementServerImpl. getCommands()

Note that the calls done from the command, should reference only interfaces from cloud-api or cloud-util packages

Image Added


When command comes as a part of plugin/service
  • Location: Define the command (request/response) in the plugin package
  • Access Permissions: Define the permissions in the Cmd file, @APICommand annotation, "authorized" field. Example: authorized = {RoleType.Admin}) 
  • Command Registration: Make your plugin manager to extent PluggableService interface. Add new API command to the list of commands returned by 
  • getCommands()

The commands defined in the plugin, should reference only interfaces located in cloud-api/cloud-utils/<your plugin> packages

  

Image Added