From c517fad22daf23a22069d0288c62dc38abf618c5 Mon Sep 17 00:00:00 2001 From: adriancole Date: Sat, 2 Feb 2013 18:45:33 -0800 Subject: [PATCH] issue #1184 add named for Azure commands --- .../management/features/DiskAsyncApi.java | 9 +++ .../features/HostedServiceAsyncApi.java | 25 +++---- .../management/features/LocationAsyncApi.java | 2 + .../management/features/OSImageAsyncApi.java | 5 ++ .../features/OperationAsyncApi.java | 9 ++- .../management/features/RoleAsyncApi.java | 65 +++++++++++-------- .../azureblob/AzureBlobAsyncClient.java | 45 +++++++++---- 7 files changed, 107 insertions(+), 53 deletions(-) diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/DiskAsyncApi.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/DiskAsyncApi.java index da7ed72375..bc00dd97ae 100644 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/DiskAsyncApi.java +++ b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/DiskAsyncApi.java @@ -20,6 +20,7 @@ package org.jclouds.azure.management.features; import java.util.Set; +import javax.inject.Named; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -50,6 +51,10 @@ import com.google.common.util.concurrent.ListenableFuture; @Headers(keys = "x-ms-version", values = "2012-03-01") public interface DiskAsyncApi { + /** + * @see DiskApi#list() + */ + @Named("ListDisks") @GET @Path("/services/disks") @XMLResponseParser(ListDisksHandler.class) @@ -57,6 +62,10 @@ public interface DiskAsyncApi { @Consumes(MediaType.APPLICATION_XML) ListenableFuture> list(); + /** + * @see DiskApi#delete + */ + @Named("DeleteDisk") @DELETE @Path("/services/disks/{diskName}") @Fallback(NullOnNotFoundOr404.class) diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/HostedServiceAsyncApi.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/HostedServiceAsyncApi.java index 3a424fab24..0175c6f552 100644 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/HostedServiceAsyncApi.java +++ b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/HostedServiceAsyncApi.java @@ -20,6 +20,7 @@ package org.jclouds.azure.management.features; import java.util.Set; +import javax.inject.Named; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -66,6 +67,7 @@ public interface HostedServiceAsyncApi { /** * @see HostedServiceApi#list() */ + @Named("ListHostedServices") @GET @Path("/services/hostedservices") @XMLResponseParser(ListHostedServicesHandler.class) @@ -76,6 +78,7 @@ public interface HostedServiceAsyncApi { /** * @see HostedServiceApi#createServiceWithLabelInLocation(String, String, String) */ + @Named("CreateHostedService") @POST @Path("/services/hostedservices") @MapBinder(BindCreateHostedServiceToXmlPayload.class) @@ -88,6 +91,7 @@ public interface HostedServiceAsyncApi { * @see HostedServiceApi#createServiceWithLabelInLocation(String, String, String, * CreateHostedServiceOptions) */ + @Named("CreateHostedService") @POST @Path("/services/hostedservices") @MapBinder(BindCreateHostedServiceToXmlPayload.class) @@ -100,6 +104,7 @@ public interface HostedServiceAsyncApi { /** * @see HostedServiceApi#get(String) */ + @Named("GetHostedServiceProperties") @GET @Path("/services/hostedservices/{serviceName}") @XMLResponseParser(HostedServiceHandler.class) @@ -110,6 +115,7 @@ public interface HostedServiceAsyncApi { /** * @see HostedServiceApi#getDetails(String) */ + @Named("GetHostedServiceProperties") @GET @Path("/services/hostedservices/{serviceName}") @QueryParams(keys = "embed-detail", values = "true") @@ -121,33 +127,28 @@ public interface HostedServiceAsyncApi { /** * @see HostedServiceApi#delete(String) */ + @Named("DeleteHostedService") @DELETE @Path("/services/hostedservices/{serviceName}") @Fallback(NullOnNotFoundOr404.class) @ResponseParser(ParseRequestIdHeader.class) ListenableFuture delete(@PathParam("serviceName") String serviceName); - // This is a PaaS REST service ! -// @POST -// @Path("/services/hostedservices/{serviceName}/deploymentslots/{deploymentSlotName}") -// @Produces(MediaType.APPLICATION_ATOM_XML) -// @Consumes(MediaType.TEXT_PLAIN) -// @Fallback(NullOnNotFoundOr404.class) -// ListenableFuture createDeployment(@PathParam("serviceName") String serviceName, -// @PathParam("deploymentSlotName") String deploymentSlotName, -// @BinderParam(BindToXMLPayload.class) CreateDeployment createDeployment); - + /** + * @see HostedServiceApi#deleteDeployment(String, String) + */ + @Named("DeleteDeployment") @DELETE @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}") @Fallback(VoidOnNotFoundOr404.class) @ResponseParser(ParseRequestIdHeader.class) ListenableFuture deleteDeployment(@PathParam("serviceName") String serviceName, @PathParam("deploymentName") String deploymentName); - - + /** * @see HostedServiceApi#get(String,String) */ + @Named("GetDeployment") @GET @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}") @XMLResponseParser(DeploymentHandler.class) diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/LocationAsyncApi.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/LocationAsyncApi.java index e64a3a6c3d..8e7ed057f6 100644 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/LocationAsyncApi.java +++ b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/LocationAsyncApi.java @@ -20,6 +20,7 @@ package org.jclouds.azure.management.features; import java.util.Set; +import javax.inject.Named; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -49,6 +50,7 @@ public interface LocationAsyncApi { /** * @see LocationApi#list() */ + @Named("ListLocations") @GET @Path("/locations") @XMLResponseParser(ListLocationsHandler.class) diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/OSImageAsyncApi.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/OSImageAsyncApi.java index 7876183aec..28084b83e2 100644 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/OSImageAsyncApi.java +++ b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/OSImageAsyncApi.java @@ -20,6 +20,7 @@ package org.jclouds.azure.management.features; import java.util.Set; +import javax.inject.Named; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; @@ -58,6 +59,7 @@ public interface OSImageAsyncApi { /** * @see OSImageApi#list() */ + @Named("ListOsImages") @GET @Path("/services/images") @XMLResponseParser(ListOSImagesHandler.class) @@ -68,6 +70,7 @@ public interface OSImageAsyncApi { /** * @see OSImageApi#add(String) */ + @Named("AddOsImage") @POST @Path("/services/images") @Produces(MediaType.APPLICATION_XML) @@ -76,6 +79,7 @@ public interface OSImageAsyncApi { /** * @see OSImageApi#update(String) */ + @Named("UpdateOsImage") @PUT @Path("/services/images/{imageName}") @Produces(MediaType.APPLICATION_XML) @@ -85,6 +89,7 @@ public interface OSImageAsyncApi { /** * @see OSImageApi#delete(String) */ + @Named("DeleteOsImage") @DELETE @Path("/services/images/{imageName}") @Fallback(VoidOnNotFoundOr404.class) diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/OperationAsyncApi.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/OperationAsyncApi.java index 739f84f237..621fd18b01 100644 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/OperationAsyncApi.java +++ b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/OperationAsyncApi.java @@ -18,6 +18,7 @@ */ package org.jclouds.azure.management.features; +import javax.inject.Named; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -34,7 +35,8 @@ import org.jclouds.rest.annotations.XMLResponseParser; import com.google.common.util.concurrent.ListenableFuture; /** - * The Service Management API includes one operation for tracking the progress of asynchronous requests. + * The Service Management API includes one operation for tracking the progress + * of asynchronous requests. * * @see docs * @see OperationApi @@ -43,11 +45,14 @@ import com.google.common.util.concurrent.ListenableFuture; @Headers(keys = "x-ms-version", values = "2012-03-01") public interface OperationAsyncApi { + /** + * @see OperationApi#get(String) + */ + @Named("GetOperation") @GET @Path("/operations/{request-id}") @XMLResponseParser(OperationHandler.class) @Fallback(NullOnNotFoundOr404.class) @Consumes(MediaType.APPLICATION_XML) ListenableFuture get(@PathParam("request-id") String requestId); - } diff --git a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/RoleAsyncApi.java b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/RoleAsyncApi.java index 70e2868f1b..2f452cc65b 100644 --- a/labs/azure-management/src/main/java/org/jclouds/azure/management/features/RoleAsyncApi.java +++ b/labs/azure-management/src/main/java/org/jclouds/azure/management/features/RoleAsyncApi.java @@ -18,6 +18,7 @@ */ package org.jclouds.azure.management.features; +import javax.inject.Named; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -52,16 +53,22 @@ import com.google.common.util.concurrent.ListenableFuture; @Headers(keys = "x-ms-version", values = "2012-03-01") public interface RoleAsyncApi { + /** + * @see RoleApi#getRole(String, String, String) + */ + @Named("GetRole") @GET @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roles/{roleName}") @Consumes(MediaType.APPLICATION_ATOM_XML) @JAXBResponseParser @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getRole(@PathParam("serviceName") - String serviceName, - @PathParam("deploymentName") String deploymentName, - @PathParam("roleName") String roleName); + ListenableFuture getRole(@PathParam("serviceName") String serviceName, + @PathParam("deploymentName") String deploymentName, @PathParam("roleName") String roleName); + /** + * @see RoleApi#restartRole(String, String, String) + */ + @Named("RestartRole") @POST // Warning : the url in the documentation is WRONG ! @see // http://social.msdn.microsoft.com/Forums/pl-PL/WAVirtualMachinesforWindows/thread/7ba2367b-e450-49e0-89e4-46c240e9d213 @@ -71,21 +78,26 @@ public interface RoleAsyncApi { @Fallback(NullOnNotFoundOr404.class) @ResponseParser(ParseRequestIdHeader.class) @Payload(value = "RestartRoleOperation") - ListenableFuture restartRole( - @PathParam("serviceName") String serviceName, - @PathParam("deploymentName") String deploymentName, - @PathParam("roleName") String roleName); + ListenableFuture restartRole(@PathParam("serviceName") String serviceName, + @PathParam("deploymentName") String deploymentName, @PathParam("roleName") String roleName); + /** + * @see RoleApi#createDeployment(String, DeploymentParams) + */ + @Named("CreateVirtualMachineDeployment") @POST @Path("/services/hostedservices/{serviceName}/deployments") @Produces(MediaType.APPLICATION_ATOM_XML) @Consumes(MediaType.APPLICATION_ATOM_XML) @Fallback(NullOnNotFoundOr404.class) @ResponseParser(ParseRequestIdHeader.class) - ListenableFuture createDeployment( - @PathParam("serviceName") String serviceName, + ListenableFuture createDeployment(@PathParam("serviceName") String serviceName, @BinderParam(BindDeploymentParamsToXmlPayload.class) DeploymentParams deploymentParams); + /** + * @see RoleApi#captureRole(String, String, String, String, String) + */ + @Named("CaptureRole") @POST @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleInstances/{roleName}/Operations") @Consumes(MediaType.APPLICATION_ATOM_XML) @@ -93,13 +105,14 @@ public interface RoleAsyncApi { @Fallback(NullOnNotFoundOr404.class) @ResponseParser(ParseRequestIdHeader.class) @Payload(value = "CaptureRoleOperationDelete{imageLabel}{imageName}") - ListenableFuture captureRole( - @PathParam("serviceName") String serviceName, - @PathParam("deploymentName") String deploymentName, - @PathParam("roleName") String roleName, - @PayloadParam("imageName") String imageName, - @PayloadParam("imageLabel") String imageLabel); - + ListenableFuture captureRole(@PathParam("serviceName") String serviceName, + @PathParam("deploymentName") String deploymentName, @PathParam("roleName") String roleName, + @PayloadParam("imageName") String imageName, @PayloadParam("imageLabel") String imageLabel); + + /** + * @see RoleApi#shutdownRole(String, String, String) + */ + @Named("ShutdownRole") @POST @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleInstances/{roleName}/Operations") @Consumes(MediaType.APPLICATION_ATOM_XML) @@ -107,11 +120,13 @@ public interface RoleAsyncApi { @Fallback(NullOnNotFoundOr404.class) @ResponseParser(ParseRequestIdHeader.class) @Payload(value = "ShutdownRoleOperation") - ListenableFuture shutdownRole( - @PathParam("serviceName") String serviceName, - @PathParam("deploymentName") String deploymentName, - @PathParam("roleName") String roleName); - + ListenableFuture shutdownRole(@PathParam("serviceName") String serviceName, + @PathParam("deploymentName") String deploymentName, @PathParam("roleName") String roleName); + + /** + * @see RoleApi#startRole(String, String, String) + */ + @Named("StartRole") @POST @Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleInstances/{roleName}/Operations") @Consumes(MediaType.APPLICATION_ATOM_XML) @@ -119,9 +134,7 @@ public interface RoleAsyncApi { @Fallback(NullOnNotFoundOr404.class) @ResponseParser(ParseRequestIdHeader.class) @Payload(value = "StartRoleOperation") - ListenableFuture startRole( - @PathParam("serviceName") String serviceName, - @PathParam("deploymentName") String deploymentName, - @PathParam("roleName") String roleName); + ListenableFuture startRole(@PathParam("serviceName") String serviceName, + @PathParam("deploymentName") String deploymentName, @PathParam("roleName") String roleName); } diff --git a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobAsyncClient.java b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobAsyncClient.java index 266c1bf621..8245f9b66d 100644 --- a/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobAsyncClient.java +++ b/providers/azureblob/src/main/java/org/jclouds/azureblob/AzureBlobAsyncClient.java @@ -21,6 +21,7 @@ package org.jclouds.azureblob; import java.util.Map; import java.util.concurrent.ExecutionException; +import javax.inject.Named; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.HEAD; @@ -93,6 +94,7 @@ public interface AzureBlobAsyncClient { /** * @see AzureBlobClient#listContainers */ + @Named("ListContainers") @GET @XMLResponseParser(AccountNameEnumerationResultsHandler.class) @QueryParams(keys = "comp", values = "list") @@ -101,69 +103,76 @@ public interface AzureBlobAsyncClient { /** * @see AzureBlobClient#createContainer */ + @Named("CreateContainer") @PUT @Path("{container}") @Fallback(FalseIfContainerAlreadyExists.class) @QueryParams(keys = "restype", values = "container") ListenableFuture createContainer( - @PathParam("container") @ParamValidators( { ContainerNameValidator.class }) String container, + @PathParam("container") @ParamValidators(ContainerNameValidator.class) String container, CreateContainerOptions... options); /** * @see AzureBlobClient#getPublicAccessForContainer */ + @Named("GetContainerACL") @HEAD @Path("{container}") @QueryParams(keys = { "restype", "comp" }, values = { "container", "acl" }) @ResponseParser(ParsePublicAccessHeader.class) @Fallback(NullOnContainerNotFound.class) ListenableFuture getPublicAccessForContainer( - @PathParam("container") @ParamValidators( { ContainerNameValidator.class }) String container); + @PathParam("container") @ParamValidators(ContainerNameValidator.class) String container); /** * @see AzureBlobClient#getContainerProperties */ + @Named("GetContainerProperties") @HEAD @Path("{container}") @QueryParams(keys = "restype", values = "container") @ResponseParser(ParseContainerPropertiesFromHeaders.class) @Fallback(NullOnContainerNotFound.class) ListenableFuture getContainerProperties( - @PathParam("container") @ParamValidators( { ContainerNameValidator.class }) String container); + @PathParam("container") @ParamValidators(ContainerNameValidator.class) String container); /** * @see AzureBlobClient#containerExists */ + @Named("GetContainerProperties") @HEAD @Path("{container}") @QueryParams(keys = "restype", values = "container") @Fallback(FalseOnContainerNotFound.class) ListenableFuture containerExists( - @PathParam("container") @ParamValidators( { ContainerNameValidator.class }) String container); + @PathParam("container") @ParamValidators(ContainerNameValidator.class) String container); /** * @see AzureBlobClient#setResourceMetadata */ + @Named("SetContainerMetadata") @PUT @Path("{container}") @QueryParams(keys = { "restype", "comp" }, values = { "container", "metadata" }) ListenableFuture setResourceMetadata( - @PathParam("container") @ParamValidators( { ContainerNameValidator.class }) String container, + @PathParam("container") @ParamValidators(ContainerNameValidator.class) String container, @BinderParam(BindMapToHeadersWithPrefix.class) Map metadata); /** * @see AzureBlobClient#deleteContainer */ + @Named("DeleteContainer") @DELETE @Path("{container}") @Fallback(VoidOnNotFoundOr404.class) @QueryParams(keys = "restype", values = "container") ListenableFuture deleteContainer( - @PathParam("container") @ParamValidators( { ContainerNameValidator.class }) String container); + @PathParam("container") @ParamValidators(ContainerNameValidator.class) String container); /** * @see AzureBlobClient#createRootContainer */ + @Named("CreateContainer") @PUT @Path("$root") @Fallback(FalseIfContainerAlreadyExists.class) @@ -173,6 +182,7 @@ public interface AzureBlobAsyncClient { /** * @see AzureBlobClient#deleteRootContainer */ + @Named("DeleteContainer") @DELETE @Path("$root") @Fallback(TrueOnNotFoundOr404.class) @@ -182,17 +192,19 @@ public interface AzureBlobAsyncClient { /** * @see AzureBlobClient#listBlobs(String, ListBlobsOptions[]) */ + @Named("ListBlobs") @GET @XMLResponseParser(ContainerNameEnumerationResultsHandler.class) @Path("{container}") @QueryParams(keys = { "restype", "comp" }, values = { "container", "list" }) ListenableFuture listBlobs( - @PathParam("container") @ParamValidators( { ContainerNameValidator.class }) String container, + @PathParam("container") @ParamValidators(ContainerNameValidator.class) String container, ListBlobsOptions... options); /** * @see AzureBlobClient#listBlobs(ListBlobsOptions[]) */ + @Named("ListBlobs") @GET @XMLResponseParser(ContainerNameEnumerationResultsHandler.class) @Path("$root") @@ -202,63 +214,70 @@ public interface AzureBlobAsyncClient { /** * @see AzureBlobClient#putBlob */ + @Named("PutBlob") @PUT @Path("{container}/{name}") @ResponseParser(ParseETagHeader.class) ListenableFuture putBlob( - @PathParam("container") @ParamValidators( { ContainerNameValidator.class }) String container, + @PathParam("container") @ParamValidators(ContainerNameValidator.class) String container, @PathParam("name") @ParamParser(BlobName.class) @BinderParam(BindAzureBlobMetadataToRequest.class) org.jclouds.azureblob.domain.AzureBlob object); /** * @see AzureBlobClient#getBlob */ + @Named("GetBlob") @GET @ResponseParser(ParseBlobFromHeadersAndHttpContent.class) @Fallback(NullOnKeyNotFound.class) @Path("{container}/{name}") ListenableFuture getBlob( - @PathParam("container") @ParamValidators( { ContainerNameValidator.class }) String container, + @PathParam("container") @ParamValidators(ContainerNameValidator.class) String container, @PathParam("name") String name, GetOptions... options); /** * @see AzureBlobClient#getBlobProperties */ + @Named("GetBlobProperties") @HEAD @ResponseParser(ParseBlobPropertiesFromHeaders.class) @Fallback(NullOnKeyNotFound.class) @Path("{container}/{name}") ListenableFuture getBlobProperties( - @PathParam("container") @ParamValidators( { ContainerNameValidator.class }) String container, + @PathParam("container") @ParamValidators(ContainerNameValidator.class) String container, @PathParam("name") String name); /** * @see AzureBlobClient#blobExists + * */ + @Named("GetBlobProperties") @HEAD @Fallback(FalseOnKeyNotFound.class) @Path("{container}/{name}") ListenableFuture blobExists( - @PathParam("container") @ParamValidators( { ContainerNameValidator.class }) String container, + @PathParam("container") @ParamValidators(ContainerNameValidator.class) String container, @PathParam("name") String name); /** * @see AzureBlobClient#setBlobMetadata */ + @Named("SetBlobMetadata") @PUT @Path("{container}/{name}") @QueryParams(keys = { "comp" }, values = { "metadata" }) ListenableFuture setBlobMetadata( - @PathParam("container") @ParamValidators( { ContainerNameValidator.class }) String container, + @PathParam("container") @ParamValidators(ContainerNameValidator.class) String container, @PathParam("name") String name, @BinderParam(BindMapToHeadersWithPrefix.class) Map metadata); /** * @see AzureBlobClient#deleteBlob */ + @Named("DeleteBlob") @DELETE @Fallback(VoidOnNotFoundOr404.class) @Path("{container}/{name}") ListenableFuture deleteBlob( - @PathParam("container") @ParamValidators( { ContainerNameValidator.class }) String container, + @PathParam("container") @ParamValidators(ContainerNameValidator.class) String container, @PathParam("name") String name); }