I think this is not explained very well in the FS. The entire cmd/response layer represents CloudStack's REST-like (using that very loosely) resources. The way api_refactoring achieves this is by making use of annotations. So in effect, the annotations describe the REST API so, therefore, the @parameter annotation should always reference the response object because for all intents and purposes that is the actual resource to someone looking at Cloudstack as a client. We also generate xml which leads to cloudmonkey and other clients and documentation for others from these annotations. For all of these things, the response object really is the resource object.
On the flip side, we also have to know how a cloudstack resource really maps to cloudstack db entities. Hence the annotation on the response object itself to represent that. We still need to work on defining the resource objects better but we couldn't do that in this release because it would mean changing the api. --Alex > -----Original Message----- > From: Kelven Yang [mailto:kelven.y...@citrix.com] > Sent: Sunday, January 27, 2013 10:50 PM > To: cloudstack-dev@incubator.apache.org > Subject: Re: [DISCUSS] Question about @Parameter (entityType) > > > > On 1/27/13 9:52 PM, "Mice Xia" <weiran.x...@gmail.com> wrote: > > >i have the same question and i found this: > > > >http://mail-archives.apache.org/mod_mbox//incubator-cloudstack- > dev/201301. > >mbox/%3CCANLSSBXHw5FHwRN3BS+YOj6YCpbbdU1kHjzq4nCAA59fQfaAU > g...@mail.gmail.com > >%3E > > > >seems this annotation is used for converting entity UUID->ID > > > Yes, I know it is used for this purpose, my question is why we do this > indirectly through a Response class? Especially when a command object is > expecting multiple such entities, we can see a number of Response classes > be introduced to the Command class like DeployVMCmd, a new developer > may > wonder what are those Response classes are to do with one command. > > And one more confusing part in DeployVMCmd, I can see some entity > references are done through Response classes, while the special > ipToNetworkList parameter is trying to directly refer to the entities (by > the way, populating value of ipToNetworkList is actually done by another > helper method in DeployVMCmd class). Is this in this way for an > implementation purpose? > > -Kelven > > > > >-Mice > > > >2013/1/28 Kelven Yang <kelven.y...@citrix.com>: > >> I have a question about a change in @Parameter at API layer, in regards > >>to > >> entityType, does anyone know the reason behind why it has to go > through > >> with some Response class which in turn declares links to the entity > >>class > >> via @EntityReference annotation? > >> > >> And in DeployVMCmd as an example, there is also another special field > >> (ipToNetworkList) declares entity reference directly, could someone > >> clarify it? > >> > >> @ACL(checkKeyAccess=true) > >> @Parameter(name = ApiConstants.IP_NETWORK_LIST, type = > >> CommandType.MAP, entityType={Network.class, IpAddress.class}, > >> description = "ip to network mapping. Can't be specified > >>with > >> networkIds parameter." + > >> " Example: > >> iptonetworklist[0].ip=10.10.10.11&iptonetworklist[0].networkid=uuid - > >> requests to use ip 10.10.10.11 in network id=uuid") > >> private Map ipToNetworkList; > >> > >> Kelven > >> > >>