http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/PublicIpInstanceIdPair.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/PublicIpInstanceIdPair.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/PublicIpInstanceIdPair.java new file mode 100644 index 0000000..b0d24bf --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/PublicIpInstanceIdPair.java @@ -0,0 +1,110 @@ +/* + * 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.ec2.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import org.jclouds.javax.annotation.Nullable; + +/** + * + * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-DescribeAddressesResponseInfoType.html" + * /> + */ +public class PublicIpInstanceIdPair implements Comparable<PublicIpInstanceIdPair> { + + private final String region; + @Nullable + private final String instanceId; + private final String publicIp; + + public PublicIpInstanceIdPair(String region, String publicIp, @Nullable String instanceId) { + this.region = checkNotNull(region, "region"); + this.instanceId = instanceId; + this.publicIp = checkNotNull(publicIp, "publicIp"); + } + + /** + * To be removed in jclouds 1.6 <h4>Warning</h4> + * + * Especially on EC2 clones that may not support regions, this value is fragile. Consider + * alternate means to determine context. + */ + @Deprecated + public String getRegion() { + return region; + } + + /** + * {@inheritDoc} + */ + public int compareTo(PublicIpInstanceIdPair o) { + return (this == o) ? 0 : getPublicIp().compareTo(o.getPublicIp()); + } + + /** + * The ID of the instance. + */ + public String getInstanceId() { + return instanceId; + } + + /** + * The public IP address. + */ + public String getPublicIp() { + return publicIp; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((instanceId == null) ? 0 : instanceId.hashCode()); + result = prime * result + ((publicIp == null) ? 0 : publicIp.hashCode()); + result = prime * result + ((region == null) ? 0 : region.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PublicIpInstanceIdPair other = (PublicIpInstanceIdPair) obj; + if (instanceId == null) { + if (other.instanceId != null) + return false; + } else if (!instanceId.equals(other.instanceId)) + return false; + if (publicIp == null) { + if (other.publicIp != null) + return false; + } else if (!publicIp.equals(other.publicIp)) + return false; + if (region == null) { + if (other.region != null) + return false; + } else if (!region.equals(other.region)) + return false; + return true; + } + +}
http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Reservation.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Reservation.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Reservation.java new file mode 100644 index 0000000..4fb7e22 --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Reservation.java @@ -0,0 +1,227 @@ +/* + * 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.ec2.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Set; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Objects; +import com.google.common.collect.ComparisonChain; +import com.google.common.collect.ForwardingSet; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Ordering; + +/** + * + * @see <a href= + * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-ReservationInfoType.html" + * /> + */ +public class Reservation<T extends RunningInstance> extends ForwardingSet<T> implements Comparable<Reservation<T>> { + + public static <T extends RunningInstance> Builder<T> builder() { + return new Builder<T>(); + } + + public Builder<T> toBuilder() { + return Reservation.<T> builder().fromReservation(this); + } + + public static class Builder<T extends RunningInstance> { + private String region; + private String ownerId; + private String requesterId; + private String reservationId; + + private ImmutableSet.Builder<T> instances = ImmutableSet.<T> builder(); + private ImmutableSet.Builder<String> groupNames = ImmutableSet.<String> builder(); + + /** + * @see Reservation#getRegion() + */ + public Builder<T> region(String region) { + this.region = region; + return this; + } + + /** + * @see Reservation#getOwnerId() + */ + public Builder<T> ownerId(String ownerId) { + this.ownerId = ownerId; + return this; + } + + /** + * @see Reservation#getRequesterId() + */ + public Builder<T> requesterId(String requesterId) { + this.requesterId = requesterId; + return this; + } + + /** + * @see Reservation#getReservationId() + */ + public Builder<T> reservationId(String reservationId) { + this.reservationId = reservationId; + return this; + } + + /** + * @see Reservation#iterator + */ + public Builder<T> instance(T instance) { + this.instances.add(checkNotNull(instance, "instance")); + return this; + } + + /** + * @see Reservation#iterator + */ + public Builder<T> instances(Set<T> instances) { + this.instances.addAll(checkNotNull(instances, "instances")); + return this; + } + + /** + * @see Reservation#getGroupNames() + */ + public Builder<T> groupName(String groupName) { + this.groupNames.add(checkNotNull(groupName, "groupName")); + return this; + } + + /** + * @see Reservation#getGroupNames() + */ + public Builder<T> groupNames(Iterable<String> groupNames) { + this.groupNames = ImmutableSet.<String> builder().addAll(checkNotNull(groupNames, "groupNames")); + return this; + } + + public Reservation<T> build() { + return new Reservation<T>(region, groupNames.build(), instances.build(), ownerId, requesterId, reservationId); + } + + public Builder<T> fromReservation(Reservation<T> in) { + return region(in.region).ownerId(in.ownerId).requesterId(in.requesterId).reservationId(in.reservationId) + .instances(in).groupNames(in.groupNames); + } + } + + private final String region; + private final ImmutableSet<String> groupNames; + private final ImmutableSet<T> instances; + @Nullable + private final String ownerId; + @Nullable + private final String requesterId; + @Nullable + private final String reservationId; + + public Reservation(String region, Iterable<String> groupNames, Iterable<T> instances, @Nullable String ownerId, + @Nullable String requesterId, @Nullable String reservationId) { + this.region = checkNotNull(region, "region"); + this.groupNames = ImmutableSet.copyOf(checkNotNull(groupNames, "groupNames")); + this.instances = ImmutableSet.copyOf(checkNotNull(instances, "instances")); + this.ownerId = ownerId; + this.requesterId = requesterId; + this.reservationId = reservationId; + } + + @Override + protected Set<T> delegate() { + return instances; + } + + /** + * To be removed in jclouds 1.6 <h4>Warning</h4> + * + * Especially on EC2 clones that may not support regions, this value is fragile. Consider + * alternate means to determine context. + */ + @Deprecated + public String getRegion() { + return region; + } + + /** + * Names of the security groups. + */ + public Set<String> getGroupNames() { + return groupNames; + } + + /** + * AWS Access Key ID of the user who owns the reservation. + */ + public String getOwnerId() { + return ownerId; + } + + /** + * The ID of the requester that launched the instances on your behalf (for example, AWS + * Management Console or Auto Scaling). + */ + public String getRequesterId() { + return requesterId; + } + + /** + * Unique ID of the reservation. + */ + public String getReservationId() { + return reservationId; + } + + @Override + public int hashCode() { + return Objects.hashCode(region, reservationId, super.hashCode()); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; + @SuppressWarnings("unchecked") + Reservation<T> that = Reservation.class.cast(obj); + return super.equals(that) && Objects.equal(this.region, that.region) + && Objects.equal(this.reservationId, that.reservationId); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues().add("region", region).add("reservationId", reservationId) + .add("requesterId", requesterId).add("instances", instances).add("groupNames", groupNames).toString(); + } + + @Override + public int compareTo(Reservation<T> other) { + return ComparisonChain.start().compare(region, other.region) + .compare(reservationId, other.reservationId, Ordering.natural().nullsLast()).result(); + } + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/ReservedInstancesOffering.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/ReservedInstancesOffering.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/ReservedInstancesOffering.java new file mode 100644 index 0000000..4dfd868 --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/ReservedInstancesOffering.java @@ -0,0 +1,181 @@ +/* + * 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.ec2.domain; + +/** + * + * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateVolume.html" + * /> + */ +public class ReservedInstancesOffering implements Comparable<ReservedInstancesOffering> { + private final String region; + private final String availabilityZone; + private final long duration; + private final float fixedPrice; + private final String instanceType; + private final String productDescription; + private final String id; + private final float usagePrice; + + public ReservedInstancesOffering(String region, String availabilityZone, long duration, float fixedPrice, String instanceType, + String productDescription, String reservedInstancesOfferingId, float usagePrice) { + this.region = region; + this.availabilityZone = availabilityZone; + this.duration = duration; + this.fixedPrice = fixedPrice; + this.instanceType = instanceType; + this.productDescription = productDescription; + this.id = reservedInstancesOfferingId; + this.usagePrice = usagePrice; + } + + /** + * To be removed in jclouds 1.6 <h4>Warning</h4> + * + * Especially on EC2 clones that may not support regions, this value is fragile. Consider + * alternate means to determine context. + */ + @Deprecated + public String getRegion() { + return region; + } + + /** + * @return The Availability Zone in which the Reserved Instance can be used. + */ + public String getAvailabilityZone() { + return availabilityZone; + } + + /** + * + * @return The duration of the Reserved Instance, in seconds + */ + public long getDuration() { + return duration; + } + + /** + * + * @return The purchase price of the Reserved Instance. + */ + public float getFixedPrice() { + return fixedPrice; + } + + /** + * + * @return The instance type on which the Reserved Instance can be used. + */ + public String getInstanceType() { + return instanceType; + } + + /** + * + * @return The Reserved Instance description. + */ + public String getProductDescription() { + return productDescription; + } + + /** + * @return The ID of the Reserved Instance offering. + */ + public String getId() { + return id; + } + + /** + * + * @return The usage price of the Reserved Instance, per hour. + */ + public float getUsagePrice() { + return usagePrice; + } + + @Override + public int compareTo(ReservedInstancesOffering o) { + return id.compareTo(o.id); + } + + @Override + public String toString() { + return "[availabilityZone=" + availabilityZone + ", duration=" + duration + + ", fixedPrice=" + fixedPrice + ", id=" + id + ", instanceType=" + instanceType + ", productDescription=" + + productDescription + ", region=" + region + ", usagePrice=" + usagePrice + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((availabilityZone == null) ? 0 : availabilityZone.hashCode()); + result = prime * result + (int) (duration ^ (duration >>> 32)); + result = prime * result + Float.floatToIntBits(fixedPrice); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((instanceType == null) ? 0 : instanceType.hashCode()); + result = prime * result + ((productDescription == null) ? 0 : productDescription.hashCode()); + result = prime * result + ((region == null) ? 0 : region.hashCode()); + result = prime * result + Float.floatToIntBits(usagePrice); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ReservedInstancesOffering other = (ReservedInstancesOffering) obj; + if (availabilityZone == null) { + if (other.availabilityZone != null) + return false; + } else if (!availabilityZone.equals(other.availabilityZone)) + return false; + if (duration != other.duration) + return false; + if (Float.floatToIntBits(fixedPrice) != Float.floatToIntBits(other.fixedPrice)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (instanceType == null) { + if (other.instanceType != null) + return false; + } else if (!instanceType.equals(other.instanceType)) + return false; + if (productDescription == null) { + if (other.productDescription != null) + return false; + } else if (!productDescription.equals(other.productDescription)) + return false; + if (region == null) { + if (other.region != null) + return false; + } else if (!region.equals(other.region)) + return false; + if (Float.floatToIntBits(usagePrice) != Float.floatToIntBits(other.usagePrice)) + return false; + return true; + } + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/RootDeviceType.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/RootDeviceType.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/RootDeviceType.java new file mode 100644 index 0000000..0b6e99e --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/RootDeviceType.java @@ -0,0 +1,46 @@ +/* + * 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.ec2.domain; + +import com.google.common.base.CaseFormat; + +/** + * The root device type used by the AMI. The AMI can use an Amazon EBS or instance store root + * device. + */ +public enum RootDeviceType { + + INSTANCE_STORE, + + EBS, UNRECOGNIZED; + + public String value() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name()); + } + + public String toString() { + return value(); + } + + public static RootDeviceType fromValue(String v) { + try { + return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, v)); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/RunningInstance.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/RunningInstance.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/RunningInstance.java new file mode 100644 index 0000000..ee35901 --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/RunningInstance.java @@ -0,0 +1,524 @@ +/* + * 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.ec2.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Date; +import java.util.Map; +import java.util.Set; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.base.Strings; +import com.google.common.collect.ComparisonChain; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; +import com.google.common.collect.Ordering; +import com.google.common.collect.Sets; + +/** + * + * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-RunningInstancesItemType.html" + * /> + */ +public class RunningInstance implements Comparable<RunningInstance> { + + public static Builder<?> builder() { + return new ConcreteBuilder(); + } + + public Builder<?> toBuilder() { + return new ConcreteBuilder().fromRunningInstance(this); + } + + public abstract static class Builder<T extends Builder<T>> { + protected abstract T self(); + + protected String region; + protected Set<String> groupNames = Sets.newLinkedHashSet(); + protected String amiLaunchIndex; + protected String dnsName; + protected String imageId; + protected String instanceId; + protected InstanceState instanceState; + protected String rawState; + protected String instanceType; + protected String ipAddress; + protected String kernelId; + protected String keyName; + protected Date launchTime; + protected String availabilityZone; + protected String virtualizationType = "paravirtual"; + protected String platform; + protected String privateDnsName; + protected String privateIpAddress; + protected String ramdiskId; + protected String reason; + protected RootDeviceType rootDeviceType = RootDeviceType.INSTANCE_STORE; + protected String rootDeviceName; + protected Map<String, BlockDevice> ebsBlockDevices = Maps.newLinkedHashMap(); + protected Map<String, String> tags = Maps.newLinkedHashMap(); + + public T tags(Map<String, String> tags) { + this.tags = ImmutableMap.copyOf(checkNotNull(tags, "tags")); + return self(); + } + + public T tag(String key, String value) { + if (key != null) + this.tags.put(key, Strings.nullToEmpty(value)); + return self(); + } + + public T region(String region) { + this.region = region; + return self(); + } + + public T groupNames(Iterable<String> groupNames) { + this.groupNames = ImmutableSet.copyOf(checkNotNull(groupNames, "groupNames")); + return self(); + } + + public T groupName(String groupName) { + if (groupName != null) + this.groupNames.add(groupName); + return self(); + } + + public T amiLaunchIndex(String amiLaunchIndex) { + this.amiLaunchIndex = amiLaunchIndex; + return self(); + } + + public T dnsName(String dnsName) { + this.dnsName = dnsName; + return self(); + } + + public T imageId(String imageId) { + this.imageId = imageId; + return self(); + } + + public T instanceId(String instanceId) { + this.instanceId = instanceId; + return self(); + } + + public T instanceState(InstanceState instanceState) { + this.instanceState = instanceState; + return self(); + } + + public T rawState(String rawState) { + this.rawState = rawState; + return self(); + } + + public T instanceType(String instanceType) { + this.instanceType = instanceType; + return self(); + } + + public T ipAddress(String ipAddress) { + this.ipAddress = ipAddress; + return self(); + } + + public T kernelId(String kernelId) { + this.kernelId = kernelId; + return self(); + } + + public T keyName(String keyName) { + this.keyName = keyName; + return self(); + } + + public T launchTime(Date launchTime) { + this.launchTime = launchTime; + return self(); + } + + public T availabilityZone(String availabilityZone) { + this.availabilityZone = availabilityZone; + return self(); + } + + public T virtualizationType(String virtualizationType) { + this.virtualizationType = virtualizationType; + return self(); + } + + public T platform(String platform) { + this.platform = platform; + return self(); + } + + public T privateDnsName(String privateDnsName) { + this.privateDnsName = privateDnsName; + return self(); + } + + public T privateIpAddress(String privateIpAddress) { + this.privateIpAddress = privateIpAddress; + return self(); + } + + public T ramdiskId(String ramdiskId) { + this.ramdiskId = ramdiskId; + return self(); + } + + public T reason(String reason) { + this.reason = reason; + return self(); + } + + public T rootDeviceType(RootDeviceType rootDeviceType) { + this.rootDeviceType = rootDeviceType; + return self(); + } + + public T rootDeviceName(String rootDeviceName) { + this.rootDeviceName = rootDeviceName; + return self(); + } + + public T devices(Map<String, BlockDevice> ebsBlockDevices) { + this.ebsBlockDevices = ImmutableMap.copyOf(checkNotNull(ebsBlockDevices, "ebsBlockDevices")); + return self(); + } + + public T device(String key, BlockDevice value) { + if (key != null && value != null) + this.ebsBlockDevices.put(key, value); + return self(); + } + + public T fromRunningInstance(RunningInstance in) { + return region(in.region).groupNames(in.groupNames).amiLaunchIndex(in.amiLaunchIndex).dnsName(in.dnsName) + .imageId(in.imageId).instanceId(in.instanceId).instanceState(in.instanceState).rawState(in.rawState) + .instanceType(in.instanceType).ipAddress(in.ipAddress).kernelId(in.kernelId).keyName(in.keyName) + .launchTime(in.launchTime).availabilityZone(in.availabilityZone) + .virtualizationType(in.virtualizationType).platform(in.platform).privateDnsName(in.privateDnsName) + .privateIpAddress(in.privateIpAddress).ramdiskId(in.ramdiskId).reason(in.reason) + .rootDeviceType(in.rootDeviceType).rootDeviceName(in.rootDeviceName).devices(in.ebsBlockDevices) + .tags(in.tags); + } + + public abstract RunningInstance build(); + + } + + private static class ConcreteBuilder extends Builder<ConcreteBuilder> { + @Override + protected ConcreteBuilder self() { + return this; + } + + @Override + public RunningInstance build() { + return new RunningInstance(region, groupNames, amiLaunchIndex, dnsName, imageId, instanceId, instanceState, + rawState, instanceType, ipAddress, kernelId, keyName, launchTime, availabilityZone, virtualizationType, + platform, privateDnsName, privateIpAddress, ramdiskId, reason, rootDeviceType, rootDeviceName, + ebsBlockDevices, tags); + } + } + + protected final String region; + protected final Set<String> groupNames; + protected final String amiLaunchIndex; + @Nullable + protected final String dnsName; + protected final String imageId; + protected final String instanceId; + protected final InstanceState instanceState; + protected final String rawState; + protected final String instanceType; + @Nullable + protected final String ipAddress; + @Nullable + protected final String kernelId; + @Nullable + protected final String keyName; + protected final Date launchTime; + protected final String availabilityZone; + protected final String virtualizationType; + @Nullable + protected final String platform; + @Nullable + protected final String privateDnsName; + @Nullable + protected final String privateIpAddress; + @Nullable + protected final String ramdiskId; + @Nullable + protected final String reason; + protected final RootDeviceType rootDeviceType; + @Nullable + protected final String rootDeviceName; + protected final Map<String, BlockDevice> ebsBlockDevices; + protected final Map<String, String> tags; + + protected RunningInstance(String region, Iterable<String> groupNames, @Nullable String amiLaunchIndex, + @Nullable String dnsName, String imageId, String instanceId, InstanceState instanceState, String rawState, + String instanceType, @Nullable String ipAddress, @Nullable String kernelId, @Nullable String keyName, + Date launchTime, String availabilityZone, String virtualizationType, @Nullable String platform, + @Nullable String privateDnsName, @Nullable String privateIpAddress, @Nullable String ramdiskId, + @Nullable String reason, RootDeviceType rootDeviceType, @Nullable String rootDeviceName, + Map<String, BlockDevice> ebsBlockDevices, Map<String, String> tags) { + this.region = checkNotNull(region, "region"); + this.amiLaunchIndex = amiLaunchIndex; // nullable on runinstances. + this.dnsName = dnsName; // nullable on runinstances. + this.imageId = imageId; // nullable on runinstances. + this.instanceId = checkNotNull(instanceId, "instanceId"); + this.instanceState = checkNotNull(instanceState, "instanceState for %s/%s", region, instanceId); + this.rawState = checkNotNull(rawState, "rawState for %s/%s", region, instanceId); + this.instanceType = checkNotNull(instanceType, "instanceType for %s/%s", region, instanceId); + this.ipAddress = ipAddress; + this.kernelId = kernelId; + this.keyName = keyName; + this.launchTime = launchTime;// nullable on spot. + this.availabilityZone = availabilityZone;// nullable on spot. + this.virtualizationType = virtualizationType; + this.platform = platform; + this.privateDnsName = privateDnsName;// nullable on runinstances. + this.privateIpAddress = privateIpAddress;// nullable on runinstances. + this.ramdiskId = ramdiskId; + this.reason = reason; + this.rootDeviceType = checkNotNull(rootDeviceType, "rootDeviceType for %s/%s", region, instanceId); + this.rootDeviceName = rootDeviceName; + this.ebsBlockDevices = ImmutableMap.copyOf(checkNotNull(ebsBlockDevices, "ebsBlockDevices for %s/%s", region, instanceId)); + this.groupNames = ImmutableSet.copyOf(checkNotNull(groupNames, "groupNames for %s/%s", region, instanceId)); + this.tags = ImmutableMap.<String, String> copyOf(checkNotNull(tags, "tags")); + } + + /** + * To be removed in jclouds 1.6 <h4>Warning</h4> + * + * Especially on EC2 clones that may not support regions, this value is fragile. Consider + * alternate means to determine context. + */ + @Deprecated + public String getRegion() { + return region; + } + + /** + * The AMI launch index, which can be used to find this instance within the launch group. For + * more information, go to the Metadata section of the Amazon Elastic Compute Cloud Developer + * Guide. + * + * @see <a href="http://docs.amazonwebservices.com/AWSEC2/2010-08-31/DeveloperGuide/" /> + */ + public String getAmiLaunchIndex() { + return amiLaunchIndex; + } + + /** + * The public DNS name assigned to the instance. This DNS name is contactable from outside the + * Amazon EC2 network. This element remains empty until the instance enters a running state. + */ + public String getDnsName() { + return dnsName; + } + + /** + * Image ID of the AMI used to launch the instance. + */ + public String getImageId() { + return imageId; + } + + /** + * Unique ID of the instance launched. + */ + public String getId() { + return instanceId; + } + + /** + * The current state of the instance. + */ + public InstanceState getInstanceState() { + return instanceState; + } + + /** + * The current state of the instance, as returned literally from the input XML + */ + public String getRawState() { + return rawState; + } + + /** + * The instance type. + */ + public String getInstanceType() { + return instanceType; + } + + /** + * Specifies the IP address of the instance. + */ + public String getIpAddress() { + return ipAddress; + } + + /** + * Optional. Kernel associated with this instance. + */ + public String getKernelId() { + return kernelId; + } + + /** + * If this instance was launched with an associated key pair, this displays the key pair name. + */ + public String getKeyName() { + return keyName; + } + + /** + * The time the instance launched. + */ + public Date getLaunchTime() { + return launchTime; + } + + /** + * The location where the instance launched. + */ + public String getAvailabilityZone() { + return availabilityZone; + } + + /** + * Specifies the instance's virtualization type. Valid values are paravirtual or hvm. + */ + public String getVirtualizationType() { + return virtualizationType; + } + + /** + * Platform of the instance (e.g., Windows). + */ + public String getPlatform() { + return platform; + } + + /** + * The private DNS name assigned to the instance. This DNS name can only be used inside the + * Amazon EC2 network. This element remains empty until the instance enters a running state. + */ + public String getPrivateDnsName() { + return privateDnsName; + } + + /** + * Specifies the private IP address that is assigned to the instance (Amazon VPC). + */ + public String getPrivateIpAddress() { + return privateIpAddress; + } + + /** + * Optional. RAM disk associated with this instance. + */ + public String getRamdiskId() { + return ramdiskId; + } + + /** + * Reason for the most recent state transition. This might be an empty string. + */ + public String getReason() { + return reason; + } + + public RootDeviceType getRootDeviceType() { + return rootDeviceType; + } + + public String getRootDeviceName() { + return rootDeviceName; + } + + /** + * EBS volumes associated with the instance. + */ + public Map<String, BlockDevice> getEbsBlockDevices() { + return ebsBlockDevices; + } + + /** + * Names of the security groups. + */ + public Set<String> getGroupNames() { + return groupNames; + } + + /** + * tags that are present in the instance + */ + public Map<String, String> getTags() { + return tags; + } + + @Override + public int compareTo(RunningInstance other) { + return ComparisonChain.start().compare(region, other.region).compare(instanceId, other.instanceId, Ordering.natural().nullsLast()).result(); + } + + @Override + public int hashCode() { + return Objects.hashCode(region, instanceId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; + RunningInstance that = RunningInstance.class.cast(obj); + return Objects.equal(this.region, that.region) && Objects.equal(this.instanceId, that.instanceId); + } + + protected ToStringHelper string() { + return Objects.toStringHelper(this).omitNullValues().add("region", region) + .add("availabilityZone", availabilityZone).add("id", instanceId).add("state", rawState) + .add("type", instanceType).add("virtualizationType", virtualizationType).add("imageId", imageId) + .add("ipAddress", ipAddress).add("dnsName", dnsName).add("privateIpAddress", privateIpAddress) + .add("privateDnsName", privateDnsName).add("keyName", keyName).add("groupNames", groupNames) + .add("platform", platform).add("launchTime", launchTime).add("rootDeviceName", rootDeviceName) + .add("rootDeviceType", rootDeviceType).add("ebsBlockDevices", ebsBlockDevices).add("tags", tags); + } + + @Override + public String toString() { + return string().toString(); + } + + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/SecurityGroup.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/SecurityGroup.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/SecurityGroup.java new file mode 100644 index 0000000..5db66ed --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/SecurityGroup.java @@ -0,0 +1,228 @@ +/* + * 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.ec2.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Set; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.net.domain.IpPermission; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.ForwardingSet; +import com.google.common.collect.ImmutableSet; + +/** + * + * @see <a href= + * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-SecurityGroupItemType.html" + * /> + */ +public class SecurityGroup extends ForwardingSet<IpPermission> { + + public static Builder<?> builder() { + return new ConcreteBuilder(); + } + + public Builder<?> toBuilder() { + return new ConcreteBuilder().fromSecurityGroup(this); + } + + public abstract static class Builder<T extends Builder<T>> { + protected abstract T self(); + + protected String region; + protected String id; + protected String name; + protected String ownerId; + protected String description; + protected ImmutableSet.Builder<IpPermission> ipPermissions = ImmutableSet.<IpPermission> builder(); + + /** + * @see SecurityGroup#getRegion() + */ + public T region(String region) { + this.region = region; + return self(); + } + + /** + * @see SecurityGroup#getId() + */ + public T id(String id) { + this.id = id; + return self(); + } + + /** + * @see SecurityGroup#getName() + */ + public T name(String name) { + this.name = name; + return self(); + } + + /** + * @see SecurityGroup#getOwnerId() + */ + public T ownerId(String ownerId) { + this.ownerId = ownerId; + return self(); + } + + /** + * @see SecurityGroup#getDescription() + */ + public T description(String description) { + this.description = description; + return self(); + } + + /** + * @see SecurityGroup#delegate() + */ + public T role(IpPermission role) { + this.ipPermissions.add(role); + return self(); + } + + /** + * @see SecurityGroup#delegate() + */ + public T ipPermissions(Iterable<IpPermission> ipPermissions) { + this.ipPermissions.addAll(checkNotNull(ipPermissions, "ipPermissions")); + return self(); + } + + /** + * @see SecurityGroup#delegate() + */ + public T ipPermission(IpPermission ipPermission) { + this.ipPermissions.add(checkNotNull(ipPermission, "ipPermission")); + return self(); + } + + public SecurityGroup build() { + return new SecurityGroup(region, id, name, ownerId, description, ipPermissions.build()); + } + + public T fromSecurityGroup(SecurityGroup in) { + return region(in.region).id(in.id).name(in.name).ownerId(in.ownerId).description(in.description) + .ipPermissions(in); + } + } + + private static class ConcreteBuilder extends Builder<ConcreteBuilder> { + @Override + protected ConcreteBuilder self() { + return this; + } + } + + private final String region; + private final String id; + private final String name; + private final String ownerId; + private final String description; + private final Set<IpPermission> ipPermissions; + + public SecurityGroup(String region, String id, String name, String ownerId, String description, + Iterable<IpPermission> ipPermissions) { + this.region = checkNotNull(region, "region"); + this.id = id; + this.name = name; + this.ownerId = ownerId; + this.description = description; + this.ipPermissions = ImmutableSet.copyOf(checkNotNull(ipPermissions, "ipPermissions")); + } + + /** + * To be removed in jclouds 1.6 <h4>Warning</h4> + * + * Especially on EC2 clones that may not support regions, this value is + * fragile. Consider alternate means to determine context. + */ + @Deprecated + public String getRegion() { + return region; + } + + /** + * id of the security group. Not in all EC2 impls + */ + @Nullable + public String getId() { + return id; + } + + /** + * Name of the security group. + */ + public String getName() { + return name; + } + + /** + * AWS Access Key ID of the owner of the security group. + */ + public String getOwnerId() { + return ownerId; + } + + /** + * Description of the security group. + */ + public String getDescription() { + return description; + } + + @Override + public int hashCode() { + return Objects.hashCode(region, id, name, ownerId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; + SecurityGroup that = SecurityGroup.class.cast(obj); + return Objects.equal(this.region, that.region) + && Objects.equal(this.id, that.id) + && Objects.equal(this.name, that.name) + && Objects.equal(this.ownerId, that.ownerId); + } + + protected ToStringHelper string() { + return Objects.toStringHelper(this).omitNullValues().add("region", region).add("id", id).add("name", name) + .add("ownerId", ownerId).add("description", description) + .add("ipPermissions", ipPermissions.size() == 0 ? null : ipPermissions); + } + + @Override + public String toString() { + return string().toString(); + } + + @Override + protected Set<IpPermission> delegate() { + return ipPermissions; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Snapshot.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Snapshot.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Snapshot.java new file mode 100644 index 0000000..64faabb --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Snapshot.java @@ -0,0 +1,234 @@ +/* + * 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.ec2.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Date; + +/** + * + * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateSnapshot.html" + * /> + */ +public class Snapshot implements Comparable<Snapshot> { + public static enum Status { + PENDING, COMPLETED, ERROR, UNRECOGNIZED; + public String value() { + return name().toLowerCase(); + } + + @Override + public String toString() { + return value(); + } + + public static Status fromValue(String status) { + try { + return valueOf(checkNotNull(status, "status").toUpperCase()); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + } + + private final String region; + private final String id; + private final String volumeId; + private final int volumeSize; + private final Status status; + private final Date startTime; + private final int progress; + private final String ownerId; + private final String description; + private final String ownerAlias; + + public Snapshot(String region, String id, String volumeId, int volumeSize, Status status, Date startTime, + int progress, String ownerId, String description, String ownerAlias) { + this.region = checkNotNull(region, "region"); + this.id = id; + this.volumeId = volumeId; + this.volumeSize = volumeSize; + this.status = status; + this.startTime = startTime; + this.progress = progress; + this.ownerId = ownerId; + this.description = description; + this.ownerAlias = ownerAlias; + } + + /** + * To be removed in jclouds 1.6 <h4>Warning</h4> + * + * Especially on EC2 clones that may not support regions, this value is fragile. Consider + * alternate means to determine context. + */ + @Deprecated + public String getRegion() { + return region; + } + + /** + * The ID of the snapshot. + */ + public String getId() { + return id; + } + + /** + * The ID of the volume. + */ + public String getVolumeId() { + return volumeId; + } + + /** + * The size of the volume, in GiB. + */ + public int getVolumeSize() { + return volumeSize; + } + + /** + * Snapshot state (e.g., pending, completed, or error) + */ + public Status getStatus() { + return status; + } + + /** + * Time stamp when the snapshot was initiated. + */ + public Date getStartTime() { + return startTime; + } + + /** + * The progress of the snapshot, in percentage. + */ + public int getProgress() { + return progress; + } + + /** + * AWS Access Key ID of the user who owns the snapshot. + */ + public String getOwnerId() { + return ownerId; + } + + /** + * Description of the snapshot. + */ + public String getDescription() { + return description; + } + + /** + * The AWS identity alias (e.g., "amazon", "redhat", "self", etc.) or AWS identity ID that owns + * the AMI. + */ + public String getOwnerAlias() { + return ownerAlias; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((ownerAlias == null) ? 0 : ownerAlias.hashCode()); + result = prime * result + ((ownerId == null) ? 0 : ownerId.hashCode()); + result = prime * result + progress; + result = prime * result + ((region == null) ? 0 : region.hashCode()); + result = prime * result + ((startTime == null) ? 0 : startTime.hashCode()); + result = prime * result + ((status == null) ? 0 : status.hashCode()); + result = prime * result + ((volumeId == null) ? 0 : volumeId.hashCode()); + result = prime * result + volumeSize; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Snapshot other = (Snapshot) obj; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (ownerAlias == null) { + if (other.ownerAlias != null) + return false; + } else if (!ownerAlias.equals(other.ownerAlias)) + return false; + if (ownerId == null) { + if (other.ownerId != null) + return false; + } else if (!ownerId.equals(other.ownerId)) + return false; + if (progress != other.progress) + return false; + if (region == null) { + if (other.region != null) + return false; + } else if (!region.equals(other.region)) + return false; + if (startTime == null) { + if (other.startTime != null) + return false; + } else if (!startTime.equals(other.startTime)) + return false; + if (status == null) { + if (other.status != null) + return false; + } else if (!status.equals(other.status)) + return false; + if (volumeId == null) { + if (other.volumeId != null) + return false; + } else if (!volumeId.equals(other.volumeId)) + return false; + if (volumeSize != other.volumeSize) + return false; + return true; + } + + @Override + public String toString() { + return "Snapshot [description=" + description + ", id=" + id + ", ownerAlias=" + ownerAlias + ", ownerId=" + + ownerId + ", progress=" + progress + ", startTime=" + startTime + ", status=" + status + ", volumeId=" + + volumeId + ", volumeSize=" + volumeSize + "]"; + } + + @Override + public int compareTo(Snapshot o) { + return startTime.compareTo(o.startTime); + } + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Subnet.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Subnet.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Subnet.java new file mode 100644 index 0000000..eecc169 --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Subnet.java @@ -0,0 +1,250 @@ +/* + * 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.ec2.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Map; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.ImmutableMap; + +/** + * Amazon EC2 VPCs contain one or more subnets. + * + * @see <a href="http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Subnets.html" >doc</a> + */ +public final class Subnet { + + public static enum State { + /** + * The subnet is available for use. + */ + AVAILABLE, + /** + * The subnet is not yet available for use. + */ + PENDING, UNRECOGNIZED; + public String value() { + return name().toLowerCase(); + } + + public static State fromValue(String v) { + try { + return valueOf(v.toUpperCase()); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + } + + private final String subnetId; + private final State subnetState; + private final String vpcId; + private final String cidrBlock; + private final int availableIpAddressCount; + private final String availabilityZone; + private final Map<String, String> tags; + + private Subnet(String subnetId, State subnetState, String vpcId, String cidrBlock, int availableIpAddressCount, + String availabilityZone, ImmutableMap<String, String> tags) { + this.subnetId = checkNotNull(subnetId, "subnetId"); + this.subnetState = checkNotNull(subnetState, "subnetState for %s", subnetId); + this.vpcId = checkNotNull(vpcId, "vpcId for %s", subnetId); + this.cidrBlock = checkNotNull(cidrBlock, "cidrBlock for %s", subnetId); + this.availableIpAddressCount = availableIpAddressCount; + this.availabilityZone = checkNotNull(availabilityZone, "availabilityZone for %s", subnetId); + this.tags = checkNotNull(tags, "tags for %s", subnetId); + } + + /** + * The subnet ID, ex. subnet-c5473ba8 + */ + public String getSubnetId() { + return subnetId; + } + + /** + * The subnet state - either available or pending. + */ + public State getSubnetState() { + return subnetState; + } + + /** + * The vpc ID this subnet belongs to. + */ + public String getVpcId() { + return vpcId; + } + + /** + * The CIDR block for this subnet. + */ + public String getCidrBlock() { + return cidrBlock; + } + + /** + * The number of available IPs in this subnet. + */ + public int getAvailableIpAddressCount() { + return availableIpAddressCount; + } + + /** + * The availability zone this subnet is in. + */ + public String getAvailabilityZone() { + return availabilityZone; + } + + /** + * Tags that are attached to this subnet. + */ + public Map<String, String> getTags() { + return tags; + } + + @Override + public int hashCode() { + return Objects.hashCode(subnetId, vpcId, availabilityZone); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null || getClass() != obj.getClass()) + return false; + Subnet that = Subnet.class.cast(obj); + return Objects.equal(this.subnetId, that.subnetId) && Objects.equal(this.vpcId, that.vpcId) + && Objects.equal(this.availabilityZone, that.availabilityZone); + } + + @Override + public String toString() { + return string().toString(); + } + + private ToStringHelper string() { + return Objects.toStringHelper(this).omitNullValues().add("subnetId", subnetId).add("subnetState", subnetState) + .add("vpcId", vpcId).add("cidrBlock", cidrBlock).add("availableIpAddressCount", availableIpAddressCount) + .add("availabilityZone", availabilityZone).add("tags", tags); + } + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return builder().from(this); + } + + public static final class Builder { + private String subnetId; + private State subnetState; + private String vpcId; + private String cidrBlock; + private int availableIpAddressCount; + private String availabilityZone; + private ImmutableMap.Builder<String, String> tags = ImmutableMap.<String, String> builder(); + + /** + * @see Subnet#getSubnetId() + */ + public Builder subnetId(String subnetId) { + this.subnetId = subnetId; + return this; + } + + /** + * @see Subnet#getState() + */ + public Builder subnetState(State subnetState) { + this.subnetState = subnetState; + return this; + } + + /** + * @see Subnet#getVpcId() + */ + public Builder vpcId(String vpcId) { + this.vpcId = vpcId; + return this; + } + + /** + * @see Subnet#getCidrBlock() + */ + public Builder cidrBlock(String cidrBlock) { + this.cidrBlock = cidrBlock; + return this; + } + + /** + * @see Subnet#getAvailableIpAddressCount() + */ + public Builder availableIpAddressCount(int availableIpAddressCount) { + this.availableIpAddressCount = availableIpAddressCount; + return this; + } + + /** + * @see Subnet#getAvailabilityZone() + */ + public Builder availabilityZone(String availabilityZone) { + this.availabilityZone = availabilityZone; + return this; + } + + /** + * @see Subnet#getTags() + */ + public Builder tags(Map<String, String> tags) { + this.tags.putAll(checkNotNull(tags, "tags")); + return this; + } + + /** + * @see Subnet#getTags() + */ + public Builder tag(String key) { + return tag(key, ""); + } + + /** + * @see Subnet#getTags() + */ + public Builder tag(String key, String value) { + this.tags.put(checkNotNull(key, "key"), checkNotNull(value, "value")); + return this; + } + + public Subnet build() { + return new Subnet(subnetId, subnetState, vpcId, cidrBlock, availableIpAddressCount, availabilityZone, + tags.build()); + } + + public Builder from(Subnet in) { + return this.subnetId(in.getSubnetId()).subnetState(in.getSubnetState()).vpcId(in.getVpcId()) + .cidrBlock(in.getCidrBlock()).availableIpAddressCount(in.getAvailableIpAddressCount()) + .availabilityZone(in.getAvailabilityZone()).tags(in.getTags()); + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Tag.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Tag.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Tag.java new file mode 100644 index 0000000..4c2b376 --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Tag.java @@ -0,0 +1,194 @@ +/* + * 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.ec2.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.Objects; +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.base.Optional; + +/** + * To help you manage your Amazon EC2 instances, images, and other Amazon EC2 + * resources, you can assign your own metadata to each resource in the form of + * tags. + * + * @see <a + * href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/Using_Tags.html" + * >doc</a> + */ +public class Tag { + + /** + * Describes the well-known resource types that can be tagged. + */ + public interface ResourceType { + public static final String CUSTOMER_GATEWAY = "customer-gateway"; + public static final String DHCP_OPTIONS = "dhcp-options"; + public static final String IMAGE = "image"; + public static final String INSTANCE = "instance"; + public static final String INTERNET_GATEWAY = "internet-gateway"; + public static final String NETWORK_ACL = "network-acl"; + public static final String RESERVED_INSTANCES = "reserved-instances"; + public static final String ROUTE_TABLE = "route-table"; + public static final String SECURITY_GROUP = "security-group"; + public static final String SNAPSHOT = "snapshot"; + public static final String SPOT_INSTANCES_REQUEST = "spot-instances-request"; + public static final String SUBNET = "subnet"; + public static final String VOLUME = "volume"; + public static final String VPC = "vpc"; + public static final String VPN_CONNECTION = "vpn-connection"; + public static final String VPN_GATEWAY = "vpn-gateway"; + } + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return builder().fromTag(this); + } + + public static class Builder { + + protected String resourceId; + protected String resourceType; + protected String key; + protected Optional<String> value = Optional.absent(); + + /** + * @see Tag#getResourceId() + */ + public Builder resourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + + /** + * @see Tag#getResourceType() + */ + public Builder resourceType(String resourceType) { + this.resourceType = resourceType; + return this; + } + + /** + * @see Tag#getKey() + */ + public Builder key(String key) { + this.key = key; + return this; + } + + /** + * @see TagGroup#getValue() + */ + public Builder value(String value) { + this.value = Optional.fromNullable(value); + return this; + } + + public Tag build() { + return new Tag(resourceId, resourceType, key, value); + } + + public Builder fromTag(Tag in) { + return this.resourceId(in.getResourceId()).resourceType(in.getResourceType()).key(in.getKey()) + .value(in.getValue().orNull()); + } + } + + protected final String resourceId; + protected final String resourceType; + protected final String key; + protected final Optional<String> value; + + protected Tag(String resourceId, String resourceType, String key, Optional<String> value) { + this.resourceId = checkNotNull(resourceId, "resourceId"); + this.resourceType = checkNotNull(resourceType, "resourceType"); + this.key = checkNotNull(key, "key"); + this.value = checkNotNull(value, "value"); + } + + /** + * The resource ID ex. i-erf235 + */ + public String getResourceId() { + return resourceId; + } + + /** + * The resource type. ex. customer-gateway, dhcp-options, image, instance, + * internet-gateway, network-acl, reserved-instances, route-table, + * security-group, snapshot, spot-instances-request, subnet, volume, vpc, + * vpn-connection, vpn-gateway + */ + public String getResourceType() { + return resourceType; + } + + /** + * The tag key. + */ + public String getKey() { + return key; + } + + /** + * The tag value. + */ + public Optional<String> getValue() { + return value; + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return Objects.hashCode(resourceId, key); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Tag other = (Tag) obj; + return Objects.equal(this.resourceId, other.resourceId) && Objects.equal(this.key, other.key); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return string().toString(); + } + + protected ToStringHelper string() { + return Objects.toStringHelper(this).omitNullValues().add("resourceId", resourceId) + .add("resourceType", resourceType).add("key", key).add("value", value.orNull()); + } + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/UserIdGroupPair.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/UserIdGroupPair.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/UserIdGroupPair.java new file mode 100644 index 0000000..5177cb0 --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/UserIdGroupPair.java @@ -0,0 +1,99 @@ +/* + * 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.ec2.domain; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * + * @see <a href= + * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-UserIdGroupPairType.html" + * /> + */ +public class UserIdGroupPair implements Comparable<UserIdGroupPair> { + private final String userId; + private final String groupName; + + public UserIdGroupPair(String userId, String groupName) { + this.userId = checkNotNull(userId, "userId"); + this.groupName = checkNotNull(groupName, "groupName"); + } + + + @Override + public String toString() { + return "[userId=" + userId + ", groupName=" + groupName + "]"; + } + + + /** + * {@inheritDoc} + */ + public int compareTo(UserIdGroupPair o) { + return (this == o) ? 0 : getUserId().compareTo(o.getUserId()); + } + + + /** + * AWS User ID of an identity. Cannot be used when specifying a CIDR IP address. + */ + public String getUserId() { + return userId; + } + + + /** + * Name of the security group. Cannot be used when specifying a CIDR IP address. + */ + public String getGroupName() { + return groupName; + } + + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((groupName == null) ? 0 : groupName.hashCode()); + result = prime * result + ((userId == null) ? 0 : userId.hashCode()); + return result; + } + + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + UserIdGroupPair other = (UserIdGroupPair) obj; + if (groupName == null) { + if (other.groupName != null) + return false; + } else if (!groupName.equals(other.groupName)) + return false; + if (userId == null) { + if (other.userId != null) + return false; + } else if (!userId.equals(other.userId)) + return false; + return true; + } + +} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/VirtualizationType.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/VirtualizationType.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/VirtualizationType.java new file mode 100644 index 0000000..68ddc33 --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/VirtualizationType.java @@ -0,0 +1,45 @@ +/* + * 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.ec2.domain; + +import com.google.common.base.CaseFormat; + +/** + * Virtualization type of the image. + */ +public enum VirtualizationType { + + PARAVIRTUAL, + + HVM, UNRECOGNIZED; + + public String value() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name()); + } + + public String toString() { + return value(); + } + + public static VirtualizationType fromValue(String v) { + try { + return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, v)); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/397d9926/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Volume.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Volume.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Volume.java new file mode 100644 index 0000000..76e40c1 --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Volume.java @@ -0,0 +1,352 @@ +/* + * 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.ec2.domain; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Sets.newHashSet; + +import java.util.Date; +import java.util.Set; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.CaseFormat; +import com.google.common.collect.ImmutableSet; + +/** + * + * @see <a href= + * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateVolume.html" + * /> + */ +public class Volume implements Comparable<Volume> { + + public Builder toBuilder() { + return builder().fromVolume(this); + } + + /** + * Specifies whether the instance's Amazon EBS volumes are stopped or terminated when the + * instance is shut down. + * + */ + public static enum InstanceInitiatedShutdownBehavior { + STOP, TERMINATE, UNRECOGNIZED; + public String value() { + return name().toLowerCase(); + } + + @Override + public String toString() { + return value(); + } + + public static InstanceInitiatedShutdownBehavior fromValue(String status) { + try { + return valueOf(checkNotNull(status, "status").toUpperCase()); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + } + + public static enum Status { + CREATING, AVAILABLE, IN_USE, DELETING, ERROR, UNRECOGNIZED; + public String value() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name()); + } + + @Override + public String toString() { + return value(); + } + + public static Status fromValue(String status) { + try { + return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(status, "status"))); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private String region; + private String id; + private int size; + @Nullable + private String snapshotId; + private String availabilityZone; + private Status status; + private Date createTime; + private Set<Attachment> attachments = ImmutableSet.of(); + @Nullable + private String volumeType; + @Nullable + private Integer iops; + private boolean encrypted = false; + + public Builder region(String region) { + this.region = region; + return this; + } + + public Builder id(String id) { + this.id = id; + return this; + } + + public Builder size(int size) { + this.size = size; + return this; + } + + public Builder snapshotId(String snapshotId) { + this.snapshotId = snapshotId; + return this; + } + + public Builder availabilityZone(String availabilityZone) { + this.availabilityZone = availabilityZone; + return this; + } + + public Builder status(Status status) { + this.status = status; + return this; + } + + public Builder createTime(Date createTime) { + this.createTime = createTime; + return this; + } + + public Builder attachments(Attachment... attachments) { + this.attachments = newHashSet(attachments); + return this; + } + + public Builder attachments(Set<Attachment> attachments) { + this.attachments = ImmutableSet.copyOf(attachments); + return this; + } + + public Builder volumeType(String volumeType) { + this.volumeType = volumeType; + return this; + } + + public Builder iops(Integer iops) { + this.iops = iops; + return this; + } + + public Builder encrypted(boolean encrypted) { + this.encrypted = encrypted; + return this; + } + + public Volume build() { + return new Volume(region, id, size, snapshotId, availabilityZone, status, createTime, + volumeType, iops, encrypted, attachments); + } + + public Builder fromVolume(Volume in) { + return region(in.region).id(in.id).size(in.size).snapshotId(in.snapshotId) + .availabilityZone(in.availabilityZone).status(in.status).createTime(in.createTime) + .volumeType(in.volumeType).iops(in.iops).encrypted(in.encrypted).attachments(in.attachments); + } + } + + private final String region; + private final String id; + private final int size; + @Nullable + private final String snapshotId; + private final String availabilityZone; + private final Status status; + private final Date createTime; + private final Set<Attachment> attachments; + + @Nullable + private final String volumeType; + @Nullable + private final Integer iops; + private final boolean encrypted; + + public Volume(String region, String id, int size, String snapshotId, String availabilityZone, Volume.Status status, + Date createTime, String volumeType, Integer iops, boolean encrypted, Iterable<Attachment> attachments) { + this.region = checkNotNull(region, "region"); + this.id = id; + this.size = size; + this.snapshotId = snapshotId; + this.availabilityZone = availabilityZone; + this.status = status; + this.createTime = createTime; + this.volumeType = volumeType; + this.iops = iops; + this.encrypted = encrypted; + this.attachments = ImmutableSet.copyOf(attachments); + } + + /** + * To be removed in jclouds 1.6 <h4>Warning</h4> + * + * Especially on EC2 clones that may not support regions, this value is fragile. Consider + * alternate means to determine context. + */ + @Deprecated + public String getRegion() { + return region; + } + + public String getId() { + return id; + } + + public int getSize() { + return size; + } + + public String getSnapshotId() { + return snapshotId; + } + + public String getAvailabilityZone() { + return availabilityZone; + } + + public Status getStatus() { + return status; + } + + public Date getCreateTime() { + return createTime; + } + + public String getVolumeType() { + return volumeType; + } + + public Integer getIops() { + return iops; + } + + public boolean getEncrypted() { + return encrypted; + } + + public Set<Attachment> getAttachments() { + return attachments; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((attachments == null) ? 0 : attachments.hashCode()); + result = prime * result + ((availabilityZone == null) ? 0 : availabilityZone.hashCode()); + result = prime * result + ((createTime == null) ? 0 : createTime.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((region == null) ? 0 : region.hashCode()); + result = prime * result + size; + result = prime * result + ((snapshotId == null) ? 0 : snapshotId.hashCode()); + result = prime * result + ((status == null) ? 0 : status.hashCode()); + result = prime * result + ((volumeType == null) ? 0 : volumeType.hashCode()); + result = prime * result + ((iops == null) ? 0 : iops.hashCode()); + result = prime * result + (encrypted ? 1249 : 1259); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Volume other = (Volume) obj; + if (attachments == null) { + if (other.attachments != null) + return false; + } else if (!attachments.equals(other.attachments)) + return false; + if (availabilityZone == null) { + if (other.availabilityZone != null) + return false; + } else if (!availabilityZone.equals(other.availabilityZone)) + return false; + if (createTime == null) { + if (other.createTime != null) + return false; + } else if (!createTime.equals(other.createTime)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (region == null) { + if (other.region != null) + return false; + } else if (!region.equals(other.region)) + return false; + if (size != other.size) + return false; + if (snapshotId == null) { + if (other.snapshotId != null) + return false; + } else if (!snapshotId.equals(other.snapshotId)) + return false; + if (status == null) { + if (other.status != null) + return false; + } else if (!status.equals(other.status)) + return false; + if (volumeType == null) { + if (other.volumeType != null) + return false; + } else if (!volumeType.equals(other.volumeType)) + return false; + if (iops == null) { + if (other.iops != null) + return false; + } else if (!iops.equals(other.iops)) + return false; + if (encrypted != other.encrypted) + return false; + return true; + } + + @Override + public int compareTo(Volume that) { + return id.compareTo(that.id); + } + + @Override + public String toString() { + return "Volume [attachments=" + attachments + ", availabilityZone=" + availabilityZone + ", createTime=" + + createTime + ", id=" + id + ", region=" + region + ", size=" + size + ", snapshotId=" + snapshotId + + ", status=" + status + ", volumeType=" + volumeType + ", iops=" + iops + ", encrypted=" + encrypted + + "]"; + } +}
