Updated Branches: refs/heads/api_refactoring 99875a165 -> ee0a4a41d
api_refactor: entity annotation and fix parameter - Add Entity annotation - Annotate few responses - Fix Parameter annotation to have entityType Signed-off-by: Rohit Yadav <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/ee0a4a41 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/ee0a4a41 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/ee0a4a41 Branch: refs/heads/api_refactoring Commit: ee0a4a41d0f8db2f895a1699150c60cac6facab8 Parents: 99875a1 Author: Fang Wang <[email protected]> Authored: Wed Dec 5 11:50:23 2012 -0800 Committer: Rohit Yadav <[email protected]> Committed: Wed Dec 5 11:50:23 2012 -0800 ---------------------------------------------------------------------- api/src/com/cloud/api/response/DomainResponse.java | 3 ++ .../cloud/api/response/InstanceGroupResponse.java | 3 ++ .../com/cloud/api/response/NetworkResponse.java | 3 ++ .../cloud/api/response/SecurityGroupResponse.java | 3 ++ api/src/com/cloud/api/response/UserVmResponse.java | 3 ++ api/src/com/cloud/api/response/ZoneResponse.java | 3 ++ api/src/org/apache/cloudstack/api/Entity.java | 28 +++++++++++++++ api/src/org/apache/cloudstack/api/Parameter.java | 2 + 8 files changed, 48 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ee0a4a41/api/src/com/cloud/api/response/DomainResponse.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/api/response/DomainResponse.java b/api/src/com/cloud/api/response/DomainResponse.java index 03738a2..4568f91 100644 --- a/api/src/com/cloud/api/response/DomainResponse.java +++ b/api/src/com/cloud/api/response/DomainResponse.java @@ -17,10 +17,13 @@ package com.cloud.api.response; import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.Entity; +import com.cloud.domain.Domain; import com.cloud.utils.IdentityProxy; import com.cloud.serializer.Param; import com.google.gson.annotations.SerializedName; +@Entity(value = Domain.class) public class DomainResponse extends BaseResponse { @SerializedName(ApiConstants.ID) @Param(description="the ID of the domain") private IdentityProxy id = new IdentityProxy("domain"); http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ee0a4a41/api/src/com/cloud/api/response/InstanceGroupResponse.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/api/response/InstanceGroupResponse.java b/api/src/com/cloud/api/response/InstanceGroupResponse.java index ba9963a..ec450c3 100644 --- a/api/src/com/cloud/api/response/InstanceGroupResponse.java +++ b/api/src/com/cloud/api/response/InstanceGroupResponse.java @@ -19,11 +19,14 @@ package com.cloud.api.response; import java.util.Date; import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.Entity; +import com.cloud.vm.InstanceGroup; import com.cloud.utils.IdentityProxy; import com.cloud.serializer.Param; import com.google.gson.annotations.SerializedName; @SuppressWarnings("unused") +@Entity(value = InstanceGroup.class) public class InstanceGroupResponse extends BaseResponse implements ControlledEntityResponse{ @SerializedName(ApiConstants.ID) @Param(description="the id of the instance group") private IdentityProxy id = new IdentityProxy("instance_group"); http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ee0a4a41/api/src/com/cloud/api/response/NetworkResponse.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/api/response/NetworkResponse.java b/api/src/com/cloud/api/response/NetworkResponse.java index 78bae94..5b6c4ac 100644 --- a/api/src/com/cloud/api/response/NetworkResponse.java +++ b/api/src/com/cloud/api/response/NetworkResponse.java @@ -19,11 +19,14 @@ package com.cloud.api.response; import java.util.List; import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.Entity; +import com.cloud.projects.ProjectAccount; import com.cloud.utils.IdentityProxy; import com.cloud.serializer.Param; import com.google.gson.annotations.SerializedName; @SuppressWarnings("unused") +@Entity(value = ProjectAccount.class) public class NetworkResponse extends BaseResponse implements ControlledEntityResponse{ @SerializedName(ApiConstants.ID) @Param(description="the id of the network") http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ee0a4a41/api/src/com/cloud/api/response/SecurityGroupResponse.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/api/response/SecurityGroupResponse.java b/api/src/com/cloud/api/response/SecurityGroupResponse.java index 46dbd04..e993116 100644 --- a/api/src/com/cloud/api/response/SecurityGroupResponse.java +++ b/api/src/com/cloud/api/response/SecurityGroupResponse.java @@ -19,11 +19,14 @@ package com.cloud.api.response; import java.util.List; import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.Entity; +import com.cloud.network.security.SecurityGroup; import com.cloud.serializer.Param; import com.cloud.utils.IdentityProxy; import com.google.gson.annotations.SerializedName; @SuppressWarnings("unused") +@Entity(value = SecurityGroup.class) public class SecurityGroupResponse extends BaseResponse implements ControlledEntityResponse{ @SerializedName(ApiConstants.ID) @Param(description="the ID of the security group") private IdentityProxy id = new IdentityProxy("security_group"); http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ee0a4a41/api/src/com/cloud/api/response/UserVmResponse.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/api/response/UserVmResponse.java b/api/src/com/cloud/api/response/UserVmResponse.java index d1f70e0..e7665b5 100755 --- a/api/src/com/cloud/api/response/UserVmResponse.java +++ b/api/src/com/cloud/api/response/UserVmResponse.java @@ -20,11 +20,14 @@ import java.util.Date; import java.util.List; import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.Entity; +import com.cloud.vm.VirtualMachine; import com.cloud.serializer.Param; import com.cloud.utils.IdentityProxy; import com.google.gson.annotations.SerializedName; @SuppressWarnings("unused") +@Entity(value = VirtualMachine.class) public class UserVmResponse extends BaseResponse implements ControlledEntityResponse { @SerializedName(ApiConstants.ID) @Param(description="the ID of the virtual machine") private IdentityProxy id = new IdentityProxy("vm_instance"); http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ee0a4a41/api/src/com/cloud/api/response/ZoneResponse.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/api/response/ZoneResponse.java b/api/src/com/cloud/api/response/ZoneResponse.java index 147e8a7..1296744 100755 --- a/api/src/com/cloud/api/response/ZoneResponse.java +++ b/api/src/com/cloud/api/response/ZoneResponse.java @@ -19,11 +19,14 @@ package com.cloud.api.response; import java.util.List; import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.Entity; +import com.cloud.dc.DataCenter; import com.cloud.utils.IdentityProxy; import com.cloud.serializer.Param; import com.google.gson.annotations.SerializedName; @SuppressWarnings("unused") +@Entity(value = DataCenter.class) public class ZoneResponse extends BaseResponse { @SerializedName(ApiConstants.ID) @Param(description="Zone id") private IdentityProxy id = new IdentityProxy("data_center"); http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ee0a4a41/api/src/org/apache/cloudstack/api/Entity.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/Entity.java b/api/src/org/apache/cloudstack/api/Entity.java new file mode 100644 index 0000000..58c27ba --- /dev/null +++ b/api/src/org/apache/cloudstack/api/Entity.java @@ -0,0 +1,28 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.api; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/* There is a one on one mapping between the Entity and the EntityResponse + * to the OTW layer. Value is the actual entity class it refers to. + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface Entity { + Class[] value() default {}; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/ee0a4a41/api/src/org/apache/cloudstack/api/Parameter.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/Parameter.java b/api/src/org/apache/cloudstack/api/Parameter.java index 2364d4f..470ad26 100644 --- a/api/src/org/apache/cloudstack/api/Parameter.java +++ b/api/src/org/apache/cloudstack/api/Parameter.java @@ -37,6 +37,8 @@ public @interface Parameter { CommandType collectionType() default CommandType.OBJECT; + Class<?>[] entityType() default Object.class; + boolean expose() default true; boolean includeInApiDoc() default true;
