diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java index ab93cbeea..19c364e45 100644 --- a/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/AzureComputeApi.java @@ -30,6 +30,7 @@ import org.jclouds.azurecompute.features.OperationApi; import org.jclouds.azurecompute.features.StorageAccountApi; import org.jclouds.azurecompute.features.SubscriptionApi; +import org.jclouds.azurecompute.features.TrafficManagerApi; import org.jclouds.azurecompute.features.VirtualMachineApi; import org.jclouds.azurecompute.features.VirtualNetworkApi; import org.jclouds.rest.annotations.Delegate; @@ -139,4 +140,13 @@ VirtualMachineApi getVirtualMachineApiForDeploymentInService(@PathParam("deploym */ @Delegate NetworkSecurityGroupApi getNetworkSecurityGroupApi(); + + /** + * The Service Management API includes operations for creating, updating, listing, and deleting Azure Traffic Manager + * profiles and definitions. + * + * @see docs + */ + @Delegate + TrafficManagerApi getTrafficManaerApi(); } diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/ProfileDefinitionParamsToXML.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/ProfileDefinitionParamsToXML.java new file mode 100644 index 000000000..413fe8a9f --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/ProfileDefinitionParamsToXML.java @@ -0,0 +1,79 @@ +/* + * 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.azurecompute.binders; + +import static com.google.common.base.Throwables.propagate; + +import org.jclouds.http.HttpRequest; +import org.jclouds.rest.Binder; + +import com.jamesmurty.utils.XMLBuilder; +import org.jclouds.azurecompute.domain.ProfileDefinitionEndpointParams; +import org.jclouds.azurecompute.domain.ProfileDefinitionParams; + +public final class ProfileDefinitionParamsToXML implements Binder { + + @Override + @SuppressWarnings("unchecked") + public R bindToRequest(final R request, final Object input) { + final ProfileDefinitionParams params = ProfileDefinitionParams.class.cast(input); + try { + XMLBuilder bld = XMLBuilder.create("Definition", "http://schemas.microsoft.com/windowsazure"); + bld.e("DnsOptions").e("TimeToLiveInSeconds").t(params.ttl().toString()).up().up(); + + bld.e("Monitors").e("Monitor").e("IntervalInSeconds").t("30").up() + .e("TimeoutInSeconds").t("10").up() + .e("ToleratedNumberOfFailures").t("3").up() + .e("Protocol").t(params.protocol().name()).up() + .e("Port").t(params.port().toString()).up() + .e("HttpOptions") + .e("Verb").t("GET").up() + .e("RelativePath").t(params.path()).up() + .e("ExpectedStatusCode").t("200"); + + bld = bld.e("Policy").e("LoadBalancingMethod").t(params.lb().getValue()).up() + .e("Endpoints"); + + for (ProfileDefinitionEndpointParams endpoint : params.endpoints()) { + bld = bld.e("Endpoint") + .e("DomainName").t(endpoint.domain()).up() + .e("Status").t(endpoint.status().getValue()).up(); + + if (endpoint.type() != null) { + bld = bld.e("Type").t(endpoint.type().getValue()).up(); + } + if (endpoint.location() != null) { + bld = bld.e("Location").t(endpoint.location()).up(); + } + if (endpoint.min() != null) { + bld = bld.e("MinChildEndpoints").t(endpoint.min().toString()).up(); + } + if (endpoint.weight() != null) { + bld = bld.e("Weight").t(endpoint.weight().toString()).up(); + } + + bld = bld.up(); + } + + bld.up().up(); + + return (R) request.toBuilder().payload(bld.up().asString()).build(); + } catch (Exception e) { + throw propagate(e); + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/binders/ProfileParamsToXML.java b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/ProfileParamsToXML.java new file mode 100644 index 000000000..eb6970dac --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/binders/ProfileParamsToXML.java @@ -0,0 +1,51 @@ +/* + * 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.azurecompute.binders; + +import static com.google.common.base.Throwables.propagate; + +import org.jclouds.http.HttpRequest; +import org.jclouds.rest.Binder; + +import com.jamesmurty.utils.XMLBuilder; +import org.jclouds.azurecompute.domain.CreateProfileParams; +import org.jclouds.azurecompute.domain.UpdateProfileParams; + +public final class ProfileParamsToXML implements Binder { + + @Override + @SuppressWarnings("unchecked") + public R bindToRequest(final R request, final Object input) { + + try { + final XMLBuilder bld = XMLBuilder.create("Profile", "http://schemas.microsoft.com/windowsazure"); + if (input instanceof CreateProfileParams) { + final CreateProfileParams params = CreateProfileParams.class.cast(input); + bld.e("DomainName").t(params.domain()).up(); + bld.e("Name").t(params.name()).up().up(); + return (R) request.toBuilder().payload(bld.up().asString()).build(); + } else { + final UpdateProfileParams params = UpdateProfileParams.class.cast(input); + bld.e("Status").t(params.status().getValue()).up(); + bld.e("StatusDetails").e("EnabledVersion").t("1").up().up().up(); + return (R) request.toBuilder().payload(bld.up().asString()).build(); + } + } catch (Exception e) { + throw propagate(e); + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CreateProfileParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CreateProfileParams.java new file mode 100644 index 000000000..0f2a9a3b8 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/CreateProfileParams.java @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.domain; + +import com.google.auto.value.AutoValue; + +/** + * The Create Profile operation creates a new profile for a domain name, owned by the specified subscription. + * + * @see docs + */ +@AutoValue +public abstract class CreateProfileParams { + + CreateProfileParams() { + } // For AutoValue only! + + /** + * Specifies the name of the domain that the profile is being created for. + * + * A valid DNS name of the form <subdomain name>.trafficmanager.net, conforming to RFC 1123 specification. + * + * Total length of the domain name must be less than or equal to 253 characters. The <subdomain name> can + * contain periods and each label within the subdomain must be less or equal to 63 characters. + * + * @return profile domain name. + */ + public abstract String domain(); + + /** + * Specifies the name of the profile. + * + * The name must be composed of letters, numbers, and hyphens. The maximum length of the profile name is 256 + * characters. Hyphens cannot be the first or last character. + * + * @return profile name.. + */ + public abstract String name(); + + public Builder toBuilder() { + return builder().fromImageParams(this); + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + + private String domain; + private String name; + + public Builder domain(final String domain) { + this.domain = domain; + return this; + } + + public Builder name(final String name) { + this.name = name; + return this; + } + + public CreateProfileParams build() { + return CreateProfileParams.create(domain, name); + } + + public Builder fromImageParams(final CreateProfileParams in) { + return domain(in.domain()).name(in.name()); + } + } + + private static CreateProfileParams create( + final String domain, + final String name) { + return new AutoValue_CreateProfileParams(domain, name); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Profile.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Profile.java new file mode 100644 index 000000000..7d166f8fc --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/Profile.java @@ -0,0 +1,81 @@ +/* + * 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.azurecompute.domain; + +import com.google.auto.value.AutoValue; +import java.util.Map; +import org.jclouds.javax.annotation.Nullable; + +/** + * Traffic Maager profile. + * + * @see Traffic Manager operations + */ +@AutoValue +public abstract class Profile { + + Profile() { + } // For AutoValue only! + + /** + * Specifies the domain name, as specified during the creation of the profile. + * + * @return domain nae. + */ + public abstract String domain(); + + /** + * Specifies the profile name. + * + * @return profile name. + */ + public abstract String name(); + + /** + * Indicates whether a definition of the specified profile is enabled or disabled in Azure Traffic Manager. Possible + * values are: Enabled, Disabled. + * + * @return profile definition status. + */ + public abstract ProfileDefinition.Status status(); + + /** + * Specifies the version of the enabled definition. This value is always 1. + * + * @return version. + */ + @Nullable + public abstract String version(); + + /** + * Specifies the definition for the specified profile, along with the status. Only one definition version exists for + * a profile. + * + * @return profile definitions in terms of version-status pairs; + */ + public abstract Map definitions(); + + public static Profile create( + final String domain, + final String name, + final ProfileDefinition.Status status, + final String version, + final Map definitions) { + + return new AutoValue_Profile(domain, name, status, version, definitions); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ProfileDefinition.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ProfileDefinition.java new file mode 100644 index 000000000..df0190f3c --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ProfileDefinition.java @@ -0,0 +1,199 @@ +/* + * 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.azurecompute.domain; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableList; +import java.util.List; + +/** + * Cloud service certifcate. + * + * @see ServiceCertificate + */ +@AutoValue +public abstract class ProfileDefinition { + + public static enum Status { + + UNRECOGNIZED(""), + ENABLED("Enabled"), + DISABLED("Disabled"); + + private final String value; + + private Status(final String value) { + this.value = value; + } + + public static Status fromString(final String value) { + for (Status status : Status.values()) { + if (status.value.equalsIgnoreCase(value)) { + return status; + } + } + return UNRECOGNIZED; + } + + public String getValue() { + return value; + } + } + + public static enum LBMethod { + + UNRECOGNIZED(""), + PERFORMANCE("Performance"), + FAILOVER("Failover"), + ROUNDROBIN("RoundRobin"); + + private final String value; + + private LBMethod(final String value) { + this.value = value; + } + + public static LBMethod fromString(final String value) { + for (LBMethod lb : LBMethod.values()) { + if (lb.value.equalsIgnoreCase(value)) { + return lb; + } + } + return UNRECOGNIZED; + } + + public String getValue() { + return value; + } + } + + public static enum Protocol { + + UNRECOGNIZED, HTTP, HTTPS; + + public static Protocol fromString(final String value) { + for (Protocol protocol : Protocol.values()) { + if (protocol.name().equalsIgnoreCase(value)) { + return protocol; + } + } + return UNRECOGNIZED; + } + } + + public static enum HealthStatus { + + UNRECOGNIZED(""), + ONLINE("Online"), + DEGRADED("Degraded"), + INACTIVE("Inactive"), + DISABLED("Disabled"), + STOPPED("Stopped"), + CHECKINGENDPOINT("CheckingEndpoint"); + + private final String value; + + private HealthStatus(final String value) { + this.value = value; + } + + public static HealthStatus fromString(final String value) { + for (HealthStatus status : HealthStatus.values()) { + if (status.value.equalsIgnoreCase(value)) { + return status; + } + } + return UNRECOGNIZED; + } + + public String getValue() { + return value; + } + } + + ProfileDefinition() { + } // For AutoValue only! + + /** + * Specifies the DNS Time-To-Live (TTL) that informs the Local DNS resolvers how long to cache DNS entries. The value + * is an integer from 30 through 999,999. + * + * @return DNS cache Time-To-Live (TTL) + */ + public abstract int ttl(); + + /** + * Indicates whether this definition is enabled or disabled for the profile. Possible values are: Enabled, Disabled. + * + * @return profile definition status. + */ + public abstract Status status(); + + /** + * Specifies the version of the definition. This value is always 1. + * + * @return version. + */ + public abstract String version(); + + /** + * Encapsulates the list of Azure Traffic Manager endpoint monitors. You have to define just 1 monitor in the list. + * + * @return profile definition monitors; + */ + public abstract List monitors(); + + /** + * Specifies the load balancing method to use to distribute connection. Possible values are: Performance, Failover, + * RoundRobin + * + * @return load balancing method.. + */ + public abstract LBMethod lb(); + + /** + * Encapsulates the list of Azure Traffic Manager endpoints. You can define up to 100 endpoints in the list. + * + * @return endpoints. + * @see EndpointParams + */ + public abstract List endpoints(); + + /** + * When defined as part of a policy, indicates the health status for the overall load balancing policy. Possible + * values are: Online, Degraded, Inactive, Disabled, CheckingEndpoints. + * + * When defined as part of an endpoint, indicates the health status for the endpoint. Possible values are: Online, + * Degraded, Inactive, Disabled, Stopped, CheckingEndpoint. + * + * @return endpoint health status. + */ + public abstract ProfileDefinition.HealthStatus healthStatus(); + + public static ProfileDefinition create( + final int ttl, + final Status status, + final String version, + final List monitors, + final LBMethod lb, + final List endpoints, + final ProfileDefinition.HealthStatus healthStatus) { + + return new AutoValue_ProfileDefinition( + ttl, status, version, ImmutableList.copyOf(monitors), lb, ImmutableList.copyOf(endpoints), healthStatus); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ProfileDefinitionEndpoint.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ProfileDefinitionEndpoint.java new file mode 100644 index 000000000..e846a798a --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ProfileDefinitionEndpoint.java @@ -0,0 +1,148 @@ +/* + * 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.azurecompute.domain; + +import com.google.auto.value.AutoValue; +import org.jclouds.azurecompute.domain.ProfileDefinition.HealthStatus; +import org.jclouds.javax.annotation.Nullable; + +/** + * Encapsulates the list of Azure Traffic Manager endpoints. You can define up to 100 endpoints in the list. + * + * @see docs + */ +@AutoValue +public abstract class ProfileDefinitionEndpoint { + + public static enum Type { + + UNRECOGNIZED(""), + CLOUDSERVICE("CloudService"), + AZUREWEBSITE("AzureWebsite"), + ANY("Any"), + TRAFFICMANAGER("TrafficManager"); + + private final String value; + + private Type(final String value) { + this.value = value; + } + + public static Type fromString(final String value) { + for (Type type : Type.values()) { + if (type.value.equalsIgnoreCase(value)) { + return type; + } + } + return UNRECOGNIZED; + } + + public String getValue() { + return value; + } + } + + ProfileDefinitionEndpoint() { + } // For AutoValue only! + + /** + * Specifies the endpoint domain name. The value depends on endpoint type. If Type is CloudService, the value must be + * a fully qualified domain name (FQDN) of a cloud service that belongs to the subscription ID that owns the + * definition. If Type is AzureWebsite, the value must be an FQDN of an Azure web site that belongs to the + * subscription ID that owns the definition. If Type is Any, the value can be any FQDN for an Azure service or a + * service outside of Azure. + * + * @return endpoint domain name. + */ + public abstract String domain(); + + /** + * Specifies the status of the monitoring endpoint. If set to Enabled, the endpoint is considered by the load + * balancing method and is monitored. Possible values are:Enabled, Disabled + * + * @return status of the monitoring endpoint. + */ + public abstract ProfileDefinition.Status status(); + + /** + * When defined as part of a policy, indicates the health status for the overall load balancing policy. Possible + * values are: Online, Degraded, Inactive, Disabled, CheckingEndpoints. + * + * When defined as part of an endpoint, indicates the health status for the endpoint. Possible values are: Online, + * Degraded, Inactive, Disabled, Stopped, CheckingEndpoint. + * + * @return endpoint health status. + */ + public abstract ProfileDefinition.HealthStatus healthStatus(); + + /** + * Optional. Specifies the type of endpoint being added to the definition. Possible values are: CloudService, + * AzureWebsite, Any, TrafficManager. + * + * If there is more than one AzureWebsite endpoint, they must be in different datacenters. This limitation doesn’t + * apply to cloud services. The default value is CloudService. Use the TrafficManager type when configuring nested + * profiles.. + * + * @return endpoint type. + * @see Traffic Manager Overview + */ + public abstract Type type(); + + /** + * Required when LoadBalancingMethod is set to Performance and Type is set to Any or TrafficManager. Specifies the + * name of the Azure region. The Location cannot be specified for endpoints of type CloudService or AzureWebsite, in + * which the locations are determined from the service. + * + * @return endpoint protocol. + * @see List Locations + */ + @Nullable + public abstract String location(); + + /** + * Optional. Specifies the priority of the endpoint in load balancing. The higher the weight, the more frequently the + * endpoint will be made available to the load balancer. The value must be greater than 0. For endpoints that do not + * specify a weight value, a default weight of 1 will be used. + * + * @return + */ + @Nullable + public abstract Integer weight(); + + /** + * Optional. Can be specified when Type is set to TrafficManager. The minimum number of healthy endpoints within a + * nested profile that determines whether any of the endpoints within that profile can receive traffic. Default value + * is 1. + * + * @return minimum number of healthy endpoints. + */ + @Nullable + public abstract Integer min(); + + public static ProfileDefinitionEndpoint create( + final String domain, + final ProfileDefinition.Status status, + final HealthStatus healthStatus, + final Type type, + final String location, + final Integer weight, + final Integer min) { + + return new AutoValue_ProfileDefinitionEndpoint( + domain, status, healthStatus, type, location, weight, min); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ProfileDefinitionEndpointParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ProfileDefinitionEndpointParams.java new file mode 100644 index 000000000..34173f9bb --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ProfileDefinitionEndpointParams.java @@ -0,0 +1,180 @@ +/* + * 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.azurecompute.domain; + +import com.google.auto.value.AutoValue; +import org.jclouds.azurecompute.domain.ProfileDefinition.Status; +import org.jclouds.azurecompute.domain.ProfileDefinitionEndpoint.Type; +import org.jclouds.javax.annotation.Nullable; + +/** + * Encapsulates the list of Azure Traffic Manager endpoints. You can define up to 100 endpoints in the list. + * + * @see docs + */ +@AutoValue +public abstract class ProfileDefinitionEndpointParams { + + ProfileDefinitionEndpointParams() { + } // For AutoValue only! + + /** + * Specifies the endpoint domain name. The value depends on endpoint type. If Type is CloudService, the value must be + * a fully qualified domain name (FQDN) of a cloud service that belongs to the subscription ID that owns the + * definition. If Type is AzureWebsite, the value must be an FQDN of an Azure web site that belongs to the + * subscription ID that owns the definition. If Type is Any, the value can be any FQDN for an Azure service or a + * service outside of Azure. + * + * @return endpoint domain name. + */ + public abstract String domain(); + + /** + * Specifies the status of the monitoring endpoint. If set to Enabled, the endpoint is considered by the load + * balancing method and is monitored. Possible values are:Enabled, Disabled + * + * @return status of the monitoring endpoint. + */ + public abstract Status status(); + + /** + * Optional. Specifies the type of endpoint being added to the definition. Possible values are: CloudService, + * AzureWebsite, Any, TrafficManager. + * + * If there is more than one AzureWebsite endpoint, they must be in different datacenters. This limitation doesn’t + * apply to cloud services. The default value is CloudService. Use the TrafficManager type when configuring nested + * profiles.. + * + * @return endpoint type. + * @see Traffic Manager Overview + */ + @Nullable + public abstract Type type(); + + /** + * Required when LoadBalancingMethod is set to Performance and Type is set to Any or TrafficManager. Specifies the + * name of the Azure region. The Location cannot be specified for endpoints of type CloudService or AzureWebsite, in + * which the locations are determined from the service. + * + * @return endpoint protocol. + * @see List Locations + */ + @Nullable + public abstract String location(); + + /** + * Optional. Can be specified when Type is set to TrafficManager. The minimum number of healthy endpoints within a + * nested profile that determines whether any of the endpoints within that profile can receive traffic. Default value + * is 1. + * + * @return minimum number of healthy endpoints. + */ + @Nullable + public abstract Integer min(); + + /** + * Optional. Specifies the priority of the endpoint in load balancing. The higher the weight, the more frequently the + * endpoint will be made available to the load balancer. The value must be greater than 0. For endpoints that do not + * specify a weight value, a default weight of 1 will be used. + * + * @return endpoint priority. + */ + @Nullable + public abstract Integer weight(); + + public Builder toBuilder() { + return builder().fromImageParams(this); + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + + private String domain; + + private Status status; + + private Type type; + + private String location; + + private Integer min; + + private Integer weight; + + public Builder domain(final String domain) { + this.domain = domain; + return this; + } + + public Builder status(final Status status) { + this.status = status; + return this; + } + + public Builder type(final Type type) { + this.type = type; + return this; + } + + public Builder location(final String location) { + this.location = location; + return this; + } + + public Builder min(final Integer min) { + this.min = min; + return this; + } + + public Builder weight(final Integer weight) { + this.weight = weight; + return this; + } + + public ProfileDefinitionEndpointParams build() { + return ProfileDefinitionEndpointParams.create( + domain, + status, + type, + location, + min, + weight); + } + + public Builder fromImageParams(final ProfileDefinitionEndpointParams in) { + return domain(in.domain()) + .status(in.status()) + .type(in.type()) + .location(in.location()) + .min(in.min()) + .weight(in.weight()); + } + } + + private static ProfileDefinitionEndpointParams create( + final String domain, + final Status status, + final Type type, + final String location, + final Integer min, + final Integer weight) { + return new AutoValue_ProfileDefinitionEndpointParams(domain, status, type, location, min, weight); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ProfileDefinitionMonitor.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ProfileDefinitionMonitor.java new file mode 100644 index 000000000..50dc800d9 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ProfileDefinitionMonitor.java @@ -0,0 +1,121 @@ +/* + * 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.azurecompute.domain; + +import com.google.auto.value.AutoValue; +import org.jclouds.javax.annotation.Nullable; + +/** + * Azure Traffic Manager endpoint monitor. + * + * @see docs + */ +@AutoValue +public abstract class ProfileDefinitionMonitor { + + public static final int DEFAULT_INTERVAL = 30; + public static final int DEFAULT_TIMEOUT = 10; + public static final int DEFAULT_TOLERAION = 3; + public static final int DEFAULT_EXPECTED = 200; + public static final String DEFAULT_VERB = "GET"; + + ProfileDefinitionMonitor() { + } // For AutoValue only! + + /** + * Specifies the number of seconds between consecutive attempts to check the status of a monitoring endpoint. The + * value must be set to 30. + * + * @return intervall in seconds. + */ + @Nullable + public abstract Integer intervall(); + + /** + * Specifies the time to wait for response from the monitoring endpoint. The value must be set to 10. + * + * @return timeout in seconds. + */ + @Nullable + public abstract Integer timeout(); + + /** + * Specifies the number of consecutive failures to probe an endpoint before taking the endpoint out of rotation. The + * value must be set to 3. + * + * @return tolerated number of failures. + */ + @Nullable + public abstract Integer toleration(); + + /** + * Specifies the protocol to use to monitor endpoint health. Possible values are: HTTP, HTTPS. + * + * @return endpoint protocol. + */ + public abstract ProfileDefinition.Protocol protocol(); + + /** + * Specifies the port used to monitor endpoint health. Accepted values are integer values greater than 0 and less or + * equal to 65,535. + * + * @return endpoint port. + */ + public abstract int port(); + + /** + * Specifies the verb to use when making an HTTP request to monitor endpoint health. The value must be set to GET. + * + * @return verb to use when making an HTTP request. + */ + @Nullable + public abstract String verb(); + + /** + * Specifies the path relative to the endpoint domain name to probe for health state. Restrictions are: The path must + * be from 1 through 1000 characters. It must start with a forward slash /. It must contain no brackets <>. It + * must contain no double slashes //. It must be a well-formed URI string. + * + * @return endpoint relative path. + * @see + * Uri.IsWellFormedUriString Method + */ + public abstract String path(); + + /** + * Specifies the HTTP status code expected from a healthy endpoint. The endpoint is considered unhealthy otherwise. + * The value must be set to 200. + * + * @return expected status code. + */ + @Nullable + public abstract Integer expected(); + + public static ProfileDefinitionMonitor create( + final Integer intervall, + final Integer timeout, + final Integer toleration, + final ProfileDefinition.Protocol protocol, + final int port, + final String verb, + final String path, + final Integer expected) { + + return new AutoValue_ProfileDefinitionMonitor( + intervall, timeout, toleration, protocol, port, verb, path, expected); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ProfileDefinitionParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ProfileDefinitionParams.java new file mode 100644 index 000000000..fdd8b2023 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/ProfileDefinitionParams.java @@ -0,0 +1,161 @@ +/* + * 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.azurecompute.domain; + +import com.google.auto.value.AutoValue; +import java.util.List; +import org.jclouds.azurecompute.domain.ProfileDefinition.LBMethod; +import org.jclouds.azurecompute.domain.ProfileDefinition.Protocol; + +/** + * The Create Definition operation creates a new definition for a specified profile. This definition will be assigned a + * version number by the service. For more information about creating a profile, see Create Profile. + * + * @see docs + */ +@AutoValue +public abstract class ProfileDefinitionParams { + + ProfileDefinitionParams() { + } // For AutoValue only! + + /** + * Specifies the DNS Time-To-Live (TTL) that informs the Local DNS resolvers how long to cache DNS entries. The value + * is an integer from 30 through 999,999. + * + * @return DNS cache Time-To-Live (TTL) + */ + public abstract Integer ttl(); + + /** + * Specifies the protocol to use to monitor endpoint health. Possible values are: HTTP, HTTPS. + * + * @return endpoint protocol. + */ + public abstract Protocol protocol(); + + /** + * Specifies the port used to monitor endpoint health. Accepted values are integer values greater than 0 and less or + * equal to 65,535. + * + * @return endpoint port. + */ + public abstract Integer port(); + + /** + * Specifies the path relative to the endpoint domain name to probe for health state. Restrictions are: The path must + * be from 1 through 1000 characters. It must start with a forward slash /. It must contain no brackets <>. It + * must contain no double slashes //. It must be a well-formed URI string. + * + * @return endpoint relative path. + * @see + * Uri.IsWellFormedUriString Method + */ + public abstract String path(); + + /** + * Specifies the load balancing method to use to distribute connection. Possible values are: Performance, Failover, + * RoundRobin + * + * @return load balancing method.. + */ + public abstract LBMethod lb(); + + /** + * Encapsulates the list of Azure Traffic Manager endpoints. You can define up to 100 endpoints in the list. + * + * @return endpoints. + * @see ProfileDefinitionEndpointParams + */ + public abstract List endpoints(); + + public Builder toBuilder() { + return builder().fromImageParams(this); + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + + private Integer ttl; + + private Protocol protocol; + + private Integer port; + + private String path; + + private LBMethod lb; + + private List endpoints; + + public Builder ttl(final Integer ttl) { + this.ttl = ttl; + return this; + } + + public Builder protocol(final Protocol protocol) { + this.protocol = protocol; + return this; + } + + public Builder port(final Integer port) { + this.port = port; + return this; + } + + public Builder path(final String path) { + this.path = path; + return this; + } + + public Builder lb(final LBMethod lb) { + this.lb = lb; + return this; + } + + public Builder endpoints(final List endpoints) { + this.endpoints = endpoints; + return this; + } + + public ProfileDefinitionParams build() { + return ProfileDefinitionParams.create(ttl, protocol, port, path, lb, endpoints); + } + + public Builder fromImageParams(final ProfileDefinitionParams in) { + return ttl(in.ttl()) + .protocol(in.protocol()) + .port(in.port()) + .path(in.path()) + .lb(in.lb()) + .endpoints(in.endpoints()); + } + } + + private static ProfileDefinitionParams create( + final Integer ttl, + final Protocol protocol, + final Integer port, + final String path, + final LBMethod lb, + final List endpoints) { + return new AutoValue_ProfileDefinitionParams(ttl, protocol, port, path, lb, endpoints); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/domain/UpdateProfileParams.java b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/UpdateProfileParams.java new file mode 100644 index 000000000..8fc9242fd --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/domain/UpdateProfileParams.java @@ -0,0 +1,86 @@ +/* + * 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.azurecompute.domain; + +import com.google.auto.value.AutoValue; +import org.jclouds.javax.annotation.Nullable; + +/** + * The Create Profile operation creates a new profile for a status version, owned by the specified subscription. + * + * @see docs + */ +@AutoValue +public abstract class UpdateProfileParams { + + UpdateProfileParams() { + } // For AutoValue only! + + /** + * Specifies whether the profile should be enabled or disabled. If there is a currently enabled profile, it is + * disabled. Possible values are: Enabled, Disabled; + * + * @return profile status. + */ + public abstract ProfileDefinition.Status status(); + + /** + * This element is not used. + * + * @return profile definition version. + */ + @Nullable + public abstract String version(); + + public Builder toBuilder() { + return builder().fromImageParams(this); + } + + public static Builder builder() { + return new Builder(); + } + + public static final class Builder { + + private ProfileDefinition.Status status; + private String version; + + public Builder status(final ProfileDefinition.Status status) { + this.status = status; + return this; + } + + public Builder version(final String version) { + this.version = version; + return this; + } + + public UpdateProfileParams build() { + return UpdateProfileParams.create(status, version); + } + + public Builder fromImageParams(final UpdateProfileParams in) { + return status(in.status()).version(in.version()); + } + } + + private static UpdateProfileParams create( + final ProfileDefinition.Status status, + final String version) { + return new AutoValue_UpdateProfileParams(status, version); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/features/TrafficManagerApi.java b/azurecompute/src/main/java/org/jclouds/azurecompute/features/TrafficManagerApi.java new file mode 100644 index 000000000..d41cda1fc --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/features/TrafficManagerApi.java @@ -0,0 +1,184 @@ +/* + * 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.azurecompute.features; + +import java.util.List; +import static javax.ws.rs.core.MediaType.APPLICATION_XML; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import org.jclouds.Fallbacks; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.azurecompute.binders.ProfileDefinitionParamsToXML; +import org.jclouds.azurecompute.binders.ProfileParamsToXML; +import org.jclouds.azurecompute.domain.Profile; +import org.jclouds.azurecompute.domain.ProfileDefinition; +import org.jclouds.azurecompute.domain.ProfileDefinitionParams; +import org.jclouds.azurecompute.domain.CreateProfileParams; +import org.jclouds.azurecompute.domain.UpdateProfileParams; +import org.jclouds.azurecompute.functions.ParseRequestIdHeader; +import org.jclouds.azurecompute.xml.ListProfileDefinitionsHandler; +import org.jclouds.azurecompute.xml.ListProfilesHandler; +import org.jclouds.azurecompute.xml.ProfileDefinitionHandler; +import org.jclouds.azurecompute.xml.ProfileHandler; +import org.jclouds.azurecompute.xml.ResultHandler; + +import org.jclouds.rest.annotations.BinderParam; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.Headers; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.XMLResponseParser; + +/** + * The Service Management API includes operations for creating, updating, listing, and deleting Azure Traffic Manager + * profiles and definitions. + * + * @see docs + */ +@Path("/services/WATM") +@Headers(keys = "x-ms-version", values = "{jclouds.api-version}") +@Consumes(APPLICATION_XML) +@Produces(APPLICATION_XML) +public interface TrafficManagerApi { + + /** + * The List Definitions operation returns all definitions of a profile. + * + * @param profile profile name. + * @return profile definitions. + */ + @Named("ListProfileDefinitions") + @GET + @Path("/profiles/{profile}/definitions") + @XMLResponseParser(ListProfileDefinitionsHandler.class) + @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class) + List listDefinitions(@PathParam("profile") String profile); + + /** + * The Get Definition operation returns an existing profile definition. + * + * @param profile profile name. + * @return profile definition. + */ + @Named("GetProfileDefinition") + @GET + @Path("/profiles/{profile}/definitions/1") + @XMLResponseParser(ProfileDefinitionHandler.class) + @Fallback(NullOnNotFoundOr404.class) + ProfileDefinition getDefinition(@PathParam("profile") String profile); + + /** + * The Create Profile operation creates a new profile for a domain name, owned by the specified subscription. + * + * @return traffic manager profiles. + */ + @Named("ListProfiles") + @GET + @Path("/profiles") + @XMLResponseParser(ListProfilesHandler.class) + @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class) + List listProfiles(); + + /** + * The Get Profile operation returns profile details, including all definition versions and their statuses. + * + * @param profile profile name. + * @return traffic manager profile. + */ + @Named("GetProfile") + @GET + @Path("/profiles/{profile}") + @XMLResponseParser(ProfileHandler.class) + @Fallback(NullOnNotFoundOr404.class) + Profile getProfile(@PathParam("profile") String profile); + + /** + * The Check DNS Prefix Availability operation checks whether the specified DNS prefix is available for creating a + * profile. + * + * @param name DNS name that you want to use. You must include .trafficmanager.net in the name. + * @return DNS name availability. + */ + @Named("CheckDNSPrefixAvailability") + @GET + @Path("/operations/isavailable/{name}") + @XMLResponseParser(ResultHandler.class) + @Fallback(NullOnNotFoundOr404.class) + boolean checkDNSPrefixAvailability(@PathParam("name") String name); + + /** + * The Create Definition operation creates a new definition for a specified profile. This definition will be assigned + * a version number by the service. For more information about creating a profile, see Create Profile. + * + * @param name profile name. + * @param params profile definition details to be sent as request body. + * @return request id. + */ + @Named("CreateProfileDefinition") + @POST + @Path("/profiles/{name}/definitions") + @ResponseParser(ParseRequestIdHeader.class) + String createDefinition( + @PathParam("name") String name, + @BinderParam(ProfileDefinitionParamsToXML.class) ProfileDefinitionParams params); + + /** + * The Delete Profile operation deletes a profile and all of its definitions. This operation cannot be reverted. + * + * @param profile traffic manager profile name. + * @return request id. + */ + @Named("DeleteProfile") + @DELETE + @Path("/profiles/{profile}") + @Fallback(NullOnNotFoundOr404.class) + @ResponseParser(ParseRequestIdHeader.class) + String delete(@PathParam("profile") String profile); + + /** + * The Create Profile operation creates a new profile for a domain name, owned by the specified subscription. + * + * @param params profile parameters. + * @return request id. + */ + @Named("CreateProfile") + @POST + @Path("/profiles") + @ResponseParser(ParseRequestIdHeader.class) + String createProfile(@BinderParam(ProfileParamsToXML.class) CreateProfileParams params); + + /** + * The Update Profile operation enables or disables a profile. + * + * @param profile traffic manager profile name. + * @param params update profile params. + * @return request id. + */ + @Named("UpdateProfile") + @PUT + @Path("/profiles/{profile}") + @ResponseParser(ParseRequestIdHeader.class) + String updateProfile( + @PathParam("profile") String profile, @BinderParam(ProfileParamsToXML.class) UpdateProfileParams params); +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListProfileDefinitionsHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListProfileDefinitionsHandler.java new file mode 100644 index 000000000..185153237 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListProfileDefinitionsHandler.java @@ -0,0 +1,79 @@ +/* + * 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.azurecompute.xml; + +import java.util.List; + +import javax.inject.Inject; + +import org.jclouds.http.functions.ParseSax; +import org.xml.sax.Attributes; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList.Builder; +import org.jclouds.azurecompute.domain.ProfileDefinition; + +/** + * @see Response body description + */ +public final class ListProfileDefinitionsHandler extends + ParseSax.HandlerForGeneratedRequestWithResult> { + + private boolean inDefinition; + + private final ProfileDefinitionHandler profileDefinitionHandler; + + private final Builder definitions = ImmutableList.builder(); + + @Inject + ListProfileDefinitionsHandler(ProfileDefinitionHandler profileDefinitionHandler) { + this.profileDefinitionHandler = profileDefinitionHandler; + } + + @Override + public List getResult() { + return definitions.build(); + } + + @Override + public void startElement(final String url, final String name, final String qName, final Attributes attributes) { + if (qName.equals("Definition")) { + inDefinition = true; + } + + if (inDefinition) { + profileDefinitionHandler.startElement(url, name, qName, attributes); + } + } + + @Override + public void endElement(final String uri, final String name, final String qName) { + if (qName.equals("Definition")) { + inDefinition = false; + definitions.add(profileDefinitionHandler.getResult()); + } else if (inDefinition) { + profileDefinitionHandler.endElement(uri, name, qName); + } + } + + @Override + public void characters(final char ch[], final int start, final int length) { + if (inDefinition) { + profileDefinitionHandler.characters(ch, start, length); + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListProfilesHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListProfilesHandler.java new file mode 100644 index 000000000..7987564ca --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ListProfilesHandler.java @@ -0,0 +1,79 @@ +/* + * 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.azurecompute.xml; + +import java.util.List; + +import javax.inject.Inject; + +import org.jclouds.http.functions.ParseSax; +import org.xml.sax.Attributes; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList.Builder; +import org.jclouds.azurecompute.domain.Profile; + +/** + * @see Response body description + */ +public final class ListProfilesHandler extends + ParseSax.HandlerForGeneratedRequestWithResult> { + + private boolean inProfile; + + private final ProfileHandler profileHandler; + + private final Builder profiles = ImmutableList.builder(); + + @Inject + ListProfilesHandler(ProfileHandler profileHandler) { + this.profileHandler = profileHandler; + } + + @Override + public List getResult() { + return profiles.build(); + } + + @Override + public void startElement(final String url, final String name, final String qName, final Attributes attributes) { + if (qName.equals("Profile")) { + inProfile = true; + } + + if (inProfile) { + profileHandler.startElement(url, name, qName, attributes); + } + } + + @Override + public void endElement(final String uri, final String name, final String qName) { + if (qName.equals("Profile")) { + inProfile = false; + profiles.add(profileHandler.getResult()); + } else if (inProfile) { + profileHandler.endElement(uri, name, qName); + } + } + + @Override + public void characters(final char ch[], final int start, final int length) { + if (inProfile) { + profileHandler.characters(ch, start, length); + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ProfileDefinitionEndpointHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ProfileDefinitionEndpointHandler.java new file mode 100644 index 000000000..3c634accf --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ProfileDefinitionEndpointHandler.java @@ -0,0 +1,110 @@ +/* + * 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.azurecompute.xml; + +import static org.jclouds.util.SaxUtils.currentOrNull; + +import org.jclouds.azurecompute.domain.ProfileDefinition; +import org.jclouds.azurecompute.domain.ProfileDefinitionEndpoint; +import org.jclouds.azurecompute.domain.ProfileDefinition.HealthStatus; +import org.jclouds.azurecompute.domain.ProfileDefinition.Status; + +import org.jclouds.http.functions.ParseSax; + +import org.xml.sax.Attributes; + +/** + * @see Response body description + */ +public final class ProfileDefinitionEndpointHandler + extends ParseSax.HandlerForGeneratedRequestWithResult { + + private String domain; + + private Status status; + + private HealthStatus healthStatus; + + private ProfileDefinitionEndpoint.Type type; + + private String location; + + private Integer weight; + + private Integer min; + + private final StringBuilder currentText = new StringBuilder(); + + @Override + public ProfileDefinitionEndpoint getResult() { + final ProfileDefinitionEndpoint result = ProfileDefinitionEndpoint.create( + domain, status, healthStatus, type, location, weight, min); + resetState(); // handler is called in a loop. + return result; + } + + private void resetState() { + domain = location = null; + min = null; + status = null; + type = null; + } + + @Override + public void startElement( + final String ignoredUri, + final String ignoredLocalName, + final String qName, + final Attributes ignoredAttributes) { + } + + @Override + public void endElement(final String ignoredUri, final String ignoredName, final String qName) { + if (qName.equals("DomainName")) { + domain = currentOrNull(currentText); + } else if (qName.equals("Status")) { + final String value = currentText.toString().trim(); + status = value.isEmpty() + ? null + : Status.fromString(value); + } else if (qName.equals("MonitorStatus")) { + final String value = currentText.toString().trim(); + healthStatus = value.isEmpty() + ? null + : ProfileDefinition.HealthStatus.fromString(value); + } else if (qName.equals("Type")) { + final String value = currentText.toString().trim(); + type = value.isEmpty() + ? ProfileDefinitionEndpoint.Type.CLOUDSERVICE + : ProfileDefinitionEndpoint.Type.fromString(value); + } else if (qName.equals("Location")) { + location = currentOrNull(currentText); + } else if (qName.equals("Weight")) { + final String value = currentText.toString().trim(); + weight = value.isEmpty() ? 1 : Integer.parseInt(value); + } else if (qName.equals("MinChildEndpoints")) { + final String value = currentText.toString().trim(); + min = value.isEmpty() ? 1 : Integer.parseInt(value); + } + currentText.setLength(0); + } + + @Override + public void characters(final char ch[], final int start, final int length) { + currentText.append(ch, start, length); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ProfileDefinitionHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ProfileDefinitionHandler.java new file mode 100644 index 000000000..c4d9d24eb --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ProfileDefinitionHandler.java @@ -0,0 +1,148 @@ +/* + * 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.azurecompute.xml; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList.Builder; +import static org.jclouds.util.SaxUtils.currentOrNull; + +import org.jclouds.http.functions.ParseSax; +import org.xml.sax.Attributes; + +import javax.inject.Inject; +import org.jclouds.azurecompute.domain.ProfileDefinition; +import org.jclouds.azurecompute.domain.ProfileDefinitionEndpoint; +import org.jclouds.azurecompute.domain.ProfileDefinitionMonitor; + +/** + * @see Response body description + */ +public final class ProfileDefinitionHandler extends ParseSax.HandlerForGeneratedRequestWithResult { + + private Integer ttl; + + private ProfileDefinition.Status status; + + private String version; + + private Builder monitors = ImmutableList.builder(); + + private ProfileDefinition.LBMethod lb; + + private Builder endpoints = ImmutableList.builder(); + + private ProfileDefinition.HealthStatus healthStatus; + + private final StringBuilder currentText = new StringBuilder(); + + private final ProfileDefinitionMonitorHandler monitorHandler; + + private final ProfileDefinitionEndpointHandler endpointHandler; + + private boolean inMonitor = false; + private boolean inEndpoint = false; + + @Inject + public ProfileDefinitionHandler( + ProfileDefinitionMonitorHandler monitorHandler, ProfileDefinitionEndpointHandler endpointHandler) { + this.monitorHandler = monitorHandler; + this.endpointHandler = endpointHandler; + } + + @Override + public ProfileDefinition getResult() { + final ProfileDefinition result = ProfileDefinition.create( + ttl, status, version, monitors.build(), lb, endpoints.build(), healthStatus); + resetState(); // handler is called in a loop. + return result; + } + + private void resetState() { + ttl = null; + status = null; + version = null; + monitors = ImmutableList.builder(); + lb = null; + endpoints = ImmutableList.builder(); + inMonitor = false; + inEndpoint = false; + } + + @Override + public void startElement( + final String url, + final String name, + final String qName, + final Attributes attributes) { + + if (!inEndpoint && qName.equals("Monitor")) { + inMonitor = true; + } + + if (!inMonitor && qName.equals("Endpoint")) { + inEndpoint = true; + } + + if (inMonitor) { + monitorHandler.startElement(url, name, qName, attributes); + } else if (inEndpoint) { + endpointHandler.startElement(url, name, qName, attributes); + } + } + + @Override + public void endElement(final String uri, final String name, final String qName) { + if (!inEndpoint && qName.equals("Monitor")) { + inMonitor = false; + monitors.add(monitorHandler.getResult()); + } else if (!inMonitor && qName.equals("Endpoint")) { + inEndpoint = false; + endpoints.add(endpointHandler.getResult()); + } else if (inMonitor) { + monitorHandler.endElement(uri, name, qName); + } else if (inEndpoint) { + endpointHandler.endElement(uri, name, qName); + } else { + if (qName.equals("TimeToLiveInSeconds")) { + ttl = Integer.parseInt(currentOrNull(currentText)); + } else if (qName.equals("Status")) { + status = ProfileDefinition.Status.fromString(currentOrNull(currentText)); + } else if (qName.equals("Version")) { + version = currentOrNull(currentText); + } else if (qName.equals("LoadBalancingMethod")) { + lb = ProfileDefinition.LBMethod.fromString(currentOrNull(currentText)); + } else if (qName.equals("MonitorStatus")) { + final String value = currentText.toString().trim(); + healthStatus = value.isEmpty() + ? null + : ProfileDefinition.HealthStatus.fromString(value); + } + currentText.setLength(0); + } + } + + @Override + public void characters(final char ch[], final int start, final int length) { + if (inMonitor) { + monitorHandler.characters(ch, start, length); + } else if (inEndpoint) { + endpointHandler.characters(ch, start, length); + } else { + currentText.append(ch, start, length); + } + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ProfileDefinitionMonitorHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ProfileDefinitionMonitorHandler.java new file mode 100644 index 000000000..5415107a3 --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ProfileDefinitionMonitorHandler.java @@ -0,0 +1,114 @@ +/* + * 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.azurecompute.xml; + +import static org.jclouds.util.SaxUtils.currentOrNull; + +import org.jclouds.http.functions.ParseSax; +import org.xml.sax.Attributes; + +import org.jclouds.azurecompute.domain.ProfileDefinition; +import org.jclouds.azurecompute.domain.ProfileDefinitionMonitor; + +/** + * @see Response body description + */ +public final class ProfileDefinitionMonitorHandler + extends ParseSax.HandlerForGeneratedRequestWithResult { + + private Integer intervall; + + private Integer timeout; + + private Integer toleration; + + private ProfileDefinition.Protocol protocol; + + private Integer port; + + private String verb; + + private String path; + + private Integer expected; + + private final StringBuilder currentText = new StringBuilder(); + + @Override + public ProfileDefinitionMonitor getResult() { + final ProfileDefinitionMonitor result = ProfileDefinitionMonitor.create( + intervall, timeout, toleration, protocol, port, verb, path, expected); + resetState(); // handler is called in a loop. + return result; + } + + private void resetState() { + intervall = timeout = toleration = port = expected = null; + protocol = null; + verb = path = null; + } + + @Override + public void startElement( + final String ignoredUri, + final String ignoredLocalName, + final String qName, + final Attributes ignoredAttributes) { + } + + @Override + public void endElement(final String ignoredUri, final String ignoredName, final String qName) { + if (qName.equals("IntervalInSeconds")) { + final String value = currentText.toString().trim(); + intervall = value.isEmpty() + ? ProfileDefinitionMonitor.DEFAULT_INTERVAL + : Integer.parseInt(value); + } else if (qName.equals("TimeoutInSeconds")) { + final String value = currentText.toString().trim(); + timeout = value.isEmpty() + ? ProfileDefinitionMonitor.DEFAULT_TIMEOUT + : Integer.parseInt(value); + } else if (qName.equals("ToleratedNumberOfFailures")) { + final String value = currentText.toString().trim(); + toleration = value.isEmpty() + ? ProfileDefinitionMonitor.DEFAULT_TOLERAION + : Integer.parseInt(value); + } else if (qName.equals("Protocol")) { + protocol = ProfileDefinition.Protocol.fromString(currentOrNull(currentText)); + } else if (qName.equals("Port")) { + port = Integer.parseInt(currentOrNull(currentText)); + } else if (qName.equals("Verb")) { + final String value = currentText.toString().trim(); + verb = value.isEmpty() + ? ProfileDefinitionMonitor.DEFAULT_VERB + : value; + } else if (qName.equals("RelativePath")) { + path = currentOrNull(currentText); + } else if (qName.equals("ExpectedStatusCode")) { + final String value = currentText.toString().trim(); + expected = value.isEmpty() + ? ProfileDefinitionMonitor.DEFAULT_EXPECTED + : Integer.parseInt(value); + } + currentText.setLength(0); + } + + @Override + public void characters(final char ch[], final int start, final int length) { + currentText.append(ch, start, length); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ProfileHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ProfileHandler.java new file mode 100644 index 000000000..1a8825b2a --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ProfileHandler.java @@ -0,0 +1,113 @@ +/* + * 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.azurecompute.xml; + +import com.google.common.collect.ImmutableMap; +import static org.jclouds.util.SaxUtils.currentOrNull; + +import org.jclouds.http.functions.ParseSax; +import org.xml.sax.Attributes; + +import org.jclouds.azurecompute.domain.Profile; +import org.jclouds.azurecompute.domain.ProfileDefinition; + +/** + * @see Response body description + */ +public final class ProfileHandler extends ParseSax.HandlerForGeneratedRequestWithResult { + + private String domain; + + private String name; + + private ProfileDefinition.Status status; + + private String version; + + private ImmutableMap.Builder definitions + = ImmutableMap.builder(); + + private final StringBuilder currentText = new StringBuilder(); + + private boolean inDefinition = false; + + private String definitionVersion = null; + private ProfileDefinition.Status definitionStatus = null; + + @Override + public Profile getResult() { + final Profile result = Profile.create(domain, name, status, version, definitions.build()); + resetState(); // handler is called in a loop. + return result; + } + + private void resetState() { + domain = name = version = null; + status = null; + definitions = ImmutableMap.builder(); + inDefinition = false; + } + + @Override + public void startElement( + final String url, + final String name, + final String qName, + final Attributes attributes) { + + if (qName.equals("Definition")) { + inDefinition = true; + } + } + + @Override + public void endElement(final String ignoredURI, final String ignoredName, final String qName) { + if (qName.equals("Definition")) { + inDefinition = false; + definitions.put(definitionVersion, definitionStatus); + } else if (inDefinition) { + if (qName.equals("Status")) { + final String value = currentText.toString().trim(); + definitionStatus = value.isEmpty() + ? null + : ProfileDefinition.Status.fromString(value); + } else if (qName.equals("Version")) { + definitionVersion = currentOrNull(currentText); + } + } else { + if (qName.equals("DomainName")) { + domain = currentOrNull(currentText); + } else if (qName.equals("Name")) { + name = currentOrNull(currentText); + } else if (qName.equals("Status")) { + final String value = currentText.toString().trim(); + status = value.isEmpty() + ? null + : ProfileDefinition.Status.fromString(value); + } else if (qName.equals("EnabledVersion")) { + version = currentOrNull(currentText); + } + } + currentText.setLength(0); + + } + + @Override + public void characters(final char ch[], final int start, final int length) { + currentText.append(ch, start, length); + } +} diff --git a/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ResultHandler.java b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ResultHandler.java new file mode 100644 index 000000000..fa1ed06db --- /dev/null +++ b/azurecompute/src/main/java/org/jclouds/azurecompute/xml/ResultHandler.java @@ -0,0 +1,64 @@ +/* + * 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.azurecompute.xml; + +import org.jclouds.http.functions.ParseSax; +import org.xml.sax.Attributes; + +/** + * @see for example Check DNS Prefix + * Availability + */ +public final class ResultHandler extends ParseSax.HandlerForGeneratedRequestWithResult { + + private boolean result = false; + private final StringBuilder currentText = new StringBuilder(); + + @Override + public Boolean getResult() { + final boolean res = result; + resetState(); // handler is called in a loop. + return res; + } + + private void resetState() { + result = false; + } + + @Override + public void startElement( + final String url, + final String name, + final String qName, + final Attributes attributes) { + } + + @Override + public void endElement(final String ignoredURI, final String ignoredName, final String qName) { + if (qName.equals("Result")) { + final String value = currentText.toString().trim(); + result = value.isEmpty() ? false : Boolean.parseBoolean(value); + } + currentText.setLength(0); + + } + + @Override + public void characters(final char ch[], final int start, final int length) { + currentText.append(ch, start, length); + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/TrafficManagerApiLiveTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/TrafficManagerApiLiveTest.java new file mode 100644 index 000000000..bff0508a7 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/TrafficManagerApiLiveTest.java @@ -0,0 +1,183 @@ +/* + * 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.azurecompute.features; + +import com.google.common.collect.ImmutableList; +import java.util.List; +import static java.util.concurrent.TimeUnit.SECONDS; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.jclouds.azurecompute.domain.CreateProfileParams; +import org.jclouds.azurecompute.domain.Profile; +import org.jclouds.azurecompute.domain.ProfileDefinition; +import org.jclouds.azurecompute.domain.ProfileDefinitionEndpoint; +import org.jclouds.azurecompute.domain.ProfileDefinitionEndpointParams; +import org.jclouds.azurecompute.domain.ProfileDefinitionParams; +import org.jclouds.azurecompute.domain.UpdateProfileParams; +import org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest; +import static org.jclouds.azurecompute.internal.BaseAzureComputeApiLiveTest.LOCATION; +import org.jclouds.azurecompute.util.ConflictManagementPredicate; +import static org.jclouds.util.Predicates2.retry; +import org.testng.Assert; +import static org.testng.Assert.assertTrue; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +@Test(groups = "live", testName = "ServiceCertificatesApiLivTest", singleThreaded = true) +public class TrafficManagerApiLiveTest extends BaseAzureComputeApiLiveTest { + + private static final String CLOUD1 = String.format("%s%d-%s1", + System.getProperty("user.name"), RAND, CloudServiceApiLiveTest.class.getSimpleName()).toLowerCase(); + + private static final String CLOUD2 = String.format("%s%d-%s2", + System.getProperty("user.name"), RAND, CloudServiceApiLiveTest.class.getSimpleName()).toLowerCase(); + + @BeforeClass + @Override + public void setup() { + super.setup(); + String requestId = api.getCloudServiceApi().createWithLabelInLocation(CLOUD1, CLOUD1, LOCATION); + assertTrue(operationSucceeded.apply(requestId), requestId); + Logger.getAnonymousLogger().log(Level.INFO, "operation succeeded: {0}", requestId); + + requestId = api.getCloudServiceApi().createWithLabelInLocation(CLOUD2, CLOUD2, LOCATION); + assertTrue(operationSucceeded.apply(requestId), requestId); + Logger.getAnonymousLogger().log(Level.INFO, "operation succeeded: {0}", requestId); + } + + @Test + public void createProfile() throws Exception { + final CreateProfileParams params = CreateProfileParams.builder(). + domain(String.format("%s.trafficmanager.net", CLOUD1)).name(CLOUD1).build(); + + final String requestId = api().createProfile(params); + assertTrue(operationSucceeded.apply(requestId), requestId); + Logger.getAnonymousLogger().log(Level.INFO, "operation succeeded: {0}", requestId); + } + + @Test(dependsOnMethods = "createProfile") + public void createDefinition() throws Exception { + final ImmutableList.Builder endpoints + = ImmutableList.builder(); + + endpoints.add(ProfileDefinitionEndpointParams.builder() + .domain(String.format("%s.cloudapp.net", CLOUD1)) + .status(ProfileDefinition.Status.ENABLED) + .type(ProfileDefinitionEndpoint.Type.CLOUDSERVICE) + .weight(1).build()); + + endpoints.add(ProfileDefinitionEndpointParams.builder() + .domain(String.format("%s.cloudapp.net", CLOUD2)) + .status(ProfileDefinition.Status.ENABLED) + .type(ProfileDefinitionEndpoint.Type.CLOUDSERVICE) + .weight(1).build()); + + final ProfileDefinitionParams params = ProfileDefinitionParams.builder() + .ttl(300) + .lb(ProfileDefinition.LBMethod.ROUNDROBIN) + .path("/") + .port(80) + .protocol(ProfileDefinition.Protocol.HTTP) + .endpoints(endpoints.build()) + .build(); + + final String requestId = api().createDefinition(CLOUD1, params); + assertTrue(operationSucceeded.apply(requestId), requestId); + Logger.getAnonymousLogger().log(Level.INFO, "operation succeeded: {0}", requestId); + } + + @Test(dependsOnMethods = "createDefinition") + public void updateProfile() throws Exception { + final UpdateProfileParams params = UpdateProfileParams.builder(). + status(ProfileDefinition.Status.DISABLED).build(); + + final String requestId = api().updateProfile(CLOUD1, params); + assertTrue(operationSucceeded.apply(requestId), requestId); + Logger.getAnonymousLogger().log(Level.INFO, "operation succeeded: {0}", requestId); + } + + @Test(dependsOnMethods = "createDefinition") + public void listDefinitions() throws Exception { + final List defs = api().listDefinitions(CLOUD1); + Assert.assertEquals(defs.size(), 1); + Assert.assertEquals(defs.get(0).endpoints().size(), 2); + Assert.assertEquals(defs.get(0).monitors().size(), 1); + Assert.assertEquals(defs.get(0).lb(), ProfileDefinition.LBMethod.ROUNDROBIN); + Assert.assertEquals(defs.get(0).ttl(), 300, 0); + Assert.assertEquals(defs.get(0).status(), ProfileDefinition.Status.ENABLED); + Assert.assertEquals(defs.get(0).monitors().get(0).port(), 80, 0); + Assert.assertEquals(defs.get(0).monitors().get(0).path(), "/"); + Assert.assertEquals(defs.get(0).endpoints().get(0).type(), ProfileDefinitionEndpoint.Type.CLOUDSERVICE); + Assert.assertNull(defs.get(0).endpoints().get(0).location()); + } + + @Test(dependsOnMethods = "createDefinition") + public void getDefinitions() throws Exception { + final ProfileDefinition def = api().getDefinition(CLOUD1); + Assert.assertEquals(def.endpoints().size(), 2); + Assert.assertEquals(def.monitors().size(), 1); + Assert.assertEquals(def.lb(), ProfileDefinition.LBMethod.ROUNDROBIN); + Assert.assertEquals(def.ttl(), 300, 0); + Assert.assertEquals(def.status(), ProfileDefinition.Status.ENABLED); + Assert.assertEquals(def.monitors().get(0).port(), 80, 0); + Assert.assertEquals(def.monitors().get(0).path(), "/"); + Assert.assertEquals(def.endpoints().get(0).type(), ProfileDefinitionEndpoint.Type.CLOUDSERVICE); + Assert.assertNull(def.endpoints().get(0).location()); + } + + @Test(dependsOnMethods = "createDefinition") + public void listProfile() throws Exception { + final List profs = api().listProfiles(); + Assert.assertFalse(profs.isEmpty()); + + final Profile prof = api().getProfile(CLOUD1); + Assert.assertEquals(prof.domain(), String.format("%s.trafficmanager.net", CLOUD1)); + Assert.assertEquals(prof.name(), CLOUD1); + Assert.assertEquals(prof.status(), ProfileDefinition.Status.ENABLED); + Assert.assertEquals(prof.version(), "1"); + Assert.assertFalse(prof.definitions().isEmpty()); + } + + @Override + @AfterClass(alwaysRun = true) + protected void tearDown() { + final String requestId = api().delete(CLOUD1); + assertTrue(operationSucceeded.apply(requestId), requestId); + Logger.getAnonymousLogger().log(Level.INFO, "operation succeeded: {0}", requestId); + + retry(new ConflictManagementPredicate(operationSucceeded) { + @Override + protected String operation() { + return api.getCloudServiceApi().delete(CLOUD1); + } + }, 600, 30, 30, SECONDS).apply(CLOUD1); + + retry(new ConflictManagementPredicate(operationSucceeded) { + @Override + protected String operation() { + return api.getCloudServiceApi().delete(CLOUD2); + } + }, 600, 30, 30, SECONDS).apply(CLOUD2); + + super.tearDown(); + } + + private TrafficManagerApi api() { + return api.getTrafficManaerApi(); + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/features/TrafficManagerApiMockTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/features/TrafficManagerApiMockTest.java new file mode 100644 index 000000000..e94a339be --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/features/TrafficManagerApiMockTest.java @@ -0,0 +1,258 @@ +/* + * 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.azurecompute.features; + +import com.google.common.collect.ImmutableList; +import static org.testng.Assert.assertTrue; + +import org.jclouds.azurecompute.internal.BaseAzureComputeApiMockTest; +import org.testng.annotations.Test; + +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.MockWebServer; +import org.jclouds.azurecompute.domain.CreateProfileParams; +import org.jclouds.azurecompute.domain.ProfileDefinition; +import org.jclouds.azurecompute.domain.ProfileDefinitionEndpoint; +import org.jclouds.azurecompute.domain.ProfileDefinitionEndpointParams; +import org.jclouds.azurecompute.domain.ProfileDefinitionParams; +import org.jclouds.azurecompute.domain.UpdateProfileParams; +import org.jclouds.azurecompute.xml.ListProfileDefinitionsHandlerTest; +import org.jclouds.azurecompute.xml.ListProfilesHandlerTest; +import org.jclouds.azurecompute.xml.ProfileDefinitionHandlerTest; +import org.jclouds.azurecompute.xml.ProfileHandlerTest; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNull; + +@Test(groups = "unit", testName = "TrafficManagerApiMockTest") +public class TrafficManagerApiMockTest extends BaseAzureComputeApiMockTest { + + public void listDefWhenFound() throws Exception { + final MockWebServer server = mockAzureManagementServer(); + server.enqueue(xmlResponse("/listprofiledefinitions.xml")); + + try { + final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); + assertEquals(api.listDefinitions("myprofile"), ListProfileDefinitionsHandlerTest.expected()); + assertSent(server, "GET", "/services/WATM/profiles/myprofile/definitions"); + } finally { + server.shutdown(); + } + } + + public void listDefWhenNotFound() throws Exception { + final MockWebServer server = mockAzureManagementServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + + try { + final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); + assertTrue(api.listDefinitions("myprofile").isEmpty()); + assertSent(server, "GET", "/services/WATM/profiles/myprofile/definitions"); + } finally { + server.shutdown(); + } + } + + public void getDefWhenFound() throws Exception { + final MockWebServer server = mockAzureManagementServer(); + server.enqueue(xmlResponse("/profiledefinition.xml")); + + try { + final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); + assertEquals(api.getDefinition("myprofile"), ProfileDefinitionHandlerTest.expected()); + assertSent(server, "GET", "/services/WATM/profiles/myprofile/definitions/1"); + } finally { + server.shutdown(); + } + } + + public void getDefWhenNotFound() throws Exception { + final MockWebServer server = mockAzureManagementServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + + try { + final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); + assertNull(api.getDefinition("myprofile")); + assertSent(server, "GET", "/services/WATM/profiles/myprofile/definitions/1"); + } finally { + server.shutdown(); + } + } + + public void listProfWhenFound() throws Exception { + final MockWebServer server = mockAzureManagementServer(); + server.enqueue(xmlResponse("/listprofiles.xml")); + + try { + final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); + assertEquals(api.listProfiles(), ListProfilesHandlerTest.expected()); + assertSent(server, "GET", "/services/WATM/profiles"); + } finally { + server.shutdown(); + } + } + + public void listProfWhenNotFound() throws Exception { + final MockWebServer server = mockAzureManagementServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + + try { + final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); + assertTrue(api.listProfiles().isEmpty()); + assertSent(server, "GET", "/services/WATM/profiles"); + } finally { + server.shutdown(); + } + } + + public void getProfWhenFound() throws Exception { + final MockWebServer server = mockAzureManagementServer(); + server.enqueue(xmlResponse("/profile.xml")); + + try { + final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); + assertEquals(api.getProfile("myprofile"), ProfileHandlerTest.expected()); + assertSent(server, "GET", "/services/WATM/profiles/myprofile"); + } finally { + server.shutdown(); + } + } + + public void getProfWhenNotFound() throws Exception { + final MockWebServer server = mockAzureManagementServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + + try { + final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); + assertNull(api.getProfile("myprofile")); + assertSent(server, "GET", "/services/WATM/profiles/myprofile"); + } finally { + server.shutdown(); + } + } + + public void checkDNSPrefixAvailability() throws Exception { + final MockWebServer server = mockAzureManagementServer(); + server.enqueue(xmlResponse("/checkdnsprefixavailability.xml")); + + try { + final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); + assertTrue(api.checkDNSPrefixAvailability("jclouds.trafficmanager.net")); + assertSent(server, "GET", "/services/WATM/operations/isavailable/jclouds.trafficmanager.net"); + } finally { + server.shutdown(); + } + } + + public void deleteWhenFound() throws Exception { + final MockWebServer server = mockAzureManagementServer(); + server.enqueue(requestIdResponse("request-1")); + + try { + final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); + assertEquals(api.delete("myprofile"), "request-1"); + assertSent(server, "DELETE", "/services/WATM/profiles/myprofile"); + + } finally { + server.shutdown(); + } + } + + public void deleteWhenNotFound() throws Exception { + final MockWebServer server = mockAzureManagementServer(); + server.enqueue(new MockResponse().setResponseCode(404)); + + try { + final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); + assertNull(api.delete("myprofile")); + assertSent(server, "DELETE", "/services/WATM/profiles/myprofile"); + } finally { + server.shutdown(); + } + } + + public void createProfile() throws Exception { + final MockWebServer server = mockAzureManagementServer(); + server.enqueue(requestIdResponse("request-1")); + + try { + final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); + + final CreateProfileParams params = CreateProfileParams.builder() + .domain("jclouds.trafficmanager.net").name("jclouds").build(); + + assertEquals(api.createProfile(params), "request-1"); + assertSent(server, "POST", "/services/WATM/profiles", "/createprofileparams.xml"); + } finally { + server.shutdown(); + } + } + + public void updateProfile() throws Exception { + final MockWebServer server = mockAzureManagementServer(); + server.enqueue(requestIdResponse("request-1")); + + try { + final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); + + final UpdateProfileParams params = UpdateProfileParams.builder() + .status(ProfileDefinition.Status.ENABLED).build(); + + assertEquals(api.updateProfile("myprofile", params), "request-1"); + assertSent(server, "PUT", "/services/WATM/profiles/myprofile", "/updateprofileparams.xml"); + } finally { + server.shutdown(); + } + } + + public void createDefinition() throws Exception { + final MockWebServer server = mockAzureManagementServer(); + server.enqueue(requestIdResponse("request-1")); + + try { + final TrafficManagerApi api = api(server.getUrl("/")).getTrafficManaerApi(); + + final ImmutableList.Builder endpoints + = ImmutableList.builder(); + + endpoints.add(ProfileDefinitionEndpointParams.builder() + .domain("jclouds1.cloudapp.net") + .status(ProfileDefinition.Status.ENABLED) + .type(ProfileDefinitionEndpoint.Type.CLOUDSERVICE) + .weight(1).build()); + + endpoints.add(ProfileDefinitionEndpointParams.builder() + .domain("jclouds2.cloudapp.net") + .status(ProfileDefinition.Status.ENABLED) + .type(ProfileDefinitionEndpoint.Type.CLOUDSERVICE) + .weight(1).build()); + + final ProfileDefinitionParams params = ProfileDefinitionParams.builder() + .ttl(300) + .lb(ProfileDefinition.LBMethod.ROUNDROBIN) + .path("/") + .port(80) + .protocol(ProfileDefinition.Protocol.HTTP) + .endpoints(endpoints.build()) + .build(); + + assertEquals(api.createDefinition("myprofile", params), "request-1"); + assertSent(server, "POST", "/services/WATM/profiles/myprofile/definitions", "/profiledefinitioncsparams.xml"); + } finally { + server.shutdown(); + } + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListProfileDefinitionsHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListProfileDefinitionsHandlerTest.java new file mode 100644 index 000000000..c14c2ee48 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListProfileDefinitionsHandlerTest.java @@ -0,0 +1,75 @@ +/* + * 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.azurecompute.xml; + +import static org.testng.Assert.assertEquals; + +import java.io.InputStream; +import java.util.List; + +import org.jclouds.http.functions.BaseHandlerTest; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableList; +import java.util.ArrayList; +import org.jclouds.azurecompute.domain.ProfileDefinition; +import org.jclouds.azurecompute.domain.ProfileDefinitionEndpoint; +import org.jclouds.azurecompute.domain.ProfileDefinitionMonitor; + +@Test(groups = "unit", testName = "ListProfileDefinitionsHandlerTest") +public class ListProfileDefinitionsHandlerTest extends BaseHandlerTest { + + public void test() { + final InputStream is = getClass().getResourceAsStream("/listprofiledefinitions.xml"); + final ListProfileDefinitionsHandler handler + = new ListProfileDefinitionsHandler(new ProfileDefinitionHandler( + new ProfileDefinitionMonitorHandler(), new ProfileDefinitionEndpointHandler())); + final List result = factory.create(handler).parse(is); + assertEquals(result, expected()); + } + + public static List expected() { + final ArrayList monitors = new ArrayList(); + monitors.add(ProfileDefinitionMonitor.create( + 30, 10, 3, ProfileDefinition.Protocol.HTTP, 80, "GET", "/", 200)); + + final ArrayList endpoints = new ArrayList(); + endpoints.add(ProfileDefinitionEndpoint.create("jclouds1.cloudapp.net", + ProfileDefinition.Status.ENABLED, + ProfileDefinition.HealthStatus.STOPPED, + ProfileDefinitionEndpoint.Type.CLOUDSERVICE, + null, + 1, + null)); + + endpoints.add(ProfileDefinitionEndpoint.create("jclouds2.cloudapp.net", + ProfileDefinition.Status.ENABLED, + ProfileDefinition.HealthStatus.STOPPED, + ProfileDefinitionEndpoint.Type.CLOUDSERVICE, + null, + 1, + null)); + + return ImmutableList.of(ProfileDefinition.create(300, + ProfileDefinition.Status.ENABLED, + "1", + monitors, + ProfileDefinition.LBMethod.ROUNDROBIN, + endpoints, + ProfileDefinition.HealthStatus.INACTIVE)); + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListProfilesHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListProfilesHandlerTest.java new file mode 100644 index 000000000..3c1ac7193 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ListProfilesHandlerTest.java @@ -0,0 +1,57 @@ +/* + * 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.azurecompute.xml; + +import autovalue.shaded.com.google.common.common.collect.ImmutableMap; +import static org.testng.Assert.assertEquals; + +import java.io.InputStream; +import java.util.List; + +import org.jclouds.http.functions.BaseHandlerTest; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableList; +import org.jclouds.azurecompute.domain.Profile; +import org.jclouds.azurecompute.domain.ProfileDefinition; + +@Test(groups = "unit", testName = "ListProfilesHandlerTest") +public class ListProfilesHandlerTest extends BaseHandlerTest { + + public void test() { + final InputStream is = getClass().getResourceAsStream("/listprofiles.xml"); + final ListProfilesHandler handler = new ListProfilesHandler(new ProfileHandler()); + final List result = factory.create(handler).parse(is); + assertEquals(result, expected()); + } + + public static List expected() { + return ImmutableList.of( + Profile.create("jclouds.trafficmanager.net", + "jclouds", + ProfileDefinition.Status.ENABLED, + "1", + ImmutableMap.builder().put("1", ProfileDefinition.Status.ENABLED).build() + ), + Profile.create("jclouds2.trafficmanager.net", + "jclouds2", + ProfileDefinition.Status.DISABLED, + null, + ImmutableMap.builder().build() + )); + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ProfileDefinitionHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ProfileDefinitionHandlerTest.java new file mode 100644 index 000000000..292a46e26 --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ProfileDefinitionHandlerTest.java @@ -0,0 +1,71 @@ +/* + * 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.azurecompute.xml; + +import static org.testng.Assert.assertEquals; + +import java.io.InputStream; +import java.util.ArrayList; +import org.jclouds.azurecompute.domain.ProfileDefinition; +import org.jclouds.azurecompute.domain.ProfileDefinition.Status; +import org.jclouds.azurecompute.domain.ProfileDefinitionEndpoint; +import org.jclouds.azurecompute.domain.ProfileDefinitionMonitor; +import org.jclouds.http.functions.BaseHandlerTest; +import org.testng.annotations.Test; + +@Test(groups = "unit", testName = "ProfileDefinitionHandlerTest") +public class ProfileDefinitionHandlerTest extends BaseHandlerTest { + + public void test() { + final InputStream is = getClass().getResourceAsStream("/profiledefinition.xml"); + final ProfileDefinition result = factory.create(new ProfileDefinitionHandler( + new ProfileDefinitionMonitorHandler(), new ProfileDefinitionEndpointHandler())).parse(is); + assertEquals(result, expected()); + } + + public static ProfileDefinition expected() { + final ArrayList monitors = new ArrayList(); + monitors.add(ProfileDefinitionMonitor.create( + 30, 10, 3, ProfileDefinition.Protocol.HTTP, 80, "GET", "/", 200)); + + final ArrayList endpoints = new ArrayList(); + endpoints.add(ProfileDefinitionEndpoint.create("jclouds1.cloudapp.net", + Status.ENABLED, + ProfileDefinition.HealthStatus.STOPPED, + ProfileDefinitionEndpoint.Type.CLOUDSERVICE, + null, + 1, + null)); + + endpoints.add(ProfileDefinitionEndpoint.create("jclouds2.cloudapp.net", + Status.ENABLED, + ProfileDefinition.HealthStatus.STOPPED, + ProfileDefinitionEndpoint.Type.CLOUDSERVICE, + null, + 1, + null)); + + return ProfileDefinition.create(300, + Status.ENABLED, + "1", + monitors, + ProfileDefinition.LBMethod.ROUNDROBIN, + endpoints, + ProfileDefinition.HealthStatus.INACTIVE + ); + } +} diff --git a/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ProfileHandlerTest.java b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ProfileHandlerTest.java new file mode 100644 index 000000000..13a57ca9f --- /dev/null +++ b/azurecompute/src/test/java/org/jclouds/azurecompute/xml/ProfileHandlerTest.java @@ -0,0 +1,45 @@ +/* + * 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.azurecompute.xml; + +import autovalue.shaded.com.google.common.common.collect.ImmutableMap; +import static org.testng.Assert.assertEquals; + +import java.io.InputStream; +import org.jclouds.azurecompute.domain.Profile; +import org.jclouds.azurecompute.domain.ProfileDefinition.Status; +import org.jclouds.http.functions.BaseHandlerTest; +import org.testng.annotations.Test; + +@Test(groups = "unit", testName = "ProfileHandlerTest") +public class ProfileHandlerTest extends BaseHandlerTest { + + public void test() { + final InputStream is = getClass().getResourceAsStream("/profile.xml"); + final Profile result = factory.create(new ProfileHandler()).parse(is); + assertEquals(result, expected()); + } + + public static Profile expected() { + return Profile.create("jclouds.trafficmanager.net", + "jclouds", + Status.ENABLED, + "1", + ImmutableMap.builder().put("1", Status.ENABLED).build() + ); + } +} diff --git a/azurecompute/src/test/resources/checkdnsprefixavailability.xml b/azurecompute/src/test/resources/checkdnsprefixavailability.xml new file mode 100644 index 000000000..1b525adfa --- /dev/null +++ b/azurecompute/src/test/resources/checkdnsprefixavailability.xml @@ -0,0 +1,4 @@ + + + true + diff --git a/azurecompute/src/test/resources/createprofileparams.xml b/azurecompute/src/test/resources/createprofileparams.xml new file mode 100644 index 000000000..aa518b5e9 --- /dev/null +++ b/azurecompute/src/test/resources/createprofileparams.xml @@ -0,0 +1 @@ +jclouds.trafficmanager.netjclouds diff --git a/azurecompute/src/test/resources/listprofiledefinitions.xml b/azurecompute/src/test/resources/listprofiledefinitions.xml new file mode 100644 index 000000000..eff1b5189 --- /dev/null +++ b/azurecompute/src/test/resources/listprofiledefinitions.xml @@ -0,0 +1,44 @@ + + + + + 300 + + Enabled + 1 + + + 30 + 10 + 3 + HTTP + 80 + + GET + / + 200 + + + + + RoundRobin + + + jclouds1.cloudapp.net + Enabled + CloudService + Stopped + 1 + + + jclouds2.cloudapp.net + Enabled + CloudService + Stopped + 1 + + + Inactive + + + diff --git a/azurecompute/src/test/resources/listprofiles.xml b/azurecompute/src/test/resources/listprofiles.xml new file mode 100644 index 000000000..5ffa7cd44 --- /dev/null +++ b/azurecompute/src/test/resources/listprofiles.xml @@ -0,0 +1,23 @@ + + + + jclouds.trafficmanager.net + jclouds + Enabled + + 1 + + + + Enabled + 1 + + + + + jclouds2.trafficmanager.net + jclouds2 + Disabled + + + diff --git a/azurecompute/src/test/resources/profile.xml b/azurecompute/src/test/resources/profile.xml new file mode 100644 index 000000000..f69931f29 --- /dev/null +++ b/azurecompute/src/test/resources/profile.xml @@ -0,0 +1,15 @@ + + + jclouds.trafficmanager.net + jclouds + Enabled + + 1 + + + + Enabled + 1 + + + diff --git a/azurecompute/src/test/resources/profiledefinition.xml b/azurecompute/src/test/resources/profiledefinition.xml new file mode 100644 index 000000000..f272e0077 --- /dev/null +++ b/azurecompute/src/test/resources/profiledefinition.xml @@ -0,0 +1,42 @@ + + + + 300 + + Enabled + 1 + + + 30 + 10 + 3 + HTTP + 80 + + GET + / + 200 + + + + + RoundRobin + + + jclouds1.cloudapp.net + Enabled + CloudService + Stopped + 1 + + + jclouds2.cloudapp.net + Enabled + CloudService + Stopped + 1 + + + Inactive + + diff --git a/azurecompute/src/test/resources/profiledefinitioncsparams.xml b/azurecompute/src/test/resources/profiledefinitioncsparams.xml new file mode 100644 index 000000000..42bbdcfb7 --- /dev/null +++ b/azurecompute/src/test/resources/profiledefinitioncsparams.xml @@ -0,0 +1 @@ +30030103HTTP80GET/200RoundRobinjclouds1.cloudapp.netEnabledCloudService1jclouds2.cloudapp.netEnabledCloudService1 diff --git a/azurecompute/src/test/resources/profiledefinitiontmparams.xml b/azurecompute/src/test/resources/profiledefinitiontmparams.xml new file mode 100644 index 000000000..312f4be49 --- /dev/null +++ b/azurecompute/src/test/resources/profiledefinitiontmparams.xml @@ -0,0 +1,35 @@ + + + 300 + + + + 30 + 10 + 3 + HTTP + 80 + + GET + / + 200 + + + + + + RoundRobin + + + + jcloudsprova.cloudapp.net + Enabled + TrafficManager + West Europe + 1 + 1 + + + + + diff --git a/azurecompute/src/test/resources/updateprofileparams.xml b/azurecompute/src/test/resources/updateprofileparams.xml new file mode 100644 index 000000000..ee61d13ae --- /dev/null +++ b/azurecompute/src/test/resources/updateprofileparams.xml @@ -0,0 +1 @@ +Enabled1