http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/config/SystemProperty.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/SystemProperty.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/config/SystemProperty.java deleted file mode 100644 index 5189216..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/SystemProperty.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.abiquo.domain.config; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.rest.ApiContext; - -import com.abiquo.server.core.config.SystemPropertyDto; - -/** - * Adds high level functionality to {@link SystemPropertyDto}. - * - * @see API: <a - * href="http://community.abiquo.com/display/ABI20/System+Property+resource" - * > http://community.abiquo.com/display/ABI20/System+Property+resource</a> - */ - -public class SystemProperty extends DomainWrapper<SystemPropertyDto> { - /** - * Constructor to be used only by the builder. This resource cannot be - * created. - */ - private SystemProperty(final ApiContext<AbiquoApi> context, final SystemPropertyDto target) { - super(context, target); - } - - // Domain operations - - /** - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/System+Property+resource#SystemPropertyresource-ModifyanexistingSystemProperty" - * > http://community.abiquo.com/display/ABI20/System+Property+resource# - * SystemPropertyresource-ModifyanexistingSystemProperty</a> - */ - public void update() { - target = context.getApi().getConfigApi().updateSystemProperty(target); - } - - // Delegate methods - - public String getName() { - return target.getName(); - } - - public String getValue() { - return target.getValue(); - } - - public void setValue(final String value) { - target.setValue(value); - } - - @Override - public String toString() { - return "SystemProperty [getName()=" + getName() + ", getValue()=" + getValue() + "]"; - } - -}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/IconOptions.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/IconOptions.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/IconOptions.java deleted file mode 100644 index 0bd6015..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/IconOptions.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.abiquo.domain.config.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Available options to query icons. - */ -public class IconOptions extends BaseHttpRequestOptions { - public static Builder builder() { - return new Builder(); - } - - @Override - protected Object clone() throws CloneNotSupportedException { - IconOptions options = new IconOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } - - public static class Builder { - private String path; - - public Builder path(final String path) { - this.path = path; - return this; - } - - public IconOptions build() { - IconOptions options = new IconOptions(); - if (path != null) { - options.queryParameters.put("path", path); - } - - return options; - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/LicenseOptions.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/LicenseOptions.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/LicenseOptions.java deleted file mode 100644 index 84786ac..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/LicenseOptions.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.abiquo.domain.config.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Available options to query licenses. - */ -public class LicenseOptions extends BaseHttpRequestOptions { - public static Builder builder() { - return new Builder(); - } - - @Override - protected Object clone() throws CloneNotSupportedException { - LicenseOptions options = new LicenseOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } - - public static class Builder { - private Boolean active; - - /** - * Search active licenses - */ - public Builder active(final boolean active) { - this.active = active; - return this; - } - - /** - * Search inactive licenses - */ - public Builder inactive(final boolean inactive) { - this.active = !inactive; - return this; - } - - public LicenseOptions build() { - LicenseOptions options = new LicenseOptions(); - if (active != null) { - options.queryParameters.put("active", active.toString()); - } - return options; - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/PropertyOptions.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/PropertyOptions.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/PropertyOptions.java deleted file mode 100644 index 2a47979..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/domain/config/options/PropertyOptions.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.abiquo.domain.config.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Available options to query system properties. - */ -public class PropertyOptions extends BaseHttpRequestOptions { - public static Builder builder() { - return new Builder(); - } - - @Override - protected Object clone() throws CloneNotSupportedException { - PropertyOptions options = new PropertyOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } - - public static class Builder { - private String component; - - private String name; - - public Builder component(final String component) { - this.component = component; - return this; - } - - public Builder name(final String name) { - this.name = name; - return this; - } - - public PropertyOptions build() { - PropertyOptions options = new PropertyOptions(); - if (component != null) { - options.queryParameters.put("component", component.toString()); - } - - if (name != null) { - options.queryParameters.put("name", name.toString()); - } - return options; - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Enterprise.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Enterprise.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Enterprise.java deleted file mode 100644 index 8752f5a..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Enterprise.java +++ /dev/null @@ -1,645 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.abiquo.domain.enterprise; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.DomainWithLimitsWrapper; -import org.jclouds.abiquo.domain.PaginatedCollection; -import org.jclouds.abiquo.domain.builder.LimitsBuilder; -import org.jclouds.abiquo.domain.cloud.VirtualAppliance; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate; -import org.jclouds.abiquo.domain.enterprise.options.UserOptions; -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.domain.infrastructure.Machine; -import org.jclouds.abiquo.domain.network.ExternalNetwork; -import org.jclouds.abiquo.domain.network.UnmanagedNetwork; -import org.jclouds.abiquo.strategy.enterprise.ListVirtualMachineTemplates; -import org.jclouds.collect.PagedIterable; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.functions.ParseXMLWithJAXB; -import org.jclouds.rest.ApiContext; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.appslibrary.TemplateDefinitionListDto; -import com.abiquo.server.core.appslibrary.TemplateDefinitionListsDto; -import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto; -import com.abiquo.server.core.cloud.VirtualAppliancesDto; -import com.abiquo.server.core.cloud.VirtualDatacentersDto; -import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto; -import com.abiquo.server.core.enterprise.DatacenterLimitsDto; -import com.abiquo.server.core.enterprise.DatacentersLimitsDto; -import com.abiquo.server.core.enterprise.EnterpriseDto; -import com.abiquo.server.core.enterprise.EnterprisePropertiesDto; -import com.abiquo.server.core.enterprise.RolesDto; -import com.abiquo.server.core.enterprise.UserDto; -import com.abiquo.server.core.enterprise.UsersDto; -import com.abiquo.server.core.infrastructure.DatacentersDto; -import com.abiquo.server.core.infrastructure.MachinesDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworksDto; -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; -import com.google.inject.TypeLiteral; - -/** - * Represents a tenant. - * <p> - * Each tenant has a set of available locations, and a set of compute, - * networking and storage resources that can be consumed in the assigned - * locations. - */ -public class Enterprise extends DomainWithLimitsWrapper<EnterpriseDto> { - /** The default value for the reservation restricted flag. */ - private static final boolean DEFAULT_RESERVATION_RESTRICTED = false; - - /** - * Constructor to be used only by the builder. - */ - protected Enterprise(final ApiContext<AbiquoApi> context, final EnterpriseDto target) { - super(context, target); - } - - // Domain operations - - /** - * Delete the enterprise. - * - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource-DeleteanexistingEnterprise" - * > http://community.abiquo.com/display/ABI20/EnterpriseResource# - * EnterpriseResource- DeleteanexistingEnterprise</a> - */ - public void delete() { - context.getApi().getEnterpriseApi().deleteEnterprise(target); - target = null; - } - - /** - * Create a new enterprise in Abiquo. - * - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource-CreatesanewEnterprise" - * > http://community.abiquo.com/display/ABI20/EnterpriseResource# - * EnterpriseResource- CreatesanewEnterprise</a> - */ - public void save() { - target = context.getApi().getEnterpriseApi().createEnterprise(target); - } - - /** - * Update enterprise information in the server with the data from this - * enterprise. - * - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource-Updateanexistingenterprise" - * > http://community.abiquo.com/display/ABI20/EnterpriseResource# - * EnterpriseResource- Updateanexistingenterprise</a> - */ - public void update() { - target = context.getApi().getEnterpriseApi().updateEnterprise(target); - } - - // Children access - - /** - * Retrieve the list of virtual datacenters by this enterprise. - * - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource-RetrievealistofvitualdatacentersbyanEnterprise" - * > http://community.abiquo.com/display/ABI20/EnterpriseResource# - * EnterpriseResource- - * RetrievealistofvitualdatacentersbyanEnterprise</a> - * @return List of virtual datacenters in this enterprise. - */ - public Iterable<VirtualDatacenter> listVirtualDatacenters() { - VirtualDatacentersDto dto = context.getApi().getEnterpriseApi().listVirtualDatacenters(target); - return wrap(context, VirtualDatacenter.class, dto.getCollection()); - } - - /** - * Retrieve the list of template definition lists of the enterprise. - * - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#TemplateDefinitionListResource-Retrievealltemplatedefinitionlists" - * > http://community.abiquo.com/display/ABI20/ - * TemplateDefinitionListResource# - * TemplateDefinitionListResource-Retrievealltemplatedefinitionlists</a> - * @return List of template definition lists of the enterprise. - */ - public Iterable<TemplateDefinitionList> listTemplateDefinitionLists() { - TemplateDefinitionListsDto dto = context.getApi().getEnterpriseApi().listTemplateDefinitionLists(target); - return wrap(context, TemplateDefinitionList.class, dto.getCollection()); - } - - /** - * Retrieve a single template definition list. - * - * @param id - * Unique ID of the template definition list for this enterprise. - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#TemplateDefinitionListResource-Retrieveatemplatedefinitionlist" - * > http://community.abiquo.com/display/ABI20/ - * TemplateDefinitionListResource# - * TemplateDefinitionListResource-Retrieveatemplatedefinitionlist</a> - * @return Template definition with the given id or <code>null</code> if it - * does not exist. - */ - public TemplateDefinitionList getTemplateDefinitionList(final Integer id) { - TemplateDefinitionListDto templateList = context.getApi().getEnterpriseApi() - .getTemplateDefinitionList(target, id); - return wrap(context, TemplateDefinitionList.class, templateList); - } - - /** - * Retrieve the list of datacenter limits by enterprise. - * - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/DatacenterLimitsResource#DatacenterLimitsResource-Retrievelimitsbyenterprise" - * > http://community.abiquo.com/display/ABI20/DatacenterLimitsResource# - * DatacenterLimitsResource-Retrievelimitsbyenterprise</a> - * @return List of datacenter limits by enterprise. - */ - public Iterable<Limits> listLimits() { - DatacentersLimitsDto dto = context.getApi().getEnterpriseApi().listLimits(this.unwrap()); - return wrap(context, Limits.class, dto.getCollection()); - } - - /** - * Retrieve the defined properties of the given enterprise. - * - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/EnterprisePropertiesResource#EnterprisePropertiesResource-Retrievethepropertiesforanenterprise" - * > http://community.abiquo.com/display/ABI20/ - * EnterprisePropertiesResource# - * EnterprisePropertiesResource-Retrievethepropertiesforanenterprise</a> - * @return The defined properties of the given enterprise. - */ - public EnterpriseProperties getEnterpriseProperties() { - EnterprisePropertiesDto dto = context.getApi().getEnterpriseApi().getEnterpriseProperties(this.unwrap()); - return wrap(context, EnterpriseProperties.class, dto); - } - - /** - * Retrieve the list of users of this enterprise. - * - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/UserResource#UserResource-Retrievealistofusers" - * > - * http://community.abiquo.com/display/ABI20/UserResource#UserResource- - * Retrievealistofusers</a> - * @return List of users of this enterprise. - */ - public Iterable<User> listUsers() { - PagedIterable<UserDto> dto = context.getApi().getEnterpriseApi().listUsers(target); - return wrap(context, User.class, dto.concat()); - } - - /** - * Retrieve the list of users of this enterprise, allowing pagination - * - * @param options - * User options - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/UserResource#UserResource-Retrievealistofusers" - * > - * http://community.abiquo.com/display/ABI20/UserResource#UserResource- - * Retrievealistofusers</a> - * @return List of users of this enterprise, according to the specified - * pagination options - */ - public Iterable<User> listUsers(final UserOptions options) { - PaginatedCollection<UserDto, UsersDto> dto = context.getApi().getEnterpriseApi().listUsers(target, options); - return wrap(context, User.class, dto.toPagedIterable().concat()); - } - - /** - * Retrieve a single user. - * - * @param id - * Unique ID of the user in this enterprise. - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/UserResource#UserResource-Retrieveauser" - * > - * http://community.abiquo.com/display/ABI20/UserResource#UserResource- - * Retrieveauser</a> - * @return User with the given id or <code>null</code> if it does not exist. - */ - public User getUser(final Integer id) { - UserDto user = context.getApi().getEnterpriseApi().getUser(target, id); - return wrap(context, User.class, user); - } - - /** - * Retrieve the list of roles defined by this enterprise. - * - * @return List of roles by this enterprise. - */ - public Iterable<Role> listRoles() { - RolesDto dto = context.getApi().getAdminApi().listRoles(target); - return wrap(context, Role.class, dto.getCollection()); - } - - public Iterable<VirtualMachineTemplate> listTemplatesInRepository(final Datacenter datacenter) { - PagedIterable<VirtualMachineTemplateDto> templates = context.getApi().getVirtualMachineTemplateApi() - .listVirtualMachineTemplates(target.getId(), datacenter.getId()); - return wrap(context, VirtualMachineTemplate.class, templates.concat()); - } - - public VirtualMachineTemplate getTemplateInRepository(final Datacenter datacenter, final Integer id) { - VirtualMachineTemplateDto template = context.getApi().getVirtualMachineTemplateApi() - .getVirtualMachineTemplate(target.getId(), datacenter.getId(), id); - return wrap(context, VirtualMachineTemplate.class, template); - } - - public Iterable<VirtualMachineTemplate> listTemplates() { - ListVirtualMachineTemplates strategy = context.utils().injector().getInstance(ListVirtualMachineTemplates.class); - return strategy.execute(this); - } - - public Iterable<Datacenter> listAllowedDatacenters() { - DatacentersDto datacenters = context.getApi().getEnterpriseApi().listAllowedDatacenters(target.getId()); - return wrap(context, Datacenter.class, datacenters.getCollection()); - } - - /** - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource-Getthelistofexternalnetworks" - * > http://community.abiquo.com/display/ABI20/Enterprise+Resource# - * EnterpriseResource- Getthelistofexternalnetworks</a> - */ - public Iterable<ExternalNetwork> listExternalNetworks(final Datacenter datacenter) { - DatacenterLimitsDto limitForDatacenter = getLimits(datacenter); - - HttpResponse response = context.getApi().get(limitForDatacenter.searchLink("externalnetworks")); - - ParseXMLWithJAXB<VLANNetworksDto> parser = new ParseXMLWithJAXB<VLANNetworksDto>(context.utils().xml(), - TypeLiteral.get(VLANNetworksDto.class)); - - return wrap(context, ExternalNetwork.class, parser.apply(response).getCollection()); - } - - public Iterable<UnmanagedNetwork> listUnmanagedNetworks(final Datacenter datacenter) { - DatacenterLimitsDto limitForDatacenter = getLimits(datacenter); - - // The "rel" for the unmanaged networks is the same than the one used for - // external networks - HttpResponse response = context.getApi().get(limitForDatacenter.searchLink("externalnetworks")); - - ParseXMLWithJAXB<VLANNetworksDto> parser = new ParseXMLWithJAXB<VLANNetworksDto>(context.utils().xml(), - TypeLiteral.get(VLANNetworksDto.class)); - - return wrap(context, UnmanagedNetwork.class, parser.apply(response).getCollection()); - } - - /** - * Retrieve the list of virtual appliances by this enterprise. - * - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource-RetrievethelistofvirtualappliancesbyanEnterprise" - * > http://community.abiquo.com/display/ABI20/EnterpriseResource# - * EnterpriseResource- - * RetrievethelistofvirtualappliancesbyanEnterprise</a> - * @return List of virtual appliances by this enterprise. - */ - public Iterable<VirtualAppliance> listVirtualAppliances() { - VirtualAppliancesDto virtualAppliances = context.getApi().getEnterpriseApi().listVirtualAppliances(target); - return wrap(context, VirtualAppliance.class, virtualAppliances.getCollection()); - } - - /** - * Retrieve the list of virtual machines by this enterprise. - * - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/EnterpriseResource#EnterpriseResource-RetrievealistofvirtualmachinesbyanEnterprise" - * > http://community.abiquo.com/display/ABI20/EnterpriseResource# - * EnterpriseResource- RetrievealistofvirtualmachinesbyanEnterprise</a> - * @return List of virtual machines by this enterprise. - */ - public Iterable<VirtualMachine> listVirtualMachines() { - VirtualMachinesWithNodeExtendedDto machines = context.getApi().getEnterpriseApi().listVirtualMachines(target); - return wrap(context, VirtualMachine.class, machines.getCollection()); - } - - public Iterable<Machine> listReservedMachines() { - MachinesDto machines = context.getApi().getEnterpriseApi().listReservedMachines(target); - return wrap(context, Machine.class, machines.getCollection()); - } - - // Actions - - /** - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/Datacenter+Repository+Resource#DatacenterRepositoryResource-SynchronizetheDatacenterRepositorywiththerepository" - * > http://community.abiquo.com/display/ABI20/Datacenter+Repository+ - * Resource# DatacenterRepositoryResource- - * SynchronizetheDatacenterRepositorywiththerepository</a> - */ - public void refreshTemplateRepository(final Datacenter datacenter) { - context.getApi().getEnterpriseApi().refreshTemplateRepository(target.getId(), datacenter.getId()); - } - - /** - * Allows the given datacenter to be used by this enterprise. Creates a - * {@link Limits} object if not exists. - * - * @param datacenter - * The datacenter. - * @return Default datacenter limits of the enterprise for the given - * datacenter. - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/Datacenter+Limits+Resource#DatacenterLimitsResource-CreateanewLimitforanenterpriseinadatacenter" - * > http://community.abiquo.com/display/ABI20/Datacenter+Limits+ - * Resource# - * DatacenterLimitsResource-CreateanewLimitforanenterpriseinadatacenter - * </a> - */ - public Limits allowDatacenter(final Datacenter datacenter) { - DatacenterLimitsDto dto; - - try { - // Create new limits - Limits limits = Limits.builder(context, datacenter).build(); - - // Save new limits - dto = context.getApi().getEnterpriseApi().createLimits(target, datacenter.unwrap(), limits.unwrap()); - } catch (AbiquoException ex) { - // Controlled error to allow duplicated authorizations - if (ex.hasError("LIMIT-7")) { - DatacentersLimitsDto limits = context.getApi().getEnterpriseApi().getLimits(target, datacenter.unwrap()); - // Should be only one limit - dto = limits.getCollection().get(0); - } else { - throw ex; - } - } - - return wrap(context, Limits.class, dto); - } - - /** - * Prohibit the given datacenter to be used by this enterprise. Deletes a - * {@link Limits} object. - * - * @param datacenter - * The datacenter. - * @return Default datacenter limits of the enterprise for the given - * datacenter. - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/Datacenter+Limits+Resource#DatacenterLimitsResource-Deleteanexistinglimitforanenterpriseinadatacenter" - * > http://community.abiquo.com/display/ABI20/Datacenter+Limits+ - * Resource# DatacenterLimitsResource- - * Deleteanexistinglimitforanenterpriseinadatacenter</a> - */ - public void prohibitDatacenter(final Datacenter datacenter) { - // Get limits - DatacentersLimitsDto dto = context.getApi().getEnterpriseApi().getLimits(target, datacenter.unwrap()); - - // Delete limits (if any) - if (dto != null && !dto.isEmpty()) { - // Should be only one limit - context.getApi().getEnterpriseApi().deleteLimits(dto.getCollection().get(0)); - } - } - - /** - * Disables chef in the enterprise. - * - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource-DisableChefinanexistingEnterprise" - * > http://community.abiquo.com/display/ABI20/Enterprise+Resource# - * EnterpriseResource- DisableChefinanexistingEnterprise</a> - */ - public void disableChef() { - target.setChefClient(null); - target.setChefClientCertificate(null); - target.setChefURL(null); - target.setChefValidator(null); - target.setChefValidatorCertificate(null); - update(); - } - - // Builder - - public static Builder builder(final ApiContext<AbiquoApi> context) { - return new Builder(context); - } - - public static class Builder extends LimitsBuilder<Builder> { - private ApiContext<AbiquoApi> context; - - private String name; - - protected Long repositorySoft = Long.valueOf(DEFAULT_LIMITS); - - protected Long repositoryHard = Long.valueOf(DEFAULT_LIMITS); - - private Boolean isReservationRestricted = DEFAULT_RESERVATION_RESTRICTED; - - private String chefURL; - - private String chefClient; - - private String chefValidator; - - private String chefApiCertificate; - - private String chefValidatorCertificate; - - public Builder(final ApiContext<AbiquoApi> context) { - super(); - this.context = context; - } - - public Builder isReservationRestricted(final boolean isReservationRestricted) { - this.isReservationRestricted = isReservationRestricted; - return this; - } - - public Builder chefURL(final String chefURL) { - this.chefURL = chefURL; - return this; - } - - public Builder chefClient(final String chefClient) { - this.chefClient = chefClient; - return this; - } - - public Builder chefApiCertificate(final String chefApiCertificate) { - this.chefApiCertificate = chefApiCertificate; - return this; - } - - public Builder chefValidator(final String chefValidator) { - this.chefValidator = chefValidator; - return this; - } - - public Builder chefValidatorCertificate(final String chefValidatorCertificate) { - this.chefValidatorCertificate = chefValidatorCertificate; - return this; - } - - public Builder name(final String name) { - this.name = name; - return this; - } - - public Builder repositoryLimits(final long soft, final long hard) { - this.repositorySoft = soft; - this.repositoryHard = hard; - return this; - } - - public Enterprise build() { - EnterpriseDto dto = new EnterpriseDto(); - dto.setName(name); - dto.setRamLimitsInMb(ramSoftLimitInMb, ramHardLimitInMb); - dto.setCpuCountLimits(cpuCountSoftLimit, cpuCountHardLimit); - dto.setHdLimitsInMb(hdSoftLimitInMb, hdHardLimitInMb); - dto.setStorageLimits(storageSoft, storageHard); - dto.setVlansLimits(vlansSoft, vlansHard); - dto.setPublicIPLimits(publicIpsSoft, publicIpsHard); - dto.setRepositoryLimits(repositorySoft, repositoryHard); - dto.setIsReservationRestricted(isReservationRestricted); - dto.setChefClient(chefClient); - dto.setChefClientCertificate(chefApiCertificate); - dto.setChefURL(chefURL); - dto.setChefValidator(chefValidator); - dto.setChefValidatorCertificate(chefValidatorCertificate); - - return new Enterprise(context, dto); - } - - public static Builder fromEnterprise(final Enterprise in) { - return Enterprise.builder(in.context).name(in.getName()) - .ramLimits(in.getRamSoftLimitInMb(), in.getRamHardLimitInMb()) - .cpuCountLimits(in.getCpuCountSoftLimit(), in.getCpuCountHardLimit()) - .hdLimitsInMb(in.getHdSoftLimitInBytes(), in.getHdHardLimitInBytes()) - .storageLimits(in.getStorageSoft(), in.getStorageHard()) - .vlansLimits(in.getVlansSoft(), in.getVlansHard()) - .publicIpsLimits(in.getPublicIpsSoft(), in.getPublicIpsHard()) - .repositoryLimits(in.getRepositorySoft(), in.getRepositoryHard()) - .isReservationRestricted(in.getIsReservationRestricted()).chefClient(in.getChefClient()) - .chefApiCertificate(in.getChefApiCertificate()).chefURL(in.getChefURL()) - .chefValidator(in.getChefValidator()).chefValidatorCertificate(in.getChefValidatorCertificate()); - } - } - - // Delegate methods - - public Integer getId() { - return target.getId(); - } - - public boolean getIsReservationRestricted() { - return target.getIsReservationRestricted(); - } - - public String getName() { - return target.getName(); - } - - public long getRepositoryHard() { - return target.getRepositoryHard(); - } - - public long getRepositorySoft() { - return target.getRepositorySoft(); - } - - public void setIsReservationRestricted(final boolean isReservationRestricted) { - target.setIsReservationRestricted(isReservationRestricted); - } - - public void setName(final String name) { - target.setName(name); - } - - public void setRepositoryHard(final long repositoryHard) { - target.setRepositoryHard(repositoryHard); - } - - public void setRepositoryLimits(final long soft, final long hard) { - target.setRepositoryLimits(soft, hard); - } - - public void setRepositorySoft(final long repositorySoft) { - target.setRepositorySoft(repositorySoft); - } - - public String getChefClient() { - return target.getChefClient(); - } - - public String getChefApiCertificate() { - return target.getChefClientCertificate(); - } - - public String getChefURL() { - return target.getChefURL(); - } - - public String getChefValidator() { - return target.getChefValidator(); - } - - public String getChefValidatorCertificate() { - return target.getChefValidatorCertificate(); - } - - public void setChefClient(final String chefClient) { - target.setChefClient(chefClient); - } - - public void setChefClientCertificate(final String chefClientCertificate) { - target.setChefClientCertificate(chefClientCertificate); - } - - public void setChefURL(final String chefURL) { - target.setChefURL(chefURL); - } - - public void setChefValidator(final String chefValidator) { - target.setChefValidator(chefValidator); - } - - public void setChefValidatorCertificate(final String chefValidatorCertificate) { - target.setChefValidatorCertificate(chefValidatorCertificate); - } - - @Override - public String toString() { - return "Enterprise [id=" + getId() + ", isReservationRestricted=" + getIsReservationRestricted() + ", name=" - + getName() + "]"; - } - - private DatacenterLimitsDto getLimits(final Datacenter datacenter) { - DatacentersLimitsDto limits = context.getApi().getEnterpriseApi().listLimits(target); - - return Iterables.find(limits.getCollection(), new Predicate<DatacenterLimitsDto>() { - @Override - public boolean apply(final DatacenterLimitsDto input) { - RESTLink datacenterLink = input.searchLink("datacenter"); - return datacenterLink != null - && datacenterLink.getHref().equals(datacenter.unwrap().getEditLink().getHref()); - } - }); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/EnterpriseProperties.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/EnterpriseProperties.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/EnterpriseProperties.java deleted file mode 100644 index 31c6e48..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/EnterpriseProperties.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.abiquo.domain.enterprise; - -import java.util.Map; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.DomainWrapper; - -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.rest.ApiContext; - -import com.abiquo.server.core.enterprise.EnterprisePropertiesDto; - -/** - * Adds high level functionality to {@link EnterprisePropertiesDto}. - * - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/Enterprise+Properties+Resource" - * > - * http://community.abiquo.com/display/ABI20/Enterprise+Properties+Resource - * </a> - */ -public class EnterpriseProperties extends DomainWrapper<EnterprisePropertiesDto> { - /** - * Constructor to be used only by the builder. - */ - protected EnterpriseProperties(final ApiContext<AbiquoApi> context, final EnterprisePropertiesDto target) { - super(context, target); - } - - // Domain operations - /** - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/Enterprise+Properties+Resource#EnterprisePropertiesResource-UpdatesthepropertiesforanEnterprise" - * > http://community.abiquo.com/display/ABI20/Enterprise+Properties+ - * Resource# - * EnterprisePropertiesResource-UpdatesthepropertiesforanEnterprise</a> - */ - public void update() { - target = context.getApi().getEnterpriseApi().updateEnterpriseProperties(target); - } - - // Parent access - /** - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource-RetrieveaEnterprise" - * > http://community.abiquo.com/display/ABI20/Enterprise+Resource# - * EnterpriseResource- RetrieveaEnterprise</a> - */ - public Enterprise getEnterprise() { - Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE); - return wrap(context, Enterprise.class, context.getApi().getEnterpriseApi().getEnterprise(enterpriseId)); - } - - // Delegate methods - public Map<String, String> getProperties() { - return target.getProperties(); - } - - public void setProperties(final Map<String, String> properties) { - target.setProperties(properties); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Limits.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Limits.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Limits.java deleted file mode 100644 index 083c513..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Limits.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.abiquo.domain.enterprise; - -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.DomainWithLimitsWrapper; -import org.jclouds.abiquo.domain.builder.LimitsBuilder; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.rest.ApiContext; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.enterprise.DatacenterLimitsDto; -import com.abiquo.server.core.infrastructure.DatacenterDto; - -/** - * Adds high level functionality to {@link DatacenterLimitsDto}. - * - * @see API: <a - * href="http://community.abiquo.com/display/ABI20/Datacenter+Limits+Resource" - * > - * http://community.abiquo.com/display/ABI20/Datacenter+Limits+Resource</a> - */ -public class Limits extends DomainWithLimitsWrapper<DatacenterLimitsDto> { - /** - * Constructor to be used only by the builder. - */ - protected Limits(final ApiContext<AbiquoApi> context, final DatacenterLimitsDto target) { - super(context, target); - } - - // Domain operations - - /** - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/Datacenter+Limits+Resource#DatacenterLimitsResource-UpdatesanexistingLimitforanenterpriseinadatacenter" - * > - * http://community.abiquo.com/display/ABI20/Datacenter+Limits+Resource - * #DatacenterLimitsResource - * -UpdatesanexistingLimitforanenterpriseinadatacenter</a> - */ - public void update() { - target = context.getApi().getEnterpriseApi().updateLimits(target); - } - - // Builder - - public static Builder builder(final ApiContext<AbiquoApi> context, Datacenter datacenter) { - return new Builder(context, datacenter); - } - - public static class Builder extends LimitsBuilder<Builder> { - private ApiContext<AbiquoApi> context; - - protected Long repositorySoft = Long.valueOf(DEFAULT_LIMITS); - - protected Long repositoryHard = Long.valueOf(DEFAULT_LIMITS); - - protected Datacenter datacenter; - - public Builder(final ApiContext<AbiquoApi> context, final Datacenter datacenter) { - this.context = checkNotNull(context, "missing context object"); - this.datacenter = checkNotNull(datacenter, "missing datacenter object"); - } - - public Builder repositoryLimits(final long soft, final long hard) { - this.repositorySoft = soft; - this.repositoryHard = hard; - return this; - } - - public Limits build() { - DatacenterLimitsDto dto = new DatacenterLimitsDto(); - dto.setRamLimitsInMb(ramSoftLimitInMb, ramHardLimitInMb); - dto.setCpuCountLimits(cpuCountSoftLimit, cpuCountHardLimit); - dto.setHdLimitsInMb(hdSoftLimitInMb, hdHardLimitInMb); - dto.setStorageLimits(storageSoft, storageHard); - dto.setVlansLimits(vlansSoft, vlansHard); - dto.setPublicIPLimits(publicIpsSoft, publicIpsHard); - dto.setRepositoryHardLimitsInMb(repositoryHard); - dto.setRepositorySoftLimitsInMb(repositorySoft); - - // Establish the relation with the physical datacenter - dto.addLink(new RESTLink(ParentLinkName.DATACENTER, checkNotNull(datacenter.unwrap().getEditLink(), - "missing edit link").getHref())); - - Limits limits = new Limits(context, dto); - - return limits; - } - - public static Builder fromEnterprise(final Limits in) { - return Limits.builder(in.context, in.getDatacenter()) - .ramLimits(in.getRamSoftLimitInMb(), in.getRamHardLimitInMb()) - .cpuCountLimits(in.getCpuCountSoftLimit(), in.getCpuCountHardLimit()) - .hdLimitsInMb(in.getHdSoftLimitInBytes(), in.getHdHardLimitInBytes()) - .storageLimits(in.getStorageSoft(), in.getStorageHard()) - .vlansLimits(in.getVlansSoft(), in.getVlansHard()) - .publicIpsLimits(in.getPublicIpsSoft(), in.getPublicIpsHard()) - .repositoryLimits(in.getRepositorySoft(), in.getRepositoryHard()); - } - } - - // Delegate methods - - public Integer getId() { - return target.getId(); - } - - public long getRepositoryHard() { - return target.getRepositoryHardLimitsInMb(); - } - - public long getRepositorySoft() { - return target.getRepositorySoftLimitsInMb(); - } - - public void setRepositoryHard(final long repositoryHard) { - target.setRepositoryHardLimitsInMb(repositoryHard); - } - - public void setRepositoryLimits(final long soft, final long hard) { - target.setRepositoryHardLimitsInMb(hard); - target.setRepositorySoftLimitsInMb(soft); - } - - public void setRepositorySoft(final long repositorySoft) { - target.setRepositorySoftLimitsInMb(repositorySoft); - } - - public Datacenter getDatacenter() { - Integer datacenterId = target.getIdFromLink(ParentLinkName.DATACENTER); - checkNotNull(datacenterId, ValidationErrors.MISSING_REQUIRED_LINK); - DatacenterDto dto = context.getApi().getInfrastructureApi().getDatacenter(datacenterId); - return wrap(context, Datacenter.class, dto); - } - - @Override - public String toString() { - return "Limits [id=" + getId() + ", repositoryHard=" + getRepositoryHard() + ", repositorySoft=" - + getRepositorySoft() + ", cpuCountHard=" + getCpuCountHardLimit() + ", cpuCountSoft=" - + getCpuCountSoftLimit() + ", hdHardInBytes=" + getHdHardLimitInBytes() + ", hdSoftInBytes=" + getHdSoftLimitInBytes() - + ", publicIPsHard=" + getPublicIpsHard() + ", publicIpsSoft=" + getPublicIpsSoft() + ", ramHardInMB=" - + getRamHardLimitInMb() + ", ramSoftInMB=" + getRamSoftLimitInMb() + ", storageHard=" + getStorageHard() - + ", storageSoft=" + getStorageSoft() + ", vlansHard=" + getVlansHard() + ", vlansSoft=" + getVlansSoft() - + "]"; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Role.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Role.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Role.java deleted file mode 100644 index c1c4b22..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/Role.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.abiquo.domain.enterprise; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.List; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.config.Privilege; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.rest.ApiContext; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.enterprise.PrivilegesDto; -import com.abiquo.server.core.enterprise.RoleDto; - -/** - * Adds high level functionality to {@link RoleDto}. - * - * @see API: <a href="http://community.abiquo.com/display/ABI20/Roles+Resource"> - * http://community.abiquo.com/display/ABI20/Roles+Resource</a> - */ -public class Role extends DomainWrapper<RoleDto> { - /** Default active value of the user */ - private static final boolean DEFAULT_BLOCKED = false; - - /** - * Constructor to be used only by the builder. - */ - protected Role(final ApiContext<AbiquoApi> context, final RoleDto target) { - super(context, target); - } - - // Domain operations - - /** - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource-DeleteanexistingRole" - * > - * http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource - * -DeleteanexistingRole </a> - */ - public void delete() { - context.getApi().getAdminApi().deleteRole(target); - target = null; - } - - /** - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource-CreateanewRole" - * > http - * ://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource - * -CreateanewRole</a> - */ - public void save() { - target = context.getApi().getAdminApi().createRole(target); - } - - /** - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource-UpdateanexistingRole" - * > - * http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource - * -UpdateanexistingRole </a> - */ - public void update() { - target = context.getApi().getAdminApi().updateRole(target); - } - - public void setEnterprise(final Enterprise enterprise) { - checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class); - checkNotNull(enterprise.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + Enterprise.class); - - RESTLink link = enterprise.unwrap().searchLink("edit"); - - checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); - - target.addLink(new RESTLink("enterprise", link.getHref())); - } - - public void setPrivileges(final List<Privilege> privileges) { - for (Privilege privilege : privileges) { - addPrivilege(privilege); - } - } - - private void addPrivilege(final Privilege privilege) { - checkNotNull(privilege, ValidationErrors.NULL_RESOURCE + Privilege.class); - checkNotNull(privilege.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + Privilege.class); - - RESTLink link = privilege.unwrap().searchLink("self"); - - // rel would be "privilege" if the object is coming from a privilege list. - if (link == null) { - link = privilege.unwrap().searchLink("privilege"); - } - - checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK); - - target.addLink(new RESTLink("privilege" + privilege.getId(), link.getHref())); - } - - // Children access - - /** - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/Roles+Resource#RolesResource-RetrievealistofprivilegesfromaRole" - * > http://community.abiquo.com/display/ABI20/Roles+Resource# - * RolesResource- RetrievealistofprivilegesfromaRole</a> - */ - public Iterable<Privilege> listPrivileges() { - PrivilegesDto dto = context.getApi().getAdminApi().listPrivileges(target); - return wrap(context, Privilege.class, dto.getCollection()); - } - - // Builder - - public static Builder builder(final ApiContext<AbiquoApi> context) { - return new Builder(context); - } - - public static class Builder { - private ApiContext<AbiquoApi> context; - - private String name; - - private boolean blocked = DEFAULT_BLOCKED; - - public Builder(final ApiContext<AbiquoApi> context) { - super(); - this.context = context; - } - - public Builder name(final String name) { - this.name = name; - return this; - } - - public Builder blocked(final boolean blocked) { - this.blocked = blocked; - return this; - } - - public Role build() { - RoleDto dto = new RoleDto(); - dto.setName(name); - dto.setBlocked(blocked); - Role role = new Role(context, dto); - - return role; - } - - public static Builder fromRole(final Role in) { - return Role.builder(in.context).blocked(in.isBlocked()).name(in.getName()); - } - } - - // Delegate methods - - public Integer getId() { - return target.getId(); - } - - public String getName() { - return target.getName(); - } - - public boolean isBlocked() { - return target.isBlocked(); - } - - public void setBlocked(final boolean blocked) { - target.setBlocked(blocked); - } - - public void setName(final String name) { - target.setName(name); - } - - @Override - public String toString() { - return "Role [id=" + getId() + ", name=" + getName() + ", blocked=" + isBlocked() + "]"; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionList.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionList.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionList.java deleted file mode 100644 index cf1ca3b..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/TemplateDefinitionList.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.abiquo.domain.enterprise; - -import static com.google.common.collect.Iterables.filter; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.infrastructure.Datacenter; -import org.jclouds.rest.ApiContext; - -import com.abiquo.am.model.TemplatesStateDto; -import com.abiquo.server.core.appslibrary.TemplateDefinitionListDto; -import com.google.common.base.Predicate; - -/** - * Adds high level functionality to {@link TemplateDefinitionListDto}. A - * Template Definition List provides a way to organize multiple Template - * Definitions. A single Template Definition can be shared by many lists. Its - * compatible with ovfindex.xml format. - */ -public class TemplateDefinitionList extends DomainWrapper<TemplateDefinitionListDto> { - /** The enterprise where the list belongs. */ - private Enterprise enterprise; - - /** - * Constructor to be used only by the builder. - */ - protected TemplateDefinitionList(final ApiContext<AbiquoApi> context, final TemplateDefinitionListDto target) { - super(context, target); - } - - // Domain operations - - /** - * Delete the template definition list. Deleting the list doesn't delete the - * containing Template Definitions. - * - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#TemplateDefinitionListResource-Deleteatemplatedefinitionlist" - * > http://community.abiquo.com/display/ABI20/ - * TemplateDefinitionListResource# - * TemplateDefinitionListResource-Deleteatemplatedefinitionlist</a> - */ - public void delete() { - context.getApi().getEnterpriseApi().deleteTemplateDefinitionList(target); - target = null; - } - - /** - * Create a template definition list. All the contained Template Definitions - * will also be created. - * - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#TemplateDefinitionListResource-Createatemplatedefinitionlist" - * > http://community.abiquo.com/display/ABI20/ - * TemplateDefinitionListResource# - * TemplateDefinitionListResource-Createatemplatedefinitionlistr</a> - */ - public void save() { - target = context.getApi().getEnterpriseApi().createTemplateDefinitionList(enterprise.unwrap(), target); - } - - /** - * Update a template definition list with the data from this template - * definition list. - * - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#TemplateDefinitionListResource-Modifyatemplatedefinitionlist" - * > http://community.abiquo.com/display/ABI20/ - * TemplateDefinitionListResource# - * TemplateDefinitionListResource-Modifyatemplatedefinitionlist</a> - */ - public void update() { - target = context.getApi().getEnterpriseApi().updateTemplateDefinitionList(target); - } - - // Children access - - /** - * Retrieve the list of states of the templates in the template definition - * list in the repository of the given datacenter. Template Definition are - * available sources, but in order to create a Virtual Machine the Definition - * should be downloaded into the Datacenter Repository (NFS filesystem). - * - * @param The - * datacenter in which repository search. - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#TemplateDefinitionListResource-Retrievealistofthestatusofalltemplatestatuslist" - * > http://community.abiquo.com/display/ABI20/ - * TemplateDefinitionListResource# TemplateDefinitionListResource- - * Retrievealistofthestatusofalltemplatestatuslist</a> - */ - public Iterable<TemplateState> listStatus(final Datacenter datacenter) { - TemplatesStateDto states = context.getApi().getEnterpriseApi() - .listTemplateListStatus(target, datacenter.unwrap()); - return wrap(context, TemplateState.class, states.getCollection()); - } - - /** - * Retrieve a filtered list of states of the templates in the template - * definition list in the repository of the given datacenter. Template - * Definition are available sources, but in order to create a Virtual Machine - * the Definition should be downloaded into the Datacenter Repository (NFS - * filesystem). - * - * @param filter - * Filter to be applied to the list. - * @param The - * datacenter in which repository search. - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/TemplateDefinitionListResource#TemplateDefinitionListResource-Retrievealistofthestatusofalltemplatestatuslist" - * > http://community.abiquo.com/display/ABI20/ - * TemplateDefinitionListResource# TemplateDefinitionListResource- - * Retrievealistofthestatusofalltemplatestatuslist</a> - */ - public Iterable<TemplateState> listStatus(final Predicate<TemplateState> filter, final Datacenter datacenter) { - return filter(listStatus(datacenter), filter); - } - - // Builder - - public static Builder builder(final ApiContext<AbiquoApi> context, final Enterprise enterprise) { - return new Builder(context, enterprise); - } - - public static class Builder { - private ApiContext<AbiquoApi> context; - - private Enterprise enterprise; - - private String name; - - private String url; - - public Builder(final ApiContext<AbiquoApi> context, final Enterprise enterprise) { - super(); - this.context = context; - this.enterprise = enterprise; - } - - public Builder name(final String name) { - this.name = name; - return this; - } - - public Builder url(final String url) { - this.url = url; - return this; - } - - public TemplateDefinitionList build() { - TemplateDefinitionListDto dto = new TemplateDefinitionListDto(); - dto.setName(name); - dto.setUrl(url); - - TemplateDefinitionList templateList = new TemplateDefinitionList(context, dto); - templateList.enterprise = enterprise; - return templateList; - - } - - public static Builder fromTemplateDefinitionList(final TemplateDefinitionList in) { - return TemplateDefinitionList.builder(in.context, in.enterprise).name(in.getName()).url(in.getUrl()); - } - } - - // Delegate methods - - public Integer getId() { - return target.getId(); - } - - public String getName() { - return target.getName(); - } - - public String getUrl() { - return target.getUrl(); - } - - public void setName(final String name) { - target.setName(name); - } - - public void setUrl(final String url) { - target.setUrl(url); - } - - @Override - public String toString() { - return "TemplateDefinitionList [getId()=" + getId() + ", getName()=" + getName() + ", getUrl()=" + getUrl() + "]"; - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/TemplateState.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/TemplateState.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/TemplateState.java deleted file mode 100644 index 0bf35d2..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/TemplateState.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.abiquo.domain.enterprise; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.rest.ApiContext; - -import com.abiquo.am.model.TemplateStateDto; -import com.abiquo.am.model.TemplateStatusEnumType; - -/** - * Adds high level functionality to {@link TemplateStateDto}. - */ -public class TemplateState extends DomainWrapper<TemplateStateDto> { - /** - * Constructor to be used only by the builder. - */ - protected TemplateState(final ApiContext<AbiquoApi> context, final TemplateStateDto target) { - super(context, target); - } - - // Domain operations - - public Double getDownloadingProgress() { - return target.getDownloadingProgress(); - } - - public String getErrorCause() { - return target.getErrorCause(); - } - - public String getMasterOvf() { - return target.getMasterOvf(); - } - - public String getOvfId() { - return target.getOvfId(); - } - - public TemplateStatusEnumType getStatus() { - return target.getStatus(); - } - - @Override - public String toString() { - return "TemplateState [getDownloadingProgress()=" + getDownloadingProgress() + ", getErrorCause()=" - + getErrorCause() + ", getMasterOvf()=" + getMasterOvf() + ", getOvfId()=" + getOvfId() + ", getStatus()=" - + getStatus() + "]"; - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/User.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/User.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/User.java deleted file mode 100644 index 2dd1130..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/User.java +++ /dev/null @@ -1,417 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.abiquo.domain.enterprise; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.List; -import java.util.StringTokenizer; - -import org.jclouds.abiquo.AbiquoApi; -import org.jclouds.abiquo.domain.DomainWrapper; -import org.jclouds.abiquo.domain.cloud.VirtualDatacenter; -import org.jclouds.abiquo.domain.cloud.VirtualMachine; -import org.jclouds.abiquo.reference.ValidationErrors; -import org.jclouds.abiquo.reference.rest.ParentLinkName; -import org.jclouds.abiquo.strategy.cloud.ListVirtualDatacenters; -import org.jclouds.rest.ApiContext; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.cloud.VirtualMachinesWithNodeExtendedDto; -import com.abiquo.server.core.enterprise.RoleDto; -import com.abiquo.server.core.enterprise.UserDto; -import com.google.common.base.Joiner; -import com.google.common.collect.Lists; - -/** - * Adds high level functionality to {@link UserDto}. - * - * @see API: <a href="http://community.abiquo.com/display/ABI20/Users+Resource"> - * http://community.abiquo.com/display/ABI20/Users+Resource</a> - */ -public class User extends DomainWrapper<UserDto> { - /** Default active value of the user */ - private static final boolean DEFAULT_ACTIVE = true; - - /** The default authentication type. */ - private static final String DEFAULT_AUTH_TYPE = "ABIQUO"; - - /** The default locale for the user. */ - private static final String DEFAULT_LOCALE = "en_US"; - - /** The enterprise where the user belongs. */ - private Enterprise enterprise; - - /** Role of the user. */ - private Role role; - - /** - * Constructor to be used only by the builder. - */ - protected User(final ApiContext<AbiquoApi> context, final UserDto target) { - super(context, target); - } - - // Domain operations - - /** - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/User+resource#Userresource-Deleteanexistinguser" - * > - * http://community.abiquo.com/display/ABI20/User+resource#Userresource - * -Deleteanexistinguser </a> - */ - public void delete() { - context.getApi().getEnterpriseApi().deleteUser(target); - target = null; - } - - /** - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/User+resource#Userresource-Createanewuser" - * > - * http://community.abiquo.com/display/ABI20/User+resource#Userresource - * -Createanewuser</a> - */ - public void save() { - // set role link - target.addLink(new RESTLink("role", role.unwrap().getEditLink().getHref())); - target = context.getApi().getEnterpriseApi().createUser(enterprise.unwrap(), target); - } - - /** - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/User+resource#Userresource-Updatesanexistinguser" - * > - * http://community.abiquo.com/display/ABI20/User+resource#Userresource - * -Updatesanexistinguser </a> - */ - public void update() { - // update role link (if exists) - if (role != null) { - target.searchLink("role").setHref(role.unwrap().getEditLink().getHref()); - } - - target = context.getApi().getEnterpriseApi().updateUser(target); - } - - public Iterable<VirtualDatacenter> listPermittedVirtualDatacenters() { - List<Integer> ids = extractAvailableDatacenters(); - - // null value means all virtual datacenters all allowed - if (ids.size() == 0) { - return this.getEnterprise().listVirtualDatacenters(); - } - - ListVirtualDatacenters listVirtualDatacenters = context.utils().injector() - .getInstance(ListVirtualDatacenters.class); - return listVirtualDatacenters.execute(ids); - } - - /** - * Give access to all virtualdatacenters in the enterprise (requires update). - */ - public void permitAllVirtualDatacenters() { - setAvailableVirtualDatacenters(null); - } - - /** - * Limits user access ONLY to the virtual datacenters in the list. If the - * list is empty, user will get access to all virtual datacenters. - * - * @param vdc - * List of virtual datacenters from the user's enterprise. - */ - public void setPermittedVirtualDatacenters(final List<VirtualDatacenter> vdcs) { - List<Integer> ids = Lists.newArrayList(); - - for (VirtualDatacenter vdc : vdcs) { - checkNotNull(vdc.getId(), ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + VirtualDatacenter.class); - ids.add(vdc.getId()); - } - - setAvailableVirtualDatacenters(ids); - } - - // Parent access - /** - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/Enterprise+Resource#EnterpriseResource-RetrieveaEnterprise" - * > http://community.abiquo.com/display/ABI20/Enterprise+Resource# - * EnterpriseResource- RetrieveaEnterprise</a> - */ - public Enterprise getEnterprise() { - Integer enterpriseId = target.getIdFromLink(ParentLinkName.ENTERPRISE); - return wrap(context, Enterprise.class, context.getApi().getEnterpriseApi().getEnterprise(enterpriseId)); - } - - // Children access - - public Role getRole() { - RoleDto role = context.getApi().getAdminApi().getRole(target); - return wrap(context, Role.class, role); - } - - /** - * @see API: <a href= - * "http://community.abiquo.com/display/ABI20/User+resource#Userresource-Retrievethelistofvirtualmachinesbyuser" - * > http://community.abiquo.com/display/ABI20/User+resource# - * Userresource- Retrievethelistofvirtualmachinesbyuser</a> - */ - public Iterable<VirtualMachine> listMachines() { - VirtualMachinesWithNodeExtendedDto machines = context.getApi().getEnterpriseApi().listVirtualMachines(target); - return wrap(context, VirtualMachine.class, machines.getCollection()); - } - - // Builder - - public static Builder builder(final ApiContext<AbiquoApi> context, final Enterprise enterprise, final Role role) { - return new Builder(context, enterprise, role); - } - - public static class Builder { - private ApiContext<AbiquoApi> context; - - private Enterprise enterprise; - - private Role role; - - private String name; - - private String nick; - - private String locale = DEFAULT_LOCALE; - - private String password; - - private String surname; - - private boolean active = DEFAULT_ACTIVE; - - private String email; - - private String description; - - private String authType = DEFAULT_AUTH_TYPE; - - public Builder(final ApiContext<AbiquoApi> context, final Enterprise enterprise, final Role role) { - super(); - checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class); - checkNotNull(role, ValidationErrors.NULL_RESOURCE + Role.class); - this.context = context; - this.enterprise = enterprise; - this.role = role; - } - - public Builder enterprise(final Enterprise enterprise) { - checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class); - this.enterprise = enterprise; - return this; - } - - public Builder role(final Role role) { - this.role = role; - return this; - } - - public Builder name(final String name, final String surname) { - this.name = name; - this.surname = surname; - return this; - } - - public Builder nick(final String nick) { - this.nick = nick; - return this; - } - - public Builder locale(final String locale) { - this.locale = locale; - return this; - } - - public Builder password(final String password) { - this.password = password; - return this; - } - - public Builder active(final boolean active) { - this.active = active; - return this; - } - - public Builder email(final String email) { - this.email = email; - return this; - } - - public Builder description(final String description) { - this.description = description; - return this; - } - - public Builder authType(final String authType) { - this.authType = authType; - return this; - } - - public User build() { - UserDto dto = new UserDto(); - dto.setActive(active); - dto.setAuthType(authType); - dto.setDescription(description); - dto.setEmail(email); - dto.setLocale(locale); - dto.setName(name); - dto.setNick(nick); - dto.setPassword(password); - dto.setSurname(surname); - User user = new User(context, dto); - user.enterprise = enterprise; - user.role = role; - - return user; - } - - public static Builder fromUser(final User in) { - return User.builder(in.context, in.enterprise, in.role).active(in.isActive()).authType(in.getAuthType()) - .description(in.getDescription()).email(in.getEmail()).locale(in.getLocale()) - .name(in.getName(), in.getSurname()).nick(in.getNick()).password(in.getPassword()); - } - } - - // Delegate methods - - public String getAuthType() { - return target.getAuthType(); - } - - public String getDescription() { - return target.getDescription(); - } - - public String getEmail() { - return target.getEmail(); - } - - public Integer getId() { - return target.getId(); - } - - public String getLocale() { - return target.getLocale(); - } - - public String getName() { - return target.getName(); - } - - public String getNick() { - return target.getNick(); - } - - public String getPassword() { - return target.getPassword(); - } - - public String getSurname() { - return target.getSurname(); - } - - public boolean isActive() { - return target.isActive(); - } - - public void setActive(final boolean active) { - target.setActive(active); - } - - public void setAuthType(final String authType) { - target.setAuthType(authType); - } - - public void setDescription(final String description) { - target.setDescription(description); - } - - public void setEmail(final String email) { - target.setEmail(email); - } - - public void setLocale(final String locale) { - target.setLocale(locale); - } - - public void setName(final String name) { - target.setName(name); - } - - public void setNick(final String nick) { - target.setNick(nick); - } - - public void setPassword(final String password) { - target.setPassword(password); - } - - public void setSurname(final String surname) { - target.setSurname(surname); - } - - public void setRole(final Role role) { - this.role = role; - } - - // Aux operations - - /** - * Converts the tokenized String of available virtual datacenters provided in - * the userDto to a list of ids. - */ - private List<Integer> extractAvailableDatacenters() { - List<Integer> ids = Lists.newArrayList(); - - if (target.getAvailableVirtualDatacenters() != null) { - - StringTokenizer st = new StringTokenizer(target.getAvailableVirtualDatacenters(), ","); - - while (st.hasMoreTokens()) { - ids.add(Integer.parseInt(st.nextToken())); - } - } - - return ids; - } - - private void setAvailableVirtualDatacenters(final List<Integer> ids) { - if (ids == null || ids.size() == 0) { - target.setAvailableVirtualDatacenters(""); - } else { - Joiner joiner = Joiner.on(",").skipNulls(); - target.setAvailableVirtualDatacenters(joiner.join(ids)); - } - } - - @Override - public String toString() { - return "User [id=" + getId() + ", role=" + getRole() + ", authType=" + getAuthType() + ", description=" - + getDescription() + ", email=" + getEmail() + ", locale=" + getLocale() + ", name=" + getName() - + ", nick=" + getNick() + ", password=" + getPassword() + ", surname=" + getSurname() + ", active=" - + isActive() + "]"; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/options/EnterpriseOptions.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/options/EnterpriseOptions.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/options/EnterpriseOptions.java deleted file mode 100644 index 858c662..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/options/EnterpriseOptions.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.abiquo.domain.enterprise.options; - -import org.jclouds.abiquo.domain.options.FilterOptions.BaseFilterOptionsBuilder; -import org.jclouds.http.options.BaseHttpRequestOptions; -import org.jclouds.rest.annotations.SinceApiVersion; - -/** - * Available options to query enterprises. - */ -public class EnterpriseOptions extends BaseHttpRequestOptions { - public static Builder builder() { - return new Builder(); - } - - @Override - protected Object clone() throws CloneNotSupportedException { - EnterpriseOptions options = new EnterpriseOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } - - public static class Builder extends BaseFilterOptionsBuilder<Builder> { - private String idPricingTemplate; - - private String idScope; - - private Boolean included; - - public Builder pricingTemplate(final String idPricingTemplate) { - this.idPricingTemplate = idPricingTemplate; - return this; - } - - @SinceApiVersion("2.3") - public Builder scope(final String scope) { - this.idScope = scope; - return this; - } - - public Builder included(final boolean included) { - this.included = included; - return this; - } - - public EnterpriseOptions build() { - EnterpriseOptions options = new EnterpriseOptions(); - - if (idPricingTemplate != null) { - options.queryParameters.put("idPricingTemplate", String.valueOf(idPricingTemplate)); - } - - if (idScope != null) { - options.queryParameters.put("idScope", String.valueOf(idScope)); - } - - if (included != null) { - options.queryParameters.put("included", String.valueOf(included)); - } - - return addFilterOptions(options); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/options/UserOptions.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/options/UserOptions.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/options/UserOptions.java deleted file mode 100644 index 1e07210..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/domain/enterprise/options/UserOptions.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.abiquo.domain.enterprise.options; - -import org.jclouds.abiquo.domain.options.FilterOptions.BaseFilterOptionsBuilder; -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Available options to query users. - */ -public class UserOptions extends BaseHttpRequestOptions implements Cloneable { - public static Builder builder() { - return new Builder(); - } - - @Override - protected Object clone() throws CloneNotSupportedException { - UserOptions options = new UserOptions(); - options.queryParameters.putAll(queryParameters); - return options; - } - - public static class Builder extends BaseFilterOptionsBuilder<Builder> { - - private final UserOptions options = new UserOptions(); - - public Builder page(int page) { - this.options.queryParameters.put("page", String.valueOf(page)); - return this; - } - - @Override - public Builder limit(int limit) { - this.options.queryParameters.put("numResults", String.valueOf(limit)); - return this; - } - - public UserOptions build() { - return addFilterOptions(this.options); - } - } -}
