You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2015/08/20 11:36:31 UTC
[45/51] [abbrv] [partial] stratos git commit: Revert "Upgrading to
jclouds 1.9.1"
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Operation.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Operation.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Operation.java
new file mode 100644
index 0000000..deab873
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Operation.java
@@ -0,0 +1,556 @@
+/*
+ * 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 java.util.List;
+
+import org.jclouds.http.HttpResponse;
+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.collect.ImmutableList;
+
+/**
+ * Describes an operation being executed on some Resource
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/operations"/>
+ */
+@Beta
+public class Operation extends Resource {
+
+ public static enum Status {
+ PENDING,
+ RUNNING,
+ DONE
+ }
+
+ private final URI targetLink;
+ private final Optional<String> targetId;
+ private final Optional<String> clientOperationId;
+ private final Status status;
+ private final Optional<String> statusMessage;
+ private final String user;
+ private final Optional<Integer> progress;
+ private final Date insertTime;
+ private final Optional<Date> startTime;
+ private final Optional<Date> endTime;
+ private final Optional<HttpResponse> httpError;
+ private final String operationType;
+ private final List<Error> errors;
+ private final Optional<URI> zone;
+ private final Optional<URI> region;
+
+ protected Operation(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ URI targetLink, String targetId, String clientOperationId, Status status,
+ String statusMessage, String user, Integer progress, Date insertTime, Date startTime,
+ Date endTime, Integer httpErrorStatusCode, String httpErrorMessage, String operationType,
+ @Nullable List<Error> errors, URI region, URI zone) {
+ super(Kind.OPERATION, id, creationTimestamp, selfLink, name, description);
+ this.targetLink = checkNotNull(targetLink, "targetLink of %s", name);
+ this.targetId = fromNullable(targetId);
+ this.clientOperationId = fromNullable(clientOperationId);
+ this.status = checkNotNull(status, "status of %s", name);
+ this.statusMessage = fromNullable(statusMessage);
+ this.user = checkNotNull(user, "user of %s", name);
+ this.progress = fromNullable(progress);
+ this.insertTime = checkNotNull(insertTime, "insertTime of %s", name);
+ this.startTime = fromNullable(startTime);
+ this.endTime = fromNullable(endTime);
+ this.httpError = httpErrorStatusCode != null && httpErrorStatusCode != 0 ?
+ Optional.of(HttpResponse.builder()
+ .statusCode(httpErrorStatusCode)
+ .message(httpErrorMessage)
+ .build())
+ : Optional.<HttpResponse>absent();
+ this.operationType = checkNotNull(operationType, "insertTime of %s", name);
+ this.errors = errors == null ? ImmutableList.<Error>of() : ImmutableList.copyOf(errors);
+ this.region = fromNullable(region);
+ this.zone = fromNullable(zone);
+ }
+
+ /**
+ * @return URL of the resource the operation is mutating.
+ */
+ public URI getTargetLink() {
+ return targetLink;
+ }
+
+ /**
+ * @return An optional identifier specified by the client when the mutation was initiated. Must be unique for all
+ * operation resources in the project.
+ */
+ public Optional<String> getClientOperationId() {
+ return clientOperationId;
+ }
+
+ /**
+ * @return unique target id which identifies a particular incarnation of the target.
+ */
+ public Optional<String> getTargetId() {
+ return targetId;
+ }
+
+ /**
+ * @return region this operation is in, if any.
+ */
+ public Optional<URI> getRegion() {
+ return region;
+ }
+
+ /**
+ * @return zone this operation is in, if any.
+ */
+ public Optional<URI> getZone() {
+ return zone;
+ }
+
+ /**
+ * @return Status of the operation. Can be one of the following: PENDING, RUNNING, or DONE.
+ */
+ public Status getStatus() {
+ return status;
+ }
+
+ /**
+ * @return An optional textual description of the current status of the operation.
+ */
+ public Optional<String> getStatusMessage() {
+ return statusMessage;
+ }
+
+ /**
+ * @return User who requested the operation, for example "user@example.com".
+ */
+ public String getUser() {
+ return user;
+ }
+
+ /**
+ * @return an optional progress indicator that ranges from 0 to 100. This should not be used to guess at when the
+ * operation will be complete. This number should be monotonically increasing as the operation progresses
+ * (output only).
+ */
+ public Optional<Integer> getProgress() {
+ return progress;
+ }
+
+ /**
+ * @return the time that this operation was requested.
+ */
+ public Date getInsertTime() {
+ return insertTime;
+ }
+
+ /**
+ * @return the time that this operation was started by the server.
+ */
+ public Optional<Date> getStartTime() {
+ return startTime;
+ }
+
+ /**
+ * @return the time that this operation was completed.
+ */
+ public Optional<Date> getEndTime() {
+ return endTime;
+ }
+
+ /**
+ * @return if operation fails, the HttpResponse with error status code returned and the message, e.g. NOT_FOUND.
+ */
+ public Optional<HttpResponse> getHttpError() {
+ return httpError;
+ }
+
+ /**
+ * @return type of the operation. Examples include insert, update, and delete.
+ */
+ public String getOperationType() {
+ return operationType;
+ }
+
+ /**
+ * @return if error occurred during processing of this operation, this field will be populated.
+ */
+ public List<Error> getErrors() {
+ return errors;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .omitNullValues()
+ .add("targetLink", targetLink)
+ .add("targetId", targetId.orNull())
+ .add("clientOperationId", clientOperationId.orNull())
+ .add("status", status)
+ .add("statusMessage", statusMessage.orNull())
+ .add("user", user)
+ .add("progress", progress.orNull())
+ .add("insertTime", insertTime)
+ .add("startTime", startTime.orNull())
+ .add("endTime", endTime.orNull())
+ .add("httpError", httpError.orNull())
+ .add("operationType", operationType)
+ .add("errors", errors)
+ .add("region", region.orNull())
+ .add("zone", zone.orNull());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromOperation(this);
+ }
+
+ public static final class Builder extends Resource.Builder<Builder> {
+
+ private URI targetLink;
+ private String targetId;
+ private String clientOperationId;
+ private Status status;
+ private String statusMessage;
+ private String user;
+ private Integer progress;
+ private Date insertTime;
+ private Date startTime;
+ private Date endTime;
+ private Integer httpErrorStatusCode;
+ private String httpErrorMessage;
+ private String operationType;
+ private ImmutableList.Builder<Error> errors = ImmutableList.builder();
+ private URI region;
+ private URI zone;
+
+ /**
+ * @see Operation#getTargetLink()
+ */
+ public Builder targetLink(URI targetLink) {
+ this.targetLink = targetLink;
+ return self();
+ }
+
+ /**
+ * @see Operation#getRegion()
+ */
+ public Builder region(URI region) {
+ this.region = region;
+ return self();
+ }
+
+ /**
+ * @see Operation#getZone()
+ */
+ public Builder zone(URI zone) {
+ this.zone = zone;
+ return self();
+ }
+
+ /**
+ * @see Operation#getTargetId()
+ */
+ public Builder targetId(String targetId) {
+ this.targetId = targetId;
+ return self();
+ }
+
+ /**
+ * @see Operation#getClientOperationId()
+ */
+ public Builder clientOperationId(String clientOperationId) {
+ this.clientOperationId = clientOperationId;
+ return self();
+ }
+
+ /**
+ * @see Operation#getStatus()
+ */
+ public Builder status(Status status) {
+ this.status = status;
+ return self();
+ }
+
+ /**
+ * @see Operation#getStatusMessage()
+ */
+ public Builder statusMessage(String statusMessage) {
+ this.statusMessage = statusMessage;
+ return self();
+ }
+
+ /**
+ * @see Operation#getUser()
+ */
+ public Builder user(String user) {
+ this.user = user;
+ return self();
+ }
+
+ /**
+ * @see Operation#getProgress()
+ */
+ public Builder progress(Integer progress) {
+ this.progress = progress;
+ return self();
+ }
+
+ /**
+ * @see Operation#getInsertTime()
+ */
+ public Builder insertTime(Date insertTime) {
+ this.insertTime = insertTime;
+ return self();
+ }
+
+ /**
+ * @see Operation#getStartTime()
+ */
+ public Builder startTime(Date startTime) {
+ this.startTime = startTime;
+ return self();
+ }
+
+ /**
+ * @see Operation#getEndTime()
+ */
+ public Builder endTime(Date endTime) {
+ this.endTime = endTime;
+ return self();
+ }
+
+ /**
+ * @see Operation#getHttpError()
+ */
+ public Builder httpErrorStatusCode(Integer httpErrorStatusCode) {
+ this.httpErrorStatusCode = httpErrorStatusCode;
+ return self();
+ }
+
+ /**
+ * @see Operation#getHttpError()
+ */
+ public Builder httpErrorMessage(String httpErrorMessage) {
+ this.httpErrorMessage = httpErrorMessage;
+ return self();
+ }
+
+ /**
+ * @see Operation#getOperationType()
+ */
+ public Builder operationType(String operationType) {
+ this.operationType = operationType;
+ return self();
+ }
+
+ /**
+ * @see Operation#getErrors()
+ */
+ public Builder errors(Iterable<Error> errors) {
+ if (errors != null)
+ this.errors.addAll(errors);
+ return self();
+ }
+
+ /**
+ * @see Operation#getErrors()
+ */
+ public Builder addError(Error error) {
+ this.errors.add(error);
+ return self();
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+
+ public Operation build() {
+ return new Operation(super.id, super.creationTimestamp, super.selfLink, super.name,
+ super.description, targetLink, targetId, clientOperationId, status, statusMessage, user, progress,
+ insertTime, startTime, endTime, httpErrorStatusCode, httpErrorMessage, operationType,
+ errors.build(), region, zone);
+ }
+
+ public Builder fromOperation(Operation in) {
+ return super.fromResource(in)
+ .targetLink(in.getTargetLink())
+ .targetId(in.getTargetId().orNull())
+ .clientOperationId(in.getClientOperationId().orNull())
+ .status(in.getStatus())
+ .statusMessage(in.getStatusMessage().orNull())
+ .user(in.getUser())
+ .progress(in.getProgress().get())
+ .insertTime(in.getInsertTime())
+ .startTime(in.getStartTime().orNull())
+ .endTime(in.getEndTime().orNull())
+ .httpErrorStatusCode(in.getHttpError().isPresent() ? in.getHttpError().get().getStatusCode() : null)
+ .httpErrorMessage(in.getHttpError().isPresent() ? in.getHttpError().get().getMessage() : null)
+ .operationType(in.getOperationType()).errors(in.getErrors())
+ .zone(in.getZone().orNull()).region(in.getRegion().orNull());
+ }
+ }
+
+ /**
+ * A particular error for an operation including the details.
+ */
+ public static final class Error {
+
+ private final String code;
+ private final Optional<String> location;
+ private final Optional<String> message;
+
+ @ConstructorProperties({
+ "code", "location", "message"
+ })
+ private Error(String code, String location, String message) {
+ this.code = checkNotNull(code, "code");
+ this.location = fromNullable(location);
+ this.message = fromNullable(message);
+ }
+
+ /**
+ * @return the error type identifier for this error.
+ */
+ public String getCode() {
+ return code;
+ }
+
+ /**
+ * @return indicates the field in the request which caused the error..
+ */
+ public Optional<String> getLocation() {
+ return location;
+ }
+
+ /**
+ * @return an optional, human-readable error message.
+ */
+ public Optional<String> getMessage() {
+ return message;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(code, location, message);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Error that = Error.class.cast(obj);
+ return equal(this.code, that.code)
+ && equal(this.location, that.location)
+ && equal(this.message, that.message);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this)
+ .omitNullValues()
+ .add("code", code)
+ .add("location", location.orNull())
+ .add("message", message.orNull());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromOperationErrorDetail(this);
+ }
+
+ public static final class Builder {
+
+ private String code;
+ private String location;
+ private String message;
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Operation.Error#getCode()
+ */
+ public Builder code(String code) {
+ this.code = code;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Operation.Error#getLocation()
+ */
+ public Builder location(String location) {
+ this.location = location;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Operation.Error#getMessage()
+ */
+ public Builder message(String message) {
+ this.message = message;
+ return this;
+ }
+
+ public Error build() {
+ return new Error(code, location, message);
+ }
+
+ public Builder fromOperationErrorDetail(Error in) {
+ return new Builder().code(in.getCode()).location(in.getLocation().orNull()).message
+ (in.getMessage().orNull());
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Project.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Project.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Project.java
new file mode 100644
index 0000000..ac3867b
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Project.java
@@ -0,0 +1,162 @@
+/*
+ * 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.Preconditions.checkNotNull;
+
+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.collect.ImmutableSet;
+
+/**
+ * A Project resource is the root collection and settings resource for all Google Compute Engine resources.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/projects"/>
+ */
+@Beta
+public class Project extends Resource {
+
+ private final Metadata commonInstanceMetadata;
+ private final Set<Quota> quotas;
+ private final Set<String> externalIpAddresses;
+
+ protected Project(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ Metadata commonInstanceMetadata, Set<Quota> quotas, Set<String> externalIpAddresses) {
+ super(Kind.PROJECT, id, creationTimestamp, selfLink, name, description);
+ this.commonInstanceMetadata = checkNotNull(commonInstanceMetadata, "commonInstanceMetadata");
+ this.quotas = quotas == null ? ImmutableSet.<Quota>of() : ImmutableSet.copyOf(quotas);
+ this.externalIpAddresses = externalIpAddresses == null ? ImmutableSet.<String>of() : ImmutableSet.copyOf
+ (externalIpAddresses);
+ }
+
+ /**
+ * @return metadata key/value pairs available to all instances contained in this project.
+ */
+ public Metadata getCommonInstanceMetadata() {
+ return commonInstanceMetadata;
+ }
+
+ /**
+ * @return quotas assigned to this project.
+ */
+ public Set<Quota> getQuotas() {
+ return quotas;
+ }
+
+ /**
+ * @return internet available IP addresses available for use in this project.
+ */
+ @Nullable
+ public Set<String> getExternalIpAddresses() {
+ return externalIpAddresses;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .add("commonInstanceMetadata", commonInstanceMetadata)
+ .add("quotas", quotas)
+ .add("externalIpAddresses", externalIpAddresses);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromProject(this);
+ }
+
+ public static final class Builder extends Resource.Builder<Builder> {
+
+ private Metadata commonInstanceMetadata;
+ private ImmutableSet.Builder<Quota> quotas = ImmutableSet.builder();
+ private ImmutableSet.Builder<String> externalIpAddresses = ImmutableSet.builder();
+
+ /**
+ * @see Project#getCommonInstanceMetadata()
+ */
+ public Builder commonInstanceMetadata(Metadata commonInstanceMetadata) {
+ this.commonInstanceMetadata = commonInstanceMetadata;
+ return this;
+ }
+
+ /**
+ * @see Project#getQuotas()
+ */
+ public Builder addQuota(String metric, double usage, double limit) {
+ this.quotas.add(Quota.builder().metric(metric).usage(usage).limit(limit).build());
+ return this;
+ }
+
+ /**
+ * @see Project#getQuotas()
+ */
+ public Builder quotas(Set<Quota> quotas) {
+ this.quotas.addAll(checkNotNull(quotas));
+ return this;
+ }
+
+ /**
+ * @see Project#getExternalIpAddresses()
+ */
+ public Builder addExternalIpAddress(String externalIpAddress) {
+ this.externalIpAddresses.add(checkNotNull(externalIpAddress, "externalIpAddress"));
+ return this;
+ }
+
+ /**
+ * @see Project#getExternalIpAddresses()
+ */
+ public Builder externalIpAddresses(Set<String> externalIpAddresses) {
+ this.externalIpAddresses.addAll(checkNotNull(externalIpAddresses, "externalIpAddresses"));
+ return this;
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+
+ public Project build() {
+ return new Project(super.id, super.creationTimestamp, super.selfLink, super.name,
+ super.description, commonInstanceMetadata, quotas.build(), externalIpAddresses.build());
+ }
+
+ public Builder fromProject(Project in) {
+ return super.fromResource(in).commonInstanceMetadata(in.getCommonInstanceMetadata()).quotas(in.getQuotas())
+ .externalIpAddresses(in.getExternalIpAddresses());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Quota.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Quota.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Quota.java
new file mode 100644
index 0000000..3c17130
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Quota.java
@@ -0,0 +1,152 @@
+/*
+ * 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.Preconditions.checkNotNull;
+
+import java.beans.ConstructorProperties;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+
+/**
+ * Quotas assigned to a given project or region.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/projects#resource"/>
+ */
+@Beta
+public class Quota {
+ private String metric;
+ private double usage;
+ private double limit;
+
+ @ConstructorProperties({
+ "metric", "usage", "limit"
+ })
+ public Quota(String metric, Double usage, Double limit) {
+ this.metric = metric != null ? metric : "undefined";
+ this.usage = checkNotNull(usage, "usage");
+ this.limit = checkNotNull(limit, "limit");
+ }
+
+ /**
+ * @return name of the quota metric.
+ */
+ public String getMetric() {
+ return metric;
+ }
+
+ /**
+ * @return current usage of this metric.
+ */
+ public Double getUsage() {
+ return usage;
+ }
+
+ /**
+ * @return quota limit for this metric.
+ */
+ public Double getLimit() {
+ return limit;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(metric);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || this.getClass() != obj.getClass()) return false;
+ Quota that = Quota.class.cast(obj);
+ return Objects.equal(this.metric, that.metric);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ToStringHelper string() {
+ return Objects.toStringHelper(this)
+ .omitNullValues()
+ .add("metric", metric)
+ .add("usage", usage)
+ .add("limit", limit);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromQuota(this);
+ }
+
+ public static class Builder {
+
+ private String metric;
+ private Double usage;
+ private Double limit;
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Quota#getMetric()
+ */
+ public Builder metric(String metric) {
+ this.metric = checkNotNull(metric, "metric");
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Quota#getUsage()
+ */
+ public Builder usage(Double usage) {
+ this.usage = usage;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Quota#getLimit()
+ */
+ public Builder limit(Double limit) {
+ this.limit = limit;
+ return this;
+ }
+
+ public Quota build() {
+ return new Quota(metric, usage, limit);
+ }
+
+ public Builder fromQuota(Quota quota) {
+ return new Builder().metric(quota.getMetric()).usage(quota.getUsage()).limit(quota.getLimit());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Region.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Region.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Region.java
new file mode 100644
index 0000000..aa459bf
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Region.java
@@ -0,0 +1,175 @@
+/*
+ * 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.Preconditions.checkNotNull;
+
+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.collect.ImmutableSet;
+
+/**
+ * Represents a region resource.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/regions"/>
+ */
+@Beta
+public final class Region extends Resource {
+
+ public enum Status {
+ UP,
+ DOWN
+ }
+
+ private final Status status;
+ private final Set<URI> zones;
+ private final Set<Quota> quotas;
+
+ @ConstructorProperties({
+ "id", "creationTimestamp", "selfLink", "name", "description", "status",
+ "zones", "quotas"
+ })
+ private Region(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ Status status, Set<URI> zones, Set<Quota> quotas) {
+ super(Kind.REGION, id, creationTimestamp, selfLink, name, description);
+ this.status = checkNotNull(status, "status of %name", name);
+ this.zones = zones == null ? ImmutableSet.<URI>of() : ImmutableSet
+ .copyOf(zones);
+ this.quotas = quotas == null ? ImmutableSet.<Quota>of() : ImmutableSet.copyOf(quotas);
+ }
+
+ /**
+ * @return Status of the region. "UP" or "DOWN".
+ */
+ public Status getStatus() {
+ return status;
+ }
+
+ /**
+ * @return the zones that can be used in this region.
+ */
+ @Nullable
+ public Set<URI> getZones() {
+ return zones;
+ }
+
+ /**
+ * @return quotas assigned to this project.
+ */
+ public Set<Quota> getQuotas() {
+ return quotas;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .add("status", status)
+ .add("zones", zones)
+ .add("quotas", quotas);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromRegion(this);
+ }
+
+ public static final class Builder extends Resource.Builder<Builder> {
+
+ private Status status;
+ private ImmutableSet.Builder<URI> zones = ImmutableSet.builder();
+ private ImmutableSet.Builder<Quota> quotas = ImmutableSet.builder();
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Region#getStatus()
+ */
+ public Builder status(Status status) {
+ this.status = status;
+ return this;
+ }
+
+ /**
+ * @see Region#getZones()
+ */
+ public Builder zone(URI zone) {
+ this.zones.add(checkNotNull(zone, "zone"));
+ return this;
+ }
+
+ /**
+ * @see Region#getZones()
+ */
+ public Builder zones(Set<URI> zones) {
+ this.zones.addAll(checkNotNull(zones, "zones"));
+ return this;
+ }
+
+ /**
+ * @see Region#getQuotas()
+ */
+ public Builder addQuota(String metric, double usage, double limit) {
+ this.quotas.add(Quota.builder().metric(metric).usage(usage).limit(limit).build());
+ return this;
+ }
+
+ /**
+ * @see Region#getQuotas()
+ */
+ public Builder quotas(Set<Quota> quotas) {
+ this.quotas.addAll(checkNotNull(quotas));
+ return this;
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+
+ public Region build() {
+ return new Region(super.id, super.creationTimestamp, super.selfLink, super.name,
+ super.description, status, zones.build(), quotas.build());
+ }
+
+ public Builder fromRegion(Region in) {
+ return super.fromResource(in)
+ .status(in.getStatus())
+ .zones(in.getZones())
+ .quotas(in.getQuotas());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Resource.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Resource.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Resource.java
new file mode 100644
index 0000000..4d0a1c8
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Resource.java
@@ -0,0 +1,283 @@
+/*
+ * 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.ToStringHelper;
+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 org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.CaseFormat;
+import com.google.common.base.Joiner;
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.base.Splitter;
+import com.google.common.collect.Iterables;
+
+/**
+ * Base class for Google Compute Engine resources.
+ */
+@Beta
+public class Resource {
+
+ public enum Kind {
+ ADDRESS,
+ ADDRESS_LIST,
+ DISK,
+ DISK_LIST,
+ FIREWALL,
+ FIREWALL_LIST,
+ IMAGE,
+ IMAGE_LIST,
+ OPERATION,
+ OPERATION_LIST,
+ INSTANCE,
+ INSTANCE_LIST,
+ MACHINE_TYPE,
+ MACHINE_TYPE_LIST,
+ PROJECT,
+ NETWORK,
+ NETWORK_LIST,
+ REGION,
+ REGION_LIST,
+ ROUTE,
+ ROUTE_LIST,
+ SNAPSHOT,
+ SNAPSHOT_LIST,
+ ZONE,
+ ZONE_LIST;
+
+ public String value() {
+ return Joiner.on("#").join("compute", CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name()));
+ }
+
+ @Override
+ public String toString() {
+ return value();
+ }
+
+ public static Kind fromValue(String kind) {
+ return valueOf(CaseFormat.LOWER_CAMEL.to(CaseFormat
+ .UPPER_UNDERSCORE,
+ Iterables.getLast(Splitter.on("#").split(checkNotNull(kind,
+ "kind")))));
+ }
+ }
+
+ protected final Kind kind;
+ protected final String id;
+ protected final Optional<Date> creationTimestamp;
+ protected final URI selfLink;
+ protected final String name;
+ protected final Optional<String> description;
+
+ @ConstructorProperties({
+ "kind", "id", "creationTimestamp", "selfLink", "name", "description"
+ })
+ protected Resource(Kind kind, String id, Date creationTimestamp, URI selfLink, String name,
+ String description) {
+ this.kind = checkNotNull(kind, "kind");
+ this.id = checkNotNull(id, "id");
+ this.creationTimestamp = fromNullable(creationTimestamp);
+ this.selfLink = checkNotNull(selfLink, "selfLink");
+ this.name = checkNotNull(name, "name");
+ this.description = fromNullable(description);
+ }
+
+ /**
+ * @return the Type of the resource
+ */
+ public Kind getKind() {
+ return kind;
+ }
+
+ /**
+ * @return unique identifier for the resource; defined by the server.
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * @return creation timestamp in RFC3339 text format.
+ */
+ public Optional<Date> getCreationTimestamp() {
+ return creationTimestamp;
+ }
+
+ /**
+ * @return server defined URL for the resource.
+ */
+ public URI getSelfLink() {
+ return selfLink;
+ }
+
+ /**
+ * @return name of the resource.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return an optional textual description of the resource.
+ */
+ @Nullable
+ public Optional<String> getDescription() {
+ return description;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(kind, name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Resource that = Resource.class.cast(obj);
+ return equal(this.kind, that.kind)
+ && equal(this.name, that.name);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected ToStringHelper string() {
+ return toStringHelper(this)
+ .omitNullValues()
+ .add("kind", kind)
+ .add("id", id)
+ .add("name", name)
+ .add("creationTimestamp", creationTimestamp.orNull())
+ .add("selfLink", selfLink)
+ .add("name", name)
+ .add("description", description.orNull());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder<?> builder() {
+ return new ConcreteBuilder();
+ }
+
+ public Builder<?> toBuilder() {
+ return new ConcreteBuilder().fromResource(this);
+ }
+
+ public abstract static class Builder<T extends Builder<T>> {
+
+ protected abstract T self();
+
+ protected Kind kind;
+ protected String id;
+ protected Date creationTimestamp;
+ protected URI selfLink;
+ protected String name;
+ protected String description;
+
+ /**
+ * @see Resource#getKind()
+ */
+ protected T kind(Kind kind) {
+ this.kind = kind;
+ return self();
+ }
+
+ /**
+ * @see Resource#getId()
+ */
+ public T id(String id) {
+ this.id = id;
+ return self();
+ }
+
+ /**
+ * @see Resource#getCreationTimestamp()
+ */
+ public T creationTimestamp(Date creationTimestamp) {
+ this.creationTimestamp = creationTimestamp;
+ return self();
+ }
+
+ /**
+ * @see Resource#getSelfLink()
+ */
+ public T selfLink(URI selfLink) {
+ this.selfLink = selfLink;
+ return self();
+ }
+
+ /**
+ * @see Resource#getName()
+ */
+ public T name(String name) {
+ this.name = name;
+ return self();
+ }
+
+ /**
+ * @see Resource#getDescription()
+ */
+ public T description(String description) {
+ this.description = description;
+ return self();
+ }
+
+ public Resource build() {
+ return new Resource(kind, id, creationTimestamp, selfLink, name, description);
+ }
+
+ public T fromResource(Resource in) {
+ return this
+ .kind(in.getKind())
+ .id(in.getId())
+ .creationTimestamp(in.getCreationTimestamp().orNull())
+ .selfLink(in.getSelfLink())
+ .name(in.getName())
+ .description(in.getDescription().orNull());
+ }
+ }
+
+ private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
+ @Override
+ protected ConcreteBuilder self() {
+ return this;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Route.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Route.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Route.java
new file mode 100644
index 0000000..df5bb1d
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Route.java
@@ -0,0 +1,433 @@
+/*
+ * 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 java.util.Map;
+import java.util.Set;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.Objects;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Represents a route resource.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/routes"/>
+ */
+@Beta
+public final class Route extends Resource {
+
+ private final URI network;
+ private final Set<String> tags;
+ private final String destRange;
+ private final Integer priority;
+ private final Optional<URI> nextHopInstance;
+ private final Optional<String> nextHopIp;
+ private final Optional<URI> nextHopNetwork;
+ private final Optional<URI> nextHopGateway;
+ private final Set<Warning> warnings;
+
+ @ConstructorProperties({
+ "id", "creationTimestamp", "selfLink", "name", "description", "network", "tags",
+ "destRange", "priority", "nextHopInstance", "nextHopIp", "nextHopNetwork",
+ "nextHopGateway", "warnings"
+ })
+ private Route(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ URI network, Set<String> tags, String destRange, Integer priority,
+ URI nextHopInstance, String nextHopIp, URI nextHopNetwork,
+ URI nextHopGateway, Set<Warning> warnings) {
+ super(Kind.ROUTE, id, creationTimestamp, selfLink, name, description);
+ this.network = checkNotNull(network, "network for %name", name);
+ this.tags = tags == null ? ImmutableSet.<String>of() : tags;
+ this.destRange = checkNotNull(destRange, "destination range for %name", name);
+ this.priority = checkNotNull(priority, "priority of %name", name);
+ this.nextHopInstance = fromNullable(nextHopInstance);
+ this.nextHopIp = fromNullable(nextHopIp);
+ this.nextHopNetwork = fromNullable(nextHopNetwork);
+ this.nextHopGateway = fromNullable(nextHopGateway);
+ this.warnings = warnings == null ? ImmutableSet.<Warning>of() : warnings;
+ }
+
+ /**
+ * @return Network for this Route.
+ */
+ public URI getNetwork() {
+ return network;
+ }
+
+ /**
+ * @return The set of instance items to which this route applies.
+ */
+ public Set<String> getTags() {
+ return tags;
+ }
+
+ /**
+ * @return The destination range of outgoing packets that this route applies to.
+ */
+ public String getDestRange() {
+ return destRange;
+ }
+
+ /**
+ * @return The priority of this route. Priority is used to break ties in the case
+ * where there is more than one matching route of maximum length. A lower value
+ * is higher priority; a priority of 100 is higher than 200.
+ */
+ public Integer getPriority() {
+ return priority;
+ }
+
+ /**
+ * @return The fully-qualified URL to an instance that should handle matching packets.
+ */
+ public Optional<URI> getNextHopInstance() {
+ return nextHopInstance;
+ }
+
+ /**
+ * @return The network IP address of an instance that should handle matching packets.
+ */
+ public Optional<String> getNextHopIp() {
+ return nextHopIp;
+ }
+
+ /**
+ * @return The URL of the local network if it should handle matching packets.
+ */
+ public Optional<URI> getNextHopNetwork() {
+ return nextHopNetwork;
+ }
+
+ /**
+ * @return The URL to a gateway that should handle matching packets. Currently, this is only the internet gateway.
+ */
+ public Optional<URI> getNextHopGateway() {
+ return nextHopGateway;
+ }
+
+ /**
+ * @return If potential misconfigurations are detected for this route, this field will be populated with warning messages.
+ */
+ public Set<Warning> getWarnings() {
+ return warnings;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .add("network", network)
+ .add("tags", tags)
+ .add("destRange", destRange)
+ .add("priority", priority)
+ .add("nextHopInstance", nextHopInstance.orNull())
+ .add("nextHopIp", nextHopIp.orNull())
+ .add("nextHopNetwork", nextHopNetwork.orNull())
+ .add("nextHopGateway", nextHopGateway.orNull())
+ .add("warnings", warnings);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromRoute(this);
+ }
+
+ public static final class Builder extends Resource.Builder<Builder> {
+
+ private URI network;
+ private ImmutableSet.Builder<String> tags = ImmutableSet.builder();
+ private String destRange;
+ private Integer priority;
+ private URI nextHopInstance;
+ private String nextHopIp;
+ private URI nextHopNetwork;
+ private URI nextHopGateway;
+ private ImmutableSet.Builder<Warning> warnings = ImmutableSet.builder();
+
+
+ /**
+ * @see Route#getNetwork()
+ */
+ public Builder network(URI network) {
+ this.network = network;
+ return this;
+ }
+
+ /**
+ * @see Route#getTags()
+ */
+ public Builder addTag(String tag) {
+ this.tags.add(tag);
+ return this;
+ }
+
+ /**
+ * @see Route#getTags()
+ */
+ public Builder tags(Set<String> tags) {
+ this.tags.addAll(tags);
+ return this;
+ }
+
+ /**
+ * @see Route#getDestRange()
+ */
+ public Builder destRange(String destRange) {
+ this.destRange = destRange;
+ return this;
+ }
+
+ /**
+ * @see Route#getPriority()
+ */
+ public Builder priority(Integer priority) {
+ this.priority = priority;
+ return this;
+ }
+
+ /**
+ * @see Route#getNextHopInstance()
+ */
+ public Builder nextHopInstance(URI nextHopInstance) {
+ this.nextHopInstance = nextHopInstance;
+ return this;
+ }
+
+ /**
+ * @see Route#getNextHopIp()
+ */
+ public Builder nextHopIp(String nextHopIp) {
+ this.nextHopIp = nextHopIp;
+ return this;
+ }
+
+ /**
+ * @see Route#getNextHopNetwork()
+ */
+ public Builder nextHopNetwork(URI nextHopNetwork) {
+ this.nextHopNetwork = nextHopNetwork;
+ return this;
+ }
+
+ /**
+ * @see Route#getNextHopGateway()
+ */
+ public Builder nextHopGateway(URI nextHopGateway) {
+ this.nextHopGateway = nextHopGateway;
+ return this;
+ }
+
+ /**
+ * @see Route#getWarnings()
+ */
+ public Builder addWarning(Warning warning) {
+ this.warnings.add(warning);
+ return this;
+ }
+
+ /**
+ * @see Route#getWarnings()
+ */
+ public Builder warnings(Set<Warning> warnings) {
+ this.warnings.addAll(warnings);
+ return this;
+ }
+
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+
+ public Route build() {
+ return new Route(super.id, super.creationTimestamp, super.selfLink, super.name,
+ super.description, network, tags.build(), destRange, priority,
+ nextHopInstance, nextHopIp, nextHopNetwork, nextHopGateway,
+ warnings.build());
+ }
+
+ public Builder fromRoute(Route in) {
+ return super.fromResource(in)
+ .network(in.getNetwork())
+ .tags(in.getTags())
+ .destRange(in.getDestRange())
+ .priority(in.getPriority())
+ .nextHopInstance(in.getNextHopInstance().orNull())
+ .nextHopIp(in.getNextHopIp().orNull())
+ .nextHopNetwork(in.getNextHopNetwork().orNull())
+ .nextHopGateway(in.getNextHopGateway().orNull())
+ .warnings(in.getWarnings());
+ }
+ }
+
+ /**
+ * If potential misconfigurations are detected for this route, this field will be populated with warning messages.
+ */
+ public static class Warning {
+ private final String code;
+ private final Optional<String> message;
+ private final Map<String, String> data;
+
+ @ConstructorProperties({
+ "code", "message", "data"
+ })
+ public Warning(String code, String message, Map<String, String> data) {
+ this.code = checkNotNull(code, "code");
+ this.message = fromNullable(message);
+ this.data = data == null ? ImmutableMap.<String, String>of() : data;
+ }
+
+ /**
+ * @return The warning type identifier for this warning.
+ */
+ public String getCode() {
+ return code;
+ }
+
+ /**
+ * @return Optional human-readable details for this warning.
+ */
+ public Optional<String> getMessage() {
+ return message;
+ }
+
+ /**
+ * @return Metadata for this warning
+ */
+ public Map<String, String> getData() {
+ return data;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(code, message, data);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ Warning that = Warning.class.cast(obj);
+ return equal(this.code, that.code)
+ && equal(this.message, that.message)
+ && equal(this.data, that.data);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this)
+ .add("code", code)
+ .add("message", message)
+ .add("data", data);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromWarning(this);
+ }
+
+ public static final class Builder {
+ private String code;
+ private String message;
+ private ImmutableMap.Builder<String, String> data = ImmutableMap.builder();
+
+ /**
+ * @see Warning#getCode()
+ */
+ public Builder code(String code) {
+ this.code = code;
+ return this;
+ }
+
+ /**
+ * @see Warning#getMessage()
+ */
+ public Builder message(String message) {
+ this.message = message;
+ return this;
+ }
+
+ /**
+ * @see Warning#getData()
+ */
+ public Builder data(Map<String, String> data) {
+ this.data = new ImmutableMap.Builder<String, String>().putAll(data);
+ return this;
+ }
+
+ /**
+ * @see Warning#getData()
+ */
+ public Builder addData(String key, String value) {
+ this.data.put(checkNotNull(key, "key"), checkNotNull(value, "value of %s", key));
+ return this;
+ }
+
+ public Warning build() {
+ return new Warning(code, message, data.build());
+ }
+
+ public Builder fromWarning(Warning in) {
+ return this.code(in.getCode())
+ .message(in.getMessage().orNull())
+ .data(in.getData());
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/SlashEncodedIds.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/SlashEncodedIds.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/SlashEncodedIds.java
new file mode 100644
index 0000000..0080b29
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/SlashEncodedIds.java
@@ -0,0 +1,83 @@
+/*
+ * 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.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Splitter;
+import com.google.common.collect.Iterables;
+
+public class SlashEncodedIds {
+ public static SlashEncodedIds fromSlashEncoded(String id) {
+ Iterable<String> parts = Splitter.on('/').split(checkNotNull(id, "id"));
+ checkArgument(Iterables.size(parts) == 2, "id must be in format firstId/secondId");
+ return new SlashEncodedIds(Iterables.get(parts, 0), Iterables.get(parts, 1));
+ }
+
+ public static SlashEncodedIds fromTwoIds(String firstId, String secondId) {
+ return new SlashEncodedIds(firstId, secondId);
+ }
+
+ private static String slashEncodeTwoIds(String firstId, String secondId) {
+ return checkNotNull(firstId, "firstId") + "/" + checkNotNull(secondId, "secondId");
+ }
+
+ public String slashEncode() {
+ return slashEncodeTwoIds(firstId, secondId);
+ }
+
+ protected final String firstId;
+ protected final String secondId;
+
+ protected SlashEncodedIds(String firstId, String secondId) {
+ this.firstId = checkNotNull(firstId, "firstId");
+ this.secondId = checkNotNull(secondId, "secondId");
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(firstId, secondId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ SlashEncodedIds other = (SlashEncodedIds) obj;
+ return Objects.equal(firstId, other.firstId) && Objects.equal(secondId, other.secondId);
+ }
+
+ public String getFirstId() {
+ return firstId;
+ }
+
+ public String getSecondId() {
+ return secondId;
+ }
+
+ @Override
+ public String toString() {
+ return "[firstId=" + firstId + ", secondId=" + secondId + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Snapshot.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Snapshot.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Snapshot.java
new file mode 100644
index 0000000..69af275
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Snapshot.java
@@ -0,0 +1,135 @@
+/*
+ * 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.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;
+
+/**
+ * A Persistent Disk Snapshot resource.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/snapshots"/>
+ */
+@Beta
+public final class Snapshot extends AbstractDisk {
+
+ private final Optional<URI> sourceDisk;
+ private final String sourceDiskId;
+
+ @ConstructorProperties({
+ "id", "creationTimestamp", "selfLink", "name", "description", "diskSizeGb",
+ "status", "sourceDisk", "sourceDiskId"
+ })
+ private Snapshot(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ Integer sizeGb, String status, URI sourceDisk, String sourceDiskId) {
+ super(Kind.SNAPSHOT, id, creationTimestamp, selfLink, name, description, sizeGb, status);
+ this.sourceDisk = fromNullable(sourceDisk);
+ this.sourceDiskId = checkNotNull(sourceDiskId, "sourceDiskId of %s", name);
+ }
+
+ /**
+ * @return The source disk used to create this snapshot. Once the source disk
+ * has been deleted from the system, this field will be cleared, and will
+ * not be set even if a disk with the same name has been re-created (output only).
+ */
+ public Optional<URI> getSourceDisk() {
+ return sourceDisk;
+ }
+
+ /**
+ * @return The ID value of the disk used to create this snapshot. This value
+ * may be used to determine whether the snapshot was taken from the current
+ * or a previous instance of a given disk name.
+ */
+ public String getSourceDiskId() {
+ return sourceDiskId;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .omitNullValues()
+ .add("sourceDisk", sourceDisk.orNull())
+ .add("sourceDiskId", sourceDiskId);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromSnapshot(this);
+ }
+
+ public static final class Builder extends AbstractDisk.Builder<Builder> {
+
+ private URI sourceDisk;
+ private String sourceDiskId;
+
+ /**
+ * @see Snapshot#getSourceDisk()
+ */
+ public Builder sourceDisk(URI sourceDisk) {
+ this.sourceDisk = sourceDisk;
+ return this;
+ }
+
+ /**
+ * @see Snapshot#getSourceDiskId()
+ */
+ public Builder sourceDiskId(String sourceDiskId) {
+ this.sourceDiskId = sourceDiskId;
+ return this;
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+
+ public Snapshot build() {
+ return new Snapshot(super.id, super.creationTimestamp, super.selfLink, super.name,
+ super.description, super.sizeGb, super.status, sourceDisk, sourceDiskId);
+ }
+
+ public Builder fromSnapshot(Snapshot in) {
+ return super.fromAbstractDisk(in)
+ .sourceDisk(in.getSourceDisk().orNull())
+ .sourceDiskId(in.getSourceDiskId());
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Zone.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Zone.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Zone.java
new file mode 100644
index 0000000..232386c
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/Zone.java
@@ -0,0 +1,334 @@
+/*
+ * 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 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.collect.ImmutableSet;
+
+/**
+ * Represents a zone resource.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/zones"/>
+ */
+@Beta
+public final class Zone extends Resource {
+
+ public enum Status {
+ UP,
+ DOWN
+ }
+
+ private final Status status;
+ private final Set<MaintenanceWindow> maintenanceWindows;
+ private final Set<String> availableMachineTypes;
+
+ @ConstructorProperties({
+ "id", "creationTimestamp", "selfLink", "name", "description", "status", "maintenanceWindows",
+ "availableMachineTypes"
+ })
+ private Zone(String id, Date creationTimestamp, URI selfLink, String name, String description,
+ Status status, Set<MaintenanceWindow> maintenanceWindows, Set<String> availableMachineTypes) {
+ super(Kind.ZONE, id, creationTimestamp, selfLink, name, description);
+ this.status = checkNotNull(status, "status of %name", name);
+ this.maintenanceWindows = maintenanceWindows == null ? ImmutableSet.<MaintenanceWindow>of() : ImmutableSet
+ .copyOf(maintenanceWindows);
+ this.availableMachineTypes = availableMachineTypes == null ? ImmutableSet.<String>of() : ImmutableSet
+ .copyOf(availableMachineTypes);
+ }
+
+ /**
+ * @return Status of the zone. "UP" or "DOWN".
+ */
+ public Status getStatus() {
+ return status;
+ }
+
+ /**
+ * @return scheduled maintenance windows for the zone. When the zone is in a maintenance window,
+ * all resources which reside in the zone will be unavailable.
+ */
+ public Set<MaintenanceWindow> getMaintenanceWindows() {
+ return maintenanceWindows;
+ }
+
+ /**
+ * @return the machine types that can be used in this zone.
+ */
+ @Nullable
+ public Set<String> getAvailableMachineTypes() {
+ return availableMachineTypes;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return super.string()
+ .add("status", status)
+ .add("maintenanceWindows", maintenanceWindows)
+ .add("availableMachineTypes", availableMachineTypes);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return new Builder().fromZone(this);
+ }
+
+ public static final class Builder extends Resource.Builder<Builder> {
+
+ private Status status;
+ private ImmutableSet.Builder<MaintenanceWindow> maintenanceWindows = ImmutableSet.builder();
+ private ImmutableSet.Builder<String> availableMachineTypes = ImmutableSet.builder();
+
+ /**
+ * @see Zone#getStatus()
+ */
+ public Builder status(Status status) {
+ this.status = status;
+ return this;
+ }
+
+ /**
+ * @see Zone#getMaintenanceWindows()
+ */
+ public Builder addMaintenanceWindow(MaintenanceWindow maintenanceWindow) {
+ this.maintenanceWindows.add(checkNotNull(maintenanceWindow, "maintenanceWindow"));
+ return this;
+ }
+
+ /**
+ * @see Zone#getMaintenanceWindows()
+ */
+ public Builder maintenanceWindows(Set<MaintenanceWindow> maintenanceWindows) {
+ this.maintenanceWindows.addAll(checkNotNull(maintenanceWindows, "maintenanceWindows"));
+ return this;
+ }
+
+ /**
+ * @see Zone#getAvailableMachineTypes()
+ */
+ public Builder addAvailableMachineType(String availableMachineType) {
+ this.availableMachineTypes.add(checkNotNull(availableMachineType, "availableMachineType"));
+ return this;
+ }
+
+ /**
+ * @see Zone#getAvailableMachineTypes()
+ */
+ public Builder availableMachineTypes(Set<String> availableMachineTypes) {
+ this.availableMachineTypes.addAll(checkNotNull(availableMachineTypes, "availableMachineTypes"));
+ return this;
+ }
+
+ @Override
+ protected Builder self() {
+ return this;
+ }
+
+ public Zone build() {
+ return new Zone(super.id, super.creationTimestamp, super.selfLink, super.name,
+ super.description, status, maintenanceWindows.build(), availableMachineTypes.build());
+ }
+
+ public Builder fromZone(Zone in) {
+ return super.fromResource(in)
+ .status(in.getStatus())
+ .maintenanceWindows(in.getMaintenanceWindows())
+ .availableMachineTypes(in.getAvailableMachineTypes());
+ }
+ }
+
+ /**
+ * Scheduled maintenance windows for the zone. When the zone is in a maintenance window,
+ * all resources which reside in the zone will be unavailable.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/zones"/>
+ */
+ public static final class MaintenanceWindow {
+
+ private final String name;
+ private final Optional<String> description;
+ private final Date beginTime;
+ private final Date endTime;
+
+ @ConstructorProperties({
+ "name", "description", "beginTime", "endTime"
+ })
+ private MaintenanceWindow(String name, String description, Date beginTime, Date endTime) {
+ this.name = checkNotNull(name, "name");
+ this.description = fromNullable(description);
+ this.beginTime = checkNotNull(beginTime, "beginTime of %name", name);
+ this.endTime = checkNotNull(endTime, "endTime of %name", name);
+ }
+
+ /**
+ * @return name of the maintenance window.
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return textual description of the maintenance window.
+ */
+ public Optional<String> getDescription() {
+ return description;
+ }
+
+ /**
+ * @return begin time of the maintenance window.
+ */
+ public Date getBeginTime() {
+ return beginTime;
+ }
+
+ /**
+ * @return end time of the maintenance window.
+ */
+ public Date getEndTime() {
+ return endTime;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(name, description, beginTime, endTime);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ MaintenanceWindow that = MaintenanceWindow.class.cast(obj);
+ return equal(this.name, that.name)
+ && equal(this.beginTime, that.beginTime)
+ && equal(this.endTime, that.endTime);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Objects.ToStringHelper string() {
+ return toStringHelper(this)
+ .omitNullValues()
+ .add("name", name)
+ .add("description", description.orNull())
+ .add("beginTime", beginTime)
+ .add("endTime", endTime);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public Builder toBuilder() {
+ return builder().fromZoneMaintenanceWindow(this);
+ }
+
+ public static final class Builder {
+
+ private String name;
+ private String description;
+ private Date beginTime;
+ private Date endTime;
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Zone.MaintenanceWindow#getName()
+ */
+ public Builder name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Zone.MaintenanceWindow#getDescription()
+ */
+ public Builder description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Zone.MaintenanceWindow#getBeginTime()
+ */
+ public Builder beginTime(Date beginTime) {
+ this.beginTime = beginTime;
+ return this;
+ }
+
+ /**
+ * @see org.jclouds.googlecomputeengine.domain.Zone.MaintenanceWindow#getEndTime()
+ */
+ public Builder endTime(Date endTime) {
+ this.endTime = endTime;
+ return this;
+ }
+
+
+ public MaintenanceWindow build() {
+ return new MaintenanceWindow(name, description, beginTime, endTime);
+ }
+
+ public Builder fromZoneMaintenanceWindow(MaintenanceWindow in) {
+ return new Builder()
+ .name(in.getName())
+ .description(in.getDescription().orNull())
+ .beginTime(in.getBeginTime())
+ .endTime(in.getEndTime());
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/internal/NetworkAndAddressRange.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/internal/NetworkAndAddressRange.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/internal/NetworkAndAddressRange.java
new file mode 100644
index 0000000..66fbd66
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/domain/internal/NetworkAndAddressRange.java
@@ -0,0 +1,91 @@
+/*
+ * 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.internal;
+
+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 org.jclouds.javax.annotation.Nullable;
+
+import com.google.common.base.Objects;
+import com.google.common.base.Objects.ToStringHelper;
+import com.google.common.base.Optional;
+
+/**
+ * Container for network, IPv4 range and optional gateway, for creation caching
+ */
+public class NetworkAndAddressRange {
+ protected final String name;
+ protected final String ipV4Range;
+ protected final Optional<String> gateway;
+
+ @ConstructorProperties({
+ "name", "ipV4Range", "gateway"
+ })
+ public NetworkAndAddressRange(String name, String ipV4Range, @Nullable String gateway) {
+ this.name = checkNotNull(name, "name");
+ this.ipV4Range = checkNotNull(ipV4Range, "ipV4Range");
+ this.gateway = fromNullable(gateway);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getIpV4Range() {
+ return ipV4Range;
+ }
+
+ @Nullable
+ public Optional<String> getGateway() {
+ return gateway;
+ }
+
+ @Override
+ public int hashCode() {
+ // We only do hashcode/equals on name.
+ // the ip v4 range and gateway are included for creation rather than caching.
+ return Objects.hashCode(name);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj == null || getClass() != obj.getClass()) return false;
+ NetworkAndAddressRange that = NetworkAndAddressRange.class.cast(obj);
+ return equal(this.name, that.name);
+ }
+
+ protected ToStringHelper string() {
+ return toStringHelper(this)
+ .omitNullValues()
+ .add("name", name)
+ .add("ipV4Range", ipV4Range)
+ .add("gateway", gateway.orNull());
+ }
+
+ @Override
+ public String toString() {
+ return string().toString();
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/b45ae00e/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java
----------------------------------------------------------------------
diff --git a/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java
new file mode 100644
index 0000000..d363715
--- /dev/null
+++ b/dependencies/jclouds/apis/gce/1.8.1-stratos/src/main/java/org/jclouds/googlecomputeengine/features/AddressApi.java
@@ -0,0 +1,187 @@
+/*
+ * 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.features;
+
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
+import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404;
+import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.collect.PagedIterable;
+import org.jclouds.googlecomputeengine.domain.Address;
+import org.jclouds.googlecomputeengine.domain.ListPage;
+import org.jclouds.googlecomputeengine.domain.Operation;
+import org.jclouds.googlecomputeengine.functions.internal.ParseAddresses;
+import org.jclouds.googlecomputeengine.options.ListOptions;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.oauth.v2.config.OAuthScopes;
+import org.jclouds.oauth.v2.filters.OAuthAuthenticationFilter;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.MapBinder;
+import org.jclouds.rest.annotations.PayloadParam;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.ResponseParser;
+import org.jclouds.rest.annotations.SkipEncoding;
+import org.jclouds.rest.annotations.Transform;
+import org.jclouds.rest.binders.BindToJsonPayload;
+
+/**
+ * Provides access to Addresses via their REST API.
+ *
+ * @see <a href="https://developers.google.com/compute/docs/reference/v1/addresses"/>
+ */
+@SkipEncoding({'/', '='})
+@RequestFilters(OAuthAuthenticationFilter.class)
+public interface AddressApi {
+
+ /**
+ * Returns the specified address resource.
+ *
+ * @param region Name of the region the address is in.
+ * @param addressName name of the address resource to return.
+ * @return a Address resource.
+ */
+ @Named("Addresss:get")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/regions/{region}/addresses/{address}")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Address getInRegion(@PathParam("region") String region, @PathParam("address") String addressName);
+
+ /**
+ * Creates a address resource in the specified project specifying the size of the address.
+ *
+ *
+ * @param region the name of the region where the address is to be created.
+ * @param addressName the name of address.
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Addresss:insert")
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @Path("/regions/{region}/addresses")
+ @OAuthScopes({COMPUTE_SCOPE})
+ @MapBinder(BindToJsonPayload.class)
+ Operation createInRegion(@PathParam("region") String region, @PayloadParam("name") String addressName);
+
+ /**
+ * Deletes the specified address resource.
+ *
+ * @param region the region the address is in.
+ * @param addressName name of the address resource to delete.
+ * @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
+ * you, and look for the status field.
+ */
+ @Named("Addresss:delete")
+ @DELETE
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/regions/{region}/addresses/{address}")
+ @OAuthScopes(COMPUTE_SCOPE)
+ @Fallback(NullOnNotFoundOr404.class)
+ @Nullable
+ Operation deleteInRegion(@PathParam("region") String region, @PathParam("address") String addressName);
+
+ /**
+ * @see org.jclouds.googlecomputeengine.features.AddressApi#listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Addresss:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/regions/{region}/addresses")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseAddresses.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Address> listFirstPageInRegion(@PathParam("region") String region);
+
+ /**
+ * @see org.jclouds.googlecomputeengine.features.AddressApi#listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Addresss:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/regions/{region}/addresses")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseAddresses.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Address> listAtMarkerInRegion(@PathParam("region") String region, @QueryParam("pageToken") @Nullable String marker);
+
+ /**
+ * Retrieves the listPage of address resources contained within the specified project and region.
+ * By default the listPage as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has
+ * not been set.
+ *
+ * @param region the region to search in
+ * @param marker marks the beginning of the next list page
+ * @param listOptions listing options
+ * @return a page of the listPage
+ * @see org.jclouds.googlecomputeengine.options.ListOptions
+ * @see org.jclouds.googlecomputeengine.domain.ListPage
+ */
+ @Named("Addresss:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/regions/{region}/addresses")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseAddresses.class)
+ @Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
+ ListPage<Address> listAtMarkerInRegion(@PathParam("region") String region, @QueryParam("pageToken") @Nullable String marker, ListOptions listOptions);
+
+ /**
+ * A paged version of AddressApi#listPageInRegion(String)
+ *
+ * @param region the region to list in
+ * @return a Paged, Fluent Iterable that is able to fetch additional pages when required
+ * @see org.jclouds.collect.PagedIterable
+ * @see org.jclouds.googlecomputeengine.features.AddressApi#listAtMarkerInRegion(String, String, org.jclouds.googlecomputeengine.options.ListOptions)
+ */
+ @Named("Addresss:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/regions/{region}/addresses")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseAddresses.class)
+ @Transform(ParseAddresses.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Address> listInRegion(@PathParam("region") String region);
+
+ @Named("Addresss:list")
+ @GET
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Path("/regions/{region}/addresses")
+ @OAuthScopes(COMPUTE_READONLY_SCOPE)
+ @ResponseParser(ParseAddresses.class)
+ @Transform(ParseAddresses.ToPagedIterable.class)
+ @Fallback(EmptyPagedIterableOnNotFoundOr404.class)
+ PagedIterable<Address> listInRegion(@PathParam("region") String region, ListOptions options);
+
+}