Package com.abiquo.model.rest

Examples of com.abiquo.model.rest.RESTLink


      // Add the given nics in the appropriate order
      int i = 0;
      if (ips != null) {
         for (i = 0; i < ips.size(); i++) {
            RESTLink source = LinkUtils.getSelfLink(ips.get(i).unwrap());
            RESTLink link = new RESTLink("nic" + i, source.getHref());
            link.setType(ips.get(i).unwrap().getBaseMediaType());
            target.addLink(link);
         }
      }

      // Add unmanaged network references, if given
      if (unmanagedNetworks != null) {
         for (UnmanagedNetwork unmanaged : unmanagedNetworks) {
            RESTLink source = checkNotNull(unmanaged.unwrap().searchLink("ips"), ValidationErrors.MISSING_REQUIRED_LINK
                  + "ips");

            RESTLink link = new RESTLink("nic" + i, source.getHref());
            link.setType(UnmanagedIpDto.BASE_MEDIA_TYPE);
            target.addLink(link);
            i++;
         }
      }

      VirtualMachineTask task = update(true);
      if (gatewayNetwork == null) {
         return task;
      }

      // If there is a gateway network, we have to wait until the network
      // configuration links are
      // available
      if (task != null) {
         VirtualMachineState originalState = target.getState();
         VirtualMachineMonitor monitor = context.utils().injector().getInstance(MonitoringService.class)
               .getVirtualMachineMonitor();
         monitor.awaitState(originalState, this);
      }

      // Set the new network configuration

      // Refresh virtual machine, to get the new configuration links
      refresh();

      VMNetworkConfigurationsDto configs = context.getApi().getCloudApi().listNetworkConfigurations(target);

      Iterables.removeIf(target.getLinks(), LinkPredicates.rel(ParentLinkName.NETWORK_GATEWAY));
      for (VMNetworkConfigurationDto config : configs.getCollection()) {
         if (config.getGateway().equalsIgnoreCase(gatewayNetwork.getGateway())) {
            target.addLink(new RESTLink(ParentLinkName.NETWORK_GATEWAY, config.getEditLink().getHref()));
            break;
         }
      }

      return update(true);
View Full Code Here


      return target.getDvd() != null;
   }

   public void attachDvd() {
      DvdManagementDto dvd = new DvdManagementDto();
      RESTLink link = new RESTLink("image", "");
      dvd.addLink(link);
      target.setDvd(dvd);
   }
View Full Code Here

* @author Francesc Montserrat
*/
public class AdminResources {
   public static RoleDto rolePost() {
      RoleDto role = new RoleDto();
      role.addLink(new RESTLink("privileges", "http://localhost/api/admin/roles/1/action/privileges"));
      role.setName("HAWAIAN_ADMIN");
      return role;
   }
View Full Code Here

   }

   public static RoleDto rolePut() {
      RoleDto role = rolePost();
      role.setId(1);
      role.addLink(new RESTLink("edit", "http://localhost/api/admin/roles/1"));

      return role;
   }
View Full Code Here

   }

   public static DatacenterLimitsDto datacenterLimitsPut(final EnterpriseDto enterprise) {
      DatacenterLimitsDto limits = datacenterLimitsPost();
      limits.setId(1);
      limits.addLink(new RESTLink("edit", "http://localhost/api/admin/enterprises/" + enterprise.getId() + "/limits/1"));
      return limits;
   }
View Full Code Here

      user.setNick("abejo");
      user.setAuthType("ABIQUO");
      user.setLocale("en_US");
      user.setActive(true);
      user.setPassword("c69a39bd64ffb77ea7ee3369dce742f3");
      user.addLink(new RESTLink("role", "http://localhost/api/admin/roles/1"));
      return user;
   }
View Full Code Here

      binder.bindToRequest(request, new Object());
   }

   public void testBindIpRef() throws IOException {
      PrivateIpDto ip = NetworkResources.privateIpPut();
      RESTLink selfLink = ip.searchLink("self");
      BindIpRefToPayload binder = new BindIpRefToPayload(new JAXBParser("false"));
      HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://localhost")).build();
      request = binder.bindToRequest(request, ip);
      assertPayloadEquals(request.getPayload(), withHeader("<links><link href=\"" + selfLink.getHref() + "\" rel=\""
            + selfLink.getTitle() + "\"/></links>"), LinksDto.class);

   }
View Full Code Here

   }

   public static UserDto userPut() {
      UserDto user = userPost();
      user.setId(1);
      user.addLink(new RESTLink("edit", "http://localhost/api/admin/enterprises/1/users/1"));
      user.addLink(new RESTLink("enterprise", "http://localhost/api/admin/enterprises/1"));
      user.addLink(new RESTLink("virtualmachines",
            "http://localhost/api/admin/enterprises/1/users/1/action/virtualmachines"));
      return user;
   }
View Full Code Here

   static class TestDto extends SingleResourceTransportDto {

      private static final long serialVersionUID = 5381713583837345158L;

      public TestDto() {
         addLink(new RESTLink("edit", "http://linkuri"));
      }
View Full Code Here

      dto.setName("Template");
      dto.setDescription("Template description");
      dto.setHdRequired(50L * 1024 * 1024 * 1024); // 50 GB
      dto.setCpuRequired(5);
      dto.setRamRequired(2048);
      dto.addLink(new RESTLink("edit", "http://foo/bar"));
      VirtualMachineTemplate template = wrap(context, VirtualMachineTemplate.class, dto);

      VirtualDatacenterDto vdcDto = new VirtualDatacenterDto();
      vdcDto.setId(6);
      vdcDto.setHypervisorType(HypervisorType.VMX_04);
View Full Code Here

TOP

Related Classes of com.abiquo.model.rest.RESTLink

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.