http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/features/InfrastructureApi.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/InfrastructureApi.java b/abiquo/src/main/java/org/jclouds/abiquo/features/InfrastructureApi.java deleted file mode 100644 index 6b12a4b..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/features/InfrastructureApi.java +++ /dev/null @@ -1,1367 +0,0 @@ -/* - * 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.jclouds.abiquo.features; - -import java.io.Closeable; - -import javax.inject.Named; -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 javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.abiquo.AbiquoFallbacks.FalseIfNotAvailable; -import org.jclouds.abiquo.AbiquoFallbacks.PropagateAbiquoExceptionOnNotFoundOr4xx; -import org.jclouds.abiquo.binders.AppendToPath; -import org.jclouds.abiquo.binders.BindToPath; -import org.jclouds.abiquo.binders.BindToXMLPayloadAndPath; -import org.jclouds.abiquo.binders.infrastructure.AppendMachineIdToPath; -import org.jclouds.abiquo.binders.infrastructure.AppendRemoteServiceTypeToPath; -import org.jclouds.abiquo.binders.infrastructure.BindSupportedDevicesLinkToPath; -import org.jclouds.abiquo.domain.PaginatedCollection; -import org.jclouds.abiquo.domain.infrastructure.options.DatacenterOptions; -import org.jclouds.abiquo.domain.infrastructure.options.IpmiOptions; -import org.jclouds.abiquo.domain.infrastructure.options.MachineOptions; -import org.jclouds.abiquo.domain.infrastructure.options.StoragePoolOptions; -import org.jclouds.abiquo.domain.network.options.IpOptions; -import org.jclouds.abiquo.domain.network.options.NetworkOptions; -import org.jclouds.abiquo.functions.infrastructure.ParseDatacenterId; -import org.jclouds.abiquo.functions.pagination.ParseExternalIps; -import org.jclouds.abiquo.functions.pagination.ParsePublicIps; -import org.jclouds.abiquo.functions.pagination.ParseUnmanagedIps; -import org.jclouds.abiquo.http.filters.AbiquoAuthentication; -import org.jclouds.abiquo.http.filters.AppendApiVersionToMediaType; -import org.jclouds.abiquo.rest.annotations.EndpointLink; -import org.jclouds.collect.PagedIterable; -import org.jclouds.http.functions.ReturnStringIf2xx; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.ParamParser; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.SinceApiVersion; -import org.jclouds.rest.annotations.Transform; -import org.jclouds.rest.binders.BindToXMLPayload; - -import com.abiquo.model.enumerator.HypervisorType; -import com.abiquo.model.enumerator.RemoteServiceType; -import com.abiquo.server.core.cloud.HypervisorTypesDto; -import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto; -import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto; -import com.abiquo.server.core.enterprise.DatacentersLimitsDto; -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.infrastructure.DatacenterDto; -import com.abiquo.server.core.infrastructure.DatacentersDto; -import com.abiquo.server.core.infrastructure.MachineDto; -import com.abiquo.server.core.infrastructure.MachineIpmiStateDto; -import com.abiquo.server.core.infrastructure.MachineStateDto; -import com.abiquo.server.core.infrastructure.MachinesDto; -import com.abiquo.server.core.infrastructure.RackDto; -import com.abiquo.server.core.infrastructure.RacksDto; -import com.abiquo.server.core.infrastructure.RemoteServiceDto; -import com.abiquo.server.core.infrastructure.RemoteServicesDto; -import com.abiquo.server.core.infrastructure.network.ExternalIpDto; -import com.abiquo.server.core.infrastructure.network.ExternalIpsDto; -import com.abiquo.server.core.infrastructure.network.NetworkServiceTypeDto; -import com.abiquo.server.core.infrastructure.network.NetworkServiceTypesDto; -import com.abiquo.server.core.infrastructure.network.PublicIpDto; -import com.abiquo.server.core.infrastructure.network.PublicIpsDto; -import com.abiquo.server.core.infrastructure.network.UnmanagedIpDto; -import com.abiquo.server.core.infrastructure.network.UnmanagedIpsDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworksDto; -import com.abiquo.server.core.infrastructure.network.VlanTagAvailabilityDto; -import com.abiquo.server.core.infrastructure.storage.StorageDeviceDto; -import com.abiquo.server.core.infrastructure.storage.StorageDevicesDto; -import com.abiquo.server.core.infrastructure.storage.StorageDevicesMetadataDto; -import com.abiquo.server.core.infrastructure.storage.StoragePoolDto; -import com.abiquo.server.core.infrastructure.storage.StoragePoolsDto; -import com.abiquo.server.core.infrastructure.storage.TierDto; -import com.abiquo.server.core.infrastructure.storage.TiersDto; - -/** - * Provides synchronous access to Abiquo Infrastructure API. - * - * @see API: <a href="http://community.abiquo.com/display/ABI20/API+Reference"> - * http://community.abiquo.com/display/ABI20/API+Reference</a> - */ -@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) -@Path("/admin") -public interface InfrastructureApi extends Closeable { - /*********************** Datacenter ***********************/ - - /** - * List all datacenters. - * - * @return The list of Datacenters. - */ - @Named("datacenter:list") - @GET - @Path("/datacenters") - @Consumes(DatacentersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - DatacentersDto listDatacenters(); - - /** - * Create a new datacenter. - * - * @param datacenter - * The datacenter to be created. - * @return The created datacenter. - */ - @Named("datacenter:create") - @POST - @Path("/datacenters") - @Produces(DatacenterDto.BASE_MEDIA_TYPE) - @Consumes(DatacenterDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - DatacenterDto createDatacenter(@BinderParam(BindToXMLPayload.class) DatacenterDto datacenter); - - /** - * Get the given datacenter. - * - * @param datacenterId - * The id of the datacenter. - * @return The datacenter or <code>null</code> if it does not exist. - */ - @Named("datacenter:get") - @GET - @Path("/datacenters/{datacenter}") - @Consumes(DatacenterDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - DatacenterDto getDatacenter(@PathParam("datacenter") Integer datacenterId); - - /** - * Updates an existing datacenter. - * - * @param datacenter - * The new attributes for the datacenter. - * @return The updated datacenter. - */ - @Named("datacenter:update") - @PUT - @Produces(DatacenterDto.BASE_MEDIA_TYPE) - @Consumes(DatacenterDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - DatacenterDto updateDatacenter( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) DatacenterDto datacenter); - - /** - * Deletes an existing datacenter. - * - * @param datacenter - * The datacenter to delete. - */ - @Named("datacenter:delete") - @DELETE - void deleteDatacenter(@EndpointLink("edit") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * Retrieve remote machine information. - * - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrieveremotemachineinformation" - * > http://community.abiquo.com/display/ABI20/DatacenterResource# - * DatacenterResource- Retrieveremotemachineinformation</a> - * @param datacenter - * The datacenter. - * @param ip - * IP address of the remote hypervisor to connect. - * @param hypervisorType - * Kind of hypervisor we want to connect. Valid values are {vbox, - * kvm, xen-3, vmx-04, hyperv-301, xenserver}. - * @param user - * User to log in. - * @param password - * Password to authenticate. - * @return The physical machine. - */ - @Named("machine:discover") - @GET - @Consumes(MachineDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(PropagateAbiquoExceptionOnNotFoundOr4xx.class) - MachineDto discoverSingleMachine( - @EndpointLink("discoversingle") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @QueryParam("ip") String ip, @QueryParam("hypervisor") HypervisorType hypervisorType, - @QueryParam("user") String user, @QueryParam("password") String password); - - /** - * Retrieve remote machine information. - * - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrieveremotemachineinformation" - * > http://community.abiquo.com/display/ABI20/DatacenterResource# - * DatacenterResource- Retrieveremotemachineinformation</a> - * @param datacenter - * The datacenter. - * @param ip - * IP address of the remote hypervisor to connect. - * @param hypervisorType - * Kind of hypervisor we want to connect. Valid values are {vbox, - * kvm, xen-3, vmx-04, hyperv-301, xenserver}. - * @param user - * User to log in. - * @param password - * Password to authenticate. - * @param options - * Optional query params. - * @return The physical machine. - */ - @Named("machine:discover") - @GET - @Consumes(MachineDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(PropagateAbiquoExceptionOnNotFoundOr4xx.class) - MachineDto discoverSingleMachine( - @EndpointLink("discoversingle") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @QueryParam("ip") String ip, @QueryParam("hypervisor") HypervisorType hypervisorType, - @QueryParam("user") String user, @QueryParam("password") String password, MachineOptions options); - - /** - * Retrieve a list of remote machine information. - * - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrievealistofremotemachineinformation" - * > http://community.abiquo.com/display/ABI20/DatacenterResource# - * DatacenterResource- Retrievealistofremotemachineinformation</a> - * @param datacenter - * The datacenter. - * @param ipFrom - * IP address of the remote first hypervisor to check. - * @param ipTo - * IP address of the remote last hypervisor to check. - * @param hypervisorType - * Kind of hypervisor we want to connect. Valid values are {vbox, - * kvm, xen-3, vmx-04, hyperv-301, xenserver}. - * @param user - * User to log in. - * @param password - * Password to authenticate. - * @return The physical machine list. - */ - @Named("machine:discover") - @GET - @Consumes(MachinesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(PropagateAbiquoExceptionOnNotFoundOr4xx.class) - MachineDto discoverMultipleMachines( - @EndpointLink("discovermultiple") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @QueryParam("ipFrom") String ipFrom, @QueryParam("ipTo") String ipTo, - @QueryParam("hypervisor") HypervisorType hypervisorType, @QueryParam("user") String user, - @QueryParam("password") String password); - - /** - * Retrieve a list of remote machine information. - * - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/DatacenterResource#DatacenterResource-Retrievealistofremotemachineinformation" - * > http://community.abiquo.com/display/ABI20/DatacenterResource# - * DatacenterResource- Retrievealistofremotemachineinformation</a> - * @param datacenter - * The datacenter. - * @param ipFrom - * IP address of the remote first hypervisor to check. - * @param ipTo - * IP address of the remote last hypervisor to check. - * @param hypervisorType - * Kind of hypervisor we want to connect. Valid values are {vbox, - * kvm, xen-3, vmx-04, hyperv-301, xenserver}. - * @param user - * User to log in. - * @param password - * Password to authenticate. - * @param options - * Optional query params. - * @return The physical machine list. - */ - @Named("machine:discover") - @GET - @Consumes(MachinesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(PropagateAbiquoExceptionOnNotFoundOr4xx.class) - MachinesDto discoverMultipleMachines( - @EndpointLink("discovermultiple") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @QueryParam("ipFrom") String ipFrom, @QueryParam("ipTo") String ipTo, - @QueryParam("hypervisor") HypervisorType hypervisorType, @QueryParam("user") String user, - @QueryParam("password") String password, MachineOptions options); - - /** - * Retrieves limits for the given datacenter and any enterprise. - * - * @param datacenter - * The datacenter. - * @return The usage limits for the datacenter on any enterprise. - */ - @Named("limit:list") - @GET - @Consumes(DatacentersLimitsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - DatacentersLimitsDto listLimits(@EndpointLink("getLimits") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * Check the state of a remote machine. This machine does not need to be - * managed by Abiquo. - * - * @param datacenter - * The datacenter. - * @param ip - * IP address of the remote hypervisor to connect. - * @param hypervisorType - * Kind of hypervisor we want to connect. Valid values are {vbox, - * kvm, xen-3, vmx-04, hyperv-301, xenserver}. - * @param user - * User to log in. - * @param password - * Password to authenticate. - * @return The physical machine state information. - */ - @Named("machine:checkstate") - @GET - @Consumes(MachineStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(PropagateAbiquoExceptionOnNotFoundOr4xx.class) - MachineStateDto checkMachineState( - @EndpointLink("checkmachinestate") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @QueryParam("ip") String ip, @QueryParam("hypervisor") HypervisorType hypervisorType, - @QueryParam("user") String user, @QueryParam("password") String password); - - /** - * Check the state of a remote machine. This machine does not need to be - * managed by Abiquo. - * - * @param datacenter - * The datacenter. - * @param ip - * IP address of the remote hypervisor to connect. - * @param hypervisorType - * Kind of hypervisor we want to connect. Valid values are {vbox, - * kvm, xen-3, vmx-04, hyperv-301, xenserver}. - * @param user - * User to log in. - * @param password - * Password to authenticate. - * @param options - * Optional query params. - * @return The physical machine state information. - */ - @Named("machine:checkstate") - @GET - @Consumes(MachineStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(PropagateAbiquoExceptionOnNotFoundOr4xx.class) - MachineStateDto checkMachineState( - @EndpointLink("checkmachinestate") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @QueryParam("ip") String ip, @QueryParam("hypervisor") HypervisorType hypervisorType, - @QueryParam("user") String user, @QueryParam("password") String password, MachineOptions options); - - /** - * Check the ipmi configuration state of a remote machine. This machine does - * not need to be managed by Abiquo. - * - * @param datacenter - * The datacenter. - * @param ip - * IP address of the remote hypervisor to connect. - * @param user - * User to log in. - * @param password - * Password to authenticate. - * @return The ipmi configuration state information - */ - @Named("machine:checkipmi") - @GET - @Consumes(MachineIpmiStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(PropagateAbiquoExceptionOnNotFoundOr4xx.class) - MachineIpmiStateDto checkMachineIpmiState( - @EndpointLink("checkmachineipmistate") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @QueryParam("ip") String ip, @QueryParam("user") String user, @QueryParam("password") String password); - - /** - * Check the ipmi configuration state of a remote machine. This machine does - * not need to be managed by Abiquo. - * - * @param datacenter - * The datacenter. - * @param ip - * IP address of the remote hypervisor to connect. - * @param user - * User to log in. - * @param password - * Password to authenticate. - * @param options - * Optional query params. - * @return The ipmi configuration state information - */ - @Named("machine:checkipmi") - @GET - @Consumes(MachineIpmiStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(PropagateAbiquoExceptionOnNotFoundOr4xx.class) - MachineIpmiStateDto checkMachineIpmiState( - @EndpointLink("checkmachineipmistate") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @QueryParam("ip") String ip, @QueryParam("user") String user, @QueryParam("password") String password, - IpmiOptions options); - - /*********************** Hypervisor ***********************/ - - /** - * Retrieves the hypervisor type of a remote a machine. - * - * @param datacenter - * The datacenter. - * @param options - * Optional query params. - * @return The hypervisor type. - */ - @Named("hypervisortype:getfrommachine") - @GET - @Consumes(MediaType.TEXT_PLAIN) - @ResponseParser(ReturnStringIf2xx.class) - String getHypervisorTypeFromMachine( - @EndpointLink("hypervisor") @BinderParam(BindToPath.class) DatacenterDto datacenter, DatacenterOptions options); - - /** - * Retrieves the hypervisor types in the datacenter. - * - * @param datacenter - * The datacenter. - * @return The hypervisor types. - */ - @Named("hypervisortype:list") - @GET - @Consumes(HypervisorTypesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - HypervisorTypesDto getHypervisorTypes( - @EndpointLink("hypervisors") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /*********************** Unmanaged Rack ********************** */ - - /** - * List all not managed racks for a datacenter. - * - * @param datacenter - * The datacenter. - * @return The list of not managed racks for the datacenter. - */ - @Named("rack:list") - @GET - @Consumes(RacksDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - RacksDto listRacks(@EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * Create a new not managed rack in a datacenter. - * - * @param datacenter - * The datacenter. - * @param rack - * The rack to be created. - * @return The created rack. - */ - @Named("rack:create") - @POST - @Produces(RackDto.BASE_MEDIA_TYPE) - @Consumes(RackDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - RackDto createRack(@EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(BindToXMLPayload.class) RackDto rack); - - /** - * Get the given rack from the given datacenter. - * - * @param datacenter - * The datacenter. - * @param rackId - * The id of the rack. - * @return The rack or <code>null</code> if it does not exist. - */ - @Named("rack:get") - @GET - @Consumes(RackDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - RackDto getRack(@EndpointLink("racks") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(AppendToPath.class) Integer rackId); - - /** - * Updates an existing rack from the given datacenter. - * - * @param rack - * The new attributes for the rack. - * @return The updated rack. - */ - @Named("rack:update") - @PUT - @Consumes(RackDto.BASE_MEDIA_TYPE) - @Produces(RackDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - RackDto updateRack(@EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) RackDto rack); - - /** - * Deletes an existing rack. - * - * @param rack - * The rack to delete. - */ - @Named("rack:delete") - @DELETE - void deleteRack(@EndpointLink("edit") @BinderParam(BindToPath.class) RackDto rack); - - /*********************** Remote Service ********************** */ - - /** - * List all remote services of the datacenter. - * - * @param datacenter - * The datacenter. - * @return The list of remote services for the datacenter. - */ - @Named("rs:list") - @GET - @Consumes(RemoteServicesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - RemoteServicesDto listRemoteServices( - @EndpointLink("remoteservices") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * Create a new remote service in a datacenter. - * - * @param datacenter - * The datacenter. - * @param remoteService - * The remote service to be created. - * @return The created remote service. - */ - @Named("rs:create") - @POST - @Produces(RemoteServiceDto.BASE_MEDIA_TYPE) - @Consumes(RemoteServiceDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - RemoteServiceDto createRemoteService( - @EndpointLink("remoteservices") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(BindToXMLPayload.class) RemoteServiceDto remoteService); - - /** - * Get the given remote service from the given datacenter. - * - * @param datacenter - * The datacenter. - * @param remoteServiceType - * The type of the remote service. - * @return The remote service or <code>null</code> if it does not exist. - */ - @Named("rs:get") - @GET - @Consumes(RemoteServiceDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - RemoteServiceDto getRemoteService( - @EndpointLink("remoteservices") @BinderParam(BindToPath.class) final DatacenterDto datacenter, - @BinderParam(AppendRemoteServiceTypeToPath.class) final RemoteServiceType remoteServiceType); - - /** - * Updates an existing remote service from the given datacenter. - * - * @param remoteService - * The new attributes for the remote service. - * @return The updated remote service. - */ - @Named("rs:update") - @PUT - @Consumes(RemoteServiceDto.BASE_MEDIA_TYPE) - @Produces(RemoteServiceDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - RemoteServiceDto updateRemoteService( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) RemoteServiceDto remoteService); - - /** - * Deletes an existing remote service. - * - * @param remoteService - * The remote service to delete. - */ - @Named("rs:delete") - @DELETE - void deleteRemoteService(@EndpointLink("edit") @BinderParam(BindToPath.class) RemoteServiceDto remoteService); - - /** - * Check if the given remote service is available and properly configured. - * - * @param remoteService - * The remote service to check. - * @return A Boolean indicating if the remote service is available. - */ - @Named("rs:available") - @GET - @Fallback(FalseIfNotAvailable.class) - boolean isAvailable(@EndpointLink("check") @BinderParam(BindToPath.class) RemoteServiceDto remoteService); - - /*********************** Machine ********************** */ - - /** - * Create a new physical machine in a rack. - * - * @param rack - * The rack. - * @param machine - * The physical machine to be created. - * @return The created physical machine. - */ - @Named("machine:create") - @POST - @Produces(MachineDto.BASE_MEDIA_TYPE) - @Consumes(MachineDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - MachineDto createMachine(@EndpointLink("machines") @BinderParam(BindToPath.class) RackDto rack, - @BinderParam(BindToXMLPayload.class) MachineDto machine); - - /** - * Get the given machine from the given rack. - * - * @param rack - * The rack. - * @param machineId - * The id of the machine. - * @return The machine or <code>null</code> if it does not exist. - */ - @Named("machine:get") - @GET - @Consumes(MachineDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - MachineDto getMachine(@EndpointLink("machines") @BinderParam(BindToPath.class) final RackDto rack, - @BinderParam(AppendToPath.class) Integer machineId); - - /** - * Checks the real infrastructure state for the given physical machine. The - * machine is updated with the result state. - * - * @param machine - * The machine to check - * @param sync - * boolean that indicates a database synchronization - * @return A machineStateDto with a machine state value from enum - * MachineState - */ - @Named("machine:checkstate") - @GET - @Consumes(MachineStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - MachineStateDto checkMachineState( - @EndpointLink("checkstate") @BinderParam(BindToPath.class) final MachineDto machine, - @QueryParam("sync") boolean sync); - - /** - * Checks the ipmi configuration state for the given physical machine. - * - * @param machine - * The machine to check - * @return A machineIpmiStateDto with a machine ipmi configuration state - * value from enum MachineState - */ - @Named("machine:checkipmi") - @GET - @Consumes(MachineIpmiStateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - MachineIpmiStateDto checkMachineIpmiState( - @EndpointLink("checkipmistate") @BinderParam(BindToPath.class) final MachineDto machine); - - /** - * Updates an existing physical machine. - * - * @param machine - * The new attributes for the physical machine. - * @return The updated machine. - */ - @Named("machine:update") - @PUT - @Produces(MachineDto.BASE_MEDIA_TYPE) - @Consumes(MachineDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - MachineDto updateMachine(@EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) MachineDto machine); - - /** - * Deletes an existing physical machine. - * - * @param machine - * The physical machine to delete. - */ - @Named("machine:delete") - @DELETE - void deleteMachine(@EndpointLink("edit") @BinderParam(BindToPath.class) MachineDto machine); - - /** - * Reserve the given machine for the given enterprise. - * - * @param enterprise - * The enterprise reserving the machine. - * @param machine - * The machine to reserve. - * @return The reserved machine. - */ - @Named("machine:reserve") - @POST - @Consumes(MachineDto.BASE_MEDIA_TYPE) - @Produces(MachineDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - MachineDto reserveMachine(@EndpointLink("reservedmachines") @BinderParam(BindToPath.class) EnterpriseDto enterprise, - @BinderParam(BindToXMLPayload.class) MachineDto machine); - - /** - * Cancels the reservation of the given machine. - * - * @param enterprise - * The enterprise to cancel reservation. - * @param machine - * The machine to release. - */ - @Named("machine:cancelreservation") - @DELETE - void cancelReservation(@EndpointLink("reservedmachines") @BinderParam(BindToPath.class) EnterpriseDto enterprise, - @BinderParam(AppendMachineIdToPath.class) MachineDto machine); - - /** - * List all machines racks for a rack. - * - * @param rack - * The rack. - * @return The list of physical machines for the rack. - */ - @Named("machine:list") - @GET - @Consumes(MachinesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - MachinesDto listMachines(@EndpointLink("machines") @BinderParam(BindToPath.class) RackDto rack); - - /** - * List all virtual machines in a physical machine. - * - * @param machine - * The physical machine. - * @return The list of virtual machines in the physical machine. - */ - @Named("machine:listvms") - @GET - @Consumes(VirtualMachinesWithNodeExtendedDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - VirtualMachinesWithNodeExtendedDto listVirtualMachinesByMachine( - @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) MachineDto machine, MachineOptions options); - - /** - * Get the given virtual machine - * - * @param machine - * @param virtualMachineId - * @return - */ - @Named("machine:getvm") - @GET - @Fallback(NullOnNotFoundOr404.class) - @Consumes(VirtualMachineWithNodeExtendedDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - VirtualMachineWithNodeExtendedDto getVirtualMachine( - @EndpointLink("virtualmachines") @BinderParam(BindToPath.class) MachineDto machine, - @BinderParam(AppendToPath.class) Integer virtualMachineId); - - /*********************** Storage Device ***********************/ - - /** - * List all storage devices of the datacenter. - * - * @param datacenter - * The datacenter. - * @return The list of storage devices in the datacenter. - */ - @Named("storagedevice:list") - @GET - @Consumes(StorageDevicesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - StorageDevicesDto listStorageDevices(@EndpointLink("devices") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * List all supported storage devices. - * - * @param datacenter - * The datacenter. - * @return The list of supported storage devices. - */ - @Named("storagedevice:listsupported") - @GET - @Consumes(StorageDevicesMetadataDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - StorageDevicesMetadataDto listSupportedStorageDevices( - @EndpointLink("devices") @BinderParam(BindSupportedDevicesLinkToPath.class) DatacenterDto datacenter); - - /** - * Get the storage device. - * - * @param storageDeviceId - * The id of the storage device. - * @return The storage device or <code>null</code> if it does not exist. - */ - @Named("storagedevice:get") - @GET - @Consumes(StorageDeviceDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - StorageDeviceDto getStorageDevice(@EndpointLink("devices") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(AppendToPath.class) Integer storageDeviceId); - - /** - * Create a new storage device. - * - * @param datacenter - * The datacenter. - * @param storageDevice - * The storage device to be created. - * @return The created storage device. - */ - @Named("storagedevice:create") - @POST - @Produces(StorageDeviceDto.BASE_MEDIA_TYPE) - @Consumes(StorageDeviceDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - StorageDeviceDto createStorageDevice( - @EndpointLink("devices") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(BindToXMLPayload.class) StorageDeviceDto storageDevice); - - /** - * Deletes an existing storage device. - * - * @param storageDevice - * The storage device to delete. - */ - @Named("storagedevice:delete") - @DELETE - void deleteStorageDevice(@EndpointLink("edit") @BinderParam(BindToPath.class) StorageDeviceDto storageDevice); - - /** - * Updates an existing storage device. - * - * @param storageDevice - * The new attributes for the storage device. - * @return The updated storage device. - */ - @Named("storagedevice:update") - @PUT - @Produces(StorageDeviceDto.BASE_MEDIA_TYPE) - @Consumes(StorageDeviceDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - StorageDeviceDto updateStorageDevice( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) StorageDeviceDto storageDevice); - - /*********************** Tier ***********************/ - /** - * List all tiers of the datacenter. - * - * @param datacenter - * The datacenter. - * @return The list of tiers in the datacenter. - */ - @Named("tier:list") - @GET - @Consumes(TiersDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - TiersDto listTiers(@EndpointLink("tiers") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * Updates a tier. - * - * @param tier - * The new attributes for the tier. - * @return The updated tier. - */ - @Named("tier:update") - @PUT - @Produces(TierDto.BASE_MEDIA_TYPE) - @Consumes(TierDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - TierDto updateTier(@EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) TierDto tier); - - /** - * Get the tier. - * - * @param tierId - * The id of the tier. - * @return The tier or <code>null</code> if it does not exist. - */ - @Named("tier:get") - @GET - @Consumes(TierDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - TierDto getTier(@EndpointLink("tiers") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(AppendToPath.class) Integer tierId); - - /*********************** Storage Pool ***********************/ - - /** - * List storage pools on a storage device. - * - * @param storageDevice - * The storage device. - * @param options - * Optional query params. - * @return The list of storage pools in the storage device. - */ - @Named("storagepool:list") - @GET - @Consumes(StoragePoolsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - StoragePoolsDto listStoragePools( - @EndpointLink("pools") @BinderParam(BindToPath.class) StorageDeviceDto storageDevice, - StoragePoolOptions options); - - /** - * List storage pools on a tier. - * - * @param tier - * The tier device. - * @return The list of storage pools in the tier. - */ - @Named("storagepool:list") - @GET - @Consumes(StoragePoolsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - StoragePoolsDto listStoragePools(@EndpointLink("pools") @BinderParam(BindToPath.class) TierDto tier); - - /** - * Create a new storage pool in a storage device. - * - * @param storageDevice - * The storage device. - * @param storagePool - * The storage pool to be created. - * @return The created storage pool. - */ - @Named("storagepool:create") - @POST - @Consumes(StoragePoolDto.BASE_MEDIA_TYPE) - @Produces(StoragePoolDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - StoragePoolDto createStoragePool( - @EndpointLink("pools") @BinderParam(BindToPath.class) StorageDeviceDto storageDevice, - @BinderParam(BindToXMLPayload.class) StoragePoolDto storagePool); - - /** - * Updates a storage pool. - * - * @param storagePool - * The new attributes for the storage pool. - * @return The updated tier. - */ - @Named("storagepool:update") - @PUT - // For the most strangest reason in world, compiler does not accept - // constants StoragePoolDto.BASE_MEDIA_TYPE for this method. - @Consumes("application/vnd.abiquo.storagepool+xml") - @Produces("application/vnd.abiquo.storagepool+xml") - @JAXBResponseParser - StoragePoolDto updateStoragePool( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) StoragePoolDto StoragePoolDto); - - /** - * Deletes an existing storage pool. - * - * @param storagePool - * The storage pool to delete. - */ - @Named("storagepool:delete") - @DELETE - void deleteStoragePool(@EndpointLink("edit") @BinderParam(BindToPath.class) StoragePoolDto storagePool); - - /** - * Get the storage pool. - * - * @param storageDevice - * The storage device. - * @param storagePoolId - * The id of the storage pool. - * @return The storage pool or <code>null</code> if it does not exist. - */ - @Named("storagepool:get") - @GET - @Consumes(StoragePoolDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - StoragePoolDto getStoragePool( - @EndpointLink("pools") @BinderParam(BindToPath.class) final StorageDeviceDto storageDevice, - @BinderParam(AppendToPath.class) final String storagePoolId); - - /** - * Refresh the given storage pool data. - * - * @param storagePool - * The storage pool to refresh. - * @param options - * The options to query the storage pool. - * @return The updated storage pool. - */ - @Named("storagepool:refresh") - @GET - @Consumes(StoragePoolDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - StoragePoolDto refreshStoragePool(@EndpointLink("edit") @BinderParam(BindToPath.class) StoragePoolDto storagePool, - StoragePoolOptions options); - - /*********************** Network ***********************/ - - /** - * List all public, external and not managed networks of a datacenter. - * - * @param datacenter - * The datacenter. - * @return The list of not public, external and not managed for the - * datacenter. - */ - @Named("network:list") - @GET - @Consumes(VLANNetworksDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - VLANNetworksDto listNetworks(@EndpointLink("network") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * List networks of a datacenter with options. - * - * @param datacenter - * The datacenter. - * @param options - * Optional query params. - * @return The list of not public, external and not managed for the - * datacenter. - */ - @Named("network:list") - @GET - @Consumes(VLANNetworksDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - VLANNetworksDto listNetworks(@EndpointLink("network") @BinderParam(BindToPath.class) DatacenterDto datacenter, - NetworkOptions options); - - /** - * Get the given network from the given datacenter. - * - * @param datacenter - * The datacenter. - * @param networkId - * The id of the network. - * @return The rack or <code>null</code> if it does not exist. - */ - @Named("network:get") - @GET - @Consumes(VLANNetworkDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - VLANNetworkDto getNetwork(@EndpointLink("network") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(AppendToPath.class) Integer networkId); - - /** - * Create a new public network. - * - * @param storageDevice - * The storage device. - * @param storagePool - * The storage pool to be created. - * @return The created storage pool. - */ - @Named("network:create") - @POST - @Produces(VLANNetworkDto.BASE_MEDIA_TYPE) - @Consumes(VLANNetworkDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - VLANNetworkDto createNetwork(@EndpointLink("network") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(BindToXMLPayload.class) VLANNetworkDto network); - - /** - * Updates a network. - * - * @param network - * The new attributes for the network. - * @return The updated tier. - */ - @Named("network:update") - @PUT - @Produces(VLANNetworkDto.BASE_MEDIA_TYPE) - @Consumes(VLANNetworkDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - VLANNetworkDto updateNetwork(@EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) VLANNetworkDto network); - - /** - * Deletes an existing network. - * - * @param network - * The network to delete. - */ - @Named("network:delete") - @DELETE - void deleteNetwork(@EndpointLink("edit") @BinderParam(BindToPath.class) VLANNetworkDto network); - - /** - * Check the availability of a tag. - * - * @param datacenter - * The datacenter. - * @param tag - * Tag to check. - * @return A tag availability object. - */ - @Named("network:checktag") - @GET - @Path("/datacenters/{datacenter}/network/action/checkavailability") - @Consumes(VlanTagAvailabilityDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - VlanTagAvailabilityDto checkTagAvailability( - @PathParam("datacenter") @ParamParser(ParseDatacenterId.class) DatacenterDto datacenter, - @QueryParam("tag") Integer tag); - - /*********************** Network IPs ***********************/ - - /** - * List all the IPs in the given public network. - * - * @param network - * The public network. - * @return The IPs in the given public network. - */ - @SinceApiVersion("2.3") - @Named("publicnetwork:listips") - @GET - @Consumes(PublicIpsDto.BASE_MEDIA_TYPE) - @ResponseParser(ParsePublicIps.class) - @Transform(ParsePublicIps.ToPagedIterable.class) - PagedIterable<PublicIpDto> listPublicIps(@EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network); - - /** - * List all the IPs in the given public network. - * - * @param network - * The public network. - * @param options - * The filtering options. - * @return The IPs in the given public network. - */ - @SinceApiVersion("2.3") - @Named("publicnetwork:listips") - @GET - @Consumes(PublicIpsDto.BASE_MEDIA_TYPE) - @ResponseParser(ParsePublicIps.class) - PaginatedCollection<PublicIpDto, PublicIpsDto> listPublicIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, IpOptions options); - - /** - * Get the given public ip. - * - * @param network - * The public network. - * @param ipId - * The id of the ip to get. - * @return The requested ip. - */ - @SinceApiVersion("2.3") - @Named("publicnetwork:getip") - @GET - @Consumes(PublicIpDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - PublicIpDto getPublicIp(@EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, - @BinderParam(AppendToPath.class) Integer ipId); - - /** - * List all the IPs in the given external network. - * - * @param network - * The external network. - * @return The IPs in the given external network. - */ - @SinceApiVersion("2.3") - @Named("externalnetwork:listips") - @GET - @Consumes(ExternalIpsDto.BASE_MEDIA_TYPE) - @ResponseParser(ParseExternalIps.class) - @Transform(ParseExternalIps.ToPagedIterable.class) - PagedIterable<ExternalIpDto> listExternalIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network); - - /** - * List all the IPs in the given external network. - * - * @param network - * The external network. - * @param options - * The filtering options. - * @return The IPs in the given external network. - */ - @SinceApiVersion("2.3") - @Named("externalnetwork:listips") - @GET - @Consumes(ExternalIpsDto.BASE_MEDIA_TYPE) - @ResponseParser(ParseExternalIps.class) - PaginatedCollection<ExternalIpDto, ExternalIpsDto> listExternalIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, IpOptions options); - - /** - * Get the given external ip. - * - * @param network - * The external network. - * @param ipId - * The id of the ip to get. - * @return The requested ip. - */ - @SinceApiVersion("2.3") - @Named("externalnetwork:getip") - @GET - @Consumes(ExternalIpDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ExternalIpDto getExternalIp(@EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, - @BinderParam(AppendToPath.class) Integer ipId); - - /** - * List all the IPs in the given unmanaged network. - * - * @param network - * The unmanaged network. - * @return The IPs in the given unmanaged network. - */ - @SinceApiVersion("2.3") - @Named("unmanagednetwork:listips") - @GET - @Consumes(UnmanagedIpsDto.BASE_MEDIA_TYPE) - @ResponseParser(ParseUnmanagedIps.class) - @Transform(ParseUnmanagedIps.ToPagedIterable.class) - PagedIterable<UnmanagedIpDto> listUnmanagedIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network); - - /** - * List all the IPs in the given unmanaged network. - * - * @param network - * The unmanaged network. - * @param options - * The filtering options. - * @return The IPs in the given unmanaged network. - */ - @SinceApiVersion("2.3") - @Named("unmanagednetwork:listips") - @GET - @Consumes(UnmanagedIpsDto.BASE_MEDIA_TYPE) - @ResponseParser(ParseUnmanagedIps.class) - PaginatedCollection<UnmanagedIpDto, UnmanagedIpsDto> listUnmanagedIps( - @EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, IpOptions options); - - /** - * Get the given unmanaged ip. - * - * @param network - * The unmanaged network. - * @param ipId - * The id of the ip to get. - * @return The requested ip. - */ - @SinceApiVersion("2.3") - @Named("unmanagednetwork:getip") - @GET - @Consumes(UnmanagedIpDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - UnmanagedIpDto getUnmanagedIp(@EndpointLink("ips") @BinderParam(BindToPath.class) VLANNetworkDto network, - @BinderParam(AppendToPath.class) Integer ipId); - - /** - * List all the Network Service types definied into a datacenter. - * - * @param datacenter - * The datacenter - * @return The list of Network Service Types in the datacenter. - */ - @Named("networkservicetype:list") - @GET - @Consumes(NetworkServiceTypesDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - NetworkServiceTypesDto listNetworkServiceTypes( - @EndpointLink("networkservicetypes") @BinderParam(BindToPath.class) DatacenterDto datacenter); - - /** - * Create a new Network Service Type Dto. - * - * @param datacenter - * the datacenter where the network service type will belong to - * @param nst - * {@link NetworkServiceTypeDto} instance to create - * @return the created {@link NetworkServiceTypeDto} - */ - @Named("networkservicetype:create") - @POST - @Produces(NetworkServiceTypeDto.BASE_MEDIA_TYPE) - @Consumes(NetworkServiceTypeDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - NetworkServiceTypeDto createNetworkServiceType( - @EndpointLink("networkservicetypes") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(BindToXMLPayload.class) NetworkServiceTypeDto nst); - - /** - * Get a single instance of a {@link NetworkServiceTypeDto} - * - * @param datacenter - * datacenter where search into - * @param nstId - * identifier of the {@link NetworkServiceTypeDto} - * @return the found entity - */ - @Named("networkservicetype:get") - @GET - @Consumes(NetworkServiceTypeDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - NetworkServiceTypeDto getNetworkServiceType( - @EndpointLink("networkservicetypes") @BinderParam(BindToPath.class) DatacenterDto datacenter, - @BinderParam(AppendToPath.class) Integer nstId); - - /** - * Update the value of a {@link NetworkServiceTypeDto} - * - * @param nstDto - * the instance to update with the new values. - * @return the updated entity. - */ - @Named("networkservicetype:update") - @PUT - @Produces(NetworkServiceTypeDto.BASE_MEDIA_TYPE) - @Consumes(NetworkServiceTypeDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - NetworkServiceTypeDto updateNetworkServiceType( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) NetworkServiceTypeDto nstDto); - - /** - * Remove a {@link NetworkServiceTypeDto} entity. - * - * @param nstDto - * the entity to delete - */ - @Named("networkservicetype:delete") - @DELETE - void deleteNetworkServiceType(@EndpointLink("edit") @BinderParam(BindToPath.class) NetworkServiceTypeDto nstDto); - -}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/features/TaskApi.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/TaskApi.java b/abiquo/src/main/java/org/jclouds/abiquo/features/TaskApi.java deleted file mode 100644 index ec7c915..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/features/TaskApi.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.jclouds.abiquo.features; - -import java.io.Closeable; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; - -import org.jclouds.abiquo.AbiquoFallbacks.NullOn303; -import org.jclouds.abiquo.binders.BindLinkToPath; -import org.jclouds.abiquo.binders.BindToPath; -import org.jclouds.abiquo.http.filters.AbiquoAuthentication; -import org.jclouds.abiquo.http.filters.AppendApiVersionToMediaType; -import org.jclouds.abiquo.rest.annotations.EndpointLink; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.RequestFilters; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.SingleResourceTransportDto; -import com.abiquo.server.core.task.TaskDto; -import com.abiquo.server.core.task.TasksDto; - -/** - * Provides synchronous access to Abiquo Task API. - * - * @see API: <a href="http://community.abiquo.com/display/ABI20/API+Reference"> - * http://community.abiquo.com/display/ABI20/API+Reference</a> - */ -@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) -public interface TaskApi extends Closeable { - /*********************** Task ***********************/ - - /** - * Get a task from its link. - * - * @param link - * The link of the task. - * @return The task. - */ - @Named("task:get") - @GET - @Consumes(TaskDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOn303.class) - TaskDto getTask(@BinderParam(BindLinkToPath.class) RESTLink link); - - /** - * Get the list of tasks of the given object. - * - * @param dto - * The object. - * @return The list of tasks for the given object. - */ - @Named("task:list") - @GET - @Consumes(TasksDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - <T extends SingleResourceTransportDto> TasksDto listTasks(@EndpointLink("tasks") @BinderParam(BindToPath.class) T dto); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/features/VirtualMachineTemplateApi.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/VirtualMachineTemplateApi.java b/abiquo/src/main/java/org/jclouds/abiquo/features/VirtualMachineTemplateApi.java deleted file mode 100644 index 0abac24..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/features/VirtualMachineTemplateApi.java +++ /dev/null @@ -1,258 +0,0 @@ -/* - * 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.jclouds.abiquo.features; - -import java.io.Closeable; - -import javax.inject.Named; -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 org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.abiquo.binders.AppendToPath; -import org.jclouds.abiquo.binders.BindToPath; -import org.jclouds.abiquo.binders.BindToXMLPayloadAndPath; -import org.jclouds.abiquo.domain.PaginatedCollection; -import org.jclouds.abiquo.domain.cloud.options.ConversionOptions; -import org.jclouds.abiquo.domain.cloud.options.VirtualMachineTemplateOptions; -import org.jclouds.abiquo.functions.ReturnTaskReferenceOrNull; -import org.jclouds.abiquo.functions.pagination.ParseVirtualMachineTemplates; -import org.jclouds.abiquo.http.filters.AbiquoAuthentication; -import org.jclouds.abiquo.http.filters.AppendApiVersionToMediaType; -import org.jclouds.abiquo.rest.annotations.EndpointLink; -import org.jclouds.collect.PagedIterable; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.JAXBResponseParser; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.Transform; -import org.jclouds.rest.binders.BindToXMLPayload; - -import com.abiquo.model.enumerator.DiskFormatType; -import com.abiquo.model.transport.AcceptedRequestDto; -import com.abiquo.server.core.appslibrary.ConversionDto; -import com.abiquo.server.core.appslibrary.ConversionsDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplatePersistentDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplatesDto; - -/** - * Provides synchronous access to Abiquo Apps library API. - * - * @see API: <a href="http://community.abiquo.com/display/ABI20/API+Reference"> - * http://community.abiquo.com/display/ABI20/API+Reference</a> - */ -@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) -@Path("/admin/enterprises") -public interface VirtualMachineTemplateApi extends Closeable { - /*********************** Virtual Machine Template ***********************/ - - /** - * List all virtual machine templates for an enterprise in a datacenter - * repository. - * - * @param enterpriseId - * Id of the enterprise. - * @param datacenterRepositoryId - * Id of the datacenter repository containing the templates. - * @return The list of virtual machine templates for the enterprise in the - * datacenter repository. - */ - @Named("template:list") - @GET - @Path("/{enterprise}/datacenterrepositories/{datacenterrepository}/virtualmachinetemplates") - @Consumes(VirtualMachineTemplatesDto.BASE_MEDIA_TYPE) - @ResponseParser(ParseVirtualMachineTemplates.class) - @Transform(ParseVirtualMachineTemplates.ToPagedIterable.class) - PagedIterable<VirtualMachineTemplateDto> listVirtualMachineTemplates(@PathParam("enterprise") Integer enterpriseId, - @PathParam("datacenterrepository") Integer datacenterRepositoryId); - - /** - * List all virtual machine templates for an enterprise in a datacenter - * repository. - * - * @param enterpriseId - * Id of the enterprise. - * @param datacenterRepositoryId - * Id of the datacenter repository containing the templates. - * @param options - * The options to query the virtual machine templates. - * @return The filtered list of virtual machine templates for the enterprise - * in the datacenter repository. - */ - @Named("template:list") - @GET - @Path("/{enterprise}/datacenterrepositories/{datacenterrepository}/virtualmachinetemplates") - @Consumes(VirtualMachineTemplatesDto.BASE_MEDIA_TYPE) - @ResponseParser(ParseVirtualMachineTemplates.class) - PaginatedCollection<VirtualMachineTemplateDto, VirtualMachineTemplatesDto> listVirtualMachineTemplates( - @PathParam("enterprise") Integer enterpriseId, - @PathParam("datacenterrepository") Integer datacenterRepositoryId, VirtualMachineTemplateOptions options); - - /** - * Get the given virtual machine template. - * - * @param enterpriseId - * Id of the enterprise. - * @param datacenterRepositoryId - * Id of the datacenter repository containing the templates. - * @param enterpriseId - * The id of the virtual machine template. - * @return The virtual machine template or <code>null</code> if it does not - * exist. - */ - @Named("template:get") - @GET - @Path("/{enterprise}/datacenterrepositories/{datacenterrepository}/virtualmachinetemplates/{virtualmachinetemplate}") - @Consumes(VirtualMachineTemplateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - VirtualMachineTemplateDto getVirtualMachineTemplate(@PathParam("enterprise") Integer enterpriseId, - @PathParam("datacenterrepository") Integer datacenterRepositoryId, - @PathParam("virtualmachinetemplate") Integer virtualMachineTemplateId); - - /** - * Updates an existing virtual machine template. - * - * @param template - * The new attributes for the template. - * @return The updated template. - */ - @Named("template:update") - @PUT - @Produces(VirtualMachineTemplateDto.BASE_MEDIA_TYPE) - @Consumes(VirtualMachineTemplateDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - VirtualMachineTemplateDto updateVirtualMachineTemplate( - @EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) VirtualMachineTemplateDto template); - - /** - * Deletes an existing virtual machine template. - * - * @param template - * The virtual machine template to delete. - */ - @Named("template:delete") - @DELETE - void deleteVirtualMachineTemplate( - @EndpointLink("edit") @BinderParam(BindToPath.class) VirtualMachineTemplateDto template); - - /** - * Creates a persistent virtual machine template from other virtual machine - * template. - * - * @param dcRepository - * The repository where the persistent virtual machine template - * will be created. - * @param options - * The persistent options like name, volume/tier, virtual - * datacenter and original template. - * @return Response message to the persistent request. - */ - @Named("template:createpersistent") - @POST - @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) - @Produces(VirtualMachineTemplatePersistentDto.BASE_MEDIA_TYPE) - @Path("/{enterprise}/datacenterrepositories/{datacenterrepository}/virtualmachinetemplates") - @JAXBResponseParser - AcceptedRequestDto<String> createPersistentVirtualMachineTemplate(@PathParam("enterprise") Integer enterpriseId, - @PathParam("datacenterrepository") Integer datacenterRepositoryId, - @BinderParam(BindToXMLPayload.class) VirtualMachineTemplatePersistentDto persistentOptions); - - /** - * List all the conversions for a virtual machine template. - * - * @param template - * , The virtual machine template of the conversions. - * @return The list of conversions for the virtual machine template. - */ - @Named("conversion:list") - @GET - @Consumes(ConversionsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ConversionsDto listConversions( - @EndpointLink("conversions") @BinderParam(BindToPath.class) VirtualMachineTemplateDto template); - - /** - * List conversions for a virtual machine template. - * - * @param template - * , The virtual machine template of the conversions - * @param options - * , Optionally filter compatible conversions with a provided - * hypervisor or with the desired state. - * @return The list of conversions for the virtual machine template with the - * applied constrains. - */ - @Named("conversion:list") - @GET - @Consumes(ConversionsDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - ConversionsDto listConversions( - @EndpointLink("conversions") @BinderParam(BindToPath.class) final VirtualMachineTemplateDto template, - ConversionOptions options); - - /** - * Get the conversions for a virtual machine template and the desired target - * format. - * - * @param template - * , The virtual machine template of the conversion - * @param targetFormat - * The disk format type of the requested conversion - * @return The conversions for the virtual machine template with the desired - * target disk format type. - */ - @Named("conversion:get") - @GET - @Consumes(ConversionDto.BASE_MEDIA_TYPE) - @JAXBResponseParser - @Fallback(NullOnNotFoundOr404.class) - ConversionDto getConversion( - @EndpointLink("conversions") @BinderParam(BindToPath.class) final VirtualMachineTemplateDto template, - @BinderParam(AppendToPath.class) DiskFormatType targetFormat); - - /** - * Starts a V2V conversion of the current virtual machine template, or - * updates a failed conversion. - * - * @param template - * The virtual machine template to convert - * @param targetFormat - * The requested target {@link DiskFormatType} of the conversion. - * @param conversion - * , the dto representing the conversion - * @return an accepted request with a link to track the progress of the - * conversion tasks. - */ - @Named("conversion:request") - @PUT - @ResponseParser(ReturnTaskReferenceOrNull.class) - @Consumes(AcceptedRequestDto.BASE_MEDIA_TYPE) - @Produces(ConversionDto.BASE_MEDIA_TYPE) - AcceptedRequestDto<String> requestConversion( - @EndpointLink("conversions") @BinderParam(BindToPath.class) final VirtualMachineTemplateDto template, - @BinderParam(AppendToPath.class) DiskFormatType targetFormat, - @BinderParam(BindToXMLPayload.class) ConversionDto conversion); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java b/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java deleted file mode 100644 index 2a98e1a..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/features/services/AdministrationService.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * 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.jclouds.abiquo.features.services; - -import org.jclouds.abiquo.domain.config.Category; -import org.jclouds.abiquo.domain.config.License; -import org.jclouds.abiquo.domain.config.Privilege; -import org.jclouds.abiquo.domain.config.SystemProperty; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.domain.enterprise.EnterpriseProperties; -import org.jclouds.abiquo.domain.enterprise.Role; -import org.jclouds.abiquo.domain.enterprise.User; -import org.jclouds.abiquo.domain.enterprise.options.EnterpriseOptions; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.domain.infrastructure.Machine; -import org.jclouds.abiquo.internal.BaseAdministrationService; - -import com.google.inject.ImplementedBy; - -/** - * Provides high level Abiquo administration operations. - */ -@ImplementedBy(BaseAdministrationService.class) -public interface AdministrationService { - /*********************** Datacenter ***********************/ - - /** - * Get the list of all datacenters. - */ - Iterable<Datacenter> listDatacenters(); - - /** - * Get the datacenter with the given id. - */ - Datacenter getDatacenter(final Integer datacenterId); - - /*********************** Machine ***********************/ - - /** - * Get the list of all machines in the infrastructure. - */ - Iterable<Machine> listMachines(); - - /*********************** Enterprise ***********************/ - - /** - * Get the list of all enterprises. - */ - Iterable<Enterprise> listEnterprises(); - - /** - * Get the list of all enterprises, filtered with the given options. - */ - Iterable<Enterprise> listEnterprises(EnterpriseOptions options); - - /** - * Get the enterprise with the given id. - */ - Enterprise getEnterprise(final Integer enterpriseId); - - /*********************** Enterprise Properties ***********************/ - /** - * Get the properties of an enterprise. - */ - EnterpriseProperties getEnterpriseProperties(final Enterprise enterprise); - - /*********************** Role ***********************/ - - /** - * Get the list of global roles. - */ - Iterable<Role> listRoles(); - - /** - * Get the role with the given id. - */ - Role getRole(final Integer roleId); - - /*********************** Privilege ***********************/ - - /** - * Get the list of global privileges. - */ - Iterable<Privilege> listPrivileges(); - - /** - * Get a privilege given its id. - * - * @param privilegeId - * The id of the privilege. - * @return The privilege. - */ - Privilege getPrivilege(Integer privilegeId); - - /*********************** User ***********************/ - - /** - * Get the current user. - */ - User getCurrentUser(); - - /** - * Get the enterprise of the current user. - */ - Enterprise getCurrentEnterprise(); - - /*********************** License ***********************/ - - /** - * Get the list of all licenses. - */ - Iterable<License> listLicenses(); - - /** - * Get the list of all active/inactive licenses. - * - * @param active - * Defines if searching for active (<code>true</code>) or inactive - * ( <code>false</code>) licenses. - */ - Iterable<License> listLicenses(boolean active); - - /*********************** System Properties ***********************/ - - /** - * Get the list of system properties. - */ - Iterable<SystemProperty> listSystemProperties(); - - /** - * Get the system property with the give name or <code>null</code> if none is - * found. - */ - SystemProperty getSystemProperty(String name); - - /** - * Get the list of system properties with options. - */ - Iterable<SystemProperty> listSystemProperties(String component); - - /*********************** Category ***********************/ - - /** - * Get the list of categories. - */ - Iterable<Category> listCategories(); - - /** - * Get the category identified by the given id. - * - * @param categoryId - * The id of the category. - * @return The requested category. - */ - Category getCategory(Integer categoryId); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/features/services/CloudService.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/services/CloudService.java b/abiquo/src/main/java/org/jclouds/abiquo/features/services/CloudService.java deleted file mode 100644 index 91c5423..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/features/services/CloudService.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.jclouds.abiquo.features.services; - -import java.util.List; - -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.domain.cloud.options.VirtualMachineOptions; -import org.jclouds.abiquo.domain.enterprise.Enterprise; -import org.jclouds.abiquo.internal.BaseCloudService; - -import com.google.inject.ImplementedBy; - -/** - * Provides high level Abiquo cloud operations. - */ -@ImplementedBy(BaseCloudService.class) -public interface CloudService { - /*********************** Virtual Datacenter ***********************/ - - /** - * Get the list of all virtual datacenters. - */ - Iterable<VirtualDatacenter> listVirtualDatacenters(); - - /** - * Get the list of all virtual datacenters for a pair enterprise-datacenter. - * - * @param enterprise - * The given enterprise. - * @param datacenter - * The given datacenter. - */ - Iterable<VirtualDatacenter> listVirtualDatacenters(final Enterprise enterprise); - - /** - * Get the virtual datacenter with the given id. - */ - VirtualDatacenter getVirtualDatacenter(final Integer virtualDatacenterId); - - /** - * Get the list of virtual datacenter with the given ids. - */ - Iterable<VirtualDatacenter> getVirtualDatacenters(final List<Integer> virtualDatacenterIds); - - /*********************** Virtual Appliance ***********************/ - - /** - * Get the list of all virtual appliances. - */ - Iterable<VirtualAppliance> listVirtualAppliances(); - - /*********************** Virtual Machine ***********************/ - - /** - * Get the list of all virtual machines. - */ - Iterable<VirtualMachine> listVirtualMachines(); - - /** - * Get the list of all virtual machines filtered with the given options. - */ - Iterable<VirtualMachine> listVirtualMachines(VirtualMachineOptions options); - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/features/services/EventService.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/services/EventService.java b/abiquo/src/main/java/org/jclouds/abiquo/features/services/EventService.java deleted file mode 100644 index 5197793..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/features/services/EventService.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.jclouds.abiquo.features.services; - -import org.jclouds.abiquo.domain.event.Event; -import org.jclouds.abiquo.domain.event.options.EventOptions; -import org.jclouds.abiquo.internal.BaseEventService; - -import com.google.inject.ImplementedBy; - -/** - * Provides high level Abiquo event operations. - */ -@ImplementedBy(BaseEventService.class) -public interface EventService { - /** - * Get the list of all events. - */ - Iterable<Event> listEvents(); - - /** - * Get the list of all events using filters as query params. - */ - Iterable<Event> listEvents(EventOptions options); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/features/services/MonitoringService.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/services/MonitoringService.java b/abiquo/src/main/java/org/jclouds/abiquo/features/services/MonitoringService.java deleted file mode 100644 index db63f7a..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/features/services/MonitoringService.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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.jclouds.abiquo.features.services; - -import java.util.concurrent.TimeUnit; - -import org.jclouds.abiquo.internal.BaseMonitoringService; -import org.jclouds.abiquo.monitor.AsyncTaskMonitor; -import org.jclouds.abiquo.monitor.ConversionMonitor; -import org.jclouds.abiquo.monitor.MonitorStatus; -import org.jclouds.abiquo.monitor.VirtualApplianceMonitor; -import org.jclouds.abiquo.monitor.VirtualMachineMonitor; -import org.jclouds.abiquo.monitor.handlers.AbstractEventHandler; - -import com.google.common.base.Function; -import com.google.inject.ImplementedBy; - -/** - * Utility service to monitor asynchronous operations. - */ -@ImplementedBy(BaseMonitoringService.class) -public interface MonitoringService { - - /*************** Generic monitoring methods ***************/ - - /** - * Monitor the given objects using the given complete condition. - * - * @param completeCondition - * The function that will be used to decide if the asynchronous - * operations have finished. - * @param objects - * The objects to monitor. - */ - <T> void awaitCompletion(final Function<T, MonitorStatus> completeCondition, final T... objects); - - /** - * Monitor the given objects using the given complete condition. - * - * @param maxWait - * The maximum time to wait. - * @param timeUnit - * The time unit for the maxWait parameter. - * @param completeCondition - * The function that will be used to decide if the asynchronous - * operations have finished. - * @param objects - * The objects to monitor. - */ - <T> void awaitCompletion(final Long maxWait, final TimeUnit timeUnit, - final Function<T, MonitorStatus> completeCondition, final T... objects); - - /** - * Monitor the given objects using the given complete condition. - * - * @param completeCondition - * The function that will be used to decide if the asynchronous - * operations have finished. - * @param objects - * The objects to monitor. - */ - <T> void monitor(final Function<T, MonitorStatus> completeCondition, final T... objects); - - /** - * Monitor the given objects using the given complete condition. - * - * @param maxWait - * The maximum time to wait. - * @param timeUnit - * The time unit for the maxWait parameter. - * @param completeCondition - * The function that will be used to decide if the asynchronous - * operations have finished. - * @param objects - * The objects to monitor. - */ - <T> void monitor(final Long maxWait, final TimeUnit timeUnit, - final Function<T, MonitorStatus> completeCondition, final T... objects); - - /*************** Handler registration methods ***************/ - - /** - * Registers the given event handler. - * - * @param <T> - * The type of event handler to register. - * @param handler - * The event handler to register. - */ - <T extends AbstractEventHandler<?>> void register(T handler); - - /** - * Unregisters the given event handler. - * - * @param <T> - * The type of event handler to unregister. - * @param handler - * The event handler to unregister. - */ - <T extends AbstractEventHandler<?>> void unregister(T handler); - - /*************** Delegating monitors ***************/ - - /** - * Gets the virtual machine monitor service. - * - * @return The virtual machine monitor service. - */ - VirtualMachineMonitor getVirtualMachineMonitor(); - - /** - * Gets the virtual appliance monitor service. - * - * @return The virtual appliance monitor service. - */ - VirtualApplianceMonitor getVirtualApplianceMonitor(); - - /** - * Gets the asynchronous task monitor service. - * - * @return The asynchronous task monitor service. - */ - AsyncTaskMonitor getAsyncTaskMonitor(); - - /** - * Gets the conversion monitor service. - * - * @return The conversion monitor service. - */ - ConversionMonitor getConversionMonitor(); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/functions/AppendApiVersionToAbiquoMimeType.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/functions/AppendApiVersionToAbiquoMimeType.java b/abiquo/src/main/java/org/jclouds/abiquo/functions/AppendApiVersionToAbiquoMimeType.java index e62ad40..0e2be07 100644 --- a/abiquo/src/main/java/org/jclouds/abiquo/functions/AppendApiVersionToAbiquoMimeType.java +++ b/abiquo/src/main/java/org/jclouds/abiquo/functions/AppendApiVersionToAbiquoMimeType.java @@ -20,7 +20,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import javax.inject.Inject; import javax.inject.Singleton; -import javax.ws.rs.core.MediaType; import org.jclouds.rest.annotations.ApiVersion; @@ -38,23 +37,18 @@ public class AppendApiVersionToAbiquoMimeType implements Function<String, String protected String apiVersion; @Inject - public AppendApiVersionToAbiquoMimeType(@ApiVersion final String apiVersion) { - super(); + AppendApiVersionToAbiquoMimeType(@ApiVersion final String apiVersion) { this.apiVersion = checkNotNull(apiVersion, "apiVersion"); } @Override public String apply(final String input) { - MediaType mediaType = MediaType.valueOf(checkNotNull(input, "input")); - if (isAbiquoMimeType(input) && !mediaType.getParameters().containsKey("version")) { - return mediaType.toString() + ";version=" + apiVersion; + checkNotNull(input, "input"); + if (input.startsWith(ABIQUO_MIME_TYPE_PREFIX) && !input.contains("version")) { + return input + ";version=" + apiVersion; } else { - return mediaType.toString(); + return input; } } - private static boolean isAbiquoMimeType(final String mimeType) { - return mimeType.startsWith(ABIQUO_MIME_TYPE_PREFIX); - } - } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/functions/ParseErrors.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/functions/ParseErrors.java b/abiquo/src/main/java/org/jclouds/abiquo/functions/ParseErrors.java deleted file mode 100644 index e348f9f..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/functions/ParseErrors.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.jclouds.abiquo.functions; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.xml.XMLParser; - -import com.abiquo.model.transport.error.ErrorsDto; -import com.google.inject.TypeLiteral; - -/** - * Parses a errors object. - */ -@Singleton -public class ParseErrors extends ParseXMLWithJAXB<ErrorsDto> { - @Inject - public ParseErrors(final XMLParser xml, final TypeLiteral<ErrorsDto> type) { - super(xml, type); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnTaskReferenceOrNull.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnTaskReferenceOrNull.java b/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnTaskReferenceOrNull.java deleted file mode 100644 index b7c8b81..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/functions/ReturnTaskReferenceOrNull.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.jclouds.abiquo.functions; - -import static org.jclouds.http.HttpUtils.releasePayload; - -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.ws.rs.core.Response.Status; - -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.xml.XMLParser; - -import com.abiquo.model.transport.AcceptedRequestDto; -import com.google.inject.TypeLiteral; - -/** - * Return an {@link AcceptedRequestDto} representing the asynchronous task or - * <code>null</code> if the operation completed synchronously. - * <p> - * Operations that generate asynchronous tasks will return one of the following: - * <ul> - * <li>204 if the operation completed synchronously</li> - * <li>202 with the asynchronous task reference in the body if the operation has - * been submitted and will be executed asynchronously</li> - * </ul> - */ -@Singleton -public class ReturnTaskReferenceOrNull extends ParseXMLWithJAXB<AcceptedRequestDto<String>> { - @Inject - public ReturnTaskReferenceOrNull(final XMLParser xml, final TypeLiteral<AcceptedRequestDto<String>> type) { - super(xml, type); - } - - @Override - public AcceptedRequestDto<String> apply(final HttpResponse from) { - if (from.getStatusCode() == Status.NO_CONTENT.getStatusCode()) { - releasePayload(from); - return null; - } else { - return super.apply(from); - } - } - -}
