mirror of https://github.com/apache/jclouds.git
Updated TargetHttpProxyOptions, TargetPoolCreationOptions, UrlMapOptions to AutoValue + Builder
This commit is contained in:
parent
2ba48dc9f6
commit
0f67b62505
|
@ -1,75 +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.binders;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions;
|
|
||||||
import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions.SessionAffinityValue;
|
|
||||||
import org.jclouds.http.HttpRequest;
|
|
||||||
import org.jclouds.json.Json;
|
|
||||||
import org.jclouds.rest.binders.BindToJsonPayload;
|
|
||||||
|
|
||||||
|
|
||||||
public class TargetPoolCreationBinder extends BindToJsonPayload {
|
|
||||||
|
|
||||||
@Inject TargetPoolCreationBinder(Json jsonBinder) {
|
|
||||||
super(jsonBinder);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
|
|
||||||
TargetPoolCreationOptions options = (TargetPoolCreationOptions) postParams.get("options");
|
|
||||||
String name = postParams.get("name").toString();
|
|
||||||
TargetPoolBinderHelper targetPoolBinderHelper = new TargetPoolBinderHelper(name, options);
|
|
||||||
return super.bindToRequest(request, targetPoolBinderHelper);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TargetPoolBinderHelper{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Values used to bind TargetPoolCreationOptions to json request.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private String name;
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private List<URI> healthChecks;
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private List<URI> instances;
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private SessionAffinityValue sessionAffinity;
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private Float failoverRatio;
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private URI backupPool;
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
private TargetPoolBinderHelper(String name, TargetPoolCreationOptions targetPoolCreationOptions){
|
|
||||||
this.name = name;
|
|
||||||
this.healthChecks = targetPoolCreationOptions.getHealthChecks();
|
|
||||||
this.instances = targetPoolCreationOptions.getInstances();
|
|
||||||
this.sessionAffinity = targetPoolCreationOptions.getSessionAffinity();
|
|
||||||
this.failoverRatio = targetPoolCreationOptions.getFailoverRatio();
|
|
||||||
this.backupPool = targetPoolCreationOptions.getBackupPool();
|
|
||||||
this.description = targetPoolCreationOptions.getDescription();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -83,6 +83,7 @@ public interface TargetHttpProxyApi {
|
||||||
@Path("/global/targetHttpProxies")
|
@Path("/global/targetHttpProxies")
|
||||||
Operation create(@BinderParam(BindToJsonPayload.class) TargetHttpProxyOptions targetHttpProxyOptions);
|
Operation create(@BinderParam(BindToJsonPayload.class) TargetHttpProxyOptions targetHttpProxyOptions);
|
||||||
|
|
||||||
|
//TODO (broudy) : Should we remove this because it is redundant?
|
||||||
/**
|
/**
|
||||||
* Creates a targetHttpProxy resource in the specified project using the given URI for the urlMap.
|
* Creates a targetHttpProxy resource in the specified project using the given URI for the urlMap.
|
||||||
*
|
*
|
||||||
|
|
|
@ -38,7 +38,6 @@ import org.jclouds.googlecloud.domain.ListPage;
|
||||||
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
|
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
|
||||||
import org.jclouds.googlecomputeengine.binders.TargetPoolChangeHealthChecksBinder;
|
import org.jclouds.googlecomputeengine.binders.TargetPoolChangeHealthChecksBinder;
|
||||||
import org.jclouds.googlecomputeengine.binders.TargetPoolChangeInstancesBinder;
|
import org.jclouds.googlecomputeengine.binders.TargetPoolChangeInstancesBinder;
|
||||||
import org.jclouds.googlecomputeengine.binders.TargetPoolCreationBinder;
|
|
||||||
import org.jclouds.googlecomputeengine.domain.HealthStatus;
|
import org.jclouds.googlecomputeengine.domain.HealthStatus;
|
||||||
import org.jclouds.googlecomputeengine.domain.Operation;
|
import org.jclouds.googlecomputeengine.domain.Operation;
|
||||||
import org.jclouds.googlecomputeengine.domain.TargetPool;
|
import org.jclouds.googlecomputeengine.domain.TargetPool;
|
||||||
|
@ -47,6 +46,7 @@ import org.jclouds.googlecomputeengine.options.ListOptions;
|
||||||
import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions;
|
import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions;
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
import org.jclouds.oauth.v2.filters.OAuthFilter;
|
import org.jclouds.oauth.v2.filters.OAuthFilter;
|
||||||
|
import org.jclouds.rest.annotations.BinderParam;
|
||||||
import org.jclouds.rest.annotations.Fallback;
|
import org.jclouds.rest.annotations.Fallback;
|
||||||
import org.jclouds.rest.annotations.MapBinder;
|
import org.jclouds.rest.annotations.MapBinder;
|
||||||
import org.jclouds.rest.annotations.PayloadParam;
|
import org.jclouds.rest.annotations.PayloadParam;
|
||||||
|
@ -82,8 +82,7 @@ public interface TargetPoolApi {
|
||||||
@Named("TargetPools:insert")
|
@Named("TargetPools:insert")
|
||||||
@POST
|
@POST
|
||||||
@Produces(APPLICATION_JSON)
|
@Produces(APPLICATION_JSON)
|
||||||
@MapBinder(TargetPoolCreationBinder.class)
|
Operation create(@BinderParam(BindToJsonPayload.class) TargetPoolCreationOptions options);
|
||||||
Operation create(@PayloadParam("name") String name, @PayloadParam("options") TargetPoolCreationOptions options);
|
|
||||||
|
|
||||||
/** Deletes a target pool by name and returns the operation in progress, or null if not found. */
|
/** Deletes a target pool by name and returns the operation in progress, or null if not found. */
|
||||||
@Named("TargetPools:delete")
|
@Named("TargetPools:delete")
|
||||||
|
|
|
@ -113,6 +113,7 @@ public interface UrlMapApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the specified urlMap resource, with patch semantics, with the data included in the request.
|
* Updates the specified urlMap resource, with patch semantics, with the data included in the request.
|
||||||
|
* Note:{@link UrlMapOptions.Builder#buildForPatch()} may be helpful.
|
||||||
*
|
*
|
||||||
* @param urlMapName the name urlMap to be updated.
|
* @param urlMapName the name urlMap to be updated.
|
||||||
* @param urlMapOptions the new urlMap options.
|
* @param urlMapOptions the new urlMap options.
|
||||||
|
|
|
@ -161,7 +161,7 @@ public abstract class HttpHealthCheckCreationOptions {
|
||||||
* Useful when performing a PATCH operation and you do not want to overwrite
|
* Useful when performing a PATCH operation and you do not want to overwrite
|
||||||
* unspecified values with the default values.
|
* unspecified values with the default values.
|
||||||
*/
|
*/
|
||||||
public HttpHealthCheckCreationOptions buildNoDefaults() {
|
public HttpHealthCheckCreationOptions buildForPatch() {
|
||||||
return HttpHealthCheckCreationOptions.create(host, requestPath, port,
|
return HttpHealthCheckCreationOptions.create(host, requestPath, port,
|
||||||
checkIntervalSec, timeoutSec, unhealthyThreshold, healthyThreshold, description);
|
checkIntervalSec, timeoutSec, unhealthyThreshold, healthyThreshold, description);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,60 +16,52 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.googlecomputeengine.options;
|
package org.jclouds.googlecomputeengine.options;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
public final class TargetHttpProxyOptions {
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
|
@AutoValue
|
||||||
|
public abstract class TargetHttpProxyOptions {
|
||||||
|
|
||||||
|
public abstract String name();
|
||||||
|
@Nullable public abstract String description();
|
||||||
|
public abstract URI urlMap();
|
||||||
|
|
||||||
|
@SerializedNames({ "name", "description", "urlMap"})
|
||||||
|
static TargetHttpProxyOptions create(String name, String description, URI urlMap) {
|
||||||
|
return new AutoValue_TargetHttpProxyOptions(name, description, urlMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
TargetHttpProxyOptions() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
private String name;
|
private String name;
|
||||||
@Nullable private String description;
|
private String description;
|
||||||
private URI urlMap;
|
private URI urlMap;
|
||||||
|
|
||||||
/**
|
public Builder(String name, URI urlMap) {
|
||||||
* Name of the TargetHttpProxy resource.
|
|
||||||
* @return name, provided by the client.
|
|
||||||
*/
|
|
||||||
public String getName(){
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TargetHttpProxyOptions#getName()
|
|
||||||
*/
|
|
||||||
public TargetHttpProxyOptions name(String name) {
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
return this;
|
this.urlMap = urlMap;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An optional textual description of the TargetHttpProxy.
|
|
||||||
* @return description, provided by the client.
|
|
||||||
*/
|
|
||||||
public String getDescription(){
|
|
||||||
return description;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see TargetHttpProxyOptions#getDescription()
|
* @see TargetHttpProxyOptions#getDescription()
|
||||||
*/
|
*/
|
||||||
public TargetHttpProxyOptions description(String description) {
|
public Builder description(String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public TargetHttpProxyOptions build() {
|
||||||
* URL to the UrlMap resource that defines the mapping from URL to the BackendService.
|
checkNotNull(name, "TargetHttpProxyOptions name cannot be null");
|
||||||
*/
|
checkNotNull(urlMap, "TargetHttpProxyOptions name cannot be null");
|
||||||
public URI getUrlMap() {
|
return create(name, description, urlMap);
|
||||||
return urlMap;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TargetHttpProxyOptions#getUrlMap()
|
|
||||||
*/
|
|
||||||
public TargetHttpProxyOptions urlMap(URI urlMap) {
|
|
||||||
this.urlMap = urlMap;
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,14 +16,21 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.googlecomputeengine.options;
|
package org.jclouds.googlecomputeengine.options;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options for creating a Target Pool
|
* Options for creating a Target Pool
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class TargetPoolCreationOptions{
|
@AutoValue
|
||||||
|
public abstract class TargetPoolCreationOptions{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Session affinity determines the hash method that
|
* Session affinity determines the hash method that
|
||||||
|
@ -36,6 +43,28 @@ public class TargetPoolCreationOptions{
|
||||||
NONE
|
NONE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract String name();
|
||||||
|
@Nullable public abstract List<URI> healthChecks();
|
||||||
|
@Nullable public abstract List<URI> instances();
|
||||||
|
@Nullable public abstract SessionAffinityValue sessionAffinity();
|
||||||
|
@Nullable public abstract Float failoverRatio();
|
||||||
|
@Nullable public abstract URI backupPool();
|
||||||
|
@Nullable public abstract String description();
|
||||||
|
|
||||||
|
@SerializedNames({ "name", "healthChecks", "instances", "sessionAffinity", "failoverRatio",
|
||||||
|
"backupPool", "description"})
|
||||||
|
public static TargetPoolCreationOptions create(String name, List<URI> healthChecks, List<URI> instances,
|
||||||
|
SessionAffinityValue sessionAffinity, Float failoverRatio, URI backupPool, String description) {
|
||||||
|
return new AutoValue_TargetPoolCreationOptions(name, healthChecks, instances, sessionAffinity, failoverRatio,
|
||||||
|
backupPool, description);
|
||||||
|
}
|
||||||
|
|
||||||
|
TargetPoolCreationOptions() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
private String name;
|
||||||
private List<URI> healthChecks;
|
private List<URI> healthChecks;
|
||||||
private List<URI> instances;
|
private List<URI> instances;
|
||||||
private SessionAffinityValue sessionAffinity;
|
private SessionAffinityValue sessionAffinity;
|
||||||
|
@ -43,32 +72,33 @@ public class TargetPoolCreationOptions{
|
||||||
private URI backupPool;
|
private URI backupPool;
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
/**
|
public Builder(String name){
|
||||||
* The set of HealthChecks
|
checkNotNull(name, "TargetPoolCreationOptions name cannot be null");
|
||||||
*
|
this.name = name;
|
||||||
* @return a set of HealthCheck URIs
|
}
|
||||||
*/
|
|
||||||
public List<URI> getHealthChecks(){
|
/** The set of HealthChecks */
|
||||||
return healthChecks;
|
public Builder healthChecks(List<URI> healthChecks){
|
||||||
|
this.healthChecks = healthChecks;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A List of resource URIs to the member VMs serving this pool.
|
* A List of resource URIs to the member VMs serving this pool.
|
||||||
* They must live in zones contained in the same region as this pool.
|
* They must live in zones contained in the same region as this pool.
|
||||||
*
|
|
||||||
* @return set of instance URIs
|
|
||||||
*/
|
*/
|
||||||
public List<URI> getInstances(){
|
public Builder instances(List<URI> instances){
|
||||||
return instances;
|
this.instances = instances;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the session affinity option.
|
* Defines the session affinity option.
|
||||||
* Session affinity determines the hash method that Google Compute Engine uses to distribute traffic.
|
* Session affinity determines the hash method that Google Compute Engine uses to distribute traffic.
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public SessionAffinityValue getSessionAffinity(){
|
public Builder sessionAffinity(SessionAffinityValue sessionAffinity){
|
||||||
return sessionAffinity;
|
this.sessionAffinity = sessionAffinity;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,74 +108,35 @@ public class TargetPoolCreationOptions{
|
||||||
* If set, backupPool must also be set.
|
* If set, backupPool must also be set.
|
||||||
* @return failoverRatio, a float between [0, 1]
|
* @return failoverRatio, a float between [0, 1]
|
||||||
*/
|
*/
|
||||||
public Float getFailoverRatio(){
|
public Builder failoverRatio(float failoverRatio){
|
||||||
return failoverRatio;
|
this.failoverRatio = failoverRatio;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This field is applicable only when the target pool is serving a forwarding rule as the primary pool
|
* This field is applicable only when the target pool is serving a forwarding rule as the primary pool
|
||||||
* (e.g. not as a backup pool to some other target pool). Must be a fully-qualified URL to a target pool that is in the same region as the primary target pool.
|
* (e.g. not as a backup pool to some other target pool). Must be a fully-qualified URL to a target pool
|
||||||
|
* that is in the same region as the primary target pool.
|
||||||
* If set, failoverRatio must also be set
|
* If set, failoverRatio must also be set
|
||||||
* @return backupPool, Fully-qualified URI to a target pool in the same region as primary target pool
|
* @return backupPool, Fully-qualified URI to a target pool in the same region as primary target pool
|
||||||
*/
|
*/
|
||||||
public URI getBackupPool(){
|
public Builder backupPool(URI backupPool){
|
||||||
return backupPool;
|
this.backupPool = backupPool;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An optional textual description of the TargetPool.
|
* An optional textual description of the TargetPool.
|
||||||
* @return description, provided by the client.
|
* @return description, provided by the client.
|
||||||
*/
|
*/
|
||||||
public String getDescription(){
|
public Builder description(String description){
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TargetPoolCreationOptions#getHealthChecks()
|
|
||||||
*/
|
|
||||||
public TargetPoolCreationOptions healthChecks(List<URI> healthChecks){
|
|
||||||
this.healthChecks = healthChecks;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TargetPoolCreationOptions#getInstances()
|
|
||||||
*/
|
|
||||||
public TargetPoolCreationOptions instances(List<URI> instances){
|
|
||||||
this.instances = instances;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TargetPoolCreationOptions#getSessionAffinity()
|
|
||||||
*/
|
|
||||||
public TargetPoolCreationOptions sessionAffinity(SessionAffinityValue sessionAffinity){
|
|
||||||
this.sessionAffinity = sessionAffinity;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TargetPoolCreationOptions#getFailoverRatio()
|
|
||||||
*/
|
|
||||||
public TargetPoolCreationOptions failoverRatio(float failoverRatio){
|
|
||||||
this.failoverRatio = failoverRatio;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TargetPoolCreationOptions#getBackupPool()
|
|
||||||
*/
|
|
||||||
public TargetPoolCreationOptions backupPool(URI backupPool){
|
|
||||||
this.backupPool = backupPool;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see TargetPoolCreationOptions#getDescription()
|
|
||||||
*/
|
|
||||||
public TargetPoolCreationOptions description(String description){
|
|
||||||
this.description = description;
|
this.description = description;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TargetPoolCreationOptions build() {
|
||||||
|
return create(name, healthChecks, instances, sessionAffinity, failoverRatio,
|
||||||
|
backupPool, description);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.googlecomputeengine.options;
|
package org.jclouds.googlecomputeengine.options;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -23,13 +25,36 @@ import org.jclouds.googlecomputeengine.domain.UrlMap.HostRule;
|
||||||
import org.jclouds.googlecomputeengine.domain.UrlMap.PathMatcher;
|
import org.jclouds.googlecomputeengine.domain.UrlMap.PathMatcher;
|
||||||
import org.jclouds.googlecomputeengine.domain.UrlMap.UrlMapTest;
|
import org.jclouds.googlecomputeengine.domain.UrlMap.UrlMapTest;
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
import org.jclouds.json.SerializedNames;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.auto.value.AutoValue;
|
||||||
|
|
||||||
public class UrlMapOptions {
|
@AutoValue
|
||||||
|
public abstract class UrlMapOptions {
|
||||||
|
|
||||||
|
@Nullable public abstract String name();
|
||||||
|
@Nullable public abstract String description();
|
||||||
|
@Nullable public abstract List<HostRule> hostRules();
|
||||||
|
@Nullable public abstract List<PathMatcher> pathMatchers();
|
||||||
|
@Nullable public abstract List<UrlMapTest> tests();
|
||||||
|
@Nullable public abstract URI defaultService();
|
||||||
|
@Nullable public abstract String fingerprint();
|
||||||
|
|
||||||
|
@SerializedNames({ "name", "description", "hostRules", "pathMatchers", "tests",
|
||||||
|
"defaultService", "fingerprint"})
|
||||||
|
static UrlMapOptions create(String name, String description, List<HostRule> hostRules,
|
||||||
|
List<PathMatcher> pathMatchers, List<UrlMapTest> tests, URI defaultService, String fingerprint) {
|
||||||
|
return new AutoValue_UrlMapOptions(name, description, hostRules,
|
||||||
|
pathMatchers, tests, defaultService, fingerprint);
|
||||||
|
}
|
||||||
|
|
||||||
|
UrlMapOptions(){
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
@Nullable private String description;
|
private String description;
|
||||||
private List<HostRule> hostRules;
|
private List<HostRule> hostRules;
|
||||||
private List<PathMatcher> pathMatchers;
|
private List<PathMatcher> pathMatchers;
|
||||||
private List<UrlMapTest> tests;
|
private List<UrlMapTest> tests;
|
||||||
|
@ -38,32 +63,16 @@ public class UrlMapOptions {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the UrlMap resource.
|
* Name of the UrlMap resource.
|
||||||
* @return name, provided by the client.
|
|
||||||
*/
|
*/
|
||||||
public String getName(){
|
public Builder name(String name) {
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see UrlMapOptions#getName()
|
|
||||||
*/
|
|
||||||
public UrlMapOptions name(String name) {
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An optional textual description of the UrlMap.
|
* An optional textual description of the UrlMap.
|
||||||
* @return description, provided by the client.
|
|
||||||
*/
|
*/
|
||||||
public String getDescription(){
|
public Builder description(String description) {
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see UrlMapOptions#getDescription()
|
|
||||||
*/
|
|
||||||
public UrlMapOptions description(String description) {
|
|
||||||
this.description = description;
|
this.description = description;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -71,45 +80,15 @@ public class UrlMapOptions {
|
||||||
/**
|
/**
|
||||||
* Rules for matching and directing incoming hosts.
|
* Rules for matching and directing incoming hosts.
|
||||||
*/
|
*/
|
||||||
public List<HostRule> getHostRules() {
|
public Builder hostRules(List<HostRule> hostRules) {
|
||||||
return hostRules;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see UrlMapOptions#getHostRules()
|
|
||||||
*/
|
|
||||||
public UrlMapOptions hostRules(List<HostRule> hostRules) {
|
|
||||||
this.hostRules = hostRules;
|
this.hostRules = hostRules;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see UrlMapOptions#getHostRules()
|
|
||||||
*/
|
|
||||||
public UrlMapOptions hostRule(HostRule hostRule){
|
|
||||||
this.hostRules = ImmutableList.of(hostRule);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of named PathMatchers to use against the URL.
|
* The list of named PathMatchers to use against the URL.
|
||||||
*/
|
*/
|
||||||
public List<PathMatcher> getPathMatchers() {
|
public Builder pathMatchers(List<PathMatcher> pathMatchers) {
|
||||||
return pathMatchers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see UrlMapOptions#getPathMatchers()
|
|
||||||
*/
|
|
||||||
public UrlMapOptions pathMatcher(PathMatcher pathMatcher) {
|
|
||||||
this.pathMatchers = ImmutableList.of(pathMatcher);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see UrlMapOptions#getPathMatchers()
|
|
||||||
*/
|
|
||||||
public UrlMapOptions pathMatchers(List<PathMatcher> pathMatchers) {
|
|
||||||
this.pathMatchers = pathMatchers;
|
this.pathMatchers = pathMatchers;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -118,37 +97,15 @@ public class UrlMapOptions {
|
||||||
* The list of expected URL mappings. Request to update this
|
* The list of expected URL mappings. Request to update this
|
||||||
* UrlMap will succeed only all of the test cases pass.
|
* UrlMap will succeed only all of the test cases pass.
|
||||||
*/
|
*/
|
||||||
public List<UrlMapTest> getTests() {
|
public Builder tests(List<UrlMapTest> tests) {
|
||||||
return tests;
|
this.tests = tests;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see UrlMapOptions#getTests()
|
|
||||||
*/
|
|
||||||
public UrlMapOptions test(UrlMapTest urlMapTest) {
|
|
||||||
this.tests = ImmutableList.of(urlMapTest);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see UrlMapOptions#getTests()
|
|
||||||
*/
|
|
||||||
public UrlMapOptions urlMapTests(List<UrlMapTest> urlMapTests) {
|
|
||||||
this.tests = urlMapTests;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL of the BackendService resource if none of the hostRules match.
|
* The URL of the BackendService resource if none of the hostRules match.
|
||||||
*/
|
*/
|
||||||
public URI getDefaultService() {
|
public Builder defaultService(URI defaultService) {
|
||||||
return defaultService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see UrlMapOptions#getDefaultService()
|
|
||||||
*/
|
|
||||||
public UrlMapOptions defaultService(URI defaultService) {
|
|
||||||
this.defaultService = defaultService;
|
this.defaultService = defaultService;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -159,15 +116,30 @@ public class UrlMapOptions {
|
||||||
* inserting a UrlMap. An up-to-date fingerprint must be provided in order to
|
* inserting a UrlMap. An up-to-date fingerprint must be provided in order to
|
||||||
* update the UrlMap.
|
* update the UrlMap.
|
||||||
*/
|
*/
|
||||||
public String getFingerprint() {
|
public Builder fingerprint(String fingerprint) {
|
||||||
return fingerprint;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see UrlMapOptions#getFingerprint()
|
|
||||||
*/
|
|
||||||
public UrlMapOptions fingerprint(String fingerprint) {
|
|
||||||
this.fingerprint = fingerprint;
|
this.fingerprint = fingerprint;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the UrlMapOptions.
|
||||||
|
* Note: This enforces that "name" and "defaultService" are not null as the GCE API expects.
|
||||||
|
* If you are patching an existing UrlMap you may wish to use {@link #buildForPatch()} instead.
|
||||||
|
*/
|
||||||
|
public UrlMapOptions build() {
|
||||||
|
checkNotNull(name, "In UrlMapOptions: A UrlMap name cannot be null, if patching an existing UrlMap use buildForPatch() instead of build()");
|
||||||
|
checkNotNull(defaultService, "In UrlMapOptions: A UrlMap defaultService cannot be null, if patching an existing UrlMap use buildForPatch() instead of build()");
|
||||||
|
return create(name, description, hostRules, pathMatchers, tests,
|
||||||
|
defaultService, fingerprint);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This build option is specifically for when patching an existing UrlMap.
|
||||||
|
* If not patching an existing urlMap it is recommended that you use {@link #build()}.
|
||||||
|
*/
|
||||||
|
public UrlMapOptions buildForPatch() {
|
||||||
|
return create(name, description, hostRules, pathMatchers, tests,
|
||||||
|
defaultService, fingerprint);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,72 +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.binders;
|
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineExpectTest;
|
|
||||||
import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions;
|
|
||||||
import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions.SessionAffinityValue;
|
|
||||||
import org.jclouds.http.HttpRequest;
|
|
||||||
import org.jclouds.json.Json;
|
|
||||||
import org.jclouds.json.internal.GsonWrapper;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
|
|
||||||
@Test(groups = "unit", testName = "TargetPoolCreationBinderTest")
|
|
||||||
public class TargetPoolCreationBinderTest extends BaseGoogleComputeEngineExpectTest<Object>{
|
|
||||||
|
|
||||||
private static final List<URI> FAKE_HEALTH_CHECKS = ImmutableList.of(
|
|
||||||
URI.create("https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20141017"));
|
|
||||||
private static SessionAffinityValue SESSION_AFFINITY = SessionAffinityValue.CLIENT_IP_PROTO;
|
|
||||||
private static float FAILOVER_RATIO = (float) 0.4;
|
|
||||||
private static String DESCRIPTION = "This is a test!";
|
|
||||||
|
|
||||||
Json json = new GsonWrapper(new Gson());
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testMap() throws SecurityException, NoSuchMethodException {
|
|
||||||
TargetPoolCreationBinder binder = new TargetPoolCreationBinder(json);
|
|
||||||
TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions()
|
|
||||||
.healthChecks(FAKE_HEALTH_CHECKS)
|
|
||||||
.sessionAffinity(SESSION_AFFINITY)
|
|
||||||
.failoverRatio(FAILOVER_RATIO)
|
|
||||||
.description(DESCRIPTION);
|
|
||||||
|
|
||||||
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
|
|
||||||
Map<String, Object> postParams = ImmutableMap.of("name", "testTargetPoolName", "options", targetPoolCreationOptions);
|
|
||||||
|
|
||||||
binder.bindToRequest(request, postParams);
|
|
||||||
|
|
||||||
assertEquals(request.getPayload().getRawContent(),
|
|
||||||
"{\""
|
|
||||||
+ "name\":\"testTargetPoolName\","
|
|
||||||
+ "\"healthChecks\":[\"" + FAKE_HEALTH_CHECKS.toArray()[0] + "\"],"
|
|
||||||
+ "\"sessionAffinity\":\"CLIENT_IP_PROTO\","
|
|
||||||
+ "\"failoverRatio\":0.4,"
|
|
||||||
+ "\"description\":\"This is a test!\""
|
|
||||||
+ "}");
|
|
||||||
assertEquals(request.getPayload().getContentMetadata().getContentType(), "application/json");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -61,11 +61,12 @@ public class ForwardingRuleApiLiveTest extends BaseGoogleComputeEngineApiLiveTes
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public void init() {
|
public void init() {
|
||||||
TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions();
|
TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions.Builder(TARGETPOOL_NAME).build();
|
||||||
assertOperationDoneSuccessfully(targetPoolApi().create(TARGETPOOL_NAME, targetPoolCreationOptions));
|
assertOperationDoneSuccessfully(targetPoolApi().create(targetPoolCreationOptions));
|
||||||
targetPool = targetPoolApi().get(TARGETPOOL_NAME);
|
targetPool = targetPoolApi().get(TARGETPOOL_NAME);
|
||||||
|
|
||||||
assertOperationDoneSuccessfully(targetPoolApi().create(TARGETPOOL_NAME_NEW, targetPoolCreationOptions));
|
targetPoolCreationOptions = new TargetPoolCreationOptions.Builder(TARGETPOOL_NAME_NEW).build();
|
||||||
|
assertOperationDoneSuccessfully(targetPoolApi().create(targetPoolCreationOptions));
|
||||||
newTargetPool = targetPoolApi().get(TARGETPOOL_NAME_NEW);
|
newTargetPool = targetPoolApi().get(TARGETPOOL_NAME_NEW);
|
||||||
|
|
||||||
assertOperationDoneSuccessfully(addressApi().create(ADDRESS_NAME));
|
assertOperationDoneSuccessfully(addressApi().create(ADDRESS_NAME));
|
||||||
|
|
|
@ -66,9 +66,9 @@ public class GlobalForwardingRuleApiLiveTest extends BaseGoogleComputeEngineApiL
|
||||||
assertOperationDoneSuccessfully(api.backendServices()
|
assertOperationDoneSuccessfully(api.backendServices()
|
||||||
.create(b));
|
.create(b));
|
||||||
|
|
||||||
UrlMapOptions map = new UrlMapOptions().name(GLOBAL_FORWARDING_RULE_URL_MAP_NAME)
|
UrlMapOptions map = new UrlMapOptions.Builder().name(GLOBAL_FORWARDING_RULE_URL_MAP_NAME)
|
||||||
.description("simple url map")
|
.description("simple url map")
|
||||||
.defaultService(getBackendServiceUrl(GLOBAL_FORWARDING_RULE_BACKEND_SERVICE_NAME));
|
.defaultService(getBackendServiceUrl(GLOBAL_FORWARDING_RULE_BACKEND_SERVICE_NAME)).build();
|
||||||
assertOperationDoneSuccessfully(api.urlMaps()
|
assertOperationDoneSuccessfully(api.urlMaps()
|
||||||
.create(map));
|
.create(map));
|
||||||
assertOperationDoneSuccessfully(api.targetHttpProxies()
|
assertOperationDoneSuccessfully(api.targetHttpProxies()
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class HttpHealthCheckApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
|
||||||
.port(options.port() + OFFSET)
|
.port(options.port() + OFFSET)
|
||||||
.checkIntervalSec(options.checkIntervalSec() + OFFSET)
|
.checkIntervalSec(options.checkIntervalSec() + OFFSET)
|
||||||
.timeoutSec(options.timeoutSec() + OFFSET)
|
.timeoutSec(options.timeoutSec() + OFFSET)
|
||||||
.buildNoDefaults();
|
.buildForPatch();
|
||||||
assertOperationDoneSuccessfully(api().patch(HTTP_HEALTH_CHECK_NAME, newOptions));
|
assertOperationDoneSuccessfully(api().patch(HTTP_HEALTH_CHECK_NAME, newOptions));
|
||||||
|
|
||||||
// Check changes happened and others unchanged.
|
// Check changes happened and others unchanged.
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class HttpHealthCheckApiMockTest extends BaseGoogleComputeEngineApiMockTe
|
||||||
server.enqueue(jsonResponse("/global_operation.json"));
|
server.enqueue(jsonResponse("/global_operation.json"));
|
||||||
|
|
||||||
HttpHealthCheckCreationOptions options = new HttpHealthCheckCreationOptions.Builder()
|
HttpHealthCheckCreationOptions options = new HttpHealthCheckCreationOptions.Builder()
|
||||||
.timeoutSec(0).unhealthyThreshold(0).buildNoDefaults();
|
.timeoutSec(0).unhealthyThreshold(0).buildForPatch();
|
||||||
assertEquals(httpHealthCheckApi().patch("http-health-check", options),
|
assertEquals(httpHealthCheckApi().patch("http-health-check", options),
|
||||||
new ParseGlobalOperationTest().expected(url("/projects")));
|
new ParseGlobalOperationTest().expected(url("/projects")));
|
||||||
|
|
||||||
|
|
|
@ -57,12 +57,14 @@ public class TargetHttpProxyApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
|
||||||
|
|
||||||
assertOperationDoneSuccessfully(api.backendServices().create(b));
|
assertOperationDoneSuccessfully(api.backendServices().create(b));
|
||||||
|
|
||||||
UrlMapOptions map = new UrlMapOptions().name(TARGET_HTTP_PROXY_URL_MAP_NAME).description("simple url map")
|
UrlMapOptions map = new UrlMapOptions.Builder().name(TARGET_HTTP_PROXY_URL_MAP_NAME).description("simple url map")
|
||||||
.defaultService(getBackendServiceUrl(URL_MAP_DEFAULT_SERVICE_NAME));
|
.defaultService(getBackendServiceUrl(URL_MAP_DEFAULT_SERVICE_NAME)).build();
|
||||||
assertOperationDoneSuccessfully(api.urlMaps().create(map));
|
assertOperationDoneSuccessfully(api.urlMaps().create(map));
|
||||||
|
|
||||||
UrlMapOptions map2 = new UrlMapOptions().name(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2").description("a second simple url map")
|
UrlMapOptions map2 = new UrlMapOptions.Builder().name(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2")
|
||||||
.defaultService(getBackendServiceUrl(URL_MAP_DEFAULT_SERVICE_NAME));
|
.description("a second simple url map")
|
||||||
|
.defaultService(getBackendServiceUrl(URL_MAP_DEFAULT_SERVICE_NAME))
|
||||||
|
.build();
|
||||||
assertOperationDoneSuccessfully(api.urlMaps().create(map2));
|
assertOperationDoneSuccessfully(api.urlMaps().create(map2));
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,11 +80,6 @@ public class TargetHttpProxyApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
|
||||||
|
|
||||||
@Test(groups = "live", dependsOnMethods = "testGetTargetHttpProxy")
|
@Test(groups = "live", dependsOnMethods = "testGetTargetHttpProxy")
|
||||||
public void testSetUrlMapTargetHttpProxy() {
|
public void testSetUrlMapTargetHttpProxy() {
|
||||||
UrlMapOptions map = new UrlMapOptions().name(TARGET_HTTP_PROXY_URL_MAP_NAME).description("simple url map")
|
|
||||||
.defaultService(getBackendServiceUrl(URL_MAP_DEFAULT_SERVICE_NAME));
|
|
||||||
assertOperationDoneSuccessfully(api.urlMaps()
|
|
||||||
.create(map));
|
|
||||||
|
|
||||||
assertOperationDoneSuccessfully(api().setUrlMap(TARGET_HTTP_PROXY_NAME,
|
assertOperationDoneSuccessfully(api().setUrlMap(TARGET_HTTP_PROXY_NAME,
|
||||||
getUrlMapUrl(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2")));
|
getUrlMapUrl(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2")));
|
||||||
}
|
}
|
||||||
|
@ -97,7 +94,7 @@ public class TargetHttpProxyApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
|
||||||
getUrlMapUrl(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2"));
|
getUrlMapUrl(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = "live", dependsOnMethods = "testListTargetHttpProxy")
|
@Test(groups = "live", dependsOnMethods = "testListTargetHttpProxy", alwaysRun = true)
|
||||||
public void testDeleteTargetHttpProxy() {
|
public void testDeleteTargetHttpProxy() {
|
||||||
assertOperationDoneSuccessfully(api().delete(TARGET_HTTP_PROXY_NAME));
|
assertOperationDoneSuccessfully(api().delete(TARGET_HTTP_PROXY_NAME));
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import static org.testng.AssertJUnit.assertNull;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiMockTest;
|
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiMockTest;
|
||||||
|
import org.jclouds.googlecomputeengine.options.TargetHttpProxyOptions;
|
||||||
import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
|
import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
|
||||||
import org.jclouds.googlecomputeengine.parse.ParseTargetHttpProxyListTest;
|
import org.jclouds.googlecomputeengine.parse.ParseTargetHttpProxyListTest;
|
||||||
import org.jclouds.googlecomputeengine.parse.ParseTargetHttpProxyTest;
|
import org.jclouds.googlecomputeengine.parse.ParseTargetHttpProxyTest;
|
||||||
|
@ -55,6 +56,20 @@ public class TargetHttpProxyApiMockTest extends BaseGoogleComputeEngineApiMockTe
|
||||||
stringFromResource("/target_http_proxy_insert.json"));
|
stringFromResource("/target_http_proxy_insert.json"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void insert_options() throws Exception {
|
||||||
|
server.enqueue(jsonResponse("/operation.json"));
|
||||||
|
|
||||||
|
URI urlMap = URI.create(url("/projects/myproject/global/urlMaps/jclouds-test"));
|
||||||
|
TargetHttpProxyOptions options = new TargetHttpProxyOptions.Builder("jclouds-test", urlMap).description("test").build();
|
||||||
|
assertEquals(targetHttpProxyApi().create(options), new ParseOperationTest().expected(url("/projects")));
|
||||||
|
assertSent(server, "POST", "/projects/party/global/targetHttpProxies",
|
||||||
|
"{" +
|
||||||
|
" \"name\": \"jclouds-test\"," +
|
||||||
|
" \"urlMap\": \"" + url("/projects/myproject/global/urlMaps/jclouds-test") + "\"," +
|
||||||
|
" \"description\": \"test\"" +
|
||||||
|
"}");
|
||||||
|
}
|
||||||
|
|
||||||
public void delete() throws Exception {
|
public void delete() throws Exception {
|
||||||
server.enqueue(jsonResponse("/operation.json"));
|
server.enqueue(jsonResponse("/operation.json"));
|
||||||
|
|
||||||
|
|
|
@ -126,10 +126,11 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
||||||
|
|
||||||
@Test(groups = "live")
|
@Test(groups = "live")
|
||||||
public void testInsertTargetPool() {
|
public void testInsertTargetPool() {
|
||||||
TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions()
|
TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions.Builder(BACKUP_TARGETPOOL_NAME)
|
||||||
.description(DESCRIPTION_BACKUP)
|
.description(DESCRIPTION_BACKUP)
|
||||||
.sessionAffinity(SessionAffinityValue.CLIENT_IP);
|
.sessionAffinity(SessionAffinityValue.CLIENT_IP)
|
||||||
assertOperationDoneSuccessfully(api().create(BACKUP_TARGETPOOL_NAME, targetPoolCreationOptions));
|
.build();
|
||||||
|
assertOperationDoneSuccessfully(api().create(targetPoolCreationOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = "live", dependsOnMethods = "testInsertTargetPool")
|
@Test(groups = "live", dependsOnMethods = "testInsertTargetPool")
|
||||||
|
@ -137,12 +138,13 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
||||||
TargetPool targetPool = api().get(BACKUP_TARGETPOOL_NAME);
|
TargetPool targetPool = api().get(BACKUP_TARGETPOOL_NAME);
|
||||||
assertNotNull(targetPool);
|
assertNotNull(targetPool);
|
||||||
// Make a Target Pool with a backup and failoverRatio specified.
|
// Make a Target Pool with a backup and failoverRatio specified.
|
||||||
TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions()
|
TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions.Builder(TARGETPOOL_NAME)
|
||||||
.description(DESCRIPTION)
|
.description(DESCRIPTION)
|
||||||
.sessionAffinity(SessionAffinityValue.CLIENT_IP)
|
.sessionAffinity(SessionAffinityValue.CLIENT_IP)
|
||||||
.backupPool(targetPool.selfLink())
|
.backupPool(targetPool.selfLink())
|
||||||
.failoverRatio((float) 0.5);
|
.failoverRatio((float) 0.5)
|
||||||
assertOperationDoneSuccessfully(api().create(TARGETPOOL_NAME, targetPoolCreationOptions));
|
.build();
|
||||||
|
assertOperationDoneSuccessfully(api().create(targetPoolCreationOptions));
|
||||||
TargetPool targetPool2 = api().get(TARGETPOOL_NAME);
|
TargetPool targetPool2 = api().get(TARGETPOOL_NAME);
|
||||||
assertNotNull(targetPool2);
|
assertNotNull(targetPool2);
|
||||||
assertEquals(targetPool2.name(), TARGETPOOL_NAME);
|
assertEquals(targetPool2.name(), TARGETPOOL_NAME);
|
||||||
|
@ -222,8 +224,9 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
||||||
|
|
||||||
@Test(groups = "live", dependsOnMethods = {"testInsertTargetPool2"})
|
@Test(groups = "live", dependsOnMethods = {"testInsertTargetPool2"})
|
||||||
public void testListBackupTargetPool() {
|
public void testListBackupTargetPool() {
|
||||||
TargetPoolCreationOptions options = new TargetPoolCreationOptions().description("A targetPool for testing setBackup.");
|
TargetPoolCreationOptions options = new TargetPoolCreationOptions.Builder(THIRD_TARGETPOOL_NAME)
|
||||||
assertOperationDoneSuccessfully(api().create(THIRD_TARGETPOOL_NAME, options));
|
.description("A targetPool for testing setBackup.").build();
|
||||||
|
assertOperationDoneSuccessfully(api().create(options));
|
||||||
TargetPool targetPool = api().get(THIRD_TARGETPOOL_NAME);
|
TargetPool targetPool = api().get(THIRD_TARGETPOOL_NAME);
|
||||||
assertNotNull(targetPool);
|
assertNotNull(targetPool);
|
||||||
assertEquals(targetPool.name(), THIRD_TARGETPOOL_NAME);
|
assertEquals(targetPool.name(), THIRD_TARGETPOOL_NAME);
|
||||||
|
|
|
@ -54,8 +54,8 @@ public class TargetPoolApiMockTest extends BaseGoogleComputeEngineApiMockTest {
|
||||||
public void insert() throws Exception {
|
public void insert() throws Exception {
|
||||||
server.enqueue(jsonResponse("/region_operation.json"));
|
server.enqueue(jsonResponse("/region_operation.json"));
|
||||||
|
|
||||||
TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions();
|
TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions.Builder("test").build();
|
||||||
assertEquals(targetPoolApi().create("test", targetPoolCreationOptions),
|
assertEquals(targetPoolApi().create(targetPoolCreationOptions),
|
||||||
new ParseRegionOperationTest().expected(url("/projects")));
|
new ParseRegionOperationTest().expected(url("/projects")));
|
||||||
assertSent(server, "POST", "/projects/party/regions/us-central1/targetPools",
|
assertSent(server, "POST", "/projects/party/regions/us-central1/targetPools",
|
||||||
stringFromResource("/targetpool_insert.json"));
|
stringFromResource("/targetpool_insert.json"));
|
||||||
|
|
|
@ -58,8 +58,8 @@ public class UrlMapApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
||||||
.healthChecks(healthChecks);
|
.healthChecks(healthChecks);
|
||||||
assertOperationDoneSuccessfully(api.backendServices().create(b));
|
assertOperationDoneSuccessfully(api.backendServices().create(b));
|
||||||
|
|
||||||
UrlMapOptions map = new UrlMapOptions().name(URL_MAP_NAME).description("simple url map")
|
UrlMapOptions map = new UrlMapOptions.Builder().name(URL_MAP_NAME).description("simple url map")
|
||||||
.defaultService(getBackendServiceUrl(URL_MAP_BACKEND_SERVICE_NAME));
|
.defaultService(getBackendServiceUrl(URL_MAP_BACKEND_SERVICE_NAME)).build();
|
||||||
|
|
||||||
assertOperationDoneSuccessfully(api().create(map));
|
assertOperationDoneSuccessfully(api().create(map));
|
||||||
|
|
||||||
|
@ -100,11 +100,11 @@ public class UrlMapApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
||||||
|
|
||||||
ImmutableList<String> hosts = ImmutableList.<String>of("jclouds-test");
|
ImmutableList<String> hosts = ImmutableList.<String>of("jclouds-test");
|
||||||
ImmutableList<HostRule> hostRules = ImmutableList.<HostRule>of(HostRule.create("", hosts, "test-path-matcher"));
|
ImmutableList<HostRule> hostRules = ImmutableList.<HostRule>of(HostRule.create("", hosts, "test-path-matcher"));
|
||||||
UrlMapOptions options = new UrlMapOptions().name(URL_MAP_NAME)
|
UrlMapOptions options = new UrlMapOptions.Builder().name(URL_MAP_NAME)
|
||||||
.pathMatchers(matchers)
|
.pathMatchers(matchers)
|
||||||
.hostRules(hostRules)
|
.hostRules(hostRules)
|
||||||
.defaultService(service)
|
.defaultService(service)
|
||||||
.fingerprint(fingerprint);
|
.fingerprint(fingerprint).build();
|
||||||
|
|
||||||
assertOperationDoneSuccessfully(api().update(URL_MAP_NAME, options));
|
assertOperationDoneSuccessfully(api().update(URL_MAP_NAME, options));
|
||||||
|
|
||||||
|
@ -119,8 +119,8 @@ public class UrlMapApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
||||||
UrlMapTest urlMapTest = UrlMapTest.create(null, "jclouds-test", "/test/path", service);
|
UrlMapTest urlMapTest = UrlMapTest.create(null, "jclouds-test", "/test/path", service);
|
||||||
ImmutableList<UrlMap.UrlMapTest> urlMapTests = ImmutableList.<UrlMap.UrlMapTest>of(urlMapTest);
|
ImmutableList<UrlMap.UrlMapTest> urlMapTests = ImmutableList.<UrlMap.UrlMapTest>of(urlMapTest);
|
||||||
|
|
||||||
UrlMapOptions options = new UrlMapOptions().urlMapTests(urlMapTests)
|
UrlMapOptions options = new UrlMapOptions.Builder().tests(urlMapTests)
|
||||||
.fingerprint(fingerprint);
|
.fingerprint(fingerprint).buildForPatch();
|
||||||
assertOperationDoneSuccessfully(api().patch(URL_MAP_NAME, options));
|
assertOperationDoneSuccessfully(api().patch(URL_MAP_NAME, options));
|
||||||
|
|
||||||
// Update options with settings it should have for later assertions.
|
// Update options with settings it should have for later assertions.
|
||||||
|
@ -132,11 +132,15 @@ public class UrlMapApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
||||||
|
|
||||||
ImmutableList<String> hosts = ImmutableList.<String>of("jclouds-test");
|
ImmutableList<String> hosts = ImmutableList.<String>of("jclouds-test");
|
||||||
ImmutableList<HostRule> hostRules = ImmutableList.<HostRule>of(HostRule.create("", hosts, "test-path-matcher"));
|
ImmutableList<HostRule> hostRules = ImmutableList.<HostRule>of(HostRule.create("", hosts, "test-path-matcher"));
|
||||||
options.name(URL_MAP_NAME)
|
|
||||||
|
options = new UrlMapOptions.Builder().name(URL_MAP_NAME)
|
||||||
.description("simple url map")
|
.description("simple url map")
|
||||||
.pathMatchers(matchers)
|
.pathMatchers(matchers)
|
||||||
.hostRules(hostRules)
|
.hostRules(hostRules)
|
||||||
.defaultService(service);
|
.defaultService(service)
|
||||||
|
.tests(urlMapTests)
|
||||||
|
.fingerprint(fingerprint)
|
||||||
|
.build();
|
||||||
|
|
||||||
assertUrlMapEquals(api().get(URL_MAP_NAME), options);
|
assertUrlMapEquals(api().get(URL_MAP_NAME), options);
|
||||||
}
|
}
|
||||||
|
@ -163,14 +167,14 @@ public class UrlMapApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
||||||
UrlMapTest urlMapTest = UrlMapTest.create(null, "jclouds-test", "/test/path", service);
|
UrlMapTest urlMapTest = UrlMapTest.create(null, "jclouds-test", "/test/path", service);
|
||||||
ImmutableList<UrlMap.UrlMapTest> urlMapTests = ImmutableList.<UrlMap.UrlMapTest>of(urlMapTest);
|
ImmutableList<UrlMap.UrlMapTest> urlMapTests = ImmutableList.<UrlMap.UrlMapTest>of(urlMapTest);
|
||||||
|
|
||||||
UrlMapOptions options = new UrlMapOptions();
|
UrlMapOptions options = new UrlMapOptions.Builder()
|
||||||
|
.pathMatchers(matchers)
|
||||||
options.pathMatchers(matchers)
|
|
||||||
.name(URL_MAP_NAME)
|
.name(URL_MAP_NAME)
|
||||||
.hostRules(hostRules)
|
.hostRules(hostRules)
|
||||||
.urlMapTests(urlMapTests)
|
.tests(urlMapTests)
|
||||||
.defaultService(service)
|
.defaultService(service)
|
||||||
.description("simple url map");
|
.description("simple url map")
|
||||||
|
.build();
|
||||||
|
|
||||||
UrlMapValidateResult results = api().validate(URL_MAP_NAME, options);
|
UrlMapValidateResult results = api().validate(URL_MAP_NAME, options);
|
||||||
UrlMapValidateResult expected = UrlMapValidateResult.allPass();
|
UrlMapValidateResult expected = UrlMapValidateResult.allPass();
|
||||||
|
@ -196,9 +200,9 @@ public class UrlMapApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertUrlMapEquals(UrlMap result, UrlMapOptions expected) {
|
private void assertUrlMapEquals(UrlMap result, UrlMapOptions expected) {
|
||||||
assertEquals(result.name(), expected.getName());
|
assertEquals(result.name(), expected.name());
|
||||||
assertEquals(result.defaultService(), expected.getDefaultService());
|
assertEquals(result.defaultService(), expected.defaultService());
|
||||||
assertEquals(result.pathMatchers(), expected.getPathMatchers());
|
assertEquals(result.pathMatchers(), expected.pathMatchers());
|
||||||
assertEquals(result.hostRules(), expected.getHostRules());
|
assertEquals(result.hostRules(), expected.hostRules());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,17 +119,18 @@ public class UrlMapApiMockTest extends BaseGoogleComputeEngineApiMockTest {
|
||||||
|
|
||||||
private UrlMapOptions createBasicMap() {
|
private UrlMapOptions createBasicMap() {
|
||||||
URI service = URI.create(url("/projects/myproject/global/backendServices/jclouds-test"));
|
URI service = URI.create(url("/projects/myproject/global/backendServices/jclouds-test"));
|
||||||
return new UrlMapOptions().name("jclouds-test")
|
return new UrlMapOptions.Builder().name("jclouds-test")
|
||||||
.description("Sample url map")
|
.description("Sample url map")
|
||||||
.hostRule(HostRule.create(null, ImmutableList.of("jclouds-test"), "path"))
|
.hostRules(ImmutableList.of(HostRule.create(null, ImmutableList.of("jclouds-test"), "path")))
|
||||||
.pathMatcher(PathMatcher.create("path",
|
.pathMatchers(ImmutableList.of(PathMatcher.create("path",
|
||||||
null,
|
null,
|
||||||
service,
|
service,
|
||||||
ImmutableList.of(
|
ImmutableList.of(
|
||||||
PathRule.create(ImmutableList.of("/"),
|
PathRule.create(ImmutableList.of("/"),
|
||||||
service))))
|
service)))))
|
||||||
.test(UrlMap.UrlMapTest.create(null, "jclouds-test", "/test/path", service))
|
.tests(ImmutableList.of(UrlMap.UrlMapTest.create(null, "jclouds-test", "/test/path", service)))
|
||||||
.defaultService(service);
|
.defaultService(service)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
UrlMapApi urlMapApi() {
|
UrlMapApi urlMapApi() {
|
||||||
|
|
|
@ -1 +1,4 @@
|
||||||
{"name":"jclouds-test","urlMap":"https://www.googleapis.com/compute/v1/projects/myproject/global/urlMaps/jclouds-test"}
|
{
|
||||||
|
"name": "jclouds-test",
|
||||||
|
"urlMap": "https://www.googleapis.com/compute/v1/projects/myproject/global/urlMaps/jclouds-test"
|
||||||
|
}
|
Loading…
Reference in New Issue