http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/domain/Distribution.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/domain/Distribution.java b/packet/src/main/java/org/jclouds/packet/domain/Distribution.java deleted file mode 100644 index 0692d59..0000000 --- a/packet/src/main/java/org/jclouds/packet/domain/Distribution.java +++ /dev/null @@ -1,68 +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.packet.domain; - -import java.util.List; - -import org.jclouds.compute.domain.OsFamily; - -import com.google.common.base.Predicate; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.tryFind; -import static java.util.Arrays.asList; - -public enum Distribution { - - CENTOS(OsFamily.CENTOS, "centos"), - COREOS(OsFamily.COREOS, "coreos"), - DEBIAN(OsFamily.DEBIAN, "debian"), - UBUNTU(OsFamily.UBUNTU, "ubuntu"), - WINDOWS(OsFamily.WINDOWS, "windows"), - UNRECOGNIZED(OsFamily.UNRECOGNIZED, ""); - - private static final List<Distribution> values = asList(Distribution.values()); - - private final OsFamily osFamily; - private final String value; - - private Distribution(OsFamily osFamily, String value) { - this.osFamily = checkNotNull(osFamily, "osFamily cannot be null"); - this.value = checkNotNull(value, "value cannot be null"); - } - - public OsFamily osFamily() { - return this.osFamily; - } - - public String value() { - return this.value; - } - - public static Distribution fromValue(String value) { - return tryFind(values, hasValue(value)).or(UNRECOGNIZED); - } - - private static Predicate<Distribution> hasValue(final String value) { - return new Predicate<Distribution>() { - @Override - public boolean apply(Distribution input) { - return input.value.equalsIgnoreCase(value); - } - }; - } -}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/domain/Facility.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/domain/Facility.java b/packet/src/main/java/org/jclouds/packet/domain/Facility.java deleted file mode 100644 index 3124c7e..0000000 --- a/packet/src/main/java/org/jclouds/packet/domain/Facility.java +++ /dev/null @@ -1,45 +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.packet.domain; - -import java.util.List; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableList; - -@AutoValue -public abstract class Facility { - - public abstract String id(); - public abstract String name(); - public abstract String code(); - public abstract List<String> features(); - @Nullable - public abstract String address(); - - @SerializedNames({"id", "name", "code", "features", "address"}) - public static Facility create(final String id, String name, String code, List<String> features, String address) { - return new AutoValue_Facility(id, name, code, - features == null ? ImmutableList.<String> of() : ImmutableList.copyOf(features), - address); - } - - Facility() {} -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/domain/Href.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/domain/Href.java b/packet/src/main/java/org/jclouds/packet/domain/Href.java deleted file mode 100644 index 493d000..0000000 --- a/packet/src/main/java/org/jclouds/packet/domain/Href.java +++ /dev/null @@ -1,34 +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.packet.domain; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Href { - - public abstract String href(); - - @SerializedNames({ "href" }) - public static Href create(String href) { - return new AutoValue_Href(href); - } - - Href() {} -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/domain/IpAddress.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/domain/IpAddress.java b/packet/src/main/java/org/jclouds/packet/domain/IpAddress.java deleted file mode 100644 index d8b3e1e..0000000 --- a/packet/src/main/java/org/jclouds/packet/domain/IpAddress.java +++ /dev/null @@ -1,59 +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.packet.domain; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class IpAddress { - - public abstract String id(); - public abstract Integer addressFamily(); - public abstract String netmask(); - public abstract Boolean publicAddress(); - public abstract Integer cidr(); - public abstract Boolean management(); - public abstract Boolean manageable(); - public abstract Href assignedTo(); - public abstract String network(); - public abstract String address(); - public abstract String gateway(); - public abstract String href(); - - @SerializedNames({"id", "address_family", "netmask", "public", "cidr", "management", "manageable", "assigned_to", "network", "address", "gateway", "href"}) - public static IpAddress create( - String id, - Integer addressFamily, - String netmask, - Boolean publicAddress, - Integer cidr, - Boolean management, - Boolean manageable, - Href assignedTo, - String network, - String address, - String gateway, - String href - ) { - return new AutoValue_IpAddress(id, addressFamily, netmask, publicAddress, cidr, management, manageable, assignedTo, network, address, gateway, href - ); - } - - IpAddress() {} -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/domain/OperatingSystem.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/domain/OperatingSystem.java b/packet/src/main/java/org/jclouds/packet/domain/OperatingSystem.java deleted file mode 100644 index e491661..0000000 --- a/packet/src/main/java/org/jclouds/packet/domain/OperatingSystem.java +++ /dev/null @@ -1,45 +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.packet.domain; - -import java.util.Set; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableSet; - -@AutoValue -public abstract class OperatingSystem { - - public abstract String id(); - public abstract String slug(); - public abstract String name(); - public abstract String distribution(); - public abstract String version(); - public abstract Set<String> provisionableOn(); - - @SerializedNames({"id", "slug", "name", "distro", "version", "provisionable_on"}) - public static OperatingSystem create(String id, String slug, String name, String distribution, String version, Set<String> provisionableOn) { - return new AutoValue_OperatingSystem(id, slug, name, distribution, version, - provisionableOn == null ? ImmutableSet.<String> of() : ImmutableSet.copyOf(provisionableOn) - ); - } - - OperatingSystem() {} - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/domain/Plan.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/domain/Plan.java b/packet/src/main/java/org/jclouds/packet/domain/Plan.java deleted file mode 100644 index 95683b6..0000000 --- a/packet/src/main/java/org/jclouds/packet/domain/Plan.java +++ /dev/null @@ -1,50 +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.packet.domain; - -import java.util.List; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableList; - -@AutoValue -public abstract class Plan { - - public abstract String id(); - public abstract String slug(); - public abstract String name(); - public abstract String description(); - public abstract String line(); - @Nullable - public abstract Specs specs(); - public abstract List<Href> availableIn(); - public abstract Pricing pricing(); - - @SerializedNames({"id", "slug", "name", "description", "line", "specs", "available_in", "pricing"}) - public static Plan create(final String id, String slug, String name, String description, String line, Specs specs, List<Href> availableIn, Pricing pricing) { - return new AutoValue_Plan(id, slug, name, description, line, - specs, - availableIn == null ? ImmutableList.<Href> of() : ImmutableList.copyOf(availableIn), - pricing - ); - } - - Plan() {} -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/domain/Pricing.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/domain/Pricing.java b/packet/src/main/java/org/jclouds/packet/domain/Pricing.java deleted file mode 100644 index 9ca7435..0000000 --- a/packet/src/main/java/org/jclouds/packet/domain/Pricing.java +++ /dev/null @@ -1,34 +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.packet.domain; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class Pricing { - - public abstract double hour(); - - @SerializedNames({ "hour" }) - public static Pricing create(double hour) { - return new AutoValue_Pricing(hour); - } - - Pricing() {} -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/domain/Project.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/domain/Project.java b/packet/src/main/java/org/jclouds/packet/domain/Project.java deleted file mode 100644 index 69fe077..0000000 --- a/packet/src/main/java/org/jclouds/packet/domain/Project.java +++ /dev/null @@ -1,66 +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.packet.domain; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -@AutoValue -public abstract class Project { - - public abstract String id(); - public abstract String name(); - public abstract Date createdAt(); - public abstract Date updatedAt(); - public abstract Map<String, Object> maxDevices(); - public abstract List<Href> members(); - public abstract List<Href> memberships(); - public abstract List<Href> invitations(); - public abstract Href paymentMethod(); - public abstract List<Href> devices(); - public abstract List<Href> sshKeys(); - public abstract List<Href> volumes(); - public abstract String href(); - - @SerializedNames({"id", "name", "created_at", "updated_at", "max_devices", "members", "memberships", "invitations", "payment_method", "devices", "ssh_keys", "volumes", "href"}) - public static Project create(String id, String name, Date createdAt, Date updatedAt, Map<String, Object> maxDevices, - List<Href> members, List<Href> memberships, List<Href> invitations, Href paymentMethod, - List<Href> devices, - List<Href> sshKeys, - List<Href> volumes, - String href) { - return new AutoValue_Project(id, name, createdAt, updatedAt, - maxDevices == null ? ImmutableMap.<String, Object> of() : ImmutableMap.copyOf(maxDevices), - members == null ? ImmutableList.<Href> of() : ImmutableList.copyOf(members), - memberships == null ? ImmutableList.<Href> of() : ImmutableList.copyOf(memberships), - invitations == null ? ImmutableList.<Href> of() : ImmutableList.copyOf(invitations), - paymentMethod, - devices == null ? ImmutableList.<Href> of() : ImmutableList.copyOf(devices), - sshKeys == null ? ImmutableList.<Href> of() : ImmutableList.copyOf(sshKeys), - volumes == null ? ImmutableList.<Href> of() : ImmutableList.copyOf(volumes), - href); - } - - Project() {} -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/domain/ProvisioningEvent.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/domain/ProvisioningEvent.java b/packet/src/main/java/org/jclouds/packet/domain/ProvisioningEvent.java deleted file mode 100644 index 3df979f..0000000 --- a/packet/src/main/java/org/jclouds/packet/domain/ProvisioningEvent.java +++ /dev/null @@ -1,52 +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.packet.domain; - -import java.util.Date; -import java.util.List; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableList; - -@AutoValue -public abstract class ProvisioningEvent { - - @Nullable - public abstract String id(); - public abstract String type(); - public abstract String body(); - @Nullable - public abstract Date createdAt(); - public abstract List<Href> relationships(); - public abstract String interpolated(); - @Nullable - public abstract String href(); - - @SerializedNames({"id", "type", "body", "created_at", "relationships", "interpolated", "href"}) - public static ProvisioningEvent create(String id, String type, String body, Date createdAt, - List<Href> relationships, String interpolated, String href) { - return new AutoValue_ProvisioningEvent(id, type, body, createdAt, - relationships == null ? ImmutableList.<Href> of() : ImmutableList.copyOf(relationships), - interpolated, - href); - } - - ProvisioningEvent() {} -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/domain/Specs.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/domain/Specs.java b/packet/src/main/java/org/jclouds/packet/domain/Specs.java deleted file mode 100644 index bafd344..0000000 --- a/packet/src/main/java/org/jclouds/packet/domain/Specs.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.packet.domain; - -import java.util.List; -import java.util.Map; - -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -@AutoValue -public abstract class Specs { - - @AutoValue - public abstract static class NIC { - - public abstract Integer count(); - public abstract String type(); - - @SerializedNames({ "count", "type" }) - public static NIC create(Integer count, String type) { - return new AutoValue_Specs_NIC(count, type); - } - } - - @AutoValue - public abstract static class Drive { - - public abstract Integer count(); - public abstract String size(); - public abstract String type(); - - @SerializedNames({ "count", "size", "type" }) - public static Drive create(Integer count, String size, String type) { - return new AutoValue_Specs_Drive(count, size, type); - } - } - - @AutoValue - public abstract static class CPU { - - public abstract Integer count(); - public abstract String type(); - - @SerializedNames({ "count", "type" }) - public static CPU create(Integer count, String type) { - return new AutoValue_Specs_CPU(count, type); - } - } - - @AutoValue - public abstract static class Memory { - - public abstract String total(); - - @SerializedNames({ "total" }) - public static Memory create(String total) { - return new AutoValue_Specs_Memory(total); - } - } - - public abstract List<CPU> cpus(); - public abstract Memory memory(); - public abstract List<Drive> drives(); - public abstract List<NIC> nics(); - public abstract Map<String, Object> features(); - - @SerializedNames({"cpus", "memory", "drives", "nics", "features"}) - public static Specs create(List<CPU> cpus, Memory memory, List<Drive> drives, List<NIC> nics, Map<String, Object> features) { - return new AutoValue_Specs( - cpus == null ? ImmutableList.<CPU> of() : ImmutableList.copyOf(cpus), - memory, - drives == null ? ImmutableList.<Drive> of() : ImmutableList.copyOf(drives), - nics == null ? ImmutableList.<NIC> of() : ImmutableList.copyOf(nics), - features == null ? ImmutableMap.<String, Object> of() : ImmutableMap.copyOf(features) - ); - } - - Specs() {} - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/domain/SshKey.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/domain/SshKey.java b/packet/src/main/java/org/jclouds/packet/domain/SshKey.java deleted file mode 100644 index 82e9c00..0000000 --- a/packet/src/main/java/org/jclouds/packet/domain/SshKey.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.packet.domain; - -import java.util.Date; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; - -import com.google.auto.value.AutoValue; - -@AutoValue -public abstract class SshKey { - - @AutoValue - public abstract static class Owner { - - public abstract String href(); - - @SerializedNames({ "href" }) - public static Owner create(String href) { - return new AutoValue_SshKey_Owner(href); - } - } - - public abstract String id(); - public abstract String label(); - public abstract String key(); - public abstract String fingerprint(); - public abstract Date createdAt(); - public abstract Date updatedAt(); - @Nullable public abstract Owner owner(); - public abstract String href(); - - @SerializedNames({"id", "label", "key", "fingerprint", "created_at", "updated_at", "owner", "href"}) - public static SshKey create(String id, String label, String key, String fingerprint, Date createdAt, Date updatedAt, Owner owner, String href) { - return new AutoValue_SshKey(id, label, key, fingerprint, createdAt, updatedAt, owner, href); - } - - SshKey() {} -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/domain/internal/PaginatedCollection.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/domain/internal/PaginatedCollection.java b/packet/src/main/java/org/jclouds/packet/domain/internal/PaginatedCollection.java deleted file mode 100644 index 14621bc..0000000 --- a/packet/src/main/java/org/jclouds/packet/domain/internal/PaginatedCollection.java +++ /dev/null @@ -1,84 +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.packet.domain.internal; - -import java.util.Iterator; -import java.util.List; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.SerializedNames; -import org.jclouds.packet.domain.Href; - -import com.google.auto.value.AutoValue; -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableList; - -import static com.google.common.base.Preconditions.checkNotNull; - -/** - * Base class for all collections that return paginated results. - */ -public abstract class PaginatedCollection<T> extends IterableWithMarker<T> { - - @AutoValue - public abstract static class Meta { - public abstract long total(); - @Nullable public abstract Href first(); - @Nullable public abstract Href previous(); - @Nullable public abstract Href self(); - @Nullable public abstract Href next(); - @Nullable public abstract Href last(); - - @SerializedNames({ "total", "first", "previous", "self", "next", "last" }) - public static Meta create(long total, Href first, Href previous, Href self, Href next, Href last) { - return new AutoValue_PaginatedCollection_Meta(total, first, previous, self, next, last); - } - - Meta() { } - } - - private final List<T> items; - private final Meta meta; - - protected PaginatedCollection(List<T> items, Meta meta) { - this.items = ImmutableList.copyOf(checkNotNull(items, "items cannot be null")); - this.meta = meta; - } - - public List<T> items() { - return items; - } - - public Meta meta() { - return meta; - } - - @Override - public Iterator<T> iterator() { - return items.iterator(); - } - - @Override - public Optional<Object> nextMarker() { - if (meta == null || meta.next() == null) { - return Optional.absent(); - } - return Optional.fromNullable((Object) meta.next()); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/domain/options/ListOptions.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/domain/options/ListOptions.java b/packet/src/main/java/org/jclouds/packet/domain/options/ListOptions.java deleted file mode 100644 index c858a7f..0000000 --- a/packet/src/main/java/org/jclouds/packet/domain/options/ListOptions.java +++ /dev/null @@ -1,60 +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.packet.domain.options; - -import org.jclouds.http.options.BaseHttpRequestOptions; - -/** - * Options to customize how paginated lists are returned. - */ -public class ListOptions extends BaseHttpRequestOptions { - public static final String PAGE_PARAM = "page"; - public static final String PER_PAGE_PARAM = "per_page"; - - /** - * Configures the number of entries to return in each page. - */ - public ListOptions perPage(int perPage) { - queryParameters.put(PER_PAGE_PARAM, String.valueOf(perPage)); - return this; - } - - /** - * Configures the number of the page to be returned. - */ - public ListOptions page(int page) { - queryParameters.put(PAGE_PARAM, String.valueOf(page)); - return this; - } - - public static final class Builder { - - /** - * @see {@link ListOptions#perPage(int)} - */ - public static ListOptions perPage(int perPage) { - return new ListOptions().perPage(perPage); - } - - /** - * @see {@link ListOptions#page(int)} - */ - public static ListOptions page(int page) { - return new ListOptions().page(page); - } - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/features/DeviceApi.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/features/DeviceApi.java b/packet/src/main/java/org/jclouds/packet/features/DeviceApi.java deleted file mode 100644 index cae9305..0000000 --- a/packet/src/main/java/org/jclouds/packet/features/DeviceApi.java +++ /dev/null @@ -1,163 +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.packet.features; - -import java.beans.ConstructorProperties; -import java.util.List; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.collect.internal.Arg0ToPagedIterable; -import org.jclouds.http.functions.ParseJson; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.Json; -import org.jclouds.packet.PacketApi; -import org.jclouds.packet.domain.Device; -import org.jclouds.packet.domain.Href; -import org.jclouds.packet.domain.internal.PaginatedCollection; -import org.jclouds.packet.domain.options.ListOptions; -import org.jclouds.packet.filters.AddApiVersionToRequest; -import org.jclouds.packet.filters.AddXAuthTokenToRequest; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.Payload; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.Transform; -import org.jclouds.rest.binders.BindToJsonPayload; - -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.inject.TypeLiteral; - -@Consumes(MediaType.APPLICATION_JSON) -@RequestFilters({AddXAuthTokenToRequest.class, AddApiVersionToRequest.class}) -public interface DeviceApi { - - @Named("device:list") - @GET - @Path("/projects/{projectId}/devices") - @ResponseParser(ParseDevices.class) - @Transform(ParseDevices.ToPagedIterable.class) - @Fallback(Fallbacks.EmptyPagedIterableOnNotFoundOr404.class) - PagedIterable<Device> list(); - - @Named("device:list") - @GET - @Path("/projects/{projectId}/devices") - @ResponseParser(ParseDevices.class) - @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class) - IterableWithMarker<Device> list(ListOptions options); - - final class ParseDevices extends ParseJson<ParseDevices.Devices> { - @Inject - ParseDevices(Json json) { - super(json, TypeLiteral.get(Devices.class)); - } - - private static class Devices extends PaginatedCollection<Device> { - @ConstructorProperties({"devices", "meta"}) - public Devices(List<Device> items, Meta meta) { - super(items, meta); - } - } - - public static class ToPagedIterable extends Arg0ToPagedIterable.FromCaller<Device, ToPagedIterable> { - - private final PacketApi api; - private final Function<Href, ListOptions> hrefToOptions; - - @Inject - ToPagedIterable(PacketApi api, Function<Href, ListOptions> hrefToOptions) { - this.api = api; - this.hrefToOptions = hrefToOptions; - } - - @Override - protected Function<Object, IterableWithMarker<Device>> markerToNextForArg0(Optional<Object> arg0) { - String projectId = arg0.get().toString(); - final DeviceApi deviceApi = api.deviceApi(projectId); - return new Function<Object, IterableWithMarker<Device>>() { - - @SuppressWarnings("unchecked") - @Override - public IterableWithMarker<Device> apply(Object input) { - ListOptions listOptions = hrefToOptions.apply(Href.class.cast(input)); - return IterableWithMarker.class.cast(deviceApi.list(listOptions)); - } - - }; - } - } - } - - @Named("device:create") - @POST - @Path("/projects/{projectId}/devices") - @Produces(MediaType.APPLICATION_JSON) - Device create(@BinderParam(BindToJsonPayload.class) Device.CreateDevice device); - - - @Named("device:get") - @GET - @Path("/devices/{id}") - @Fallback(NullOnNotFoundOr404.class) - @Nullable - Device get(@PathParam("id") String id); - - @Named("device:delete") - @DELETE - @Path("/devices/{id}") - @Fallback(VoidOnNotFoundOr404.class) - void delete(@PathParam("id") String id); - - @Named("device:powerOff") - @POST - @Produces(MediaType.APPLICATION_JSON) - @Path("/devices/{id}/actions") - @Payload("{\"type\":\"power_off\"}") - void powerOff(@PathParam("id") String id); - - @Named("device:powerOn") - @POST - @Produces(MediaType.APPLICATION_JSON) - @Path("/devices/{id}/actions") - @Payload("{\"type\":\"power_on\"}") - void powerOn(@PathParam("id") String id); - - @Named("device:reboot") - @POST - @Produces(MediaType.APPLICATION_JSON) - @Path("/devices/{id}/actions") - @Payload("{\"type\":\"reboot\"}") - void reboot(@PathParam("id") String id); - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/features/FacilityApi.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/features/FacilityApi.java b/packet/src/main/java/org/jclouds/packet/features/FacilityApi.java deleted file mode 100644 index bde9898..0000000 --- a/packet/src/main/java/org/jclouds/packet/features/FacilityApi.java +++ /dev/null @@ -1,94 +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.packet.features; - -import java.beans.ConstructorProperties; -import java.util.List; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.http.functions.ParseJson; -import org.jclouds.json.Json; -import org.jclouds.packet.PacketApi; -import org.jclouds.packet.domain.Facility; -import org.jclouds.packet.domain.Href; -import org.jclouds.packet.domain.internal.PaginatedCollection; -import org.jclouds.packet.domain.options.ListOptions; -import org.jclouds.packet.filters.AddApiVersionToRequest; -import org.jclouds.packet.filters.AddXAuthTokenToRequest; -import org.jclouds.packet.functions.BaseToPagedIterable; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.Transform; - -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.inject.TypeLiteral; - -@Path("/facilities") -@Consumes(MediaType.APPLICATION_JSON) -@RequestFilters({ AddXAuthTokenToRequest.class, AddApiVersionToRequest.class} ) -public interface FacilityApi { - - @Named("facility:list") - @GET - @ResponseParser(ParseFacilities.class) - @Transform(ParseFacilities.ToPagedIterable.class) - @Fallback(Fallbacks.EmptyPagedIterableOnNotFoundOr404.class) - PagedIterable<Facility> list(); - - @Named("facility:list") - @GET - @ResponseParser(ParseFacilities.class) - @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class) - IterableWithMarker<Facility> list(ListOptions options); - - final class ParseFacilities extends ParseJson<ParseFacilities.Facilities> { - @Inject - ParseFacilities(Json json) { - super(json, TypeLiteral.get(Facilities.class)); - } - - private static class Facilities extends PaginatedCollection<Facility> { - @ConstructorProperties({ "facilities", "meta" }) - public Facilities(List<Facility> items, Meta meta) { - super(items, meta); - } - } - - private static class ToPagedIterable extends BaseToPagedIterable<Facility, ListOptions> { - @Inject ToPagedIterable(PacketApi api, Function<Href, ListOptions> hrefToOptions) { - super(api, hrefToOptions); - } - - @Override - protected IterableWithMarker<Facility> fetchPageUsingOptions(ListOptions options, Optional<Object> arg0) { - return api.facilityApi().list(options); - } - } - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/features/OperatingSystemApi.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/features/OperatingSystemApi.java b/packet/src/main/java/org/jclouds/packet/features/OperatingSystemApi.java deleted file mode 100644 index 401b1e9..0000000 --- a/packet/src/main/java/org/jclouds/packet/features/OperatingSystemApi.java +++ /dev/null @@ -1,94 +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.packet.features; - -import java.beans.ConstructorProperties; -import java.util.List; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.http.functions.ParseJson; -import org.jclouds.json.Json; -import org.jclouds.packet.PacketApi; -import org.jclouds.packet.domain.Href; -import org.jclouds.packet.domain.OperatingSystem; -import org.jclouds.packet.domain.internal.PaginatedCollection; -import org.jclouds.packet.domain.options.ListOptions; -import org.jclouds.packet.filters.AddApiVersionToRequest; -import org.jclouds.packet.filters.AddXAuthTokenToRequest; -import org.jclouds.packet.functions.BaseToPagedIterable; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.Transform; - -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.inject.TypeLiteral; - -@Path("/operating-systems") -@Consumes(MediaType.APPLICATION_JSON) -@RequestFilters({ AddXAuthTokenToRequest.class, AddApiVersionToRequest.class} ) -public interface OperatingSystemApi { - - @Named("operatingsystem:list") - @GET - @ResponseParser(ParseOperatingSystems.class) - @Transform(ParseOperatingSystems.ToPagedIterable.class) - @Fallback(Fallbacks.EmptyPagedIterableOnNotFoundOr404.class) - PagedIterable<OperatingSystem> list(); - - @Named("operatingsystem:list") - @GET - @ResponseParser(ParseOperatingSystems.class) - @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class) - IterableWithMarker<OperatingSystem> list(ListOptions options); - - final class ParseOperatingSystems extends ParseJson<ParseOperatingSystems.OperatingSystems> { - @Inject - ParseOperatingSystems(Json json) { - super(json, TypeLiteral.get(ParseOperatingSystems.OperatingSystems.class)); - } - - private static class OperatingSystems extends PaginatedCollection<OperatingSystem> { - @ConstructorProperties({ "operating_systems", "meta" }) - public OperatingSystems(List<OperatingSystem> items, Meta meta) { - super(items, meta); - } - } - - private static class ToPagedIterable extends BaseToPagedIterable<OperatingSystem, ListOptions> { - @Inject ToPagedIterable(PacketApi api, Function<Href, ListOptions> hrefToOptions) { - super(api, hrefToOptions); - } - - @Override - protected IterableWithMarker<OperatingSystem> fetchPageUsingOptions(ListOptions options, Optional<Object> arg0) { - return api.operatingSystemApi().list(options); - } - } - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/features/PlanApi.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/features/PlanApi.java b/packet/src/main/java/org/jclouds/packet/features/PlanApi.java deleted file mode 100644 index 7ed5c3a..0000000 --- a/packet/src/main/java/org/jclouds/packet/features/PlanApi.java +++ /dev/null @@ -1,94 +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.packet.features; - -import java.beans.ConstructorProperties; -import java.util.List; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.http.functions.ParseJson; -import org.jclouds.json.Json; -import org.jclouds.packet.PacketApi; -import org.jclouds.packet.domain.Href; -import org.jclouds.packet.domain.Plan; -import org.jclouds.packet.domain.internal.PaginatedCollection; -import org.jclouds.packet.domain.options.ListOptions; -import org.jclouds.packet.filters.AddApiVersionToRequest; -import org.jclouds.packet.filters.AddXAuthTokenToRequest; -import org.jclouds.packet.functions.BaseToPagedIterable; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.Transform; - -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.inject.TypeLiteral; - -@Path("/plans") -@Consumes(MediaType.APPLICATION_JSON) -@RequestFilters({ AddXAuthTokenToRequest.class, AddApiVersionToRequest.class} ) -public interface PlanApi { - - @Named("plan:list") - @GET - @ResponseParser(ParsePlans.class) - @Transform(ParsePlans.ToPagedIterable.class) - @Fallback(Fallbacks.EmptyPagedIterableOnNotFoundOr404.class) - PagedIterable<Plan> list(); - - @Named("plan:list") - @GET - @ResponseParser(ParsePlans.class) - @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class) - IterableWithMarker<Plan> list(ListOptions options); - - final class ParsePlans extends ParseJson<ParsePlans.Plans> { - @Inject - ParsePlans(Json json) { - super(json, TypeLiteral.get(ParsePlans.Plans.class)); - } - - private static class Plans extends PaginatedCollection<Plan> { - @ConstructorProperties({ "plans", "meta" }) - public Plans(List<Plan> items, Meta meta) { - super(items, meta); - } - } - - private static class ToPagedIterable extends BaseToPagedIterable<Plan, ListOptions> { - @Inject ToPagedIterable(PacketApi api, Function<Href, ListOptions> hrefToOptions) { - super(api, hrefToOptions); - } - - @Override - protected IterableWithMarker<Plan> fetchPageUsingOptions(ListOptions options, Optional<Object> arg0) { - return api.planApi().list(options); - } - } - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/features/ProjectApi.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/features/ProjectApi.java b/packet/src/main/java/org/jclouds/packet/features/ProjectApi.java deleted file mode 100644 index 9da50d0..0000000 --- a/packet/src/main/java/org/jclouds/packet/features/ProjectApi.java +++ /dev/null @@ -1,94 +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.packet.features; - -import java.beans.ConstructorProperties; -import java.util.List; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.http.functions.ParseJson; -import org.jclouds.json.Json; -import org.jclouds.packet.PacketApi; -import org.jclouds.packet.domain.Href; -import org.jclouds.packet.domain.Project; -import org.jclouds.packet.domain.internal.PaginatedCollection; -import org.jclouds.packet.domain.options.ListOptions; -import org.jclouds.packet.filters.AddApiVersionToRequest; -import org.jclouds.packet.filters.AddXAuthTokenToRequest; -import org.jclouds.packet.functions.BaseToPagedIterable; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.Transform; - -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.inject.TypeLiteral; - -@Path("/projects") -@Consumes(MediaType.APPLICATION_JSON) -@RequestFilters({ AddXAuthTokenToRequest.class, AddApiVersionToRequest.class} ) -public interface ProjectApi { - - @Named("project:list") - @GET - @ResponseParser(ParseProjects.class) - @Transform(ParseProjects.ToPagedIterable.class) - @Fallback(Fallbacks.EmptyPagedIterableOnNotFoundOr404.class) - PagedIterable<Project> list(); - - @Named("project:list") - @GET - @ResponseParser(ParseProjects.class) - @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class) - IterableWithMarker<Project> list(ListOptions options); - - final class ParseProjects extends ParseJson<ParseProjects.Projects> { - @Inject - ParseProjects(Json json) { - super(json, TypeLiteral.get(Projects.class)); - } - - private static class Projects extends PaginatedCollection<Project> { - @ConstructorProperties({ "projects", "meta" }) - public Projects(List<Project> items, Meta meta) { - super(items, meta); - } - } - - private static class ToPagedIterable extends BaseToPagedIterable<Project, ListOptions> { - @Inject ToPagedIterable(PacketApi api, Function<Href, ListOptions> hrefToOptions) { - super(api, hrefToOptions); - } - - @Override - protected IterableWithMarker<Project> fetchPageUsingOptions(ListOptions options, Optional<Object> arg0) { - return api.projectApi().list(options); - } - } - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/features/SshKeyApi.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/features/SshKeyApi.java b/packet/src/main/java/org/jclouds/packet/features/SshKeyApi.java deleted file mode 100644 index cd22107..0000000 --- a/packet/src/main/java/org/jclouds/packet/features/SshKeyApi.java +++ /dev/null @@ -1,122 +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.packet.features; - -import java.beans.ConstructorProperties; -import java.util.List; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.PagedIterable; -import org.jclouds.http.functions.ParseJson; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.json.Json; -import org.jclouds.packet.PacketApi; -import org.jclouds.packet.domain.Href; -import org.jclouds.packet.domain.SshKey; -import org.jclouds.packet.domain.internal.PaginatedCollection; -import org.jclouds.packet.domain.options.ListOptions; -import org.jclouds.packet.filters.AddApiVersionToRequest; -import org.jclouds.packet.filters.AddXAuthTokenToRequest; -import org.jclouds.packet.functions.BaseToPagedIterable; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.Transform; -import org.jclouds.rest.binders.BindToJsonPayload; - -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.inject.TypeLiteral; - -@Path("/ssh-keys") -@Consumes(MediaType.APPLICATION_JSON) -@RequestFilters({ AddXAuthTokenToRequest.class, AddApiVersionToRequest.class} ) -public interface SshKeyApi { - - @Named("sshkey:list") - @GET - @ResponseParser(ParseSshKeys.class) - @Transform(ParseSshKeys.ToPagedIterable.class) - @Fallback(Fallbacks.EmptyPagedIterableOnNotFoundOr404.class) - PagedIterable<SshKey> list(); - - @Named("sshkey:list") - @GET - @ResponseParser(ParseSshKeys.class) - @Fallback(Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404.class) - IterableWithMarker<SshKey> list(ListOptions options); - - final class ParseSshKeys extends ParseJson<ParseSshKeys.SshKeys> { - @Inject - ParseSshKeys(Json json) { - super(json, TypeLiteral.get(ParseSshKeys.SshKeys.class)); - } - - private static class SshKeys extends PaginatedCollection<SshKey> { - @ConstructorProperties({ "ssh_keys", "meta" }) - public SshKeys(List<SshKey> items, Meta meta) { - super(items, meta); - } - } - - private static class ToPagedIterable extends BaseToPagedIterable<SshKey, ListOptions> { - @Inject ToPagedIterable(PacketApi api, Function<Href, ListOptions> hrefToOptions) { - super(api, hrefToOptions); - } - - @Override - protected IterableWithMarker<SshKey> fetchPageUsingOptions(ListOptions options, Optional<Object> arg0) { - return api.sshKeyApi().list(options); - } - } - } - - @Named("sshkey:create") - @POST - @Produces(MediaType.APPLICATION_JSON) - @MapBinder(BindToJsonPayload.class) - SshKey create(@PayloadParam("label") String label, @PayloadParam("key") String key); - - @Named("sshkey:get") - @GET - @Path("/{id}") - @Fallback(NullOnNotFoundOr404.class) - @Nullable - SshKey get(@PathParam("id") String id); - - @Named("sshkey:delete") - @DELETE - @Path("/{id}") - @Fallback(VoidOnNotFoundOr404.class) - void delete(@PathParam("id") String id); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/filters/AddApiVersionToRequest.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/filters/AddApiVersionToRequest.java b/packet/src/main/java/org/jclouds/packet/filters/AddApiVersionToRequest.java deleted file mode 100644 index 70e66fb..0000000 --- a/packet/src/main/java/org/jclouds/packet/filters/AddApiVersionToRequest.java +++ /dev/null @@ -1,57 +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.packet.filters; - -import java.util.Collection; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpException; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpRequestFilter; -import org.jclouds.rest.annotations.ApiVersion; - -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableList; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.net.HttpHeaders.ACCEPT; -import static java.lang.String.format; - -@Singleton -public class AddApiVersionToRequest implements HttpRequestFilter { - - private final String apiVersion; - - @Inject - AddApiVersionToRequest(@ApiVersion String apiVersion) { - this.apiVersion = apiVersion; - } - - @Override - public HttpRequest filter(final HttpRequest request) throws HttpException { - Collection<String> accept = checkNotNull(request.getHeaders().get(ACCEPT), "accept header must not be null"); - String versionHeader = Joiner.on("; ").join(ImmutableList.builder() - .addAll(accept) - .add(format("version=%s", apiVersion)) - .build()); - return request.toBuilder() - .replaceHeader(ACCEPT, versionHeader) - .build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/filters/AddXAuthTokenToRequest.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/filters/AddXAuthTokenToRequest.java b/packet/src/main/java/org/jclouds/packet/filters/AddXAuthTokenToRequest.java deleted file mode 100644 index e9d6bdd..0000000 --- a/packet/src/main/java/org/jclouds/packet/filters/AddXAuthTokenToRequest.java +++ /dev/null @@ -1,47 +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.packet.filters; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.domain.Credentials; -import org.jclouds.http.HttpException; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpRequestFilter; -import org.jclouds.location.Provider; - -import com.google.common.base.Supplier; - -import static com.google.common.base.Preconditions.checkNotNull; - -@Singleton -public class AddXAuthTokenToRequest implements HttpRequestFilter { - - private final Supplier<Credentials> creds; - - @Inject - AddXAuthTokenToRequest(@Provider Supplier<Credentials> creds) { - this.creds = creds; - } - - @Override - public HttpRequest filter(HttpRequest request) throws HttpException { - Credentials currentCreds = checkNotNull(creds.get(), "credential supplier returned null"); - return request.toBuilder().replaceHeader("X-Auth-Token", currentCreds.credential).build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/functions/BaseToPagedIterable.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/functions/BaseToPagedIterable.java b/packet/src/main/java/org/jclouds/packet/functions/BaseToPagedIterable.java deleted file mode 100644 index abc59a2..0000000 --- a/packet/src/main/java/org/jclouds/packet/functions/BaseToPagedIterable.java +++ /dev/null @@ -1,59 +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.packet.functions; - -import javax.inject.Inject; - -import org.jclouds.collect.IterableWithMarker; -import org.jclouds.collect.internal.Arg0ToPagedIterable; -import org.jclouds.packet.PacketApi; -import org.jclouds.packet.domain.Href; -import org.jclouds.packet.domain.options.ListOptions; - -import com.google.common.base.Function; -import com.google.common.base.Optional; - -/** - * Base class to implement the functions that build the - * <code>PagedIterable</code>. Subclasses just need to override the - * {@link #fetchPageUsingOptions(ListOptions, Optional)} to invoke the right API - * method with the given options parameter to get the next page. - */ -public abstract class BaseToPagedIterable<T, O extends ListOptions> extends - Arg0ToPagedIterable<T, BaseToPagedIterable<T, O>> { - private final Function<Href, O> hrefToOptions; - protected final PacketApi api; - - @Inject protected BaseToPagedIterable(PacketApi api, Function<Href, O> hrefToOptions) { - this.api = api; - this.hrefToOptions = hrefToOptions; - } - - protected abstract IterableWithMarker<T> fetchPageUsingOptions(O options, Optional<Object> arg0); - - @Override - protected Function<Object, IterableWithMarker<T>> markerToNextForArg0(final Optional<Object> arg0) { - return new Function<Object, IterableWithMarker<T>>() { - @Override - public IterableWithMarker<T> apply(Object input) { - O nextOptions = hrefToOptions.apply(Href.class.cast(input)); - return fetchPageUsingOptions(nextOptions, arg0); - } - }; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/functions/HrefToListOptions.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/functions/HrefToListOptions.java b/packet/src/main/java/org/jclouds/packet/functions/HrefToListOptions.java deleted file mode 100644 index d380b26..0000000 --- a/packet/src/main/java/org/jclouds/packet/functions/HrefToListOptions.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.packet.functions; - -import java.net.URI; - -import org.jclouds.packet.domain.Href; -import org.jclouds.packet.domain.options.ListOptions; - -import com.google.common.base.Function; -import com.google.common.collect.Multimap; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Strings.emptyToNull; -import static com.google.common.collect.Iterables.getFirst; -import static org.jclouds.http.utils.Queries.queryParser; -import static org.jclouds.packet.domain.options.ListOptions.PAGE_PARAM; -import static org.jclouds.packet.domain.options.ListOptions.PER_PAGE_PARAM; - -/** - * Transforms an href returned by the API into a {@link ListOptions} that can be - * used to perform a request to get another page of a paginated list. - */ -public class HrefToListOptions implements Function<Href, ListOptions> { - - @Override - public ListOptions apply(Href input) { - checkNotNull(input, "input cannot be null"); - - Multimap<String, String> queryParams = queryParser().apply(URI.create(input.href()).getQuery()); - String nextPage = getFirstOrNull(PAGE_PARAM, queryParams); - String nextPerPage = getFirstOrNull(PER_PAGE_PARAM, queryParams); - - ListOptions options = new ListOptions(); - if (nextPage != null) { - options.page(Integer.parseInt(nextPage)); - } - if (nextPerPage != null) { - options.perPage(Integer.parseInt(nextPerPage)); - } - - return options; - } - - public static String getFirstOrNull(String key, Multimap<String, String> params) { - return params.containsKey(key) ? emptyToNull(getFirst(params.get(key), null)) : null; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/main/java/org/jclouds/packet/handlers/PacketErrorHandler.java ---------------------------------------------------------------------- diff --git a/packet/src/main/java/org/jclouds/packet/handlers/PacketErrorHandler.java b/packet/src/main/java/org/jclouds/packet/handlers/PacketErrorHandler.java deleted file mode 100644 index 01d870b..0000000 --- a/packet/src/main/java/org/jclouds/packet/handlers/PacketErrorHandler.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.packet.handlers; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpCommand; -import org.jclouds.http.HttpErrorHandler; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ResourceNotFoundException; - -import static org.jclouds.http.HttpUtils.closeClientButKeepContentStream; - -/** - * This will parse and set an appropriate exception on the command object. - */ -@Singleton -public class PacketErrorHandler implements HttpErrorHandler { - - public void handleError(HttpCommand command, HttpResponse response) { - // it is important to always read fully and close streams - byte[] data = closeClientButKeepContentStream(response); - String message = data != null ? new String(data) : null; - - Exception exception = message != null ? new HttpResponseException(command, response, message) - : new HttpResponseException(command, response); - message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), - response.getStatusLine()); - switch (response.getStatusCode()) { - case 400: - exception = new IllegalArgumentException(message, exception); - break; - case 401: - case 403: - exception = new AuthorizationException(message, exception); - break; - case 404: - if (!command.getCurrentRequest().getMethod().equals("DELETE")) { - exception = new ResourceNotFoundException(message, exception); - } - break; - case 409: - exception = new IllegalStateException(message, exception); - break; - } - command.setException(exception); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/test/java/org/jclouds/packet/PacketProviderMetadataTest.java ---------------------------------------------------------------------- diff --git a/packet/src/test/java/org/jclouds/packet/PacketProviderMetadataTest.java b/packet/src/test/java/org/jclouds/packet/PacketProviderMetadataTest.java deleted file mode 100644 index cc0c8c5..0000000 --- a/packet/src/test/java/org/jclouds/packet/PacketProviderMetadataTest.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.packet; - -import org.jclouds.providers.internal.BaseProviderMetadataTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "PacketProviderMetadataTest") -public class PacketProviderMetadataTest extends BaseProviderMetadataTest { - - public PacketProviderMetadataTest() { - super(new PacketProviderMetadata(), new PacketApiMetadata()); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/test/java/org/jclouds/packet/compute/PacketComputeProviderMetadataTest.java ---------------------------------------------------------------------- diff --git a/packet/src/test/java/org/jclouds/packet/compute/PacketComputeProviderMetadataTest.java b/packet/src/test/java/org/jclouds/packet/compute/PacketComputeProviderMetadataTest.java deleted file mode 100644 index a7f0c97..0000000 --- a/packet/src/test/java/org/jclouds/packet/compute/PacketComputeProviderMetadataTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.packet.compute; - -import org.jclouds.packet.PacketApiMetadata; -import org.jclouds.packet.PacketProviderMetadata; -import org.jclouds.providers.internal.BaseProviderMetadataTest; -import org.testng.annotations.Test; - -@Test(groups = "unit", testName = "PacketComputeProviderMetadataTest") -public class PacketComputeProviderMetadataTest extends BaseProviderMetadataTest { - - public PacketComputeProviderMetadataTest() { - super(new PacketProviderMetadata(), new PacketApiMetadata()); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/test/java/org/jclouds/packet/compute/PacketComputeServiceLiveTest.java ---------------------------------------------------------------------- diff --git a/packet/src/test/java/org/jclouds/packet/compute/PacketComputeServiceLiveTest.java b/packet/src/test/java/org/jclouds/packet/compute/PacketComputeServiceLiveTest.java deleted file mode 100644 index dc10ecd..0000000 --- a/packet/src/test/java/org/jclouds/packet/compute/PacketComputeServiceLiveTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.packet.compute; - -import java.util.Properties; - -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.internal.BaseComputeServiceLiveTest; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; - -/** - * Live tests for the {@link org.jclouds.compute.ComputeService} integration. - */ -@Test(groups = "live", singleThreaded = true, testName = "PacketComputeServiceLiveTest") -public class PacketComputeServiceLiveTest extends BaseComputeServiceLiveTest { - - public PacketComputeServiceLiveTest() { - provider = "packet"; - } - - @Override - protected Module getSshModule() { - return new SshjSshClientModule(); - } - - @Override - @Test(expectedExceptions = AuthorizationException.class) - public void testCorrectAuthException() throws Exception { - ComputeServiceContext context = null; - try { - Properties overrides = setupProperties(); - overrides.setProperty(provider + ".identity", "MOM:MA"); - overrides.setProperty(provider + ".credential", "MIA"); - context = newBuilder() - .modules(ImmutableSet.of(getLoggingModule(), credentialStoreModule)) - .overrides(overrides) - .build(ComputeServiceContext.class); - // replace listNodes with listImages as it doesn't require `projectId` - context.getComputeService().listImages(); - } catch (AuthorizationException e) { - throw e; - } catch (RuntimeException e) { - e.printStackTrace(); - throw e; - } finally { - if (context != null) - context.close(); - } - } - - @Override - public void testOptionToNotBlock() throws Exception { - // Packet ComputeService implementation has to block until the node - // is provisioned, to be able to return it. - } - - @Override - protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap<String, String> userMetadata) { - // The Packet API does not return the user data - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/cb70f325/packet/src/test/java/org/jclouds/packet/compute/PacketTemplateBuilderLiveTest.java ---------------------------------------------------------------------- diff --git a/packet/src/test/java/org/jclouds/packet/compute/PacketTemplateBuilderLiveTest.java b/packet/src/test/java/org/jclouds/packet/compute/PacketTemplateBuilderLiveTest.java deleted file mode 100644 index 5faddde..0000000 --- a/packet/src/test/java/org/jclouds/packet/compute/PacketTemplateBuilderLiveTest.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.packet.compute; - -import java.io.IOException; -import java.util.Set; - -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -import static org.jclouds.compute.util.ComputeServiceUtils.getCores; -import static org.testng.Assert.assertEquals; - -@Test(groups = "live", testName = "PacketTemplateBuilderLiveTest") -public class PacketTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { - - public PacketTemplateBuilderLiveTest() { - provider = "packet"; - } - - @Test - @Override - public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = view.getComputeService().templateBuilder().build(); - assert defaultTemplate.getImage().getOperatingSystem().getVersion().startsWith("16.") : defaultTemplate - .getImage().getOperatingSystem().getVersion(); - assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); - assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); - } - - @Override - protected Set<String> getIso3166Codes() { - return ImmutableSet.of("US-CA", "US-NJ", "NL", "JP"); - } - -}
