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")
|
||||
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.
|
||||
*
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.jclouds.googlecloud.domain.ListPage;
|
|||
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
|
||||
import org.jclouds.googlecomputeengine.binders.TargetPoolChangeHealthChecksBinder;
|
||||
import org.jclouds.googlecomputeengine.binders.TargetPoolChangeInstancesBinder;
|
||||
import org.jclouds.googlecomputeengine.binders.TargetPoolCreationBinder;
|
||||
import org.jclouds.googlecomputeengine.domain.HealthStatus;
|
||||
import org.jclouds.googlecomputeengine.domain.Operation;
|
||||
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.javax.annotation.Nullable;
|
||||
import org.jclouds.oauth.v2.filters.OAuthFilter;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.Fallback;
|
||||
import org.jclouds.rest.annotations.MapBinder;
|
||||
import org.jclouds.rest.annotations.PayloadParam;
|
||||
|
@ -82,8 +82,7 @@ public interface TargetPoolApi {
|
|||
@Named("TargetPools:insert")
|
||||
@POST
|
||||
@Produces(APPLICATION_JSON)
|
||||
@MapBinder(TargetPoolCreationBinder.class)
|
||||
Operation create(@PayloadParam("name") String name, @PayloadParam("options") TargetPoolCreationOptions options);
|
||||
Operation create(@BinderParam(BindToJsonPayload.class) TargetPoolCreationOptions options);
|
||||
|
||||
/** Deletes a target pool by name and returns the operation in progress, or null if not found. */
|
||||
@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.
|
||||
* Note:{@link UrlMapOptions.Builder#buildForPatch()} may be helpful.
|
||||
*
|
||||
* @param urlMapName the name urlMap to be updated.
|
||||
* @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
|
||||
* unspecified values with the default values.
|
||||
*/
|
||||
public HttpHealthCheckCreationOptions buildNoDefaults() {
|
||||
public HttpHealthCheckCreationOptions buildForPatch() {
|
||||
return HttpHealthCheckCreationOptions.create(host, requestPath, port,
|
||||
checkIntervalSec, timeoutSec, unhealthyThreshold, healthyThreshold, description);
|
||||
}
|
||||
|
|
|
@ -16,60 +16,52 @@
|
|||
*/
|
||||
package org.jclouds.googlecomputeengine.options;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.json.SerializedNames;
|
||||
|
||||
public final class TargetHttpProxyOptions {
|
||||
import com.google.auto.value.AutoValue;
|
||||
|
||||
private String name;
|
||||
@Nullable private String description;
|
||||
private URI urlMap;
|
||||
@AutoValue
|
||||
public abstract class TargetHttpProxyOptions {
|
||||
|
||||
/**
|
||||
* Name of the TargetHttpProxy resource.
|
||||
* @return name, provided by the client.
|
||||
*/
|
||||
public String getName(){
|
||||
return name;
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TargetHttpProxyOptions#getName()
|
||||
*/
|
||||
public TargetHttpProxyOptions name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
TargetHttpProxyOptions() {
|
||||
}
|
||||
|
||||
/**
|
||||
* An optional textual description of the TargetHttpProxy.
|
||||
* @return description, provided by the client.
|
||||
*/
|
||||
public String getDescription(){
|
||||
return description;
|
||||
}
|
||||
public static class Builder {
|
||||
private String name;
|
||||
private String description;
|
||||
private URI urlMap;
|
||||
|
||||
/**
|
||||
* @see TargetHttpProxyOptions#getDescription()
|
||||
*/
|
||||
public TargetHttpProxyOptions description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
public Builder(String name, URI urlMap) {
|
||||
this.name = name;
|
||||
this.urlMap = urlMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* URL to the UrlMap resource that defines the mapping from URL to the BackendService.
|
||||
*/
|
||||
public URI getUrlMap() {
|
||||
return urlMap;
|
||||
}
|
||||
/**
|
||||
* @see TargetHttpProxyOptions#getDescription()
|
||||
*/
|
||||
public Builder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TargetHttpProxyOptions#getUrlMap()
|
||||
*/
|
||||
public TargetHttpProxyOptions urlMap(URI urlMap) {
|
||||
this.urlMap = urlMap;
|
||||
return this;
|
||||
public TargetHttpProxyOptions build() {
|
||||
checkNotNull(name, "TargetHttpProxyOptions name cannot be null");
|
||||
checkNotNull(urlMap, "TargetHttpProxyOptions name cannot be null");
|
||||
return create(name, description, urlMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,14 +16,21 @@
|
|||
*/
|
||||
package org.jclouds.googlecomputeengine.options;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
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
|
||||
*
|
||||
*/
|
||||
public class TargetPoolCreationOptions{
|
||||
@AutoValue
|
||||
public abstract class TargetPoolCreationOptions{
|
||||
|
||||
/**
|
||||
* Session affinity determines the hash method that
|
||||
|
@ -36,116 +43,100 @@ public class TargetPoolCreationOptions{
|
|||
NONE
|
||||
}
|
||||
|
||||
private List<URI> healthChecks;
|
||||
private List<URI> instances;
|
||||
private SessionAffinityValue sessionAffinity;
|
||||
private Float failoverRatio;
|
||||
private URI backupPool;
|
||||
private String description;
|
||||
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();
|
||||
|
||||
/**
|
||||
* The set of HealthChecks
|
||||
*
|
||||
* @return a set of HealthCheck URIs
|
||||
*/
|
||||
public List<URI> getHealthChecks(){
|
||||
return healthChecks;
|
||||
@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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return set of instance URIs
|
||||
*/
|
||||
public List<URI> getInstances(){
|
||||
return instances;
|
||||
TargetPoolCreationOptions() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the session affinity option.
|
||||
* Session affinity determines the hash method that Google Compute Engine uses to distribute traffic.
|
||||
* @return
|
||||
*/
|
||||
public SessionAffinityValue getSessionAffinity(){
|
||||
return sessionAffinity;
|
||||
}
|
||||
public static class Builder {
|
||||
|
||||
/**
|
||||
* 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).
|
||||
* The value of the a float between [0, 1].
|
||||
* If set, backupPool must also be set.
|
||||
* @return failoverRatio, a float between [0, 1]
|
||||
*/
|
||||
public Float getFailoverRatio(){
|
||||
return failoverRatio;
|
||||
}
|
||||
private String name;
|
||||
private List<URI> healthChecks;
|
||||
private List<URI> instances;
|
||||
private SessionAffinityValue sessionAffinity;
|
||||
private Float failoverRatio;
|
||||
private URI backupPool;
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* If set, failoverRatio must also be set
|
||||
* @return backupPool, Fully-qualified URI to a target pool in the same region as primary target pool
|
||||
*/
|
||||
public URI getBackupPool(){
|
||||
return backupPool;
|
||||
}
|
||||
public Builder(String name){
|
||||
checkNotNull(name, "TargetPoolCreationOptions name cannot be null");
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* An optional textual description of the TargetPool.
|
||||
* @return description, provided by the client.
|
||||
*/
|
||||
public String getDescription(){
|
||||
return description;
|
||||
}
|
||||
/** The set of HealthChecks */
|
||||
public Builder healthChecks(List<URI> healthChecks){
|
||||
this.healthChecks = healthChecks;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TargetPoolCreationOptions#getHealthChecks()
|
||||
*/
|
||||
public TargetPoolCreationOptions healthChecks(List<URI> healthChecks){
|
||||
this.healthChecks = healthChecks;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public Builder instances(List<URI> instances){
|
||||
this.instances = instances;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TargetPoolCreationOptions#getInstances()
|
||||
*/
|
||||
public TargetPoolCreationOptions instances(List<URI> instances){
|
||||
this.instances = instances;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Defines the session affinity option.
|
||||
* Session affinity determines the hash method that Google Compute Engine uses to distribute traffic.
|
||||
*/
|
||||
public Builder sessionAffinity(SessionAffinityValue sessionAffinity){
|
||||
this.sessionAffinity = sessionAffinity;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TargetPoolCreationOptions#getSessionAffinity()
|
||||
*/
|
||||
public TargetPoolCreationOptions sessionAffinity(SessionAffinityValue sessionAffinity){
|
||||
this.sessionAffinity = sessionAffinity;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* 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).
|
||||
* The value of the a float between [0, 1].
|
||||
* If set, backupPool must also be set.
|
||||
* @return failoverRatio, a float between [0, 1]
|
||||
*/
|
||||
public Builder failoverRatio(float failoverRatio){
|
||||
this.failoverRatio = failoverRatio;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TargetPoolCreationOptions#getFailoverRatio()
|
||||
*/
|
||||
public TargetPoolCreationOptions failoverRatio(float failoverRatio){
|
||||
this.failoverRatio = failoverRatio;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
* If set, failoverRatio must also be set
|
||||
* @return backupPool, Fully-qualified URI to a target pool in the same region as primary target pool
|
||||
*/
|
||||
public Builder backupPool(URI backupPool){
|
||||
this.backupPool = backupPool;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TargetPoolCreationOptions#getBackupPool()
|
||||
*/
|
||||
public TargetPoolCreationOptions backupPool(URI backupPool){
|
||||
this.backupPool = backupPool;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* An optional textual description of the TargetPool.
|
||||
* @return description, provided by the client.
|
||||
*/
|
||||
public Builder description(String description){
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TargetPoolCreationOptions#getDescription()
|
||||
*/
|
||||
public TargetPoolCreationOptions description(String description){
|
||||
this.description = description;
|
||||
return this;
|
||||
public TargetPoolCreationOptions build() {
|
||||
return create(name, healthChecks, instances, sessionAffinity, failoverRatio,
|
||||
backupPool, description);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
*/
|
||||
package org.jclouds.googlecomputeengine.options;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -23,151 +25,121 @@ import org.jclouds.googlecomputeengine.domain.UrlMap.HostRule;
|
|||
import org.jclouds.googlecomputeengine.domain.UrlMap.PathMatcher;
|
||||
import org.jclouds.googlecomputeengine.domain.UrlMap.UrlMapTest;
|
||||
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 {
|
||||
|
||||
private String name;
|
||||
@Nullable private String description;
|
||||
private List<HostRule> hostRules;
|
||||
private List<PathMatcher> pathMatchers;
|
||||
private List<UrlMapTest> tests;
|
||||
private URI defaultService;
|
||||
private String fingerprint;
|
||||
@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();
|
||||
|
||||
/**
|
||||
* Name of the UrlMap resource.
|
||||
* @return name, provided by the client.
|
||||
*/
|
||||
public String getName(){
|
||||
return name;
|
||||
@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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UrlMapOptions#getName()
|
||||
*/
|
||||
public UrlMapOptions name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
UrlMapOptions(){
|
||||
}
|
||||
|
||||
/**
|
||||
* An optional textual description of the UrlMap.
|
||||
* @return description, provided by the client.
|
||||
*/
|
||||
public String getDescription(){
|
||||
return description;
|
||||
}
|
||||
public static class Builder {
|
||||
|
||||
/**
|
||||
* @see UrlMapOptions#getDescription()
|
||||
*/
|
||||
public UrlMapOptions description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
private String name;
|
||||
private String description;
|
||||
private List<HostRule> hostRules;
|
||||
private List<PathMatcher> pathMatchers;
|
||||
private List<UrlMapTest> tests;
|
||||
private URI defaultService;
|
||||
private String fingerprint;
|
||||
|
||||
/**
|
||||
* Rules for matching and directing incoming hosts.
|
||||
*/
|
||||
public List<HostRule> getHostRules() {
|
||||
return hostRules;
|
||||
}
|
||||
/**
|
||||
* Name of the UrlMap resource.
|
||||
*/
|
||||
public Builder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UrlMapOptions#getHostRules()
|
||||
*/
|
||||
public UrlMapOptions hostRules(List<HostRule> hostRules) {
|
||||
this.hostRules = hostRules;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* An optional textual description of the UrlMap.
|
||||
*/
|
||||
public Builder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UrlMapOptions#getHostRules()
|
||||
*/
|
||||
public UrlMapOptions hostRule(HostRule hostRule){
|
||||
this.hostRules = ImmutableList.of(hostRule);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Rules for matching and directing incoming hosts.
|
||||
*/
|
||||
public Builder hostRules(List<HostRule> hostRules) {
|
||||
this.hostRules = hostRules;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The list of named PathMatchers to use against the URL.
|
||||
*/
|
||||
public List<PathMatcher> getPathMatchers() {
|
||||
return pathMatchers;
|
||||
}
|
||||
/**
|
||||
* The list of named PathMatchers to use against the URL.
|
||||
*/
|
||||
public Builder pathMatchers(List<PathMatcher> pathMatchers) {
|
||||
this.pathMatchers = pathMatchers;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UrlMapOptions#getPathMatchers()
|
||||
*/
|
||||
public UrlMapOptions pathMatcher(PathMatcher pathMatcher) {
|
||||
this.pathMatchers = ImmutableList.of(pathMatcher);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* The list of expected URL mappings. Request to update this
|
||||
* UrlMap will succeed only all of the test cases pass.
|
||||
*/
|
||||
public Builder tests(List<UrlMapTest> tests) {
|
||||
this.tests = tests;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UrlMapOptions#getPathMatchers()
|
||||
*/
|
||||
public UrlMapOptions pathMatchers(List<PathMatcher> pathMatchers) {
|
||||
this.pathMatchers = pathMatchers;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* The URL of the BackendService resource if none of the hostRules match.
|
||||
*/
|
||||
public Builder defaultService(URI defaultService) {
|
||||
this.defaultService = defaultService;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The list of expected URL mappings. Request to update this
|
||||
* UrlMap will succeed only all of the test cases pass.
|
||||
*/
|
||||
public List<UrlMapTest> getTests() {
|
||||
return tests;
|
||||
}
|
||||
/**
|
||||
* Fingerprint of this resource. A hash of the contents stored in this object.
|
||||
* This field is used in optimistic locking. This field will be ignored when
|
||||
* inserting a UrlMap. An up-to-date fingerprint must be provided in order to
|
||||
* update the UrlMap.
|
||||
*/
|
||||
public Builder fingerprint(String fingerprint) {
|
||||
this.fingerprint = fingerprint;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UrlMapOptions#getTests()
|
||||
*/
|
||||
public UrlMapOptions test(UrlMapTest urlMapTest) {
|
||||
this.tests = ImmutableList.of(urlMapTest);
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UrlMapOptions#getTests()
|
||||
*/
|
||||
public UrlMapOptions urlMapTests(List<UrlMapTest> urlMapTests) {
|
||||
this.tests = urlMapTests;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The URL of the BackendService resource if none of the hostRules match.
|
||||
*/
|
||||
public URI getDefaultService() {
|
||||
return defaultService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UrlMapOptions#getDefaultService()
|
||||
*/
|
||||
public UrlMapOptions defaultService(URI defaultService) {
|
||||
this.defaultService = defaultService;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fingerprint of this resource. A hash of the contents stored in this object.
|
||||
* This field is used in optimistic locking. This field will be ignored when
|
||||
* inserting a UrlMap. An up-to-date fingerprint must be provided in order to
|
||||
* update the UrlMap.
|
||||
*/
|
||||
public String getFingerprint() {
|
||||
return fingerprint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see UrlMapOptions#getFingerprint()
|
||||
*/
|
||||
public UrlMapOptions fingerprint(String fingerprint) {
|
||||
this.fingerprint = fingerprint;
|
||||
return this;
|
||||
/**
|
||||
* 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
|
||||
public void init() {
|
||||
TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions();
|
||||
assertOperationDoneSuccessfully(targetPoolApi().create(TARGETPOOL_NAME, targetPoolCreationOptions));
|
||||
TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions.Builder(TARGETPOOL_NAME).build();
|
||||
assertOperationDoneSuccessfully(targetPoolApi().create(targetPoolCreationOptions));
|
||||
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);
|
||||
|
||||
assertOperationDoneSuccessfully(addressApi().create(ADDRESS_NAME));
|
||||
|
|
|
@ -66,9 +66,9 @@ public class GlobalForwardingRuleApiLiveTest extends BaseGoogleComputeEngineApiL
|
|||
assertOperationDoneSuccessfully(api.backendServices()
|
||||
.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")
|
||||
.defaultService(getBackendServiceUrl(GLOBAL_FORWARDING_RULE_BACKEND_SERVICE_NAME));
|
||||
.defaultService(getBackendServiceUrl(GLOBAL_FORWARDING_RULE_BACKEND_SERVICE_NAME)).build();
|
||||
assertOperationDoneSuccessfully(api.urlMaps()
|
||||
.create(map));
|
||||
assertOperationDoneSuccessfully(api.targetHttpProxies()
|
||||
|
|
|
@ -78,7 +78,7 @@ public class HttpHealthCheckApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
|
|||
.port(options.port() + OFFSET)
|
||||
.checkIntervalSec(options.checkIntervalSec() + OFFSET)
|
||||
.timeoutSec(options.timeoutSec() + OFFSET)
|
||||
.buildNoDefaults();
|
||||
.buildForPatch();
|
||||
assertOperationDoneSuccessfully(api().patch(HTTP_HEALTH_CHECK_NAME, newOptions));
|
||||
|
||||
// Check changes happened and others unchanged.
|
||||
|
|
|
@ -91,7 +91,7 @@ public class HttpHealthCheckApiMockTest extends BaseGoogleComputeEngineApiMockTe
|
|||
server.enqueue(jsonResponse("/global_operation.json"));
|
||||
|
||||
HttpHealthCheckCreationOptions options = new HttpHealthCheckCreationOptions.Builder()
|
||||
.timeoutSec(0).unhealthyThreshold(0).buildNoDefaults();
|
||||
.timeoutSec(0).unhealthyThreshold(0).buildForPatch();
|
||||
assertEquals(httpHealthCheckApi().patch("http-health-check", options),
|
||||
new ParseGlobalOperationTest().expected(url("/projects")));
|
||||
|
||||
|
|
|
@ -57,12 +57,14 @@ public class TargetHttpProxyApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
|
|||
|
||||
assertOperationDoneSuccessfully(api.backendServices().create(b));
|
||||
|
||||
UrlMapOptions map = new UrlMapOptions().name(TARGET_HTTP_PROXY_URL_MAP_NAME).description("simple url map")
|
||||
.defaultService(getBackendServiceUrl(URL_MAP_DEFAULT_SERVICE_NAME));
|
||||
UrlMapOptions map = new UrlMapOptions.Builder().name(TARGET_HTTP_PROXY_URL_MAP_NAME).description("simple url map")
|
||||
.defaultService(getBackendServiceUrl(URL_MAP_DEFAULT_SERVICE_NAME)).build();
|
||||
assertOperationDoneSuccessfully(api.urlMaps().create(map));
|
||||
|
||||
UrlMapOptions map2 = new UrlMapOptions().name(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2").description("a second simple url map")
|
||||
.defaultService(getBackendServiceUrl(URL_MAP_DEFAULT_SERVICE_NAME));
|
||||
UrlMapOptions map2 = new UrlMapOptions.Builder().name(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2")
|
||||
.description("a second simple url map")
|
||||
.defaultService(getBackendServiceUrl(URL_MAP_DEFAULT_SERVICE_NAME))
|
||||
.build();
|
||||
assertOperationDoneSuccessfully(api.urlMaps().create(map2));
|
||||
|
||||
|
||||
|
@ -78,13 +80,8 @@ public class TargetHttpProxyApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
|
|||
|
||||
@Test(groups = "live", dependsOnMethods = "testGetTargetHttpProxy")
|
||||
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,
|
||||
getUrlMapUrl(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2")));
|
||||
getUrlMapUrl(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2")));
|
||||
}
|
||||
|
||||
@Test(groups = "live", dependsOnMethods = "testSetUrlMapTargetHttpProxy")
|
||||
|
@ -97,7 +94,7 @@ public class TargetHttpProxyApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
|
|||
getUrlMapUrl(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2"));
|
||||
}
|
||||
|
||||
@Test(groups = "live", dependsOnMethods = "testListTargetHttpProxy")
|
||||
@Test(groups = "live", dependsOnMethods = "testListTargetHttpProxy", alwaysRun = true)
|
||||
public void testDeleteTargetHttpProxy() {
|
||||
assertOperationDoneSuccessfully(api().delete(TARGET_HTTP_PROXY_NAME));
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import static org.testng.AssertJUnit.assertNull;
|
|||
import java.net.URI;
|
||||
|
||||
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiMockTest;
|
||||
import org.jclouds.googlecomputeengine.options.TargetHttpProxyOptions;
|
||||
import org.jclouds.googlecomputeengine.parse.ParseOperationTest;
|
||||
import org.jclouds.googlecomputeengine.parse.ParseTargetHttpProxyListTest;
|
||||
import org.jclouds.googlecomputeengine.parse.ParseTargetHttpProxyTest;
|
||||
|
@ -55,6 +56,20 @@ public class TargetHttpProxyApiMockTest extends BaseGoogleComputeEngineApiMockTe
|
|||
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 {
|
||||
server.enqueue(jsonResponse("/operation.json"));
|
||||
|
||||
|
|
|
@ -126,10 +126,11 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
|
||||
@Test(groups = "live")
|
||||
public void testInsertTargetPool() {
|
||||
TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions()
|
||||
TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions.Builder(BACKUP_TARGETPOOL_NAME)
|
||||
.description(DESCRIPTION_BACKUP)
|
||||
.sessionAffinity(SessionAffinityValue.CLIENT_IP);
|
||||
assertOperationDoneSuccessfully(api().create(BACKUP_TARGETPOOL_NAME, targetPoolCreationOptions));
|
||||
.sessionAffinity(SessionAffinityValue.CLIENT_IP)
|
||||
.build();
|
||||
assertOperationDoneSuccessfully(api().create(targetPoolCreationOptions));
|
||||
}
|
||||
|
||||
@Test(groups = "live", dependsOnMethods = "testInsertTargetPool")
|
||||
|
@ -137,12 +138,13 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
TargetPool targetPool = api().get(BACKUP_TARGETPOOL_NAME);
|
||||
assertNotNull(targetPool);
|
||||
// Make a Target Pool with a backup and failoverRatio specified.
|
||||
TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions()
|
||||
TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions.Builder(TARGETPOOL_NAME)
|
||||
.description(DESCRIPTION)
|
||||
.sessionAffinity(SessionAffinityValue.CLIENT_IP)
|
||||
.backupPool(targetPool.selfLink())
|
||||
.failoverRatio((float) 0.5);
|
||||
assertOperationDoneSuccessfully(api().create(TARGETPOOL_NAME, targetPoolCreationOptions));
|
||||
.failoverRatio((float) 0.5)
|
||||
.build();
|
||||
assertOperationDoneSuccessfully(api().create(targetPoolCreationOptions));
|
||||
TargetPool targetPool2 = api().get(TARGETPOOL_NAME);
|
||||
assertNotNull(targetPool2);
|
||||
assertEquals(targetPool2.name(), TARGETPOOL_NAME);
|
||||
|
@ -222,8 +224,9 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
|
||||
@Test(groups = "live", dependsOnMethods = {"testInsertTargetPool2"})
|
||||
public void testListBackupTargetPool() {
|
||||
TargetPoolCreationOptions options = new TargetPoolCreationOptions().description("A targetPool for testing setBackup.");
|
||||
assertOperationDoneSuccessfully(api().create(THIRD_TARGETPOOL_NAME, options));
|
||||
TargetPoolCreationOptions options = new TargetPoolCreationOptions.Builder(THIRD_TARGETPOOL_NAME)
|
||||
.description("A targetPool for testing setBackup.").build();
|
||||
assertOperationDoneSuccessfully(api().create(options));
|
||||
TargetPool targetPool = api().get(THIRD_TARGETPOOL_NAME);
|
||||
assertNotNull(targetPool);
|
||||
assertEquals(targetPool.name(), THIRD_TARGETPOOL_NAME);
|
||||
|
|
|
@ -54,8 +54,8 @@ public class TargetPoolApiMockTest extends BaseGoogleComputeEngineApiMockTest {
|
|||
public void insert() throws Exception {
|
||||
server.enqueue(jsonResponse("/region_operation.json"));
|
||||
|
||||
TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions();
|
||||
assertEquals(targetPoolApi().create("test", targetPoolCreationOptions),
|
||||
TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions.Builder("test").build();
|
||||
assertEquals(targetPoolApi().create(targetPoolCreationOptions),
|
||||
new ParseRegionOperationTest().expected(url("/projects")));
|
||||
assertSent(server, "POST", "/projects/party/regions/us-central1/targetPools",
|
||||
stringFromResource("/targetpool_insert.json"));
|
||||
|
|
|
@ -58,8 +58,8 @@ public class UrlMapApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
.healthChecks(healthChecks);
|
||||
assertOperationDoneSuccessfully(api.backendServices().create(b));
|
||||
|
||||
UrlMapOptions map = new UrlMapOptions().name(URL_MAP_NAME).description("simple url map")
|
||||
.defaultService(getBackendServiceUrl(URL_MAP_BACKEND_SERVICE_NAME));
|
||||
UrlMapOptions map = new UrlMapOptions.Builder().name(URL_MAP_NAME).description("simple url map")
|
||||
.defaultService(getBackendServiceUrl(URL_MAP_BACKEND_SERVICE_NAME)).build();
|
||||
|
||||
assertOperationDoneSuccessfully(api().create(map));
|
||||
|
||||
|
@ -100,11 +100,11 @@ public class UrlMapApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
|
||||
ImmutableList<String> hosts = ImmutableList.<String>of("jclouds-test");
|
||||
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)
|
||||
.hostRules(hostRules)
|
||||
.defaultService(service)
|
||||
.fingerprint(fingerprint);
|
||||
.fingerprint(fingerprint).build();
|
||||
|
||||
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);
|
||||
ImmutableList<UrlMap.UrlMapTest> urlMapTests = ImmutableList.<UrlMap.UrlMapTest>of(urlMapTest);
|
||||
|
||||
UrlMapOptions options = new UrlMapOptions().urlMapTests(urlMapTests)
|
||||
.fingerprint(fingerprint);
|
||||
UrlMapOptions options = new UrlMapOptions.Builder().tests(urlMapTests)
|
||||
.fingerprint(fingerprint).buildForPatch();
|
||||
assertOperationDoneSuccessfully(api().patch(URL_MAP_NAME, options));
|
||||
|
||||
// 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<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")
|
||||
.pathMatchers(matchers)
|
||||
.hostRules(hostRules)
|
||||
.defaultService(service);
|
||||
.defaultService(service)
|
||||
.tests(urlMapTests)
|
||||
.fingerprint(fingerprint)
|
||||
.build();
|
||||
|
||||
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);
|
||||
ImmutableList<UrlMap.UrlMapTest> urlMapTests = ImmutableList.<UrlMap.UrlMapTest>of(urlMapTest);
|
||||
|
||||
UrlMapOptions options = new UrlMapOptions();
|
||||
|
||||
options.pathMatchers(matchers)
|
||||
UrlMapOptions options = new UrlMapOptions.Builder()
|
||||
.pathMatchers(matchers)
|
||||
.name(URL_MAP_NAME)
|
||||
.hostRules(hostRules)
|
||||
.urlMapTests(urlMapTests)
|
||||
.tests(urlMapTests)
|
||||
.defaultService(service)
|
||||
.description("simple url map");
|
||||
.description("simple url map")
|
||||
.build();
|
||||
|
||||
UrlMapValidateResult results = api().validate(URL_MAP_NAME, options);
|
||||
UrlMapValidateResult expected = UrlMapValidateResult.allPass();
|
||||
|
@ -196,9 +200,9 @@ public class UrlMapApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
}
|
||||
|
||||
private void assertUrlMapEquals(UrlMap result, UrlMapOptions expected) {
|
||||
assertEquals(result.name(), expected.getName());
|
||||
assertEquals(result.defaultService(), expected.getDefaultService());
|
||||
assertEquals(result.pathMatchers(), expected.getPathMatchers());
|
||||
assertEquals(result.hostRules(), expected.getHostRules());
|
||||
assertEquals(result.name(), expected.name());
|
||||
assertEquals(result.defaultService(), expected.defaultService());
|
||||
assertEquals(result.pathMatchers(), expected.pathMatchers());
|
||||
assertEquals(result.hostRules(), expected.hostRules());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,17 +119,18 @@ public class UrlMapApiMockTest extends BaseGoogleComputeEngineApiMockTest {
|
|||
|
||||
private UrlMapOptions createBasicMap() {
|
||||
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")
|
||||
.hostRule(HostRule.create(null, ImmutableList.of("jclouds-test"), "path"))
|
||||
.pathMatcher(PathMatcher.create("path",
|
||||
.hostRules(ImmutableList.of(HostRule.create(null, ImmutableList.of("jclouds-test"), "path")))
|
||||
.pathMatchers(ImmutableList.of(PathMatcher.create("path",
|
||||
null,
|
||||
service,
|
||||
ImmutableList.of(
|
||||
PathRule.create(ImmutableList.of("/"),
|
||||
service))))
|
||||
.test(UrlMap.UrlMapTest.create(null, "jclouds-test", "/test/path", service))
|
||||
.defaultService(service);
|
||||
service)))))
|
||||
.tests(ImmutableList.of(UrlMap.UrlMapTest.create(null, "jclouds-test", "/test/path", service)))
|
||||
.defaultService(service)
|
||||
.build();
|
||||
}
|
||||
|
||||
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