http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/main/java/org/jclouds/azurecompute/features/DiskApi.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/DiskApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/DiskApi.java deleted file mode 100644 index 22938aa..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/DiskApi.java +++ /dev/null @@ -1,71 +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.azurecompute.features; - -import java.util.List; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.azurecompute.domain.Disk; -import org.jclouds.azurecompute.functions.ParseRequestIdHeader; -import org.jclouds.azurecompute.xml.ListDisksHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.QueryParams; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.XMLResponseParser; - -/** - * The Service Management API includes operations for managing the disks in your subscription. - * - * @see <a href="http://msdn.microsoft.com/en-us/library/jj157188">docs</a> - */ -@Path("/services/disks") -@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") -@Consumes(MediaType.APPLICATION_XML) -public interface DiskApi { - - /** - * The List Disks operation retrieves a list of the disks in your image repository. - */ - @Named("ListDisks") - @GET - @XMLResponseParser(ListDisksHandler.class) - @Fallback(EmptyListOnNotFoundOr404.class) - List<Disk> list(); - - /** - * The Delete Disk operation deletes the specified data or operating system disk from your image repository. - * - * @return request id or null, if not found - */ - @Named("DeleteDisk") - @DELETE - @Path("/{diskName}") - @QueryParams(keys = "comp", values = "media") - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - String delete(@PathParam("diskName") String diskName); -}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java deleted file mode 100644 index 60a3b1a..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/LocationApi.java +++ /dev/null @@ -1,54 +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.azurecompute.features; - -import java.util.List; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; -import org.jclouds.azurecompute.domain.Location; -import org.jclouds.azurecompute.xml.ListLocationsHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.XMLResponseParser; - -/** - * The Service Management API includes operations for listing the available data center locations for a cloud service in - * your subscription. - * <p/> - * - * @see <a href="http://msdn.microsoft.com/en-us/library/gg441299">docs</a> - */ -@Path("/locations") -@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") -@Consumes(MediaType.APPLICATION_XML) -public interface LocationApi { - - /** - * The List Locations operation lists all of the data center locations that are valid for your subscription. - */ - @Named("ListLocations") - @GET - @XMLResponseParser(ListLocationsHandler.class) - @Fallback(EmptyListOnNotFoundOr404.class) - List<Location> list(); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/main/java/org/jclouds/azurecompute/features/NetworkSecurityGroupApi.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/NetworkSecurityGroupApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/NetworkSecurityGroupApi.java deleted file mode 100644 index d709831..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/NetworkSecurityGroupApi.java +++ /dev/null @@ -1,215 +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.azurecompute.features; - -import java.util.List; - -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.core.MediaType; - -import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.azurecompute.binders.NetworkSecurityGroupToXML; -import org.jclouds.azurecompute.binders.RuleToXML; -import org.jclouds.azurecompute.domain.NetworkSecurityGroup; -import org.jclouds.azurecompute.domain.Rule; -import org.jclouds.azurecompute.functions.ParseRequestIdHeader; -import org.jclouds.azurecompute.xml.ListNetworkSecurityGroupsHandler; -import org.jclouds.azurecompute.xml.NetworkSecurityGroupHandler; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.Payload; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.QueryParams; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.XMLResponseParser; - -/** - * The Service Management API includes operations for managing the network security groups in your subscription. - * - * @see https://msdn.microsoft.com/en-us/library/azure/dn913824.aspx. - */ -@Path("/services/networking") -@Produces(MediaType.APPLICATION_XML) -@Consumes(MediaType.APPLICATION_XML) -@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") -public interface NetworkSecurityGroupApi { - - /** - * The List Network Security Groups operation returns a list of the network security groups in the specified - * subscription. - * - * @return network security group list. - */ - @Named("ListNetworkSecurityGroups") - @Path("/networksecuritygroups") - @GET - @XMLResponseParser(ListNetworkSecurityGroupsHandler.class) - @Fallback(EmptyListOnNotFoundOr404.class) - List<NetworkSecurityGroup> list(); - - /** - * The Create Network Security Group operation creates a new network security group within the context of the - * specified subscription. For more information, see - * <a href="https://msdn.microsoft.com/en-us/library/azure/dn848316.aspx">About Network Security Groups</a>. - * - * @param networkSecurityGroup network security group. - * @return request id. - */ - @Named("CreateNetworkSecurityGroup") - @Path("/networksecuritygroups") - @POST - @ResponseParser(ParseRequestIdHeader.class) - String create(@BinderParam(NetworkSecurityGroupToXML.class) NetworkSecurityGroup networkSecurityGroup); - - /** - * Deletes the pecified Network Security Group from your subscription. If the Network Security group is still - * associated with some VM/Role/Subnet, the deletion will fail. In order to successfully delete the Network Security, - * it needs to be not used. - * - * @param networkSecurityGroupName - * @return request id - */ - @Named("CreateNetworkSecurityGroup") - @Path("/networksecuritygroups/{networkSecurityGroupName}") - @Fallback(NullOnNotFoundOr404.class) - @DELETE - @ResponseParser(ParseRequestIdHeader.class) - String delete(@PathParam("networkSecurityGroupName") String networkSecurityGroupName); - - /** - * The Get Network Security Group for Subnet operation returns information about the network security group - * associated with a subnet. - * - * @param virtualNetworkName virtual network name. - * @param subnetName subnet name. - * @return network security group. - */ - @Named("GetsNetworkSecurityGroupAppliedToSubnet") - @Path("/virtualnetwork/{virtualNetworkName}/subnets/{subnetName}/networksecuritygroups") - @GET - @XMLResponseParser(NetworkSecurityGroupHandler.class) - @Fallback(NullOnNotFoundOr404.class) - NetworkSecurityGroup getNetworkSecurityGroupAppliedToSubnet( - @PathParam("virtualNetworkName") String virtualNetworkName, @PathParam("subnetName") String subnetName); - - /** - * The Get Network Security Group operation returns information about the specified network security group and rules. - * - * @param networkSecurityGroupName network security group name. - * @return network security group. - */ - @Named("GetDetailsNetworkSecurityGroup") - @Path("/networksecuritygroups/{networkSecurityGroupName}") - @GET - @QueryParams(keys = "detaillevel", values = "Full") - @XMLResponseParser(NetworkSecurityGroupHandler.class) - @Fallback(NullOnNotFoundOr404.class) - NetworkSecurityGroup getFullDetails(@PathParam("networkSecurityGroupName") String networkSecurityGroupName); - - /** - * The Get Network Security Group operation returns information about the specified network security group. - * - * @param networkSecurityGroupName network security group name. - * @return network security group. - */ - @Named("GetDetailsNetworkSecurityGroup") - @Path("/networksecuritygroups/{networkSecurityGroupName}") - @GET - @XMLResponseParser(NetworkSecurityGroupHandler.class) - @Fallback(NullOnNotFoundOr404.class) - NetworkSecurityGroup get(@PathParam("networkSecurityGroupName") String networkSecurityGroupName); - - /** - * The Add Network Security Group to Subnet operation associates the network security group with specified subnet in - * a virtual network. For more information, see - * <a href="https://msdn.microsoft.com/en-us/library/azure/dn848316.aspx">About Network Security Groups</a>. - * - * @param virtualNetworkName virtual network name. - * @param subnetName subnet name. - * @param networkSecurityGroupName network security group name. - * @return request id. - */ - @Named("AddNetworkSecurityGroupToSubnet") - @Path("/virtualnetwork/{virtualNetworkName}/subnets/{subnetName}/networksecuritygroups") - @Payload("<NetworkSecurityGroup xmlns=\"http://schemas.microsoft.com/windowsazure\">" - + "<Name>{networkSecurityGroupName}</Name></NetworkSecurityGroup>") - @POST - @ResponseParser(ParseRequestIdHeader.class) - String addToSubnet(@PathParam("virtualNetworkName") String virtualNetworkName, - @PathParam("subnetName") String subnetName, - @PayloadParam("networkSecurityGroupName") String networkSecurityGroupName); - - /** - * The Remove Network Security Group from Subnet operation removes the association of the specified network security - * group from the specified subnet. - * - * @param virtualNetworkName virtual network name. - * @param subnetName subnet name. - * @param networkSecurityGroupName network security group name. - * @return request id. - */ - @Named("RemoveNetworkSecurityGroupToSubnet") - @Path("/virtualnetwork/{virtualNetworkName}/subnets/{subnetName}/networksecuritygroups/{networkSecurityGroupName}") - @Fallback(NullOnNotFoundOr404.class) - @DELETE - @ResponseParser(ParseRequestIdHeader.class) - String removeFromSubnet(@PathParam("virtualNetworkName") String virtualNetworkName, - @PathParam("subnetName") String subnetName, - @PathParam("networkSecurityGroupName") String networkSecurityGroupName); - - /** - * The Set Network Security Rule operation adds or updates a network security rule that is associated with the - * specified network security group. - * - * @param networkSecurityGroupName network security group name. - * @param ruleName rule name. - * @param rule rule. - * @return request id. - */ - @Named("SetNetworkSecurityRuleToNetworkSecurityGroup") - @Path("/networksecuritygroups/{networkSecurityGroupName}/rules/{ruleName}") - @PUT - @ResponseParser(ParseRequestIdHeader.class) - String setRule(@PathParam("networkSecurityGroupName") String networkSecurityGroupName, - @PathParam("ruleName") String ruleName, @BinderParam(RuleToXML.class) Rule rule); - - /** - * The Delete Network Security Rule operation deletes a network security group rule from the specified network - * security group. - * - * @param networkSecurityGroupName network security group name. - * @param ruleName name of the rule to be deleted. - * @return request id. - */ - @Named("SetNetworkSecurityRuleToNetworkSecurityGroup") - @Path("/networksecuritygroups/{networkSecurityGroupName}/rules/{ruleName}") - @Fallback(NullOnNotFoundOr404.class) - @DELETE - @ResponseParser(ParseRequestIdHeader.class) - String deleteRule(@PathParam("networkSecurityGroupName") String networkSecurityGroupName, - @PathParam("ruleName") String ruleName); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/main/java/org/jclouds/azurecompute/features/OSImageApi.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/OSImageApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/OSImageApi.java deleted file mode 100644 index aaf3ba8..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/OSImageApi.java +++ /dev/null @@ -1,98 +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.azurecompute.features; - -import static javax.ws.rs.core.MediaType.APPLICATION_XML; - -import java.util.List; - -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.EmptyListOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.azurecompute.binders.OSImageParamsToXML; -import org.jclouds.azurecompute.domain.OSImage; -import org.jclouds.azurecompute.domain.OSImageParams; -import org.jclouds.azurecompute.functions.OSImageParamsName; -import org.jclouds.azurecompute.functions.ParseRequestIdHeader; -import org.jclouds.azurecompute.xml.ListOSImagesHandler; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.ParamParser; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.XMLResponseParser; - -/** - * The Service Management API includes operations for managing the OS images in your subscription. - * - * @see <a href="http://msdn.microsoft.com/en-us/library/jj157175">docs</a> - */ -@Path("/services/images") -@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") -@Consumes(APPLICATION_XML) -public interface OSImageApi { - - /** - * The List Cloud Services operation lists the cloud services available under the current subscription. - */ - @Named("ListImages") - @GET - @Produces(APPLICATION_XML) - @XMLResponseParser(ListOSImagesHandler.class) - @Fallback(EmptyListOnNotFoundOr404.class) - List<OSImage> list(); - - /** - * The Add OS Image operation adds an OS image that is currently stored in a storage account in your subscription to - * the image repository. - */ - @Named("AddImage") - @POST - @ResponseParser(ParseRequestIdHeader.class) - String add(@BinderParam(OSImageParamsToXML.class) OSImageParams params); - - /** - * The Update OS Image operation updates an OS image that in your image repository. - */ - @Named("UpdateImage") - @PUT - @Path("/{imageName}") - @ResponseParser(ParseRequestIdHeader.class) - String update(@PathParam("imageName") @ParamParser(OSImageParamsName.class) - @BinderParam(OSImageParamsToXML.class) OSImageParams params); - - /** - * The Delete Cloud Service operation deletes the specified cloud service from Windows Azure. - * - * @param imageName the unique DNS Prefix value in the Windows Azure Management Portal - */ - @Named("DeleteImage") - @DELETE - @Path("/{imageName}") - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - String delete(@PathParam("imageName") String imageName); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/main/java/org/jclouds/azurecompute/features/OperationApi.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/OperationApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/OperationApi.java deleted file mode 100644 index bc5e2dc..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/OperationApi.java +++ /dev/null @@ -1,48 +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.azurecompute.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.azurecompute.domain.Operation; -import org.jclouds.azurecompute.xml.OperationHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.XMLResponseParser; - -/** - * The Service Management API includes one operation for tracking the progress of asynchronous requests. - * - * @see <a href="http://msdn.microsoft.com/en-us/library/ee460796">docs</a> - */ -@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") -@Consumes(MediaType.APPLICATION_XML) -public interface OperationApi { - - @Named("GetOperation") - @GET - @Path("/operations/{request-id}") - @XMLResponseParser(OperationHandler.class) - @Fallback(NullOnNotFoundOr404.class) - Operation get(@PathParam("request-id") String requestId); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/main/java/org/jclouds/azurecompute/features/ReservedIPAddressApi.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/ReservedIPAddressApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/ReservedIPAddressApi.java deleted file mode 100644 index fd93665..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/ReservedIPAddressApi.java +++ /dev/null @@ -1,107 +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.azurecompute.features; - -import static javax.ws.rs.core.MediaType.APPLICATION_XML; - -import java.util.List; - -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.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; - -import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.azurecompute.binders.ReservedIPAddressParamsToXML; -import org.jclouds.azurecompute.domain.ReservedIPAddress; -import org.jclouds.azurecompute.domain.ReservedIPAddressParams; -import org.jclouds.azurecompute.functions.ParseRequestIdHeader; -import org.jclouds.azurecompute.xml.ListReservedIPAddressHandler; -import org.jclouds.azurecompute.xml.ReservedIPAddressHandler; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.XMLResponseParser; - -/** - * The Service Management API includes operations for managing the reserved IP addresses in your subscription. - * - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/dn722420.aspx">docs</a> - */ -@Path("/services/networking/reservedips") -@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") -@Consumes(APPLICATION_XML) -@Produces(APPLICATION_XML) -public interface ReservedIPAddressApi { - - /** - * The List Reserved IP Addresses operation lists the IP addresses that have been reserved for the specified - * subscription. - * - * @return list of reserved IPs. - */ - @Named("ListReservedIPAddress") - @GET - @XMLResponseParser(ListReservedIPAddressHandler.class) - @Fallback(EmptyListOnNotFoundOr404.class) - List<ReservedIPAddress> list(); - - /** - * The Get Reserved IP Address operation retrieves information about the specified reserved IP address. - * - * @param name reserver IP address name. - * @return reserved IP. - */ - @Named("GetReservedIPAddress") - @GET - @Path("/{name}") - @XMLResponseParser(ReservedIPAddressHandler.class) - @Fallback(NullOnNotFoundOr404.class) - ReservedIPAddress get(@PathParam("name") String name); - - /** - * The Get Reserved IP Address operation retrieves information about the specified reserved IP address. - * - * @param name reserver IP address name. - * @return request id. - */ - @Named("DeleteReservedIPAddress") - @DELETE - @Path("/{name}") - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - String delete(@PathParam("name") String name); - - /** - * The Create Reserved IP Address operation reserves an IPv4 address for the specified subscription. For more - * information, see Reserved IP Addresses. You can use a small number of reserved IP addresses for free, but unused - * reserved IP addresses and a number of addresses above the limit will incur charges. - * - * @param params reserved IP details to be sent as request body. - * @return request id. - */ - @Named("CreateReservedIPAddress") - @POST - @ResponseParser(ParseRequestIdHeader.class) - String create(@BinderParam(ReservedIPAddressParamsToXML.class) ReservedIPAddressParams params); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/main/java/org/jclouds/azurecompute/features/ServiceCertificatesApi.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/ServiceCertificatesApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/ServiceCertificatesApi.java deleted file mode 100644 index 4ddc98e..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/ServiceCertificatesApi.java +++ /dev/null @@ -1,123 +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.azurecompute.features; - -import static javax.ws.rs.core.MediaType.APPLICATION_XML; - -import java.util.List; - -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.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; - -import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.azurecompute.binders.ServiceCertificateParamsToXML; -import org.jclouds.azurecompute.domain.ServiceCertificate; -import org.jclouds.azurecompute.domain.ServiceCertificateParams; -import org.jclouds.azurecompute.functions.ParseRequestIdHeader; -import org.jclouds.azurecompute.xml.ListServiceCertificatesHandler; -import org.jclouds.azurecompute.xml.ServiceCertificateHandler; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.XMLResponseParser; - -/** - * The Service Management API includes operations for managing service certificates in your subscription. - * - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/ee795178.aspx">docs</a> - */ -@Path("/services/hostedservices") -@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") -@Consumes(APPLICATION_XML) -@Produces(APPLICATION_XML) -public interface ServiceCertificatesApi { - - /** - * The List Service Certificates operation lists all of the service certificates associated with the specified cloud - * service. - * - * @param service service name. - * @return list of cloud service certificates. - */ - @Named("ListServiceCertificates") - @GET - @Path("/{service}/certificates") - @XMLResponseParser(ListServiceCertificatesHandler.class) - @Fallback(EmptyListOnNotFoundOr404.class) - List<ServiceCertificate> list(@PathParam("service") String service); - - /** - * The Get Service Certificate operation returns the public data for the specified X.509 certificate associated with - * a cloud service. - * - * @param service service name. - * @param thumbprintAlgorithm thumbprint algorithm. - * @param thumbprintInHexadecimal thumbprint hexadecimal format. - * @return service certificate including data only. - */ - @Named("GetServiceCertificate") - @GET - @Path("/{service}/certificates/{thumbprintAlgorithm}-{thumbprintInHexadecimal}") - @XMLResponseParser(ServiceCertificateHandler.class) - @Fallback(NullOnNotFoundOr404.class) - ServiceCertificate get( - @PathParam("service") String service, - @PathParam("thumbprintAlgorithm") String thumbprintAlgorithm, - @PathParam("thumbprintInHexadecimal") String thumbprintInHexadecimal); - - /** - * The Delete Service Certificate asynchronous operation deletes a service certificate from the certificate store of - * a cloud service. - * - * @param service service name. - * @param thumbprintAlgorithm thumbprint algorithm. - * @param thumbprintInHexadecimal thumbprint hexadecimal format. - * @return request id. - */ - @Named("DeleteServiceCertificate") - @DELETE - @Path("/{service}/certificates/{thumbprintAlgorithm}-{thumbprintInHexadecimal}") - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - String delete( - @PathParam("service") String service, - @PathParam("thumbprintAlgorithm") String thumbprintAlgorithm, - @PathParam("thumbprintInHexadecimal") String thumbprintInHexadecimal); - - /** - * The Add Service Certificate asynchronous operation adds a certificate to a cloud service. - * - * @param service service name. - * @param params service certificate details to be sent as request body. - * @return request id. - */ - @Named("AddServiceCertificate") - @POST - @Path("/{service}/certificates") - @ResponseParser(ParseRequestIdHeader.class) - String add( - @PathParam("service") String service, - @BinderParam(ServiceCertificateParamsToXML.class) ServiceCertificateParams params); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/main/java/org/jclouds/azurecompute/features/StorageAccountApi.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/StorageAccountApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/StorageAccountApi.java deleted file mode 100644 index 336cdc7..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/StorageAccountApi.java +++ /dev/null @@ -1,140 +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.azurecompute.features; - -import java.util.List; - -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.core.MediaType; - -import org.jclouds.Fallbacks; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.azurecompute.binders.StorageServiceKeyTypeToXML; -import org.jclouds.azurecompute.binders.CreateStorageServiceParamsToXML; -import org.jclouds.azurecompute.binders.UpdateStorageServiceParamsToXML; -import org.jclouds.azurecompute.domain.Availability; -import org.jclouds.azurecompute.domain.StorageService; -import org.jclouds.azurecompute.domain.StorageServiceKeys; -import org.jclouds.azurecompute.domain.StorageServiceKeys.KeyType; -import org.jclouds.azurecompute.domain.CreateStorageServiceParams; -import org.jclouds.azurecompute.domain.UpdateStorageServiceParams; -import org.jclouds.azurecompute.functions.ParseRequestIdHeader; -import org.jclouds.azurecompute.xml.AvailabilityHandler; -import org.jclouds.azurecompute.xml.ListStorageServicesHandler; -import org.jclouds.azurecompute.xml.StorageServiceHandler; -import org.jclouds.azurecompute.xml.StorageServiceKeysHandler; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.QueryParams; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.XMLResponseParser; - -/** - * The Service Management API includes operations for managing the storage accounts in your subscription. - * - * @see <a href="http://msdn.microsoft.com/en-us/library/azure/ee460790">docs</a> - */ -@Path("/services/storageservices") -@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") -@Produces(MediaType.APPLICATION_XML) -@Consumes(MediaType.APPLICATION_XML) -public interface StorageAccountApi { - - /** - * The List Storage Accounts operation lists the storage accounts that are available in the specified subscription. - */ - @Named("ListStorageAccounts") - @GET - @XMLResponseParser(ListStorageServicesHandler.class) - @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class) - List<StorageService> list(); - - /** - * The Create Storage Account asynchronous operation creates a new storage account in Microsoft Azure. - */ - @Named("CreateStorageAccount") - @POST - @ResponseParser(ParseRequestIdHeader.class) - String create(@BinderParam(CreateStorageServiceParamsToXML.class) CreateStorageServiceParams storageServiceParams); - - /** - * The Check Storage Account Name Availability operation checks to see if the specified storage account name is - * available, or if it has already been taken. - */ - @Named("CheckStorageAccountNameAvailability") - @GET - @Path("/operations/isavailable/{storageAccountName}") - @XMLResponseParser(AvailabilityHandler.class) - Availability isAvailable(@PathParam("storageAccountName") String storageAccountName); - - /** - * The Get Storage Account Properties operation returns system properties for the specified storage account. - */ - @Named("GetStorageAccountProperties") - @GET - @Path("/{storageAccountName}") - @XMLResponseParser(StorageServiceHandler.class) - @Fallback(NullOnNotFoundOr404.class) - StorageService get(@PathParam("storageAccountName") String storageAccountName); - - /** - * The Get Storage Keys operation returns the primary and secondary access keys for the specified storage account. - */ - @Named("GetStorageAccountKeys") - @GET - @Path("/{storageAccountName}/keys") - @XMLResponseParser(StorageServiceKeysHandler.class) - @Fallback(NullOnNotFoundOr404.class) - StorageServiceKeys getKeys(@PathParam("storageAccountName") String storageAccountName); - - @Named("RegenerateStorageAccountKeys") - @POST - @Path("/{storageAccountName}/keys") - @QueryParams(keys = "action", values = "regenerate") - @ResponseParser(ParseRequestIdHeader.class) - String regenerateKeys( - @PathParam("storageAccountName") String storageAccountName, - @BinderParam(StorageServiceKeyTypeToXML.class) KeyType keyType); - - /** - * The Update Storage Account asynchronous operation updates the label, the description, and enables or disables the - * geo-replication status for the specified storage account. - */ - @Named("UpdateStorageAccount") - @PUT - @Path("/{storageAccountName}") - @ResponseParser(ParseRequestIdHeader.class) - String update( - @PathParam("storageAccountName") String storageAccountName, - @BinderParam(UpdateStorageServiceParamsToXML.class) UpdateStorageServiceParams storageServiceParams); - - @Named("DeleteStorageAccount") - @DELETE - @Path("/{serviceName}") - @ResponseParser(ParseRequestIdHeader.class) - String delete(@PathParam("serviceName") String serviceName); - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/main/java/org/jclouds/azurecompute/features/SubscriptionApi.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/SubscriptionApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/SubscriptionApi.java deleted file mode 100644 index c0ac9ca..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/SubscriptionApi.java +++ /dev/null @@ -1,53 +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.azurecompute.features; - -import java.util.List; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; -import org.jclouds.azurecompute.domain.RoleSize; -import org.jclouds.azurecompute.xml.ListRoleSizesHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.XMLResponseParser; - -/** - * The Service Management API includes operations for retrieving information about a subscription. - * - * @see <a href="http://msdn.microsoft.com/en-us/library/gg715315">docs</a> - */ -@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") -@Consumes(MediaType.APPLICATION_XML) -public interface SubscriptionApi { - - /** - * The List Role Sizes operation lists the role sizes that are available under the specified subscription. - */ - @Named("ListRoleSizes") - @GET - @Path("/rolesizes") - @XMLResponseParser(ListRoleSizesHandler.class) - @Fallback(EmptyListOnNotFoundOr404.class) - List<RoleSize> listRoleSizes(); - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/main/java/org/jclouds/azurecompute/features/TrafficManagerApi.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/TrafficManagerApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/TrafficManagerApi.java deleted file mode 100644 index d41cda1..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/TrafficManagerApi.java +++ /dev/null @@ -1,184 +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.azurecompute.features; - -import java.util.List; -import static javax.ws.rs.core.MediaType.APPLICATION_XML; - -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; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.azurecompute.binders.ProfileDefinitionParamsToXML; -import org.jclouds.azurecompute.binders.ProfileParamsToXML; -import org.jclouds.azurecompute.domain.Profile; -import org.jclouds.azurecompute.domain.ProfileDefinition; -import org.jclouds.azurecompute.domain.ProfileDefinitionParams; -import org.jclouds.azurecompute.domain.CreateProfileParams; -import org.jclouds.azurecompute.domain.UpdateProfileParams; -import org.jclouds.azurecompute.functions.ParseRequestIdHeader; -import org.jclouds.azurecompute.xml.ListProfileDefinitionsHandler; -import org.jclouds.azurecompute.xml.ListProfilesHandler; -import org.jclouds.azurecompute.xml.ProfileDefinitionHandler; -import org.jclouds.azurecompute.xml.ProfileHandler; -import org.jclouds.azurecompute.xml.ResultHandler; - -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.XMLResponseParser; - -/** - * The Service Management API includes operations for creating, updating, listing, and deleting Azure Traffic Manager - * profiles and definitions. - * - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/hh758255.aspx">docs</a> - */ -@Path("/services/WATM") -@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") -@Consumes(APPLICATION_XML) -@Produces(APPLICATION_XML) -public interface TrafficManagerApi { - - /** - * The List Definitions operation returns all definitions of a profile. - * - * @param profile profile name. - * @return profile definitions. - */ - @Named("ListProfileDefinitions") - @GET - @Path("/profiles/{profile}/definitions") - @XMLResponseParser(ListProfileDefinitionsHandler.class) - @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class) - List<ProfileDefinition> listDefinitions(@PathParam("profile") String profile); - - /** - * The Get Definition operation returns an existing profile definition. - * - * @param profile profile name. - * @return profile definition. - */ - @Named("GetProfileDefinition") - @GET - @Path("/profiles/{profile}/definitions/1") - @XMLResponseParser(ProfileDefinitionHandler.class) - @Fallback(NullOnNotFoundOr404.class) - ProfileDefinition getDefinition(@PathParam("profile") String profile); - - /** - * The Create Profile operation creates a new profile for a domain name, owned by the specified subscription. - * - * @return traffic manager profiles. - */ - @Named("ListProfiles") - @GET - @Path("/profiles") - @XMLResponseParser(ListProfilesHandler.class) - @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class) - List<Profile> listProfiles(); - - /** - * The Get Profile operation returns profile details, including all definition versions and their statuses. - * - * @param profile profile name. - * @return traffic manager profile. - */ - @Named("GetProfile") - @GET - @Path("/profiles/{profile}") - @XMLResponseParser(ProfileHandler.class) - @Fallback(NullOnNotFoundOr404.class) - Profile getProfile(@PathParam("profile") String profile); - - /** - * The Check DNS Prefix Availability operation checks whether the specified DNS prefix is available for creating a - * profile. - * - * @param name DNS name that you want to use. You must include .trafficmanager.net in the name. - * @return DNS name availability. - */ - @Named("CheckDNSPrefixAvailability") - @GET - @Path("/operations/isavailable/{name}") - @XMLResponseParser(ResultHandler.class) - @Fallback(NullOnNotFoundOr404.class) - boolean checkDNSPrefixAvailability(@PathParam("name") String name); - - /** - * The Create Definition operation creates a new definition for a specified profile. This definition will be assigned - * a version number by the service. For more information about creating a profile, see Create Profile. - * - * @param name profile name. - * @param params profile definition details to be sent as request body. - * @return request id. - */ - @Named("CreateProfileDefinition") - @POST - @Path("/profiles/{name}/definitions") - @ResponseParser(ParseRequestIdHeader.class) - String createDefinition( - @PathParam("name") String name, - @BinderParam(ProfileDefinitionParamsToXML.class) ProfileDefinitionParams params); - - /** - * The Delete Profile operation deletes a profile and all of its definitions. This operation cannot be reverted. - * - * @param profile traffic manager profile name. - * @return request id. - */ - @Named("DeleteProfile") - @DELETE - @Path("/profiles/{profile}") - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) - String delete(@PathParam("profile") String profile); - - /** - * The Create Profile operation creates a new profile for a domain name, owned by the specified subscription. - * - * @param params profile parameters. - * @return request id. - */ - @Named("CreateProfile") - @POST - @Path("/profiles") - @ResponseParser(ParseRequestIdHeader.class) - String createProfile(@BinderParam(ProfileParamsToXML.class) CreateProfileParams params); - - /** - * The Update Profile operation enables or disables a profile. - * - * @param profile traffic manager profile name. - * @param params update profile params. - * @return request id. - */ - @Named("UpdateProfile") - @PUT - @Path("/profiles/{profile}") - @ResponseParser(ParseRequestIdHeader.class) - String updateProfile( - @PathParam("profile") String profile, @BinderParam(ProfileParamsToXML.class) UpdateProfileParams params); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/main/java/org/jclouds/azurecompute/features/VMImageApi.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/VMImageApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/VMImageApi.java deleted file mode 100644 index 6ad52b2..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/VMImageApi.java +++ /dev/null @@ -1,95 +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.azurecompute.features; - -import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.azurecompute.binders.VMImageParamsToXML; -import org.jclouds.azurecompute.domain.VMImage; -import org.jclouds.azurecompute.domain.VMImageParams; -import org.jclouds.azurecompute.functions.ParseRequestIdHeader; -import org.jclouds.azurecompute.xml.ListVMImagesHandler; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.XMLResponseParser; -import org.jclouds.rest.annotations.BinderParam; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.DELETE; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import java.util.List; - -import static javax.ws.rs.core.MediaType.APPLICATION_XML; - -/** - * The Service Management API includes operations for managing the VM Images in your subscription. - * - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/dn499771.aspx">docs</a> - */ -@Path("/services/vmimages") -@Consumes(APPLICATION_XML) -@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") -public interface VMImageApi { - - - /** - * The List VM Images operation retrieves a list of the VM Images from the image repository that is associated with - * the specified subscription. - */ - @Named("ListVMImages") - @GET - @XMLResponseParser(ListVMImagesHandler.class) - @Fallback(EmptyListOnNotFoundOr404.class) List<VMImage> list(); - - /** - * The Create VM Image operation creates a VM Image in the image repository that is associated with the specified - * subscription using a specified set of virtual hard disks. - */ - @Named("CreateVMImage") - @POST - @Produces(APPLICATION_XML) - @ResponseParser(ParseRequestIdHeader.class) String create( - @BinderParam(VMImageParamsToXML.class) VMImageParams params); - - /** - * The Create VM Image operation creates a VM Image in the image repository that is associated with the specified - * subscription using a specified set of virtual hard disks. - */ - @Named("UpdateVMImage") - @PUT - @Path("/{imageName}") - @Produces(APPLICATION_XML) - @ResponseParser(ParseRequestIdHeader.class) String update(@PathParam("imageName") String imageName, - @BinderParam(VMImageParamsToXML.class) VMImageParams params); - - /** - * The Delete VM Image operation deletes the specified VM Image from the image repository that is associated with - * the specified subscription. - */ - @Named("DeleteImage") - @DELETE - @Path("/{imageName}") - @Fallback(NullOnNotFoundOr404.class) - @ResponseParser(ParseRequestIdHeader.class) String delete(@PathParam("imageName") String imageName); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualMachineApi.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualMachineApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualMachineApi.java deleted file mode 100644 index 4065195..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualMachineApi.java +++ /dev/null @@ -1,152 +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.azurecompute.features; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -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.core.MediaType; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.azurecompute.binders.CaptureVMImageParamsToXML; -import org.jclouds.azurecompute.binders.RoleToXML; -import org.jclouds.azurecompute.domain.CaptureVMImageParams; -import org.jclouds.azurecompute.domain.Role; -import org.jclouds.azurecompute.functions.ParseRequestIdHeader; -import org.jclouds.azurecompute.xml.RoleHandler; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.Payload; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.XMLResponseParser; - -/** - * The Service Management API includes operations for managing the virtual machines in your subscription. - * - * @see <a href="http://msdn.microsoft.com/en-us/library/jj157206">docs</a> - */ -@Path("/services/hostedservices/{serviceName}/deployments/{deploymentName}") -@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") -@Consumes(MediaType.APPLICATION_XML) -// NOTE: MS Docs refer to the commands as Role, but in the description, it is always Virtual Machine. -public interface VirtualMachineApi { - - @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 - @Path("/roleinstances/{name}/Operations") - @Produces(MediaType.APPLICATION_XML) - @ResponseParser(ParseRequestIdHeader.class) - @Payload(value = "<RestartRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\">" - + "<OperationType>RestartRoleOperation</OperationType></RestartRoleOperation>") - String restart(@PathParam("name") String name); - - /** - * http://msdn.microsoft.com/en-us/library/jj157201 - */ - @Named("CaptureRole") - @POST - @Path("/roleinstances/{name}/Operations") - @Produces(MediaType.APPLICATION_XML) - @ResponseParser(ParseRequestIdHeader.class) - @Payload(value = "<CaptureRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\">" - + "<OperationType>CaptureRoleOperation</OperationType>" - + "<PostCaptureAction>Delete</PostCaptureAction>" - + "<TargetImageLabel>{imageLabel}</TargetImageLabel>" - + "<TargetImageName>{imageName}</TargetImageName></CaptureRoleOperation>") - String capture(@PathParam("name") String name, @PayloadParam("imageName") String imageName, - @PayloadParam("imageLabel") String imageLabel); - - /** - * http://msdn.microsoft.com/en-us/library/jj157195 - */ - @Named("ShutdownRole") - @POST - @Path("/roleinstances/{name}/Operations") - @Produces(MediaType.APPLICATION_XML) - @ResponseParser(ParseRequestIdHeader.class) - @Payload(value = "<ShutdownRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\">" - + "<OperationType>ShutdownRoleOperation</OperationType>" + - "<PostShutdownAction>{postShutdownAction}</PostShutdownAction></ShutdownRoleOperation>") - String shutdown(@PathParam("name") String name, @PayloadParam("postShutdownAction") String postShutdownAction); - - /** - * http://msdn.microsoft.com/en-us/library/jj157195 - */ - @Named("ShutdownRole") - @POST - @Path("/roleinstances/{name}/Operations") - @Produces(MediaType.APPLICATION_XML) - @ResponseParser(ParseRequestIdHeader.class) - @Payload(value = "<ShutdownRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\">" - + "<OperationType>ShutdownRoleOperation</OperationType></ShutdownRoleOperation>") - String shutdown(@PathParam("name") String name); - - /** - * http://msdn.microsoft.com/en-us/library/jj157189 - */ - @Named("StartRole") - @POST - @Path("/roleinstances/{name}/Operations") - @Produces(MediaType.APPLICATION_XML) - @ResponseParser(ParseRequestIdHeader.class) - @Payload(value = "<StartRoleOperation xmlns=\"http://schemas.microsoft.com/windowsazure\">" - + "<OperationType>StartRoleOperation</OperationType></StartRoleOperation>") - String start(@PathParam("name") String name); - - /** - * https://msdn.microsoft.com/en-us/library/azure/jj157193.aspx - */ - @Named("GetRole") - @GET - @Path("/roles/{roleName}") - @Produces(MediaType.APPLICATION_XML) - @XMLResponseParser(RoleHandler.class) - @Fallback(NullOnNotFoundOr404.class) - Role getRole(@PathParam("roleName") String roleName); - - /** - * https://msdn.microsoft.com/library/azure/jj157187.aspx - */ - @Named("UpdateRole") - @PUT - @Path("/roles/{roleName}") - @Produces(MediaType.APPLICATION_XML) - @ResponseParser(ParseRequestIdHeader.class) - String updateRole(@PathParam("roleName") String roleName, @BinderParam(RoleToXML.class) Role role); - - /** - * The Capture VM Image operation creates a copy of the operating system virtual hard disk (VHD) and all of the data - * VHDs that are associated with the Virtual Machine, saves the VHD copies in the same storage location as the original - * VHDs, and registers the copies as a VM Image in the image repository that is associated with the specified subscription. - */ - @Named("CaptureVMImage") - @POST - @Produces(MediaType.APPLICATION_XML) - @Path("/roleinstances/{name}/Operations") - @ResponseParser(ParseRequestIdHeader.class) String capture(@PathParam("name") String name, - @BinderParam(CaptureVMImageParamsToXML.class) CaptureVMImageParams params); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualNetworkApi.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualNetworkApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualNetworkApi.java deleted file mode 100644 index 23cba78..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/features/VirtualNetworkApi.java +++ /dev/null @@ -1,75 +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.azurecompute.features; - -import java.util.List; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.azurecompute.binders.NetworkConfigurationToXML; -import org.jclouds.azurecompute.domain.NetworkConfiguration; -import org.jclouds.azurecompute.domain.NetworkConfiguration.VirtualNetworkSite; -import org.jclouds.azurecompute.functions.ParseRequestIdHeader; -import org.jclouds.azurecompute.xml.ListVirtualNetworkSitesHandler; -import org.jclouds.azurecompute.xml.NetworkConfigurationHandler; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Headers; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.XMLResponseParser; - -@Path("/services/networking") -@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") -@Consumes(MediaType.APPLICATION_XML) -public interface VirtualNetworkApi { - - /** - * The Get Network Configuration operation retrieves the network configuration file. - * - * @return The response body is a netcfg.cfg file. - * - */ - @Named("GetVirtualNetworkConfiguration") - @Path("/media") - @GET - @XMLResponseParser(NetworkConfigurationHandler.class) - @Fallback(NullOnNotFoundOr404.class) - NetworkConfiguration getNetworkConfiguration(); - - @Named("ListVirtualNetworkSites") - @Path("/virtualnetwork") - @GET - @XMLResponseParser(ListVirtualNetworkSitesHandler.class) - @Fallback(EmptyListOnNotFoundOr404.class) - List<VirtualNetworkSite> list(); - - @Named("SetVirtualNetworkConfiguration") - @Path("/media") - @PUT - @Produces(MediaType.TEXT_PLAIN) - @ResponseParser(ParseRequestIdHeader.class) - String set(@BinderParam(NetworkConfigurationToXML.class) NetworkConfiguration networkConfiguration); - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/main/java/org/jclouds/azurecompute/functions/Base64EncodeLabel.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/Base64EncodeLabel.java b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/Base64EncodeLabel.java deleted file mode 100644 index 89aa61b..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/Base64EncodeLabel.java +++ /dev/null @@ -1,30 +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.azurecompute.functions; - -import static com.google.common.base.Charsets.UTF_8; -import static com.google.common.io.BaseEncoding.base64; - -import com.google.common.base.Function; - -public final class Base64EncodeLabel implements Function<Object, String> { - - @Override - public String apply(final Object label) { - return base64().encode(label.toString().getBytes(UTF_8)); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/main/java/org/jclouds/azurecompute/functions/OSImageParamsName.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/OSImageParamsName.java b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/OSImageParamsName.java deleted file mode 100644 index 1f5fa40..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/OSImageParamsName.java +++ /dev/null @@ -1,29 +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.azurecompute.functions; - -import org.jclouds.azurecompute.domain.OSImageParams; - -import com.google.common.base.Function; - -public class OSImageParamsName implements Function<Object, String> { - - @Override - public String apply(final Object input) { - return OSImageParams.class.cast(input).name(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ParseRequestIdHeader.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ParseRequestIdHeader.java b/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ParseRequestIdHeader.java deleted file mode 100644 index 17cc0bb..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/functions/ParseRequestIdHeader.java +++ /dev/null @@ -1,46 +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.azurecompute.functions; - -import static org.jclouds.http.HttpUtils.releasePayload; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpResponse; - -import com.google.common.base.Function; - -/** - * Parses an x-ms-request-id the header - * - * A value that uniquely identifies a request made against the management service. For an asynchronous operation, you - * can call get operation status with the value of the header to determine whether the operation is complete, has - * failed, or is still in progress. - */ -@Singleton -public class ParseRequestIdHeader implements Function<HttpResponse, String> { - - public String apply(final HttpResponse from) { - releasePayload(from); - final String requestId = from.getFirstHeaderOrNull("x-ms-request-id"); - if (requestId != null) { - return requestId; - } - throw new IllegalStateException("did not receive RequestId in: " + from); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/main/java/org/jclouds/azurecompute/handlers/AzureComputeErrorHandler.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/handlers/AzureComputeErrorHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/handlers/AzureComputeErrorHandler.java deleted file mode 100644 index 23a691c..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/handlers/AzureComputeErrorHandler.java +++ /dev/null @@ -1,83 +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.azurecompute.handlers; - -import java.io.IOException; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ResourceNotFoundException; -import org.jclouds.util.Closeables2; -import org.jclouds.util.Strings2; - -/** - * This will parse and set an appropriate exception on the command object. - */ -@Singleton -public class AzureComputeErrorHandler implements HttpErrorHandler { - - @Override - public void handleError(final HttpCommand command, final HttpResponse response) { - // it is important to always read fully and close streams - String message = parseMessage(response); - Exception exception = message == null - ? new HttpResponseException(command, response) - : new HttpResponseException(command, response, message); - try { - message = message == null - ? String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine()) - : message; - switch (response.getStatusCode()) { - case 401: - case 403: - exception = new AuthorizationException(message, exception); - break; - - case 404: - if (!command.getCurrentRequest().getMethod().equals("DELETE")) { - exception = new ResourceNotFoundException(message, exception); - } - break; - - case 409: - exception = new IllegalStateException(message, exception); - break; - - default: - } - } finally { - Closeables2.closeQuietly(response.getPayload()); - command.setException(exception); - } - } - - public String parseMessage(final HttpResponse response) { - if (response.getPayload() == null) { - return null; - } - try { - return Strings2.toStringAndClose(response.getPayload().openStream()); - } catch (IOException e) { - throw new RuntimeException(e); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/DelegatingSSLContextSupplier.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/DelegatingSSLContextSupplier.java b/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/DelegatingSSLContextSupplier.java deleted file mode 100644 index bdc81f3..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/DelegatingSSLContextSupplier.java +++ /dev/null @@ -1,92 +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.azurecompute.suppliers; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Throwables.propagate; - -import com.google.common.base.Supplier; -import java.io.File; -import java.security.SecureRandom; -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.net.ssl.KeyManager; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; -import org.jclouds.crypto.Crypto; -import org.jclouds.domain.Credentials; -import org.jclouds.http.HttpUtils; -import org.jclouds.http.config.SSLModule.TrustAllCerts; -import org.jclouds.location.Provider; -import org.jclouds.rest.AuthorizationException; - -/** - * This supplier handles two different types of authentication: PKCS12 and PEM. - * <br/> - * Out of the {@link Credentials} instance: - * <ol> - * <li><tt>PKCS12</tt>: where {@link Credentials#identity} is keystore path and {@link Credentials#credential} is - * keystore password</li> - * <li><tt>PEM</tt>: where {@link Credentials#identity} is PEM-encoded certificate content and - * {@link Credentials#credential} is PEM-encoded private key</li> - * </ol> - */ -@Singleton -public class DelegatingSSLContextSupplier implements Supplier<SSLContext> { - - private final Crypto crypto; - - private final TrustManager[] trustManager; - - private final Supplier<Credentials> creds; - - @Inject - DelegatingSSLContextSupplier( - Crypto crypto, @Provider Supplier<Credentials> creds, HttpUtils utils, TrustAllCerts trustAllCerts) { - - this.crypto = crypto; - this.trustManager = utils.trustAllCerts() ? new TrustManager[]{trustAllCerts} : null; - this.creds = creds; - } - - @Override - public SSLContext get() { - final Credentials currentCreds = checkNotNull(creds.get(), "credential supplier returned null"); - final String identity = checkNotNull(currentCreds.identity, "credential supplier returned null identity"); - final String credential = checkNotNull(currentCreds.credential, "credential supplier returned null credential"); - - final File pkcs12File = new File(identity); - - final KeyManager[] keyManagers = pkcs12File.isFile() - ? // identity is path to PKCS12 file, credential holds keystore password - new FileBasedKeyManagersSupplier(pkcs12File, credential.toCharArray()).get() - : // identity is PEM-encoded certificate content, credentials PEM-encoded private key - new InMemoryKeyManagersSupplier(crypto, identity).get(); - - if (keyManagers == null) { - throw new AuthorizationException("Could not setup any viable authentication method"); - } - - try { - final SSLContext sslContext = SSLContext.getInstance("TLS"); - sslContext.init(keyManagers, trustManager, new SecureRandom()); - return sslContext; - } catch (Exception e) { - throw propagate(e); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/FileBasedKeyManagersSupplier.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/FileBasedKeyManagersSupplier.java b/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/FileBasedKeyManagersSupplier.java deleted file mode 100644 index e388184..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/FileBasedKeyManagersSupplier.java +++ /dev/null @@ -1,64 +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.azurecompute.suppliers; - -import com.google.common.base.Supplier; -import java.io.File; -import java.io.FileInputStream; -import java.security.KeyStore; -import javax.net.ssl.KeyManager; -import javax.net.ssl.KeyManagerFactory; -import org.jclouds.util.Closeables2; - -import static com.google.common.base.Throwables.propagate; - -class FileBasedKeyManagersSupplier implements Supplier<KeyManager[]> { - - private final File pkcs12File; - - private final char[] credential; - - public FileBasedKeyManagersSupplier(final File pkcs12File, final char[] credential) { - this.pkcs12File = pkcs12File; - this.credential = credential; - } - - @Override - public KeyManager[] get() { - KeyManager[] keyManagers = null; - - FileInputStream stream = null; - try { - stream = new FileInputStream(pkcs12File); - - final KeyStore keyStore = KeyStore.getInstance("PKCS12"); - keyStore.load(stream, credential); - - final KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("SunX509"); - keyManagerFactory.init(keyStore, credential); - - keyManagers = keyManagerFactory.getKeyManagers(); - } catch (Exception e) { - propagate(e); - } finally { - Closeables2.closeQuietly(stream); - } - - return keyManagers; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/eb990020/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/InMemoryKeyManagersSupplier.java ---------------------------------------------------------------------- diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/InMemoryKeyManagersSupplier.java b/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/InMemoryKeyManagersSupplier.java deleted file mode 100644 index d95a928..0000000 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/suppliers/InMemoryKeyManagersSupplier.java +++ /dev/null @@ -1,138 +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.azurecompute.suppliers; - -import com.google.common.base.Charsets; -import com.google.common.base.Supplier; -import com.google.common.io.ByteSource; -import java.io.ByteArrayInputStream; -import java.net.Socket; -import java.security.Principal; -import java.security.PrivateKey; -import java.security.cert.Certificate; -import java.security.cert.CertificateFactory; -import java.security.cert.X509Certificate; -import java.security.spec.KeySpec; -import java.util.Collection; -import javax.net.ssl.KeyManager; -import javax.net.ssl.X509ExtendedKeyManager; -import org.jclouds.crypto.Crypto; -import org.jclouds.crypto.Pems; - -import static com.google.common.base.Throwables.propagate; - -class InMemoryKeyManagersSupplier implements Supplier<KeyManager[]> { - - private final Crypto crypto; - - private final String identity; - - public InMemoryKeyManagersSupplier(final Crypto crypto, final String identity) { - this.crypto = crypto; - this.identity = identity; - } - - @Override - public KeyManager[] get() { - KeyManager[] keyManagers = null; - - // split in private key and certs - final int privateKeyBeginIdx = identity.indexOf("-----BEGIN PRIVATE KEY"); - final int privateKeyEndIdx = identity.indexOf("-----END PRIVATE KEY"); - if (privateKeyBeginIdx != -1 && privateKeyEndIdx != -1) { - try { - final String pemPrivateKey = identity.substring(privateKeyBeginIdx, privateKeyEndIdx + 26); - - final StringBuilder pemCerts = new StringBuilder(); - int certsBeginIdx = 0; - do { - certsBeginIdx = identity.indexOf("-----BEGIN CERTIFICATE", certsBeginIdx); - if (certsBeginIdx >= 0) { - final int certsEndIdx = identity.indexOf("-----END CERTIFICATE", certsBeginIdx) + 26; - pemCerts.append(identity.substring(certsBeginIdx, certsEndIdx)); - certsBeginIdx = certsEndIdx; - } - } while (certsBeginIdx != -1); - - // parse private key - final KeySpec keySpec = Pems.privateKeySpec(ByteSource.wrap(pemPrivateKey.getBytes(Charsets.UTF_8))); - final PrivateKey privateKey = crypto.rsaKeyFactory().generatePrivate(keySpec); - - // parse cert(s) - @SuppressWarnings("unchecked") - final Collection<Certificate> certs = (Collection<Certificate>) CertificateFactory.getInstance("X.509"). - generateCertificates(new ByteArrayInputStream(pemCerts.toString().getBytes(Charsets.UTF_8))); - - if (certs.isEmpty()) { - throw new IllegalStateException("Could not find any valid certificate"); - } - - final X509Certificate certificate = (X509Certificate) certs.iterator().next(); - - keyManagers = new KeyManager[]{new InMemoryKeyManager(certificate, privateKey)}; - } catch (Exception e) { - propagate(e); - } - } - - return keyManagers; - } - - private static class InMemoryKeyManager extends X509ExtendedKeyManager { - - private static final String DEFAULT_ALIAS = "azure"; - - private final X509Certificate certificate; - - private final PrivateKey privateKey; - - public InMemoryKeyManager(final X509Certificate certificate, final PrivateKey privateKey) { - this.certificate = certificate; - this.privateKey = privateKey; - } - - @Override - public String chooseClientAlias(final String[] keyType, final Principal[] issuers, final Socket socket) { - return DEFAULT_ALIAS; - } - - @Override - public String chooseServerAlias(final String keyType, final Principal[] issuers, final Socket socket) { - return DEFAULT_ALIAS; - } - - @Override - public X509Certificate[] getCertificateChain(final String alias) { - return new X509Certificate[]{certificate}; - } - - @Override - public String[] getClientAliases(final String keyType, final Principal[] issuers) { - return new String[]{DEFAULT_ALIAS}; - } - - @Override - public PrivateKey getPrivateKey(final String alias) { - return privateKey; - } - - @Override - public String[] getServerAliases(final String keyType, final Principal[] issuers) { - return new String[]{DEFAULT_ALIAS}; - } - } -}
