http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Deprecated.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Deprecated.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Deprecated.java deleted file mode 100644 index 5a48acf..0000000 --- a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Deprecated.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecomputeengine.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Optional.fromNullable; - -import java.beans.ConstructorProperties; -import java.net.URI; - -import com.google.common.base.Objects; -import com.google.common.base.Optional; - -/** - * Deprecation information for an image or kernel - */ -public class Deprecated { - private final Optional<String> state; - private final Optional<URI> replacement; - private final Optional<String> deprecated; - private final Optional<String> obsolete; - private final Optional<String> deleted; - - @ConstructorProperties({"state", "replacement", "deprecated", "obsolete", "deleted"}) - public Deprecated(String state, URI replacement, String deprecated, String obsolete, - String deleted) { - this.state = fromNullable(state); - this.replacement = fromNullable(replacement); - this.deprecated = fromNullable(deprecated); - this.obsolete = fromNullable(obsolete); - this.deleted = fromNullable(deleted); - } - - /** - * @return The deprecation state of this image. - */ - public Optional<String> getState() { - return state; - } - - /** - * @return A fully-qualified URL of the suggested replacement for the deprecated image. - */ - public Optional<URI> getReplacement() { - return replacement; - } - - /** - * @return An optional RFC3339 timestamp for when the deprecation state of this resource will be changed to DEPRECATED. - */ - public Optional<String> getDeprecated() { - return deprecated; - } - - /** - * @return An optional RFC3339 timestamp on or after which the deprecation state of this resource will be changed toOBSOLETE. - */ - public Optional<String> getObsolete() { - return obsolete; - } - - /** - * @return An optional RFC3339 timestamp on or after which the deprecation state of this resource will be changed to DELETED. - */ - public Optional<String> getDeleted() { - return deleted; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(state, replacement, deprecated, obsolete, deleted); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - Deprecated that = Deprecated.class.cast(obj); - return equal(this.state, that.state) - && equal(this.replacement, that.replacement) - && equal(this.deprecated, that.deprecated) - && equal(this.obsolete, that.obsolete) - && equal(this.deleted, that.deleted); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return toStringHelper(this) - .omitNullValues() - .add("state", state.orNull()) - .add("replacement", replacement.orNull()) - .add("deprecated", deprecated.orNull()) - .add("obsolete", obsolete.orNull()) - .add("deleted", deleted.orNull()); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromDeprecated(this); - } - - public static class Builder { - private String state; - private URI replacement; - private String deprecated; - private String obsolete; - private String deleted; - - /** - * @see org.jclouds.googlecomputeengine.domain.Deprecated#getState() - */ - public Builder state(String state) { - this.state = state; - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Deprecated#getReplacement() - */ - public Builder replacement(URI replacement) { - this.replacement = replacement; - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Deprecated#getDeprecated() - */ - public Builder deprecated(String deprecated) { - this.deprecated = deprecated; - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Deprecated#getObsolete() - */ - public Builder obsolete(String obsolete) { - this.obsolete = obsolete; - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Deprecated#getDeprecated() - */ - public Builder deleted(String deleted) { - this.deleted = deleted; - return this; - } - - public Deprecated build() { - return new Deprecated(state, replacement, deprecated, obsolete, deleted); - } - - public Builder fromDeprecated(Deprecated in) { - return new Builder().state(in.getState().orNull()) - .replacement(in.getReplacement().orNull()) - .deprecated(in.getDeprecated().orNull()) - .obsolete(in.getObsolete().orNull()) - .deleted(in.getDeleted().orNull()); - } - } -}
http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Disk.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Disk.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Disk.java deleted file mode 100644 index 91d1502..0000000 --- a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Disk.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecomputeengine.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.beans.ConstructorProperties; -import java.net.URI; -import java.util.Date; - -import com.google.common.annotations.Beta; -import com.google.common.base.Objects; - -/** - * A persistent disk resource - * - * @see <a href="https://developers.google.com/compute/docs/reference/v1/disks"/> - */ -@Beta -public final class Disk extends AbstractDisk { - - private final URI zone; - - @ConstructorProperties({ - "id", "creationTimestamp", "selfLink", "name", "description", "sizeGb", "zone", - "status" - }) - private Disk(String id, Date creationTimestamp, URI selfLink, String name, String description, - Integer sizeGb, URI zone, String status) { - super(Kind.DISK, id, creationTimestamp, selfLink, name, description, sizeGb, status); - this.zone = checkNotNull(zone, "zone of %s", name); - } - - /** - * @return URL for the zone where the persistent disk resides. - */ - public URI getZone() { - return zone; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - Disk that = Disk.class.cast(obj); - return equal(this.kind, that.kind) - && equal(this.name, that.name) - && equal(this.zone, that.zone); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return super.string() - .omitNullValues() - .add("zone", zone); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromDisk(this); - } - - public static final class Builder extends AbstractDisk.Builder<Builder> { - - private URI zone; - - /** - * @see Disk#getZone() - */ - public Builder zone(URI zone) { - this.zone = zone; - return this; - } - - @Override - protected Builder self() { - return this; - } - - public Disk build() { - return new Disk(super.id, super.creationTimestamp, super.selfLink, super.name, - super.description, super.sizeGb, zone, super.status); - } - - public Builder fromDisk(Disk in) { - return super.fromAbstractDisk(in) - .zone(in.getZone()); - } - - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Firewall.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Firewall.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Firewall.java deleted file mode 100644 index aee2cd4..0000000 --- a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Firewall.java +++ /dev/null @@ -1,379 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecomputeengine.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; -import static com.google.common.collect.Range.closed; -import static com.google.common.collect.Range.singleton; - -import java.beans.ConstructorProperties; -import java.net.URI; -import java.util.Date; -import java.util.Set; - -import org.jclouds.net.domain.IpProtocol; - -import com.google.common.annotations.Beta; -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.RangeSet; -import com.google.common.collect.TreeRangeSet; - -/** - * Represents a network firewall - * - * @see <a href="https://developers.google.com/compute/docs/reference/v1/firewalls"/> - * @see <a href="https://developers.google.com/compute/docs/networking#firewalls"/> - */ -@Beta -public final class Firewall extends Resource { - - private final URI network; - private final Set<String> sourceRanges; - private final Set<String> sourceTags; - private final Set<String> targetTags; - private final Set<Rule> allowed; - - @ConstructorProperties({ - "id", "creationTimestamp", "selfLink", "name", "description", "network", "sourceRanges", - "sourceTags", "targetTags", "allowed" - }) - protected Firewall(String id, Date creationTimestamp, URI selfLink, String name, String description, - URI network, Set<String> sourceRanges, Set<String> sourceTags, Set<String> targetTags, - Set<Rule> allowed) { - super(Kind.FIREWALL, id, creationTimestamp, selfLink, name, description); - this.network = checkNotNull(network, "network of %s", name); - this.sourceRanges = sourceRanges == null ? ImmutableSet.<String>of() : sourceRanges; - this.sourceTags = sourceTags == null ? ImmutableSet.<String>of() : sourceTags; - this.targetTags = targetTags == null ? ImmutableSet.<String>of() : targetTags; - this.allowed = allowed == null ? ImmutableSet.<Rule>of() : allowed; - } - - /** - * @return URI of the network to which this firewall is applied; provided by the client when the firewall is created. - */ - public URI getNetwork() { - return network; - } - - /** - * One or both of sourceRanges and sourceTags may be set; an inbound connection is allowed if either the range or - * the tag of the source matches. - * - * @return a list of IP address blocks expressed in CIDR format which this rule applies to. - */ - public Set<String> getSourceRanges() { - return sourceRanges; - } - - /** - * @return a list of instance items which this rule applies to. One or both of sourceRanges and sourceTags may be - * set; an inbound connection is allowed if either the range or the tag of the source matches. - */ - public Set<String> getSourceTags() { - return sourceTags; - } - - /** - * If no targetTags are specified, the firewall rule applies to all instances on the specified network. - * - * @return a list of instance items indicating sets of instances located on network which may make network - * connections as specified in allowed. - */ - public Set<String> getTargetTags() { - return targetTags; - } - - /** - * Each rule specifies a protocol and port-range tuple that describes a permitted connection. - * - * @return the list of rules specified by this firewall. - */ - public Set<Rule> getAllowed() { - return allowed; - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return super.string() - .add("network", network) - .add("sourceRanges", sourceRanges) - .add("sourceTags", sourceTags) - .add("targetTags", targetTags) - .add("allowed", allowed); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromFirewall(this); - } - - public static final class Builder extends Resource.Builder<Builder> { - - private URI network; - private ImmutableSet.Builder<String> sourceRanges = ImmutableSet.builder(); - private ImmutableSet.Builder<String> sourceTags = ImmutableSet.builder(); - private ImmutableSet.Builder<String> targetTags = ImmutableSet.builder(); - private ImmutableSet.Builder<Rule> allowed = ImmutableSet.builder(); - - /** - * @see Firewall#getNetwork() - */ - public Builder network(URI network) { - this.network = network; - return this; - } - - /** - * @see Firewall#getSourceRanges() - */ - public Builder addSourceRange(String sourceRange) { - this.sourceRanges.add(checkNotNull(sourceRange)); - return this; - } - - /** - * @see Firewall#getSourceRanges() - */ - public Builder sourceRanges(Set<String> sourceRanges) { - this.sourceRanges.addAll(checkNotNull(sourceRanges)); - return this; - } - - /** - * @see Firewall#getSourceTags() - */ - public Builder addSourceTag(String sourceTag) { - this.sourceTags.add(checkNotNull(sourceTag)); - return this; - } - - /** - * @see Firewall#getSourceTags() - */ - public Builder sourceTags(Set<String> sourceTags) { - this.sourceTags.addAll(checkNotNull(sourceTags)); - return this; - } - - /** - * @see Firewall#getTargetTags() - */ - public Builder addTargetTag(String targetTag) { - this.targetTags.add(checkNotNull(targetTag)); - return this; - } - - /** - * @see Firewall#getTargetTags() - */ - public Builder targetTags(Set<String> targetTags) { - this.targetTags.addAll(checkNotNull(targetTags)); - return this; - } - - /** - * @see Firewall#getAllowed() - */ - public Builder addAllowed(Rule firewallRule) { - this.allowed.add(checkNotNull(firewallRule)); - return this; - } - - /** - * @see Firewall#getAllowed() - */ - public Builder allowed(Set<Rule> firewallRules) { - this.allowed = ImmutableSet.builder(); - this.allowed.addAll(firewallRules); - return this; - } - - @Override - protected Builder self() { - return this; - } - - public Firewall build() { - return new Firewall(super.id, super.creationTimestamp, super.selfLink, super.name, - super.description, network, sourceRanges.build(), sourceTags.build(), targetTags.build(), - allowed.build()); - } - - public Builder fromFirewall(Firewall in) { - return super.fromResource(in).network(in.getNetwork()).sourceRanges(in.getSourceRanges()).sourceTags(in - .getSourceTags()).targetTags(in.getTargetTags()).allowed(in.getAllowed()); - } - - } - - /** - * A Firewall rule. Rule specifies a protocol and port-range tuple that describes a - * permitted connection. - * - * @see <a href="https://developers.google.com/compute/docs/reference/v1/firewalls"/> - */ - public static final class Rule { - - private final IpProtocol ipProtocol; - private final RangeSet<Integer> ports; - - /* Some handy shortcuts */ - public static Rule permitTcpRule(Integer start, Integer end) { return Rule.builder().IpProtocol(IpProtocol.TCP).addPortRange(start, end).build(); } - public static Rule permitTcpRule(Integer port) { return Rule.builder().IpProtocol(IpProtocol.TCP).addPort(port).build(); } - public static Rule permitUdpRule(Integer start, Integer end) { return Rule.builder().IpProtocol(IpProtocol.UDP).addPortRange(start, end).build(); } - public static Rule permitUdpRule(Integer port) { return Rule.builder().IpProtocol(IpProtocol.UDP).addPort(port).build(); } - @ConstructorProperties({ - "IpProtocol", "ports" - }) - private Rule(IpProtocol IpProtocol, RangeSet<Integer> ports) { - this.ipProtocol = checkNotNull(IpProtocol); - this.ports = ports == null ? TreeRangeSet.<Integer>create() : ports; - } - - /** - * This can either be a well known protocol string (tcp, udp or icmp) or the IP protocol number. - * - * @return this is the IP protocol that is allowed for this rule. - */ - public IpProtocol getIpProtocol() { - return ipProtocol; - } - - /** - * Each entry must be either an integer or a range. If not specified, connections through any port are allowed. - * Example inputs include: ["22"], ["80,"443"], and ["12345-12349"]. - * <p/> - * It is an error to specify this for any protocol that isn't UDP or TCP. - * - * @return An optional list of ports which are allowed. - */ - public RangeSet<Integer> getPorts() { - return ports; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(ipProtocol, ports); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - Rule that = Rule.class.cast(obj); - return equal(this.ipProtocol, that.ipProtocol) - && equal(this.ports, that.ports); - } - - /** - * {@inheritDoc} - */ - public Objects.ToStringHelper string() { - return toStringHelper(this) - .add("IpProtocol", ipProtocol).add("ports", ports); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromFirewallRule(this); - } - - public static final class Builder { - - private IpProtocol ipProtocol; - private RangeSet<Integer> ports = TreeRangeSet.create(); - - /** - * @see org.jclouds.googlecomputeengine.domain.Firewall.Rule#getIpProtocol() - */ - public Builder IpProtocol(IpProtocol IpProtocol) { - this.ipProtocol = IpProtocol; - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Firewall.Rule#getPorts() - */ - public Builder addPort(Integer port) { - this.ports.add(singleton(checkNotNull(port, "port"))); - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Firewall.Rule#getPorts() - */ - public Builder addPortRange(Integer start, Integer end) { - checkState(checkNotNull(start, "start") < checkNotNull(end, "end"), - "start of range must be lower than end of range"); - this.ports.add(closed(start, end)); - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Firewall.Rule#getPorts() - */ - public Builder ports(RangeSet<Integer> ports) { - this.ports = TreeRangeSet.create(); - this.ports.addAll(ports); - return this; - } - - public Rule build() { - return new Rule(ipProtocol, ports); - } - - public Builder fromFirewallRule(Rule firewallRule) { - return new Builder().IpProtocol(firewallRule.getIpProtocol()).ports(firewallRule.getPorts()); - } - } - - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Image.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Image.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Image.java deleted file mode 100644 index 424aaa1..0000000 --- a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Image.java +++ /dev/null @@ -1,286 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecomputeengine.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Optional.fromNullable; -import static com.google.common.base.Preconditions.checkNotNull; - -import java.beans.ConstructorProperties; -import java.net.URI; -import java.util.Date; - -import com.google.common.annotations.Beta; -import com.google.common.base.Objects; -import com.google.common.base.Optional; - -/** - * Represents a disk image to use on an instance. - * - * @see <a href="https://developers.google.com/compute/docs/reference/v1/images"/> - */ -@Beta -public final class Image extends Resource { - - private final String sourceType; - private final RawDisk rawDisk; - private final Optional<Deprecated> deprecated; - - @ConstructorProperties({ - "id", "creationTimestamp", "selfLink", "name", "description", "sourceType", - "rawDisk", "deprecated" - }) - protected Image(String id, Date creationTimestamp, URI selfLink, String name, String description, - String sourceType, RawDisk rawDisk, Deprecated deprecated) { - super(Kind.IMAGE, id, creationTimestamp, selfLink, name, description); - this.sourceType = checkNotNull(sourceType, "sourceType of %s", name); - // rawDisk may be null for user created private images - this.rawDisk = rawDisk; // checkNotNull(rawDisk, "rawDisk of %s", name); - this.deprecated = fromNullable(deprecated); - } - - /** - * @return must be RAW; provided by the client when the disk image is created. - */ - public String getSourceType() { - return sourceType; - } - - /** - * @return the raw disk image parameters. - */ - public RawDisk getRawDisk() { - return rawDisk; - } - - /** - * @return the deprecation information for this image - */ - public Optional<Deprecated> getDeprecated() { - return deprecated; - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return super.string() - .omitNullValues() - .add("sourceType", sourceType) - .add("rawDisk", rawDisk) - .add("deprecated", deprecated.orNull()); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromImage(this); - } - - public static final class Builder extends Resource.Builder<Builder> { - - private String sourceType; - private RawDisk rawDisk; - private Deprecated deprecated; - - /** - * @see Image#getSourceType() - */ - public Builder sourceType(String sourceType) { - this.sourceType = checkNotNull(sourceType, "sourceType"); - return this; - } - - /** - * @see Image#getDeprecated() - */ - public Builder deprecated(Deprecated deprecated) { - this.deprecated = checkNotNull(deprecated, "deprecated"); - return this; - } - - /** - * @see Image#getRawDisk() - */ - public Builder rawDisk(RawDisk rawDisk) { - this.rawDisk = checkNotNull(rawDisk); - return this; - } - - @Override - protected Builder self() { - return this; - } - - public Image build() { - return new Image(super.id, super.creationTimestamp, super.selfLink, super.name, - super.description, sourceType, rawDisk, deprecated); - } - - public Builder fromImage(Image in) { - return super.fromResource(in) - .sourceType(in.getSourceType()) - .rawDisk(in.getRawDisk()) - .deprecated(in.getDeprecated().orNull()); - } - - } - - /** - * A raw disk image, usually the base for an image. - * - * @see <a href="https://developers.google.com/compute/docs/reference/v1/images"/> - */ - public static class RawDisk { - - private final String source; - private final String containerType; - private final Optional<String> sha1Checksum; - - @ConstructorProperties({ - "source", "containerType", "sha1Checksum" - }) - private RawDisk(String source, String containerType, String sha1Checksum) { - this.source = checkNotNull(source, "source"); - this.containerType = checkNotNull(containerType, "containerType"); - this.sha1Checksum = fromNullable(sha1Checksum); - } - - /** - * @return the full Google Cloud Storage URL where the disk image is stored; provided by the client when the disk - * image is created. - */ - public String getSource() { - return source; - } - - /** - * @return the format used to encode and transmit the block device. - */ - public String getContainerType() { - return containerType; - } - - /** - * @return an optional SHA1 checksum of the disk image before unpackaging; provided by the client when the disk - * image is created. - */ - public Optional<String> getSha1Checksum() { - return sha1Checksum; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(source, containerType, sha1Checksum); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - RawDisk that = RawDisk.class.cast(obj); - return equal(this.source, that.source) - && equal(this.containerType, that.containerType) - && equal(this.sha1Checksum, that.sha1Checksum); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return toStringHelper(this) - .omitNullValues() - .add("source", source) - .add("containerType", containerType) - .add("sha1Checksum", sha1Checksum.orNull()); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromImageRawDisk(this); - } - - public static class Builder { - - private String source; - private String containerType; - private String sha1Checksum; - - /** - * @see org.jclouds.googlecomputeengine.domain.Image.RawDisk#getSource() - */ - public Builder source(String source) { - this.source = checkNotNull(source); - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Image.RawDisk#getContainerType() - */ - public Builder containerType(String containerType) { - this.containerType = checkNotNull(containerType); - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Image.RawDisk#getSha1Checksum() - */ - public Builder sha1Checksum(String sha1Checksum) { - this.sha1Checksum = sha1Checksum; - return this; - } - - public RawDisk build() { - return new RawDisk(source, containerType, sha1Checksum); - } - - public Builder fromImageRawDisk(RawDisk rawDisk) { - return new Builder().source(rawDisk.getSource()) - .containerType(rawDisk.getContainerType()) - .sha1Checksum(rawDisk.getSha1Checksum().orNull()); - } - } - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Instance.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Instance.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Instance.java deleted file mode 100644 index e67366e..0000000 --- a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Instance.java +++ /dev/null @@ -1,1187 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecomputeengine.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Objects.toStringHelper; -import static com.google.common.base.Optional.fromNullable; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.getLast; - -import java.beans.ConstructorProperties; -import java.net.URI; -import java.util.Date; -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; - -import com.google.common.annotations.Beta; -import com.google.common.base.Objects; -import com.google.common.base.Optional; -import com.google.common.base.Splitter; -import com.google.common.collect.ImmutableSet; - -/** - * Represents a virtual machine. - * - * @see <a href="https://developers.google.com/compute/docs/reference/v1/instances"/> - */ -@Beta -public class Instance extends Resource { - - public enum Status { - PROVISIONING, - STAGING, - RUNNING, - STOPPING, - STOPPED, - TERMINATED - } - - protected final Tags tags; - protected final URI machineType; - protected final Status status; - protected final Optional<String> statusMessage; - protected final URI zone; - protected final Set<NetworkInterface> networkInterfaces; - protected final Set<AttachedDisk> disks; - protected final Metadata metadata; - protected final Set<ServiceAccount> serviceAccounts; - - protected Instance(String id, Date creationTimestamp, URI selfLink, String name, String description, - Tags tags, URI machineType, Status status, String statusMessage, - URI zone, Set<NetworkInterface> networkInterfaces, Set<AttachedDisk> disks, - Metadata metadata, Set<ServiceAccount> serviceAccounts) { - super(Kind.INSTANCE, id, creationTimestamp, selfLink, name, description); - this.tags = checkNotNull(tags, "tags"); - this.machineType = checkNotNull(machineType, "machineType of %s", name); - this.status = checkNotNull(status, "status"); - this.statusMessage = fromNullable(statusMessage); - this.zone = checkNotNull(zone, "zone of %s", name); - this.networkInterfaces = networkInterfaces == null ? ImmutableSet.<NetworkInterface>of() : networkInterfaces; - this.disks = disks == null ? ImmutableSet.<AttachedDisk>of() : disks; - this.metadata = checkNotNull(metadata, "metadata"); - this.serviceAccounts = serviceAccounts == null ? ImmutableSet.<ServiceAccount>of() : serviceAccounts; - } - - /** - * Used to identify valid sources or targets for network firewalls. Provided by the client when the instance is - * created. Each tag must be unique, must be 1-63 characters long, and comply with RFC1035. - * - * @return an optional set of items applied to this instance. - */ - public Tags getTags() { - return tags; - } - - /** - * @return URL of the machine type resource describing which machine type to use to host the instance. - */ - public URI getMachineType() { - return machineType; - } - - /** - * @return Instance status - */ - public Status getStatus() { - return status; - } - - /** - * @return an optional, human-readable explanation of the status. - */ - @Nullable - public Optional<String> getStatusMessage() { - return statusMessage; - } - - /** - * @return URL of the zone resource describing where this instance should be hosted; provided by the client when - * the instance is created. - */ - public URI getZone() { - return zone; - } - - /** - * @return set of NetworkInterfaces - * @see NetworkInterface - */ - public Set<NetworkInterface> getNetworkInterfaces() { - return networkInterfaces; - } - - /** - * @return array of disks associated with this instance. Persistent disks must be created before - * you can assign them. - * @see org.jclouds.googlecomputeengine.domain.Instance.AttachedDisk - */ - public Set<AttachedDisk> getDisks() { - return disks; - } - - /** - * @return metadata for this instance - */ - public Metadata getMetadata() { - return metadata; - } - - /** - * @return list of service accounts each with specified scopes. - * @see ServiceAccount - */ - public Set<ServiceAccount> getServiceAccounts() { - return serviceAccounts; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - Instance that = Instance.class.cast(obj); - return equal(this.kind, that.kind) - && equal(this.name, that.name) - && equal(this.zone, that.zone); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return super.string() - .omitNullValues() - .add("items", tags) - .add("machineType", machineType) - .add("status", status) - .add("statusMessage", statusMessage.orNull()) - .add("zone", zone) - .add("networkInterfaces", networkInterfaces) - .add("disks", disks) - .add("metadata", metadata) - .add("serviceAccounts", serviceAccounts); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return new Builder().fromInstance(this); - } - - public static final class Builder extends Resource.Builder<Builder> { - - private Tags tags; - private URI machineType; - private Status status; - private String statusMessage; - private URI zone; - private Metadata metadata; - private ImmutableSet.Builder<NetworkInterface> networkInterfaces = ImmutableSet.builder(); - private ImmutableSet.Builder<AttachedDisk> disks = ImmutableSet.builder(); - private ImmutableSet.Builder<ServiceAccount> serviceAccounts = ImmutableSet.builder(); - - - /** - * @see Instance#getTags() - */ - public Builder tags(Tags tags) { - this.tags = tags; - return this; - } - - /** - * @see Instance#getMachineType() - */ - public Builder machineType(URI machineType) { - this.machineType = machineType; - return this; - } - - /** - * @see Instance#getStatus() - */ - public Builder status(Status status) { - this.status = status; - return this; - } - - /** - * @see Instance#getStatusMessage() - */ - public Builder statusMessage(String statusMessage) { - this.statusMessage = statusMessage; - return this; - } - - /** - * @see Instance#getZone() - */ - public Builder zone(URI zone) { - this.zone = zone; - return this; - } - - /** - * @see Instance#getNetworkInterfaces() - */ - public Builder addNetworkInterface(NetworkInterface networkInterface) { - this.networkInterfaces.add(networkInterface); - return this; - } - - /** - * @see Instance#getNetworkInterfaces() - */ - public Builder networkInterfaces(Set<NetworkInterface> networkInterfaces) { - this.networkInterfaces.addAll(networkInterfaces); - return this; - } - - /** - * @see Instance#getDisks() - */ - public Builder addDisk(AttachedDisk disk) { - this.disks.add(disk); - return this; - } - - /** - * @see Instance#getDisks() - */ - public Builder disks(Set<AttachedDisk> disks) { - this.disks.addAll(disks); - return this; - } - - /** - * @see Instance#getMetadata() - */ - public Builder metadata(Metadata metadata) { - this.metadata = metadata; - return this; - } - - /** - * @see Instance#getServiceAccounts() - */ - public Builder addServiceAccount(ServiceAccount serviceAccount) { - this.serviceAccounts.add(serviceAccount); - return this; - } - - /** - * @see Instance#getServiceAccounts() - */ - public Builder serviceAccounts(Set<ServiceAccount> serviceAccounts) { - this.serviceAccounts.addAll(serviceAccounts); - return this; - } - - - @Override - protected Builder self() { - return this; - } - - public Instance build() { - return new Instance(super.id, super.creationTimestamp, super.selfLink, super.name, - super.description, tags, machineType, status, statusMessage, zone, - networkInterfaces.build(), disks.build(), metadata, serviceAccounts.build()); - } - - public Builder fromInstance(Instance in) { - return super.fromResource(in) - .tags(in.getTags()) - .machineType(in.getMachineType()) - .status(in.getStatus()) - .statusMessage(in.getStatusMessage().orNull()) - .zone(in.getZone()) - .networkInterfaces(in.getNetworkInterfaces()) - .disks(in.getDisks()) - .metadata(in.getMetadata()) - .serviceAccounts(in.getServiceAccounts()); - } - } - - - - - /** - * Tags for an instance, with their fingerprint. - */ - public static class Tags { - private final String fingerprint; - private final Set<String> items; - - @ConstructorProperties({"fingerprint", "items"}) - public Tags(String fingerprint, @Nullable Set<String> items) { - this.fingerprint = checkNotNull(fingerprint); - this.items = items == null ? ImmutableSet.<String>of() : items; - } - - /** - * Used to identify valid sources or targets for network firewalls. Provided by the client when the instance is - * created. Each tag must be unique, must be 1-63 characters long, and comply with RFC1035. - * - * @return an optional set of items applied to this instance. - */ - public Set<String> getItems() { - return items; - } - - /** - * Gets the fingerprint for the items - needed for updating them. - * - * @return the fingerprint string for the items. - */ - public String getFingerprint() { - return fingerprint; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(fingerprint, items); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - Tags that = Tags.class.cast(obj); - return equal(this.items, that.items) - && equal(this.fingerprint, that.fingerprint); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return toStringHelper(this) - .add("items", items) - .add("fingerprint", fingerprint); - } - - public static Builder builder() { - return new Builder(); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static final class Builder { - - private ImmutableSet.Builder<String> items = ImmutableSet.builder(); - private String fingerprint; - - /** - * @see Tags#getItems() - */ - public Builder addItem(String item) { - this.items.add(item); - return this; - } - - /** - * @see Tags#getItems() - */ - public Builder items(Set<String> items) { - this.items.addAll(items); - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance.Tags#getFingerprint() - */ - public Builder fingerprint(String fingerprint) { - this.fingerprint = fingerprint; - return this; - } - - public Tags build() { - return new Tags(this.fingerprint, this.items.build()); - } - - public Builder fromTags(Tags in) { - return this.fingerprint(in.getFingerprint()) - .items(in.getItems()); - } - } - } - - /** - * A disk attached to an Instance. - * - * @see <a href="https://developers.google.com/compute/docs/reference/v1/instances"/> - */ - public static class AttachedDisk { - - private final int index; - - public AttachedDisk(Integer index) { - this.index = checkNotNull(index, "index"); - } - - public boolean isPersistent() { - return false; - } - - /** - * @return a zero-based index to assign to this disk, where 0 is reserved for the boot disk. - */ - public int getIndex() { - return index; - } - - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(index); - } - - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - AttachedDisk that = AttachedDisk.class.cast(obj); - return equal(this.index, that.index); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return toStringHelper(this).add("index", index); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static AttachedDisk ephemeralDiskAtIndex(Integer index) { - return new AttachedDisk(index); - } - } - - public static class PersistentAttachedDisk extends AttachedDisk { - public enum Mode { - READ_WRITE, - READ_ONLY; - } - - @ConstructorProperties({"mode", "source", "deviceName", "index", "deleteOnTerminate", - "boot"}) - public PersistentAttachedDisk(Mode mode, URI source, String deviceName, Integer index, - boolean deleteOnTerminate, boolean boot) { - super(index); - this.mode = checkNotNull(mode, "mode"); - this.source = checkNotNull(source, "source"); - this.deviceName = fromNullable(deviceName); - this.deleteOnTerminate = deleteOnTerminate; - this.boot = boot; - } - - private final Mode mode; - private final URI source; - private final boolean deleteOnTerminate; - private final Optional<String> deviceName; - private final boolean boot; - - @Override - public boolean isPersistent() { - return true; - } - - /** - * @return the mode in which to attach this disk, either READ_WRITE or READ_ONLY. - */ - public Mode getMode() { - return mode; - } - - /** - * @return the URL of the persistent disk resource. - */ - public URI getSource() { - return source; - } - - /** - * @return the Name of the persistent disk resource - */ - public String getSourceDiskName() { - return getLast(Splitter.on("/").split(source.toString()), null); - } - - /** - * @return Must be unique within the instance when specified. This represents a unique - * device name that is reflected into the /dev/ tree of a Linux operating system running within the - * instance. If not specified, a default will be chosen by the system. - */ - public Optional<String> getDeviceName() { - return deviceName; - } - - - /** - * @return If true, delete the disk and all its data when the associated instance is deleted. - */ - public boolean isDeleteOnTerminate() { - return deleteOnTerminate; - } - - /** - * @return If true, this is the boot disk for this instance. - */ - public boolean isBoot() { - return boot; - } - - public static Builder builder() { - return new Builder(); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return toStringHelper(this).add("boot", boot); - } - - - public static final class Builder { - - private Mode mode; - private URI source; - private String deviceName; - private Integer index; - private boolean deleteOnTerminate; - private boolean boot; - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance.PersistentAttachedDisk#getMode() - */ - public Builder mode(Mode mode) { - this.mode = mode; - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance.PersistentAttachedDisk#getSource() - */ - public Builder source(URI source) { - this.source = source; - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance.PersistentAttachedDisk#getDeviceName() - */ - public Builder deviceName(String deviceName) { - this.deviceName = deviceName; - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance.AttachedDisk#getIndex() - */ - public Builder index(Integer index) { - this.index = index; - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance.PersistentAttachedDisk#isDeleteOnTerminate() - */ - public Builder deleteOnTerminate(Boolean deleteOnTerminate) { - this.deleteOnTerminate = deleteOnTerminate; - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance.PersistentAttachedDisk#isBoot() - */ - public Builder boot(Boolean boot) { - this.boot = boot; - return this; - } - - public PersistentAttachedDisk build() { - return new PersistentAttachedDisk(this.mode, this.source, this.deviceName, this.index, - this.deleteOnTerminate, this.boot); - } - - public Builder fromPersistentAttachedDisk(PersistentAttachedDisk in) { - return this.mode(in.getMode()) - .source(in.getSource()) - .deviceName(in.getDeviceName().orNull()) - .index(in.getIndex()) - .deleteOnTerminate(in.isDeleteOnTerminate()) - .boot(in.isBoot()); - } - } - } - - /** - * A network interface for an Instance. - * - * @see <a href="https://developers.google.com/compute/docs/reference/v1/instances"/> - */ - public static final class NetworkInterface { - - private final String name; - private final URI network; - private final Optional<String> networkIP; - private final Set<AccessConfig> accessConfigs; - - @ConstructorProperties({ - "name", "network", "networkIP", "accessConfigs" - }) - private NetworkInterface(String name, URI network, String networkIP, - Set<AccessConfig> accessConfigs) { - this.name = checkNotNull(name, "name"); - this.network = checkNotNull(network, "network"); - this.networkIP = fromNullable(networkIP); - this.accessConfigs = accessConfigs == null ? ImmutableSet.<AccessConfig>of() : accessConfigs; - } - - /** - * @return the name of the network interface - */ - public String getName() { - return name; - } - - /** - * @return URL of the network resource attached to this interface. - */ - public URI getNetwork() { - return network; - } - - /** - * @return An IPV4 internal network address to assign to this instance. - */ - public Optional<String> getNetworkIP() { - return networkIP; - } - - /** - * @return array of access configurations for this interface. - */ - public Set<AccessConfig> getAccessConfigs() { - return accessConfigs; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(name, network, networkIP, accessConfigs); - } - - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - NetworkInterface that = NetworkInterface.class.cast(obj); - return equal(this.name, that.name) - && equal(this.network, that.network); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return toStringHelper(this) - .add("name", name) - .add("network", network).add("networkIP", networkIP).add("accessConfigs", - accessConfigs); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromNetworkInterface(this); - } - - public static class Builder { - - private String name; - private URI network; - private String networkIP; - private ImmutableSet.Builder<AccessConfig> accessConfigs = ImmutableSet.builder(); - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface#getNetwork() - */ - public Builder network(URI network) { - this.network = network; - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface#getNetworkIP() - */ - public Builder networkIP(String networkIP) { - this.networkIP = networkIP; - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface#getAccessConfigs() - */ - public Builder addAccessConfig(AccessConfig accessConfig) { - this.accessConfigs.add(accessConfig); - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface#getAccessConfigs() - */ - public Builder accessConfigs(Set<AccessConfig> accessConfigs) { - this.accessConfigs = ImmutableSet.builder(); - this.accessConfigs.addAll(accessConfigs); - return this; - } - - public NetworkInterface build() { - return new NetworkInterface(this.name, this.network, this.networkIP, this.accessConfigs.build()); - } - - public Builder fromNetworkInterface(NetworkInterface in) { - return this.network(in.getNetwork()) - .networkIP(in.getNetworkIP().orNull()) - .accessConfigs(in.getAccessConfigs()); - } - } - - /** - * Access configuration to an instance's network. - * <p/> - * This specifies how this interface is configured to interact with other network services, - * such as connecting to the internet. Currently, ONE_TO_ONE_NAT is the only access config supported. - */ - public static final class AccessConfig { - - public enum Type { - ONE_TO_ONE_NAT - } - - private Optional<String> name; - private Type type; - private Optional<String> natIP; - - @ConstructorProperties({ - "name", "type", "natIP" - }) - private AccessConfig(String name, Type type, String natIP) { - this.name = fromNullable(name); - this.type = checkNotNull(type, "type"); - this.natIP = fromNullable(natIP); - } - - /** - * @return name of this access configuration. - */ - public Optional<String> getName() { - return name; - } - - /** - * @return type of configuration. Must be set to ONE_TO_ONE_NAT. This configures port-for-port NAT to the - * internet. - */ - public Type getType() { - return type; - } - - /** - * @return an external IP address associated with this instance, if there is one. - */ - @Nullable - public Optional<String> getNatIP() { - return natIP; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(name, type, natIP); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - AccessConfig that = AccessConfig.class.cast(obj); - return equal(this.name, that.name) - && equal(this.type, that.type) - && equal(this.natIP, that.natIP); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return toStringHelper(this) - .add("name", name).add("type", type).add("natIP", natIP); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromAccessConfig(this); - } - - public static class Builder { - - private String name; - private Type type; - private String natIP; - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface.AccessConfig#getName() - */ - public Builder name(String name) { - this.name = name; - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface.AccessConfig#getType() - */ - public Builder type(Type type) { - this.type = type; - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface.AccessConfig#getNatIP() - */ - public Builder natIP(String natIP) { - this.natIP = natIP; - return this; - } - - public AccessConfig build() { - return new AccessConfig(name, type, natIP); - } - - public Builder fromAccessConfig(AccessConfig in) { - return this.name(in.getName().orNull()) - .type(in.getType()) - .natIP(in.getNatIP().orNull()); - } - } - } - } - - /** - * The output of an instance's serial port; - * - * @see <a href="https://developers.google.com/compute/docs/reference/v1/instances/serialPort"/> - */ - public static final class SerialPortOutput { - - private final Optional<String> selfLink; - private final String contents; - - @ConstructorProperties({ - "selfLink", "contents" - }) - public SerialPortOutput(String selfLink, String contents) { - this.selfLink = fromNullable(selfLink); - this.contents = checkNotNull(contents, "contents"); - } - - /** - * @return unique identifier for the resource; defined by the server (output only). - */ - public Optional<String> getSelfLink() { - return selfLink; - } - - /** - * @return the contents of the console output. - */ - public String getContents() { - return contents; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(selfLink, contents); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - SerialPortOutput that = SerialPortOutput.class.cast(obj); - return equal(this.selfLink, that.selfLink); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return toStringHelper(this).add("selfLink", selfLink).add("contents", contents); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromInstanceSerialPortOutput(this); - } - - public static final class Builder { - - private String selfLink; - private String contents; - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance.SerialPortOutput#getSelfLink() - */ - public Builder selfLink(String selfLink) { - this.selfLink = checkNotNull(selfLink); - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance.SerialPortOutput#getContents() - */ - public Builder contents(String contents) { - this.contents = contents; - return this; - } - - public SerialPortOutput build() { - return new SerialPortOutput(selfLink, contents); - } - - public Builder fromInstanceSerialPortOutput(SerialPortOutput in) { - return this.selfLink(in.getSelfLink().orNull()) - .contents(in.getContents()); - } - } - - } - - /** - * A service account for which access tokens are to be made available to the instance through metadata queries. - * - * @see <a href="https://developers.google.com/compute/docs/reference/v1/instances"/> - */ - public static final class ServiceAccount { - - private final String email; - private final Set<String> scopes; - - @ConstructorProperties({ - "email", "scopes" - }) - public ServiceAccount(String email, Set<String> scopes) { - this.email = checkNotNull(email, "email"); - this.scopes = checkNotNull(scopes, "scopes"); - } - - /** - * @return email address of the service account. - */ - public String getEmail() { - return email; - } - - /** - * @return the list of scopes to be made available for this service account. - */ - public Set<String> getScopes() { - return scopes; - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(email, scopes); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - ServiceAccount that = ServiceAccount.class.cast(obj); - return equal(this.email, that.email) - && equal(this.scopes, that.scopes); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - return toStringHelper(this).add("email", email).add("scopes", scopes); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public Builder toBuilder() { - return builder().fromInstanceServiceAccount(this); - } - - public static final class Builder { - - private String email; - private ImmutableSet.Builder<String> scopes = ImmutableSet.builder(); - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance.ServiceAccount#getEmail() - */ - public Builder email(String email) { - this.email = checkNotNull(email); - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance.ServiceAccount#getScopes() - */ - public Builder addScopes(String scopes) { - this.scopes.add(scopes); - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance.ServiceAccount#getScopes() - */ - public Builder scopes(Set<String> scopes) { - this.scopes.addAll(scopes); - return this; - } - - public ServiceAccount build() { - return new ServiceAccount(email, scopes.build()); - } - - public Builder fromInstanceServiceAccount(ServiceAccount in) { - return this.email(in.getEmail()).scopes(in.getScopes()); - } - } - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/InstanceInZone.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/InstanceInZone.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/InstanceInZone.java deleted file mode 100644 index 09a3088..0000000 --- a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/InstanceInZone.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecomputeengine.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; - -public class InstanceInZone extends SlashEncodedIds { - protected final Instance instance; - - public InstanceInZone(Instance instance, String zoneId) { - super(zoneId, checkNotNull(instance, "instance").getName()); - this.instance = instance; - } - - public Instance getInstance() { - return instance; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object obj) { - if (this == obj) return true; - if (obj == null || getClass() != obj.getClass()) return false; - InstanceInZone that = InstanceInZone.class.cast(obj); - return equal(this.instance, that.instance) - && equal(this.firstId, that.firstId) - && equal(this.secondId, that.secondId); - } - - @Override - public String toString() { - return "[instance=" + instance + ", zoneId=" + firstId + "]"; - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/897edde8/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/InstanceTemplate.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/InstanceTemplate.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/InstanceTemplate.java deleted file mode 100644 index e86bed2..0000000 --- a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/InstanceTemplate.java +++ /dev/null @@ -1,445 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.jclouds.googlecomputeengine.domain; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface.AccessConfig.Type; - -import java.net.URI; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - -/** - * Optional information for creating an instance. - */ -public class InstanceTemplate { - - protected String name; - protected String description; - protected URI machineType; - protected URI image; - protected Set<Instance.ServiceAccount> serviceAccounts = Sets.newLinkedHashSet(); - - protected transient List<PersistentDisk> disks = Lists.newArrayList(); - protected transient Set<NetworkInterface> networkInterfaces = Sets.newLinkedHashSet(); - protected transient Map<String, String> metadata = Maps.newLinkedHashMap(); - protected transient String machineTypeName; - - - protected InstanceTemplate(URI machineType) { - this.machineType = checkNotNull(machineType, "machineType"); - } - - protected InstanceTemplate(String machineTypeName) { - this.machineTypeName = checkNotNull(machineTypeName, "machineTypeName"); - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getName() - */ - public InstanceTemplate name(String name) { - this.name = name; - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getDescription() - */ - public InstanceTemplate description(String description) { - this.description = description; - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getImage() - */ - public InstanceTemplate image(URI image) { - this.image = image; - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getMachineType() - */ - public InstanceTemplate machineType(URI machineType) { - this.machineType = machineType; - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getMachineType() - */ - public InstanceTemplate machineType(String machineTypeName) { - this.machineTypeName = machineTypeName; - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getDisks() - */ - public InstanceTemplate addDisk(PersistentDisk.Mode mode, URI source) { - this.disks.add(new PersistentDisk(mode, source, null, false, false)); - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getDisks() - */ - public InstanceTemplate addDisk(PersistentDisk.Mode mode, URI source, Boolean deleteOnTerminate) { - this.disks.add(new PersistentDisk(mode, source, null, deleteOnTerminate, false)); - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getDisks() - */ - public InstanceTemplate addDisk(PersistentDisk.Mode mode, URI source, String deviceName, Boolean deleteOnTerminate) { - this.disks.add(new PersistentDisk(mode, source, deviceName, deleteOnTerminate, false)); - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getDisks() - */ - public InstanceTemplate addDisk(PersistentDisk.Mode mode, URI source, String deviceName, - Boolean deleteOnTerminate, Boolean boot) { - this.disks.add(new PersistentDisk(mode, source, deviceName, deleteOnTerminate, boot)); - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getDisks() - */ - public InstanceTemplate disks(List<PersistentDisk> disks) { - this.disks = Lists.newArrayList(); - this.disks.addAll(checkNotNull(disks, "disks")); - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getNetworkInterfaces() - */ - public InstanceTemplate addNetworkInterface(URI network) { - this.networkInterfaces.add(new NetworkInterface(checkNotNull(network, "network"), null, null)); - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getNetworkInterfaces() - */ - public InstanceTemplate addNetworkInterface(URI network, Type type) { - this.networkInterfaces.add(new NetworkInterface(checkNotNull(network, "network"), null, - ImmutableSet.of(Instance.NetworkInterface.AccessConfig.builder() - .type(type) - .build()))); - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getNetworkInterfaces() - */ - public InstanceTemplate addNetworkInterface(NetworkInterface networkInterface) { - this.networkInterfaces.add(networkInterface); - return this; - } - - public InstanceTemplate networkInterfaces(Set<NetworkInterface> networkInterfaces) { - this.networkInterfaces = Sets.newLinkedHashSet(networkInterfaces); - return this; - } - - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getMetadata() - */ - public InstanceTemplate addMetadata(String key, String value) { - this.metadata.put(checkNotNull(key, "key"), checkNotNull(value, "value of %", key)); - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getMetadata() - */ - public InstanceTemplate metadata(Map<String, String> metadata) { - this.metadata = Maps.newLinkedHashMap(); - this.metadata.putAll(checkNotNull(metadata, "metadata")); - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getServiceAccounts() - */ - public InstanceTemplate addServiceAccount(Instance.ServiceAccount serviceAccount) { - this.serviceAccounts.add(checkNotNull(serviceAccount, "serviceAccount")); - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getServiceAccounts() - */ - public InstanceTemplate serviceAccounts(Set<Instance.ServiceAccount> serviceAccounts) { - this.serviceAccounts = Sets.newLinkedHashSet(); - this.serviceAccounts.addAll(checkNotNull(serviceAccounts, "serviceAccounts")); - return this; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getDescription() - */ - public String getDescription() { - return description; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getDisks() - */ - public List<PersistentDisk> getDisks() { - return disks; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getImage() - */ - public URI getImage() { - return image; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getMachineType() - */ - public URI getMachineType() { - return machineType; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getMachineType() - */ - public String getMachineTypeName() { - return machineTypeName; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getMetadata() - */ - public Map<String, String> getMetadata() { - return metadata; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getNetworkInterfaces() - */ - public Set<NetworkInterface> getNetworkInterfaces() { - return networkInterfaces; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getServiceAccounts() - */ - public Set<Instance.ServiceAccount> getServiceAccounts() { - return serviceAccounts; - } - - /** - * @see org.jclouds.googlecomputeengine.domain.Instance#getName() - */ - public String getName() { - return name; - } - - public static Builder builder() { - return new Builder(); - } - - public static InstanceTemplate fromInstanceTemplate(InstanceTemplate instanceTemplate) { - return Builder.fromInstanceTemplate(instanceTemplate); - } - - public static class Builder { - - public InstanceTemplate forMachineType(URI machineType) { - return new InstanceTemplate(machineType); - } - - public InstanceTemplate forMachineType(String machineTypeName) { - return new InstanceTemplate(machineTypeName); - } - - public static InstanceTemplate fromInstanceTemplate(InstanceTemplate instanceTemplate) { - return InstanceTemplate.builder() - .forMachineType(instanceTemplate.getMachineType()) - .networkInterfaces(instanceTemplate.getNetworkInterfaces()) - .name(instanceTemplate.getName()) - .description(instanceTemplate.getDescription()) - .image(instanceTemplate.getImage()) - .disks(instanceTemplate.getDisks()) - .metadata(instanceTemplate.getMetadata()) - .serviceAccounts(instanceTemplate.getServiceAccounts()); - } - } - - - public static class PersistentDisk { - - public enum Mode { - READ_WRITE, - READ_ONLY - } - - public PersistentDisk(Mode mode, URI source, String deviceName, Boolean deleteOnTerminate, - Boolean boot) { - this.mode = checkNotNull(mode, "mode"); - this.source = checkNotNull(source, "source"); - this.deviceName = deviceName; - this.deleteOnTerminate = checkNotNull(deleteOnTerminate, "deleteOnTerminate"); - this.boot = checkNotNull(boot, "boot"); - } - - private final Mode mode; - private final URI source; - private final Boolean deleteOnTerminate; - private final String deviceName; - private final Boolean boot; - - /** - * @return the mode in which to attach this disk, either READ_WRITE or READ_ONLY. - */ - public Mode getMode() { - return mode; - } - - /** - * @return the URL of the persistent disk resource. - */ - public URI getSource() { - return source; - } - - /** - * @return Must be unique within the instance when specified. This represents a unique - * device name that is reflected into the /dev/ tree of a Linux operating system running within the - * instance. If not specified, a default will be chosen by the system. - */ - public String getDeviceName() { - return deviceName; - } - - - /** - * @return If true, delete the disk and all its data when the associated instance is deleted. - */ - public boolean isDeleteOnTerminate() { - return deleteOnTerminate; - } - - /** - * @return If true, boot from this disk. - */ - public boolean isBoot() { - return boot; - } - } - - public static class NetworkInterface { - - private final URI network; - private final String networkIP; - private final Set<Instance.NetworkInterface.AccessConfig> accessConfigs; - - public NetworkInterface(URI network, String networkIP, Set<Instance.NetworkInterface.AccessConfig> - accessConfigs) { - this.networkIP = networkIP; - this.network = network; - this.accessConfigs = accessConfigs != null ? accessConfigs : ImmutableSet.<Instance.NetworkInterface.AccessConfig>of(); - } - - public Set<Instance.NetworkInterface.AccessConfig> getAccessConfigs() { - return accessConfigs; - } - - public URI getNetwork() { - return network; - } - - public String getNetworkIP() { - return networkIP; - } - } - - - /** - * {@inheritDoc} - */ - @Override - public boolean equals(Object object) { - if (this == object) { - return true; - } - if (object instanceof InstanceTemplate) { - final InstanceTemplate other = InstanceTemplate.class.cast(object); - return equal(description, other.description) - && equal(image, other.image) - && equal(disks, other.disks) - && equal(networkInterfaces, other.networkInterfaces) - && equal(metadata, other.metadata) - && equal(serviceAccounts, other.serviceAccounts); - } else { - return false; - } - } - - /** - * {@inheritDoc} - */ - @Override - public int hashCode() { - return Objects.hashCode(description, image, disks, networkInterfaces, metadata, serviceAccounts); - } - - /** - * {@inheritDoc} - */ - protected Objects.ToStringHelper string() { - Objects.ToStringHelper toString = Objects.toStringHelper("") - .omitNullValues(); - toString.add("description", description); - if (disks.size() > 0) - toString.add("disks", disks); - if (metadata.size() > 0) - toString.add("metadata", metadata); - if (serviceAccounts.size() > 0) - toString.add("serviceAccounts", serviceAccounts); - toString.add("image", image); - toString.add("networkInterfaces", networkInterfaces); - return toString; - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return string().toString(); - } -}
