You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2014/11/27 15:32:32 UTC
[17/24] jclouds-labs git commit: JCLOUDS-785: Leave only Abiquo
skeleton to start coding Abiquo 3 provider
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/network/NetworkServiceType.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/NetworkServiceType.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/network/NetworkServiceType.java
deleted file mode 100644
index ae3e68e..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/NetworkServiceType.java
+++ /dev/null
@@ -1,128 +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.network;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.abiquo.domain.infrastructure.Datacenter;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.infrastructure.network.NetworkServiceTypeDto;
-
-/**
- * Network Service Type defines a network service.
- *
- * The network Service Type is used to select the network interface of the
- * target host where a NIC in the virtual machine will be attached.
- *
- * They are scoped at {@link Datacenter} level: two {@link NetworkServiceType}
- * can have the same name if they belong to a different {@link Datacenter}
- */
-public class NetworkServiceType extends DomainWrapper<NetworkServiceTypeDto> {
- public static Builder builder(final ApiContext<AbiquoApi> context, final Datacenter datacenter) {
- return new Builder(context, datacenter);
- }
-
- /**
- * Helper class to build {@link NetworkServiceType} in a controlled way.
- *
- */
- public static class Builder {
- private ApiContext<AbiquoApi> context;
-
- private Datacenter datacenter;
-
- private String name;
-
- public Builder(final ApiContext<AbiquoApi> context, final Datacenter datacenter) {
- super();
- checkNotNull(datacenter, ValidationErrors.NULL_RESOURCE + Datacenter.class);
- this.datacenter = datacenter;
- this.context = context;
- }
-
- public NetworkServiceType build() {
- NetworkServiceTypeDto dto = new NetworkServiceTypeDto();
- dto.setName(this.name);
-
- NetworkServiceType nst = new NetworkServiceType(context, dto);
- nst.datacenter = this.datacenter;
- return nst;
- }
-
- public Builder name(final String name) {
- this.name = checkNotNull(name, ValidationErrors.MISSING_REQUIRED_FIELD + name);
- return this;
- }
- }
-
- /** The datacenter where the NetworkServiceType belongs. */
- private Datacenter datacenter;
-
- /** Constructor will only be used by the builder. */
- protected NetworkServiceType(final ApiContext<AbiquoApi> context, final NetworkServiceTypeDto target) {
- super(context, target);
- }
-
- /**
- * Delete the Network Service Type.
- */
- public void delete() {
- context.getApi().getInfrastructureApi().deleteNetworkServiceType(target);
- target = null;
- }
-
- /**
- * Create a new Network Service Type
- */
- public void save() {
- target = context.getApi().getInfrastructureApi().createNetworkServiceType(datacenter.unwrap(), target);
- }
-
- /**
- * Update Network Service Type information in the server with the data from
- * this NST.
- */
- public void update() {
- target = context.getApi().getInfrastructureApi().updateNetworkServiceType(target);
- }
-
- public Integer getId() {
- return target.getId();
- }
-
- public String getName() {
- return target.getName();
- }
-
- public Boolean isDefaultNST() {
- return target.isDefaultNST();
- }
-
- public void setName(final String name) {
- target.setName(name);
- }
-
- @Override
- public String toString() {
- return "NetworkServiceType [id=" + getId() + ", name=" + getName() + ", isDefault=" + isDefaultNST() + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Nic.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Nic.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Nic.java
deleted file mode 100644
index ee39f80..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/Nic.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.network;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.infrastructure.network.NicDto;
-
-/**
- * Adds high level functionality to {@link NicDto}.
- *
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/VirtualMachineNetworkConfiguration"
- * > http://community.abiquo.com/display/ABI20/
- * VirtualMachineNetworkConfiguration</a>
- */
-public class Nic extends DomainWrapper<NicDto> {
- /**
- * Constructor to be used only by the builder (if any).
- */
- protected Nic(final ApiContext<AbiquoApi> context, final NicDto target) {
- super(context, target);
- }
-
- // Parent access
-
- // Delegate methods
-
- public Integer getId() {
- return target.getId();
- }
-
- public String getIp() {
- return target.getIp();
- }
-
- public String getMac() {
- return target.getMac();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PrivateIp.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PrivateIp.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PrivateIp.java
deleted file mode 100644
index 3bf7596..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PrivateIp.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.abiquo.domain.network;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.abiquo.reference.rest.ParentLinkName;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.model.enumerator.NetworkType;
-import com.abiquo.model.rest.RESTLink;
-import com.abiquo.server.core.infrastructure.network.PrivateIpDto;
-import com.abiquo.server.core.infrastructure.network.VLANNetworkDto;
-import com.google.inject.TypeLiteral;
-
-/**
- * Adds generic high level functionality to {@link PrivateIpDto}.
- */
-public class PrivateIp extends Ip<PrivateIpDto, PrivateNetwork> {
- /**
- * Constructor to be used only by the builder.
- */
- protected PrivateIp(final ApiContext<AbiquoApi> context, final PrivateIpDto target) {
- super(context, target);
- }
-
- // Domain operations
-
- @Override
- public PrivateNetwork getNetwork() {
- RESTLink link = checkNotNull(target.searchLink(ParentLinkName.PRIVATE_NETWORK),
- ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.PRIVATE_NETWORK);
-
- HttpResponse response = context.getApi().get(link);
-
- ParseXMLWithJAXB<VLANNetworkDto> parser = new ParseXMLWithJAXB<VLANNetworkDto>(context.utils().xml(),
- TypeLiteral.get(VLANNetworkDto.class));
-
- return wrap(context, PrivateNetwork.class, parser.apply(response));
- }
-
- @Override
- public NetworkType getNetworkType() {
- return NetworkType.INTERNAL;
- }
-
- @Override
- public String toString() {
- return "PrivateIp [networkType=" + getNetworkType() + ", id=" + getId() + ", ip=" + getIp() + ", mac=" + getMac()
- + ", name=" + getName() + ", networkName=" + getNetworkName() + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PrivateNetwork.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PrivateNetwork.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PrivateNetwork.java
deleted file mode 100644
index 75d9931..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PrivateNetwork.java
+++ /dev/null
@@ -1,165 +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.network;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.PaginatedCollection;
-import org.jclouds.abiquo.domain.cloud.VirtualDatacenter;
-import org.jclouds.abiquo.domain.network.options.IpOptions;
-import org.jclouds.collect.PagedIterable;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.model.enumerator.NetworkType;
-import com.abiquo.server.core.infrastructure.network.PrivateIpDto;
-import com.abiquo.server.core.infrastructure.network.PrivateIpsDto;
-import com.abiquo.server.core.infrastructure.network.VLANNetworkDto;
-
-/**
- * Adds high level functionality to private {@link VLANNetworkDto}.
- *
- * @see API: <a
- * href="http://community.abiquo.com/display/ABI20/Private+Network+Resource"
- * > http://community.abiquo.com/display/ABI20/Private+Network+Resource</a>
- */
-public class PrivateNetwork extends Network<PrivateIp> {
- /** The virtual datacenter where the network belongs. */
- private VirtualDatacenter virtualDatacenter;
-
- /**
- * Constructor to be used only by the builder.
- */
- protected PrivateNetwork(final ApiContext<AbiquoApi> context, final VLANNetworkDto target) {
- super(context, target);
- }
-
- // Domain operations
-
- /**
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Private+Network+Resource#PrivateNetworkResource-DeleteaPrivateNetwork"
- * > http://community.abiquo.com/display/ABI20/Private+Network+Resource#
- * PrivateNetworkResource -DeleteaPrivateNetwork</a>
- */
- @Override
- public void delete() {
- context.getApi().getCloudApi().deletePrivateNetwork(target);
- target = null;
- }
-
- /**
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Private+Network+Resource#PrivateNetworkResource-CreateaPrivateNetwork"
- * > http://community.abiquo.com/display/ABI20/Private+Network+Resource#
- * PrivateNetworkResource -CreateaPrivateNetwork</a>
- */
- @Override
- public void save() {
- target = context.getApi().getCloudApi().createPrivateNetwork(virtualDatacenter.unwrap(), target);
- }
-
- /**
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Private+Network+Resource#PrivateNetworkResource-UpdateaPrivateNetwork"
- * > http://community.abiquo.com/display/ABI20/Private+Network+Resource#
- * PrivateNetworkResource -UpdateaPrivateNetwork</a>
- */
- @Override
- public void update() {
- target = context.getApi().getCloudApi().updatePrivateNetwork(target);
- }
-
- @Override
- public Iterable<PrivateIp> listIps() {
- PagedIterable<PrivateIpDto> ips = context.getApi().getCloudApi().listPrivateNetworkIps(target);
- return wrap(context, PrivateIp.class, ips.concat());
- }
-
- @Override
- public Iterable<PrivateIp> listIps(final IpOptions options) {
- PaginatedCollection<PrivateIpDto, PrivateIpsDto> ips = context.getApi().getCloudApi()
- .listPrivateNetworkIps(target, options);
- return wrap(context, PrivateIp.class, ips.toPagedIterable().concat());
- }
-
- // Override to apply the filter in the server side
- @Override
- public Iterable<PrivateIp> listUnusedIps() {
- IpOptions options = IpOptions.builder().free(true).build();
- PaginatedCollection<PrivateIpDto, PrivateIpsDto> ips = context.getApi().getCloudApi()
- .listPrivateNetworkIps(target, options);
- return wrap(context, PrivateIp.class, ips.toPagedIterable().concat());
- }
-
- @Override
- public PrivateIp getIp(final Integer id) {
- PrivateIpDto ip = context.getApi().getCloudApi().getPrivateNetworkIp(target, id);
- return wrap(context, PrivateIp.class, ip);
- }
-
- // Builder
-
- public static Builder builder(final ApiContext<AbiquoApi> context) {
- return new Builder(context);
- }
-
- public static class Builder extends NetworkBuilder<Builder> {
- private VirtualDatacenter virtualDatacenter;
-
- public Builder(final ApiContext<AbiquoApi> context) {
- super(context);
- this.context = context;
- }
-
- public Builder virtualDatacenter(final VirtualDatacenter virtualDatacenter) {
- this.virtualDatacenter = virtualDatacenter;
- return this;
- }
-
- public PrivateNetwork build() {
- VLANNetworkDto dto = new VLANNetworkDto();
- dto.setName(name);
- dto.setTag(tag);
- dto.setGateway(gateway);
- dto.setAddress(address);
- dto.setMask(mask);
- dto.setPrimaryDNS(primaryDNS);
- dto.setSecondaryDNS(secondaryDNS);
- dto.setSufixDNS(suffixDNS);
- dto.setDefaultNetwork(defaultNetwork);
- dto.setUnmanaged(false);
- dto.setType(NetworkType.INTERNAL);
-
- PrivateNetwork network = new PrivateNetwork(context, dto);
- network.virtualDatacenter = virtualDatacenter;
-
- return network;
- }
-
- public static Builder fromPrivateNetwork(final PrivateNetwork in) {
- return PrivateNetwork.builder(in.context).name(in.getName()).tag(in.getTag()).gateway(in.getGateway())
- .address(in.getAddress()).mask(in.getMask()).primaryDNS(in.getPrimaryDNS())
- .secondaryDNS(in.getSecondaryDNS()).suffixDNS(in.getSuffixDNS()).defaultNetwork(in.getDefaultNetwork())
- .virtualDatacenter(in.virtualDatacenter);
- }
- }
-
- @Override
- public String toString() {
- return "Private " + super.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PublicIp.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PublicIp.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PublicIp.java
deleted file mode 100644
index 07b33b8..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PublicIp.java
+++ /dev/null
@@ -1,70 +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.network;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.abiquo.reference.rest.ParentLinkName;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.model.enumerator.NetworkType;
-import com.abiquo.model.rest.RESTLink;
-import com.abiquo.server.core.infrastructure.network.PublicIpDto;
-import com.abiquo.server.core.infrastructure.network.VLANNetworkDto;
-import com.google.inject.TypeLiteral;
-
-/**
- * Adds generic high level functionality to {@link PublicIpDto}.
- */
-public class PublicIp extends AbstractPublicIp<PublicIpDto, PublicNetwork> {
- /**
- * Constructor to be used only by the builder.
- */
- protected PublicIp(final ApiContext<AbiquoApi> context, final PublicIpDto target) {
- super(context, target);
- }
-
- @Override
- public PublicNetwork getNetwork() {
- RESTLink link = checkNotNull(target.searchLink(ParentLinkName.PUBLIC_NETWORK),
- ValidationErrors.MISSING_REQUIRED_LINK + ParentLinkName.PUBLIC_NETWORK);
-
- HttpResponse response = context.getApi().get(link);
-
- ParseXMLWithJAXB<VLANNetworkDto> parser = new ParseXMLWithJAXB<VLANNetworkDto>(context.utils().xml(),
- TypeLiteral.get(VLANNetworkDto.class));
-
- return wrap(context, PublicNetwork.class, parser.apply(response));
- }
-
- @Override
- public NetworkType getNetworkType() {
- return NetworkType.PUBLIC;
- }
-
- @Override
- public String toString() {
- return "PublicIp [networkType=" + getNetworkType() + ", available=" + isAvailable() + ", quarantine="
- + isQuarantine() + ", id=" + getId() + ", ip=" + getIp() + ", mac=" + getMac() + ", name=" + getName()
- + ", networkName=" + getNetworkName() + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PublicNetwork.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PublicNetwork.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PublicNetwork.java
deleted file mode 100644
index 0aeaba4..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/PublicNetwork.java
+++ /dev/null
@@ -1,190 +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.network;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.PaginatedCollection;
-import org.jclouds.abiquo.domain.infrastructure.Datacenter;
-import org.jclouds.abiquo.domain.network.options.IpOptions;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.abiquo.reference.rest.ParentLinkName;
-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.enumerator.NetworkType;
-import com.abiquo.model.rest.RESTLink;
-import com.abiquo.server.core.infrastructure.DatacenterDto;
-import com.abiquo.server.core.infrastructure.network.PublicIpDto;
-import com.abiquo.server.core.infrastructure.network.PublicIpsDto;
-import com.abiquo.server.core.infrastructure.network.VLANNetworkDto;
-import com.google.common.base.Optional;
-import com.google.inject.TypeLiteral;
-
-/**
- * Adds high level functionality to public {@link VLANNetworkDto}.
- *
- * @see API: <a
- * href="http://community.abiquo.com/display/ABI20/Public+Network+Resource"
- * > http://community.abiquo.com/display/ABI20/Public+Network+Resource</a>
- */
-public class PublicNetwork extends Network<PublicIp> {
- /** The datacenter where the network belongs. */
- private Datacenter datacenter;
-
- /**
- * Constructor to be used only by the builder.
- */
- protected PublicNetwork(final ApiContext<AbiquoApi> context, final VLANNetworkDto target) {
- super(context, target);
- }
-
- /**
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Public+Network+Resource#PublicNetworkResource-DeleteaPublicNetwork"
- * > http://community.abiquo.com/display/ABI20/Public+Network+Resource#
- * PublicNetworkResource -DeleteaPublicNetwork</a>
- */
- @Override
- public void delete() {
- context.getApi().getInfrastructureApi().deleteNetwork(target);
- target = null;
- }
-
- /**
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Public+Network+Resource#PublicNetworkResource-CreateanewPublicNetwork"
- * > http://community.abiquo.com/display/ABI20/Public+Network+Resource#
- * PublicNetworkResource -CreateanewPublicNetwork</a>
- */
- @Override
- public void save() {
- target = context.getApi().getInfrastructureApi().createNetwork(datacenter.unwrap(), target);
- }
-
- /**
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Public+Network+Resource#PublicNetworkResource-UpdateaPublicNetwork"
- * > http://community.abiquo.com/display/ABI20/Public+Network+Resource#
- * PublicNetworkResource -UpdateaPublicNetwork</a>
- */
- @Override
- public void update() {
- target = context.getApi().getInfrastructureApi().updateNetwork(target);
- }
-
- @Override
- public Iterable<PublicIp> listIps() {
- PagedIterable<PublicIpDto> ips = context.getApi().getInfrastructureApi().listPublicIps(target);
- return wrap(context, PublicIp.class, ips.concat());
- }
-
- @Override
- public Iterable<PublicIp> listIps(final IpOptions options) {
- PaginatedCollection<PublicIpDto, PublicIpsDto> ips = context.getApi().getInfrastructureApi()
- .listPublicIps(target, options);
- return wrap(context, PublicIp.class, ips.toPagedIterable().concat());
- }
-
- @Override
- public PublicIp getIp(final Integer id) {
- PublicIpDto ip = context.getApi().getInfrastructureApi().getPublicIp(target, id);
- return wrap(context, PublicIp.class, ip);
- }
-
- // Parent access
-
- public Datacenter getDatacenter() {
- RESTLink link = checkNotNull(target.searchLink(ParentLinkName.DATACENTER), ValidationErrors.MISSING_REQUIRED_LINK
- + " " + ParentLinkName.DATACENTER);
-
- HttpResponse response = context.getApi().get(link);
-
- ParseXMLWithJAXB<DatacenterDto> parser = new ParseXMLWithJAXB<DatacenterDto>(context.utils().xml(),
- TypeLiteral.get(DatacenterDto.class));
-
- datacenter = wrap(context, Datacenter.class, parser.apply(response));
- return datacenter;
- }
-
- // Builder
-
- public static Builder builder(final ApiContext<AbiquoApi> context, final Datacenter datacenter) {
- return new Builder(context, datacenter);
- }
-
- public static class Builder extends NetworkBuilder<Builder> {
- private Datacenter datacenter;
-
- private Optional<NetworkServiceType> networkServiceType = Optional.absent();
-
- public Builder(final ApiContext<AbiquoApi> context, final Datacenter datacenter) {
- super(context);
- this.datacenter = checkNotNull(datacenter,
- ValidationErrors.NULL_RESOURCE + Datacenter.class.getCanonicalName());
- this.context = context;
- }
-
- public Builder datacenter(final Datacenter datacenter) {
- this.datacenter = checkNotNull(datacenter,
- ValidationErrors.NULL_RESOURCE + Datacenter.class.getCanonicalName());
- return this;
- }
-
- public Builder networkServiceType(final NetworkServiceType networkServiceType) {
- this.networkServiceType = Optional.of(networkServiceType);
- return this;
- }
-
- public PublicNetwork build() {
- VLANNetworkDto dto = new VLANNetworkDto();
- dto.setName(name);
- dto.setTag(tag);
- dto.setGateway(gateway);
- dto.setAddress(address);
- dto.setMask(mask);
- dto.setPrimaryDNS(primaryDNS);
- dto.setSecondaryDNS(secondaryDNS);
- dto.setSufixDNS(suffixDNS);
- dto.setDefaultNetwork(defaultNetwork);
- dto.setUnmanaged(false);
- dto.setType(NetworkType.PUBLIC);
-
- NetworkServiceType nst = networkServiceType.or(datacenter.defaultNetworkServiceType());
- dto.addLink(new RESTLink("networkservicetype", nst.unwrap().getEditLink().getHref()));
-
- PublicNetwork network = new PublicNetwork(context, dto);
- network.datacenter = datacenter;
-
- return network;
- }
-
- public static Builder fromPublicNetwork(final PublicNetwork in) {
- return PublicNetwork.builder(in.context, in.datacenter).name(in.getName()).tag(in.getTag())
- .gateway(in.getGateway()).address(in.getAddress()).mask(in.getMask()).primaryDNS(in.getPrimaryDNS())
- .secondaryDNS(in.getSecondaryDNS()).suffixDNS(in.getSuffixDNS()).defaultNetwork(in.getDefaultNetwork());
- }
- }
-
- @Override
- public String toString() {
- return "Public " + super.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/network/UnmanagedIp.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/UnmanagedIp.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/network/UnmanagedIp.java
deleted file mode 100644
index e3579ec..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/UnmanagedIp.java
+++ /dev/null
@@ -1,72 +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.network;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.abiquo.reference.rest.ParentLinkName;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.model.enumerator.NetworkType;
-import com.abiquo.model.rest.RESTLink;
-import com.abiquo.server.core.infrastructure.network.UnmanagedIpDto;
-import com.abiquo.server.core.infrastructure.network.VLANNetworkDto;
-import com.google.inject.TypeLiteral;
-
-/**
- * Adds generic high level functionality to {@link UnmanagedIpDto}.
- */
-public class UnmanagedIp extends AbstractPublicIp<UnmanagedIpDto, UnmanagedNetwork> {
- /**
- * Constructor to be used only by the builder.
- */
- protected UnmanagedIp(final ApiContext<AbiquoApi> context, final UnmanagedIpDto target) {
- super(context, target);
- }
-
- // Domain operations
-
- @Override
- public UnmanagedNetwork getNetwork() {
- RESTLink link = checkNotNull(target.searchLink(ParentLinkName.UNMANAGED_NETWORK),
- ValidationErrors.MISSING_REQUIRED_LINK + " " + ParentLinkName.UNMANAGED_NETWORK);
-
- HttpResponse response = context.getApi().get(link);
-
- ParseXMLWithJAXB<VLANNetworkDto> parser = new ParseXMLWithJAXB<VLANNetworkDto>(context.utils().xml(),
- TypeLiteral.get(VLANNetworkDto.class));
-
- return wrap(context, UnmanagedNetwork.class, parser.apply(response));
- }
-
- @Override
- public NetworkType getNetworkType() {
- return NetworkType.UNMANAGED;
- }
-
- @Override
- public String toString() {
- return "UnmanagedIp [networkType=" + getNetworkType() + ", available=" + isAvailable() + ", quarantine="
- + isQuarantine() + ", id=" + getId() + ", ip=" + getIp() + ", mac=" + getMac() + ", name=" + getName()
- + ", networkName=" + getNetworkName() + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/network/UnmanagedNetwork.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/UnmanagedNetwork.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/network/UnmanagedNetwork.java
deleted file mode 100644
index 3980a42..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/UnmanagedNetwork.java
+++ /dev/null
@@ -1,233 +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.network;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.PaginatedCollection;
-import org.jclouds.abiquo.domain.enterprise.Enterprise;
-import org.jclouds.abiquo.domain.infrastructure.Datacenter;
-import org.jclouds.abiquo.domain.network.options.IpOptions;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.abiquo.reference.rest.ParentLinkName;
-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.enumerator.NetworkType;
-import com.abiquo.model.rest.RESTLink;
-import com.abiquo.server.core.enterprise.EnterpriseDto;
-import com.abiquo.server.core.infrastructure.DatacenterDto;
-import com.abiquo.server.core.infrastructure.network.UnmanagedIpDto;
-import com.abiquo.server.core.infrastructure.network.UnmanagedIpsDto;
-import com.abiquo.server.core.infrastructure.network.VLANNetworkDto;
-import com.google.common.base.Optional;
-import com.google.inject.TypeLiteral;
-
-/**
- * Adds high level functionality to external {@link VLANNetworkDto}.
- *
- * @see API: <a
- * href="http://community.abiquo.com/display/ABI20/Public+Network+Resource"
- * > http://community.abiquo.com/display/ABI20/Public+Network+Resource</a>
- */
-public class UnmanagedNetwork extends Network<UnmanagedIp> {
- /** The datacenter where the network belongs. */
- private Datacenter datacenter;
-
- /** The enterprise where the network belongs. */
- private Enterprise enterprise;
-
- /**
- * Constructor to be used only by the builder.
- */
- protected UnmanagedNetwork(final ApiContext<AbiquoApi> context, final VLANNetworkDto target) {
- super(context, target);
- }
-
- /**
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Public+Network+Resource#PublicNetworkResource-DeleteanUnmanagedNetwork"
- * > http://community.abiquo.com/display/ABI20/Public+Network+Resource#
- * PublicNetworkResource -DeleteanUnmanagedNetwork</a>
- */
- @Override
- public void delete() {
- context.getApi().getInfrastructureApi().deleteNetwork(target);
- target = null;
- }
-
- /**
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Public+Network+Resource#PublicNetworkResource-CreateanewUnmanagedNetwork"
- * > http://community.abiquo.com/display/ABI20/Public+Network+Resource#
- * PublicNetworkResource -CreateanewUnmanagedNetwork</a>
- */
- @Override
- public void save() {
- this.addEnterpriseLink();
- target = context.getApi().getInfrastructureApi().createNetwork(datacenter.unwrap(), target);
- }
-
- /**
- * @see API: <a href=
- * "http://community.abiquo.com/display/ABI20/Public+Network+Resource#PublicNetworkResource-UpdateanUnmanagedNetwork"
- * > http://community.abiquo.com/display/ABI20/Public+Network+Resource#
- * PublicNetworkResource -UpdateanUnmanagedNetwork</a>
- */
- @Override
- public void update() {
- target = context.getApi().getInfrastructureApi().updateNetwork(target);
- }
-
- @Override
- public Iterable<UnmanagedIp> listIps() {
- PagedIterable<UnmanagedIpDto> ips = context.getApi().getInfrastructureApi().listUnmanagedIps(target);
- return wrap(context, UnmanagedIp.class, ips.concat());
- }
-
- @Override
- public Iterable<UnmanagedIp> listIps(final IpOptions options) {
- PaginatedCollection<UnmanagedIpDto, UnmanagedIpsDto> ips = context.getApi().getInfrastructureApi()
- .listUnmanagedIps(target, options);
- return wrap(context, UnmanagedIp.class, ips.toPagedIterable().concat());
- }
-
- @Override
- public UnmanagedIp getIp(final Integer id) {
- UnmanagedIpDto ip = context.getApi().getInfrastructureApi().getUnmanagedIp(target, id);
- return wrap(context, UnmanagedIp.class, ip);
- }
-
- // Parent access
-
- public Enterprise getEnterprise() {
- RESTLink link = checkNotNull(target.searchLink(ParentLinkName.ENTERPRISE), ValidationErrors.MISSING_REQUIRED_LINK
- + " " + ParentLinkName.ENTERPRISE);
-
- HttpResponse response = context.getApi().get(link);
-
- ParseXMLWithJAXB<EnterpriseDto> parser = new ParseXMLWithJAXB<EnterpriseDto>(context.utils().xml(),
- TypeLiteral.get(EnterpriseDto.class));
-
- enterprise = wrap(context, Enterprise.class, parser.apply(response));
- return enterprise;
- }
-
- public Datacenter getDatacenter() {
- RESTLink link = checkNotNull(target.searchLink(ParentLinkName.DATACENTER), ValidationErrors.MISSING_REQUIRED_LINK
- + " " + ParentLinkName.DATACENTER);
-
- HttpResponse response = context.getApi().get(link);
-
- ParseXMLWithJAXB<DatacenterDto> parser = new ParseXMLWithJAXB<DatacenterDto>(context.utils().xml(),
- TypeLiteral.get(DatacenterDto.class));
-
- datacenter = wrap(context, Datacenter.class, parser.apply(response));
- return datacenter;
- }
-
- private void addEnterpriseLink() {
- checkNotNull(enterprise, ValidationErrors.NULL_RESOURCE + Enterprise.class);
- checkNotNull(enterprise.getId(),
- ValidationErrors.MISSING_REQUIRED_FIELD + " id in " + Enterprise.class.getCanonicalName());
-
- RESTLink link = enterprise.unwrap().searchLink("edit");
-
- checkNotNull(link, ValidationErrors.MISSING_REQUIRED_LINK);
-
- target.addLink(new RESTLink("enterprise", link.getHref()));
- }
-
- // Builder
-
- public static Builder builder(final ApiContext<AbiquoApi> context, final Datacenter datacenter,
- final Enterprise enterprise) {
- return new Builder(context, datacenter, enterprise);
- }
-
- public static class Builder extends NetworkBuilder<Builder> {
- private Datacenter datacenter;
-
- private Enterprise enterprise;
-
- private Optional<NetworkServiceType> networkServiceType = Optional.absent();
-
- public Builder(final ApiContext<AbiquoApi> context, final Datacenter datacenter, final Enterprise enterprise) {
- super(context);
- this.datacenter = checkNotNull(datacenter,
- ValidationErrors.NULL_RESOURCE + Datacenter.class.getCanonicalName());
- this.enterprise = checkNotNull(enterprise,
- ValidationErrors.NULL_RESOURCE + Enterprise.class.getCanonicalName());
- this.context = context;
- }
-
- public Builder datacenter(final Datacenter datacenter) {
- this.datacenter = checkNotNull(datacenter,
- ValidationErrors.NULL_RESOURCE + Datacenter.class.getCanonicalName());
- return this;
- }
-
- public Builder enterprise(final Enterprise enterprise) {
- this.enterprise = checkNotNull(enterprise,
- ValidationErrors.NULL_RESOURCE + Enterprise.class.getCanonicalName());
- return this;
- }
-
- public Builder networkServiceType(final NetworkServiceType networkServiceType) {
- this.networkServiceType = Optional.of(networkServiceType);
- return this;
- }
-
- public UnmanagedNetwork build() {
- VLANNetworkDto dto = new VLANNetworkDto();
- dto.setName(name);
- dto.setTag(tag);
- dto.setGateway(gateway);
- dto.setAddress(address);
- dto.setMask(mask);
- dto.setPrimaryDNS(primaryDNS);
- dto.setSecondaryDNS(secondaryDNS);
- dto.setSufixDNS(suffixDNS);
- dto.setDefaultNetwork(defaultNetwork);
- dto.setUnmanaged(true);
- dto.setType(NetworkType.UNMANAGED);
-
- NetworkServiceType nst = networkServiceType.or(datacenter.defaultNetworkServiceType());
- dto.getLinks().add(new RESTLink("networkservicetype", nst.unwrap().getEditLink().getHref()));
-
- UnmanagedNetwork network = new UnmanagedNetwork(context, dto);
- network.datacenter = datacenter;
- network.enterprise = enterprise;
-
- return network;
- }
-
- public static Builder fromUnmanagedNetwork(final UnmanagedNetwork in) {
- return UnmanagedNetwork.builder(in.context, in.datacenter, in.enterprise).name(in.getName()).tag(in.getTag())
- .gateway(in.getGateway()).address(in.getAddress()).mask(in.getMask()).primaryDNS(in.getPrimaryDNS())
- .secondaryDNS(in.getSecondaryDNS()).suffixDNS(in.getSuffixDNS()).defaultNetwork(in.getDefaultNetwork());
- }
- }
-
- @Override
- public String toString() {
- return "Unmanaged " + super.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/network/options/IpOptions.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/options/IpOptions.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/network/options/IpOptions.java
deleted file mode 100644
index a1d2f36..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/options/IpOptions.java
+++ /dev/null
@@ -1,55 +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.network.options;
-
-import org.jclouds.abiquo.domain.options.FilterOptions.BaseFilterOptionsBuilder;
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-/**
- * Available options to query ips.
- */
-public class IpOptions extends BaseHttpRequestOptions {
- public static Builder builder() {
- return new Builder();
- }
-
- @Override
- protected Object clone() throws CloneNotSupportedException {
- IpOptions options = new IpOptions();
- options.queryParameters.putAll(queryParameters);
- return options;
- }
-
- public static class Builder extends BaseFilterOptionsBuilder<Builder> {
- private Boolean free;
-
- public Builder free(final boolean free) {
- this.free = free;
- return this;
- }
-
- public IpOptions build() {
- IpOptions options = new IpOptions();
-
- if (free != null) {
- options.queryParameters.put("free", String.valueOf(free));
- }
-
- return addFilterOptions(options);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/network/options/NetworkOptions.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/options/NetworkOptions.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/network/options/NetworkOptions.java
deleted file mode 100644
index df92d99..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/network/options/NetworkOptions.java
+++ /dev/null
@@ -1,67 +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.network.options;
-
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-import com.abiquo.model.enumerator.NetworkType;
-
-/**
- * Available options to query networks.
- */
-public class NetworkOptions extends BaseHttpRequestOptions {
- public static Builder builder() {
- return new Builder();
- }
-
- @Override
- protected Object clone() throws CloneNotSupportedException {
- NetworkOptions options = new NetworkOptions();
- options.queryParameters.putAll(queryParameters);
- return options;
- }
-
- public static class Builder {
- private NetworkType type;
-
- private Boolean all;
-
- public Builder type(final NetworkType type) {
- this.type = type;
- return this;
- }
-
- public Builder all(final boolean all) {
- this.all = all;
- return this;
- }
-
- public NetworkOptions build() {
- NetworkOptions options = new NetworkOptions();
-
- if (type != null) {
- options.queryParameters.put("type", String.valueOf(type));
- }
-
- if (all != null) {
- options.queryParameters.put("all", String.valueOf(all));
- }
-
- return options;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/options/FilterOptions.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/options/FilterOptions.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/options/FilterOptions.java
deleted file mode 100644
index 7f4808d..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/options/FilterOptions.java
+++ /dev/null
@@ -1,108 +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.options;
-
-import org.jclouds.http.options.BaseHttpRequestOptions;
-
-import com.google.common.collect.Multimap;
-
-/**
- * Available options to filter and pagination methods.
- */
-public class FilterOptions extends BaseHttpRequestOptions {
- @Override
- protected Object clone() throws CloneNotSupportedException {
- FilterOptions options = new FilterOptions();
- options.queryParameters.putAll(queryParameters);
- return options;
- }
-
- public static FilterOptionsBuilder builder() {
- return new FilterOptionsBuilder();
- }
-
- public static class FilterOptionsBuilder extends BaseFilterOptionsBuilder<FilterOptionsBuilder> {
- public FilterOptions build() {
- FilterOptions options = new FilterOptions();
- return super.addFilterOptions(options);
- }
- }
-
- @SuppressWarnings("unchecked")
- public static class BaseFilterOptionsBuilder<T extends BaseFilterOptionsBuilder<T>> {
- protected Integer startWith;
-
- protected Integer limit;
-
- protected String by;
-
- protected String has;
-
- protected Boolean asc;
-
- public T startWith(final int startWith) {
- this.startWith = startWith;
- return (T) this;
- }
-
- public T has(final String has) {
- this.has = has;
- return (T) this;
- }
-
- public T limit(final int limit) {
- this.limit = limit;
- return (T) this;
- }
-
- public T orderBy(final String by) {
- this.by = by;
- return (T) this;
- }
-
- public T asc(final boolean asc) {
- this.asc = asc;
- return (T) this;
- }
-
- protected <O extends BaseHttpRequestOptions> O addFilterOptions(final O options) {
- Multimap<String, String> queryParameters = options.buildQueryParameters();
-
- if (startWith != null) {
- queryParameters.put("startwith", startWith.toString());
- }
-
- if (limit != null) {
- queryParameters.put("limit", limit.toString());
- }
-
- if (has != null) {
- queryParameters.put("has", has);
- }
-
- if (by != null) {
- queryParameters.put("by", by);
- }
-
- if (asc != null) {
- queryParameters.put("asc", asc.toString());
- }
-
- return options;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/task/AsyncJob.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/task/AsyncJob.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/task/AsyncJob.java
deleted file mode 100644
index 36872b4..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/task/AsyncJob.java
+++ /dev/null
@@ -1,70 +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.task;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.task.Job.JobState;
-import com.abiquo.server.core.task.Job.JobType;
-import com.abiquo.server.core.task.JobDto;
-
-/**
- * Adds generic high level functionality to {JobDto}.
- */
-public class AsyncJob extends DomainWrapper<JobDto> {
- /**
- * Constructor to be used only by the builder.
- */
- protected AsyncJob(final ApiContext<AbiquoApi> context, final JobDto target) {
- super(context, target);
- }
-
- // Delegate methods
-
- public String getDescription() {
- return target.getDescription();
- }
-
- public String getId() {
- return target.getId();
- }
-
- public JobState getRollbackState() {
- return target.getRollbackState();
- }
-
- public JobState getState() {
- return target.getState();
- }
-
- public long getTimestamp() {
- return target.getTimestamp();
- }
-
- public JobType getType() {
- return target.getType();
- }
-
- @Override
- public String toString() {
- return "AsyncJob [id=" + getId() + ", description=" + getDescription() + ", rollbackState=" + getRollbackState()
- + ", state=" + getState() + ", timestamp=" + getTimestamp() + ", type=" + getType() + "]";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/task/AsyncTask.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/task/AsyncTask.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/task/AsyncTask.java
deleted file mode 100644
index 50018c3..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/task/AsyncTask.java
+++ /dev/null
@@ -1,141 +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.task;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.DomainWrapper;
-import org.jclouds.abiquo.reference.ValidationErrors;
-import org.jclouds.abiquo.reference.rest.ParentLinkName;
-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.model.transport.SingleResourceTransportDto;
-import com.abiquo.server.core.task.TaskDto;
-import com.abiquo.server.core.task.enums.TaskState;
-import com.abiquo.server.core.task.enums.TaskType;
-import com.google.inject.TypeLiteral;
-
-/**
- * Adds generic high level functionality to {TaskDto}.
- *
- * @param <T>
- * The type of the result generated by the task.
- * @param <D>
- * The type of the dto generated by the task.
- */
-public abstract class AsyncTask<T extends DomainWrapper<D>, D extends SingleResourceTransportDto> extends
- DomainWrapper<TaskDto> {
- /** The type of the result generated by the task. */
- private Class<T> resultDomainClass;
-
- /** The type of the dto generated by the task. */
- private Class<D> resultDtoClass;
-
- /**
- * Constructor to be used only by the builder.
- */
- protected AsyncTask(final ApiContext<AbiquoApi> context, final TaskDto target, final Class<T> resultDomainClass,
- final Class<D> resultDtoClass) {
- super(context, target);
- this.resultDomainClass = resultDomainClass;
- this.resultDtoClass = resultDtoClass;
- }
-
- // Domain operations
-
- /**
- * Refresh the state of the task.
- */
- @Override
- public void refresh() {
- RESTLink self = checkNotNull(target.searchLink("self"), ValidationErrors.MISSING_REQUIRED_LINK + "self");
-
- target = context.getApi().getTaskApi().getTask(self);
- }
-
- public T getResult() {
- RESTLink link = target.searchLink(ParentLinkName.TASK_RESULT);
- if (link == null) {
- // The task may still be in progress or has failed
- return null;
- }
-
- HttpResponse response = context.getApi().get(link);
- ParseXMLWithJAXB<D> parser = new ParseXMLWithJAXB<D>(context.utils().xml(), TypeLiteral.get(resultDtoClass));
-
- return wrap(context, resultDomainClass, parser.apply(response));
- }
-
- // Children access
-
- /**
- * Get the individual jobs that compose the current task.
- */
- public Iterable<AsyncJob> getJobs() {
- return wrap(context, AsyncJob.class, target.getJobs().getCollection());
- }
-
- // Conversion helpers
-
- public ConversionTask asConversionTask() {
- return ConversionTask.class.cast(this);
- }
-
- public VirtualMachineTask asVirtualMachineTask() {
- return VirtualMachineTask.class.cast(this);
- }
-
- public VirtualMachineTemplateTask asVirtualMachineTemplateTask() {
- return VirtualMachineTemplateTask.class.cast(this);
- }
-
- // Delegate methods
-
- public String getOwnerId() {
- return target.getOwnerId();
- }
-
- public TaskState getState() {
- return target.getState();
- }
-
- public String getTaskId() {
- return target.getTaskId();
- }
-
- public long getTimestamp() {
- return target.getTimestamp();
- }
-
- public TaskType getType() {
- return target.getType();
- }
-
- public String getUserId() {
- return target.getUserId();
- }
-
- @Override
- public String toString() {
- return "AsyncTask [taskId=" + getTaskId() + ", ownerId=" + getOwnerId() + ", timestamp=" + getTimestamp()
- + ", userId=" + getUserId() + ", state=" + getState() + ", type=" + getType() + "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/task/ConversionTask.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/task/ConversionTask.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/task/ConversionTask.java
deleted file mode 100644
index 391e0d3..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/task/ConversionTask.java
+++ /dev/null
@@ -1,40 +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.task;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.cloud.Conversion;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.appslibrary.ConversionDto;
-import com.abiquo.server.core.task.TaskDto;
-
-/**
- * Task that produces a {@link Conversion}.
- */
-public class ConversionTask extends AsyncTask<Conversion, ConversionDto> {
- protected ConversionTask(final ApiContext<AbiquoApi> context, final TaskDto target) {
- super(context, target, Conversion.class, ConversionDto.class);
- }
-
- @Override
- public String toString() {
- return "Conversion" + super.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/task/VirtualMachineTask.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/task/VirtualMachineTask.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/task/VirtualMachineTask.java
deleted file mode 100644
index 09e5d8d..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/task/VirtualMachineTask.java
+++ /dev/null
@@ -1,40 +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.task;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.cloud.VirtualMachine;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.cloud.VirtualMachineWithNodeExtendedDto;
-import com.abiquo.server.core.task.TaskDto;
-
-/**
- * Task that produces a {@link VirtualMachine}.
- */
-public class VirtualMachineTask extends AsyncTask<VirtualMachine, VirtualMachineWithNodeExtendedDto> {
- protected VirtualMachineTask(final ApiContext<AbiquoApi> context, final TaskDto target) {
- super(context, target, VirtualMachine.class, VirtualMachineWithNodeExtendedDto.class);
- }
-
- @Override
- public String toString() {
- return "VirtualMachine" + super.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/task/VirtualMachineTemplateTask.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/task/VirtualMachineTemplateTask.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/task/VirtualMachineTemplateTask.java
deleted file mode 100644
index dbee665..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/task/VirtualMachineTemplateTask.java
+++ /dev/null
@@ -1,40 +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.task;
-
-import org.jclouds.abiquo.AbiquoApi;
-import org.jclouds.abiquo.domain.cloud.VirtualMachineTemplate;
-import org.jclouds.rest.ApiContext;
-
-import com.abiquo.server.core.appslibrary.VirtualMachineTemplateDto;
-import com.abiquo.server.core.task.TaskDto;
-
-/**
- * Task that produces a {@link VirtualMachineTemplate}.
- */
-public class VirtualMachineTemplateTask extends AsyncTask<VirtualMachineTemplate, VirtualMachineTemplateDto> {
- protected VirtualMachineTemplateTask(final ApiContext<AbiquoApi> context, final TaskDto target) {
- super(context, target, VirtualMachineTemplate.class, VirtualMachineTemplateDto.class);
- }
-
- @Override
- public String toString() {
- return "VirtualMachineTemplate" + super.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/domain/util/LinkUtils.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/domain/util/LinkUtils.java b/abiquo/src/main/java/org/jclouds/abiquo/domain/util/LinkUtils.java
deleted file mode 100644
index 62ad535..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/domain/util/LinkUtils.java
+++ /dev/null
@@ -1,55 +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.util;
-
-import static com.google.common.collect.Iterables.filter;
-
-import java.util.List;
-
-import org.jclouds.abiquo.predicates.LinkPredicates;
-
-import com.abiquo.model.rest.RESTLink;
-import com.abiquo.model.transport.SingleResourceTransportDto;
-import com.google.common.collect.ImmutableList;
-
-/**
- * Utility method to work with {@link RESTLink} objects.
- */
-public class LinkUtils {
- /**
- * Get the link that points to the current resource.
- *
- * @param dto
- * The target dto.
- * @return The link to the current resource.
- */
- public static RESTLink getSelfLink(final SingleResourceTransportDto dto) {
- RESTLink link = dto.searchLink("edit");
- return link == null ? dto.searchLink("self") : link;
- }
-
- /**
- * Filter the given link list and return only the links that point to a NIC.
- *
- * @param links
- * The list with the links to filter.
- * @return A list with all links that point to a NIC.
- */
- public static List<RESTLink> filterNicLinks(final List<RESTLink> links) {
- return ImmutableList.copyOf(filter(links, LinkPredicates.isNic()));
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/fallbacks/MovedVolume.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/fallbacks/MovedVolume.java b/abiquo/src/main/java/org/jclouds/abiquo/fallbacks/MovedVolume.java
deleted file mode 100644
index 9d55d3e..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/fallbacks/MovedVolume.java
+++ /dev/null
@@ -1,89 +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.fallbacks;
-
-import static com.google.common.base.Throwables.getCausalChain;
-import static com.google.common.base.Throwables.propagate;
-import static com.google.common.collect.Iterables.find;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import javax.ws.rs.core.Response.Status;
-
-import org.jclouds.Fallback;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.HttpResponseException;
-import org.jclouds.http.functions.ParseXMLWithJAXB;
-import org.jclouds.xml.XMLParser;
-
-import com.abiquo.server.core.infrastructure.storage.MovedVolumeDto;
-import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Predicate;
-import com.google.inject.TypeLiteral;
-
-/**
- * Return false on service error exceptions.
- */
-@Singleton
-public class MovedVolume implements Fallback<VolumeManagementDto> {
-
- @Singleton
- @VisibleForTesting
- static class ReturnMoveVolumeReference extends ParseXMLWithJAXB<MovedVolumeDto> {
- @Inject
- public ReturnMoveVolumeReference(final XMLParser xml, final TypeLiteral<MovedVolumeDto> type) {
- super(xml, type);
- }
-
- }
-
- private ParseXMLWithJAXB<MovedVolumeDto> parser;
-
- @Inject
- public MovedVolume(final ReturnMoveVolumeReference parser) {
- this.parser = parser;
- }
-
- @Override
- public VolumeManagementDto createOrPropagate(Throwable from) throws Exception {
- Throwable exception = find(getCausalChain(from), isMovedException(from), null);
-
- if (exception != null) {
- HttpResponseException responseException = (HttpResponseException) exception;
- HttpResponse response = responseException.getResponse();
-
- return parser.apply(response).getVolume();
- }
-
- throw propagate(from);
- }
-
- private static Predicate<Throwable> isMovedException(final Throwable exception) {
- return new Predicate<Throwable>() {
- @Override
- public boolean apply(final Throwable input) {
- if (input instanceof HttpResponseException) {
- HttpResponse response = ((HttpResponseException) input).getResponse();
- return response != null && response.getStatusCode() == Status.MOVED_PERMANENTLY.getStatusCode();
- }
-
- return false;
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/features/AdminApi.java
----------------------------------------------------------------------
diff --git a/abiquo/src/main/java/org/jclouds/abiquo/features/AdminApi.java b/abiquo/src/main/java/org/jclouds/abiquo/features/AdminApi.java
deleted file mode 100644
index 811c791..0000000
--- a/abiquo/src/main/java/org/jclouds/abiquo/features/AdminApi.java
+++ /dev/null
@@ -1,180 +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.features;
-
-import java.io.Closeable;
-
-import javax.inject.Named;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.abiquo.binders.BindToPath;
-import org.jclouds.abiquo.binders.BindToXMLPayloadAndPath;
-import org.jclouds.abiquo.functions.enterprise.ParseEnterpriseId;
-import org.jclouds.abiquo.http.filters.AbiquoAuthentication;
-import org.jclouds.abiquo.http.filters.AppendApiVersionToMediaType;
-import org.jclouds.abiquo.rest.annotations.EndpointLink;
-import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.JAXBResponseParser;
-import org.jclouds.rest.annotations.ParamParser;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.binders.BindToXMLPayload;
-
-import com.abiquo.server.core.enterprise.EnterpriseDto;
-import com.abiquo.server.core.enterprise.PrivilegesDto;
-import com.abiquo.server.core.enterprise.RoleDto;
-import com.abiquo.server.core.enterprise.RolesDto;
-import com.abiquo.server.core.enterprise.UserDto;
-
-/**
- * Provides synchronous access to Abiquo Admin API.
- *
- * @see API: <a href="http://community.abiquo.com/display/ABI20/API+Reference">
- * http://community.abiquo.com/display/ABI20/API+Reference</a>
- */
-@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class })
-public interface AdminApi extends Closeable {
- /* ********************** User ********************** */
-
- /**
- * Get the information of the current user.
- *
- * @return The information of the current user.
- */
- @Named("user:get")
- @GET
- @Path("/login")
- @Consumes(UserDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- UserDto getCurrentUser();
-
- /* ********************** Role ********************** */
-
- /**
- * List global roles.
- *
- * @return The list of global Roles.
- */
- @Named("role:list")
- @GET
- @Path("/admin/roles")
- @Consumes(RolesDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- RolesDto listRoles();
-
- /**
- * List enterprise roles.
- *
- * @return The list of Roles for the given enterprise.
- */
- @Named("role:list")
- @GET
- @Path("/admin/roles")
- @Consumes(RolesDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- RolesDto listRoles(@QueryParam("identerprise") @ParamParser(ParseEnterpriseId.class) final EnterpriseDto enterprise);
-
- /**
- * Retrieves the role of the given user.
- *
- * @param user
- * The user.
- * @return The role of the user.
- */
- @Named("role:get")
- @GET
- @Consumes(RoleDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- @Fallback(NullOnNotFoundOr404.class)
- RoleDto getRole(@EndpointLink("role") @BinderParam(BindToPath.class) UserDto user);
-
- /**
- * Get the given role.
- *
- * @param roleId
- * The id of the role.
- * @return The role or <code>null</code> if it does not exist.
- */
- @Named("role:get")
- @GET
- @Path("/admin/roles/{role}")
- @Consumes(RoleDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- @Fallback(NullOnNotFoundOr404.class)
- RoleDto getRole(@PathParam("role") Integer roleId);
-
- /**
- * Deletes an existing role.
- *
- * @param role
- * The role to delete.
- */
- @Named("role:delete")
- @DELETE
- void deleteRole(@EndpointLink("edit") @BinderParam(BindToPath.class) RoleDto role);
-
- /**
- * Updates an existing role.
- *
- * @param role
- * The new attributes for the role.
- * @return The updated role.
- */
- @Named("role:update")
- @PUT
- @Produces(RoleDto.BASE_MEDIA_TYPE)
- @Consumes(RoleDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- RoleDto updateRole(@EndpointLink("edit") @BinderParam(BindToXMLPayloadAndPath.class) RoleDto role);
-
- /**
- * Create a new role.
- *
- * @param role
- * The role to be created.
- * @return The created role.
- */
- @Named("role:create")
- @POST
- @Path("/admin/roles")
- @Produces(RoleDto.BASE_MEDIA_TYPE)
- @Consumes(RoleDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- RoleDto createRole(@BinderParam(BindToXMLPayload.class) RoleDto role);
-
- /**
- * Get privileges of the given role.
- *
- * @param role
- * The role.
- * @return The list of privileges.
- */
- @Named("privilege:list")
- @GET
- @Consumes(PrivilegesDto.BASE_MEDIA_TYPE)
- @JAXBResponseParser
- PrivilegesDto listPrivileges(@EndpointLink("privileges") @BinderParam(BindToPath.class) RoleDto role);
-}