CS entity model work. Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/72224194 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/72224194 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/72224194
Branch: refs/heads/api_entity Commit: 722241947dd36d1b41c37082b2a83ec94a89e154 Parents: d9b85e3 Author: Min Chen <[email protected]> Authored: Tue Mar 19 10:13:09 2013 -0700 Committer: Min Chen <[email protected]> Committed: Tue Mar 19 10:13:09 2013 -0700 ---------------------------------------------------------------------- api/pom.xml | 11 ++ .../cloudstack/entity/cloud/CloudResource.java | 45 +++++ .../entity/cloud/InstanceGroupResource.java | 83 ++++++++++ .../entity/cloud/VirtualMachineResource.java | 24 +++ .../entity/identity/AccountResource.java | 24 +++ .../cloudstack/service/InstanceGroupService.java | 81 +++++++++ .../service/InstanceGroupServiceImpl.java | 126 +++++++++++++++ 7 files changed, 394 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/72224194/api/pom.xml ---------------------------------------------------------------------- diff --git a/api/pom.xml b/api/pom.xml index 8ca258f..4d7fd3f 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -36,6 +36,17 @@ <artifactId>gson</artifactId> <version>${cs.gson.version}</version> </dependency> + <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-bundle-jaxrs</artifactId> + <version>2.7.0</version> + <exclusions> + <exclusion> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-server</artifactId> + </exclusion> + </exclusions> + </dependency> </dependencies> <build> <defaultGoal>install</defaultGoal> http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/72224194/api/src/org/apache/cloudstack/entity/cloud/CloudResource.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/entity/cloud/CloudResource.java b/api/src/org/apache/cloudstack/entity/cloud/CloudResource.java new file mode 100644 index 0000000..3213c16 --- /dev/null +++ b/api/src/org/apache/cloudstack/entity/cloud/CloudResource.java @@ -0,0 +1,45 @@ +// 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.entity.cloud; + +import java.util.Date; + + + +/** + * Base class for cloud resources. + */ +public abstract class CloudResource { + protected Date removed; + protected Date created; + + + public Date getRemoved() { + return removed; + } + public void setRemoved(Date removed) { + this.removed = removed; + } + public Date getCreated() { + return created; + } + public void setCreated(Date created) { + this.created = created; + } + + +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/72224194/api/src/org/apache/cloudstack/entity/cloud/InstanceGroupResource.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/entity/cloud/InstanceGroupResource.java b/api/src/org/apache/cloudstack/entity/cloud/InstanceGroupResource.java new file mode 100644 index 0000000..60af39b --- /dev/null +++ b/api/src/org/apache/cloudstack/entity/cloud/InstanceGroupResource.java @@ -0,0 +1,83 @@ +// 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.entity.cloud; + +import java.util.List; +import javax.xml.bind.annotation.XmlRootElement; + +import org.apache.cloudstack.entity.identity.AccountResource; + + +/** + * InstanceGroup entity resource + */ +@XmlRootElement(name = "instancegroup") +public class InstanceGroupResource extends CloudResource { + + // attributes + private long id; + private String uuid; + private String name; + + // relationships + private AccountResource account; + private List<VirtualMachineResource> vms; + + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public AccountResource getAccount() { + return account; + } + + public void setAccount(AccountResource account) { + this.account = account; + } + + public List<VirtualMachineResource> getVms() { + return vms; + } + + public void setVms(List<VirtualMachineResource> vms) { + this.vms = vms; + } + + + +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/72224194/api/src/org/apache/cloudstack/entity/cloud/VirtualMachineResource.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/entity/cloud/VirtualMachineResource.java b/api/src/org/apache/cloudstack/entity/cloud/VirtualMachineResource.java new file mode 100644 index 0000000..35e0139 --- /dev/null +++ b/api/src/org/apache/cloudstack/entity/cloud/VirtualMachineResource.java @@ -0,0 +1,24 @@ +// 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.entity.cloud; + +/** + * + */ +public class VirtualMachineResource extends CloudResource { + +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/72224194/api/src/org/apache/cloudstack/entity/identity/AccountResource.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/entity/identity/AccountResource.java b/api/src/org/apache/cloudstack/entity/identity/AccountResource.java new file mode 100644 index 0000000..c64a59d --- /dev/null +++ b/api/src/org/apache/cloudstack/entity/identity/AccountResource.java @@ -0,0 +1,24 @@ +// 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.entity.identity; + +/** + * Account Identity + */ +public class AccountResource { + +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/72224194/api/src/org/apache/cloudstack/service/InstanceGroupService.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/service/InstanceGroupService.java b/api/src/org/apache/cloudstack/service/InstanceGroupService.java new file mode 100644 index 0000000..c570ad9 --- /dev/null +++ b/api/src/org/apache/cloudstack/service/InstanceGroupService.java @@ -0,0 +1,81 @@ +// 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.service; + +import java.util.List; + +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.Consumes; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.apache.cloudstack.entity.cloud.InstanceGroupResource; +import org.apache.cloudstack.entity.cloud.VirtualMachineResource; +import org.springframework.stereotype.Component; + +/** + * Service interface for InstanceGroup. + */ +@Component +@Path("/instancegroup") +public interface InstanceGroupService { + + @POST + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public InstanceGroupResource create(InstanceGroupResource instGrp); + + @DELETE + @Path("{uuid}") + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public void delete(@PathParam("uuid") String uuid); + + @PUT + @Path("{uuid}") + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public void update(@PathParam("uuid") String uuid, InstanceGroupResource instGrp); + + @GET + @Path("{uuid}") + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public InstanceGroupResource get(@PathParam("uuid") String uuid); + + @GET + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public List<InstanceGroupResource> listAll(); + + @GET + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public List<InstanceGroupResource> listByName(@QueryParam("name") String grpName); + + @GET + @Path("{uuid}/vms") + @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) + public List<VirtualMachineResource> listVms(@PathParam("uuid") String uuid); +} http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/72224194/api/src/org/apache/cloudstack/service/InstanceGroupServiceImpl.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/service/InstanceGroupServiceImpl.java b/api/src/org/apache/cloudstack/service/InstanceGroupServiceImpl.java new file mode 100644 index 0000000..d4af1ee --- /dev/null +++ b/api/src/org/apache/cloudstack/service/InstanceGroupServiceImpl.java @@ -0,0 +1,126 @@ +// 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.service; + +import java.util.List; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; + +import org.apache.cloudstack.entity.cloud.InstanceGroupResource; +import org.apache.cloudstack.entity.cloud.VirtualMachineResource; +import org.springframework.stereotype.Service; + +/** + * Instance Group rest service + */ +@Service("instanceGroupService") // Use Spring IoC to create and manage this bean. +public class InstanceGroupServiceImpl implements InstanceGroupService { + + /* (non-Javadoc) + * @see org.apache.cloudstack.service.InstanceGroupService#create(org.apache.cloudstack.entity.cloud.InstanceGroupResource) + */ + @Override + @POST + @Consumes({ "application/xml", "application/json" }) + @Produces({ "application/xml", "application/json" }) + public InstanceGroupResource create(InstanceGroupResource instGrp) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.cloudstack.service.InstanceGroupService#delete(java.lang.String) + */ + @Override + @DELETE + @Path("{uuid}") + @Consumes({ "application/xml", "application/json" }) + @Produces({ "application/xml", "application/json" }) + public void delete(@PathParam("uuid") String uuid) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.apache.cloudstack.service.InstanceGroupService#update(java.lang.String, org.apache.cloudstack.entity.cloud.InstanceGroupResource) + */ + @Override + @PUT + @Path("{uuid}") + @Consumes({ "application/xml", "application/json" }) + @Produces({ "application/xml", "application/json" }) + public void update(@PathParam("uuid") String uuid, InstanceGroupResource instGrp) { + // TODO Auto-generated method stub + + } + + /* (non-Javadoc) + * @see org.apache.cloudstack.service.InstanceGroupService#get(java.lang.String) + */ + @Override + @GET + @Path("{uuid}") + @Consumes({ "application/xml", "application/json" }) + @Produces({ "application/xml", "application/json" }) + public InstanceGroupResource get(@PathParam("uuid") String uuid) { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.cloudstack.service.InstanceGroupService#listAll() + */ + @Override + @GET + @Consumes({ "application/xml", "application/json" }) + @Produces({ "application/xml", "application/json" }) + public List<InstanceGroupResource> listAll() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.apache.cloudstack.service.InstanceGroupService#listByName(java.lang.String) + */ + @Override + @GET + @Consumes({ "application/xml", "application/json" }) + @Produces({ "application/xml", "application/json" }) + public List<InstanceGroupResource> listByName(@QueryParam("name") String grpName) { + // TODO Auto-generated method stub + return null; + } + + @Override + @GET + @Path("{uuid}/vms") + @Consumes({ "application/xml", "application/json" }) + @Produces({ "application/xml", "application/json" }) + public List<VirtualMachineResource> listVms(@PathParam("uuid") String uuid) { + // TODO Auto-generated method stub + return null; + } + +}
