You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2014/11/20 02:39:41 UTC
[12/12] jclouds-labs-google git commit: l7 Cont: Removed ResourceView,
Converted to AutoValue and updated.
l7 Cont: Removed ResourceView, Converted to AutoValue and updated.
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/commit/d147afdc
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/tree/d147afdc
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/diff/d147afdc
Branch: refs/heads/master
Commit: d147afdc83d31b11446be3d178f9e2b17118d5a2
Parents: 844f369
Author: Daniel Broudy <br...@google.com>
Authored: Wed Nov 12 17:07:53 2014 -0800
Committer: Adrian Cole <ac...@twitter.com>
Committed: Wed Nov 19 17:38:16 2014 -0800
----------------------------------------------------------------------
.../GoogleComputeEngineApi.java | 21 +
.../ResourceViewEndpoint.java | 36 -
.../GoogleComputeEngineHttpApiModule.java | 13 +-
.../domain/BackendService.java | 509 ++---------
.../domain/BackendServiceGroupHealth.java | 240 +-----
.../domain/ForwardingRule.java | 12 +-
.../googlecomputeengine/domain/Resource.java | 292 -------
.../domain/ResourceView.java | 267 ------
.../domain/TargetHttpProxy.java | 115 +--
.../googlecomputeengine/domain/UrlMap.java | 838 ++-----------------
.../domain/UrlMapValidateResult.java | 343 +-------
.../features/BackendServiceApi.java | 172 ++--
.../features/ForwardingRuleApi.java | 2 +
.../features/ResourceViewApi.java | 614 --------------
.../features/TargetHttpProxyApi.java | 122 +--
.../googlecomputeengine/features/UrlMapApi.java | 164 ++--
.../BaseWithRegionAndNameToPagedIterable.java | 83 --
.../BaseWithZoneAndNameToPagedIterable.java | 83 --
.../internal/ParseBackendServices.java | 63 --
.../ParseRegionResourceViewMembers.java | 69 --
.../internal/ParseRegionResourceViews.java | 67 --
.../internal/ParseTargetHttpProxies.java | 63 --
.../functions/internal/ParseUrlMaps.java | 63 --
.../internal/ParseZoneResourceViewMembers.java | 70 --
.../internal/ParseZoneResourceViews.java | 67 --
.../handlers/PayloadBinder.java | 56 --
.../options/BackendServiceOptions.java | 158 ++--
.../options/ForwardingRuleOptions.java | 176 ----
.../options/ResourceOptions.java | 69 --
.../options/ResourceViewOptions.java | 149 ----
.../options/TargetHttpProxyOptions.java | 82 +-
.../options/UrlMapOptions.java | 201 ++---
.../features/BackendServiceApiExpectTest.java | 90 +-
.../features/BackendServiceApiLiveTest.java | 98 +--
.../features/ForwardingRuleApiLiveTest.java | 128 ---
.../GlobalForwardingRuleApiExpectTest.java | 177 ++++
.../GlobalForwardingRuleApiLiveTest.java | 138 +++
.../features/ResourceViewApiExpectTest.java | 338 --------
.../features/ResourceViewApiLiveTest.java | 190 -----
.../features/TargetHttpProxyApiExpectTest.java | 59 +-
.../features/TargetHttpProxyApiLiveTest.java | 95 +--
.../features/UrlMapApiExpectTest.java | 102 ++-
.../features/UrlMapApiLiveTest.java | 185 ++--
.../BaseGoogleComputeEngineApiLiveTest.java | 33 +-
.../parse/ParseBackendServiceGetHealthTest.java | 23 +-
.../parse/ParseBackendServiceListTest.java | 48 +-
.../parse/ParseBackendServiceTest.java | 43 +-
.../parse/ParseForwardingRuleTest.java | 2 +
.../ParseGlobalForwardingRuleListTest.java | 25 +-
.../parse/ParseGlobalForwardingRuleTest.java | 23 +-
.../parse/ParseResourceViewListRegionTest.java | 64 --
.../parse/ParseResourceViewListZoneTest.java | 64 --
.../parse/ParseResourceViewRegionTest.java | 50 --
.../ParseResourceViewResourceListTest.java | 51 --
.../parse/ParseResourceViewZoneTest.java | 50 --
.../parse/ParseTargetHttpProxyListTest.java | 35 +-
.../parse/ParseTargetHttpProxyTest.java | 13 +-
.../parse/ParseUrlMapListTest.java | 37 +-
.../parse/ParseUrlMapTest.java | 53 +-
.../parse/ParseUrlMapValidateTest.java | 26 +-
.../resources/backend_service_get_health.json | 1 +
.../resources/resource_view_get_region.json | 9 -
.../test/resources/resource_view_get_zone.json | 9 -
.../test/resources/resource_view_insert.json | 1 -
.../resources/resource_view_list_region.json | 25 -
.../test/resources/resource_view_list_zone.json | 25 -
.../resources/resource_view_resources_list.json | 6 -
.../googlecloud/internal/AdvancingIterator.java | 2 -
68 files changed, 1332 insertions(+), 6265 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApi.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApi.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApi.java
index 95991c5..8a6e36c 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApi.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/GoogleComputeEngineApi.java
@@ -24,6 +24,7 @@ import javax.ws.rs.PathParam;
import org.jclouds.googlecloud.config.CurrentProject;
import org.jclouds.googlecomputeengine.features.AddressApi;
import org.jclouds.googlecomputeengine.features.AggregatedListApi;
+import org.jclouds.googlecomputeengine.features.BackendServiceApi;
import org.jclouds.googlecomputeengine.features.DiskApi;
import org.jclouds.googlecomputeengine.features.DiskTypeApi;
import org.jclouds.googlecomputeengine.features.FirewallApi;
@@ -58,6 +59,11 @@ public interface GoogleComputeEngineApi extends Closeable {
@Delegate
@Endpoint(CurrentProject.class)
+ @Path("/global/backendServices")
+ BackendServiceApi backendServices();
+
+ @Delegate
+ @Endpoint(CurrentProject.class)
@Path("/zones/{zone}")
DiskApi disksInZone(@PathParam("zone") String zone);
@@ -79,6 +85,11 @@ public interface GoogleComputeEngineApi extends Closeable {
@Delegate
@Endpoint(CurrentProject.class)
@Path("/global")
+ ForwardingRuleApi globalForwardingRules();
+
+ @Delegate
+ @Endpoint(CurrentProject.class)
+ @Path("/global")
HttpHealthCheckApi httpHeathChecks();
@Delegate
@@ -122,10 +133,20 @@ public interface GoogleComputeEngineApi extends Closeable {
@Delegate
@Endpoint(CurrentProject.class)
+ TargetHttpProxyApi targetHttpProxies();
+
+ @Delegate
+ @Endpoint(CurrentProject.class)
@Path("/regions/{region}")
TargetPoolApi targetPoolsInRegion(@PathParam("region") String region);
@Delegate
@Endpoint(CurrentProject.class)
ZoneApi zones();
+
+ @Delegate
+ @Endpoint(CurrentProject.class)
+ @Path("/global/urlMaps")
+ UrlMapApi urlMaps();
+
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/ResourceViewEndpoint.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/ResourceViewEndpoint.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/ResourceViewEndpoint.java
deleted file mode 100644
index 92b5ee6..0000000
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/ResourceViewEndpoint.java
+++ /dev/null
@@ -1,36 +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;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import javax.inject.Qualifier;
-
-/**
- * Interface designed to override the default endpoint for google-compute-engine
- * so that ResourceViewApi calls go to the correct endpoint (URL).
- *
- * @see org.jclouds.googlecomputeengine.config.GoogleComputeEngineHttpAipModule#provideResourceViewUrl()
- * for actual implementation.
- */
-@Retention(value = RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD })
-@Qualifier
-public @interface ResourceViewEndpoint {}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineHttpApiModule.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineHttpApiModule.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineHttpApiModule.java
index bb57d36..2a813d1 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineHttpApiModule.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineHttpApiModule.java
@@ -91,6 +91,7 @@ public final class GoogleComputeEngineHttpApiModule extends HttpApiModule<Google
}
}, defaultEndpoint), seconds, SECONDS);
}
+
// If the project name wasn't explicitly supplied, then we lookup via api.
// This supplier must be defensive against any auth exception.
return MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier
@@ -139,16 +140,4 @@ public final class GoogleComputeEngineHttpApiModule extends HttpApiModule<Google
return URI.create(defaultEndpoint.get() + "/projects/" + api.get(projectNumber).name());
}
}
-
- @Provides
- @Singleton
- @ResourceViewEndpoint
- public Supplier<URI> provideResourceViewUrl() {
- return new Supplier<URI>() {
- @Override
- public URI get() {
- return URI.create("https://www.googleapis.com/resourceviews/v1beta1");
- }
- };
- }
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/BackendService.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/BackendService.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/BackendService.java
index 67f11fd..8b90a4f 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/BackendService.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/BackendService.java
@@ -16,470 +16,87 @@
*/
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 java.util.List;
import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
-import com.google.common.base.Objects;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableSet;
-
-/**
- * A backend service resource.
- *
- * @see <a href="https://developers.google.com/compute/docs/reference/latest/backendServices"/>
- * @see <a href="https://developers.google.com/compute/docs/load-balancing/http/backend-service"/>
- */
-public final class BackendService extends Resource {
-
- private final Set<Backend> backends;
- private final Set<URI> healthChecks;
- private final Optional<Integer> timeoutSec;
- private final Optional<Integer> port;
- private final Optional<String> protocol;
- private final Optional<String> fingerprint;
-
- @ConstructorProperties({
- "id", "creationTimestamp", "selfLink", "name", "description",
- "backends", "healthChecks", "timeoutSec", "port", "protocol",
- "fingerprint"
- })
- private BackendService(String id, Date creationTimestamp, URI selfLink,
- String name, @Nullable String description,
- @Nullable Set<Backend> backends, Set<URI> healthChecks,
- @Nullable Integer timeoutSec, @Nullable Integer port,
- @Nullable String protocol,
- @Nullable String fingerprint) {
- super(Kind.BACKEND_SERVICE, id, creationTimestamp, selfLink, name,
- description);
- this.healthChecks = checkNotNull(healthChecks);
- this.backends = backends == null ? ImmutableSet.<Backend>of() : backends;
- this.timeoutSec = fromNullable(timeoutSec);
- this.port = fromNullable(port);
- this.protocol = fromNullable(protocol);
- this.fingerprint = fromNullable(fingerprint);
- }
-
- /**
- * @return a list of backends this service uses.
- */
- public Set<Backend> getBackends() {
- return backends;
- }
-
- /**
- * @return a list of healthChecks this service uses.
- */
- public Set<URI> getHealthChecks() {
- return healthChecks;
- }
-
- /**
- * @return the time to wait for a backend before considering it a failed request.
- */
- public Optional<Integer> getTimeoutSec() {
- return timeoutSec;
- }
-
- /**
- * @return the port to connect to on the backend.
- */
- public Optional<Integer> getPort() {
- return port;
- }
+import com.google.auto.value.AutoValue;
- /**
- * @return the protocol.
- */
- public Optional<String> getProtocol() {
- return protocol;
- }
+@AutoValue
+public abstract class BackendService {
- /**
- * @return the fingerprint used for updating or patching this resource.
- */
- public Optional<String> getFingerprint() {
- return fingerprint;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return Objects.hashCode(kind, name, backends, healthChecks, timeoutSec,
- port, protocol);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null || getClass() != obj.getClass()) return false;
- BackendService that = BackendService.class.cast(obj);
- return equal(this.kind, that.kind)
- && equal(this.name, that.name)
- && equal(this.backends, that.backends)
- && equal(this.healthChecks, that.healthChecks)
- && equal(this.timeoutSec, that.timeoutSec)
- && equal(this.port, that.port)
- && equal(this.protocol, that.protocol);
- }
-
- /**
- * {@inheritDoc}
- */
- protected Objects.ToStringHelper string() {
- return super.string()
- .omitNullValues()
- .add("backends", backends)
- .add("healthChecks", healthChecks)
- .add("timeoutSec", timeoutSec.orNull())
- .add("port", port.orNull())
- .add("protocol", protocol.orNull())
- .add("fingerprint", fingerprint.orNull());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public Builder toBuilder() {
- return new Builder().fromBackendService(this);
- }
-
- public static final class Builder extends Resource.Builder<Builder> {
-
- private ImmutableSet.Builder<Backend> backends = ImmutableSet.builder();
- private ImmutableSet.Builder<URI> healthChecks = ImmutableSet.builder();
- private Integer timeoutSec;
- private Integer port;
- private String protocol;
- private String fingerprint;
-
- /**
- * @see BackendService#getBackends()
- */
- public Builder backends(Set<Backend> backends) {
- this.backends = ImmutableSet.<Backend>builder();
- this.backends.addAll(backends);
- return this;
- }
-
- /**
- * @see BackendService#getBackends()
- */
- public Builder addBackend(Backend backend) {
- this.backends.add(checkNotNull(backend, "backend"));
- return this;
- }
-
- /**
- * @see BackendService#getHealthChecks()
- */
- public Builder healthChecks(Set<URI> healthChecks) {
- this.healthChecks = ImmutableSet.<URI>builder();
- this.healthChecks.addAll(healthChecks);
- return this;
- }
-
- /**
- * @see BackendService#getHealthChecks()
- */
- public Builder addHealthCheck(URI healthCheck) {
- this.healthChecks.add(checkNotNull(healthCheck, "healthCheck"));
- return this;
- }
-
- /**
- * @see BackendService#getTimeoutSec()
- */
- public Builder timeoutSec(Integer timeoutSec) {
- this.timeoutSec = timeoutSec;
- return this;
- }
-
- /**
- * @see BackendService#getPort()
- */
- public Builder port(Integer port) {
- this.port = port;
- return this;
- }
-
- /**
- * @see BackendService#getProtocol()
- */
- public Builder protocol(String protocol) {
- this.protocol = protocol;
- return this;
- }
-
- /**
- * @see BackendService#getFingerprint()
- */
- public Builder fingerprint(String fingerprint) {
- this.fingerprint = fingerprint;
- return this;
- }
-
- @Override
- protected Builder self() {
- return this;
+ @AutoValue
+ public abstract static class Backend {
+ public enum BalancingModes{
+ RATE,
+ UTILIZATION;
}
- public BackendService build() {
- return new BackendService(super.id, super.creationTimestamp, super.selfLink, super.name,
- super.description, backends.build(), healthChecks.build(),
- timeoutSec, port, protocol, fingerprint);
- }
+ @Nullable public abstract String description();
+ public abstract URI group();
+ @Nullable public abstract BalancingModes balancingMode();
+ @Nullable public abstract Float maxUtilization();
+ @Nullable public abstract Integer maxRate();
+ @Nullable public abstract Float maxRatePerInstance();
+ @Nullable public abstract Float capacityScaler();
- public Builder fromBackendService(BackendService in) {
- return super.fromResource(in)
- .backends(in.getBackends())
- .healthChecks(in.getHealthChecks())
- .timeoutSec(in.getTimeoutSec().orNull())
- .port(in.getPort().orNull())
- .protocol(in.getProtocol().orNull())
- .fingerprint(in.getFingerprint().orNull());
- }
-
- }
-
- public static final class Backend {
-
- private final Optional<String> description;
- private final URI group;
- private final Optional<String> balancingMode;
- private final Optional<Float> maxUtilization;
- private final Optional<Integer> maxRate;
- private final Optional<Float> maxRatePerInstance;
- private final Optional<Float> capacityScaler;
-
- @ConstructorProperties({
- "description", "group", "balancingMode", "maxUtilization", "maxRate",
- "maxRatePerInstance", "capacityScaler"
- })
- private Backend(@Nullable String description, URI group,
- @Nullable String balancingMode,
- @Nullable Float maxUtilization, @Nullable Integer maxRate,
- @Nullable Float maxRatePerInstance,
- @Nullable Float capacityScaler) {
- this.description = fromNullable(description);
- this.group = checkNotNull(group, "group");
- this.balancingMode = fromNullable(balancingMode);
- this.maxUtilization = fromNullable(maxUtilization);
- this.maxRate = fromNullable(maxRate);
- this.maxRatePerInstance = fromNullable(maxRatePerInstance);
- this.capacityScaler = fromNullable(capacityScaler);
- }
-
- /**
- * @return the description.
- */
- public Optional<String> getDescription() {
- return description;
- }
- /**
- * @return URI of the resource view this backend represents.
- */
- public URI getGroup() {
- return group;
+ @SerializedNames({ "description", "group", "balancingMode", "maxUtilization", "maxRate",
+ "maxRatePerInstance", "capacityScaler" })
+ public static Backend create(String description,
+ URI group,
+ BalancingModes balancingMode,
+ Float maxUtilization,
+ Integer maxRate,
+ Float maxRatePerInstance,
+ Float capacityScaler) {
+ return new AutoValue_BackendService_Backend(description, group, balancingMode, maxUtilization, maxRate,
+ maxRatePerInstance, capacityScaler);
}
- /**
- * @return the balancingMode of this backend.
- */
- public Optional<String> getBalancingMode() {
- return balancingMode;
+ public static Backend create(URI group){
+ return create(null, group, null, null, null, null, null);
}
- /**
- * @return the CPU utilization target for the group when the balancing
- * mode is UTILIZATION.
- */
- public Optional<Float> getMaxUtilization() {
- return maxUtilization;
- }
-
- /**
- * @return the max RPS of the group.
- */
- public Optional<Integer> getMaxRate() {
- return maxRate;
- }
-
- /**
- * @return the max RPS per instance in the group.
- */
- public Optional<Float> getMaxRatePerInstance() {
- return maxRatePerInstance;
- }
-
- /**
- * @return the multiplier of the max capacity the group should serve up
- * to.
- */
- public Optional<Float> getCapacityScaler() {
- return capacityScaler;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return Objects.hashCode(group, balancingMode, maxUtilization, maxRate,
- maxRatePerInstance, capacityScaler);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null || getClass() != obj.getClass()) return false;
- Backend that = Backend.class.cast(obj);
- return equal(this.group, that.group)
- && equal(this.balancingMode, that.balancingMode)
- && equal(this.maxUtilization, that.maxUtilization)
- && equal(this.maxRate, that.maxRate)
- && equal(this.maxRatePerInstance, that.maxRatePerInstance)
- && equal(this.capacityScaler, that.capacityScaler);
- }
-
- /**
- * {@inheritDoc}
- */
- public Objects.ToStringHelper string() {
- return toStringHelper(this)
- .omitNullValues()
- .add("description", description.orNull())
- .add("group", group)
- .add("balancingMode", balancingMode.orNull())
- .add("maxUtilization", maxUtilization.orNull())
- .add("maxRate", maxRate.orNull())
- .add("maxRatePerInstance", maxRatePerInstance.orNull())
- .add("capacityScaler", capacityScaler.orNull());
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return string().toString();
+ Backend(){
}
+ }
- public static Builder builder() {
- return new Builder();
- }
+ public abstract String id();
+ public abstract Date creationTimestamp();
+ public abstract URI selfLink();
+ public abstract String name();
+ @Nullable public abstract String description();
+ @Nullable public abstract List<Backend> backends();
+ @Nullable public abstract List<URI> healthChecks();
+ @Nullable public abstract int timeoutSec();
+ @Nullable public abstract int port();
+ @Nullable public abstract String protocol();
+ @Nullable public abstract String fingerprint();
- public Builder toBuilder() {
- return builder().fromBackendServicesBackend(this);
- }
+ /**
+ * @param timeoutSec Defaults to 30 when null.
+ * @param port Defaults to 80 when null.
+ */
+ @SerializedNames({ "id", "creationTimestamp", "selfLink", "name", "description",
+ "backends", "healthChecks", "timeoutSec", "port", "protocol",
+ "fingerprint"})
+ public static BackendService create(String id, Date creationTimestamp, URI selfLink,
+ String name, @Nullable String description,
+ @Nullable List<Backend> backends, List<URI> healthChecks,
+ @Nullable Integer timeoutSec, @Nullable Integer port,
+ @Nullable String protocol,
+ @Nullable String fingerprint){
+ return new AutoValue_BackendService(id, creationTimestamp, selfLink, name, description,
+ backends, healthChecks,
+ timeoutSec != null ? timeoutSec : 30,
+ port != null ? port : 80,
+ protocol, fingerprint);
+ }
- public static final class Builder {
-
- String description;
- URI group;
- String balancingMode;
- Float maxUtilization;
- Integer maxRate;
- Float maxRatePerInstance;
- Float capacityScaler;
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.BackendService.Backend#getDescription()
- */
- public Builder description(String description) {
- this.description = description;
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.BackendService.Backend#getGroup()
- */
- public Builder group(URI group) {
- this.group = group;
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.BackendService.Backend#getBalancingMode()
- */
- public Builder balancingMode(String balancingMode) {
- this.balancingMode = balancingMode;
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.BackendService.Backend#getMaxUtilization()
- */
- public Builder maxUtilization(Float maxUtilization) {
- this.maxUtilization = maxUtilization;
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.BackendService.Backend#getMaxRate()
- */
- public Builder maxRate(Integer maxRate) {
- this.maxRate = maxRate;
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.BackendService.Backend#getMaxRatePerInstance()
- */
- public Builder maxRatePerInstance(Float maxRatePerInstance) {
- this.maxRatePerInstance = maxRatePerInstance;
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.BackendService.Backend#getCapacityScaler()
- */
- public Builder capacityScaler(Float capacityScaler) {
- this.capacityScaler = capacityScaler;
- return this;
- }
-
- public Backend build() {
- return new Backend(description, group, balancingMode,
- maxUtilization, maxRate, maxRatePerInstance,
- capacityScaler);
- }
-
- public Builder fromBackendServicesBackend(Backend in) {
- return new Builder().description(in.getDescription().orNull())
- .group(in.getGroup())
- .balancingMode(in.getBalancingMode().orNull())
- .maxUtilization(in.getMaxUtilization().orNull())
- .maxRate(in.getMaxRate().orNull())
- .maxRatePerInstance(in.getMaxRatePerInstance().orNull())
- .capacityScaler(in.getCapacityScaler().orNull());
- }
- }
+ BackendService(){
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/BackendServiceGroupHealth.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/BackendServiceGroupHealth.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/BackendServiceGroupHealth.java
index bdb2db2..c31f64c 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/BackendServiceGroupHealth.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/BackendServiceGroupHealth.java
@@ -16,237 +16,41 @@
*/
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.Set;
+import java.util.List;
-import org.jclouds.googlecomputeengine.domain.Resource.Kind;
import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
-import com.google.common.base.Objects;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableSet;
+import com.google.auto.value.AutoValue;
-/**
- * Represents the health of a backend service group.
- *
- * @see <a href="https://developers.google.com/compute/docs/reference/latest/backendServices/getHealth"/>
- */
-public class BackendServiceGroupHealth {
-
- protected final Kind kind;
- protected final Set<HealthStatus> healthStatuses;
-
- @ConstructorProperties({
- "healthStatus"
- })
- private BackendServiceGroupHealth(Set<HealthStatus> healthStatuses) {
- this.kind = Kind.BACKEND_SERVICE_GROUP_HEALTH;
- this.healthStatuses = healthStatuses == null ? ImmutableSet.<HealthStatus>of() : healthStatuses;
- }
-
- /**
- * @return the Type of the resource.
- */
- public Kind getKind() {
- return kind;
- }
-
- /**
- * @return a Set of HealthStatus objects denoting the health of instances.
- */
- public Set<HealthStatus> getHealthStatuses() {
- return healthStatuses;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return Objects.hashCode(kind, healthStatuses);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null || getClass() != obj.getClass()) return false;
- BackendServiceGroupHealth that = BackendServiceGroupHealth.class.cast(obj);
- return equal(this.kind, that.kind)
- && equal(this.healthStatuses, that.healthStatuses);
- }
-
- /**
- * {@inheritDoc}
- */
- public Objects.ToStringHelper string() {
- return toStringHelper(this).omitNullValues()
- .add("healthStatuses", healthStatuses);
- }
+@AutoValue
+public abstract class BackendServiceGroupHealth {
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
+ public abstract List<HealthStatus> healthStatus();
+
+ @SerializedNames({"healthStatus"})
+ public static BackendServiceGroupHealth create(List<HealthStatus> healthStatus){
+ return new AutoValue_BackendServiceGroupHealth(healthStatus);
}
-
- public static final class Builder {
-
- ImmutableSet.Builder<HealthStatus> healthStatuses = ImmutableSet.builder();
-
- /**
- * @see BackendServiceGroupHealth#getHealthStatus()
- */
- public Builder addHealthStatus(HealthStatus healthStatus) {
- this.healthStatuses.add(checkNotNull(healthStatus, "healthStatus"));
- return this;
- }
-
- /**
- * @see BackendServiceGroupHealth#getHealthStatus()
- */
- public Builder healthStatuses(Set<HealthStatus> healthStatuses) {
- this.healthStatuses = ImmutableSet.builder();
- this.healthStatuses.addAll(healthStatuses);
- return this;
- }
-
- public BackendServiceGroupHealth build() {
- return new BackendServiceGroupHealth(healthStatuses.build());
- }
+
+ BackendServiceGroupHealth(){
}
-
- /**
- * Represents the health status of a particular instance.
- *
- */
- public static final class HealthStatus {
-
- private Optional<String> ipAddress;
- private URI instance;
- private String healthState;
-
- @ConstructorProperties({
- "ipAddress", "instance", "healthState"
- })
- private HealthStatus(@Nullable String ipAddress, URI instance,
- String healthState) {
- this.ipAddress = fromNullable(ipAddress);
- this.instance = instance;
- this.healthState = healthState;
- }
- /**
- * @return the IP address of the instance.
- */
- public Optional<String> getIpAddress() {
- return ipAddress;
- }
+ @AutoValue
+ public abstract static class HealthStatus {
- /**
- * @return the URL of the instance.
- */
- public URI getInstance() {
- return instance;
- }
+ @Nullable public abstract String ipAddress();
+ public abstract Integer port();
+ public abstract URI instance();
+ public abstract String healthState();
- /**
- * @return the health state of the instance.
- */
- public String getHealthState() {
- return healthState;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return Objects.hashCode(ipAddress, instance, healthState);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null || getClass() != obj.getClass()) return false;
- HealthStatus that = HealthStatus.class.cast(obj);
- return equal(this.ipAddress, that.ipAddress)
- && equal(this.instance, that.instance)
- && equal(this.healthState, that.healthState);
- }
-
- /**
- * {@inheritDoc}
- */
- public Objects.ToStringHelper string() {
- return toStringHelper(this).omitNullValues()
- .add("ipAddress", ipAddress.orNull())
- .add("instance", instance)
- .add("healthState", healthState);
+ @SerializedNames({"ipAddress", "port", "instance", "healthState"})
+ public static HealthStatus create(String ipAddress, int port, URI instance, String healthState) {
+ return new AutoValue_BackendServiceGroupHealth_HealthStatus(ipAddress, port, instance, healthState);
}
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return string().toString();
- }
-
- public static Builder builder() {
- return new Builder();
- }
-
- public static final class Builder {
-
- private String healthState;
- private String ipAddress;
- private URI instance;
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.BackendServiceGroupHealth.HealthStatus#getHealthState()
- */
- public Builder healthState(String healthState) {
- this.healthState = healthState;
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.BackendServiceGroupHealth.HealthStatus#getIpAddress()
- */
- public Builder ipAddress(String ipAddress) {
- this.ipAddress = ipAddress;
- return this;
- }
-
- /**
- * @see org.jclouds.googlecomputeengine.domain.BackendServiceGroupHealth.HealthStatus#getInstance()
- */
- public Builder instance(URI instance) {
- this.instance = instance;
- return this;
- }
-
- public HealthStatus build() {
- return new HealthStatus(ipAddress, instance, healthState);
- }
+ HealthStatus(){
}
}
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/ForwardingRule.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/ForwardingRule.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/ForwardingRule.java
index 4b4abb7..1e76658 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/ForwardingRule.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/ForwardingRule.java
@@ -17,6 +17,7 @@
package org.jclouds.googlecomputeengine.domain;
import java.net.URI;
+import java.util.Date;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
@@ -47,7 +48,10 @@ public abstract class ForwardingRule {
@Nullable public abstract String description();
- public abstract URI region();
+ public abstract Date creationTimestamp();
+
+ /** null when representing a GlobalForwardingRules */
+ @Nullable public abstract URI region();
/**
* The external IP address that this forwarding rule is serving on behalf of. If this is a reserved
@@ -71,10 +75,10 @@ public abstract class ForwardingRule {
public abstract URI target();
@SerializedNames(
- { "id", "selfLink", "name", "description", "region", "IPAddress", "IPProtocol", "portRange", "target" })
- public static ForwardingRule create(String id, URI selfLink, String name, String description, URI region,
+ { "id", "selfLink", "name", "description", "creationTimestamp", "region", "IPAddress", "IPProtocol", "portRange", "target" })
+ public static ForwardingRule create(String id, URI selfLink, String name, String description, Date creationTimestamp, URI region,
String ipAddress, IPProtocol ipProtocol, String portRange, URI target) {
- return new AutoValue_ForwardingRule(id, selfLink, name, description, region, ipAddress,
+ return new AutoValue_ForwardingRule(id, selfLink, name, description, creationTimestamp, region, ipAddress,
ipProtocol == null ? IPProtocol.TCP : ipProtocol, portRange, target);
}
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Resource.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Resource.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Resource.java
deleted file mode 100644
index 6584522..0000000
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/Resource.java
+++ /dev/null
@@ -1,292 +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.MoreObjects.ToStringHelper;
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Objects.equal;
-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,
- BACKEND_SERVICE,
- BACKEND_SERVICE_LIST,
- BACKEND_SERVICE_GROUP_HEALTH,
- DISK,
- DISK_LIST,
- FIREWALL,
- FIREWALL_LIST,
- FORWARDING_RULE,
- FORWARDING_RULE_LIST,
- IMAGE,
- IMAGE_LIST,
- OPERATION,
- OPERATION_LIST,
- INSTANCE,
- INSTANCE_LIST,
- MACHINE_TYPE,
- MACHINE_TYPE_LIST,
- PROJECT,
- NETWORK,
- NETWORK_LIST,
- REGION,
- REGION_LIST,
- RESOURCE_VIEW,
- RESOURCE_VIEW_LIST,
- RESOURCE_VIEW_MEMBER_LIST,
- ROUTE,
- ROUTE_LIST,
- SNAPSHOT,
- SNAPSHOT_LIST,
- TARGET_HTTP_PROXY,
- TARGET_HTTP_PROXY_LIST,
- URL_MAP,
- URL_MAP_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);
- }
-
- 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/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/ResourceView.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/ResourceView.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/ResourceView.java
deleted file mode 100644
index 36d831f..0000000
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/ResourceView.java
+++ /dev/null
@@ -1,267 +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.Optional.absent;
-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 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.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-
-/**
- * Represents a resource view resource.
- *
- * @see <a href="https://developers.google.com/compute/docs/reference/latest/urlMaps"/>
- * @see <a href="https://developers.google.com/compute/docs/load-balancing/http/url-map"/>
- */
-@Beta
-public final class ResourceView extends Resource {
-
- private final Optional<Integer> numMembers;
- private final Set<URI> members;
- private final Optional<Date> lastModified;
- private final Map<String, String> labels;
- private final Optional<String> region;
- private final Optional<String> zone;
-
- @ConstructorProperties({
- "id", "creationTime", "selfLink", "name", "description", "numMembers", "members",
- "lastModified", "labels"
- })
- protected ResourceView(String id, Date creationTimestamp, URI selfLink, String name,
- @Nullable String description, @Nullable Integer numMembers,
- @Nullable Set<URI> members, @Nullable Date lastModified,
- @Nullable Map<String, String> labels) {
- // TODO: (ashmrtnz) remove the '-1' that is passed as the id. Currently
- // resource views do not return an id and Resource requires one.
- super(Kind.RESOURCE_VIEW, "-1", creationTimestamp, selfLink, name, description);
- this.numMembers = fromNullable(numMembers);
- this.members = members == null ? ImmutableSet.<URI>of() : members;
- this.lastModified = fromNullable(lastModified);
- this.labels = labels == null ? ImmutableMap.<String, String>of() : labels;
-
- // This is not ideal, but it is the only way I can get region or zone.
- // TODO: change this when it is no longer beta because it is based on the
- // form of the self link
- String[] parts = this.selfLink.toString().split("/+");
- if (!parts[3].equals("v1beta1")) {
- throw new RuntimeException("Expected version v1beta1 but got version" + parts[3]);
- }
- if (parts[6].equals("zones")) {
- this.zone = Optional.<String>of(parts[7]);
- this.region = absent();
- } else if (parts[6].equals("regions")) {
- this.zone = absent();
- this.region = Optional.<String>of(parts[7]);
- } else {
- throw new RuntimeException("Could not find zone or region");
- }
-
- }
-
- /**
- * @return the number of resources in this resource view.
- */
- public Optional<Integer> getNumMembers() {
- return numMembers;
- }
-
-
- /**
- * @return a Set of URIs of the resources in this resource view.
- */
- public Set<URI> getMembers() {
- return members;
- }
-
-
- /**
- * @return the date this resource view was last modified.
- */
- public Optional<Date> getLastModified() {
- return lastModified;
- }
-
-
- /**
- * @return the labels for this resource view.
- */
- public Map<String, String> getLabels() {
- return labels;
- }
-
- /**
- * @return the region of this resource view.
- */
- public Optional<String> getRegion() {
- return region;
- }
-
- /**
- * @return the zone of this resource view.
- */
- public Optional<String> getZone() {
- return zone;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return Objects.hashCode(kind, name, numMembers, members, lastModified,
- labels, zone, region);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null || getClass() != obj.getClass()) return false;
- ResourceView that = ResourceView.class.cast(obj);
- return equal(this.kind, that.kind)
- && equal(this.name, that.name)
- && equal(this.numMembers, that.numMembers)
- && equal(this.members, that.members)
- && equal(this.lastModified, that.lastModified)
- && equal(this.labels, that.labels)
- && equal(this.zone, that.zone)
- && equal(this.region, that.region);
- }
-
- /**
- * {@inheritDoc}
- */
- protected Objects.ToStringHelper string() {
- return super.string()
- .omitNullValues()
- .add("numMembers", numMembers.orNull())
- .add("memebers", members)
- .add("lastModified", lastModified.orNull())
- .add("labels", labels)
- .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().fromResourceView(this);
- }
-
- public static final class Builder extends Resource.Builder<Builder> {
-
- private Integer numMembers;
- private ImmutableSet.Builder<URI> members = ImmutableSet.<URI>builder();
- private Date lastModified;
- private ImmutableMap.Builder<String, String> labels = ImmutableMap.<String, String>builder();
-
- /**
- * @see ResourceView#getNumMembers()
- */
- public Builder numMembers(Integer numMembers) {
- this.numMembers = numMembers;
- return this;
- }
-
- /**
- * @see ResourceView#getMembers()
- */
- public Builder addMember(URI member) {
- this.members.add(checkNotNull(member));
- return this;
- }
-
- /**
- * @see ResourceView#getMembers()
- */
- public Builder members(Set<URI> members) {
- this.members = ImmutableSet.<URI>builder();
- this.members.addAll(members);
- return this;
- }
-
- /**
- * @see ResourceView#getLastModified()
- */
- public Builder lastModified(Date lastModified) {
- this.lastModified = lastModified;
- return this;
- }
-
- /**
- * @see ResourceView#getLabels()
- */
- public Builder addLabel(String key, String value) {
- labels.put(checkNotNull(key), checkNotNull(value));
- return this;
- }
-
- /**
- * @see ResourceView#getLabels()
- */
- public Builder labels(Map<String, String> labels) {
- this.labels = ImmutableMap.<String, String>builder();
- this.labels.putAll(labels);
- return this;
- }
-
- @Override
- protected Builder self() {
- return this;
- }
-
- public ResourceView build() {
- return new ResourceView(super.id, super.creationTimestamp,
- super.selfLink, super.name, super.description,
- numMembers, members.build(), lastModified,
- labels.build());
- }
-
- public Builder fromResourceView(ResourceView in) {
- return super.fromResource(in).numMembers(in.getNumMembers().orNull())
- .members(in.getMembers())
- .lastModified(in.getLastModified().orNull())
- .labels(in.getLabels());
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/TargetHttpProxy.java
----------------------------------------------------------------------
diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/TargetHttpProxy.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/TargetHttpProxy.java
index fe4acc3..89014ab 100644
--- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/TargetHttpProxy.java
+++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/domain/TargetHttpProxy.java
@@ -16,117 +16,32 @@
*/
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 org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
+import com.google.auto.value.AutoValue;
import com.google.common.annotations.Beta;
-import com.google.common.base.Objects;
-/**
- * A target http proxy resource.
- *
- * @see <a href="https://developers.google.com/compute/docs/reference/latest/targetHttpProxies"/>
- * @see <a href="https://developers.google.com/compute/docs/load-balancing/http/target-http-proxy"/>
- */
+@AutoValue
@Beta
-public final class TargetHttpProxy extends Resource {
-
- private final URI urlMap;
-
- @ConstructorProperties({
- "id", "creationTimestamp", "selfLink", "name", "description", "urlMap",
- })
- private TargetHttpProxy(String id, Date creationTimestamp, URI selfLink, String name,
- @Nullable String description, URI urlMap) {
- super(Kind.TARGET_HTTP_PROXY, id, creationTimestamp, selfLink, name, description);
- this.urlMap = checkNotNull(urlMap, "urlMap");
- }
-
- /**
- * @return the url map this proxy points to.
- */
- public URI getUrlMap() {
- return urlMap;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- return Objects.hashCode(kind, name, urlMap);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null || getClass() != obj.getClass()) return false;
- TargetHttpProxy that = TargetHttpProxy.class.cast(obj);
- return equal(this.kind, that.kind)
- && equal(this.name, that.name)
- && equal(this.urlMap, that.urlMap);
- }
-
- /**
- * {@inheritDoc}
- */
- protected Objects.ToStringHelper string() {
- return super.string()
- .omitNullValues()
- .add("urlMap", urlMap);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return string().toString();
- }
+public abstract class TargetHttpProxy {
- public static Builder builder() {
- return new Builder();
- }
+ public abstract String id();
+ public abstract Date creationTimestamp();
+ public abstract URI selfLink();
+ public abstract String name();
+ @Nullable public abstract String description();
+ public abstract URI urlMap();
- public Builder toBuilder() {
- return new Builder().fromTargetHttpProxy(this);
+ @SerializedNames({"id", "creationTimestamp", "selfLink", "name", "description", "urlMap"})
+ public static TargetHttpProxy create(String id, Date creationTimestamp, URI selfLink, String name,
+ @Nullable String description, URI urlMap){
+ return new AutoValue_TargetHttpProxy(id, creationTimestamp, selfLink, name, description, urlMap);
}
- public static final class Builder extends Resource.Builder<Builder> {
-
- private URI urlMap;
-
- /**
- * @see TargetHttpProxy#getUrlMap()
- */
- public Builder urlMap(URI urlMap) {
- this.urlMap = urlMap;
- return this;
- }
-
- @Override
- protected Builder self() {
- return this;
- }
-
- public TargetHttpProxy build() {
- return new TargetHttpProxy(super.id, super.creationTimestamp, super.selfLink, super.name,
- super.description, urlMap);
- }
-
- public Builder fromTargetHttpProxy(TargetHttpProxy in) {
- return super.fromResource(in)
- .urlMap(in.getUrlMap());
- }
-
+ TargetHttpProxy(){
}
}