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/BlockDeviceMapping.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BlockDeviceMapping.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BlockDeviceMapping.java new file mode 100644 index 0000000..b270c3f --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BlockDeviceMapping.java @@ -0,0 +1,292 @@ +/* + * 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.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Strings.emptyToNull; + +import org.jclouds.javax.annotation.Nullable; + +public class BlockDeviceMapping implements Comparable<BlockDeviceMapping> { + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private String deviceName; + private String virtualName; + private String snapshotId; + private Integer sizeInGib; + private Boolean noDevice; + private Boolean deleteOnTermination; + private String volumeType; + private Integer iops; + private Boolean encrypted; + + public Builder deviceName(String deviceName) { + this.deviceName = deviceName; + return this; + } + + public Builder virtualName(String virtualName) { + this.virtualName = virtualName; + return this; + } + + public Builder snapshotId(String snapshotId) { + this.snapshotId = snapshotId; + return this; + } + + public Builder sizeInGib(Integer sizeInGib) { + this.sizeInGib = sizeInGib; + return this; + } + + public Builder noDevice(Boolean noDevice) { + this.noDevice = noDevice; + return this; + } + + public Builder deleteOnTermination(Boolean deleteOnTermination) { + this.deleteOnTermination = deleteOnTermination; + 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 BlockDeviceMapping build() { + return new BlockDeviceMapping(deviceName, virtualName, snapshotId, sizeInGib, noDevice, deleteOnTermination, + volumeType, iops, encrypted); + } + + public Builder clear() { + this.deviceName = null; + this.virtualName = null; + this.snapshotId = null; + this.sizeInGib = null; + this.noDevice = null; + this.deleteOnTermination = null; + this.volumeType = null; + this.iops = null; + this.encrypted = null; + return this; + } + } + + private final String deviceName; + private final String virtualName; + private final String snapshotId; + private final Integer sizeInGib; + private final Boolean noDevice; + private final Boolean deleteOnTermination; + private final String volumeType; + private final Integer iops; + private final Boolean encrypted; + + // values expressed in GB + private static final Integer VOLUME_SIZE_MIN_VALUE = 1; + private static final Integer VOLUME_SIZE_MAX_VALUE = 1000; + + BlockDeviceMapping(String deviceName, @Nullable String virtualName, @Nullable String snapshotId, + @Nullable Integer sizeInGib, @Nullable Boolean noDevice, @Nullable Boolean deleteOnTermination, + @Nullable String volumeType, @Nullable Integer iops, @Nullable Boolean encrypted) { + + checkNotNull(deviceName, "deviceName cannot be null"); + checkNotNull(emptyToNull(deviceName), "deviceName must be defined"); + + if (sizeInGib != null) { + checkArgument(sizeInGib >= VOLUME_SIZE_MIN_VALUE && sizeInGib <= VOLUME_SIZE_MAX_VALUE, + String.format("Size in Gib must be between %s and %s GB", VOLUME_SIZE_MIN_VALUE, VOLUME_SIZE_MAX_VALUE)); + } + this.deviceName = deviceName; + this.virtualName = virtualName; + this.snapshotId = snapshotId; + this.sizeInGib = sizeInGib; + this.noDevice = noDevice; + this.deleteOnTermination = deleteOnTermination; + this.volumeType = volumeType; + this.iops = iops; + this.encrypted = encrypted; + } + + public String getDeviceName() { + return deviceName; + } + + public String getVirtualName() { + return virtualName; + } + + public String getEbsSnapshotId() { + return snapshotId; + } + + public Integer getEbsVolumeSize() { + return sizeInGib; + } + + public Boolean getEbsNoDevice() { + return noDevice; + } + + public Boolean getEbsDeleteOnTermination() { + return deleteOnTermination; + } + + public String getEbsVolumeType() { + return volumeType; + } + + public Integer getEbsIops() { + return iops; + } + + public Boolean getEbsEncrypted() { + return encrypted; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((deleteOnTermination == null) ? 0 : deleteOnTermination.hashCode()); + result = prime * result + ((deviceName == null) ? 0 : deviceName.hashCode()); + result = prime * result + ((noDevice == null) ? 0 : noDevice.hashCode()); + result = prime * result + ((sizeInGib == null) ? 0 : sizeInGib.hashCode()); + result = prime * result + ((snapshotId == null) ? 0 : snapshotId.hashCode()); + result = prime * result + ((virtualName == null) ? 0 : virtualName.hashCode()); + result = prime * result + ((volumeType == null) ? 0 : volumeType.hashCode()); + result = prime * result + ((iops == null) ? 0 : iops.hashCode()); + result = prime * result + ((encrypted == null ) ? 0 : encrypted.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; + BlockDeviceMapping other = (BlockDeviceMapping) obj; + if (deleteOnTermination == null) { + if (other.deleteOnTermination != null) + return false; + } else if (!deleteOnTermination.equals(other.deleteOnTermination)) + return false; + if (deviceName == null) { + if (other.deviceName != null) + return false; + } else if (!deviceName.equals(other.deviceName)) + return false; + if (noDevice == null) { + if (other.noDevice != null) + return false; + } else if (!noDevice.equals(other.noDevice)) + return false; + if (sizeInGib == null) { + if (other.sizeInGib != null) + return false; + } else if (!sizeInGib.equals(other.sizeInGib)) + return false; + if (snapshotId == null) { + if (other.snapshotId != null) + return false; + } else if (!snapshotId.equals(other.snapshotId)) + return false; + if (virtualName == null) { + if (other.virtualName != null) + return false; + } else if (!virtualName.equals(other.virtualName)) + 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 == null) { + if (other.encrypted != null) + return false; + } else if (!encrypted.equals(other.encrypted)) + return false; + return true; + } + + @Override + public String toString() { + return "[deviceName=" + deviceName + ", virtualName=" + virtualName + ", snapshotId=" + snapshotId + + ", sizeInGib=" + sizeInGib + ", noDevice=" + noDevice + ", deleteOnTermination=" + deleteOnTermination + + ", volumeType=" + volumeType + ", iops=" + iops + ", encrypted=" + encrypted + + "]"; + } + + public static class MapEBSSnapshotToDevice extends BlockDeviceMapping { + public MapEBSSnapshotToDevice(String deviceName, String snapshotId, @Nullable Integer sizeInGib, + @Nullable Boolean deleteOnTermination, @Nullable String volumeType, + @Nullable Integer iops, @Nullable Boolean encrypted) { + super(deviceName, null, snapshotId, sizeInGib, null, deleteOnTermination, volumeType, iops, encrypted); + checkNotNull(emptyToNull(snapshotId), "snapshotId must be defined"); + } + } + + public static class MapNewVolumeToDevice extends BlockDeviceMapping { + public MapNewVolumeToDevice(String deviceName, Integer sizeInGib, @Nullable Boolean deleteOnTermination, + @Nullable String volumeType, @Nullable Integer iops, @Nullable Boolean encrypted) { + super(deviceName, null, null, sizeInGib, null, deleteOnTermination, volumeType, iops, encrypted); + checkNotNull(sizeInGib, "sizeInGib cannot be null"); + } + } + + public static class MapEphemeralDeviceToDevice extends BlockDeviceMapping { + public MapEphemeralDeviceToDevice(String deviceName, String virtualName) { + super(deviceName, virtualName, null, null, null, null, null, null, null); + checkNotNull(emptyToNull(virtualName), "virtualName must be defined"); + } + } + + public static class UnmapDeviceNamed extends BlockDeviceMapping { + public UnmapDeviceNamed(String deviceName) { + super(deviceName, null, null, null, true, null, null, null, null); + } + } + + @Override + public int compareTo(BlockDeviceMapping arg0) { + return deviceName.compareTo(arg0.deviceName); + } +}
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/BundleInstanceS3Storage.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BundleInstanceS3Storage.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BundleInstanceS3Storage.java new file mode 100644 index 0000000..03a0a1f --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BundleInstanceS3Storage.java @@ -0,0 +1,149 @@ +/* + * 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-BundleInstanceS3StorageType.html" + * /> + */ +public class BundleInstanceS3Storage { + private final String ccessKeyId; + private final String bucket; + private final String prefix; + private final String secretAccessKey; + private final String uploadPolicy; + private final String uploadPolicySignature; + + public BundleInstanceS3Storage(@Nullable String ccessKeyId, String bucket, String prefix, + @Nullable String secretAccessKey, @Nullable String uploadPolicy, @Nullable String uploadPolicySignature) { + this.ccessKeyId = ccessKeyId; + this.bucket = checkNotNull(bucket, "bucket"); + this.prefix = checkNotNull(prefix, "prefix"); + this.secretAccessKey = secretAccessKey; + this.uploadPolicy = uploadPolicy; + this.uploadPolicySignature = uploadPolicySignature; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((ccessKeyId == null) ? 0 : ccessKeyId.hashCode()); + result = prime * result + ((bucket == null) ? 0 : bucket.hashCode()); + result = prime * result + ((prefix == null) ? 0 : prefix.hashCode()); + result = prime * result + ((secretAccessKey == null) ? 0 : secretAccessKey.hashCode()); + result = prime * result + ((uploadPolicy == null) ? 0 : uploadPolicy.hashCode()); + result = prime * result + ((uploadPolicySignature == null) ? 0 : uploadPolicySignature.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; + BundleInstanceS3Storage other = (BundleInstanceS3Storage) obj; + if (ccessKeyId == null) { + if (other.ccessKeyId != null) + return false; + } else if (!ccessKeyId.equals(other.ccessKeyId)) + return false; + if (bucket == null) { + if (other.bucket != null) + return false; + } else if (!bucket.equals(other.bucket)) + return false; + if (prefix == null) { + if (other.prefix != null) + return false; + } else if (!prefix.equals(other.prefix)) + return false; + if (secretAccessKey == null) { + if (other.secretAccessKey != null) + return false; + } else if (!secretAccessKey.equals(other.secretAccessKey)) + return false; + if (uploadPolicy == null) { + if (other.uploadPolicy != null) + return false; + } else if (!uploadPolicy.equals(other.uploadPolicy)) + return false; + if (uploadPolicySignature == null) { + if (other.uploadPolicySignature != null) + return false; + } else if (!uploadPolicySignature.equals(other.uploadPolicySignature)) + return false; + return true; + } + + @Override + public String toString() { + return "[ccessKeyId=" + ccessKeyId + ", bucket=" + bucket + ", prefix=" + prefix + ", secretAccessKey=" + + secretAccessKey + ", uploadPolicy=" + uploadPolicy + ", uploadPolicySignature=" + uploadPolicySignature + + "]"; + } + + + /** + * + * @returnThe bucket in which to store the AMI. You can specify a bucket that + * you already own or a new bucket that Amazon EC2 creates on your + * behalf. If you specify a bucket that belongs to someone else, + * Amazon EC2 returns an error. + */ + public String getBucket() { + return bucket; + } + + /** + * + * @return Specifies the beginning of the file name of the AMI. + */ + public String getPrefix() { + return prefix; + } + + + + /** + * + * @return An Amazon S3 upload policy that gives Amazon EC2 permission to + * upload items into Amazon S3 on the user's behalf. For more + * information on bundling in Windows, go to the Amazon Elastic + * Compute Cloud Developer Guide and Amazon Elastic Compute Cloud + * Getting Started + */ + public String getUploadPolicy() { + return uploadPolicy; + } + + /** + * + * @return The signature of the Base64 encoded JSON document. + */ + public String getUploadPolicySignature() { + return uploadPolicySignature; + } +} 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/BundleTask.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BundleTask.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BundleTask.java new file mode 100644 index 0000000..2a13241 --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BundleTask.java @@ -0,0 +1,293 @@ +/* + * 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 org.jclouds.javax.annotation.Nullable; + +/** + * + * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-BundleInstanceTaskType.html" + * /> + */ +public class BundleTask implements Comparable<BundleTask> { + /** + * {@inheritDoc} + */ + public int compareTo(BundleTask o) { + return (this == o) ? 0 : getBundleId().compareTo(o.getBundleId()); + } + + /** + * If the task fails, a description of the error. + * + * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-BundleInstanceTaskErrorType.html" + * /> + */ + public static class Error { + private final String code; + private final String message; + + public Error(String code, String message) { + this.code = checkNotNull(code, "code"); + this.message = checkNotNull(message, "message"); + } + + public String getCode() { + return code; + } + + public String getMessage() { + return message; + } + + @Override + public String toString() { + return "[code=" + code + ", message=" + message + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((code == null) ? 0 : code.hashCode()); + result = prime * result + ((message == null) ? 0 : message.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; + Error other = (Error) obj; + if (code == null) { + if (other.code != null) + return false; + } else if (!code.equals(other.code)) + return false; + if (message == null) { + if (other.message != null) + return false; + } else if (!message.equals(other.message)) + return false; + return true; + } + + } + + private final String region; + private final String bundleId; + private final Error error; + private final String instanceId; + private final int progress; + private final Date startTime; + private final String state; + private final String bucket; + private final String prefix; + private final Date updateTime; + + public BundleTask(String region, String bundleId, @Nullable Error error, String instanceId, int progress, + Date startTime, String state, String bucket, String prefix, Date updateTime) { + this.region = checkNotNull(region, "region"); + this.bundleId = checkNotNull(bundleId, "bundleId"); + this.error = error; + this.instanceId = checkNotNull(instanceId, "instanceId"); + this.progress = checkNotNull(progress, "progress"); + this.startTime = checkNotNull(startTime, "startTime"); + this.state = checkNotNull(state, "state"); + this.bucket = checkNotNull(bucket, "bucket"); + this.prefix = checkNotNull(prefix, "prefix"); + this.updateTime = checkNotNull(updateTime, "updateTime"); + } + + @Override + public String toString() { + return "[bucket=" + bucket + ", bundleId=" + bundleId + ", error=" + error + ", instanceId=" + instanceId + + ", prefix=" + prefix + ", progress=" + progress + ", region=" + region + ", startTime=" + startTime + + ", state=" + state + ", updateTime=" + updateTime + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((bucket == null) ? 0 : bucket.hashCode()); + result = prime * result + ((bundleId == null) ? 0 : bundleId.hashCode()); + result = prime * result + ((error == null) ? 0 : error.hashCode()); + result = prime * result + ((instanceId == null) ? 0 : instanceId.hashCode()); + result = prime * result + ((prefix == null) ? 0 : prefix.hashCode()); + result = prime * result + progress; + result = prime * result + ((region == null) ? 0 : region.hashCode()); + result = prime * result + ((startTime == null) ? 0 : startTime.hashCode()); + result = prime * result + ((state == null) ? 0 : state.hashCode()); + result = prime * result + ((updateTime == null) ? 0 : updateTime.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; + BundleTask other = (BundleTask) obj; + if (bucket == null) { + if (other.bucket != null) + return false; + } else if (!bucket.equals(other.bucket)) + return false; + if (bundleId == null) { + if (other.bundleId != null) + return false; + } else if (!bundleId.equals(other.bundleId)) + return false; + if (error == null) { + if (other.error != null) + return false; + } else if (!error.equals(other.error)) + return false; + if (instanceId == null) { + if (other.instanceId != null) + return false; + } else if (!instanceId.equals(other.instanceId)) + return false; + if (prefix == null) { + if (other.prefix != null) + return false; + } else if (!prefix.equals(other.prefix)) + 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 (state == null) { + if (other.state != null) + return false; + } else if (!state.equals(other.state)) + return false; + if (updateTime == null) { + if (other.updateTime != null) + return false; + } else if (!updateTime.equals(other.updateTime)) + return false; + return true; + } + + /** + * 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 bucket in which to store the AMI. You can specify a bucket + * that you already own or a new bucket that Amazon EC2 creates on + * your behalf. If you specify a bucket that belongs to someone e + * lse, Amazon EC2 returns an error. + */ + public String getBucket() { + return bucket; + } + + /** + * + * @return Specifies the beginning of the file name of the AMI. + */ + public String getPrefix() { + return prefix; + } + + /** + * + * @return Identifier for this task. + */ + public String getBundleId() { + return bundleId; + } + + /** + * + * @return If the task fails, a description of the error. + */ + public Error getError() { + return error; + } + + /** + * + * @return Instance associated with this bundle task + */ + public String getInstanceId() { + return instanceId; + } + + /** + * + * @return A percentage description of the progress of the task, such as 20. + */ + public int getProgress() { + return progress; + } + + /** + * + * @return The time this task started. + */ + public Date getStartTime() { + return startTime; + } + + /** + * + * @return The state of the task. + */ + public String getState() { + return state; + } + + /** + * + * @return The time of the most recent update for the task. + */ + public Date getUpdateTime() { + return updateTime; + } + +} 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/Hypervisor.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Hypervisor.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Hypervisor.java new file mode 100644 index 0000000..a85ed0d --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Hypervisor.java @@ -0,0 +1,47 @@ +/* + * 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; + +/** + * Hypervisor of the image. + */ +public enum Hypervisor { + + XEN, + /** + * Oracle VM Server + */ + OVM, UNRECOGNIZED; + + public String value() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name()); + } + + public String toString() { + return value(); + } + + public static Hypervisor 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/Image.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Image.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Image.java new file mode 100644 index 0000000..42136cd --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Image.java @@ -0,0 +1,530 @@ +/* + * 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 java.util.Set; + +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.collect.Iterables; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; + +/** + * + * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-DescribeImagesResponseItemType.html" + * /> + */ +public class Image implements Comparable<Image> { + + private final String region; + private final Architecture architecture; + @Nullable + private final String name; + @Nullable + private final String description; + private final String imageId; + private final String imageLocation; + private final String imageOwnerId; + private final ImageState imageState; + private final String rawState; + private final ImageType imageType; + private final boolean isPublic; + @Nullable + private final String kernelId; + @Nullable + private final String platform; + private final Set<String> productCodes = Sets.newHashSet(); + @Nullable + private final String ramdiskId; + private final RootDeviceType rootDeviceType; + @Nullable + private final String rootDeviceName; + private final Map<String, EbsBlockDevice> ebsBlockDevices = Maps.newHashMap(); + private final Map<String, String> tags = Maps.newLinkedHashMap(); + private final VirtualizationType virtualizationType; + + public VirtualizationType getVirtualizationType() { + return virtualizationType; + } + + private final Hypervisor hypervisor; + + public Hypervisor getHypervisor() { + return hypervisor; + } + + public Image(String region, Architecture architecture, @Nullable String name, @Nullable String description, + String imageId, String imageLocation, String imageOwnerId, ImageState imageState, String rawState, + ImageType imageType, boolean isPublic, Iterable<String> productCodes, @Nullable String kernelId, + @Nullable String platform, @Nullable String ramdiskId, RootDeviceType rootDeviceType, + @Nullable String rootDeviceName, Map<String, EbsBlockDevice> ebsBlockDevices, + Map<String, String> tags, VirtualizationType virtualizationType, Hypervisor hypervisor) { + this.region = checkNotNull(region, "region"); + this.architecture = architecture; + this.imageId = checkNotNull(imageId, "imageId"); + this.name = name; + this.description = description; + this.rootDeviceName = rootDeviceName; + this.imageLocation = checkNotNull(imageLocation, "imageLocation"); + this.imageOwnerId = checkNotNull(imageOwnerId, "imageOwnerId"); + this.imageState = checkNotNull(imageState, "imageState"); + this.rawState = checkNotNull(rawState, "rawState"); + this.imageType = checkNotNull(imageType, "imageType"); + this.isPublic = isPublic; + this.kernelId = kernelId; + this.platform = platform; + Iterables.addAll(this.productCodes, checkNotNull(productCodes, "productCodes")); + this.ramdiskId = ramdiskId; + this.rootDeviceType = checkNotNull(rootDeviceType, "rootDeviceType"); + this.ebsBlockDevices.putAll(checkNotNull(ebsBlockDevices, "ebsBlockDevices")); + this.tags.putAll(checkNotNull(tags, "tags")); + this.virtualizationType = checkNotNull(virtualizationType, "virtualizationType"); + this.hypervisor = checkNotNull(hypervisor, "hypervisor"); + } + + public static enum ImageState { + /** + * the image is successfully registered and available for launching + */ + AVAILABLE, + /** + * the image is deregistered and no longer available for launching + */ + DEREGISTERED, UNRECOGNIZED; + public String value() { + return name().toLowerCase(); + } + + public static ImageState fromValue(String v) { + try { + return valueOf(v.toUpperCase()); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + } + + public static enum Architecture { + I386, X86_64, UNRECOGNIZED; + public String value() { + return name().toLowerCase(); + } + + public static Architecture fromValue(String v) { + try { + return valueOf(v.toUpperCase()); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + } + + public static enum ImageType { + + MACHINE, KERNEL, RAMDISK, UNRECOGNIZED; + public String value() { + return name().toLowerCase(); + } + + public static ImageType fromValue(String v) { + try { + return valueOf(v.toUpperCase()); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + + } + + public static class EbsBlockDevice { + @Nullable + private final String snapshotId; + private final long volumeSize; + private final boolean deleteOnTermination; + private final String volumeType; + private final Integer iops; + private final boolean encrypted; + + public EbsBlockDevice(@Nullable String snapshotId, long volumeSize, boolean deleteOnTermination, + @Nullable String volumeType, @Nullable Integer iops, boolean encrypted) { + this.snapshotId = snapshotId; + this.volumeSize = volumeSize; + this.deleteOnTermination = deleteOnTermination; + this.volumeType = volumeType; + this.iops = iops; + this.encrypted = encrypted; + } + + public String getSnapshotId() { + return snapshotId; + } + + public long getVolumeSize() { + return volumeSize; + } + + public boolean isDeleteOnTermination() { + return deleteOnTermination; + } + + public String getVolumeType() { + return volumeType; + } + + public Integer getIops() { + return iops; + } + + public boolean isEncrypted() { + return encrypted; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (deleteOnTermination ? 1231 : 1237); + result = prime * result + ((snapshotId == null) ? 0 : snapshotId.hashCode()); + result = prime * result + (int) (volumeSize ^ (volumeSize >>> 32)); + result = prime * result + (encrypted ? 1249 : 1259); + result = prime * result + ((volumeType == null) ? 0 : volumeType.hashCode()); + result = prime * result + ((iops == null) ? 0 : iops.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; + EbsBlockDevice other = (EbsBlockDevice) obj; + if (deleteOnTermination != other.deleteOnTermination) + return false; + if (encrypted != other.encrypted) + return false; + if (snapshotId == null) { + if (other.snapshotId != null) + return false; + } else if (!snapshotId.equals(other.snapshotId)) + 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 (volumeSize != other.volumeSize) + return false; + return true; + } + + @Override + public String toString() { + return "EbsBlockDevice [deleteOnTermination=" + deleteOnTermination + ", snapshotId=" + snapshotId + + ", volumeSize=" + volumeSize + ", volumeType=" + volumeType + ", iops=" + iops + + ", encrypted=" + encrypted + "]"; + } + + } + + /** + * 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 architecture of the image (i386 or x86_64). + */ + public Architecture getArchitecture() { + return architecture; + } + + /** + * The ID of the AMI. + */ + public String getId() { + return imageId; + } + + /** + * The location of the AMI. + */ + public String getImageLocation() { + return imageLocation; + } + + /** + * AWS Access Key ID of the image owner. + */ + public String getImageOwnerId() { + return imageOwnerId; + } + + /** + * Current state of the AMI. If the operation returns available, the image is successfully + * registered and avail able for launching. If the operation returns deregistered, the image is + * deregistered and no longer available for launching. + */ + public ImageState getImageState() { + return imageState; + } + + /** + * raw form of {@link #getImageState()} as taken directly from the api response xml document/ + */ + public String getRawState() { + return rawState; + } + + /** + * The type of image (machine, kernel, or ramdisk). + */ + public ImageType getImageType() { + return imageType; + } + + /** + * Returns true if this image has public launch permissions. Returns false if it only has + * implicit and explicit launch permissions. + */ + public boolean isPublic() { + return isPublic; + } + + /** + * The kernel associated with the image, if any. Only applicable for machine images. + */ + public String getKernelId() { + return kernelId; + } + + /** + * The operating platform of the instance. + */ + public String getPlatform() { + return platform; + } + + /** + * Product codes of the AMI. + */ + public Set<String> getProductCodes() { + return productCodes; + } + + /** + * The RAM disk associated with the image, if any. Only applicable for machine images. + */ + public String getRamdiskId() { + return ramdiskId; + } + + /** + * {@inheritDoc} + */ + public int compareTo(Image o) { + return (this == o) ? 0 : getId().compareTo(o.getId()); + } + + /** + * + * @return The root device type used by the AMI. The AMI can use an Amazon EBS or instance store + * root device. + */ + public RootDeviceType getRootDeviceType() { + return rootDeviceType; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public String getRootDeviceName() { + return rootDeviceName; + } + + public Map<String, EbsBlockDevice> getEbsBlockDevices() { + return ebsBlockDevices; + } + + public Map<String, String> getTags() { + return tags; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((architecture == null) ? 0 : architecture.hashCode()); + result = prime * result + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((ebsBlockDevices == null) ? 0 : ebsBlockDevices.hashCode()); + result = prime * result + ((tags == null) ? 0 : tags.hashCode()); + result = prime * result + ((imageId == null) ? 0 : imageId.hashCode()); + result = prime * result + ((imageLocation == null) ? 0 : imageLocation.hashCode()); + result = prime * result + ((imageOwnerId == null) ? 0 : imageOwnerId.hashCode()); + result = prime * result + ((imageType == null) ? 0 : imageType.hashCode()); + result = prime * result + (isPublic ? 1231 : 1237); + result = prime * result + ((kernelId == null) ? 0 : kernelId.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((platform == null) ? 0 : platform.hashCode()); + result = prime * result + ((productCodes == null) ? 0 : productCodes.hashCode()); + result = prime * result + ((ramdiskId == null) ? 0 : ramdiskId.hashCode()); + result = prime * result + ((region == null) ? 0 : region.hashCode()); + result = prime * result + ((rootDeviceName == null) ? 0 : rootDeviceName.hashCode()); + result = prime * result + ((rootDeviceType == null) ? 0 : rootDeviceType.hashCode()); + result = prime * result + ((virtualizationType == null) ? 0 : virtualizationType.hashCode()); + result = prime * result + ((hypervisor == null) ? 0 : hypervisor.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; + Image other = (Image) obj; + if (architecture == null) { + if (other.architecture != null) + return false; + } else if (!architecture.equals(other.architecture)) + return false; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (ebsBlockDevices == null) { + if (other.ebsBlockDevices != null) + return false; + } else if (!ebsBlockDevices.equals(other.ebsBlockDevices)) + return false; + if (tags == null) { + if (other.tags != null) + return false; + } else if (!tags.equals(other.tags)) + return false; + if (imageId == null) { + if (other.imageId != null) + return false; + } else if (!imageId.equals(other.imageId)) + return false; + if (imageLocation == null) { + if (other.imageLocation != null) + return false; + } else if (!imageLocation.equals(other.imageLocation)) + return false; + if (imageOwnerId == null) { + if (other.imageOwnerId != null) + return false; + } else if (!imageOwnerId.equals(other.imageOwnerId)) + return false; + if (imageType == null) { + if (other.imageType != null) + return false; + } else if (!imageType.equals(other.imageType)) + return false; + if (isPublic != other.isPublic) + return false; + if (kernelId == null) { + if (other.kernelId != null) + return false; + } else if (!kernelId.equals(other.kernelId)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + if (platform == null) { + if (other.platform != null) + return false; + } else if (!platform.equals(other.platform)) + return false; + if (productCodes == null) { + if (other.productCodes != null) + return false; + } else if (!productCodes.equals(other.productCodes)) + return false; + if (ramdiskId == null) { + if (other.ramdiskId != null) + return false; + } else if (!ramdiskId.equals(other.ramdiskId)) + return false; + if (region == null) { + if (other.region != null) + return false; + } else if (!region.equals(other.region)) + return false; + if (rootDeviceName == null) { + if (other.rootDeviceName != null) + return false; + } else if (!rootDeviceName.equals(other.rootDeviceName)) + return false; + if (rootDeviceType == null) { + if (other.rootDeviceType != null) + return false; + } else if (!rootDeviceType.equals(other.rootDeviceType)) + return false; + if (virtualizationType == null) { + if (other.virtualizationType != null) + return false; + } else if (!virtualizationType.equals(other.virtualizationType)) + return false; + if (hypervisor == null) { + if (other.hypervisor != null) + return false; + } else if (!hypervisor.equals(other.hypervisor)) + return false; + return true; + } + + @Override + public String toString() { + return "Image [architecture=" + architecture + ", description=" + description + ", ebsBlockDevices=" + + ebsBlockDevices + ", imageId=" + imageId + ", imageLocation=" + imageLocation + ", imageOwnerId=" + + imageOwnerId + ", imageState=" + rawState + ", imageType=" + imageType + ", isPublic=" + isPublic + + ", kernelId=" + kernelId + ", name=" + name + ", platform=" + platform + ", productCodes=" + + productCodes + ", ramdiskId=" + ramdiskId + ", region=" + region + ", rootDeviceName=" + + rootDeviceName + ", rootDeviceType=" + rootDeviceType + ", virtualizationType=" + virtualizationType + + ", hypervisor=" + hypervisor + ", tags=" + tags + "]"; + } + +} 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/ImageAttribute.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/ImageAttribute.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/ImageAttribute.java new file mode 100644 index 0000000..cf1e7d4 --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/ImageAttribute.java @@ -0,0 +1,96 @@ +/* + * 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; + +/** + * + * An attribute of an AMI. + * + * @see EC2AsyncClient#modifyImageAttribute + * @see EC2AsyncClient#resetImageAttribute + * @see EC2AsyncClient#describeImageAttribute + */ +public enum ImageAttribute { + + /** + * the product code associated with the AMI. + */ + PRODUCT_CODES, + + /** + * the ID of the RAM disk associated with the AMI. + */ + RAMDISK, + + /** + * the ID of the kernel associated with the AMI. + */ + KERNEL, + /** + * the launch permissions of the AMI. + */ + LAUNCH_PERMISSION, + /** + * the operating system platform. + */ + PLATFORM, + /** + * the mapping that defines native device names to use when exposing virtual devices. + */ + BLOCK_DEVICE_MAPPING, UNRECOGNIZED; + public String value() { + switch (this) { + case PRODUCT_CODES: + return "productCodes"; + case RAMDISK: + return "ramdisk"; + case KERNEL: + return "kernel"; + case LAUNCH_PERMISSION: + return "launchPermission"; + case PLATFORM: + return "platform"; + case BLOCK_DEVICE_MAPPING: + return "blockDeviceMapping"; + default: + throw new IllegalArgumentException("unmapped attribute: " + super.name()); + } + } + + @Override + public String toString() { + return value(); + } + + public static ImageAttribute fromValue(String attribute) { + if ("productCodes".equals(attribute)) + return PRODUCT_CODES; + else if ("ramdisk".equals(attribute)) + return RAMDISK; + else if ("kernel".equals(attribute)) + return KERNEL; + else if ("launchPermission".equals(attribute)) + return LAUNCH_PERMISSION; + else if ("platform".equals(attribute)) + return PLATFORM; + else if ("blockDeviceMapping".equals(attribute)) + return BLOCK_DEVICE_MAPPING; + else + 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/InstanceState.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/InstanceState.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/InstanceState.java new file mode 100644 index 0000000..2a38809 --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/InstanceState.java @@ -0,0 +1,95 @@ +/* + * 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.CaseFormat; + +/** + * + * The current state of the instance.. + * + * @see EC2AsyncClient#describeInstances + * @see EC2AsyncClient#runInstances + * @see EC2AsyncClient#terminateInstances + */ +public enum InstanceState { + + /** + * the instance is in the process of being launched + */ + PENDING, + + /** + * the instance launched (although the boot process might not be completed) + */ + RUNNING, + + /** + * the instance started shutting down + */ + SHUTTING_DOWN, + /** + * the instance terminated + */ + TERMINATED, + /** + * the instance is stopping + */ + STOPPING, + /** + * the instance is stopped + */ + STOPPED, UNRECOGNIZED; + + public String value() { + return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name()); + } + + @Override + public String toString() { + return value(); + } + + public static InstanceState fromValue(String state) { + try { + return valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(state, "state"))); + } catch (IllegalArgumentException e) { + return UNRECOGNIZED; + } + } + + public static InstanceState fromValue(int v) { + switch (v) { + case 0: + return PENDING; + case 16: + return RUNNING; + case 32: + return SHUTTING_DOWN; + case 48: + return TERMINATED; + case 64: + return STOPPING; + case 80: + return STOPPED; + default: + 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/InstanceStateChange.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/InstanceStateChange.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/InstanceStateChange.java new file mode 100644 index 0000000..5f454ef --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/InstanceStateChange.java @@ -0,0 +1,118 @@ +/* + * 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-TerminateInstancesResponseInfoType.html" + * /> + */ +public class InstanceStateChange implements Comparable<InstanceStateChange> { + + private final String region; + private final String instanceId; + private final InstanceState currentState; + private final InstanceState previousState; + + public int compareTo(InstanceStateChange o) { + return (this == o) ? 0 : getInstanceId().compareTo(o.getInstanceId()); + } + + public InstanceStateChange(String region, String instanceId, InstanceState currentState, + InstanceState previousState) { + this.region = checkNotNull(region, "region"); + this.instanceId = instanceId; + this.currentState = currentState; + this.previousState = previousState; + } + + /** + * 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 getInstanceId() { + return instanceId; + } + + public InstanceState getCurrentState() { + return currentState; + } + + public InstanceState getPreviousState() { + return previousState; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((instanceId == null) ? 0 : instanceId.hashCode()); + result = prime * result + ((previousState == null) ? 0 : previousState.hashCode()); + result = prime * result + ((region == null) ? 0 : region.hashCode()); + result = prime * result + ((currentState == null) ? 0 : currentState.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; + InstanceStateChange other = (InstanceStateChange) obj; + if (instanceId == null) { + if (other.instanceId != null) + return false; + } else if (!instanceId.equals(other.instanceId)) + return false; + if (previousState == null) { + if (other.previousState != null) + return false; + } else if (!previousState.equals(other.previousState)) + return false; + if (region == null) { + if (other.region != null) + return false; + } else if (!region.equals(other.region)) + return false; + if (currentState == null) { + if (other.currentState != null) + return false; + } else if (!currentState.equals(other.currentState)) + return false; + return true; + } + + @Override + public String toString() { + return "InstanceStateChange [currentState=" + currentState + ", instanceId=" + instanceId + + ", previousState=" + previousState + ", region=" + region + "]"; + } + +} 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/InstanceType.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/InstanceType.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/InstanceType.java new file mode 100644 index 0000000..32fcec5 --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/InstanceType.java @@ -0,0 +1,386 @@ +/* + * 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; + +/** + * + * The type of the instance. Description accurate as of 8-15-2009 release. + * + * @see EC2AsyncClient#describeInstances + * @see EC2AsyncClient#runInstances + * @see EC2AsyncClient#terminateInstances + */ +public class InstanceType { + + /** + * Micro Instance + * <ul> + * <li>613 MB of memory</li> + * <li>up to 2 ECUs (for short periodic bursts)</li> + * <li>No instance storage (EBS storage only)</li> + * <li>32-bit or 64-bit platform</li> + * </ul> + */ + public static final String T1_MICRO = "t1.micro"; + + /** + * Small Instance + * <ul> + * <li>1.7 GB memory</li> + * <li>1 EC2 Compute Unit (1 virtual core with 1 EC2 Compute Unit)</li> + * <li>160 GB instance storage (150 GB plus 10 GB root partition)</li> + * <li>32-bit or 64-bit platform</li> + * <li>I/O Performance: Moderate</li> + * </ul> + */ + public static final String M1_SMALL = "m1.small"; + + /** + * Medium Instance + * <ul> + * <li>3.75 GB memory</li> + * <li>2 EC2 Compute Unit (1 virtual core with 2 EC2 Compute Unit)</li> + * <li>410 GB instance storage</li> + * <li>32-bit or 64-bit platform</li> + * <li>I/O Performance: Moderate</li> + * </ul> + */ + public static final String M1_MEDIUM = "m1.medium"; + + /** + * Large Instance + * <ul> + * <li>7.5 GB memory</li> + * <li>4 EC2 Compute Units (2 virtual cores with 2 EC2 Compute Units each)</li> + * <li>850 GB instance storage (2x420 GB plus 10 GB root partition)</li> + * <li>64-bit platform</li> + * <li>I/O Performance: High</li> + * </ul> + */ + public static final String M1_LARGE = "m1.large"; + + /** + * Extra Large Instance + * <ul> + * <li>15 GB memory</li> + * <li>8 EC2 Compute Units (4 virtual cores with 2 EC2 Compute Units each)</li> + * <li>1690 GB instance storage (4x420 GB plus 10 GB root partition)</li> + * <li>64-bit platform</li> + * <li>I/O Performance: High</li> + * </ul> + */ + public static final String M1_XLARGE = "m1.xlarge"; + + /** + * High-Memory Extra Large Instance + * <ul> + * <li>17.1 GB of memory</li> + * <li>6.5 EC2 Compute Units (2 virtual cores with 3.25 EC2 Compute Units + * each)</li> + * <li>420 GB of instance storage</li> + * <li>64-bit platform</li> + * <li>I/O Performance: Moderate</li> + * </ul> + */ + public static final String M2_XLARGE = "m2.xlarge"; + + /** + * High-Memory Double Extra Large Instance + * <ul> + * <li>34.2 GB of memory</li> + * <li>13 EC2 Compute Units (4 virtual cores with 3.25 EC2 Compute Units + * each)</li> + * <li>850 GB of instance storage</li> + * <li>64-bit platform</li> + * <li>I/O Performance: High</li> + * </ul> + */ + public static final String M2_2XLARGE = "m2.2xlarge"; + + /** + * High-Memory Quadruple Extra Large Instance + * <ul> + * <li>68.4 GB of memory</li> + * <li>26 EC2 Compute Units (8 virtual cores with 3.25 EC2 Compute Units + * each)</li> + * <li>1690 GB of instance storage</li> + * <li>64-bit platform</li> + * <li>I/O Performance: High</li> + * </ul> + */ + public static final String M2_4XLARGE = "m2.4xlarge"; + + /** + * M3 Medium Instance + * <ul> + * <li>3.75 GiB memory</li> + * <li>3 EC2 Compute Units (1 virtual core with 3 EC2 Compute Units)</li> + * <li>1 SSD-based volume with 4 GiB of instance storage</li> + * <li>32-bit or 64-bit platform</li> + * <li>I/O Performance: Moderate</li> + * </ul> + */ + public static final String M3_MEDIUM = "m3.medium"; + + /** + * M3 Large Instance + * <ul> + * <li>7 GiB memory</li> + * <li>6.5 EC2 Compute Units (2 virtual cores with 3.25 EC2 Compute Units each)</li> + * <li>1 SSD-based volume with 32 GiB of instance storage</li> + * <li>32-bit or 64-bit platform</li> + * <li>I/O Performance: Moderate</li> + * </ul> + */ + public static final String M3_LARGE = "m3.large"; + + /** + * M3 Extra Large Instance + * <ul> + * <li>15 GiB memory</li> + * <li>13 EC2 Compute Units (4 virtual cores with 3.25 EC2 Compute Units each)</li> + * <li>EBS storage only</li> + * <li>64-bit platform</li> + * <li>I/O Performance: Moderate</li> + * </ul> + */ + public static final String M3_XLARGE = "m3.xlarge"; + + /** + * M3 Double Extra Large Instance + * <ul> + * <li>30 GiB memory</li> + * <li>26 EC2 Compute Units (8 virtual cores with 3.25 EC2 Compute Units each)</li> + * <li>EBS storage only</li> + * <li>64-bit platform</li> + * <li>I/O Performance: High</li> + * </ul> + */ + public static final String M3_2XLARGE = "m3.2xlarge"; + + /** + * High-CPU Medium Instance + * <ul> + * <li>1.7 GB of memory</li> + * <li>5 EC2 Compute Units (2 virtual cores with 2.5 EC2 Compute Units each)</li> + * <li>350 GB of instance storage</li> + * <li>32-bit platform</li> + * <li>I/O Performance: Moderate</li> + * </ul> + */ + public static final String C1_MEDIUM = "c1.medium"; + + /** + * High-CPU Extra Large Instance + * <ul> + * <li>7 GB of memory</li> + * <li>20 EC2 Compute Units (8 virtual cores with 2.5 EC2 Compute Units each) + * </li> + * <li>1690 GB of instance storage</li> + * <li>64-bit platform</li> + * <li>I/O Performance: High</li> + * </ul> + */ + public static final String C1_XLARGE = "c1.xlarge"; + + /** + * Cluster Compute Instance + * <ul> + * <li>22 GB of memory</li> + * <li>33.5 EC2 Compute Units (2 x Intel Xeon X5570, quad-core "Nehalem" + * architecture)</li> + * <li>1690 GB of 64-bit storage (2 x 840 GB, plus 10 GB root partition)</li> + * <li>10 Gbps Ethernet</li> + * <li>64-bit platform</li> + * <li>I/O Performance: High</li> + * </ul> + */ + public static final String CG1_4XLARGE = "cg1.4xlarge"; + + /** + * Cluster Compute Instance + * <ul> + * <li>23 GB of memory</li> + * <li>33.5 EC2 Compute Units (2 x Intel Xeon X5570, quad-core "Nehalem" + * architecture)</li> + * <li>1690 GB of 64-bit storage (2 x 840 GB, plus 10 GB root partition)</li> + * <li>10 Gbps Ethernet</li> + * <li>64-bit platform</li> + * <li>I/O Performance: High</li> + * </ul> + */ + public static final String CC1_4XLARGE = "cc1.4xlarge"; + + /** + * Cluster Compute Eight Extra Large specifications + * <ul> + * <li>60.5 GB of memory</li> + * <li>88 EC2 Compute Units (Eight-core 2 x Intel Xeon)</li> + * <li>3370 GB of 64-bit storage (4 x 840 GB, plus 10 GB root partition)</li> + * <li>10 Gbps Ethernet</li> + * <li>64-bit platform</li> + * <li>I/O Performance: High</li> + * </ul> + */ + public static final String CC2_8XLARGE = "cc2.8xlarge"; + + /** + * High I/O Quadruple Extra Large specifications + * <ul> + * <li>60.5 GB of memory</li> + * <li>35 EC2 Compute Units (16 virtual cores)</li> + * <li>2 SSD-based volumes each with 1024 GB of instance storage</li> + * <li>64-bit platform</li> + * <li>I/O Performance: Very High (10 Gigabit Ethernet)</li> + * <li>Storage I/O Performance: Very High**</li> + * </ul> + */ + public static final String HI1_4XLARGE = "hi1.4xlarge"; + + /** + * High Storage Eight Extra Large + * <ul> + * <li>117 GiB of memory</li> + * <li>35 EC2 Compute Units (16 virtual cores*)</li> + * <li>24 hard disk drives each with 2 TB of instance storage</li> + * <li>64-bit platform</li> + * <li>I/O Performance: Very High (10 Gigabit Ethernet)</li> + * <li>Storage I/O Performance: Very High**</li> + * </ul> + */ + public static final String HS1_8XLARGE = "hs1.8xlarge"; + + /** + * GPU Instance Double Extra Large + * <ul> + * <li>15 GiB of memory</li> + * <li>26 EC2 Compute Units (8 virtual cores*), 1xNVIDIA GRID GPU (Kepler GK104)</li> + * <li>60 GB instance storage</li> + * <li>64-bit platform</li> + * <li>I/O Performance: High</li> + * </ul> + */ + public static final String G2_2XLARGE = "g2.2xlarge"; + + /** + * C3 High-CPU Large + * <ul> + * <li>3.75 GiB of memory</li> + * <li>7 EC2 Compute Units (2 virtual cores)</li> + * <li>2 SSD-based volumes each with 16 GiB of instance storage</li> + * <li>64-bit platform</li> + * <li>I/O Performance: Moderate</li> + * </ul> + */ + public static final String C3_LARGE = "c3.large"; + + /** + * C3 High-CPU Extra Large + * <ul> + * <li>7 GiB of memory</li> + * <li>14 EC2 Compute Units (4 virtual cores)</li> + * <li>2 SSD-based volumes each with 40 GiB of instance storage</li> + * <li>64-bit platform</li> + * <li>I/O Performance: High</li> + * </ul> + */ + public static final String C3_XLARGE = "c3.xlarge"; + + /** + * C3 High-CPU Double Extra Large + * <ul> + * <li>15 GiB of memory</li> + * <li>28 EC2 Compute Units (8 virtual cores)</li> + * <li>2 SSD-based volumes each with 80 GiB of instance storage</li> + * <li>64-bit platform</li> + * <li>I/O Performance: High</li> + * </ul> + */ + public static final String C3_2XLARGE = "c3.2xlarge"; + + /** + * C3 High-CPU Quadruple Extra Large + * <ul> + * <li>30 GiB of memory</li> + * <li>55 EC2 Compute Units (16 virtual cores)</li> + * <li>2 SSD-based volumes each with 160 GiB of instance storage</li> + * <li>64-bit platform</li> + * <li>I/O Performance: High</li> + * </ul> + */ + public static final String C3_4XLARGE = "c3.4xlarge"; + + /** + * C3 High-CPU Octuple Extra Large + * <ul> + * <li>60 GiB of memory</li> + * <li>108 EC2 Compute Units (32 virtual cores)</li> + * <li>2 SSD-based volumes each with 320 GiB of instance storage</li> + * <li>64-bit platform</li> + * <li>I/O Performance: High</li> + * </ul> + */ + public static final String C3_8XLARGE = "c3.8xlarge"; + + /** + * I2 Extra Large + * <ul> + * <li>30.5 GiB of memory</li> + * <li>14 EC2 Compute Units (4 virtual cores)</li> + * <li>1 SSD-based volume with 800 GiB of instance storage</li> + * <li>64-bit platform</li> + * <li>I/O Performance: High</li> + * </ul> + */ + public static final String I2_XLARGE = "i2.xlarge"; + + /** + * I2 Double Extra Large + * <ul> + * <li>61 GiB of memory</li> + * <li>27 EC2 Compute Units (8 virtual cores)</li> + * <li>2 SSD-based volumes each with 800 GiB of instance storage</li> + * <li>64-bit platform</li> + * <li>I/O Performance: High</li> + * </ul> + */ + public static final String I2_2XLARGE = "i2.2xlarge"; + + /** + * I2 Quadruple Extra Large + * <ul> + * <li>122 GiB of memory</li> + * <li>53 EC2 Compute Units (16 virtual cores)</li> + * <li>4 SSD-based volumes each with 800 GiB of instance storage</li> + * <li>64-bit platform</li> + * <li>I/O Performance: High</li> + * </ul> + */ + public static final String I2_4XLARGE = "i2.4xlarge"; + + /** + * I2 Octuple Extra Large + * <ul> + * <li>244 GiB of memory</li> + * <li>104 EC2 Compute Units (32 virtual cores)</li> + * <li>8 SSD-based volumes each with 800 GiB of instance storage</li> + * <li>64-bit platform</li> + * <li>I/O Performance: High</li> + * </ul> + */ + public static final String I2_8XLARGE = "i2.8xlarge"; +} 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/KeyPair.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/KeyPair.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/KeyPair.java new file mode 100644 index 0000000..74e6f17 --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/KeyPair.java @@ -0,0 +1,205 @@ +/* + * 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; +import org.jclouds.ssh.SshKeys; + +/** + * + * @see <a href= + * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-CreateKeyPair.html" + * /> + */ +public class KeyPair implements Comparable<KeyPair> { + @Override + public String toString() { + return "[region=" + region + ", keyName=" + keyName + ", fingerprint=" + fingerprint + ", sha1OfPrivateKey=" + + sha1OfPrivateKey + ", keyMaterial?=" + (keyMaterial != null) + "]"; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private String region; + private String keyName; + private String fingerprint; + private String sha1OfPrivateKey; + private String keyMaterial; + + public Builder region(String region) { + this.region = region; + return this; + } + + public Builder keyName(String keyName) { + this.keyName = keyName; + return this; + } + + public Builder sha1OfPrivateKey(String sha1OfPrivateKey) { + this.sha1OfPrivateKey = sha1OfPrivateKey; + return this; + } + + public Builder keyMaterial(String keyMaterial) { + this.keyMaterial = keyMaterial; + return this; + } + + public Builder fingerprint(String fingerprint) { + this.fingerprint = fingerprint; + return this; + } + + public KeyPair build() { + if (fingerprint == null && keyMaterial != null) + fingerprint(SshKeys.fingerprintPrivateKey(keyMaterial)); + return new KeyPair(region, keyName, sha1OfPrivateKey, keyMaterial, fingerprint); + } + + public static Builder fromKeyPair(KeyPair in) { + return new Builder().region(in.getRegion()).keyName(in.getKeyName()).sha1OfPrivateKey(in.getSha1OfPrivateKey()) + .keyMaterial(in.getKeyMaterial()); + } + } + + private final String region; + private final String keyName; + private final String sha1OfPrivateKey; + @Nullable + private final String keyMaterial; + @Nullable + private final String fingerprint; + + public KeyPair(String region, String keyName, String sha1OfPrivateKey, @Nullable String keyMaterial, + @Nullable String fingerprint) { + this.region = checkNotNull(region, "region"); + this.keyName = checkNotNull(keyName, "keyName"); + this.sha1OfPrivateKey = checkNotNull(sha1OfPrivateKey, "sha1OfPrivateKey"); + this.keyMaterial = keyMaterial;// nullable on list + this.fingerprint = fingerprint;// nullable on list + } + + /** + * 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(KeyPair o) { + return (this == o) ? 0 : getKeyName().compareTo(o.getKeyName()); + } + + /** + * A SHA-1 digest of the DER encoded private key. + * + * @see SshKeys#sha1 + */ + public String getSha1OfPrivateKey() { + return sha1OfPrivateKey; + } + + /** + * fingerprint per the following <a + * href="http://tools.ietf.org/html/draft-friedl-secsh-fingerprint-00" >spec</a> + * + * @see SshKeys#fingerprint + */ + public String getFingerprint() { + return fingerprint; + } + + /** + * An unencrypted PEM encoded RSA private key. + */ + public String getKeyMaterial() { + return keyMaterial; + } + + /** + * The key pair name provided in the original request. + */ + public String getKeyName() { + return keyName; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((fingerprint == null) ? 0 : fingerprint.hashCode()); + result = prime * result + ((keyMaterial == null) ? 0 : keyMaterial.hashCode()); + result = prime * result + ((keyName == null) ? 0 : keyName.hashCode()); + result = prime * result + ((region == null) ? 0 : region.hashCode()); + result = prime * result + ((sha1OfPrivateKey == null) ? 0 : sha1OfPrivateKey.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; + KeyPair other = (KeyPair) obj; + if (fingerprint == null) { + if (other.fingerprint != null) + return false; + } else if (!fingerprint.equals(other.fingerprint)) + return false; + if (keyMaterial == null) { + if (other.keyMaterial != null) + return false; + } else if (!keyMaterial.equals(other.keyMaterial)) + return false; + if (keyName == null) { + if (other.keyName != null) + return false; + } else if (!keyName.equals(other.keyName)) + return false; + if (region == null) { + if (other.region != null) + return false; + } else if (!region.equals(other.region)) + return false; + if (sha1OfPrivateKey == null) { + if (other.sha1OfPrivateKey != null) + return false; + } else if (!sha1OfPrivateKey.equals(other.sha1OfPrivateKey)) + return false; + return true; + } + + public Builder toBuilder() { + return Builder.fromKeyPair(this); + } +} 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/PasswordData.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/PasswordData.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/PasswordData.java new file mode 100644 index 0000000..4103286 --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/PasswordData.java @@ -0,0 +1,151 @@ +/* + * 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 com.google.common.base.Objects; + +/** + * The encrypted administrator password for an instance running Windows. + * + * <h4>Note</h4> + * + * The Windows password is only generated the first time an AMI is launched. It is not generated for + * rebundled AMIs or after the password is changed on an instance. + * + * The password is encrypted using the key pair that you provided. + * + * @see <a + * href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-GetPasswordData.html" + * >doc</a> + */ +public class PasswordData { + + public static Builder builder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder().fromPasswordData(this); + } + + public static class Builder { + + protected String instanceId; + protected Date timestamp; + protected String passwordData; + + /** + * @see PasswordData#getInstanceId() + */ + public Builder instanceId(String instanceId) { + this.instanceId = instanceId; + return this; + } + + /** + * @see PasswordData#getTimestamp() + */ + public Builder timestamp(Date timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * @see PasswordData#getPasswordData() + */ + public Builder passwordData(String passwordData) { + this.passwordData = passwordData; + return this; + } + + public PasswordData build() { + return new PasswordData(instanceId, timestamp, passwordData); + } + + public Builder fromPasswordData(PasswordData in) { + return this.instanceId(in.getInstanceId()).timestamp(in.getTimestamp()).passwordData(in.getPasswordData()); + } + } + + protected final String instanceId; + protected final Date timestamp; + protected final String passwordData; + + protected PasswordData(String instanceId, Date timestamp, String passwordData) { + this.instanceId = checkNotNull(instanceId, "instanceId"); + this.timestamp = checkNotNull(timestamp, "timestamp"); + this.passwordData = checkNotNull(passwordData, "passwordData"); + } + + /** + * The ID of the instance. + */ + public String getInstanceId() { + return instanceId; + } + + /** + * The time the data was last updated. + */ + public Date getTimestamp() { + return timestamp; + } + + /** + * The password of the instance. + */ + public String getPasswordData() { + return passwordData; + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return Objects.hashCode(instanceId); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PasswordData other = PasswordData.class.cast(obj); + return Objects.equal(this.instanceId, other.instanceId); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return Objects.toStringHelper(this).omitNullValues().add("instanceId", instanceId).add("timestamp", timestamp) + .add("passwordData", passwordData).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/Permission.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Permission.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Permission.java new file mode 100644 index 0000000..355fc06 --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Permission.java @@ -0,0 +1,92 @@ +/* + * 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 com.google.common.collect.Iterables; +import com.google.common.collect.Sets; + +/** + * + * @see <a href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-ItemType-LaunchPermissionItemType.html" + * /> + */ +public class Permission { + private final Set<String> groups = Sets.newHashSet(); + private final Set<String> userIds = Sets.newHashSet(); + + public Permission(Iterable<String> userIds, Iterable<String> groups) { + Iterables.addAll(this.userIds, checkNotNull(userIds, "userIds")); + Iterables.addAll(this.groups, checkNotNull(groups, "groups")); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((groups == null) ? 0 : groups.hashCode()); + result = prime * result + ((userIds == null) ? 0 : userIds.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; + Permission other = (Permission) obj; + if (groups == null) { + if (other.groups != null) + return false; + } else if (!groups.equals(other.groups)) + return false; + if (userIds == null) { + if (other.userIds != null) + return false; + } else if (!userIds.equals(other.userIds)) + return false; + return true; + } + + /** + * + * @return Name of the group. Currently supports \"all.\" + */ + public Set<String> getGroups() { + return groups; + } + + /** + * + * @return AWS Access Key ID. + */ + public Set<String> getUserIds() { + return userIds; + } + + @Override + public String toString() { + return "LaunchPermission [groups=" + groups + ", userIds=" + userIds + "]"; + } + +}
