http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/LoadBalancerApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/LoadBalancerApi.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/LoadBalancerApi.java new file mode 100644 index 0000000..f91c405 --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/LoadBalancerApi.java @@ -0,0 +1,247 @@ +/* + * 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.cloudstack.features; + +import java.util.Set; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.cloudstack.domain.LoadBalancerRule; +import org.jclouds.cloudstack.domain.LoadBalancerRule.Algorithm; +import org.jclouds.cloudstack.domain.VirtualMachine; +import org.jclouds.cloudstack.filters.AuthenticationFilter; +import org.jclouds.cloudstack.options.CreateLoadBalancerRuleOptions; +import org.jclouds.cloudstack.options.ListLoadBalancerRulesOptions; +import org.jclouds.cloudstack.options.UpdateLoadBalancerRuleOptions; +import org.jclouds.functions.JoinOnComma; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.OnlyElement; +import org.jclouds.rest.annotations.ParamParser; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; + +/** + * Provides synchronous access to cloudstack via their REST API. + * <p/> + * + * @see <a href="http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html" /> + */ +@RequestFilters(AuthenticationFilter.class) +@QueryParams(keys = "response", values = "json") +public interface LoadBalancerApi { + + /** + * List the load balancer rules + * + * @param options + * if present, how to constrain the list. + * @return load balancer rules matching query, or empty set, if no load + * balancer rules are found + */ + @Named("listLoadBalancerRules") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listLoadBalancerRules", "true" }) + @SelectJson("loadbalancerrule") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(EmptySetOnNotFoundOr404.class) + Set<LoadBalancerRule> listLoadBalancerRules(ListLoadBalancerRulesOptions... options); + + /** + * get a specific LoadBalancerRule by id + * + * @param id + * LoadBalancerRule to get + * @return LoadBalancerRule or null if not found + */ + @Named("listLoadBalancerRules") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listLoadBalancerRules", "true" }) + @SelectJson("loadbalancerrule") + @OnlyElement + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + LoadBalancerRule getLoadBalancerRule(@QueryParam("id") String id); + + /** + * Creates a load balancer rule. + * + * @param publicIPId + * the public port from where the network traffic will be load + * balanced from + * @param algorithm + * load balancer algorithm (source, roundrobin, leastconn) + * @param name + * name of the load balancer rule + * @param privatePort + * the private port of the private ip address/virtual machine where + * the network traffic will be load balanced to + * @param publicPort + * public ip address id from where the network traffic will be load + * balanced from + * @param options optional call arguments + * @return newly created rule + */ + @Named("createLoadBalancerRule") + @GET + @QueryParams(keys = "command", values = "createLoadBalancerRule") + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + String createLoadBalancerRuleForPublicIP(@QueryParam("publicipid") String publicIPId, + @QueryParam("algorithm") Algorithm algorithm, @QueryParam("name") String name, + @QueryParam("privateport") int privatePort, @QueryParam("publicport") int publicPort, + CreateLoadBalancerRuleOptions... options); + + /** + * Update a load balancer rule. + * + * @param id + * rule id + * @param options + * optional arguments + * @return updated rule + */ + @Named("updateLoadBalancerRule") + @GET + @QueryParams(keys = "command", values = "updateLoadBalancerRule") + @SelectJson("loadbalancerrule") + @OnlyElement + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + LoadBalancerRule updateLoadBalancerRule(@QueryParam("id") String id, UpdateLoadBalancerRuleOptions... options); + + /** + * + * deletes a loadbalancer rule + * + * @param id + * id of the rule to delete + * @return async job id of the job completing or null, if the load balancer + * rule was not found. + */ + @Named("deleteLoadBalancerRule") + @GET + @QueryParams(keys = "command", values = "deleteLoadBalancerRule") + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + String deleteLoadBalancerRule(@QueryParam("id") String id); + + /** + * Assigns virtual machine or a list of virtual machines to a load balancer + * rule. + * + * @param id + * the ID of the load balancer rule + * @param virtualMachineIds + * the list of IDs of the virtual machine that are being assigned + * to the load balancer rule + * @return job id related to the operation + */ + @Named("assignToLoadBalancerRule") + @GET + @QueryParams(keys = "command", values = "assignToLoadBalancerRule") + @Fallback(NullOnNotFoundOr404.class) + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + String assignVirtualMachinesToLoadBalancerRule(@QueryParam("id") String id, + @QueryParam("virtualmachineids") @ParamParser(JoinOnComma.class) Iterable<String> virtualMachineIds); + + /** + * Assigns virtual machine or a list of virtual machines to a load balancer + * rule. + * + * @param id + * the ID of the load balancer rule + * @param virtualMachineIds + * the list of IDs of the virtual machine that are being assigned + * to the load balancer rule + * @return job id related to the operation + */ + @Named("assignToLoadBalancerRule") + @GET + @QueryParams(keys = "command", values = "assignToLoadBalancerRule") + @Fallback(NullOnNotFoundOr404.class) + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + String assignVirtualMachinesToLoadBalancerRule(@QueryParam("id") String id, + @QueryParam("virtualmachineids") @ParamParser(JoinOnComma.class) String... virtualMachineIds); + + /** + * Removes a virtual machine or a list of virtual machines from a load + * balancer rule. + * + * @param id + * the ID of the load balancer rule + * @param virtualMachineIds + * the list of IDs of the virtual machine that are being removed + * from the load balancer rule + * @return job id related to the operation + */ + @Named("removeFromLoadBalancerRule") + @GET + @QueryParams(keys = "command", values = "removeFromLoadBalancerRule") + @Fallback(NullOnNotFoundOr404.class) + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + String removeVirtualMachinesFromLoadBalancerRule(@QueryParam("id") String id, + @QueryParam("virtualmachineids") @ParamParser(JoinOnComma.class) Iterable<String> virtualMachineIds); + + /** + * Removes a virtual machine or a list of virtual machines from a load + * balancer rule. + * + * @param id + * the ID of the load balancer rule + * @param virtualMachineIds + * the list of IDs of the virtual machine that are being removed + * from the load balancer rule + * @return job id related to the operation + */ + @Named("removeFromLoadBalancerRule") + @GET + @QueryParams(keys = "command", values = "removeFromLoadBalancerRule") + @Fallback(NullOnNotFoundOr404.class) + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + String removeVirtualMachinesFromLoadBalancerRule(@QueryParam("id") String id, + @QueryParam("virtualmachineids") @ParamParser(JoinOnComma.class) String... virtualMachineIds); + + /** + * List all virtual machine instances that are assigned to a load balancer + * rule. + * + * @param id + * id of the rule + * @return VirtualMachines matching query, or empty set, if no + * VirtualMachines are assigned + */ + @Named("listLoadBalancerRuleInstances") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listLoadBalancerRuleInstances", "true" }) + @SelectJson("loadbalancerruleinstance") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(EmptySetOnNotFoundOr404.class) + Set<VirtualMachine> listVirtualMachinesAssignedToLoadBalancerRule(@QueryParam("id") String id); + +}
http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/NATApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/NATApi.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/NATApi.java new file mode 100644 index 0000000..015c2ba --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/NATApi.java @@ -0,0 +1,169 @@ +/* + * 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.cloudstack.features; + +import java.util.Set; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.cloudstack.domain.AsyncCreateResponse; +import org.jclouds.cloudstack.domain.IPForwardingRule; +import org.jclouds.cloudstack.filters.AuthenticationFilter; +import org.jclouds.cloudstack.options.CreateIPForwardingRuleOptions; +import org.jclouds.cloudstack.options.ListIPForwardingRulesOptions; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.OnlyElement; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.annotations.Unwrap; + +/** + * Provides synchronous access to cloudstack via their REST API. + * <p/> + * + * @see <a + * href="http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html" + * /> + */ +@RequestFilters(AuthenticationFilter.class) +@QueryParams(keys = "response", values = "json") +public interface NATApi { + + /** + * List the ip forwarding rules + * + * @param options + * if present, how to constrain the list. + * @return IPForwardingRules matching query, or empty set, if no + * IPForwardingRules are found + */ + @Named("listIpForwardingRules") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listIpForwardingRules", "true" }) + @SelectJson("ipforwardingrule") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(EmptySetOnNotFoundOr404.class) + Set<IPForwardingRule> listIPForwardingRules(ListIPForwardingRulesOptions... options); + + /** + * get a specific IPForwardingRule by id + * + * @param id + * IPForwardingRule to get + * @return IPForwardingRule or null if not found + */ + @Named("listIpForwardingRules") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listIpForwardingRules", "true" }) + @SelectJson("ipforwardingrule") + @OnlyElement + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + IPForwardingRule getIPForwardingRule(@QueryParam("id") String id); + + /** + * get a set of IPForwardingRules by ipaddress id + * + * @param id + * IPAddress of rule to get + * @return IPForwardingRule matching query or empty if not found + */ + @Named("listIpForwardingRules") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listIpForwardingRules", "true" }) + @SelectJson("ipforwardingrule") + @Consumes(MediaType.APPLICATION_JSON) + Set<IPForwardingRule> getIPForwardingRulesForIPAddress(@QueryParam("ipaddressid") String id); + + /** + * get a set of IPForwardingRules by virtual machine id + * + * @param id + * virtual machine of rule to get + * @return IPForwardingRule matching query or empty set if not found + */ + @Named("listIpForwardingRules") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listIpForwardingRules", "true" }) + @SelectJson("ipforwardingrule") + @Consumes(MediaType.APPLICATION_JSON) + Set<IPForwardingRule> getIPForwardingRulesForVirtualMachine(@QueryParam("virtualmachineid") String id); + + /** + * Creates an ip forwarding rule + * + * @param IPAddressId + * the public IP address id of the forwarding rule, already + * associated via associateIp + * @param protocol + * the protocol for the rule. Valid values are TCP or UDP. + * @param startPort + * the start port for the rule + * @return response used to track creation + */ + @Named("createIpForwardingRule") + @GET + @QueryParams(keys = "command", values = "createIpForwardingRule") + @Unwrap + @Consumes(MediaType.APPLICATION_JSON) + AsyncCreateResponse createIPForwardingRule(@QueryParam("ipaddressid") String IPAddressId, + @QueryParam("protocol") String protocol, @QueryParam("startport") int startPort, + CreateIPForwardingRuleOptions... options); + + @Named("enableStaticNat") + @GET + @QueryParams(keys = "command", values = "enableStaticNat") + @Consumes(MediaType.APPLICATION_JSON) + void enableStaticNATForVirtualMachine( + @QueryParam("virtualmachineid") String virtualMachineId, @QueryParam("ipaddressid") String IPAddressId); + + /** + * Deletes an ip forwarding rule + * + * @param id + * the id of the forwarding rule + */ + @Named("deleteIpForwardingRule") + @GET + @QueryParams(keys = "command", values = "deleteIpForwardingRule") + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + String deleteIPForwardingRule(@QueryParam("id") String id); + + /** + * Disables static rule for given ip address + * + * @param IPAddressId + * the public IP address id for which static nat feature is being + * disabled + */ + @Named("disableStaticNat") + @GET + @QueryParams(keys = "command", values = "disableStaticNat") + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + String disableStaticNATOnPublicIP(@QueryParam("ipaddressid") String IPAddressId); + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/NetworkApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/NetworkApi.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/NetworkApi.java new file mode 100644 index 0000000..9784b41 --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/NetworkApi.java @@ -0,0 +1,119 @@ +/* + * 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.cloudstack.features; + +import java.util.Set; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.cloudstack.domain.Network; +import org.jclouds.cloudstack.filters.AuthenticationFilter; +import org.jclouds.cloudstack.options.CreateNetworkOptions; +import org.jclouds.cloudstack.options.ListNetworksOptions; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.OnlyElement; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; + +/** + * Provides synchronous access to cloudstack via their REST API. + * <p/> + * + * @see <a href="http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html" /> + */ +@RequestFilters(AuthenticationFilter.class) +@QueryParams(keys = "response", values = "json") +public interface NetworkApi { + + /** + * Lists networks + * + * @param options + * if present, how to constrain the list. + * @return networks matching query, or empty set, if no networks are found + */ + @Named("listNetworks") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listNetworks", "true" }) + @SelectJson("network") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(EmptySetOnNotFoundOr404.class) + Set<Network> listNetworks(ListNetworksOptions... options); + + /** + * get a specific network by id + * + * @param id + * network to get + * @return network or null if not found + */ + @Named("listNetworks") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listNetworks", "true" }) + @SelectJson("network") + @OnlyElement + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + Network getNetwork(@QueryParam("id") String id); + + /** + * Creates a network + * + * @param zoneId + * the Zone ID for the Vlan ip range + * @param networkOfferingId + * the network offering id + * @param name + * the name of the network + * @param displayText + * the display text of the network + * @param options + * optional parameters + * @return newly created network + */ + @Named("createNetwork") + @GET + @QueryParams(keys = "command", values = "createNetwork") + @SelectJson("network") + @Consumes(MediaType.APPLICATION_JSON) + Network createNetworkInZone(@QueryParam("zoneid") String zoneId, + @QueryParam("networkofferingid") String networkOfferingId, @QueryParam("name") String name, + @QueryParam("displaytext") String displayText, CreateNetworkOptions... options); + + /** + * Deletes a network + * + * @param id + * the ID of the network + * @return job id related to destroying the network, or null if resource was + * not found + */ + @Named("deleteNetwork") + @GET + @QueryParams(keys = "command", values = "deleteNetwork") + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + String deleteNetwork(@QueryParam("id") String id); +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/OfferingApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/OfferingApi.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/OfferingApi.java new file mode 100644 index 0000000..4baf0f6 --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/OfferingApi.java @@ -0,0 +1,148 @@ +/* + * 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.cloudstack.features; + +import java.util.Set; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.cloudstack.domain.DiskOffering; +import org.jclouds.cloudstack.domain.NetworkOffering; +import org.jclouds.cloudstack.domain.ServiceOffering; +import org.jclouds.cloudstack.filters.AuthenticationFilter; +import org.jclouds.cloudstack.options.ListDiskOfferingsOptions; +import org.jclouds.cloudstack.options.ListNetworkOfferingsOptions; +import org.jclouds.cloudstack.options.ListServiceOfferingsOptions; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.OnlyElement; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; + +/** + * Provides synchronous access to cloudstack via their REST API. + * <p/> + * + * @see <a href="http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html" /> + */ +@RequestFilters(AuthenticationFilter.class) +@QueryParams(keys = "response", values = "json") +public interface OfferingApi { + + /** + * Lists service offerings + * + * @param options + * if present, how to constrain the list. + * @return service offerings matching query, or empty set, if no service + * offerings are found + */ + @Named("listServiceOfferings") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listServiceOfferings", "true" }) + @SelectJson("serviceoffering") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(EmptySetOnNotFoundOr404.class) + Set<ServiceOffering> listServiceOfferings(ListServiceOfferingsOptions... options); + + /** + * get a specific service offering by id + * + * @param id + * offering to get + * @return service offering or null if not found + */ + @Named("listServiceOfferings") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listServiceOfferings", "true" }) + @SelectJson("serviceoffering") + @OnlyElement + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + ServiceOffering getServiceOffering(@QueryParam("id") String id); + + /** + * Lists disk offerings + * + * @param options + * if present, how to constrain the list. + * @return disk offerings matching query, or empty set, if no disk offerings + * are found + */ + @Named("listDiskOfferings") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listDiskOfferings", "true" }) + @SelectJson("diskoffering") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(EmptySetOnNotFoundOr404.class) + Set<DiskOffering> listDiskOfferings(ListDiskOfferingsOptions... options); + + /** + * get a specific disk offering by id + * + * @param id + * offering to get + * @return disk offering or null if not found + */ + @Named("listDiskOfferings") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listDiskOfferings", "true" }) + @SelectJson("diskoffering") + @OnlyElement + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + DiskOffering getDiskOffering(@QueryParam("id") String id); + + /** + * Lists service offerings + * + * @param options + * if present, how to constrain the list. + * @return service offerings matching query, or empty set, if no service + * offerings are found + */ + @Named("listNetworkOfferings") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listNetworkOfferings", "true" }) + @SelectJson("networkoffering") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(EmptySetOnNotFoundOr404.class) + Set<NetworkOffering> listNetworkOfferings(ListNetworkOfferingsOptions... options); + + /** + * get a specific service offering by id + * + * @param id + * offering to get + * @return service offering or null if not found + */ + @Named("listNetworkOfferings") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listNetworkOfferings", "true" }) + @SelectJson("networkoffering") + @OnlyElement + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + NetworkOffering getNetworkOffering(@QueryParam("id") String id); + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/ProjectApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/ProjectApi.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/ProjectApi.java new file mode 100644 index 0000000..f426cdf --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/ProjectApi.java @@ -0,0 +1,76 @@ +/* + * 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.cloudstack.features; + +import java.util.Set; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.cloudstack.domain.Project; +import org.jclouds.cloudstack.filters.AuthenticationFilter; +import org.jclouds.cloudstack.options.ListProjectsOptions; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.OnlyElement; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; + +/** + * Provides synchronous access to CloudStack project features. + * + * @see <a + * href="http://download.cloud.com/releases/3.0.6/api_3.0.6/TOC_Root_Admin.html" + * /> + */ +@RequestFilters(AuthenticationFilter.class) +@QueryParams(keys = "response", values = "json") +public interface ProjectApi { + /** + * Lists the projects this account has access to. + * + * @param options if present, how to constrain the list + */ + @Named("listProjects") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listProjects", "true" }) + @SelectJson("project") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(EmptySetOnNotFoundOr404.class) + Set<Project> listProjects(ListProjectsOptions... options); + + /** + * gets a specific Project by id + * + * @param id + * Project to get + * @return Project or null if not found */ + @Named("listProjects") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listProjects", "true" }) + @SelectJson("project") + @OnlyElement + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + Project getProject(@QueryParam("id") String id); + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/SSHKeyPairApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/SSHKeyPairApi.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/SSHKeyPairApi.java new file mode 100644 index 0000000..6ab8e53 --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/SSHKeyPairApi.java @@ -0,0 +1,118 @@ +/* + * 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.cloudstack.features; + +import java.util.Set; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; +import org.jclouds.cloudstack.domain.SshKeyPair; +import org.jclouds.cloudstack.filters.AuthenticationFilter; +import org.jclouds.cloudstack.options.ListSSHKeyPairsOptions; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.OnlyElement; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; + +/** + * Provides synchronous access to CloudStack SSHKeyPair features. + * + * @see <a + * href="http://download.cloud.com/releases/2.2.0/api_2.2.8/TOC_User.html" + * /> + */ +@RequestFilters(AuthenticationFilter.class) +@QueryParams(keys = "response", values = "json") +public interface SSHKeyPairApi { + /** + * Returns a list of {@link SshKeyPair}s registered by current user. + * + * @param options if present, how to constrain the list + * @return Set of {@link SshKeyPair}s matching the current constrains or + * empty set if no SshKeyPairs found. + */ + @Named("listSSHKeyPairs") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listSSHKeyPairs", "true" }) + @SelectJson("sshkeypair") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(EmptySetOnNotFoundOr404.class) + Set<SshKeyPair> listSSHKeyPairs(ListSSHKeyPairsOptions... options); + + /** + * Registers a {@link SshKeyPair} with the given name and public kay material. + * + * @param name of the keypair + * @param publicKey Public key material of the keypair + * @return Created SshKeyPair. + */ + @Named("registerSSHKeyPair") + @GET + @QueryParams(keys = "command", values = "registerSSHKeyPair") + @SelectJson("keypair") + @Consumes(MediaType.APPLICATION_JSON) + SshKeyPair registerSSHKeyPair(@QueryParam("name") String name, @QueryParam("publickey") String publicKey); + + /** + * Creates a {@link SshKeyPair} with specified name. + * + * @param name of the SshKeyPair. + * @return Created SshKeyPair. + */ + @Named("createSSHKeyPair") + @GET + @QueryParams(keys = "command", values = "createSSHKeyPair") + @SelectJson("keypair") + @Consumes(MediaType.APPLICATION_JSON) + SshKeyPair createSSHKeyPair(@QueryParam("name") String name); + + /** + * Retrieves the {@link SSHKeyPairApi} with given name. + * + * @param name name of the key pair + * @return SSH Key pair or null if not found. + */ + @Named("listSSHKeyPairs") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listSSHKeyPairs", "true" }) + @SelectJson("sshkeypair") + @OnlyElement() + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + SshKeyPair getSSHKeyPair(@QueryParam("name") String name); + + /** + * Deletes the {@link SSHKeyPairApi} with given name. + * + * @param name name of the key pair + * @return + */ + @Named("deleteSSHKeyPair") + @GET + @QueryParams(keys = "command", values = "deleteSSHKeyPair") + @Fallback(VoidOnNotFoundOr404.class) + void deleteSSHKeyPair(@QueryParam("name") String name); + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/SecurityGroupApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/SecurityGroupApi.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/SecurityGroupApi.java new file mode 100644 index 0000000..3f53b8f --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/SecurityGroupApi.java @@ -0,0 +1,245 @@ +/* + * 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.cloudstack.features; + +import java.util.Set; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; +import org.jclouds.cloudstack.binders.BindAccountSecurityGroupPairsToIndexedQueryParams; +import org.jclouds.cloudstack.binders.BindCIDRsToCommaDelimitedQueryParam; +import org.jclouds.cloudstack.domain.SecurityGroup; +import org.jclouds.cloudstack.filters.AuthenticationFilter; +import org.jclouds.cloudstack.options.AccountInDomainOptions; +import org.jclouds.cloudstack.options.ListSecurityGroupsOptions; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.OnlyElement; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; + +import com.google.common.collect.Multimap; +/** + * Provides synchronous access to cloudstack via their REST API. + * <p/> + * + * @see <a href="http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html" /> + */ +@RequestFilters(AuthenticationFilter.class) +@QueryParams(keys = "response", values = "json") +public interface SecurityGroupApi { + + /** + * Lists security groups + * + * @param options + * if present, how to constrain the list. + * @return security groups matching query, or empty set, if no security + * groups are found + */ + @Named("listSecurityGroups") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listSecurityGroups", "true" }) + @SelectJson("securitygroup") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(EmptySetOnNotFoundOr404.class) + Set<SecurityGroup> listSecurityGroups(ListSecurityGroupsOptions... options); + + /** + * get a specific security group by id + * + * @param id + * group to get + * @return security group or null if not found + */ + @Named("listSecurityGroups") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listSecurityGroups", "true" }) + @SelectJson("securitygroup") + @OnlyElement + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + SecurityGroup getSecurityGroup(@QueryParam("id") String id); + + /** + * get a specific security group by name + * + * @param securityGroupName + * group to get + * @return security group or null if not found + */ + @Named("listSecurityGroups") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listSecurityGroups", "true" }) + @SelectJson("securitygroup") + @OnlyElement + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + SecurityGroup getSecurityGroupByName(@QueryParam("securitygroupname") String securityGroupName); + + /** + * Creates a security group + * + * @param name + * name of the security group + * @return security group + */ + @Named("createSecurityGroup") + @GET + @QueryParams(keys = "command", values = "createSecurityGroup") + @SelectJson("securitygroup") + @Consumes(MediaType.APPLICATION_JSON) + SecurityGroup createSecurityGroup(@QueryParam("name") String name); + + /** + * Authorizes a particular TCP or UDP ingress rule for this security group + * + * @param securityGroupId + * The ID of the security group + * @param protocol + * tcp or udp + * @param startPort + * start port for this ingress rule + * @param endPort + * end port for this ingress rule + * @param cidrList + * the cidr list associated + * @return response relating to the creation of this ingress rule + */ + @Named("authorizeSecurityGroupIngress") + @GET + @QueryParams(keys = "command", values = "authorizeSecurityGroupIngress") + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + String authorizeIngressPortsToCIDRs(@QueryParam("securitygroupid") String securityGroupId, + @QueryParam("protocol") String protocol, @QueryParam("startport") int startPort, + @QueryParam("endport") int endPort, + @BinderParam(BindCIDRsToCommaDelimitedQueryParam.class) Iterable<String> cidrList, + AccountInDomainOptions... options); + + /** + * Authorizes a particular TCP or UDP ingress rule for this security group + * + * @param securityGroupId + * The ID of the security group + * @param protocol + * tcp or udp + * @param startPort + * start port for this ingress rule + * @param endPort + * end port for this ingress rule + * @param accountToGroup + * mapping of account names to security groups you wish to + * authorize + * @return response relating to the creation of this ingress rule + */ + @Named("authorizeSecurityGroupIngress") + @GET + @QueryParams(keys = "command", values = "authorizeSecurityGroupIngress") + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + String authorizeIngressPortsToSecurityGroups(@QueryParam("securitygroupid") String securityGroupId, + @QueryParam("protocol") String protocol, @QueryParam("startport") int startPort, + @QueryParam("endport") int endPort, + @BinderParam(BindAccountSecurityGroupPairsToIndexedQueryParams.class) Multimap<String, String> accountToGroup, + AccountInDomainOptions... options); + + /** + * Authorizes a particular ICMP ingress rule for this security group + * + * @param securityGroupId + * The ID of the security group + * @param ICMPCode + * type of the icmp message being sent + * @param ICMPType + * error code for this icmp message + * @param cidrList + * the cidr list associated + * @return response relating to the creation of this ingress rule + */ + @Named("authorizeSecurityGroupIngress") + @GET + @QueryParams(keys = { "command", "protocol" }, values = { "authorizeSecurityGroupIngress", "ICMP" }) + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + String authorizeIngressICMPToCIDRs(@QueryParam("securitygroupid") String securityGroupId, + @QueryParam("icmpcode") int ICMPCode, @QueryParam("icmptype") int ICMPType, + @BinderParam(BindCIDRsToCommaDelimitedQueryParam.class) Iterable<String> cidrList, + AccountInDomainOptions... options); + + /** + * Authorizes a particular ICMP ingress rule for this security group + * + * @param securityGroupId + * The ID of the security group + * @param ICMPCode + * type of the icmp message being sent + * @param ICMPType + * error code for this icmp message + * @param accountToGroup + * mapping of account names to security groups you wish to + * authorize + * @return response relating to the creation of this ingress rule + */ + @Named("authorizeSecurityGroupIngress") + @GET + @QueryParams(keys = { "command", "protocol" }, values = { "authorizeSecurityGroupIngress", "ICMP" }) + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + String authorizeIngressICMPToSecurityGroups(@QueryParam("securitygroupid") String securityGroupId, + @QueryParam("icmpcode") int ICMPCode, @QueryParam("icmptype") int ICMPType, + @BinderParam(BindAccountSecurityGroupPairsToIndexedQueryParams.class) Multimap<String, String> accountToGroup, + AccountInDomainOptions... options); + + /** + * Deletes a particular ingress rule from this security group + * + * @param id + * The ID of the ingress rule + * @param options + * scope of the rule. + */ + @Named("revokeSecurityGroupIngress") + @GET + @QueryParams(keys = "command", values = "revokeSecurityGroupIngress") + @Fallback(VoidOnNotFoundOr404.class) + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + String revokeIngressRule(@QueryParam("id") String id, AccountInDomainOptions... options); + + /** + * delete a specific security group by id + * + * @param id + * group to delete + */ + @Named("deleteSecurityGroup") + @GET + @QueryParams(keys = "command", values = "deleteSecurityGroup") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(VoidOnNotFoundOr404.class) + void deleteSecurityGroup(@QueryParam("id") String id); + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/SessionApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/SessionApi.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/SessionApi.java new file mode 100644 index 0000000..0dae2da --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/SessionApi.java @@ -0,0 +1,78 @@ +/* + * 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.cloudstack.features; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; +import org.jclouds.cloudstack.domain.LoginResponse; +import org.jclouds.cloudstack.functions.ParseLoginResponseFromHttpResponse; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.ResponseParser; + +/** + * Provides synchronous access to Cloudstack Sessions + * <p/> + * + * @see <a href="http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html" /> + */ +@QueryParams(keys = "response", values = "json") +public interface SessionApi { + + /** + * Logs a user into Cloudstack. A successful login attempt will generate a JSESSIONID + * cookie value that can be passed in subsequent Query command calls until the "logout" + * command has been issued or the session has expired. + * + * + * + * @param userName + * user account name + * @param domain + * domain name, if empty defaults to ROOT + * @param hashedPassword + * hashed password (by default MD5) + * @return + * login response with session key or null + */ + @Named("login") + @GET + @QueryParams(keys = "command", values = "login") + @ResponseParser(ParseLoginResponseFromHttpResponse.class) + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + LoginResponse loginUserInDomainWithHashOfPassword(@QueryParam("username") String userName, + @QueryParam("domain") String domain, @QueryParam("password") String hashedPassword); + + /** + * Logs out the user by invalidating the session key + * + * @param sessionKey + * user session key + */ + @Named("logout") + @GET + @QueryParams(keys = "command", values = "logout") + @Fallback(VoidOnNotFoundOr404.class) + void logoutUser(@QueryParam("sessionkey") String sessionKey); +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/SnapshotApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/SnapshotApi.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/SnapshotApi.java new file mode 100644 index 0000000..de93bbf --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/SnapshotApi.java @@ -0,0 +1,171 @@ +/* + * 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.cloudstack.features; + +import java.util.Set; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; +import org.jclouds.cloudstack.binders.BindIdListToCommaDelimitedQueryParam; +import org.jclouds.cloudstack.binders.BindSnapshotPolicyScheduleToQueryParam; +import org.jclouds.cloudstack.domain.AsyncCreateResponse; +import org.jclouds.cloudstack.domain.Snapshot; +import org.jclouds.cloudstack.domain.SnapshotPolicy; +import org.jclouds.cloudstack.domain.SnapshotPolicySchedule; +import org.jclouds.cloudstack.filters.AuthenticationFilter; +import org.jclouds.cloudstack.options.CreateSnapshotOptions; +import org.jclouds.cloudstack.options.ListSnapshotPoliciesOptions; +import org.jclouds.cloudstack.options.ListSnapshotsOptions; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.OnlyElement; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.annotations.Unwrap; + +/** + * Provides synchronous access to CloudStack Snapshot features. + * <p/> + * + * @see http://download.cloud.com/releases/2.2.0/api/TOC_User.html + */ +@RequestFilters(AuthenticationFilter.class) +@QueryParams(keys = "response", values = "json") +public interface SnapshotApi { + + /** + * Creates an instant snapshot of a volume. + * + * @param volumeId The ID of the disk volume + * @param options optional arguments + * @return an asynchronous job structure + */ + @Named("createSnapshot") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @QueryParams(keys = "command", values = "createSnapshot") + @Unwrap + AsyncCreateResponse createSnapshot(@QueryParam("volumeid") String volumeId, CreateSnapshotOptions... options); + + /** + * Lists all available snapshots for the account, matching the query described by the options. + * + * @param options optional arguments + * @return the snapshots matching the query + */ + @Named("listSnapshots") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @QueryParams(keys = { "command", "listAll" }, values = { "listSnapshots", "true" }) + @SelectJson("snapshot") + @Unwrap + @Fallback(EmptySetOnNotFoundOr404.class) + Set<Snapshot> listSnapshots(ListSnapshotsOptions... options); + + /** + * Gets a snapshot by its ID. + * + * @param id the snapshot ID + * @return the snapshot with the requested ID + */ + @Named("listSnapshots") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @QueryParams(keys = { "command", "listAll" }, values = { "listSnapshots", "true" }) + @SelectJson("snapshot") + @OnlyElement + @Fallback(NullOnNotFoundOr404.class) + Snapshot getSnapshot(@QueryParam("id") String id); + + /** + * Deletes a snapshot of a disk volume. + * + * @param id The ID of the snapshot + * @return an asynchronous job structure + */ + @Named("deleteSnapshot") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @QueryParams(keys = "command", values = "deleteSnapshot") + @Fallback(VoidOnNotFoundOr404.class) + void deleteSnapshot(@QueryParam("id") String id); + + /** + * Creates a snapshot policy for the account. + * + * @param schedule how to schedule snapshots + * @param numberToRetain maximum number of snapshots to retain + * @param timezone Specifies a timezone for this command. For more information on the timezone parameter, see Time Zone Format. + * @param volumeId the ID of the disk volume + * @return the newly-created snapshot policy + */ + @Named("createSnapshotPolicy") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Unwrap + @QueryParams(keys = "command", values = "createSnapshotPolicy") + SnapshotPolicy createSnapshotPolicy(@BinderParam(BindSnapshotPolicyScheduleToQueryParam.class) SnapshotPolicySchedule schedule, @QueryParam("maxsnaps") String numberToRetain, @QueryParam("timezone") String timezone, @QueryParam("volumeid") String volumeId); + + /** + * Deletes a snapshot policy for the account. + * + * @param id The ID of the snapshot policy + * @return + */ + @Named("deleteSnapshotPolicies") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @QueryParams(keys = "command", values = "deleteSnapshotPolicies") + @Fallback(VoidOnNotFoundOr404.class) + void deleteSnapshotPolicy(@QueryParam("id") String id); + + /** + * Deletes snapshot policies for the account. + * + * @param id IDs of snapshot policies + * @return + */ + @Named("deleteSnapshotPolicies") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @QueryParams(keys = "command", values = "deleteSnapshotPolicies") + @Fallback(VoidOnNotFoundOr404.class) + void deleteSnapshotPolicies(@BinderParam(BindIdListToCommaDelimitedQueryParam.class) Iterable<String> id); + + /** + * Lists snapshot policies. + * + * @param volumeId the ID of the disk volume + * @param options optional arguments + * @return the snapshot policies matching the query + */ + @Named("listSnapshotPolicies") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @QueryParams(keys = { "command", "listAll" }, values = { "listSnapshotPolicies", "true" }) + @Unwrap + @Fallback(EmptySetOnNotFoundOr404.class) + Set<SnapshotPolicy> listSnapshotPolicies(@QueryParam("volumeid") String volumeId, ListSnapshotPoliciesOptions... options); +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/TemplateApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/TemplateApi.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/TemplateApi.java new file mode 100644 index 0000000..7a3d490 --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/TemplateApi.java @@ -0,0 +1,294 @@ +/* + * 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.cloudstack.features; + +import java.util.Set; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.cloudstack.binders.BindTemplateMetadataToQueryParams; +import org.jclouds.cloudstack.domain.AsyncCreateResponse; +import org.jclouds.cloudstack.domain.ExtractMode; +import org.jclouds.cloudstack.domain.Template; +import org.jclouds.cloudstack.domain.TemplateMetadata; +import org.jclouds.cloudstack.domain.TemplatePermission; +import org.jclouds.cloudstack.filters.AuthenticationFilter; +import org.jclouds.cloudstack.options.AccountInDomainOptions; +import org.jclouds.cloudstack.options.CreateTemplateOptions; +import org.jclouds.cloudstack.options.DeleteTemplateOptions; +import org.jclouds.cloudstack.options.ExtractTemplateOptions; +import org.jclouds.cloudstack.options.ListTemplatesOptions; +import org.jclouds.cloudstack.options.RegisterTemplateOptions; +import org.jclouds.cloudstack.options.UpdateTemplateOptions; +import org.jclouds.cloudstack.options.UpdateTemplatePermissionsOptions; +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.OnlyElement; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.annotations.Unwrap; + +/** + * Provides synchronous access to cloudstack via their REST API. + * <p/> + * + * @see <a + * href="http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html" + * /> + */ +@RequestFilters(AuthenticationFilter.class) +@QueryParams(keys = "response", values = "json") +public interface TemplateApi { + + /** + * Creates a template of a virtual machine. The virtual machine must be in a + * STOPPED state. A template created from this command is automatically + * designated as a private template visible to the account that created it. + * + * @see http + * ://download.cloud.com/releases/2.2.0/api_2.2.8/user/createTemplate + * .html + * @param templateMetadata + * overall description of the template + * @param options + * optional arguments + * @return an asynchronous job response + */ + @Named("createTemplate") + @GET + @QueryParams(keys = "command", values = "createTemplate") + @Unwrap + @Consumes(MediaType.APPLICATION_JSON) + AsyncCreateResponse createTemplate( + @BinderParam(BindTemplateMetadataToQueryParams.class) TemplateMetadata templateMetadata, + CreateTemplateOptions... options); + + /** + * Registers an existing template into the Cloud.com cloud. + * + * @see http + * ://download.cloud.com/releases/2.2.0/api_2.2.8/user/registerTemplate + * .html + * @param templateMetadata + * overall description of the template + * @param format + * the format for the template. Possible values include QCOW2, RAW, + * and VHD. + * + * @param url + * the URL of where the template is hosted. Possible URL include + * http:// and https:// + * @param zoneId + * the ID of the zone the template is to be hosted on + * @param options + * optional arguments + * @return data about the newly-registered template + */ + @Named("registerTemplate") + @GET + @QueryParams(keys = "command", values = "registerTemplate") + @SelectJson("template") + @Consumes(MediaType.APPLICATION_JSON) + Set<Template> registerTemplate( + @BinderParam(BindTemplateMetadataToQueryParams.class) TemplateMetadata templateMetadata, + @QueryParam("format") String format, @QueryParam("hypervisor") String hypervisor, + @QueryParam("url") String url, @QueryParam("zoneid") String zoneId, RegisterTemplateOptions... options); + + /** + * Updates attributes of a template. + * + * @see http + * ://download.cloud.com/releases/2.2.0/api_2.2.8/user/updateTemplate + * .html + * @param id + * the ID of the image file + * @param options + * optional arguments + * @return updated data about the template + */ + @Named("updateTemplate") + @GET + @QueryParams(keys = "command", values = "updateTemplate") + @SelectJson("template") + @Consumes(MediaType.APPLICATION_JSON) + Template updateTemplate(@QueryParam("id") String id, UpdateTemplateOptions... options); + + /** + * Copies a template from one zone to another. + * + * @see http + * ://download.cloud.com/releases/2.2.0/api_2.2.8/user/copyTemplate.html + * @param id + * Template ID. + * @param sourceZoneId + * ID of the zone the template is currently hosted on. + * @param destZoneId + * ID of the zone the template is being copied to. + * @return an asynchronous job response + */ + @Named("copyTemplate") + @GET + @QueryParams(keys = "command", values = "copyTemplate") + @Unwrap + @Consumes(MediaType.APPLICATION_JSON) + AsyncCreateResponse copyTemplateToZone(@QueryParam("id") String id, + @QueryParam("sourcezoneid") String sourceZoneId, @QueryParam("destzoneid") String destZoneId); + + /** + * Deletes a template from the system. All virtual machines using the deleted + * template will not be affected. + * + * @see http + * ://download.cloud.com/releases/2.2.0/api_2.2.8/user/deleteTemplate + * .html + * @param id + * the ID of the template + * @param options + * optional arguments + */ + @Named("deleteTemplate") + @GET + @QueryParams(keys = "command", values = "deleteTemplate") + @Unwrap + @Consumes(MediaType.APPLICATION_JSON) + AsyncCreateResponse deleteTemplate(@QueryParam("id") String id, DeleteTemplateOptions... options); + + /** + * List all executable templates. + * + * @see http + * ://download.cloud.com/releases/2.2.0/api_2.2.8/user/listTemplates. + * html + * @return all executable templates, or empty set, if no templates are found + */ + @Named("listTemplates") + @GET + @QueryParams(keys = { "command", "listAll", "templatefilter" }, values = { "listTemplates", "true", "executable" }) + @SelectJson("template") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(EmptySetOnNotFoundOr404.class) + Set<Template> listTemplates(); + + /** + * List all public, private, and privileged templates. + * + * @see http + * ://download.cloud.com/releases/2.2.0/api_2.2.8/user/listTemplates. + * html + * @param options + * if present, how to constrain the list, defaults to all + * executable templates + * @return templates matching query, or empty set, if no templates are found + * @see TemplateFilter + */ + @Named("listTemplates") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listTemplates", "true" }) + @SelectJson("template") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(EmptySetOnNotFoundOr404.class) + Set<Template> listTemplates(ListTemplatesOptions options); + + /** + * get a specific template by id + * + * + * @param templateId + * @param zoneId + * zone template is defined in + * @return template or null if not found + */ + @Named("listTemplates") + @GET + // templatefilter required in at least 2.2.8 version + @QueryParams(keys = { "command", "listAll", "templatefilter" }, values = { "listTemplates", "true", "executable" }) + @SelectJson("template") + @OnlyElement + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + Template getTemplateInZone(@QueryParam("id") String templateId, @QueryParam("zoneid") String zoneId); + + /** + * Updates a template visibility permissions. A public template is visible to + * all accounts within the same domain. A private template is visible only to + * the owner of the template. A privileged template is a private template + * with account permissions added. Only accounts specified under the template + * permissions are visible to them. + * + * @see http://download.cloud.com/releases/2.2.0/api_2.2.8/user/ + * updateTemplatePermissions.html + * @param id + * the template ID + * @param options + * optional arguments + */ + @Named("updateTemplatePermissions") + @GET + @QueryParams(keys = "command", values = "updateTemplatePermissions") + void updateTemplatePermissions(@QueryParam("id") String id, + UpdateTemplatePermissionsOptions... options); + + /** + * List template visibility and all accounts that have permissions to view + * this template. + * + * @see http://download.cloud.com/releases/2.2.0/api_2.2.8/user/ + * listTemplatePermissions.html + * @param id + * the template ID + * @param options + * optional arguments + * @return the list of permissions that apply to the template + */ + @Named("listTemplatePermissions") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listTemplatePermissions", "true" }) + @Unwrap + @Consumes(MediaType.APPLICATION_JSON) + Set<TemplatePermission> listTemplatePermissions(@QueryParam("id") String id, + AccountInDomainOptions... options); + + /** + * + * @see http + * ://download.cloud.com/releases/2.2.0/api_2.2.8/user/extractTemplate + * .html + * @param id + * the ID of the template + * @param mode + * FIXME the mode of extraction - HTTP_DOWNLOAD or FTP_UPLOAD + * @param zoneId + * the ID of the zone where the ISO is originally located + * @param options + * optional arguments + * @return an asynchronous job response + */ + @Named("extractTemplate") + @GET + @QueryParams(keys = "command", values = "extractTemplate") + @Unwrap + @Consumes(MediaType.APPLICATION_JSON) + AsyncCreateResponse extractTemplate(@QueryParam("id") String id, + @QueryParam("mode") ExtractMode mode, @QueryParam("zoneid") String zoneId, ExtractTemplateOptions... options); +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/VMGroupApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/VMGroupApi.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/VMGroupApi.java new file mode 100644 index 0000000..bf2be0d --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/VMGroupApi.java @@ -0,0 +1,114 @@ +/* + * 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.cloudstack.features; + +import java.util.Set; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; +import org.jclouds.cloudstack.domain.VMGroup; +import org.jclouds.cloudstack.filters.AuthenticationFilter; +import org.jclouds.cloudstack.options.CreateVMGroupOptions; +import org.jclouds.cloudstack.options.ListVMGroupsOptions; +import org.jclouds.cloudstack.options.UpdateVMGroupOptions; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.OnlyElement; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; + +/** + * Provides synchronous access to CloudStack VM group features. + * <p/> + * + * @see <a href="http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html" /> + */ +@RequestFilters(AuthenticationFilter.class) +@QueryParams(keys = "response", values = "json") +public interface VMGroupApi { + /** + * Lists VM groups + * + * @param options if present, how to constrain the list. + * @return VM groups matching query, or empty set, if no zones are found + */ + @Named("listInstanceGroups") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listInstanceGroups", "true" }) + @SelectJson("instancegroup") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(EmptySetOnNotFoundOr404.class) + Set<VMGroup> listInstanceGroups(ListVMGroupsOptions... options); + + /** + * @see VMGroupApi#getInstanceGroup + */ + @Named("listInstanceGroups") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listInstanceGroups", "true" }) + @SelectJson("instancegroup") + @OnlyElement + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + VMGroup getInstanceGroup(@QueryParam("id") String id); + + /** + * Creates a VM group + * + * @param name the name of the VM group + * @param options optional parameters + * @return the new VMGroup + */ + @Named("createInstanceGroup") + @GET + @QueryParams(keys = "command", values = "createInstanceGroup") + @SelectJson("instancegroup") + @Consumes(MediaType.APPLICATION_JSON) + VMGroup createInstanceGroup(@QueryParam("name") String name, CreateVMGroupOptions... options); + + /** + * Modify a VM group + * + * @param name the new name of the group + * @return the modified VMGroup + */ + @Named("updateInstanceGroup") + @GET + @QueryParams(keys = "command", values = "updateInstanceGroup") + @SelectJson("instancegroup") + @Consumes(MediaType.APPLICATION_JSON) + VMGroup updateInstanceGroup(@QueryParam("id") String id, UpdateVMGroupOptions... options); + + /** + * Delete a VM group + * + * @param id the ID of the VM group + * @return a future with a void data type + */ + @Named("deleteInstanceGroup") + @GET + @QueryParams(keys = "command", values = "deleteInstanceGroup") + @Fallback(VoidOnNotFoundOr404.class) + void deleteInstanceGroup(@QueryParam("id") String id); +} http://git-wip-us.apache.org/repos/asf/stratos/blob/86fd5cf2/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/VirtualMachineApi.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/VirtualMachineApi.java b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/VirtualMachineApi.java new file mode 100644 index 0000000..413bfc5 --- /dev/null +++ b/dependencies/jclouds/apis/cloudstack/1.8.0-stratos/src/main/java/org/jclouds/cloudstack/features/VirtualMachineApi.java @@ -0,0 +1,258 @@ +/* + * 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.cloudstack.features; + +import java.util.Set; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.cloudstack.domain.AsyncCreateResponse; +import org.jclouds.cloudstack.domain.VirtualMachine; +import org.jclouds.cloudstack.filters.AuthenticationFilter; +import org.jclouds.cloudstack.options.AssignVirtualMachineOptions; +import org.jclouds.cloudstack.options.DeployVirtualMachineOptions; +import org.jclouds.cloudstack.options.ListVirtualMachinesOptions; +import org.jclouds.cloudstack.options.StopVirtualMachineOptions; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.OnlyElement; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; + +/** + * Provides synchronous access to cloudstack via their REST API. + * <p/> + * + * @see <a href="http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html" /> + */ +@RequestFilters(AuthenticationFilter.class) +@QueryParams(keys = "response", values = "json") +public interface VirtualMachineApi { + + /** + * Lists VirtualMachines + * + * @param options + * if present, how to constrain the list. + * @return VirtualMachines matching query, or empty set, if no + * VirtualMachines are found + */ + @Named("listVirtualMachines") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listVirtualMachines", "true" }) + @SelectJson("virtualmachine") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(EmptySetOnNotFoundOr404.class) + Set<VirtualMachine> listVirtualMachines(ListVirtualMachinesOptions... options); + + /** + * get a specific VirtualMachine by id + * + * @param id + * VirtualMachine to get + * @return VirtualMachine or null if not found + */ + @Named("listVirtualMachines") + @GET + @QueryParams(keys = { "command", "listAll" }, values = { "listVirtualMachines", "true" }) + @SelectJson("virtualmachine") + @OnlyElement + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + VirtualMachine getVirtualMachine(@QueryParam("id") String id); + + /** + * Creates and automatically starts a virtual machine based on a service + * offering, disk offering, and template. + * + * @param zoneId + * availability zone for the virtual machine + * @param serviceOfferingId + * the ID of the service offering for the virtual machine + * @param templateId + * the ID of the template for the virtual machine + * + * @return virtual machine + */ + @Named("deployVirtualMachine") + @GET + @QueryParams(keys = "command", values = "deployVirtualMachine") + @SelectJson({ "deployvirtualmachine", "deployvirtualmachineresponse" }) + @Consumes(MediaType.APPLICATION_JSON) + AsyncCreateResponse deployVirtualMachineInZone(@QueryParam("zoneid") String zoneId, + @QueryParam("serviceofferingid") String serviceOfferingId, @QueryParam("templateid") String templateId, + DeployVirtualMachineOptions... options); + + /** + * Reboots a virtual machine. + * + * @param id + * The ID of the virtual machine + * @return job id related to destroying the VM + */ + @Named("rebootVirtualMachine") + @GET + @QueryParams(keys = "command", values = "rebootVirtualMachine") + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + String rebootVirtualMachine(@QueryParam("id") String id); + + /** + * Starts a virtual machine. + * + * @param id + * The ID of the virtual machine + * @return job id related to destroying the VM + */ + @Named("startVirtualMachine") + @GET + @QueryParams(keys = "command", values = "startVirtualMachine") + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + String startVirtualMachine(@QueryParam("id") String id); + + /** + * Stops a virtual machine. + * + * @param id + * The ID of the virtual machine + * @return job id related to destroying the VM + */ + @Named("stopVirtualMachine") + @GET + @QueryParams(keys = "command", values = "stopVirtualMachine") + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + String stopVirtualMachine(@QueryParam("id") String id); + + /** + * Stops a virtual machine. + * + * @param id + * The ID of the virtual machine + * @param options + * If present, whether to force stop. + * @return job id related to destroying the VM + */ + @GET + @QueryParams(keys = "command", values = "stopVirtualMachine") + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + String stopVirtualMachine(@QueryParam("id") String id, + StopVirtualMachineOptions options); + + /** + * Resets the password for virtual machine. The virtual machine must be in a + * "Stopped" state and the template must already support this feature for + * this command to take effect. + * + * @param id + * The ID of the virtual machine + * @return job id related to destroying the VM + */ + @Named("resetPasswordForVirtualMachine") + @GET + @QueryParams(keys = "command", values = "resetPasswordForVirtualMachine") + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + String resetPasswordForVirtualMachine(@QueryParam("id") String id); + + /** + * Return an encrypted password for the virtual machine. The command + * is asynchronous. + * + * @param id + * the ID of the virtual machine + * @return encrypted password + */ + @Named("getVMPassword") + @GET + @QueryParams(keys = "command", values = "getVMPassword") + @SelectJson("encryptedpassword") + @Consumes(MediaType.APPLICATION_JSON) + String getEncryptedPasswordForVirtualMachine(@QueryParam("id") String id); + + /** + * Changes the service offering for a virtual machine. The virtual machine + * must be in a "Stopped" state for this command to take effect. + * + * @param id + * The ID of the virtual machine + * @return job id related to destroying the VM + */ + @Named("changeServiceForVirtualMachine") + @GET + @QueryParams(keys = "command", values = "changeServiceForVirtualMachine") + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + String changeServiceForVirtualMachine(@QueryParam("id") String id); + + /** + * Updates parameters of a virtual machine. + * + * @param id + * The ID of the virtual machine + * @return job id related to destroying the VM + */ + @Named("updateVirtualMachine") + @GET + @QueryParams(keys = "command", values = "updateVirtualMachine") + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + String updateVirtualMachine(@QueryParam("id") String id); + + /** + * Destroys a virtual machine. Once destroyed, only the administrator can + * recover it. + * + * @param id + * vm to destroy + * @return job id related to destroying the VM, or null if resource was not + * found + */ + @Named("destroyVirtualMachine") + @GET + @QueryParams(keys = "command", values = "destroyVirtualMachine") + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + String destroyVirtualMachine(@QueryParam("id") String id); + + /** + * Re-assign a virtual machine to a different account/domain. + * + * @param virtualMachineId + * VirtualMachine to re-assign + * @param options + * AssignVirtualMachineOptions specifying account and domain to transfer to, and optional network and security group IDs. + * @return VirtualMachine or null if not found + */ + @Named("assignVirtualMachine") + @GET + @QueryParams(keys = "command", values = "assignVirtualMachine") + @SelectJson("jobid") + @Consumes(MediaType.APPLICATION_JSON) + VirtualMachine assignVirtualMachine(@QueryParam("virtualmachineid") String virtualMachineId, + AssignVirtualMachineOptions... options); + +}
