From 1e62671ccec4fc02bd76e4bef779fece64ae37ff Mon Sep 17 00:00:00 2001 From: anuchan Date: Mon, 10 Oct 2016 13:27:48 -0700 Subject: [PATCH 01/12] Adding autoRest Generated trafficmanagement module --- azure-mgmt-trafficmanager/pom.xml | 136 ++++ .../management/trafficmanager/DnsConfig.java | 98 +++ .../trafficmanager/MonitorConfig.java | 119 ++++ ...iveDnsNameAvailabilityParametersInner.java | 66 ++ .../implementation/EndpointInner.java | 315 +++++++++ .../implementation/EndpointsInner.java | 470 +++++++++++++ .../implementation/PageImpl.java | 75 ++ .../implementation/ProfileInner.java | 156 +++++ .../implementation/ProfilesInner.java | 643 ++++++++++++++++++ .../TrafficManagerManagementClientImpl.java | 214 ++++++ .../TrafficManagerNameAvailabilityInner.java | 142 ++++ .../implementation/package-info.java | 10 + gulpfile.js | 6 + pom.xml | 1 + 14 files changed, 2451 insertions(+) create mode 100644 azure-mgmt-trafficmanager/pom.xml create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/DnsConfig.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/MonitorConfig.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointInner.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointsInner.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/PageImpl.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfileInner.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfilesInner.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerManagementClientImpl.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNameAvailabilityInner.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/package-info.java diff --git a/azure-mgmt-trafficmanager/pom.xml b/azure-mgmt-trafficmanager/pom.xml new file mode 100644 index 0000000000000..44335d5458d40 --- /dev/null +++ b/azure-mgmt-trafficmanager/pom.xml @@ -0,0 +1,136 @@ + + + 4.0.0 + + com.microsoft.azure + azure-parent + 1.0.0-beta4-SNAPSHOT + ../pom.xml + + + azure-mgmt-trafficmanager + jar + + Microsoft Azure SDK for Traffic Manager Management + This package contains Microsoft Azure Traffic Manager Management SDK. + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + scm:git:https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + UTF-8 + + + + + + microsoft + Microsoft + + + + + + com.microsoft.azure + azure-client-runtime + 1.0.0-beta3 + + + com.microsoft.azure + azure-mgmt-resources + 1.0.0-beta4-SNAPSHOT + + + junit + junit + test + + + com.microsoft.azure + azure-client-authentication + 1.0.0-beta3 + test + + + com.microsoft.azure + azure-mgmt-storage + 1.0.0-beta4-SNAPSHOT + + + com.microsoft.azure + api-annotations + 0.0.1 + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + true + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + com.microsoft.azure.management.apigeneration.LangDefinitionProcessor + + true + true + + true + true + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search + /** +
* Copyright (c) Microsoft Corporation. All rights reserved. +
* Licensed under the MIT License. See License.txt in the project root for +
* license information. +
*/]]>
+
+
+ +
+
+
diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/DnsConfig.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/DnsConfig.java new file mode 100644 index 0000000000000..d77a9d5789fec --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/DnsConfig.java @@ -0,0 +1,98 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.trafficmanager; + + +/** + * Class containing DNS settings in a Traffic Manager profile. + */ +public class DnsConfig { + /** + * Gets or sets the relative DNS name provided by this Traffic Manager + * profile. This value is combined with the DNS domain name used by + * Azure Traffic Manager to form the fully-qualified domain name (FQDN) + * of the profile. + */ + private String relativeName; + + /** + * Gets or sets the fully-qualified domain name (FQDN) of the Traffic + * Manager profile. This is formed from the concatenation of the + * RelativeName with the DNS domain used by Azure Traffic Manager. + */ + private String fqdn; + + /** + * Gets or sets the DNS Ttime-To-Live (TTL), in seconds. This informs the + * local DNS resolvers and DNS clients how long to cache DNS responses + * provided by this Traffic Manager profile. + */ + private Long ttl; + + /** + * Get the relativeName value. + * + * @return the relativeName value + */ + public String relativeName() { + return this.relativeName; + } + + /** + * Set the relativeName value. + * + * @param relativeName the relativeName value to set + * @return the DnsConfig object itself. + */ + public DnsConfig withRelativeName(String relativeName) { + this.relativeName = relativeName; + return this; + } + + /** + * Get the fqdn value. + * + * @return the fqdn value + */ + public String fqdn() { + return this.fqdn; + } + + /** + * Set the fqdn value. + * + * @param fqdn the fqdn value to set + * @return the DnsConfig object itself. + */ + public DnsConfig withFqdn(String fqdn) { + this.fqdn = fqdn; + return this; + } + + /** + * Get the ttl value. + * + * @return the ttl value + */ + public Long ttl() { + return this.ttl; + } + + /** + * Set the ttl value. + * + * @param ttl the ttl value to set + * @return the DnsConfig object itself. + */ + public DnsConfig withTtl(Long ttl) { + this.ttl = ttl; + return this; + } + +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/MonitorConfig.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/MonitorConfig.java new file mode 100644 index 0000000000000..d043abc9269ff --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/MonitorConfig.java @@ -0,0 +1,119 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.trafficmanager; + + +/** + * Class containing endpoint monitoring settings in a Traffic Manager profile. + */ +public class MonitorConfig { + /** + * Gets or sets the profile-level monitoring status of the Traffic Manager + * profile. + */ + private String profileMonitorStatus; + + /** + * Gets or sets the protocol (HTTP or HTTPS) used to probe for endpoint + * health. + */ + private String protocol; + + /** + * Gets or sets the TCP port used to probe for endpoint health. + */ + private Long port; + + /** + * Gets or sets the path relative to the endpoint domain name used to + * probe for endpoint health. + */ + private String path; + + /** + * Get the profileMonitorStatus value. + * + * @return the profileMonitorStatus value + */ + public String profileMonitorStatus() { + return this.profileMonitorStatus; + } + + /** + * Set the profileMonitorStatus value. + * + * @param profileMonitorStatus the profileMonitorStatus value to set + * @return the MonitorConfig object itself. + */ + public MonitorConfig withProfileMonitorStatus(String profileMonitorStatus) { + this.profileMonitorStatus = profileMonitorStatus; + return this; + } + + /** + * Get the protocol value. + * + * @return the protocol value + */ + public String protocol() { + return this.protocol; + } + + /** + * Set the protocol value. + * + * @param protocol the protocol value to set + * @return the MonitorConfig object itself. + */ + public MonitorConfig withProtocol(String protocol) { + this.protocol = protocol; + return this; + } + + /** + * Get the port value. + * + * @return the port value + */ + public Long port() { + return this.port; + } + + /** + * Set the port value. + * + * @param port the port value to set + * @return the MonitorConfig object itself. + */ + public MonitorConfig withPort(Long port) { + this.port = port; + return this; + } + + /** + * Get the path value. + * + * @return the path value + */ + public String path() { + return this.path; + } + + /** + * Set the path value. + * + * @param path the path value to set + * @return the MonitorConfig object itself. + */ + public MonitorConfig withPath(String path) { + this.path = path; + return this; + } + +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner.java new file mode 100644 index 0000000000000..fb5ca2acf6874 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner.java @@ -0,0 +1,66 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.trafficmanager.implementation; + + +/** + * Parameters supplied to check Traffic Manager name operation. + */ +public class CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner { + /** + * Gets or sets the name of the resource. + */ + private String name; + + /** + * Gets or sets the type of the resource. + */ + private String type; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner object itself. + */ + public CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner withName(String name) { + this.name = name; + return this; + } + + /** + * Get the type value. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner object itself. + */ + public CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner withType(String type) { + this.type = type; + return this; + } + +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointInner.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointInner.java new file mode 100644 index 0000000000000..4e25796ca44ca --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointInner.java @@ -0,0 +1,315 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; + +/** + * Class representing a Traffic Manager endpoint. + */ +@JsonFlatten +public class EndpointInner { + /** + * Gets or sets the ID of the Traffic Manager endpoint. + */ + private String id; + + /** + * Gets or sets the name of the Traffic Manager endpoint. + */ + private String name; + + /** + * Gets or sets the endpoint type of the Traffic Manager endpoint. + */ + private String type; + + /** + * Gets or sets the Azure Resource URI of the of the endpoint. Not + * applicable to endpoints of type 'ExternalEndpoints'. + */ + @JsonProperty(value = "properties.targetResourceId") + private String targetResourceId; + + /** + * Gets or sets the fully-qualified DNS name of the endpoint. Traffic + * Manager returns this value in DNS responses to direct traffic to this + * endpoint. + */ + @JsonProperty(value = "properties.target") + private String target; + + /** + * Gets or sets the status of the endpoint.. If the endpoint is Enabled, + * it is probed for endpoint health and is included in the traffic + * routing method. Possible values are 'Enabled' and 'Disabled'. + */ + @JsonProperty(value = "properties.endpointStatus") + private String endpointStatus; + + /** + * Gets or sets the weight of this endpoint when using the 'Weighted' + * traffic routing method. Possible values are from 1 to 1000. + */ + @JsonProperty(value = "properties.weight") + private Long weight; + + /** + * Gets or sets the priority of this endpoint when using the ‘Priority’ + * traffic routing method. Possible values are from 1 to 1000, lower + * values represent higher priority. This is an optional parameter. If + * specified, it must be specified on all endpoints, and no two endpoints + * can share the same priority value. + */ + @JsonProperty(value = "properties.priority") + private Long priority; + + /** + * Specifies the location of the external or nested endpoints when using + * the ‘Performance’ traffic routing method. + */ + @JsonProperty(value = "properties.endpointLocation") + private String endpointLocation; + + /** + * Gets or sets the monitoring status of the endpoint. + */ + @JsonProperty(value = "properties.endpointMonitorStatus") + private String endpointMonitorStatus; + + /** + * Gets or sets the minimum number of endpoints that must be available in + * the child profile in order for the parent profile to be considered + * available. Only applicable to endpoint of type 'NestedEndpoints'. + */ + @JsonProperty(value = "properties.minChildEndpoints") + private Long minChildEndpoints; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withId(String id) { + this.id = id; + return this; + } + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withName(String name) { + this.name = name; + return this; + } + + /** + * Get the type value. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withType(String type) { + this.type = type; + return this; + } + + /** + * Get the targetResourceId value. + * + * @return the targetResourceId value + */ + public String targetResourceId() { + return this.targetResourceId; + } + + /** + * Set the targetResourceId value. + * + * @param targetResourceId the targetResourceId value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withTargetResourceId(String targetResourceId) { + this.targetResourceId = targetResourceId; + return this; + } + + /** + * Get the target value. + * + * @return the target value + */ + public String target() { + return this.target; + } + + /** + * Set the target value. + * + * @param target the target value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withTarget(String target) { + this.target = target; + return this; + } + + /** + * Get the endpointStatus value. + * + * @return the endpointStatus value + */ + public String endpointStatus() { + return this.endpointStatus; + } + + /** + * Set the endpointStatus value. + * + * @param endpointStatus the endpointStatus value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withEndpointStatus(String endpointStatus) { + this.endpointStatus = endpointStatus; + return this; + } + + /** + * Get the weight value. + * + * @return the weight value + */ + public Long weight() { + return this.weight; + } + + /** + * Set the weight value. + * + * @param weight the weight value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withWeight(Long weight) { + this.weight = weight; + return this; + } + + /** + * Get the priority value. + * + * @return the priority value + */ + public Long priority() { + return this.priority; + } + + /** + * Set the priority value. + * + * @param priority the priority value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withPriority(Long priority) { + this.priority = priority; + return this; + } + + /** + * Get the endpointLocation value. + * + * @return the endpointLocation value + */ + public String endpointLocation() { + return this.endpointLocation; + } + + /** + * Set the endpointLocation value. + * + * @param endpointLocation the endpointLocation value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withEndpointLocation(String endpointLocation) { + this.endpointLocation = endpointLocation; + return this; + } + + /** + * Get the endpointMonitorStatus value. + * + * @return the endpointMonitorStatus value + */ + public String endpointMonitorStatus() { + return this.endpointMonitorStatus; + } + + /** + * Set the endpointMonitorStatus value. + * + * @param endpointMonitorStatus the endpointMonitorStatus value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withEndpointMonitorStatus(String endpointMonitorStatus) { + this.endpointMonitorStatus = endpointMonitorStatus; + return this; + } + + /** + * Get the minChildEndpoints value. + * + * @return the minChildEndpoints value + */ + public Long minChildEndpoints() { + return this.minChildEndpoints; + } + + /** + * Set the minChildEndpoints value. + * + * @param minChildEndpoints the minChildEndpoints value to set + * @return the EndpointInner object itself. + */ + public EndpointInner withMinChildEndpoints(Long minChildEndpoints) { + this.minChildEndpoints = minChildEndpoints; + return this; + } + +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointsInner.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointsInner.java new file mode 100644 index 0000000000000..1d34b471ebfac --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointsInner.java @@ -0,0 +1,470 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.trafficmanager.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceResponseBuilder; +import com.microsoft.azure.CloudException; +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.PATCH; +import retrofit2.http.Path; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in Endpoints. + */ +public final class EndpointsInner { + /** The Retrofit service to perform REST calls. */ + private EndpointsService service; + /** The service client containing this operation class. */ + private TrafficManagerManagementClientImpl client; + + /** + * Initializes an instance of EndpointsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public EndpointsInner(Retrofit retrofit, TrafficManagerManagementClientImpl client) { + this.service = retrofit.create(EndpointsService.class); + this.client = client; + } + + /** + * The interface defining all the services for Endpoints to be + * used by Retrofit to perform actually REST calls. + */ + interface EndpointsService { + @Headers("Content-Type: application/json; charset=utf-8") + @PATCH("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}") + Observable> update(@Path("resourceGroupName") String resourceGroupName, @Path("profileName") String profileName, @Path("endpointType") String endpointType, @Path("endpointName") String endpointName, @Path("subscriptionId") String subscriptionId, @Body EndpointInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}") + Observable> get(@Path("resourceGroupName") String resourceGroupName, @Path("profileName") String profileName, @Path("endpointType") String endpointType, @Path("endpointName") String endpointName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}") + Observable> createOrUpdate(@Path("resourceGroupName") String resourceGroupName, @Path("profileName") String profileName, @Path("endpointType") String endpointType, @Path("endpointName") String endpointName, @Path("subscriptionId") String subscriptionId, @Body EndpointInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}", method = "DELETE", hasBody = true) + Observable> delete(@Path("resourceGroupName") String resourceGroupName, @Path("profileName") String profileName, @Path("endpointType") String endpointType, @Path("endpointName") String endpointName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Update a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be updated. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be updated. + * @param endpointName The name of the Traffic Manager endpoint to be updated. + * @param parameters The Traffic Manager endpoint parameters supplied to the Update operation. + * @return the EndpointInner object if successful. + */ + public EndpointInner update(String resourceGroupName, String profileName, String endpointType, String endpointName, EndpointInner parameters) { + return updateWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName, parameters).toBlocking().single().getBody(); + } + + /** + * Update a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be updated. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be updated. + * @param endpointName The name of the Traffic Manager endpoint to be updated. + * @param parameters The Traffic Manager endpoint parameters supplied to the Update operation. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall updateAsync(String resourceGroupName, String profileName, String endpointType, String endpointName, EndpointInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName, parameters), serviceCallback); + } + + /** + * Update a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be updated. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be updated. + * @param endpointName The name of the Traffic Manager endpoint to be updated. + * @param parameters The Traffic Manager endpoint parameters supplied to the Update operation. + * @return the observable to the EndpointInner object + */ + public Observable updateAsync(String resourceGroupName, String profileName, String endpointType, String endpointName, EndpointInner parameters) { + return updateWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName, parameters).map(new Func1, EndpointInner>() { + @Override + public EndpointInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Update a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be updated. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be updated. + * @param endpointName The name of the Traffic Manager endpoint to be updated. + * @param parameters The Traffic Manager endpoint parameters supplied to the Update operation. + * @return the observable to the EndpointInner object + */ + public Observable> updateWithServiceResponseAsync(String resourceGroupName, String profileName, String endpointType, String endpointName, EndpointInner parameters) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (profileName == null) { + throw new IllegalArgumentException("Parameter profileName is required and cannot be null."); + } + if (endpointType == null) { + throw new IllegalArgumentException("Parameter endpointType is required and cannot be null."); + } + if (endpointName == null) { + throw new IllegalArgumentException("Parameter endpointName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(parameters); + return service.update(resourceGroupName, profileName, endpointType, endpointName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse updateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Gets a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint. + * @param endpointName The name of the Traffic Manager endpoint. + * @return the EndpointInner object if successful. + */ + public EndpointInner get(String resourceGroupName, String profileName, String endpointType, String endpointName) { + return getWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName).toBlocking().single().getBody(); + } + + /** + * Gets a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint. + * @param endpointName The name of the Traffic Manager endpoint. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall getAsync(String resourceGroupName, String profileName, String endpointType, String endpointName, final ServiceCallback serviceCallback) { + return ServiceCall.create(getWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName), serviceCallback); + } + + /** + * Gets a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint. + * @param endpointName The name of the Traffic Manager endpoint. + * @return the observable to the EndpointInner object + */ + public Observable getAsync(String resourceGroupName, String profileName, String endpointType, String endpointName) { + return getWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName).map(new Func1, EndpointInner>() { + @Override + public EndpointInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Gets a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint. + * @param endpointName The name of the Traffic Manager endpoint. + * @return the observable to the EndpointInner object + */ + public Observable> getWithServiceResponseAsync(String resourceGroupName, String profileName, String endpointType, String endpointName) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (profileName == null) { + throw new IllegalArgumentException("Parameter profileName is required and cannot be null."); + } + if (endpointType == null) { + throw new IllegalArgumentException("Parameter endpointType is required and cannot be null."); + } + if (endpointName == null) { + throw new IllegalArgumentException("Parameter endpointName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.get(resourceGroupName, profileName, endpointType, endpointName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Create or update a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be created or updated. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be created or updated. + * @param endpointName The name of the Traffic Manager endpoint to be created or updated. + * @param parameters The Traffic Manager endpoint parameters supplied to the CreateOrUpdate operation. + * @return the EndpointInner object if successful. + */ + public EndpointInner createOrUpdate(String resourceGroupName, String profileName, String endpointType, String endpointName, EndpointInner parameters) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName, parameters).toBlocking().single().getBody(); + } + + /** + * Create or update a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be created or updated. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be created or updated. + * @param endpointName The name of the Traffic Manager endpoint to be created or updated. + * @param parameters The Traffic Manager endpoint parameters supplied to the CreateOrUpdate operation. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall createOrUpdateAsync(String resourceGroupName, String profileName, String endpointType, String endpointName, EndpointInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(createOrUpdateWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName, parameters), serviceCallback); + } + + /** + * Create or update a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be created or updated. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be created or updated. + * @param endpointName The name of the Traffic Manager endpoint to be created or updated. + * @param parameters The Traffic Manager endpoint parameters supplied to the CreateOrUpdate operation. + * @return the observable to the EndpointInner object + */ + public Observable createOrUpdateAsync(String resourceGroupName, String profileName, String endpointType, String endpointName, EndpointInner parameters) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName, parameters).map(new Func1, EndpointInner>() { + @Override + public EndpointInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Create or update a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be created or updated. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be created or updated. + * @param endpointName The name of the Traffic Manager endpoint to be created or updated. + * @param parameters The Traffic Manager endpoint parameters supplied to the CreateOrUpdate operation. + * @return the observable to the EndpointInner object + */ + public Observable> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String profileName, String endpointType, String endpointName, EndpointInner parameters) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (profileName == null) { + throw new IllegalArgumentException("Parameter profileName is required and cannot be null."); + } + if (endpointType == null) { + throw new IllegalArgumentException("Parameter endpointType is required and cannot be null."); + } + if (endpointName == null) { + throw new IllegalArgumentException("Parameter endpointName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(parameters); + return service.createOrUpdate(resourceGroupName, profileName, endpointType, endpointName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createOrUpdateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createOrUpdateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(201, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Deletes a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be deleted. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be deleted. + * @param endpointName The name of the Traffic Manager endpoint to be deleted. + */ + public void delete(String resourceGroupName, String profileName, String endpointType, String endpointName) { + deleteWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName).toBlocking().single().getBody(); + } + + /** + * Deletes a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be deleted. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be deleted. + * @param endpointName The name of the Traffic Manager endpoint to be deleted. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall deleteAsync(String resourceGroupName, String profileName, String endpointType, String endpointName, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName), serviceCallback); + } + + /** + * Deletes a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be deleted. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be deleted. + * @param endpointName The name of the Traffic Manager endpoint to be deleted. + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String resourceGroupName, String profileName, String endpointType, String endpointName) { + return deleteWithServiceResponseAsync(resourceGroupName, profileName, endpointType, endpointName).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Deletes a Traffic Manager endpoint. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager endpoint to be deleted. + * @param profileName The name of the Traffic Manager profile. + * @param endpointType The type of the Traffic Manager endpoint to be deleted. + * @param endpointName The name of the Traffic Manager endpoint to be deleted. + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String resourceGroupName, String profileName, String endpointType, String endpointName) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (profileName == null) { + throw new IllegalArgumentException("Parameter profileName is required and cannot be null."); + } + if (endpointType == null) { + throw new IllegalArgumentException("Parameter endpointType is required and cannot be null."); + } + if (endpointName == null) { + throw new IllegalArgumentException("Parameter endpointName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.delete(resourceGroupName, profileName, endpointType, endpointName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(204, new TypeToken() { }.getType()) + .build(response); + } + +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/PageImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/PageImpl.java new file mode 100644 index 0000000000000..a7b26586d8396 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/PageImpl.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.azure.Page; +import java.util.List; + +/** + * An instance of this class defines a page of Azure resources and a link to + * get the next page of resources, if any. + * + * @param type of Azure resource + */ +public class PageImpl implements Page { + /** + * The link to the next page. + */ + @JsonProperty("") + private String nextPageLink; + + /** + * The list of items. + */ + @JsonProperty("value") + private List items; + + /** + * Gets the link to the next page. + * + * @return the link to the next page. + */ + @Override + public String getNextPageLink() { + return this.nextPageLink; + } + + /** + * Gets the list of items. + * + * @return the list of items in {@link List}. + */ + @Override + public List getItems() { + return items; + } + + /** + * Sets the link to the next page. + * + * @param nextPageLink the link to the next page. + * @return this Page object itself. + */ + public PageImpl setNextPageLink(String nextPageLink) { + this.nextPageLink = nextPageLink; + return this; + } + + /** + * Sets the list of items. + * + * @param items the list of items in {@link List}. + * @return this Page object itself. + */ + public PageImpl setItems(List items) { + this.items = items; + return this; + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfileInner.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfileInner.java new file mode 100644 index 0000000000000..1aa419ce77a1c --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfileInner.java @@ -0,0 +1,156 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.management.trafficmanager.DnsConfig; +import com.microsoft.azure.management.trafficmanager.MonitorConfig; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.Resource; + +/** + * Class representing a Traffic Manager profile. + */ +@JsonFlatten +public class ProfileInner extends Resource { + /** + * Gets or sets the status of the Traffic Manager profile. Possible + * values are 'Enabled' and 'Disabled'. + */ + @JsonProperty(value = "properties.profileStatus") + private String profileStatus; + + /** + * Gets or sets the traffic routing method of the Traffic Manager profile. + * Possible values are 'Performance', 'Weighted', or 'Priority'. + */ + @JsonProperty(value = "properties.trafficRoutingMethod") + private String trafficRoutingMethod; + + /** + * Gets or sets the DNS settings of the Traffic Manager profile. + */ + @JsonProperty(value = "properties.dnsConfig") + private DnsConfig dnsConfig; + + /** + * Gets or sets the endpoint monitoring settings of the Traffic Manager + * profile. + */ + @JsonProperty(value = "properties.monitorConfig") + private MonitorConfig monitorConfig; + + /** + * Gets or sets the list of endpoints in the Traffic Manager profile. + */ + @JsonProperty(value = "properties.endpoints") + private List endpoints; + + /** + * Get the profileStatus value. + * + * @return the profileStatus value + */ + public String profileStatus() { + return this.profileStatus; + } + + /** + * Set the profileStatus value. + * + * @param profileStatus the profileStatus value to set + * @return the ProfileInner object itself. + */ + public ProfileInner withProfileStatus(String profileStatus) { + this.profileStatus = profileStatus; + return this; + } + + /** + * Get the trafficRoutingMethod value. + * + * @return the trafficRoutingMethod value + */ + public String trafficRoutingMethod() { + return this.trafficRoutingMethod; + } + + /** + * Set the trafficRoutingMethod value. + * + * @param trafficRoutingMethod the trafficRoutingMethod value to set + * @return the ProfileInner object itself. + */ + public ProfileInner withTrafficRoutingMethod(String trafficRoutingMethod) { + this.trafficRoutingMethod = trafficRoutingMethod; + return this; + } + + /** + * Get the dnsConfig value. + * + * @return the dnsConfig value + */ + public DnsConfig dnsConfig() { + return this.dnsConfig; + } + + /** + * Set the dnsConfig value. + * + * @param dnsConfig the dnsConfig value to set + * @return the ProfileInner object itself. + */ + public ProfileInner withDnsConfig(DnsConfig dnsConfig) { + this.dnsConfig = dnsConfig; + return this; + } + + /** + * Get the monitorConfig value. + * + * @return the monitorConfig value + */ + public MonitorConfig monitorConfig() { + return this.monitorConfig; + } + + /** + * Set the monitorConfig value. + * + * @param monitorConfig the monitorConfig value to set + * @return the ProfileInner object itself. + */ + public ProfileInner withMonitorConfig(MonitorConfig monitorConfig) { + this.monitorConfig = monitorConfig; + return this; + } + + /** + * Get the endpoints value. + * + * @return the endpoints value + */ + public List endpoints() { + return this.endpoints; + } + + /** + * Set the endpoints value. + * + * @param endpoints the endpoints value to set + * @return the ProfileInner object itself. + */ + public ProfileInner withEndpoints(List endpoints) { + this.endpoints = endpoints; + return this; + } + +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfilesInner.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfilesInner.java new file mode 100644 index 0000000000000..65e89d8026acc --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfilesInner.java @@ -0,0 +1,643 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.trafficmanager.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureServiceResponseBuilder; +import com.microsoft.azure.CloudException; +import com.microsoft.rest.ServiceCall; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.PATCH; +import retrofit2.http.Path; +import retrofit2.http.POST; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in Profiles. + */ +public final class ProfilesInner { + /** The Retrofit service to perform REST calls. */ + private ProfilesService service; + /** The service client containing this operation class. */ + private TrafficManagerManagementClientImpl client; + + /** + * Initializes an instance of ProfilesInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public ProfilesInner(Retrofit retrofit, TrafficManagerManagementClientImpl client) { + this.service = retrofit.create(ProfilesService.class); + this.client = client; + } + + /** + * The interface defining all the services for Profiles to be + * used by Retrofit to perform actually REST calls. + */ + interface ProfilesService { + @Headers("Content-Type: application/json; charset=utf-8") + @POST("providers/Microsoft.Network/checkTrafficManagerNameAvailability") + Observable> checkTrafficManagerRelativeDnsNameAvailability(@Path("subscriptionId") String subscriptionId, @Body CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles") + Observable> listAllInResourceGroup(@Path("resourceGroupName") String resourceGroupName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficmanagerprofiles") + Observable> listAll(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}") + Observable> get(@Path("resourceGroupName") String resourceGroupName, @Path("profileName") String profileName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}") + Observable> createOrUpdate(@Path("resourceGroupName") String resourceGroupName, @Path("profileName") String profileName, @Path("subscriptionId") String subscriptionId, @Body ProfileInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}", method = "DELETE", hasBody = true) + Observable> delete(@Path("resourceGroupName") String resourceGroupName, @Path("profileName") String profileName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers("Content-Type: application/json; charset=utf-8") + @PATCH("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}") + Observable> update(@Path("resourceGroupName") String resourceGroupName, @Path("profileName") String profileName, @Path("subscriptionId") String subscriptionId, @Body ProfileInner parameters, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Checks the availability of a Traffic Manager Relative DNS name. + * + * @param parameters The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. + * @return the TrafficManagerNameAvailabilityInner object if successful. + */ + public TrafficManagerNameAvailabilityInner checkTrafficManagerRelativeDnsNameAvailability(CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner parameters) { + return checkTrafficManagerRelativeDnsNameAvailabilityWithServiceResponseAsync(parameters).toBlocking().single().getBody(); + } + + /** + * Checks the availability of a Traffic Manager Relative DNS name. + * + * @param parameters The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall checkTrafficManagerRelativeDnsNameAvailabilityAsync(CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(checkTrafficManagerRelativeDnsNameAvailabilityWithServiceResponseAsync(parameters), serviceCallback); + } + + /** + * Checks the availability of a Traffic Manager Relative DNS name. + * + * @param parameters The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. + * @return the observable to the TrafficManagerNameAvailabilityInner object + */ + public Observable checkTrafficManagerRelativeDnsNameAvailabilityAsync(CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner parameters) { + return checkTrafficManagerRelativeDnsNameAvailabilityWithServiceResponseAsync(parameters).map(new Func1, TrafficManagerNameAvailabilityInner>() { + @Override + public TrafficManagerNameAvailabilityInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Checks the availability of a Traffic Manager Relative DNS name. + * + * @param parameters The Traffic Manager name parameters supplied to the CheckTrafficManagerNameAvailability operation. + * @return the observable to the TrafficManagerNameAvailabilityInner object + */ + public Observable> checkTrafficManagerRelativeDnsNameAvailabilityWithServiceResponseAsync(CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner parameters) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(parameters); + return service.checkTrafficManagerRelativeDnsNameAvailability(this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = checkTrafficManagerRelativeDnsNameAvailabilityDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse checkTrafficManagerRelativeDnsNameAvailabilityDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Lists all Traffic Manager profiles within a resource group. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profiles to be listed. + * @return the List<ProfileInner> object if successful. + */ + public List listAllInResourceGroup(String resourceGroupName) { + return listAllInResourceGroupWithServiceResponseAsync(resourceGroupName).toBlocking().single().getBody(); + } + + /** + * Lists all Traffic Manager profiles within a resource group. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profiles to be listed. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall> listAllInResourceGroupAsync(String resourceGroupName, final ServiceCallback> serviceCallback) { + return ServiceCall.create(listAllInResourceGroupWithServiceResponseAsync(resourceGroupName), serviceCallback); + } + + /** + * Lists all Traffic Manager profiles within a resource group. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profiles to be listed. + * @return the observable to the List<ProfileInner> object + */ + public Observable> listAllInResourceGroupAsync(String resourceGroupName) { + return listAllInResourceGroupWithServiceResponseAsync(resourceGroupName).map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * Lists all Traffic Manager profiles within a resource group. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profiles to be listed. + * @return the observable to the List<ProfileInner> object + */ + public Observable>> listAllInResourceGroupWithServiceResponseAsync(String resourceGroupName) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.listAllInResourceGroup(resourceGroupName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listAllInResourceGroupDelegate(response); + ServiceResponse> clientResponse = new ServiceResponse>(result.getBody().getItems(), result.getResponse()); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listAllInResourceGroupDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, CloudException>(this.client.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Lists all Traffic Manager profiles within a subscription. + * + * @return the List<ProfileInner> object if successful. + */ + public List listAll() { + return listAllWithServiceResponseAsync().toBlocking().single().getBody(); + } + + /** + * Lists all Traffic Manager profiles within a subscription. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall> listAllAsync(final ServiceCallback> serviceCallback) { + return ServiceCall.create(listAllWithServiceResponseAsync(), serviceCallback); + } + + /** + * Lists all Traffic Manager profiles within a subscription. + * + * @return the observable to the List<ProfileInner> object + */ + public Observable> listAllAsync() { + return listAllWithServiceResponseAsync().map(new Func1>, List>() { + @Override + public List call(ServiceResponse> response) { + return response.getBody(); + } + }); + } + + /** + * Lists all Traffic Manager profiles within a subscription. + * + * @return the observable to the List<ProfileInner> object + */ + public Observable>> listAllWithServiceResponseAsync() { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.listAll(this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listAllDelegate(response); + ServiceResponse> clientResponse = new ServiceResponse>(result.getBody().getItems(), result.getResponse()); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listAllDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder, CloudException>(this.client.mapperAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Gets a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @return the ProfileInner object if successful. + */ + public ProfileInner get(String resourceGroupName, String profileName) { + return getWithServiceResponseAsync(resourceGroupName, profileName).toBlocking().single().getBody(); + } + + /** + * Gets a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall getAsync(String resourceGroupName, String profileName, final ServiceCallback serviceCallback) { + return ServiceCall.create(getWithServiceResponseAsync(resourceGroupName, profileName), serviceCallback); + } + + /** + * Gets a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @return the observable to the ProfileInner object + */ + public Observable getAsync(String resourceGroupName, String profileName) { + return getWithServiceResponseAsync(resourceGroupName, profileName).map(new Func1, ProfileInner>() { + @Override + public ProfileInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Gets a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @return the observable to the ProfileInner object + */ + public Observable> getWithServiceResponseAsync(String resourceGroupName, String profileName) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (profileName == null) { + throw new IllegalArgumentException("Parameter profileName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.get(resourceGroupName, profileName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Create or update a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @param parameters The Traffic Manager profile parameters supplied to the CreateOrUpdate operation. + * @return the ProfileInner object if successful. + */ + public ProfileInner createOrUpdate(String resourceGroupName, String profileName, ProfileInner parameters) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, profileName, parameters).toBlocking().single().getBody(); + } + + /** + * Create or update a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @param parameters The Traffic Manager profile parameters supplied to the CreateOrUpdate operation. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall createOrUpdateAsync(String resourceGroupName, String profileName, ProfileInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(createOrUpdateWithServiceResponseAsync(resourceGroupName, profileName, parameters), serviceCallback); + } + + /** + * Create or update a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @param parameters The Traffic Manager profile parameters supplied to the CreateOrUpdate operation. + * @return the observable to the ProfileInner object + */ + public Observable createOrUpdateAsync(String resourceGroupName, String profileName, ProfileInner parameters) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, profileName, parameters).map(new Func1, ProfileInner>() { + @Override + public ProfileInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Create or update a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @param parameters The Traffic Manager profile parameters supplied to the CreateOrUpdate operation. + * @return the observable to the ProfileInner object + */ + public Observable> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String profileName, ProfileInner parameters) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (profileName == null) { + throw new IllegalArgumentException("Parameter profileName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(parameters); + return service.createOrUpdate(resourceGroupName, profileName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createOrUpdateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createOrUpdateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(201, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + + /** + * Deletes a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile to be deleted. + * @param profileName The name of the Traffic Manager profile to be deleted. + */ + public void delete(String resourceGroupName, String profileName) { + deleteWithServiceResponseAsync(resourceGroupName, profileName).toBlocking().single().getBody(); + } + + /** + * Deletes a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile to be deleted. + * @param profileName The name of the Traffic Manager profile to be deleted. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall deleteAsync(String resourceGroupName, String profileName, final ServiceCallback serviceCallback) { + return ServiceCall.create(deleteWithServiceResponseAsync(resourceGroupName, profileName), serviceCallback); + } + + /** + * Deletes a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile to be deleted. + * @param profileName The name of the Traffic Manager profile to be deleted. + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String resourceGroupName, String profileName) { + return deleteWithServiceResponseAsync(resourceGroupName, profileName).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Deletes a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile to be deleted. + * @param profileName The name of the Traffic Manager profile to be deleted. + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String resourceGroupName, String profileName) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (profileName == null) { + throw new IllegalArgumentException("Parameter profileName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + return service.delete(resourceGroupName, profileName, this.client.subscriptionId(), this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(204, new TypeToken() { }.getType()) + .build(response); + } + + /** + * Update a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @param parameters The Traffic Manager profile parameters supplied to the Update operation. + * @return the ProfileInner object if successful. + */ + public ProfileInner update(String resourceGroupName, String profileName, ProfileInner parameters) { + return updateWithServiceResponseAsync(resourceGroupName, profileName, parameters).toBlocking().single().getBody(); + } + + /** + * Update a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @param parameters The Traffic Manager profile parameters supplied to the Update operation. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceCall} object + */ + public ServiceCall updateAsync(String resourceGroupName, String profileName, ProfileInner parameters, final ServiceCallback serviceCallback) { + return ServiceCall.create(updateWithServiceResponseAsync(resourceGroupName, profileName, parameters), serviceCallback); + } + + /** + * Update a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @param parameters The Traffic Manager profile parameters supplied to the Update operation. + * @return the observable to the ProfileInner object + */ + public Observable updateAsync(String resourceGroupName, String profileName, ProfileInner parameters) { + return updateWithServiceResponseAsync(resourceGroupName, profileName, parameters).map(new Func1, ProfileInner>() { + @Override + public ProfileInner call(ServiceResponse response) { + return response.getBody(); + } + }); + } + + /** + * Update a Traffic Manager profile. + * + * @param resourceGroupName The name of the resource group containing the Traffic Manager profile. + * @param profileName The name of the Traffic Manager profile. + * @param parameters The Traffic Manager profile parameters supplied to the Update operation. + * @return the observable to the ProfileInner object + */ + public Observable> updateWithServiceResponseAsync(String resourceGroupName, String profileName, ProfileInner parameters) { + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (profileName == null) { + throw new IllegalArgumentException("Parameter profileName is required and cannot be null."); + } + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + if (this.client.apiVersion() == null) { + throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."); + } + Validator.validate(parameters); + return service.update(resourceGroupName, profileName, this.client.subscriptionId(), parameters, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse updateDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return new AzureServiceResponseBuilder(this.client.mapperAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerManagementClientImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerManagementClientImpl.java new file mode 100644 index 0000000000000..9541fdcdde7c8 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerManagementClientImpl.java @@ -0,0 +1,214 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.AzureClient; +import com.microsoft.azure.AzureServiceClient; +import com.microsoft.azure.RestClient; +import com.microsoft.rest.credentials.ServiceClientCredentials; + +/** + * Initializes a new instance of the TrafficManagerManagementClientImpl class. + */ +public final class TrafficManagerManagementClientImpl extends AzureServiceClient { + /** the {@link AzureClient} used for long running operations. */ + private AzureClient azureClient; + + /** + * Gets the {@link AzureClient} used for long running operations. + * @return the azure client; + */ + public AzureClient getAzureClient() { + return this.azureClient; + } + + /** Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. */ + private String subscriptionId; + + /** + * Gets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + * + * @return the subscriptionId value. + */ + public String subscriptionId() { + return this.subscriptionId; + } + + /** + * Sets Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + * + * @param subscriptionId the subscriptionId value. + * @return the service client itself + */ + public TrafficManagerManagementClientImpl withSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + return this; + } + + /** Client Api Version. */ + private String apiVersion; + + /** + * Gets Client Api Version. + * + * @return the apiVersion value. + */ + public String apiVersion() { + return this.apiVersion; + } + + /** Gets or sets the preferred language for the response. */ + private String acceptLanguage; + + /** + * Gets Gets or sets the preferred language for the response. + * + * @return the acceptLanguage value. + */ + public String acceptLanguage() { + return this.acceptLanguage; + } + + /** + * Sets Gets or sets the preferred language for the response. + * + * @param acceptLanguage the acceptLanguage value. + * @return the service client itself + */ + public TrafficManagerManagementClientImpl withAcceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + return this; + } + + /** Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. */ + private int longRunningOperationRetryTimeout; + + /** + * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @return the longRunningOperationRetryTimeout value. + */ + public int longRunningOperationRetryTimeout() { + return this.longRunningOperationRetryTimeout; + } + + /** + * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + * @return the service client itself + */ + public TrafficManagerManagementClientImpl withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { + this.longRunningOperationRetryTimeout = longRunningOperationRetryTimeout; + return this; + } + + /** When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ + private boolean generateClientRequestId; + + /** + * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @return the generateClientRequestId value. + */ + public boolean generateClientRequestId() { + return this.generateClientRequestId; + } + + /** + * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @param generateClientRequestId the generateClientRequestId value. + * @return the service client itself + */ + public TrafficManagerManagementClientImpl withGenerateClientRequestId(boolean generateClientRequestId) { + this.generateClientRequestId = generateClientRequestId; + return this; + } + + /** + * The EndpointsInner object to access its operations. + */ + private EndpointsInner endpoints; + + /** + * Gets the EndpointsInner object to access its operations. + * @return the EndpointsInner object. + */ + public EndpointsInner endpoints() { + return this.endpoints; + } + + /** + * The ProfilesInner object to access its operations. + */ + private ProfilesInner profiles; + + /** + * Gets the ProfilesInner object to access its operations. + * @return the ProfilesInner object. + */ + public ProfilesInner profiles() { + return this.profiles; + } + + /** + * Initializes an instance of TrafficManagerManagementClient client. + * + * @param credentials the management credentials for Azure + */ + public TrafficManagerManagementClientImpl(ServiceClientCredentials credentials) { + this("https://management.azure.com", credentials); + } + + /** + * Initializes an instance of TrafficManagerManagementClient client. + * + * @param baseUrl the base URL of the host + * @param credentials the management credentials for Azure + */ + public TrafficManagerManagementClientImpl(String baseUrl, ServiceClientCredentials credentials) { + this(new RestClient.Builder() + .withBaseUrl(baseUrl) + .withCredentials(credentials) + .build()); + } + + /** + * Initializes an instance of TrafficManagerManagementClient client. + * + * @param restClient the REST client to connect to Azure. + */ + public TrafficManagerManagementClientImpl(RestClient restClient) { + super(restClient); + initialize(); + } + + protected void initialize() { + this.apiVersion = "2015-11-01"; + this.acceptLanguage = "en-US"; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.endpoints = new EndpointsInner(restClient().retrofit(), this); + this.profiles = new ProfilesInner(restClient().retrofit(), this); + this.azureClient = new AzureClient(this); + } + + /** + * Gets the User-Agent header for the client. + * + * @return the user agent string. + */ + @Override + public String userAgent() { + return String.format("Azure-SDK-For-Java/%s (%s)", + getClass().getPackage().getImplementationVersion(), + "TrafficManagerManagementClient, 2015-11-01"); + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNameAvailabilityInner.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNameAvailabilityInner.java new file mode 100644 index 0000000000000..a6abb730aa414 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNameAvailabilityInner.java @@ -0,0 +1,142 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.trafficmanager.implementation; + + +/** + * Class representing a Traffic Manager Name Availability response. + */ +public class TrafficManagerNameAvailabilityInner { + /** + * The relative name. + */ + private String name; + + /** + * Traffic Manager profile resource type. + */ + private String type; + + /** + * Describes whether the relative name is available or not. + */ + private Boolean nameAvailable; + + /** + * The reason why the name is not available, when applicable. + */ + private String reason; + + /** + * Descriptive message that explains why the name is not available, when + * applicable. + */ + private String message; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the TrafficManagerNameAvailabilityInner object itself. + */ + public TrafficManagerNameAvailabilityInner withName(String name) { + this.name = name; + return this; + } + + /** + * Get the type value. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the TrafficManagerNameAvailabilityInner object itself. + */ + public TrafficManagerNameAvailabilityInner withType(String type) { + this.type = type; + return this; + } + + /** + * Get the nameAvailable value. + * + * @return the nameAvailable value + */ + public Boolean nameAvailable() { + return this.nameAvailable; + } + + /** + * Set the nameAvailable value. + * + * @param nameAvailable the nameAvailable value to set + * @return the TrafficManagerNameAvailabilityInner object itself. + */ + public TrafficManagerNameAvailabilityInner withNameAvailable(Boolean nameAvailable) { + this.nameAvailable = nameAvailable; + return this; + } + + /** + * Get the reason value. + * + * @return the reason value + */ + public String reason() { + return this.reason; + } + + /** + * Set the reason value. + * + * @param reason the reason value to set + * @return the TrafficManagerNameAvailabilityInner object itself. + */ + public TrafficManagerNameAvailabilityInner withReason(String reason) { + this.reason = reason; + return this; + } + + /** + * Get the message value. + * + * @return the message value + */ + public String message() { + return this.message; + } + + /** + * Set the message value. + * + * @param message the message value to set + * @return the TrafficManagerNameAvailabilityInner object itself. + */ + public TrafficManagerNameAvailabilityInner withMessage(String message) { + this.message = message; + return this; + } + +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/package-info.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/package-info.java new file mode 100644 index 0000000000000..47b1e63b276de --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/package-info.java @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the implementation classes for TrafficManagerManagementClient. + */ +package com.microsoft.azure.management.trafficmanager.implementation; diff --git a/gulpfile.js b/gulpfile.js index 2ecf5685ad9a0..3574a74f0fb54 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -74,6 +74,12 @@ var mappings = { 'package': 'com.microsoft.azure.management.search', 'args': '-FT 1' }, + 'trafficmanager': { + 'dir': 'azure-mgmt-trafficmanager', + 'source': 'arm-trafficmanager/2015-11-01/swagger/trafficmanager.json', + 'package': 'com.microsoft.azure.management.trafficmanager', + 'args': '-FT 1' + }, 'datalake.store.filesystem': { 'dir': 'azure-mgmt-datalake-store', 'source': 'arm-datalake-store/filesystem/2015-10-01-preview/swagger/filesystem.json', diff --git a/pom.xml b/pom.xml index 3afd19fa52b1a..036a191fb467c 100644 --- a/pom.xml +++ b/pom.xml @@ -291,5 +291,6 @@ ./azure-mgmt-redis ./azure-mgmt-search ./azure-mgmt-batch + ./azure-mgmt-trafficmanager From eff915163a68d72629cae0d21108e893c1bd7fa6 Mon Sep 17 00:00:00 2001 From: anuchan Date: Tue, 11 Oct 2016 15:38:36 -0700 Subject: [PATCH 02/12] Defining and implementing the fluent interfaces --- .../trafficmanager/AzureEndpoint.java | 21 + .../management/trafficmanager/Endpoint.java | 500 ++++++++++++++++++ .../trafficmanager/EndpointMonitorStatus.java | 68 +++ .../trafficmanager/EndpointType.java | 53 ++ .../trafficmanager/ExternalEndpoint.java | 16 + .../trafficmanager/NestedProfileEndpoint.java | 21 + .../management/trafficmanager/Profile.java | 436 +++++++++++++++ .../trafficmanager/ProfileMonitorStatus.java | 63 +++ .../management/trafficmanager/Profiles.java | 31 ++ .../TargetAzureResourceType.java | 53 ++ .../trafficmanager/TrafficRoutingMethod.java | 53 ++ .../implementation/AzureEndpointImpl.java | 34 ++ .../implementation/EndpointImpl.java | 174 ++++++ .../implementation/EndpointsImpl.java | 192 +++++++ .../implementation/ExternalEndpointImpl.java | 26 + .../NestedProfileEndpointImpl.java | 34 ++ .../implementation/ProfileImpl.java | 241 +++++++++ .../implementation/ProfilesImpl.java | 75 +++ .../implementation/TrafficManager.java | 99 ++++ 19 files changed, 2190 insertions(+) create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/AzureEndpoint.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Endpoint.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointMonitorStatus.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointType.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ExternalEndpoint.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/NestedProfileEndpoint.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Profile.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileMonitorStatus.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Profiles.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TargetAzureResourceType.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficRoutingMethod.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/AzureEndpointImpl.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointImpl.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointsImpl.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ExternalEndpointImpl.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/NestedProfileEndpointImpl.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfileImpl.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfilesImpl.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManager.java diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/AzureEndpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/AzureEndpoint.java new file mode 100644 index 0000000000000..c08444b86e232 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/AzureEndpoint.java @@ -0,0 +1,21 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +/** + * An immutable client-side representation of an Azure traffic manager profile Azure endpoint. + */ +public interface AzureEndpoint extends Endpoint { + /** + * @return the resource id of the target Azure resource. + */ + String targetAzureResourceId(); + + /** + * @return the type of the target Azure resource. + */ + TargetAzureResourceType targetResourceType(); +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Endpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Endpoint.java new file mode 100644 index 0000000000000..6402734718fa3 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Endpoint.java @@ -0,0 +1,500 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +import com.microsoft.azure.management.apigeneration.Fluent; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import com.microsoft.azure.management.resources.fluentcore.arm.models.ExternalChildResource; +import com.microsoft.azure.management.resources.fluentcore.model.Attachable; +import com.microsoft.azure.management.resources.fluentcore.model.Settable; +import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; +import com.microsoft.azure.management.trafficmanager.implementation.EndpointInner; + +/** + * An immutable client-side representation of an Azure traffic manager profile endpoint. + */ +@Fluent +public interface Endpoint extends + ExternalChildResource, + Wrapper { + /** + * @return the endpoint type + */ + EndpointType endpointType(); + + /** + * @return the monitor status of the endpoint + */ + EndpointMonitorStatus monitorStatus(); + + /** + * @return true if the endpoint is disabled, false otherwise + */ + boolean isDisabled(); + + /** + * @return the weight of the endpoint which is used when traffic manager profile is configured with + * Weighted traffic-routing method + */ + int routingWeight(); + + /** + * @return the priority of the endpoint which is used when traffic manager profile is configured with + * Priority traffic-routing method + */ + int routingPriority(); + + /** + * The entirety of a traffic manager profile endpoint definition as a part of parent definition. + * + * @param the return type of the final {@link Attachable#attach()} + */ + interface Definition extends + DefinitionStages.Blank, + DefinitionStages.WithEndpointType, + DefinitionStages.WithEndpointThreshold, + DefinitionStages.WithSourceTrafficLocation, + DefinitionStages.WithAttach { + } + + /** + * Grouping of traffic manager profile endpoint definition stages as a part of parent traffic manager + * profile definition. + */ + interface DefinitionStages { + /** + * The first stage of a traffic manager profile endpoint definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface Blank extends WithEndpointType { + } + + /** + * The stage of the traffic manager profile endpoint definition allowing to specify the type. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithEndpointType { + /** + * Specify that the endpoint is an Azure cloud service, web app or public ip. + * + * @param resourceId the Azure resource id + * @return the next stage of the endpoint definition + */ + WithAttach withTargetAzureResourceId(String resourceId); + + /** + * Specify that the endpoint is an external endpoint that is not hosted in Azure. + * + * @param externalFqdn the external FQDN + * @return the next stage of the endpoint definition + */ + WithSourceTrafficLocation withExternalFqdn(String externalFqdn); + + /** + * Specify that the endpoint is a nested traffic manager profile. + * + * @param nestedProfile the nested traffic manager profile + * @return the next stage of the endpoint definition + */ + WithEndpointThreshold withNestedProfile(Profile nestedProfile); + } + + /** + * The stage of the nested traffic manager profile endpoint definition allowing to specify the minimum + * endpoints to be online in the nested profile to consider it as not degraded. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithEndpointThreshold { + /** + * Specifies the child endpoint threshold. + * + * @param count the number of child endpoints to be online to consider nested profile as healthy + * @return the next stage of the endpoint definition + */ + WithSourceTrafficLocation withMinimumChildEndpoints(int count); + } + + /** + * The stage of the traffic manager endpoint definition allowing to specify the location of the external + * or nested profile endpoints. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithSourceTrafficLocation { + /** + * Specifies the location of the endpoint that will be used when the parent profile is configured with + * Performance routing method {@link TrafficRoutingMethod#PERFORMANCE}. + * + * @param location the location + * @return the next stage of the endpoint definition + */ + WithAttach withSourceTrafficLocation(Region location); + } + + /** + * The stage of the traffic manager endpoint definition allowing to specify the endpoint weight. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithRoutingWeight { + /** + * Specifies the weight for the endpoint that will be used when the parent profile is configured with + * Weighted routing method {@link TrafficRoutingMethod#WEIGHTED}. + * + * @param weight the endpoint weight + * @return the next stage of the endpoint definition + */ + WithAttach withRoutingWeight(int weight); + } + + /** + * The stage of the traffic manager endpoint definition allowing to specify the endpoint priority. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithRoutingPriority { + /** + * Specifies the priority for the endpoint that will be used when the parent profile is configured with + * Priority routing method {@link TrafficRoutingMethod#PRIORITY}. + * + * @param priority the endpoint priority + * @return the next stage of the endpoint definition + */ + WithAttach withRoutingPriority(int priority); + } + + /** + * The stage of the traffic manager endpoint definition allowing to disable the endpoint. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithTrafficDisabled { + /** + * Specify that this endpoint should be excluded from receiving traffic. + * + * @return the next stage of the endpoint definition + */ + WithAttach withTrafficDisabled(); + } + + /** The final stage of the traffic manager profile endpoint definition. + *

+ * At this stage, any remaining optional settings can be specified, or the traffic manager profile endpoint + * definition can be attached to the parent traffic manager profile definition using {@link Endpoint.DefinitionStages.WithAttach#attach()}. + * @param the return type of {@link Endpoint.DefinitionStages.WithAttach#attach()} + */ + interface WithAttach extends + Attachable.InDefinition, + DefinitionStages.WithRoutingWeight, + DefinitionStages.WithRoutingPriority, + DefinitionStages.WithTrafficDisabled { + } + } + + /** + * The entirety of a traffic manager profile endpoint definition as a part of parent update. + * + * @param the return type of the final {@link Attachable#attach()} + */ + interface UpdateDefinition extends + UpdateDefinitionStages.Blank, + UpdateDefinitionStages.WithEndpointType, + UpdateDefinitionStages.WithEndpointThreshold, + UpdateDefinitionStages.WithSourceTrafficLocation, + UpdateDefinitionStages.WithAttach { + } + + /** + * Grouping of traffic manager profile endpoint definition stages as a part of parent traffic manager + * profile update. + */ + interface UpdateDefinitionStages { + /** + * The first stage of a traffic manager profile endpoint definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface Blank extends WithEndpointType { + } + + /** + * The stage of the traffic manager profile endpoint definition allowing to specify the type. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithEndpointType { + /** + * Specify that the endpoint is an Azure cloud service, web app or public ip. + * + * @param resourceId the Azure resource id + * @return the next stage of the definition + */ + WithAttach withTargetAzureResourceId(String resourceId); + + /** + * Specify that the endpoint is an external endpoint that is not hosted in Azure. + * + * @param externalFqdn the external FQDN + * @return the next stage of the definition + */ + WithSourceTrafficLocation withExternalFqdn(String externalFqdn); + + /** + * Specify that the endpoint is a nested traffic manager profile. + * + * @param nestedProfile the nested traffic manager profile + * @return the next stage of the definition + */ + WithEndpointThreshold withNestedProfile(Profile nestedProfile); + } + + /** + * The stage of the nested traffic manager profile endpoint definition allowing to specify the minimum + * endpoints to be online in the nested profile to consider it as not degraded. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithEndpointThreshold { + /** + * Specifies the child endpoint threshold. + * + * @param count the number of child endpoints to be online to consider nested profile as healthy + * @return the next stage of the definition + */ + WithSourceTrafficLocation withMinimumChildEndpoints(int count); + } + + /** + * The stage of the traffic manager endpoint definition allowing to specify the location of the external + * or nested profile endpoints. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithSourceTrafficLocation { + /** + * Specifies the location of the endpoint that will be used when the parent profile is configured with + * Performance routing method {@link TrafficRoutingMethod#PERFORMANCE}. + * + * @param location the location + * @return the next stage of the definition + */ + WithAttach withSourceTrafficLocation(Region location); + } + + /** + * The stage of the traffic manager endpoint definition allowing to specify the endpoint weight. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithRoutingWeight { + /** + * Specifies the weight for the endpoint that will be used when the parent profile is configured with + * Weighted routing method {@link TrafficRoutingMethod#WEIGHTED}. + * + * @param weight the endpoint weight + * @return the next stage of the definition + */ + WithAttach withRoutingWeight(int weight); + } + + /** + * The stage of the traffic manager endpoint definition allowing to specify the endpoint priority. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithRoutingPriority { + /** + * Specifies the weight for the endpoint that will be used when the parent profile is configured with + * Priority routing method {@link TrafficRoutingMethod#PRIORITY}. + * + * @param priority + * @return the next stage of the definition + */ + WithAttach withRoutingPriority(int priority); + } + + /** + * The stage of the traffic manager endpoint definition allowing to disable the endpoint. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithTrafficDisabled { + /** + * Specify that this endpoint should be excluded from receiving traffic. + * + * @return the next stage of the definition + */ + WithAttach withTrafficDisabled(); + } + + /** The final stage of the traffic manager profile endpoint definition. + *

+ * At this stage, any remaining optional settings can be specified, or the traffic manager profile endpoint + * definition can be attached to the parent traffic manager profile update using {@link Endpoint.DefinitionStages.WithAttach#attach()}. + * @param the return type of {@link Endpoint.DefinitionStages.WithAttach#attach()} + */ + interface WithAttach extends + Attachable.InUpdate, + UpdateDefinitionStages.WithRoutingWeight, + UpdateDefinitionStages.WithRoutingPriority, + UpdateDefinitionStages.WithTrafficDisabled { + } + } + + /** + * The entirety of an Azure endpoint update as a part of parent traffic manager profile profile update. + */ + interface UpdateAzureEndpoint extends + UpdateStages.WithTargetAzureResourceId, + Update { + } + + /** + * The entirety of an external endpoint update as a part of parent traffic manager profile profile update. + */ + interface UpdateExternalEndpoint extends + UpdateStages.WithExternalFqdn, + UpdateStages.WithSourceTrafficLocation, + Update { + } + + /** + * The entirety of a nested profile endpoint update as a part of parent traffic manager profile profile update. + */ + interface UpdateNestedProfileEndpoint extends + UpdateStages.WithNestedProfileConfig, + UpdateStages.WithSourceTrafficLocation, + Update { + } + + /** + * the set of configurations that can be updated for all endpoint irrespective of their type (Azure, external, nested profile). + */ + interface Update extends + Settable, + UpdateStages.WithRoutingWeight, + UpdateStages.WithRoutingPriority, + UpdateStages.WithTrafficDisabledOrEnabled { + } + + /** + * Grouping of traffic manager profile endpoint update stages. + */ + interface UpdateStages { + /** + * The stage of an Azure endpoint update allowing to specify the target Azure resource. + */ + interface WithTargetAzureResourceId { + /** + * Specify the resource id of target Azure cloud service, web app or public ip. + * + * @param resourceId the Azure resource id + * @return the next stage of the endpoint update + */ + Update withTargetAzureResourceId(String resourceId); + } + + /** + * The stage of an external endpoint update allowing to specify the FQDN. + */ + interface WithExternalFqdn { + /** + * Specify the FQDN of an external endpoint that is not hosted in Azure. + * + * @param externalFqdn the external FQDN + * @return the next stage of the endpoint update + */ + UpdateExternalEndpoint withExternalFqdn(String externalFqdn); + } + + /** + * The stage of an nested profile endpoint update allowing to specify profile and + * minimum child endpoint. + */ + interface WithNestedProfileConfig { + /** + * Specify the traffic manager profile to be used as nested profile. + * + * @param nestedProfile the nested traffic manager profile + * @return the next stage of the update + */ + UpdateNestedProfileEndpoint withNestedProfile(Profile nestedProfile); + + /** + * Specifies the child endpoint threshold. + * + * @param count the number of child endpoints to be online to consider nested profile as healthy + * @return the next stage of the endpoint update + */ + UpdateNestedProfileEndpoint withMinimumChildEndpoints(int count); + } + + /** + * The stage of the traffic manager endpoint update allowing to specify the location of the external + * or nested profile endpoints. + */ + interface WithSourceTrafficLocation { + /** + * Specifies the location of the endpoint that will be used when the parent profile is configured with + * Performance routing method {@link TrafficRoutingMethod#PERFORMANCE}. + * + * @param location the location + * @return the next stage of the endpoint update + */ + Update withSourceTrafficLocation(Region location); + } + + /** + * The stage of the traffic manager profile endpoint update allowing to specify the endpoint weight. + */ + interface WithRoutingWeight { + /** + * Specifies the weight for the endpoint that will be used when the parent profile is configured with + * Weighted routing method {@link TrafficRoutingMethod#WEIGHTED}. + * + * @param weight the endpoint weight + * @return the next stage of the update + */ + Update withRoutingWeight(int weight); + } + + /** + * The stage of the traffic manager profile endpoint update allowing to specify the endpoint priority. + */ + interface WithRoutingPriority { + /** + * Specifies the weight for the endpoint that will be used when the parent profile is configured with + * Priority routing method {@link TrafficRoutingMethod#PRIORITY}. + * + * @param priority the endpoint priority + * @return the next stage of the update + */ + Update withRoutingPriority(int priority); + } + + /** + * The stage of the traffic manager profile endpoint update allowing to enable or disable it. + */ + interface WithTrafficDisabledOrEnabled { + /** + * Specify that the endpoint should be excluded from receiving traffic. + * + * @return the next stage of the update + */ + Update withTrafficDisabled(); + + /** + * Specify that the endpoint should receive the traffic. + * + * @return the next stage of the update + */ + Update withTrafficEnabled(); + } + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointMonitorStatus.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointMonitorStatus.java new file mode 100644 index 0000000000000..66d11d7cff039 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointMonitorStatus.java @@ -0,0 +1,68 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +/** + * Possible traffic manager profile endpoint monitor statuses. + */ +public enum EndpointMonitorStatus { + /** + * Enum value Inactive. + */ + INACTIVE("Inactive"), + + /** + * Enum value Disabled. + */ + DISABLED("Disabled"), + + /** + * Enum value Online. + */ + ONLINE("Online"), + + /** + * Enum value Degraded. + */ + DEGRADED("Degraded"), + + /** + * Enum value CheckingEndpoint. + */ + CHECKINGENDPOINT("CheckingEndpoint"), + + /** + * Enum value Stopped. + */ + STOPPED("Stopped"); + + private String value; + + EndpointMonitorStatus(String value) { + this.value = value; + } + + /** + * Parses a string value to a EndpointMonitorStatus instance. + * + * @param value the string value to parse. + * @return the parsed EndpointMonitorStatus object, or null if unable to parse. + */ + public static EndpointMonitorStatus fromValue(String value) { + EndpointMonitorStatus[] items = EndpointMonitorStatus.values(); + for (EndpointMonitorStatus item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @Override + public String toString() { + return this.value; + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointType.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointType.java new file mode 100644 index 0000000000000..85f60ee18213c --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointType.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +/** + * Possible endpoint types supported in a Traffic manager profile. + */ +public enum EndpointType { + /** + * Enum value AzureEndpoints. + */ + AZURE("AzureEndpoints"), + + /** + * Enum value ExternalEndpoints. + */ + EXTERNAL("ExternalEndpoints"), + + /** + * Enum value NestedEndpoints. + */ + NESTEDPROFILE("NestedEndpoints"); + + private String value; + + EndpointType(String value) { + this.value = value; + } + + /** + * Parses a string value to a TrafficRoutingMethod instance. + * + * @param value the string value to parse. + * @return the parsed TrafficRoutingMethod object, or null if unable to parse. + */ + public static EndpointType fromValue(String value) { + EndpointType[] items = EndpointType.values(); + for (EndpointType item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @Override + public String toString() { + return this.value; + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ExternalEndpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ExternalEndpoint.java new file mode 100644 index 0000000000000..af5191d464991 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ExternalEndpoint.java @@ -0,0 +1,16 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +/** + * An immutable client-side representation of an Azure traffic manager profile external endpoint. + */ +public interface ExternalEndpoint extends Endpoint { + /** + * @return the fully qualified DNS name of the external endpoint. + */ + String fqdn(); +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/NestedProfileEndpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/NestedProfileEndpoint.java new file mode 100644 index 0000000000000..390c7d4fa775e --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/NestedProfileEndpoint.java @@ -0,0 +1,21 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +/** + * An immutable client-side representation of an Azure traffic manager profile nested profile endpoint. + */ +public interface NestedProfileEndpoint extends Endpoint { + /** + * @return the nested traffic manager profile resource id + */ + String nestedProfileId(); + + /** + * @return the number of child endpoints to be online to consider nested profile as healthy + */ + int minChildEndpoints(); +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Profile.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Profile.java new file mode 100644 index 0000000000000..008fda7bc4630 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Profile.java @@ -0,0 +1,436 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +import com.microsoft.azure.management.apigeneration.Fluent; +import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource; +import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource; +import com.microsoft.azure.management.resources.fluentcore.model.Appliable; +import com.microsoft.azure.management.resources.fluentcore.model.Creatable; +import com.microsoft.azure.management.resources.fluentcore.model.Refreshable; +import com.microsoft.azure.management.resources.fluentcore.model.Updatable; +import com.microsoft.azure.management.resources.fluentcore.model.Wrapper; +import com.microsoft.azure.management.trafficmanager.implementation.ProfileInner; + +import java.util.Map; + +/** + * An immutable client-side representation of an Azure traffic manager profile. + */ +@Fluent +public interface Profile extends + GroupableResource, + Refreshable, + Wrapper, + Updatable { + /** + * @return the relative DNS name of the traffic manager profile + */ + String dnsLabel(); + + /** + * @return fully qualified domain name (FQDN) of the traffic manager profile. + */ + String fqdn(); + + /** + * @return the DNS Ttime-To-Live (TTL), in seconds + */ + int ttl(); + + /** + * @return true if the traffic manager profile is disabled, false if enabled + */ + boolean isDisabled(); + + /** + * @return the routing method used to route traffic to traffic manager profile endpoints + */ + TrafficRoutingMethod trafficRoutingMethod(); + + /** + * @return profile monitor status which is combination of the endpoint monitor status values for all endpoints in + * the profile, and the configured profile status + */ + ProfileMonitorStatus monitorStatus(); + + /** + * @return the port that is monitored to check the health of traffic manager profile endpoints + */ + int monitoringPort(); + + /** + * @return the path that is monitored to check the health of traffic manager profile endpoints + */ + String monitoringPath(); + + /** + * + * @return external endpoints in the traffic manager profile, indexed by the name + */ + Map externalEndpoints(); + + /** + * + * @return Azure endpoints in the traffic manager profile, indexed by the name + */ + Map azureEndpoints(); + + /** + * + * @return nested traffic manager profile endpoints in this traffic manager profile, indexed by the name + */ + Map nestedProfileEndpoints(); + + /** + * The entirety of the traffic manager profile definition. + */ + interface Definition extends + DefinitionStages.Blank, + DefinitionStages.WithGroup, + DefinitionStages.WithDnsLabel, + DefinitionStages.WithTrafficRoutingMethod, + DefinitionStages.WithMonitoringConfiguration, + DefinitionStages.WithCreate { + } + + /** + * Grouping of traffic manager profile definition stages. + */ + interface DefinitionStages { + /** + * The first stage of a traffic manager profile definition. + */ + interface Blank extends GroupableResource.DefinitionWithRegion { + } + + /** + * The stage of the traffic manager profile definition allowing to specify the resource group. + */ + interface WithGroup extends GroupableResource.DefinitionStages.WithGroup { + } + + /** + * The stage of the traffic manager profile definition allowing to specify the relative DNS name. + */ + interface WithDnsLabel { + /** + * Specify the relative DNS name of the profile. + *

+ * + * @param dnsLabel the relative DNS name of the profile + * @return the next stage of the traffic manager profile definition + */ + WithTrafficRoutingMethod withDnsLabel(String dnsLabel); + } + + /** + * The stage of the traffic manager profile definition allowing to specify the traffic routing method + * for the profile. + */ + interface WithTrafficRoutingMethod { + /** + * Specify that end user traffic should be routed to the endpoint based on its priority + * i.e. use the endpoint with highest priority and if it is not available fallback to next highest + * priority endpoint. + * + * @return the next stage of the traffic manager profile definition + */ + WithMonitoringConfiguration withPriorityRouting(); + + /** + * Specify that end user traffic should be distributed to the endpoints based on the weight assigned + * to the endpoint. + * + * @return the next stage of the traffic manager profile definition + */ + WithMonitoringConfiguration withWeightedRouting(); + + /** + * Specify that end user traffic should be routed based on the geographic location of the endpoint + * close to user. + * + * @return the next stage of the traffic manager profile definition + */ + WithMonitoringConfiguration withPerformanceRouting(); + + /** + * Specify the traffic routing method for the profile. + * + * @param routingMethod the traffic routing method for the profile + * @return the next stage of the traffic manager profile definition + */ + WithMonitoringConfiguration withTrafficRoutingMethod(TrafficRoutingMethod routingMethod); + } + + /** + * The stage of the traffic manager profile definition allowing to specify the endpoint monitoring configuration. + */ + interface WithMonitoringConfiguration { + /** + * Specify to use HTTP monitoring for the endpoints that checks for HTTP 200 response from the path '/' + * at regular intervals, using port 80. + * + * @return the next stage of the traffic manager profile definition + */ + WithEndpoint withHttpMonitoring(); + + /** + * Specify to use HTTPS monitoring for the endpoints that checks for HTTPS 200 response from the path '/' + * at regular intervals, using port 443. + * + * @return the next stage of the traffic manager profile definition + */ + WithEndpoint withHttpsMonitoring(); + + /** + * Specify the HTTP monitoring for the endpoints that checks for HTTP 200 response from the specified + * path at regular intervals, using the specified port. + * + * @param port the monitoring port + * @param path the monitoring path + * @return the next stage of the traffic manager profile definition + */ + WithEndpoint withHttpMonitoring(int port, String path); + + /** + * Specify the HTTPS monitoring for the endpoints that checks for HTTPS 200 response from the specified + * path at regular intervals, using the specified port. + * + * @param port the monitoring port + * @param path the monitoring path + * @return the next stage of the traffic manager profile definition + */ + WithEndpoint withHttpsMonitoring(int port, String path); + } + + /** + * The stage of the traffic manager profile definition allowing to specify endpoint. + */ + interface WithEndpoint { + /** + * Specifies definition of an endpoint to be attached to the traffic manager profile. + * + * @param name the name for the endpoint + * @return the stage representing configuration for the endpoint + */ + Endpoint.DefinitionStages.Blank defineNewEndpoint(String name); + } + + /** + * The stage of the traffic manager profile definition allowing to specify the DNS TTL. + */ + interface WithTtl { + /** + * Specify the DNS TTL in seconds. + * + * @param ttlInSeconds DNS TTL in seconds + * @return the next stage of the traffic manager profile definition + */ + WithCreate withTtl(int ttlInSeconds); + } + + /** + * The stage of the traffic manager profile definition allowing to disable the profile. + */ + interface WithProfileStatus { + /** + * Specify that the profile needs to be disabled. + *

+ * Disabling the profile will disables traffic to all endpoints in the profile + * + * @return the next stage of the traffic manager profile definition + */ + WithCreate withProfileStatusDisabled(); + } + + /** + * The stage of the definition which contains all the minimum required inputs for the resource to be created + * (via {@link WithCreate#create()}), but also allows for any other optional settings to be specified. + */ + interface WithCreate extends + Creatable, + Resource.DefinitionWithTags, + DefinitionStages.WithTtl, + DefinitionStages.WithProfileStatus, + DefinitionStages.WithEndpoint { + } + } + + /** + * Grouping of traffic manager update stages. + */ + interface UpdateStages { + /** + * The stage of the traffic manager profile update allowing to specify the traffic routing method + * for the profile. + */ + interface WithTrafficRoutingMethod { + /** + * Specify that end user traffic should be routed to the endpoint based on its priority + * i.e. use the endpoint with highest priority and if it is not available fallback to next highest + * priority endpoint. + * + * @return the next stage of the traffic manager profile update + */ + Update withPriorityRouting(); + + /** + * Specify that end user traffic should be distributed to the endpoints based on the weight assigned + * to the endpoint. + * + * @return the next stage of the traffic manager profile update + */ + Update withWeightedRouting(); + + /** + * Specify that end user traffic should be routed based on the geographic location of the endpoint + * close to user. + * + * @return the next stage of the traffic manager profile update + */ + Update withPerformanceRouting(); + + /** + * Specify the traffic routing method for the profile. + * + * @param routingMethod the traffic routing method for the profile + * @return the next stage of the traffic manager profile update + */ + Update withTrafficRoutingMethod(TrafficRoutingMethod routingMethod); + } + + /** + * The stage of the traffic manager profile update allowing to specify the endpoint monitoring configuration. + */ + interface WithMonitoringConfiguration { + /** + * Specify to use HTTP monitoring for the endpoints that checks for HTTP 200 response from the path '/' + * at regular intervals, using port 80. + * + * @return the next stage of the traffic manager profile update + */ + Update withHttpMonitoring(); + + /** + * Specify to use HTTPS monitoring for the endpoints that checks for HTTPS 200 response from the path '/' + * at regular intervals, using port 443. + * + * @return the next stage of the traffic manager profile update + */ + Update withHttpsMonitoring(); + + /** + * Specify the HTTP monitoring for the endpoints that checks for HTTP 200 response from the specified + * path at regular intervals, using the specified port. + * + * @param port the monitoring port + * @param path the monitoring path + * @return the next stage of the traffic manager profile update + */ + Update withHttpMonitoring(int port, String path); + + /** + * Specify the HTTPS monitoring for the endpoints that checks for HTTPS 200 response from the specified + * path at regular intervals, using the specified port. + * + * @param port the monitoring port + * @param path the monitoring path + * @return the next stage of the traffic manager profile update + */ + Update withHttpsMonitoring(int port, String path); + } + + /** + * The stage of the traffic manager profile update allowing to specify endpoints. + */ + interface WithEndpoint { + /** + * Specifies definition of an endpoint to be attached to the traffic manager profile. + * + * @param name the name for the endpoint + * @return the stage representing configuration for the endpoint + */ + Endpoint.UpdateDefinitionStages.Blank defineNewEndpoint(String name); + + /** + * Begins the description of an update of an existing Azure endpoint in this profile. + * + * @param name the name of the Azure endpoint + * @return the stage representing updating configuration for the Azure endpoint + */ + Endpoint.UpdateAzureEndpoint updateAzureEndpoint(String name); + + /** + * Begins the description of an update of an existing external endpoint in this profile. + * + * @param name the name of the external endpoint + * @return the stage representing updating configuration for the external endpoint + */ + Endpoint.UpdateExternalEndpoint updateExternalEndpoint(String name); + + /** + * Begins the description of an update of an existing nested traffic manager profile endpoint + * in this profile. + * + * @param name the name of the nested profile endpoint + * @return the stage representing updating configuration for the nested traffic manager profile endpoint + */ + Endpoint.UpdateNestedProfileEndpoint updateNestedProfileEndpoint(String name); + } + + /** + * The stage of the traffic manager profile update allowing to specify the DNS TTL. + */ + interface WithTtl { + /** + * Specify the DNS TTL in seconds. + * + * @param ttlInSeconds DNS TTL in seconds + * @return the next stage of the traffic manager profile update + */ + Update withTtl(int ttlInSeconds); + } + + /** + * The stage of the traffic manager profile update allowing to disable or enable the profile. + */ + interface WithProfileStatus { + /** + * Specify that the profile needs to be disabled. + *

+ * Disabling the profile will disables traffic to all endpoints in the profile + * + * @return the next stage of the traffic manager profile update + */ + Update withProfileStatusDisabled(); + + /** + * Specify that the profile needs to be enabled. + *

+ * Enabling the profile will enables traffic to all endpoints in the profile + * + * @return the next stage of the traffic manager profile update + */ + Update withProfileStatusEnabled(); + } + } + + /** + * The template for an update operation, containing all the settings that can be modified. + *

+ * Call {@link Update#apply()} to apply the changes to the resource in Azure. + */ + interface Update extends + Appliable, + UpdateStages.WithTrafficRoutingMethod, + UpdateStages.WithMonitoringConfiguration, + UpdateStages.WithEndpoint, + UpdateStages.WithTtl, + UpdateStages.WithProfileStatus, + Resource.UpdateWithTags { + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileMonitorStatus.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileMonitorStatus.java new file mode 100644 index 0000000000000..5e77c2e155656 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileMonitorStatus.java @@ -0,0 +1,63 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +/** + * Possible traffic manager profile statuses. + */ +public enum ProfileMonitorStatus { + /** + * Enum value Inactive. + */ + INACTIVE("Inactive"), + + /** + * Enum value Disabled. + */ + DISABLED("Disabled"), + + /** + * Enum value Online. + */ + ONLINE("Online"), + + /** + * Enum value Degraded. + */ + DEGRADED("Degraded"), + + /** + * Enum value CheckingEndpoint. + */ + CHECKINGENDPOINT("CheckingEndpoint"); + + private String value; + + ProfileMonitorStatus(String value) { + this.value = value; + } + + /** + * Parses a string value to a ProfileMonitorStatus instance. + * + * @param value the string value to parse. + * @return the parsed ProfileMonitorStatus object, or null if unable to parse. + */ + public static ProfileMonitorStatus fromValue(String value) { + ProfileMonitorStatus[] items = ProfileMonitorStatus.values(); + for (ProfileMonitorStatus item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @Override + public String toString() { + return this.value; + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Profiles.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Profiles.java new file mode 100644 index 0000000000000..81c90e749d397 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Profiles.java @@ -0,0 +1,31 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +import com.microsoft.azure.management.apigeneration.Fluent; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsDeletingByGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingByGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsGettingById; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.SupportsListingByGroup; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsBatchCreation; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsCreating; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsDeleting; +import com.microsoft.azure.management.resources.fluentcore.collection.SupportsListing; + +/** + * Entry point to traffic manager profile management API in Azure. + */ +@Fluent() +public interface Profiles extends + SupportsCreating, + SupportsListing, + SupportsListingByGroup, + SupportsGettingByGroup, + SupportsGettingById, + SupportsDeleting, + SupportsDeletingByGroup, + SupportsBatchCreation { +} \ No newline at end of file diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TargetAzureResourceType.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TargetAzureResourceType.java new file mode 100644 index 0000000000000..2fa29c48becfd --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TargetAzureResourceType.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +/** + * Target Azure resource types supported for an Azure endpoint in a traffic manager profile. + */ +public class TargetAzureResourceType { + /** Static value Microsoft.Network/publicIPAddresses for TargetAzureResourceType. */ + public static final TargetAzureResourceType PUBLICIP = new TargetAzureResourceType("Microsoft.Network", "publicIPAddresses"); + + /** Static value Microsoft.Web/sites for TargetAzureResourceType. */ + public static final TargetAzureResourceType WEBAPP = new TargetAzureResourceType("Microsoft.Web", "sites"); + + /** Static value Microsoft.ClassicCompute/domainNames for TargetAzureResourceType. */ + public static final TargetAzureResourceType CLOUDSERVICE = new TargetAzureResourceType("Microsoft.ClassicCompute", "domainNames"); + + private String value; + + public TargetAzureResourceType(String resourceProviderName, String resourceType) { + this.value = resourceProviderName + "/" + resourceType; + } + + @Override + public String toString() { + return this.value; + } + + @Override + public int hashCode() { + return this.value.hashCode(); + } + + @Override + public boolean equals(Object obj) { + String value = this.toString(); + if (!(obj instanceof TargetAzureResourceType)) { + return false; + } + if (obj == this) { + return true; + } + TargetAzureResourceType rhs = (TargetAzureResourceType) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficRoutingMethod.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficRoutingMethod.java new file mode 100644 index 0000000000000..f1ec8939c0377 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficRoutingMethod.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +/** + * Possible routing methods supported by Traffic manager profile. + */ +public enum TrafficRoutingMethod { + /** + * Enum value Performance. + */ + PERFORMANCE("Performance"), + + /** + * Enum value Weighted. + */ + WEIGHTED("Weighted"), + + /** + * Enum value Priority. + */ + PRIORITY("Priority"); + + private String value; + + TrafficRoutingMethod(String value) { + this.value = value; + } + + /** + * Parses a string value to a TrafficRoutingMethod instance. + * + * @param value the string value to parse. + * @return the parsed TrafficRoutingMethod object, or null if unable to parse. + */ + public static TrafficRoutingMethod fromValue(String value) { + TrafficRoutingMethod[] items = TrafficRoutingMethod.values(); + for (TrafficRoutingMethod item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + @Override + public String toString() { + return this.value; + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/AzureEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/AzureEndpointImpl.java new file mode 100644 index 0000000000000..2e11856f03bfa --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/AzureEndpointImpl.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; +import com.microsoft.azure.management.trafficmanager.AzureEndpoint; +import com.microsoft.azure.management.trafficmanager.TargetAzureResourceType; + +/** + * Implementation for {@link AzureEndpoint} + */ +class AzureEndpointImpl extends EndpointImpl + implements AzureEndpoint { + AzureEndpointImpl(String name, + ProfileImpl parent, + EndpointInner inner, + EndpointsInner client) { + super(name, parent, inner, client); + } + + @Override + public String targetAzureResourceId() { + return inner().targetResourceId(); + } + + @Override + public TargetAzureResourceType targetResourceType() { + return new TargetAzureResourceType(ResourceUtils.resourceProviderFromResourceId(targetAzureResourceId()), + ResourceUtils.resourceTypeFromResourceId(targetAzureResourceId())); + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointImpl.java new file mode 100644 index 0000000000000..a844eecc26152 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointImpl.java @@ -0,0 +1,174 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.ExternalChildResourceImpl; +import com.microsoft.azure.management.trafficmanager.Endpoint; +import com.microsoft.azure.management.trafficmanager.EndpointMonitorStatus; +import com.microsoft.azure.management.trafficmanager.Profile; +import com.microsoft.azure.management.trafficmanager.EndpointType; +import rx.Observable; +import rx.functions.Func1; + +/** + * Implementation for {@link Endpoint} + */ +class EndpointImpl extends ExternalChildResourceImpl + implements Endpoint, + Endpoint.Definition, + Endpoint.UpdateDefinition, + Endpoint.UpdateAzureEndpoint, + Endpoint.UpdateExternalEndpoint, + Endpoint.UpdateNestedProfileEndpoint { + private final EndpointsInner client; + private final String endpointStatusDisabled = "Disabled"; + private final String endpointStatusEnabled = "Enabled"; + + EndpointImpl(String name, + ProfileImpl parent, + EndpointInner inner, + EndpointsInner client) { + super(name, parent, inner); + this.client = client; + } + + @Override + public String id() { + return this.inner().id(); + } + + @Override + public EndpointType endpointType() { + return EndpointType.fromValue(this.inner().type()); + } + + @Override + public EndpointMonitorStatus monitorStatus() { + return EndpointMonitorStatus.fromValue(this.inner().endpointMonitorStatus()); + } + + @Override + public boolean isDisabled() { + return this.inner().endpointStatus().equalsIgnoreCase(this.endpointStatusDisabled); + } + + @Override + public int routingWeight() { + return this.inner().weight().intValue(); + } + + @Override + public int routingPriority() { + return this.inner().priority().intValue(); + } + + @Override + public EndpointImpl withMinimumChildEndpoints(int count) { + this.inner().withMinChildEndpoints(new Long(count)); + return this; + } + + @Override + public EndpointImpl withTargetAzureResourceId(String resourceId) { + this.inner().withTargetResourceId(resourceId); + return this; + } + + @Override + public EndpointImpl withExternalFqdn(String externalFqdn) { + this.inner().withTarget(externalFqdn); + return this; + } + + public EndpointImpl withSourceTrafficLocation(Region location) { + this.inner().withEndpointLocation(location.toString()); + return this; + } + + @Override + public EndpointImpl withNestedProfile(Profile nestedProfile) { + this.inner().withTargetResourceId(nestedProfile.id()); + return this; + } + + @Override + public EndpointImpl withRoutingPriority(int priority) { + this.inner().withPriority(new Long(priority)); + return this; + } + + @Override + public EndpointImpl withTrafficDisabled() { + this.inner().withEndpointStatus(this.endpointStatusDisabled); + return this; + } + + @Override + public EndpointImpl withTrafficEnabled() { + this.inner().withEndpointStatus(this.endpointStatusEnabled); + return this; + } + + @Override + public EndpointImpl withRoutingWeight(int weight) { + this.inner().withWeight(new Long(weight)); + return this; + } + + @Override + public Observable createAsync() { + final EndpointImpl self = this; + return this.client.createOrUpdateAsync(this.parent().resourceGroupName(), + this.parent().name(), + this.endpointType().toString(), + this.name(), + this.inner()) + .map(new Func1() { + @Override + public Endpoint call(EndpointInner inner) { + self.setInner(inner); + return self; + } + }); + } + + @Override + public Observable updateAsync() { + return createAsync(); + } + + @Override + public Observable deleteAsync() { + return this.client.deleteAsync(this.parent().resourceGroupName(), + this.parent().name(), + this.endpointType().toString(), + this.name()).map(new Func1() { + @Override + public Void call(Void result) { + return result; + } + }); + } + + @Override + public ProfileImpl attach() { + return this.parent().withEndpoint(this); + } + + @Override + public EndpointImpl refresh() { + EndpointInner inner = this.client.get(this.parent().resourceGroupName(), + this.parent().name(), + this.endpointType().toString(), + this.name()); + this.setInner(inner); + return this; + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointsImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointsImpl.java new file mode 100644 index 0000000000000..e0b2bc3ea74d0 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointsImpl.java @@ -0,0 +1,192 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ExternalChildResourcesImpl; +import com.microsoft.azure.management.trafficmanager.AzureEndpoint; +import com.microsoft.azure.management.trafficmanager.Endpoint; +import com.microsoft.azure.management.trafficmanager.EndpointType; +import com.microsoft.azure.management.trafficmanager.ExternalEndpoint; +import com.microsoft.azure.management.trafficmanager.NestedProfileEndpoint; +import com.microsoft.azure.management.trafficmanager.Profile; +import com.sun.javaws.exceptions.InvalidArgumentException; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Represents an endpoint collection associated with a traffic manager profile. + */ +class EndpointsImpl extends + ExternalChildResourcesImpl { + private final EndpointsInner client; + + /** + * Creates new EndpointsImpl. + * + * @param client the client to perform REST calls on endpoints + * @param parent the parent traffic manager profile of the endpoints + */ + EndpointsImpl(EndpointsInner client, ProfileImpl parent) { + super(parent, "Endpoint"); + this.client = client; + this.initializeCollection(); + } + + /** + * @return the azure endpoints as a map indexed by name. + */ + public Map azureEndpointsAsMap() { + Map result = new HashMap<>(); + for (Map.Entry entry : this.collection().entrySet()) { + EndpointImpl endpoint = entry.getValue(); + if (endpoint.endpointType() == EndpointType.AZURE) { + AzureEndpoint azureEndpoint = new AzureEndpointImpl(entry.getKey(), + this.parent(), + endpoint.inner(), + this.client); + result.put(entry.getKey(), azureEndpoint); + } + } + return Collections.unmodifiableMap(result); + } + + /** + * @return the external endpoints as a map indexed by name. + */ + public Map externalEndpointsAsMap() { + Map result = new HashMap<>(); + for (Map.Entry entry : this.collection().entrySet()) { + EndpointImpl endpoint = entry.getValue(); + if (endpoint.endpointType() == EndpointType.EXTERNAL) { + ExternalEndpoint externalEndpoint = new ExternalEndpointImpl(entry.getKey(), + this.parent(), + endpoint.inner(), + this.client); + result.put(entry.getKey(), externalEndpoint); + } + } + return Collections.unmodifiableMap(result); + } + + /** + * @return the nested profile endpoints as a map indexed by name. + */ + public Map nestedProfileEndpointsAsMap() { + Map result = new HashMap<>(); + for (Map.Entry entry : this.collection().entrySet()) { + EndpointImpl endpoint = entry.getValue(); + if (endpoint.endpointType() == EndpointType.NESTEDPROFILE) { + NestedProfileEndpoint nestedProfileEndpoint = new NestedProfileEndpointImpl(entry.getKey(), + this.parent(), + endpoint.inner(), + this.client); + result.put(entry.getKey(), nestedProfileEndpoint); + } + } + return Collections.unmodifiableMap(result); + } + + /** + * Starts an endpoint definition chain. + * + * @param name the name of the endpoint to be added + * @return the endpoint + */ + public EndpointImpl define(String name) { + return this.prepareDefine(name); + } + + /** + * Starts an azure endpoint update chain. + * + * @param name the name of the endpoint to be updated + * @return the endpoint + */ + public EndpointImpl updateAzureEndpoint(String name) { + EndpointImpl endpoint = this.prepareUpdate(name); + if (endpoint.endpointType() != EndpointType.AZURE) { + throw new IllegalArgumentException("An azure endpoint with name " + name + " not found in the profile"); + } + return endpoint; + } + + /** + * Starts an external endpoint update chain. + * + * @param name the name of the endpoint to be updated + * @return the endpoint + */ + public EndpointImpl updateExternalEndpoint(String name) { + EndpointImpl endpoint = this.prepareUpdate(name); + if (endpoint.endpointType() != EndpointType.EXTERNAL) { + throw new IllegalArgumentException("An external endpoint with name " + name + " not found in the profile"); + } + return endpoint; + } + + /** + * Starts a nested profile endpoint update chain. + * + * @param name the name of the endpoint to be updated + * @return the endpoint + */ + public EndpointImpl updateNestedProfileEndpoint(String name) { + EndpointImpl endpoint = this.prepareUpdate(name); + if (endpoint.endpointType() != EndpointType.NESTEDPROFILE) { + throw new IllegalArgumentException("A nested profile endpoint with name " + name + " not found in the profile"); + } + return endpoint; + } + /** + * Mark the endpoint with given name as to be removed. + * + * @param name the name of the endpoint to be removed + */ + public void remove(String name) { + this.prepareRemove(name); + } + + /** + * Adds the endpoint to the collection. + * + * @param endpoint the endpoint + */ + public void addEndpoint(EndpointImpl endpoint) { + this.addChildResource(endpoint); + } + + @Override + protected List listChildResources() { + List childResources = new ArrayList<>(); + if (parent().inner().endpoints() != null) { + for (EndpointInner inner : parent().inner().endpoints()) { + if (inner.name() == null) { + childResources.add(new EndpointImpl(inner.name(), + this.parent(), + inner, + this.client)); + } + } + } + return childResources; + } + + @Override + protected EndpointImpl newChildResource(String name) { + return new EndpointImpl(name, + this.parent(), + new EndpointInner().withName(name), + this.client); + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ExternalEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ExternalEndpointImpl.java new file mode 100644 index 0000000000000..e6df50a9e23a4 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ExternalEndpointImpl.java @@ -0,0 +1,26 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.management.trafficmanager.ExternalEndpoint; + +/** + * Implementation for {@link ExternalEndpoint} + */ +class ExternalEndpointImpl extends EndpointImpl + implements ExternalEndpoint { + ExternalEndpointImpl(String name, + ProfileImpl parent, + EndpointInner inner, + EndpointsInner client) { + super(name, parent, inner, client); + } + + @Override + public String fqdn() { + return inner().target(); + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/NestedProfileEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/NestedProfileEndpointImpl.java new file mode 100644 index 0000000000000..5c7ec1a13f81d --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/NestedProfileEndpointImpl.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.management.trafficmanager.NestedProfileEndpoint; + +/** + * Implementation for {@link NestedProfileEndpoint} + */ +public class NestedProfileEndpointImpl extends EndpointImpl + implements NestedProfileEndpoint { + NestedProfileEndpointImpl(String name, + ProfileImpl parent, + EndpointInner inner, + EndpointsInner client) { + super(name, parent, inner, client); + } + + @Override + public String nestedProfileId() { + return inner().targetResourceId(); + } + + @Override + public int minChildEndpoints() { + if (inner().minChildEndpoints() == null) { + return 0; + } + return inner().minChildEndpoints().intValue(); + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfileImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfileImpl.java new file mode 100644 index 0000000000000..b0470e90114ad --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfileImpl.java @@ -0,0 +1,241 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableResourceImpl; +import com.microsoft.azure.management.trafficmanager.AzureEndpoint; +import com.microsoft.azure.management.trafficmanager.ExternalEndpoint; +import com.microsoft.azure.management.trafficmanager.MonitorConfig; +import com.microsoft.azure.management.trafficmanager.NestedProfileEndpoint; +import com.microsoft.azure.management.trafficmanager.Profile; +import com.microsoft.azure.management.trafficmanager.ProfileMonitorStatus; +import com.microsoft.azure.management.trafficmanager.TrafficRoutingMethod; +import rx.Observable; +import rx.functions.Func1; + +import java.util.List; +import java.util.Map; + +/** + * Implementation for {@link Profile} + */ +public class ProfileImpl + extends GroupableResourceImpl< + Profile, + ProfileInner, + ProfileImpl, + TrafficManager> + implements + Profile, + Profile.Definition, + Profile.Update { + private final ProfilesInner innerCollection; + private final EndpointsInner endpointsClient; + private final String profileStatusDisabled = "Disabled"; + private final String profileStatusEnabled = "Enabled"; + private EndpointsImpl endpoints; + + ProfileImpl(String name, + final ProfileInner innerModel, + final ProfilesInner innerCollection, + final EndpointsInner endpointsClient, + final TrafficManager trafficManager) { + super(name, innerModel, trafficManager); + this.innerCollection = innerCollection; + this.endpointsClient = endpointsClient; + this.endpoints = new EndpointsImpl(endpointsClient, this); + } + + @Override + public String dnsLabel() { + return this.inner().dnsConfig().relativeName(); + } + + @Override + public String fqdn() { + return this.inner().dnsConfig().fqdn(); + } + + @Override + public int ttl() { + return this.inner().dnsConfig().ttl().intValue(); + } + + @Override + public boolean isDisabled() { + return this.inner().profileStatus().equalsIgnoreCase(this.profileStatusDisabled); + } + + @Override + public TrafficRoutingMethod trafficRoutingMethod() { + return TrafficRoutingMethod.fromValue(this.inner().trafficRoutingMethod()); + } + + @Override + public ProfileMonitorStatus monitorStatus() { + return ProfileMonitorStatus.fromValue(this.inner().monitorConfig().profileMonitorStatus()); + } + + @Override + public int monitoringPort() { + return this.inner().monitorConfig().port().intValue(); + } + + @Override + public String monitoringPath() { + return this.inner().monitorConfig().path(); + } + + // TODO Expose monitoring protocol + + @Override + public Map externalEndpoints() { + return this.endpoints.externalEndpointsAsMap(); + } + + @Override + public Map azureEndpoints() { + return this.endpoints.azureEndpointsAsMap(); + } + + @Override + public Map nestedProfileEndpoints() { + return this.endpoints.nestedProfileEndpointsAsMap(); + } + + @Override + public Profile refresh() { + ProfileInner inner = this.innerCollection.get(this.resourceGroupName(), this.name()); + this.setInner(inner); + this.endpoints.refresh(); + return this; + } + + @Override + public ProfileImpl withDnsLabel(String dnsLabel) { + this.inner().dnsConfig().withRelativeName(dnsLabel); + return this; + } + + @Override + public ProfileImpl withPriorityRouting() { + this.withTrafficRoutingMethod(TrafficRoutingMethod.PRIORITY); + return this; + } + + @Override + public ProfileImpl withWeightedRouting() { + this.withTrafficRoutingMethod(TrafficRoutingMethod.WEIGHTED); + return this; + } + + @Override + public ProfileImpl withPerformanceRouting() { + this.withTrafficRoutingMethod(TrafficRoutingMethod.PERFORMANCE); + return this; + } + + @Override + public ProfileImpl withTrafficRoutingMethod(TrafficRoutingMethod routingMethod) { + this.inner().withTrafficRoutingMethod(routingMethod.toString()); + return this; + } + + @Override + public EndpointImpl defineNewEndpoint(String name) { + return this.endpoints.define(name); + } + + @Override + public EndpointImpl updateAzureEndpoint(String name) { + return this.endpoints.updateAzureEndpoint(name); + } + + @Override + public EndpointImpl updateExternalEndpoint(String name) { + return this.endpoints.updateExternalEndpoint(name); + } + + @Override + public EndpointImpl updateNestedProfileEndpoint(String name) { + return this.endpoints.updateNestedProfileEndpoint(name); + } + + @Override + public ProfileImpl withHttpMonitoring() { + return this.withHttpMonitoring(80, "/"); + } + + @Override + public ProfileImpl withHttpsMonitoring() { + return this.withHttpsMonitoring(443, "/"); + } + + @Override + public ProfileImpl withHttpMonitoring(int port, String path) { + this.inner().withMonitorConfig(new MonitorConfig() + .withPort(new Long(port)) + .withPath(path) + .withProtocol("http")); + return this; + } + + @Override + public ProfileImpl withHttpsMonitoring(int port, String path) { + this.inner().withMonitorConfig(new MonitorConfig() + .withPort(new Long(port)) + .withPath(path) + .withProtocol("https")); + return this; + } + + @Override + public ProfileImpl withProfileStatusDisabled() { + this.inner().withProfileStatus(this.profileStatusDisabled); + return this; + } + + @Override + public ProfileImpl withProfileStatusEnabled() { + this.inner().withProfileStatus(this.profileStatusEnabled); + return this; + } + + @Override + public ProfileImpl withTtl(int ttlInSeconds) { + this.inner().dnsConfig().withTtl(new Long(ttlInSeconds)); + return this; + } + + @Override + public Observable createResourceAsync() { + final ProfileImpl self = this; + return innerCollection.createOrUpdateAsync(resourceGroupName(), name(), inner()) + .map(new Func1() { + @Override + public Profile call(ProfileInner profileInner) { + self.setInner(profileInner); + return self; + } + }).flatMap(new Func1>() { + @Override + public Observable call(Profile profile) { + return self.endpoints.commitAndGetAllAsync() + .map(new Func1, Profile>() { + @Override + public Profile call(List endpoints) { + return self; + } + }); + } + }); + } + + ProfileImpl withEndpoint(EndpointImpl endpoint) { + this.endpoints.addEndpoint(endpoint); + return this; + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfilesImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfilesImpl.java new file mode 100644 index 0000000000000..2c9427d4c65e9 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfilesImpl.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.PagedList; +import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; +import com.microsoft.azure.management.trafficmanager.Profile; +import com.microsoft.azure.management.trafficmanager.Profiles; +import rx.Observable; + +/** + * Implementation for {@link Profiles} + */ +public class ProfilesImpl extends GroupableResourcesImpl< + Profile, + ProfileImpl, + ProfileInner, + ProfilesInner, + TrafficManager> + implements Profiles { + private final EndpointsInner endpointsClient; + + ProfilesImpl( + final TrafficManagerManagementClientImpl trafficManagementClient, + final TrafficManager trafficManager) { + super(trafficManagementClient.profiles(), trafficManager); + this.endpointsClient = trafficManagementClient.endpoints(); + } + + @Override + public PagedList list() { + return wrapList(this.innerCollection.listAll()); + } + + @Override + public PagedList listByGroup(String groupName) { + return wrapList(this.innerCollection.listAllInResourceGroup(groupName)); + } + + @Override + public Profile getByGroup(String groupName, String name) { + return wrapModel(this.innerCollection.get(groupName, name)); + } + + @Override + public Observable deleteAsync(String groupName, String name) { + return this.innerCollection.deleteAsync(groupName, name); + } + + @Override + protected ProfileImpl wrapModel(String name) { + return new ProfileImpl(name, + new ProfileInner(), + this.innerCollection, + this.endpointsClient, + this.myManager); + } + + @Override + protected ProfileImpl wrapModel(ProfileInner inner) { + return new ProfileImpl(inner.name(), + inner, + this.innerCollection, + this.endpointsClient, + this.myManager); + } + + @Override + public ProfileImpl define(String name) { + return wrapModel(name); + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManager.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManager.java new file mode 100644 index 0000000000000..cca49eb5a2549 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManager.java @@ -0,0 +1,99 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.RestClient; +import com.microsoft.azure.credentials.AzureTokenCredentials; +import com.microsoft.azure.management.resources.fluentcore.arm.AzureConfigurable; +import com.microsoft.azure.management.resources.fluentcore.arm.implementation.AzureConfigurableImpl; +import com.microsoft.azure.management.resources.fluentcore.arm.implementation.Manager; +import com.microsoft.azure.management.trafficmanager.Profiles; + +/** + * Entry point to Azure traffic manager management. + */ +public final class TrafficManager extends Manager { + // Collections + private Profiles profiles; + + /** + * Get a Configurable instance that can be used to create {@link TrafficManager} + * with optional configuration. + * + * @return the instance allowing configurations + */ + public static Configurable configure() { + return new TrafficManager.ConfigurableImpl(); + } + + /** + * Creates an instance of TrafficManager that exposes traffic manager management API entry points. + * + * @param credentials the credentials to use + * @param subscriptionId the subscription UUID + * @return the TrafficManager + */ + public static TrafficManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { + return new TrafficManager(credentials.getEnvironment().newRestClientBuilder() + .withCredentials(credentials) + .build(), subscriptionId); + } + + /** + * Creates an instance of TrafficManager that exposes traffic manager management API entry points. + * + * @param restClient the RestClient to be used for API calls. + * @param subscriptionId the subscription UUID + * @return the TrafficManager + */ + public static TrafficManager authenticate(RestClient restClient, String subscriptionId) { + return new TrafficManager(restClient, subscriptionId); + } + + /** + * The interface allowing configurations to be set. + */ + public interface Configurable extends AzureConfigurable { + /** + * Creates an instance of TrafficManager that exposes traffic manager management API entry points. + * + * @param credentials the credentials to use + * @param subscriptionId the subscription UUID + * @return the interface exposing traffic manager management API entry points that work across subscriptions + */ + TrafficManager authenticate(AzureTokenCredentials credentials, String subscriptionId); + } + + /** + * The implementation for Configurable interface. + */ + private static class ConfigurableImpl + extends AzureConfigurableImpl + implements Configurable { + + public TrafficManager authenticate(AzureTokenCredentials credentials, String subscriptionId) { + return TrafficManager.authenticate(buildRestClient(credentials), subscriptionId); + } + } + + private TrafficManager(RestClient restClient, String subscriptionId) { + super(restClient, + subscriptionId, + new TrafficManagerManagementClientImpl(restClient).withSubscriptionId(subscriptionId)); + } + + /** + * @return entry point to traffic manager profile management + */ + public Profiles profiles() { + if (this.profiles == null) { + this.profiles = new ProfilesImpl( + super.innerManagementClient, + this); + } + return this.profiles; + } +} From 7ae3895accc0026ba1f60216bc8c04aa180f8dfe Mon Sep 17 00:00:00 2001 From: anuchan Date: Tue, 11 Oct 2016 17:01:40 -0700 Subject: [PATCH 03/12] Addressing offline review comments from martin --- .../trafficmanager/EndpointMonitorStatus.java | 80 +++++++------- .../trafficmanager/ProfileMonitorStatus.java | 82 +++++++------- ....java => TrafficManagerAzureEndpoint.java} | 2 +- ...point.java => TrafficManagerEndpoint.java} | 20 ++-- ...va => TrafficManagerExternalEndpoint.java} | 2 +- ... TrafficManagerNestedProfileEndpoint.java} | 2 +- ...rofile.java => TrafficManagerProfile.java} | 46 ++++---- ...files.java => TrafficManagerProfiles.java} | 14 +-- .../implementation/ExternalEndpointImpl.java | 26 ----- .../implementation/TrafficManager.java | 8 +- ...a => TrafficManagerAzureEndpointImpl.java} | 16 +-- ...l.java => TrafficManagerEndpointImpl.java} | 66 ++++++------ ....java => TrafficManagerEndpointsImpl.java} | 79 +++++++------- .../TrafficManagerExternalEndpointImpl.java | 26 +++++ ...fficManagerNestedProfileEndpointImpl.java} | 16 +-- ...pl.java => TrafficManagerProfileImpl.java} | 102 +++++++++--------- ...l.java => TrafficManagerProfilesImpl.java} | 32 +++--- azure/pom.xml | 5 + .../com/microsoft/azure/management/Azure.java | 8 ++ 19 files changed, 324 insertions(+), 308 deletions(-) rename azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/{AzureEndpoint.java => TrafficManagerAzureEndpoint.java} (87%) rename azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/{Endpoint.java => TrafficManagerEndpoint.java} (95%) rename azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/{ExternalEndpoint.java => TrafficManagerExternalEndpoint.java} (84%) rename azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/{NestedProfileEndpoint.java => TrafficManagerNestedProfileEndpoint.java} (87%) rename azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/{Profile.java => TrafficManagerProfile.java} (91%) rename azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/{Profiles.java => TrafficManagerProfiles.java} (75%) delete mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ExternalEndpointImpl.java rename azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/{AzureEndpointImpl.java => TrafficManagerAzureEndpointImpl.java} (63%) rename azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/{EndpointImpl.java => TrafficManagerEndpointImpl.java} (62%) rename azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/{EndpointsImpl.java => TrafficManagerEndpointsImpl.java} (59%) create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerExternalEndpointImpl.java rename azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/{NestedProfileEndpointImpl.java => TrafficManagerNestedProfileEndpointImpl.java} (51%) rename azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/{ProfileImpl.java => TrafficManagerProfileImpl.java} (58%) rename azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/{ProfilesImpl.java => TrafficManagerProfilesImpl.java} (63%) diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointMonitorStatus.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointMonitorStatus.java index 66d11d7cff039..4534878053690 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointMonitorStatus.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointMonitorStatus.java @@ -6,63 +6,57 @@ package com.microsoft.azure.management.trafficmanager; /** - * Possible traffic manager profile endpoint monitor statuses. + * Traffic manager profile endpoint monitor statuses. */ -public enum EndpointMonitorStatus { - /** - * Enum value Inactive. - */ - INACTIVE("Inactive"), +public class EndpointMonitorStatus { + /** Static value Inactive for EndpointMonitorStatus. */ + public static final EndpointMonitorStatus INACTIVE = new EndpointMonitorStatus("Inactive"); - /** - * Enum value Disabled. - */ - DISABLED("Disabled"), + /** Static value Disabled for EndpointMonitorStatus. */ + public static final EndpointMonitorStatus DISABLED = new EndpointMonitorStatus("Disabled"); - /** - * Enum value Online. - */ - ONLINE("Online"), + /** Static value Online for EndpointMonitorStatus. */ + public static final EndpointMonitorStatus ONLINE = new EndpointMonitorStatus("Online"); - /** - * Enum value Degraded. - */ - DEGRADED("Degraded"), + /** Static value Degraded for EndpointMonitorStatus. */ + public static final EndpointMonitorStatus DEGRADED = new EndpointMonitorStatus("Degraded"); - /** - * Enum value CheckingEndpoint. - */ - CHECKINGENDPOINT("CheckingEndpoint"), + /** Static value CheckingEndpoint for EndpointMonitorStatus. */ + public static final EndpointMonitorStatus CHECKINGENDPOINT = new EndpointMonitorStatus("CheckingEndpoint"); - /** - * Enum value Stopped. - */ - STOPPED("Stopped"); + /** Static value Stopped for EndpointMonitorStatus. */ + public static final EndpointMonitorStatus STOPPED = new EndpointMonitorStatus ("Stopped"); private String value; - EndpointMonitorStatus(String value) { + public EndpointMonitorStatus(String value) { this.value = value; } - /** - * Parses a string value to a EndpointMonitorStatus instance. - * - * @param value the string value to parse. - * @return the parsed EndpointMonitorStatus object, or null if unable to parse. - */ - public static EndpointMonitorStatus fromValue(String value) { - EndpointMonitorStatus[] items = EndpointMonitorStatus.values(); - for (EndpointMonitorStatus item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - @Override public String toString() { return this.value; } + + @Override + public int hashCode() { + return this.value.hashCode(); + } + + @Override + public boolean equals(Object obj) { + String value = this.toString(); + if (!(obj instanceof EndpointMonitorStatus)) { + return false; + } + if (obj == this) { + return true; + } + EndpointMonitorStatus rhs = (EndpointMonitorStatus) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileMonitorStatus.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileMonitorStatus.java index 5e77c2e155656..6332c2252bec9 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileMonitorStatus.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileMonitorStatus.java @@ -6,58 +6,54 @@ package com.microsoft.azure.management.trafficmanager; /** - * Possible traffic manager profile statuses. + * Traffic manager profile statuses. */ -public enum ProfileMonitorStatus { - /** - * Enum value Inactive. - */ - INACTIVE("Inactive"), - - /** - * Enum value Disabled. - */ - DISABLED("Disabled"), - - /** - * Enum value Online. - */ - ONLINE("Online"), - - /** - * Enum value Degraded. - */ - DEGRADED("Degraded"), - - /** - * Enum value CheckingEndpoint. - */ - CHECKINGENDPOINT("CheckingEndpoint"); +public class ProfileMonitorStatus { + /** Static value Inactive for ProfileMonitorStatus. */ + public static final ProfileMonitorStatus INACTIVE = new ProfileMonitorStatus("Inactive"); + + /** Static value Disabled for ProfileMonitorStatus. */ + public static final ProfileMonitorStatus DISABLED = new ProfileMonitorStatus("Disabled"); + + /** Static value Online for ProfileMonitorStatus. */ + public static final ProfileMonitorStatus ONLINE = new ProfileMonitorStatus("Online"); + + /** Static value Degraded for ProfileMonitorStatus. */ + public static final ProfileMonitorStatus DEGRADED = new ProfileMonitorStatus("Degraded"); + + /** Static value CheckingEndpoint for ProfileMonitorStatus. */ + public static final ProfileMonitorStatus CHECKINGENDPOINT = new ProfileMonitorStatus("CheckingEndpoint"); private String value; - ProfileMonitorStatus(String value) { + public ProfileMonitorStatus(String value) { this.value = value; } - /** - * Parses a string value to a ProfileMonitorStatus instance. - * - * @param value the string value to parse. - * @return the parsed ProfileMonitorStatus object, or null if unable to parse. - */ - public static ProfileMonitorStatus fromValue(String value) { - ProfileMonitorStatus[] items = ProfileMonitorStatus.values(); - for (ProfileMonitorStatus item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; - } - @Override public String toString() { return this.value; } + + @Override + public int hashCode() { + return this.value.hashCode(); + } + + @Override + public boolean equals(Object obj) { + String value = this.toString(); + if (!(obj instanceof ProfileMonitorStatus)) { + return false; + } + if (obj == this) { + return true; + } + ProfileMonitorStatus rhs = (ProfileMonitorStatus) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/AzureEndpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerAzureEndpoint.java similarity index 87% rename from azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/AzureEndpoint.java rename to azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerAzureEndpoint.java index c08444b86e232..2a94e6df6f04c 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/AzureEndpoint.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerAzureEndpoint.java @@ -8,7 +8,7 @@ /** * An immutable client-side representation of an Azure traffic manager profile Azure endpoint. */ -public interface AzureEndpoint extends Endpoint { +public interface TrafficManagerAzureEndpoint extends TrafficManagerEndpoint { /** * @return the resource id of the target Azure resource. */ diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Endpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java similarity index 95% rename from azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Endpoint.java rename to azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java index 6402734718fa3..2972700d98219 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Endpoint.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java @@ -17,8 +17,8 @@ * An immutable client-side representation of an Azure traffic manager profile endpoint. */ @Fluent -public interface Endpoint extends - ExternalChildResource, +public interface TrafficManagerEndpoint extends + ExternalChildResource, Wrapper { /** * @return the endpoint type @@ -101,7 +101,7 @@ interface WithEndpointType { * @param nestedProfile the nested traffic manager profile * @return the next stage of the endpoint definition */ - WithEndpointThreshold withNestedProfile(Profile nestedProfile); + WithEndpointThreshold withNestedProfile(TrafficManagerProfile nestedProfile); } /** @@ -186,8 +186,8 @@ interface WithTrafficDisabled { /** The final stage of the traffic manager profile endpoint definition. *

* At this stage, any remaining optional settings can be specified, or the traffic manager profile endpoint - * definition can be attached to the parent traffic manager profile definition using {@link Endpoint.DefinitionStages.WithAttach#attach()}. - * @param the return type of {@link Endpoint.DefinitionStages.WithAttach#attach()} + * definition can be attached to the parent traffic manager profile definition using {@link TrafficManagerEndpoint.DefinitionStages.WithAttach#attach()}. + * @param the return type of {@link TrafficManagerEndpoint.DefinitionStages.WithAttach#attach()} */ interface WithAttach extends Attachable.InDefinition, @@ -251,7 +251,7 @@ interface WithEndpointType { * @param nestedProfile the nested traffic manager profile * @return the next stage of the definition */ - WithEndpointThreshold withNestedProfile(Profile nestedProfile); + WithEndpointThreshold withNestedProfile(TrafficManagerProfile nestedProfile); } /** @@ -336,8 +336,8 @@ interface WithTrafficDisabled { /** The final stage of the traffic manager profile endpoint definition. *

* At this stage, any remaining optional settings can be specified, or the traffic manager profile endpoint - * definition can be attached to the parent traffic manager profile update using {@link Endpoint.DefinitionStages.WithAttach#attach()}. - * @param the return type of {@link Endpoint.DefinitionStages.WithAttach#attach()} + * definition can be attached to the parent traffic manager profile update using {@link TrafficManagerEndpoint.DefinitionStages.WithAttach#attach()}. + * @param the return type of {@link TrafficManagerEndpoint.DefinitionStages.WithAttach#attach()} */ interface WithAttach extends Attachable.InUpdate, @@ -377,7 +377,7 @@ interface UpdateNestedProfileEndpoint extends * the set of configurations that can be updated for all endpoint irrespective of their type (Azure, external, nested profile). */ interface Update extends - Settable, + Settable, UpdateStages.WithRoutingWeight, UpdateStages.WithRoutingPriority, UpdateStages.WithTrafficDisabledOrEnabled { @@ -424,7 +424,7 @@ interface WithNestedProfileConfig { * @param nestedProfile the nested traffic manager profile * @return the next stage of the update */ - UpdateNestedProfileEndpoint withNestedProfile(Profile nestedProfile); + UpdateNestedProfileEndpoint withNestedProfile(TrafficManagerProfile nestedProfile); /** * Specifies the child endpoint threshold. diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ExternalEndpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerExternalEndpoint.java similarity index 84% rename from azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ExternalEndpoint.java rename to azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerExternalEndpoint.java index af5191d464991..c0f7db54a2384 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ExternalEndpoint.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerExternalEndpoint.java @@ -8,7 +8,7 @@ /** * An immutable client-side representation of an Azure traffic manager profile external endpoint. */ -public interface ExternalEndpoint extends Endpoint { +public interface TrafficManagerExternalEndpoint extends TrafficManagerEndpoint { /** * @return the fully qualified DNS name of the external endpoint. */ diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/NestedProfileEndpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerNestedProfileEndpoint.java similarity index 87% rename from azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/NestedProfileEndpoint.java rename to azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerNestedProfileEndpoint.java index 390c7d4fa775e..e4ef31de84966 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/NestedProfileEndpoint.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerNestedProfileEndpoint.java @@ -8,7 +8,7 @@ /** * An immutable client-side representation of an Azure traffic manager profile nested profile endpoint. */ -public interface NestedProfileEndpoint extends Endpoint { +public interface TrafficManagerNestedProfileEndpoint extends TrafficManagerEndpoint { /** * @return the nested traffic manager profile resource id */ diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Profile.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java similarity index 91% rename from azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Profile.java rename to azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java index 008fda7bc4630..2969b147f4d90 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Profile.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java @@ -21,11 +21,11 @@ * An immutable client-side representation of an Azure traffic manager profile. */ @Fluent -public interface Profile extends +public interface TrafficManagerProfile extends GroupableResource, - Refreshable, + Refreshable, Wrapper, - Updatable { + Updatable { /** * @return the relative DNS name of the traffic manager profile */ @@ -71,19 +71,19 @@ public interface Profile extends * * @return external endpoints in the traffic manager profile, indexed by the name */ - Map externalEndpoints(); + Map externalEndpoints(); /** * * @return Azure endpoints in the traffic manager profile, indexed by the name */ - Map azureEndpoints(); + Map azureEndpoints(); /** * * @return nested traffic manager profile endpoints in this traffic manager profile, indexed by the name */ - Map nestedProfileEndpoints(); + Map nestedProfileEndpoints(); /** * The entirety of the traffic manager profile definition. @@ -139,7 +139,7 @@ interface WithTrafficRoutingMethod { * * @return the next stage of the traffic manager profile definition */ - WithMonitoringConfiguration withPriorityRouting(); + WithMonitoringConfiguration withPriorityBasedRouting(); /** * Specify that end user traffic should be distributed to the endpoints based on the weight assigned @@ -147,7 +147,7 @@ interface WithTrafficRoutingMethod { * * @return the next stage of the traffic manager profile definition */ - WithMonitoringConfiguration withWeightedRouting(); + WithMonitoringConfiguration withWeightBasedRouting(); /** * Specify that end user traffic should be routed based on the geographic location of the endpoint @@ -155,7 +155,7 @@ interface WithTrafficRoutingMethod { * * @return the next stage of the traffic manager profile definition */ - WithMonitoringConfiguration withPerformanceRouting(); + WithMonitoringConfiguration withPerformanceBasedRouting(); /** * Specify the traffic routing method for the profile. @@ -217,7 +217,7 @@ interface WithEndpoint { * @param name the name for the endpoint * @return the stage representing configuration for the endpoint */ - Endpoint.DefinitionStages.Blank defineNewEndpoint(String name); + TrafficManagerEndpoint.DefinitionStages.Blank defineEndpoint(String name); } /** @@ -252,7 +252,7 @@ interface WithProfileStatus { * (via {@link WithCreate#create()}), but also allows for any other optional settings to be specified. */ interface WithCreate extends - Creatable, + Creatable, Resource.DefinitionWithTags, DefinitionStages.WithTtl, DefinitionStages.WithProfileStatus, @@ -276,7 +276,7 @@ interface WithTrafficRoutingMethod { * * @return the next stage of the traffic manager profile update */ - Update withPriorityRouting(); + Update withPriorityBasedRouting(); /** * Specify that end user traffic should be distributed to the endpoints based on the weight assigned @@ -284,7 +284,7 @@ interface WithTrafficRoutingMethod { * * @return the next stage of the traffic manager profile update */ - Update withWeightedRouting(); + Update withWeightBasedRouting(); /** * Specify that end user traffic should be routed based on the geographic location of the endpoint @@ -292,7 +292,7 @@ interface WithTrafficRoutingMethod { * * @return the next stage of the traffic manager profile update */ - Update withPerformanceRouting(); + Update withPerformanceBasedRouting(); /** * Specify the traffic routing method for the profile. @@ -354,7 +354,7 @@ interface WithEndpoint { * @param name the name for the endpoint * @return the stage representing configuration for the endpoint */ - Endpoint.UpdateDefinitionStages.Blank defineNewEndpoint(String name); + TrafficManagerEndpoint.UpdateDefinitionStages.Blank defineEndpoint(String name); /** * Begins the description of an update of an existing Azure endpoint in this profile. @@ -362,7 +362,7 @@ interface WithEndpoint { * @param name the name of the Azure endpoint * @return the stage representing updating configuration for the Azure endpoint */ - Endpoint.UpdateAzureEndpoint updateAzureEndpoint(String name); + TrafficManagerEndpoint.UpdateAzureEndpoint updateAzureEndpoint(String name); /** * Begins the description of an update of an existing external endpoint in this profile. @@ -370,7 +370,7 @@ interface WithEndpoint { * @param name the name of the external endpoint * @return the stage representing updating configuration for the external endpoint */ - Endpoint.UpdateExternalEndpoint updateExternalEndpoint(String name); + TrafficManagerEndpoint.UpdateExternalEndpoint updateExternalEndpoint(String name); /** * Begins the description of an update of an existing nested traffic manager profile endpoint @@ -379,7 +379,15 @@ interface WithEndpoint { * @param name the name of the nested profile endpoint * @return the stage representing updating configuration for the nested traffic manager profile endpoint */ - Endpoint.UpdateNestedProfileEndpoint updateNestedProfileEndpoint(String name); + TrafficManagerEndpoint.UpdateNestedProfileEndpoint updateNestedProfileEndpoint(String name); + + /** + * Removes an endpoint in the profile. + * + * @param name the name of the endpoint + * @return the next stage of the traffic manager profile update + */ + Update withoutEndpoint(String name); } /** @@ -425,7 +433,7 @@ interface WithProfileStatus { * Call {@link Update#apply()} to apply the changes to the resource in Azure. */ interface Update extends - Appliable, + Appliable, UpdateStages.WithTrafficRoutingMethod, UpdateStages.WithMonitoringConfiguration, UpdateStages.WithEndpoint, diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Profiles.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfiles.java similarity index 75% rename from azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Profiles.java rename to azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfiles.java index 81c90e749d397..bfd6048001927 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/Profiles.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfiles.java @@ -19,13 +19,13 @@ * Entry point to traffic manager profile management API in Azure. */ @Fluent() -public interface Profiles extends - SupportsCreating, - SupportsListing, - SupportsListingByGroup, - SupportsGettingByGroup, - SupportsGettingById, +public interface TrafficManagerProfiles extends + SupportsCreating, + SupportsListing, + SupportsListingByGroup, + SupportsGettingByGroup, + SupportsGettingById, SupportsDeleting, SupportsDeletingByGroup, - SupportsBatchCreation { + SupportsBatchCreation { } \ No newline at end of file diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ExternalEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ExternalEndpointImpl.java deleted file mode 100644 index e6df50a9e23a4..0000000000000 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ExternalEndpointImpl.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for - * license information. - */ -package com.microsoft.azure.management.trafficmanager.implementation; - -import com.microsoft.azure.management.trafficmanager.ExternalEndpoint; - -/** - * Implementation for {@link ExternalEndpoint} - */ -class ExternalEndpointImpl extends EndpointImpl - implements ExternalEndpoint { - ExternalEndpointImpl(String name, - ProfileImpl parent, - EndpointInner inner, - EndpointsInner client) { - super(name, parent, inner, client); - } - - @Override - public String fqdn() { - return inner().target(); - } -} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManager.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManager.java index cca49eb5a2549..928376027a2e4 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManager.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManager.java @@ -10,14 +10,14 @@ import com.microsoft.azure.management.resources.fluentcore.arm.AzureConfigurable; import com.microsoft.azure.management.resources.fluentcore.arm.implementation.AzureConfigurableImpl; import com.microsoft.azure.management.resources.fluentcore.arm.implementation.Manager; -import com.microsoft.azure.management.trafficmanager.Profiles; +import com.microsoft.azure.management.trafficmanager.TrafficManagerProfiles; /** * Entry point to Azure traffic manager management. */ public final class TrafficManager extends Manager { // Collections - private Profiles profiles; + private TrafficManagerProfiles profiles; /** * Get a Configurable instance that can be used to create {@link TrafficManager} @@ -88,9 +88,9 @@ private TrafficManager(RestClient restClient, String subscriptionId) { /** * @return entry point to traffic manager profile management */ - public Profiles profiles() { + public TrafficManagerProfiles profiles() { if (this.profiles == null) { - this.profiles = new ProfilesImpl( + this.profiles = new TrafficManagerProfilesImpl( super.innerManagementClient, this); } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/AzureEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerAzureEndpointImpl.java similarity index 63% rename from azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/AzureEndpointImpl.java rename to azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerAzureEndpointImpl.java index 2e11856f03bfa..e48f47b16d21e 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/AzureEndpointImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerAzureEndpointImpl.java @@ -6,18 +6,18 @@ package com.microsoft.azure.management.trafficmanager.implementation; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; -import com.microsoft.azure.management.trafficmanager.AzureEndpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerAzureEndpoint; import com.microsoft.azure.management.trafficmanager.TargetAzureResourceType; /** - * Implementation for {@link AzureEndpoint} + * Implementation for {@link TrafficManagerAzureEndpoint} */ -class AzureEndpointImpl extends EndpointImpl - implements AzureEndpoint { - AzureEndpointImpl(String name, - ProfileImpl parent, - EndpointInner inner, - EndpointsInner client) { +class TrafficManagerAzureEndpointImpl extends TrafficManagerEndpointImpl + implements TrafficManagerAzureEndpoint { + TrafficManagerAzureEndpointImpl(String name, + TrafficManagerProfileImpl parent, + EndpointInner inner, + EndpointsInner client) { super(name, parent, inner, client); } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java similarity index 62% rename from azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointImpl.java rename to azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java index a844eecc26152..245bb7db1b82d 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java @@ -7,34 +7,34 @@ import com.microsoft.azure.management.resources.fluentcore.arm.Region; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.ExternalChildResourceImpl; -import com.microsoft.azure.management.trafficmanager.Endpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerEndpoint; import com.microsoft.azure.management.trafficmanager.EndpointMonitorStatus; -import com.microsoft.azure.management.trafficmanager.Profile; +import com.microsoft.azure.management.trafficmanager.TrafficManagerProfile; import com.microsoft.azure.management.trafficmanager.EndpointType; import rx.Observable; import rx.functions.Func1; /** - * Implementation for {@link Endpoint} + * Implementation for {@link TrafficManagerEndpoint} */ -class EndpointImpl extends ExternalChildResourceImpl - implements Endpoint, - Endpoint.Definition, - Endpoint.UpdateDefinition, - Endpoint.UpdateAzureEndpoint, - Endpoint.UpdateExternalEndpoint, - Endpoint.UpdateNestedProfileEndpoint { + TrafficManagerProfileImpl, + TrafficManagerProfile> + implements TrafficManagerEndpoint, + TrafficManagerEndpoint.Definition, + TrafficManagerEndpoint.UpdateDefinition, + TrafficManagerEndpoint.UpdateAzureEndpoint, + TrafficManagerEndpoint.UpdateExternalEndpoint, + TrafficManagerEndpoint.UpdateNestedProfileEndpoint { private final EndpointsInner client; private final String endpointStatusDisabled = "Disabled"; private final String endpointStatusEnabled = "Enabled"; - EndpointImpl(String name, - ProfileImpl parent, - EndpointInner inner, - EndpointsInner client) { + TrafficManagerEndpointImpl(String name, + TrafficManagerProfileImpl parent, + EndpointInner inner, + EndpointsInner client) { super(name, parent, inner); this.client = client; } @@ -51,7 +51,7 @@ public EndpointType endpointType() { @Override public EndpointMonitorStatus monitorStatus() { - return EndpointMonitorStatus.fromValue(this.inner().endpointMonitorStatus()); + return new EndpointMonitorStatus(this.inner().endpointMonitorStatus()); } @Override @@ -70,69 +70,69 @@ public int routingPriority() { } @Override - public EndpointImpl withMinimumChildEndpoints(int count) { + public TrafficManagerEndpointImpl withMinimumChildEndpoints(int count) { this.inner().withMinChildEndpoints(new Long(count)); return this; } @Override - public EndpointImpl withTargetAzureResourceId(String resourceId) { + public TrafficManagerEndpointImpl withTargetAzureResourceId(String resourceId) { this.inner().withTargetResourceId(resourceId); return this; } @Override - public EndpointImpl withExternalFqdn(String externalFqdn) { + public TrafficManagerEndpointImpl withExternalFqdn(String externalFqdn) { this.inner().withTarget(externalFqdn); return this; } - public EndpointImpl withSourceTrafficLocation(Region location) { + public TrafficManagerEndpointImpl withSourceTrafficLocation(Region location) { this.inner().withEndpointLocation(location.toString()); return this; } @Override - public EndpointImpl withNestedProfile(Profile nestedProfile) { + public TrafficManagerEndpointImpl withNestedProfile(TrafficManagerProfile nestedProfile) { this.inner().withTargetResourceId(nestedProfile.id()); return this; } @Override - public EndpointImpl withRoutingPriority(int priority) { + public TrafficManagerEndpointImpl withRoutingPriority(int priority) { this.inner().withPriority(new Long(priority)); return this; } @Override - public EndpointImpl withTrafficDisabled() { + public TrafficManagerEndpointImpl withTrafficDisabled() { this.inner().withEndpointStatus(this.endpointStatusDisabled); return this; } @Override - public EndpointImpl withTrafficEnabled() { + public TrafficManagerEndpointImpl withTrafficEnabled() { this.inner().withEndpointStatus(this.endpointStatusEnabled); return this; } @Override - public EndpointImpl withRoutingWeight(int weight) { + public TrafficManagerEndpointImpl withRoutingWeight(int weight) { this.inner().withWeight(new Long(weight)); return this; } @Override - public Observable createAsync() { - final EndpointImpl self = this; + public Observable createAsync() { + final TrafficManagerEndpointImpl self = this; return this.client.createOrUpdateAsync(this.parent().resourceGroupName(), this.parent().name(), this.endpointType().toString(), this.name(), this.inner()) - .map(new Func1() { + .map(new Func1() { @Override - public Endpoint call(EndpointInner inner) { + public TrafficManagerEndpoint call(EndpointInner inner) { self.setInner(inner); return self; } @@ -140,7 +140,7 @@ public Endpoint call(EndpointInner inner) { } @Override - public Observable updateAsync() { + public Observable updateAsync() { return createAsync(); } @@ -158,12 +158,12 @@ public Void call(Void result) { } @Override - public ProfileImpl attach() { + public TrafficManagerProfileImpl attach() { return this.parent().withEndpoint(this); } @Override - public EndpointImpl refresh() { + public TrafficManagerEndpointImpl refresh() { EndpointInner inner = this.client.get(this.parent().resourceGroupName(), this.parent().name(), this.endpointType().toString(), diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointsImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java similarity index 59% rename from azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointsImpl.java rename to azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java index e0b2bc3ea74d0..6e60278258bbc 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/EndpointsImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java @@ -6,13 +6,12 @@ package com.microsoft.azure.management.trafficmanager.implementation; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.ExternalChildResourcesImpl; -import com.microsoft.azure.management.trafficmanager.AzureEndpoint; -import com.microsoft.azure.management.trafficmanager.Endpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerAzureEndpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerEndpoint; import com.microsoft.azure.management.trafficmanager.EndpointType; -import com.microsoft.azure.management.trafficmanager.ExternalEndpoint; -import com.microsoft.azure.management.trafficmanager.NestedProfileEndpoint; -import com.microsoft.azure.management.trafficmanager.Profile; -import com.sun.javaws.exceptions.InvalidArgumentException; +import com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerProfile; import java.util.ArrayList; import java.util.Collections; @@ -23,12 +22,12 @@ /** * Represents an endpoint collection associated with a traffic manager profile. */ -class EndpointsImpl extends - ExternalChildResourcesImpl { + TrafficManagerProfileImpl, + TrafficManagerProfile> { private final EndpointsInner client; /** @@ -37,7 +36,7 @@ class EndpointsImpl extends * @param client the client to perform REST calls on endpoints * @param parent the parent traffic manager profile of the endpoints */ - EndpointsImpl(EndpointsInner client, ProfileImpl parent) { + TrafficManagerEndpointsImpl(EndpointsInner client, TrafficManagerProfileImpl parent) { super(parent, "Endpoint"); this.client = client; this.initializeCollection(); @@ -46,12 +45,12 @@ class EndpointsImpl extends /** * @return the azure endpoints as a map indexed by name. */ - public Map azureEndpointsAsMap() { - Map result = new HashMap<>(); - for (Map.Entry entry : this.collection().entrySet()) { - EndpointImpl endpoint = entry.getValue(); + public Map azureEndpointsAsMap() { + Map result = new HashMap<>(); + for (Map.Entry entry : this.collection().entrySet()) { + TrafficManagerEndpointImpl endpoint = entry.getValue(); if (endpoint.endpointType() == EndpointType.AZURE) { - AzureEndpoint azureEndpoint = new AzureEndpointImpl(entry.getKey(), + TrafficManagerAzureEndpoint azureEndpoint = new TrafficManagerAzureEndpointImpl(entry.getKey(), this.parent(), endpoint.inner(), this.client); @@ -64,12 +63,12 @@ public Map azureEndpointsAsMap() { /** * @return the external endpoints as a map indexed by name. */ - public Map externalEndpointsAsMap() { - Map result = new HashMap<>(); - for (Map.Entry entry : this.collection().entrySet()) { - EndpointImpl endpoint = entry.getValue(); + public Map externalEndpointsAsMap() { + Map result = new HashMap<>(); + for (Map.Entry entry : this.collection().entrySet()) { + TrafficManagerEndpointImpl endpoint = entry.getValue(); if (endpoint.endpointType() == EndpointType.EXTERNAL) { - ExternalEndpoint externalEndpoint = new ExternalEndpointImpl(entry.getKey(), + TrafficManagerExternalEndpoint externalEndpoint = new TrafficManagerExternalEndpointImpl(entry.getKey(), this.parent(), endpoint.inner(), this.client); @@ -82,12 +81,12 @@ public Map externalEndpointsAsMap() { /** * @return the nested profile endpoints as a map indexed by name. */ - public Map nestedProfileEndpointsAsMap() { - Map result = new HashMap<>(); - for (Map.Entry entry : this.collection().entrySet()) { - EndpointImpl endpoint = entry.getValue(); + public Map nestedProfileEndpointsAsMap() { + Map result = new HashMap<>(); + for (Map.Entry entry : this.collection().entrySet()) { + TrafficManagerEndpointImpl endpoint = entry.getValue(); if (endpoint.endpointType() == EndpointType.NESTEDPROFILE) { - NestedProfileEndpoint nestedProfileEndpoint = new NestedProfileEndpointImpl(entry.getKey(), + TrafficManagerNestedProfileEndpoint nestedProfileEndpoint = new TrafficManagerNestedProfileEndpointImpl(entry.getKey(), this.parent(), endpoint.inner(), this.client); @@ -103,7 +102,7 @@ public Map nestedProfileEndpointsAsMap() { * @param name the name of the endpoint to be added * @return the endpoint */ - public EndpointImpl define(String name) { + public TrafficManagerEndpointImpl define(String name) { return this.prepareDefine(name); } @@ -113,8 +112,8 @@ public EndpointImpl define(String name) { * @param name the name of the endpoint to be updated * @return the endpoint */ - public EndpointImpl updateAzureEndpoint(String name) { - EndpointImpl endpoint = this.prepareUpdate(name); + public TrafficManagerEndpointImpl updateAzureEndpoint(String name) { + TrafficManagerEndpointImpl endpoint = this.prepareUpdate(name); if (endpoint.endpointType() != EndpointType.AZURE) { throw new IllegalArgumentException("An azure endpoint with name " + name + " not found in the profile"); } @@ -127,8 +126,8 @@ public EndpointImpl updateAzureEndpoint(String name) { * @param name the name of the endpoint to be updated * @return the endpoint */ - public EndpointImpl updateExternalEndpoint(String name) { - EndpointImpl endpoint = this.prepareUpdate(name); + public TrafficManagerEndpointImpl updateExternalEndpoint(String name) { + TrafficManagerEndpointImpl endpoint = this.prepareUpdate(name); if (endpoint.endpointType() != EndpointType.EXTERNAL) { throw new IllegalArgumentException("An external endpoint with name " + name + " not found in the profile"); } @@ -141,8 +140,8 @@ public EndpointImpl updateExternalEndpoint(String name) { * @param name the name of the endpoint to be updated * @return the endpoint */ - public EndpointImpl updateNestedProfileEndpoint(String name) { - EndpointImpl endpoint = this.prepareUpdate(name); + public TrafficManagerEndpointImpl updateNestedProfileEndpoint(String name) { + TrafficManagerEndpointImpl endpoint = this.prepareUpdate(name); if (endpoint.endpointType() != EndpointType.NESTEDPROFILE) { throw new IllegalArgumentException("A nested profile endpoint with name " + name + " not found in the profile"); } @@ -162,17 +161,17 @@ public void remove(String name) { * * @param endpoint the endpoint */ - public void addEndpoint(EndpointImpl endpoint) { + public void addEndpoint(TrafficManagerEndpointImpl endpoint) { this.addChildResource(endpoint); } @Override - protected List listChildResources() { - List childResources = new ArrayList<>(); + protected List listChildResources() { + List childResources = new ArrayList<>(); if (parent().inner().endpoints() != null) { for (EndpointInner inner : parent().inner().endpoints()) { if (inner.name() == null) { - childResources.add(new EndpointImpl(inner.name(), + childResources.add(new TrafficManagerEndpointImpl(inner.name(), this.parent(), inner, this.client)); @@ -183,8 +182,8 @@ protected List listChildResources() { } @Override - protected EndpointImpl newChildResource(String name) { - return new EndpointImpl(name, + protected TrafficManagerEndpointImpl newChildResource(String name) { + return new TrafficManagerEndpointImpl(name, this.parent(), new EndpointInner().withName(name), this.client); diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerExternalEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerExternalEndpointImpl.java new file mode 100644 index 0000000000000..8d5ac1b2a3de2 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerExternalEndpointImpl.java @@ -0,0 +1,26 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager.implementation; + +import com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint; + +/** + * Implementation for {@link TrafficManagerExternalEndpoint} + */ +class TrafficManagerExternalEndpointImpl extends TrafficManagerEndpointImpl + implements TrafficManagerExternalEndpoint { + TrafficManagerExternalEndpointImpl(String name, + TrafficManagerProfileImpl parent, + EndpointInner inner, + EndpointsInner client) { + super(name, parent, inner, client); + } + + @Override + public String fqdn() { + return inner().target(); + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/NestedProfileEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNestedProfileEndpointImpl.java similarity index 51% rename from azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/NestedProfileEndpointImpl.java rename to azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNestedProfileEndpointImpl.java index 5c7ec1a13f81d..a98c56c482293 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/NestedProfileEndpointImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNestedProfileEndpointImpl.java @@ -5,17 +5,17 @@ */ package com.microsoft.azure.management.trafficmanager.implementation; -import com.microsoft.azure.management.trafficmanager.NestedProfileEndpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint; /** - * Implementation for {@link NestedProfileEndpoint} + * Implementation for {@link TrafficManagerNestedProfileEndpoint} */ -public class NestedProfileEndpointImpl extends EndpointImpl - implements NestedProfileEndpoint { - NestedProfileEndpointImpl(String name, - ProfileImpl parent, - EndpointInner inner, - EndpointsInner client) { +class TrafficManagerNestedProfileEndpointImpl extends TrafficManagerEndpointImpl + implements TrafficManagerNestedProfileEndpoint { + TrafficManagerNestedProfileEndpointImpl(String name, + TrafficManagerProfileImpl parent, + EndpointInner inner, + EndpointsInner client) { super(name, parent, inner, client); } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfileImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java similarity index 58% rename from azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfileImpl.java rename to azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java index b0470e90114ad..62b75c08236e5 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfileImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java @@ -6,11 +6,11 @@ package com.microsoft.azure.management.trafficmanager.implementation; import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableResourceImpl; -import com.microsoft.azure.management.trafficmanager.AzureEndpoint; -import com.microsoft.azure.management.trafficmanager.ExternalEndpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerAzureEndpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint; import com.microsoft.azure.management.trafficmanager.MonitorConfig; -import com.microsoft.azure.management.trafficmanager.NestedProfileEndpoint; -import com.microsoft.azure.management.trafficmanager.Profile; +import com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerProfile; import com.microsoft.azure.management.trafficmanager.ProfileMonitorStatus; import com.microsoft.azure.management.trafficmanager.TrafficRoutingMethod; import rx.Observable; @@ -20,33 +20,33 @@ import java.util.Map; /** - * Implementation for {@link Profile} + * Implementation for {@link TrafficManagerProfile} */ -public class ProfileImpl +class TrafficManagerProfileImpl extends GroupableResourceImpl< - Profile, + TrafficManagerProfile, ProfileInner, - ProfileImpl, + TrafficManagerProfileImpl, TrafficManager> implements - Profile, - Profile.Definition, - Profile.Update { + TrafficManagerProfile, + TrafficManagerProfile.Definition, + TrafficManagerProfile.Update { private final ProfilesInner innerCollection; private final EndpointsInner endpointsClient; private final String profileStatusDisabled = "Disabled"; private final String profileStatusEnabled = "Enabled"; - private EndpointsImpl endpoints; + private TrafficManagerEndpointsImpl endpoints; - ProfileImpl(String name, - final ProfileInner innerModel, - final ProfilesInner innerCollection, - final EndpointsInner endpointsClient, - final TrafficManager trafficManager) { + TrafficManagerProfileImpl(String name, + final ProfileInner innerModel, + final ProfilesInner innerCollection, + final EndpointsInner endpointsClient, + final TrafficManager trafficManager) { super(name, innerModel, trafficManager); this.innerCollection = innerCollection; this.endpointsClient = endpointsClient; - this.endpoints = new EndpointsImpl(endpointsClient, this); + this.endpoints = new TrafficManagerEndpointsImpl(endpointsClient, this); } @Override @@ -76,7 +76,7 @@ public TrafficRoutingMethod trafficRoutingMethod() { @Override public ProfileMonitorStatus monitorStatus() { - return ProfileMonitorStatus.fromValue(this.inner().monitorConfig().profileMonitorStatus()); + return new ProfileMonitorStatus(this.inner().monitorConfig().profileMonitorStatus()); } @Override @@ -92,22 +92,22 @@ public String monitoringPath() { // TODO Expose monitoring protocol @Override - public Map externalEndpoints() { + public Map externalEndpoints() { return this.endpoints.externalEndpointsAsMap(); } @Override - public Map azureEndpoints() { + public Map azureEndpoints() { return this.endpoints.azureEndpointsAsMap(); } @Override - public Map nestedProfileEndpoints() { + public Map nestedProfileEndpoints() { return this.endpoints.nestedProfileEndpointsAsMap(); } @Override - public Profile refresh() { + public TrafficManagerProfile refresh() { ProfileInner inner = this.innerCollection.get(this.resourceGroupName(), this.name()); this.setInner(inner); this.endpoints.refresh(); @@ -115,67 +115,73 @@ public Profile refresh() { } @Override - public ProfileImpl withDnsLabel(String dnsLabel) { + public TrafficManagerProfileImpl withDnsLabel(String dnsLabel) { this.inner().dnsConfig().withRelativeName(dnsLabel); return this; } @Override - public ProfileImpl withPriorityRouting() { + public TrafficManagerProfileImpl withPriorityBasedRouting() { this.withTrafficRoutingMethod(TrafficRoutingMethod.PRIORITY); return this; } @Override - public ProfileImpl withWeightedRouting() { + public TrafficManagerProfileImpl withWeightBasedRouting() { this.withTrafficRoutingMethod(TrafficRoutingMethod.WEIGHTED); return this; } @Override - public ProfileImpl withPerformanceRouting() { + public TrafficManagerProfileImpl withPerformanceBasedRouting() { this.withTrafficRoutingMethod(TrafficRoutingMethod.PERFORMANCE); return this; } @Override - public ProfileImpl withTrafficRoutingMethod(TrafficRoutingMethod routingMethod) { + public TrafficManagerProfileImpl withTrafficRoutingMethod(TrafficRoutingMethod routingMethod) { this.inner().withTrafficRoutingMethod(routingMethod.toString()); return this; } @Override - public EndpointImpl defineNewEndpoint(String name) { + public TrafficManagerEndpointImpl defineEndpoint(String name) { return this.endpoints.define(name); } @Override - public EndpointImpl updateAzureEndpoint(String name) { + public TrafficManagerEndpointImpl updateAzureEndpoint(String name) { return this.endpoints.updateAzureEndpoint(name); } @Override - public EndpointImpl updateExternalEndpoint(String name) { + public TrafficManagerEndpointImpl updateExternalEndpoint(String name) { return this.endpoints.updateExternalEndpoint(name); } @Override - public EndpointImpl updateNestedProfileEndpoint(String name) { + public TrafficManagerEndpointImpl updateNestedProfileEndpoint(String name) { return this.endpoints.updateNestedProfileEndpoint(name); } @Override - public ProfileImpl withHttpMonitoring() { + public TrafficManagerProfileImpl withoutEndpoint(String name) { + this.endpoints.remove(name); + return this; + } + + @Override + public TrafficManagerProfileImpl withHttpMonitoring() { return this.withHttpMonitoring(80, "/"); } @Override - public ProfileImpl withHttpsMonitoring() { + public TrafficManagerProfileImpl withHttpsMonitoring() { return this.withHttpsMonitoring(443, "/"); } @Override - public ProfileImpl withHttpMonitoring(int port, String path) { + public TrafficManagerProfileImpl withHttpMonitoring(int port, String path) { this.inner().withMonitorConfig(new MonitorConfig() .withPort(new Long(port)) .withPath(path) @@ -184,7 +190,7 @@ public ProfileImpl withHttpMonitoring(int port, String path) { } @Override - public ProfileImpl withHttpsMonitoring(int port, String path) { + public TrafficManagerProfileImpl withHttpsMonitoring(int port, String path) { this.inner().withMonitorConfig(new MonitorConfig() .withPort(new Long(port)) .withPath(path) @@ -193,40 +199,40 @@ public ProfileImpl withHttpsMonitoring(int port, String path) { } @Override - public ProfileImpl withProfileStatusDisabled() { + public TrafficManagerProfileImpl withProfileStatusDisabled() { this.inner().withProfileStatus(this.profileStatusDisabled); return this; } @Override - public ProfileImpl withProfileStatusEnabled() { + public TrafficManagerProfileImpl withProfileStatusEnabled() { this.inner().withProfileStatus(this.profileStatusEnabled); return this; } @Override - public ProfileImpl withTtl(int ttlInSeconds) { + public TrafficManagerProfileImpl withTtl(int ttlInSeconds) { this.inner().dnsConfig().withTtl(new Long(ttlInSeconds)); return this; } @Override - public Observable createResourceAsync() { - final ProfileImpl self = this; + public Observable createResourceAsync() { + final TrafficManagerProfileImpl self = this; return innerCollection.createOrUpdateAsync(resourceGroupName(), name(), inner()) - .map(new Func1() { + .map(new Func1() { @Override - public Profile call(ProfileInner profileInner) { + public TrafficManagerProfile call(ProfileInner profileInner) { self.setInner(profileInner); return self; } - }).flatMap(new Func1>() { + }).flatMap(new Func1>() { @Override - public Observable call(Profile profile) { + public Observable call(TrafficManagerProfile profile) { return self.endpoints.commitAndGetAllAsync() - .map(new Func1, Profile>() { + .map(new Func1, TrafficManagerProfile>() { @Override - public Profile call(List endpoints) { + public TrafficManagerProfile call(List endpoints) { return self; } }); @@ -234,7 +240,7 @@ public Profile call(List endpoints) { }); } - ProfileImpl withEndpoint(EndpointImpl endpoint) { + TrafficManagerProfileImpl withEndpoint(TrafficManagerEndpointImpl endpoint) { this.endpoints.addEndpoint(endpoint); return this; } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfilesImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java similarity index 63% rename from azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfilesImpl.java rename to azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java index 2c9427d4c65e9..ccb42d9fed4d3 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/ProfilesImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java @@ -7,23 +7,23 @@ import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; -import com.microsoft.azure.management.trafficmanager.Profile; -import com.microsoft.azure.management.trafficmanager.Profiles; +import com.microsoft.azure.management.trafficmanager.TrafficManagerProfile; +import com.microsoft.azure.management.trafficmanager.TrafficManagerProfiles; import rx.Observable; /** - * Implementation for {@link Profiles} + * Implementation for {@link TrafficManagerProfiles} */ -public class ProfilesImpl extends GroupableResourcesImpl< - Profile, - ProfileImpl, +class TrafficManagerProfilesImpl extends GroupableResourcesImpl< + TrafficManagerProfile, + TrafficManagerProfileImpl, ProfileInner, ProfilesInner, TrafficManager> - implements Profiles { + implements TrafficManagerProfiles { private final EndpointsInner endpointsClient; - ProfilesImpl( + TrafficManagerProfilesImpl( final TrafficManagerManagementClientImpl trafficManagementClient, final TrafficManager trafficManager) { super(trafficManagementClient.profiles(), trafficManager); @@ -31,17 +31,17 @@ public class ProfilesImpl extends GroupableResourcesImpl< } @Override - public PagedList list() { + public PagedList list() { return wrapList(this.innerCollection.listAll()); } @Override - public PagedList listByGroup(String groupName) { + public PagedList listByGroup(String groupName) { return wrapList(this.innerCollection.listAllInResourceGroup(groupName)); } @Override - public Profile getByGroup(String groupName, String name) { + public TrafficManagerProfile getByGroup(String groupName, String name) { return wrapModel(this.innerCollection.get(groupName, name)); } @@ -51,8 +51,8 @@ public Observable deleteAsync(String groupName, String name) { } @Override - protected ProfileImpl wrapModel(String name) { - return new ProfileImpl(name, + protected TrafficManagerProfileImpl wrapModel(String name) { + return new TrafficManagerProfileImpl(name, new ProfileInner(), this.innerCollection, this.endpointsClient, @@ -60,8 +60,8 @@ protected ProfileImpl wrapModel(String name) { } @Override - protected ProfileImpl wrapModel(ProfileInner inner) { - return new ProfileImpl(inner.name(), + protected TrafficManagerProfileImpl wrapModel(ProfileInner inner) { + return new TrafficManagerProfileImpl(inner.name(), inner, this.innerCollection, this.endpointsClient, @@ -69,7 +69,7 @@ protected ProfileImpl wrapModel(ProfileInner inner) { } @Override - public ProfileImpl define(String name) { + public TrafficManagerProfileImpl define(String name) { return wrapModel(name); } } diff --git a/azure/pom.xml b/azure/pom.xml index fb411b5bdcdae..4fa1c4f04c628 100644 --- a/azure/pom.xml +++ b/azure/pom.xml @@ -91,6 +91,11 @@ azure-mgmt-batch 1.0.0-beta4-SNAPSHOT + + com.microsoft.azure + azure-mgmt-trafficmanager + 1.0.0-beta4-SNAPSHOT + junit junit diff --git a/azure/src/main/java/com/microsoft/azure/management/Azure.java b/azure/src/main/java/com/microsoft/azure/management/Azure.java index ea4eb0a07c97e..206126becaecb 100644 --- a/azure/src/main/java/com/microsoft/azure/management/Azure.java +++ b/azure/src/main/java/com/microsoft/azure/management/Azure.java @@ -41,6 +41,8 @@ import com.microsoft.azure.management.storage.StorageAccounts; import com.microsoft.azure.management.storage.Usages; import com.microsoft.azure.management.storage.implementation.StorageManager; +import com.microsoft.azure.management.trafficmanager.TrafficManagerProfiles; +import com.microsoft.azure.management.trafficmanager.implementation.TrafficManager; import java.io.File; import java.io.IOException; @@ -55,6 +57,7 @@ public final class Azure { private final NetworkManager networkManager; private final KeyVaultManager keyVaultManager; private final BatchManager batchManager; + private final TrafficManager trafficManager; private final String subscriptionId; /** @@ -257,6 +260,7 @@ private Azure(RestClient restClient, String subscriptionId, String tenantId) { this.networkManager = NetworkManager.authenticate(restClient, subscriptionId); this.keyVaultManager = KeyVaultManager.authenticate(restClient, tenantId, subscriptionId); this.batchManager = BatchManager.authenticate(restClient, subscriptionId); + this.trafficManager = TrafficManager.authenticate(restClient, subscriptionId); this.subscriptionId = subscriptionId; } @@ -393,4 +397,8 @@ public BatchAccounts batchAccounts() { return batchManager.batchAccounts(); } + /** + * @return entry point to managing traffic manager profiles. + */ + public TrafficManagerProfiles trafficManagerProfiles() {return trafficManager.profiles(); } } From 4662d076eaa846505a34c6377c71ee49974c95ee Mon Sep 17 00:00:00 2001 From: anuchan Date: Wed, 12 Oct 2016 16:10:02 -0700 Subject: [PATCH 04/12] TMProfile region is always 'global' so definition chain sholud start with RG withers, started testing and fixing implementations --- .../arm/models/GroupableResource.java | 60 ++++++++- .../implementation/GroupableResourceImpl.java | 28 +++++ .../trafficmanager/EndpointMonitorStatus.java | 7 +- .../trafficmanager/EndpointType.java | 12 +- .../trafficmanager/ProfileMonitorStatus.java | 5 + .../TargetAzureResourceType.java | 6 + .../TrafficManagerExternalEndpoint.java | 7 +- .../TrafficManagerNestedProfileEndpoint.java | 5 + .../trafficmanager/TrafficManagerProfile.java | 9 +- .../TrafficManagerAzureEndpointImpl.java | 2 +- .../TrafficManagerEndpointImpl.java | 2 +- .../TrafficManagerEndpointsImpl.java | 15 +-- .../TrafficManagerExternalEndpointImpl.java | 7 +- ...afficManagerNestedProfileEndpointImpl.java | 7 +- .../TrafficManagerProfileImpl.java | 18 +-- .../TrafficManagerProfilesImpl.java | 21 +++- .../trafficmanager/package-info.java | 11 ++ .../azure/management/AzureTests.java | 5 + .../azure/management/TestTrafficManager.java | 115 ++++++++++++++++++ 19 files changed, 301 insertions(+), 41 deletions(-) create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/package-info.java create mode 100644 azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/GroupableResource.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/GroupableResource.java index 2049a7538139e..be337f64e8e91 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/GroupableResource.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/GroupableResource.java @@ -8,6 +8,7 @@ import com.microsoft.azure.management.apigeneration.Fluent; import com.microsoft.azure.management.resources.ResourceGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; import com.microsoft.azure.management.resources.fluentcore.model.Creatable; /** @@ -23,10 +24,11 @@ public interface GroupableResource extends Resource { /** * Grouping of all the definition stages. */ - interface DefinitionStages { /** * A resource definition allowing a resource group to be selected. + *

+ * Region of the groupable resource will be used for new resource group * * @param the next stage of the resource definition */ @@ -36,11 +38,25 @@ interface WithGroup extends } /** - * A resource definition allowing a new resource group to be created. + * A resource definition allowing a resource group to be selected. + *

+ * Region has to be specified explicitly to create a new resource group * * @param the next stage of the resource definition */ - interface WithNewResourceGroup { + interface WithGroupAndRegion extends + WithExistingResourceGroup, + WithNewResourceGroupWithRegion { + } + + /** + * A resource definition allowing a new resource group to be created in the same + * region as groupable resource. + * + * @param the next stage of the resource definition + */ + interface WithNewResourceGroup extends + WithCreatableResourceGroup { /** * Creates a new resource group to put the resource in. *

@@ -58,7 +74,45 @@ interface WithNewResourceGroup { * @return the next stage of the resource definition */ T withNewResourceGroup(); + } + + /** + * A resource definition allowing a new resource group to be created in a different + * region . + * + * @param the next stage of the resource definition + */ + interface WithNewResourceGroupWithRegion extends + WithCreatableResourceGroup { + /** + * Creates a new resource group to put the resource in. + *

+ * The group will be created in the same location as the resource. + * + * @param name the name of the new group + * @param region the region where resource group needs to be created + * @return the next stage of the resource definition + */ + T withNewResourceGroup(String name, Region region); + /** + * Creates a new resource group to put the resource in. + *

+ * The group will be created in the same location as the resource. + * The group's name is automatically derived from the resource's name. + * + * @param region the region where resource group needs to be created + * @return the next stage of the resource definition + */ + T withNewResourceGroup(Region region); + } + + /** + * A resource definition allowing a new creatable resource group to be specified. + * + * @param the next stage of the resource definition + */ + interface WithCreatableResourceGroup { /** * Creates a new resource group to put the resource in, based on the definition specified. * @param groupDefinition a creatable definition for a new resource group diff --git a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/GroupableResourceImpl.java b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/GroupableResourceImpl.java index daa5fb6332fd8..ddf2388b6ee23 100644 --- a/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/GroupableResourceImpl.java +++ b/azure-mgmt-resources/src/main/java/com/microsoft/azure/management/resources/fluentcore/arm/models/implementation/GroupableResourceImpl.java @@ -7,6 +7,7 @@ package com.microsoft.azure.management.resources.fluentcore.arm.models.implementation; import com.microsoft.azure.management.resources.ResourceGroup; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; import com.microsoft.azure.management.resources.fluentcore.arm.ResourceUtils; import com.microsoft.azure.management.resources.fluentcore.arm.implementation.ManagerBase; import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource; @@ -82,6 +83,20 @@ public final FluentModelImplT withNewResourceGroup(String groupName) { this.myManager.resourceManager().resourceGroups().define(groupName).withRegion(this.regionName())); } + /** + * Creates a new resource group to put the resource in. + *

+ * The group will be created in the same location as the resource. + * + * @param groupName the name of the new group + * @param region the region where resource group needs to be created + * @return the next stage of the resource definition + */ + public final FluentModelImplT withNewResourceGroup(String groupName, Region region) { + return this.withNewResourceGroup( + this.myManager.resourceManager().resourceGroups().define(groupName).withRegion(region)); + } + /** * Creates a new resource group to put the resource in. *

@@ -93,6 +108,19 @@ public final FluentModelImplT withNewResourceGroup() { return this.withNewResourceGroup(this.name() + "group"); } + /** + * Creates a new resource group to put the resource in. + *

+ * The group will be created in the same location as the resource. + * The group's name is automatically derived from the resource's name. + * + * @param region the region where resource group needs to be created + * @return the next stage of the resource definition + */ + public final FluentModelImplT withNewResourceGroup(Region region) { + return this.withNewResourceGroup(this.name() + "group", region); + } + /** * Creates a new resource group to put the resource in, based on the definition specified. * @param creatable a creatable definition for a new resource group diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointMonitorStatus.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointMonitorStatus.java index 4534878053690..b5790c3d32c74 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointMonitorStatus.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointMonitorStatus.java @@ -25,10 +25,15 @@ public class EndpointMonitorStatus { public static final EndpointMonitorStatus CHECKINGENDPOINT = new EndpointMonitorStatus("CheckingEndpoint"); /** Static value Stopped for EndpointMonitorStatus. */ - public static final EndpointMonitorStatus STOPPED = new EndpointMonitorStatus ("Stopped"); + public static final EndpointMonitorStatus STOPPED = new EndpointMonitorStatus("Stopped"); private String value; + /** + * Creates EndpointMonitorStatus. + * + * @param value the status + */ public EndpointMonitorStatus(String value) { this.value = value; } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointType.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointType.java index 85f60ee18213c..13c48e40a83bf 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointType.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointType.java @@ -10,19 +10,19 @@ */ public enum EndpointType { /** - * Enum value AzureEndpoints. + * Enum value Microsoft.Network/trafficManagerProfiles/azureEndpoints. */ - AZURE("AzureEndpoints"), + AZURE("Microsoft.Network/trafficManagerProfiles/azureEndpoints"), /** - * Enum value ExternalEndpoints. + * Enum value Microsoft.Network/trafficManagerProfiles/externalEndpoints. */ - EXTERNAL("ExternalEndpoints"), + EXTERNAL("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), /** - * Enum value NestedEndpoints. + * Enum value Microsoft.Network/trafficManagerProfiles/nestedEndpoints. */ - NESTEDPROFILE("NestedEndpoints"); + NESTEDPROFILE("Microsoft.Network/trafficManagerProfiles/nestedEndpoints"); private String value; diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileMonitorStatus.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileMonitorStatus.java index 6332c2252bec9..bff04475bb63e 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileMonitorStatus.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileMonitorStatus.java @@ -26,6 +26,11 @@ public class ProfileMonitorStatus { private String value; + /** + * Creates ProfileMonitorStatus. + * + * @param value the status + */ public ProfileMonitorStatus(String value) { this.value = value; } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TargetAzureResourceType.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TargetAzureResourceType.java index 2fa29c48becfd..68f3046dc1b35 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TargetAzureResourceType.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TargetAzureResourceType.java @@ -20,6 +20,12 @@ public class TargetAzureResourceType { private String value; + /** + * Creates TargetAzureResourceType. + * + * @param resourceProviderName the resource provider name + * @param resourceType the resource type + */ public TargetAzureResourceType(String resourceProviderName, String resourceType) { this.value = resourceProviderName + "/" + resourceType; } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerExternalEndpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerExternalEndpoint.java index c0f7db54a2384..2923cbff513f6 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerExternalEndpoint.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerExternalEndpoint.java @@ -10,7 +10,12 @@ */ public interface TrafficManagerExternalEndpoint extends TrafficManagerEndpoint { /** - * @return the fully qualified DNS name of the external endpoint. + * @return the fully qualified DNS name of the external endpoint */ String fqdn(); + + /** + * @return the location of the traffic that the endpoint handles + */ + String sourceTrafficLocation(); } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerNestedProfileEndpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerNestedProfileEndpoint.java index e4ef31de84966..e6cad2d0d8fbb 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerNestedProfileEndpoint.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerNestedProfileEndpoint.java @@ -18,4 +18,9 @@ public interface TrafficManagerNestedProfileEndpoint extends TrafficManagerEndpo * @return the number of child endpoints to be online to consider nested profile as healthy */ int minChildEndpoints(); + + /** + * @return the location of the traffic that the endpoint handles + */ + String sourceTrafficLocation(); } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java index 2969b147f4d90..9e175c1e2e57e 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java @@ -90,7 +90,6 @@ public interface TrafficManagerProfile extends */ interface Definition extends DefinitionStages.Blank, - DefinitionStages.WithGroup, DefinitionStages.WithDnsLabel, DefinitionStages.WithTrafficRoutingMethod, DefinitionStages.WithMonitoringConfiguration, @@ -101,16 +100,10 @@ interface Definition extends * Grouping of traffic manager profile definition stages. */ interface DefinitionStages { - /** - * The first stage of a traffic manager profile definition. - */ - interface Blank extends GroupableResource.DefinitionWithRegion { - } - /** * The stage of the traffic manager profile definition allowing to specify the resource group. */ - interface WithGroup extends GroupableResource.DefinitionStages.WithGroup { + interface Blank extends GroupableResource.DefinitionStages.WithGroupAndRegion { } /** diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerAzureEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerAzureEndpointImpl.java index e48f47b16d21e..69e371531f33b 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerAzureEndpointImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerAzureEndpointImpl.java @@ -10,7 +10,7 @@ import com.microsoft.azure.management.trafficmanager.TargetAzureResourceType; /** - * Implementation for {@link TrafficManagerAzureEndpoint} + * Implementation for {@link TrafficManagerAzureEndpoint}. */ class TrafficManagerAzureEndpointImpl extends TrafficManagerEndpointImpl implements TrafficManagerAzureEndpoint { diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java index 245bb7db1b82d..b6e135e878f6f 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java @@ -15,7 +15,7 @@ import rx.functions.Func1; /** - * Implementation for {@link TrafficManagerEndpoint} + * Implementation for {@link TrafficManagerEndpoint}. */ class TrafficManagerEndpointImpl extends ExternalChildResourceImpl listChildResources() { List childResources = new ArrayList<>(); if (parent().inner().endpoints() != null) { for (EndpointInner inner : parent().inner().endpoints()) { - if (inner.name() == null) { - childResources.add(new TrafficManagerEndpointImpl(inner.name(), - this.parent(), - inner, - this.client)); - } + childResources.add(new TrafficManagerEndpointImpl(inner.name(), + this.parent(), + inner, + this.client)); } } return childResources; @@ -183,9 +181,12 @@ protected List listChildResources() { @Override protected TrafficManagerEndpointImpl newChildResource(String name) { - return new TrafficManagerEndpointImpl(name, + TrafficManagerEndpointImpl endpoint = new TrafficManagerEndpointImpl(name, this.parent(), new EndpointInner().withName(name), this.client); + return endpoint + .withRoutingWeight(1) + .withTrafficEnabled(); } } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerExternalEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerExternalEndpointImpl.java index 8d5ac1b2a3de2..68d43cfbc7d83 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerExternalEndpointImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerExternalEndpointImpl.java @@ -8,7 +8,7 @@ import com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint; /** - * Implementation for {@link TrafficManagerExternalEndpoint} + * Implementation for {@link TrafficManagerExternalEndpoint}. */ class TrafficManagerExternalEndpointImpl extends TrafficManagerEndpointImpl implements TrafficManagerExternalEndpoint { @@ -23,4 +23,9 @@ class TrafficManagerExternalEndpointImpl extends TrafficManagerEndpointImpl public String fqdn() { return inner().target(); } + + @Override + public String sourceTrafficLocation() { + return inner().endpointLocation(); + } } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNestedProfileEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNestedProfileEndpointImpl.java index a98c56c482293..4d5276d7e3786 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNestedProfileEndpointImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNestedProfileEndpointImpl.java @@ -8,7 +8,7 @@ import com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint; /** - * Implementation for {@link TrafficManagerNestedProfileEndpoint} + * Implementation for {@link TrafficManagerNestedProfileEndpoint}. */ class TrafficManagerNestedProfileEndpointImpl extends TrafficManagerEndpointImpl implements TrafficManagerNestedProfileEndpoint { @@ -31,4 +31,9 @@ public int minChildEndpoints() { } return inner().minChildEndpoints().intValue(); } + + @Override + public String sourceTrafficLocation() { + return inner().endpointLocation(); + } } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java index 62b75c08236e5..3b89e3164de08 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java @@ -20,7 +20,7 @@ import java.util.Map; /** - * Implementation for {@link TrafficManagerProfile} + * Implementation for {@link TrafficManagerProfile}. */ class TrafficManagerProfileImpl extends GroupableResourceImpl< @@ -182,19 +182,19 @@ public TrafficManagerProfileImpl withHttpsMonitoring() { @Override public TrafficManagerProfileImpl withHttpMonitoring(int port, String path) { - this.inner().withMonitorConfig(new MonitorConfig() - .withPort(new Long(port)) - .withPath(path) - .withProtocol("http")); + this.inner().monitorConfig() + .withPort(new Long(port)) + .withPath(path) + .withProtocol("http"); return this; } @Override public TrafficManagerProfileImpl withHttpsMonitoring(int port, String path) { - this.inner().withMonitorConfig(new MonitorConfig() - .withPort(new Long(port)) - .withPath(path) - .withProtocol("https")); + this.inner().monitorConfig() + .withPort(new Long(port)) + .withPath(path) + .withProtocol("https"); return this; } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java index ccb42d9fed4d3..bfd1768ed4e7b 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java @@ -7,12 +7,16 @@ import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; +import com.microsoft.azure.management.trafficmanager.DnsConfig; +import com.microsoft.azure.management.trafficmanager.MonitorConfig; import com.microsoft.azure.management.trafficmanager.TrafficManagerProfile; import com.microsoft.azure.management.trafficmanager.TrafficManagerProfiles; import rx.Observable; +import java.util.ArrayList; + /** - * Implementation for {@link TrafficManagerProfiles} + * Implementation for {@link TrafficManagerProfiles}. */ class TrafficManagerProfilesImpl extends GroupableResourcesImpl< TrafficManagerProfile, @@ -70,6 +74,19 @@ protected TrafficManagerProfileImpl wrapModel(ProfileInner inner) { @Override public TrafficManagerProfileImpl define(String name) { - return wrapModel(name); + return setDefaults(wrapModel(name)); + } + + private TrafficManagerProfileImpl setDefaults(TrafficManagerProfileImpl profile) { + // MonitorConfig is required + profile.inner().withMonitorConfig(new MonitorConfig()); + // DnsConfig is required + profile.inner().withDnsConfig(new DnsConfig()); + profile.withTtl(300); + // TM location must be 'global' irrespective of region of the resource group it resides. + profile.inner().withLocation("global"); + // Endpoints are external child resource still initializing it avoid null checks in the model impl. + profile.inner().withEndpoints(new ArrayList()); + return profile; } } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/package-info.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/package-info.java new file mode 100644 index 0000000000000..3347e61452c01 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the classes for TrafficManagerManagementClient. + * The TrafficManager Management Client. + */ +package com.microsoft.azure.management.trafficmanager; \ No newline at end of file diff --git a/azure/src/test/java/com/microsoft/azure/management/AzureTests.java b/azure/src/test/java/com/microsoft/azure/management/AzureTests.java index 69e7cf875aab2..6796836af19e3 100644 --- a/azure/src/test/java/com/microsoft/azure/management/AzureTests.java +++ b/azure/src/test/java/com/microsoft/azure/management/AzureTests.java @@ -302,4 +302,9 @@ public void createStorageAccount() throws Exception { public void testBatchAccount() throws Exception { new TestBatch().runTest(azure.batchAccounts(), azure.resourceGroups()); } + + @Test + public void testTrafficManager() throws Exception { + new TestTrafficManager().runTest(azure.trafficManagerProfiles(), azure.resourceGroups()); + } } diff --git a/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java b/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java new file mode 100644 index 0000000000000..a5a37130e9c42 --- /dev/null +++ b/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java @@ -0,0 +1,115 @@ +package com.microsoft.azure.management; + +import com.microsoft.azure.management.resources.fluentcore.arm.Region; +import com.microsoft.azure.management.resources.fluentcore.utils.ResourceNamer; +import com.microsoft.azure.management.trafficmanager.TrafficManagerAzureEndpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint; +import com.microsoft.azure.management.trafficmanager.TrafficManagerProfile; +import com.microsoft.azure.management.trafficmanager.TrafficManagerProfiles; + +import java.util.Map; + +/** + * Test of virtual network management. + */ +public class TestTrafficManager extends TestTemplate { + + @Override + public TrafficManagerProfile createResource(TrafficManagerProfiles profiles) throws Exception { + Region region = Region.US_EAST; + String groupName = "rg" + this.testId; + final String tmProfileName = "tm" + this.testId; + final String tmProfileDnsLabel = ResourceNamer.randomResourceName("tmdns", 20); + + TrafficManagerProfile profile = profiles.define(tmProfileName) + .withNewResourceGroup(groupName, region) + .withDnsLabel(tmProfileDnsLabel) + .withPriorityBasedRouting() + .withHttpMonitoring() + .defineEndpoint("ep1") + .withExternalFqdn("www.google.com") + .withSourceTrafficLocation(Region.ASIA_EAST) + .withRoutingPriority(1) + .withRoutingWeight(1) + .attach() + .create(); + return profile; + } + + @Override + public TrafficManagerProfile updateResource(TrafficManagerProfile profile) throws Exception { + return profile; + } + + @Override + public void print(TrafficManagerProfile profile) { + StringBuilder info = new StringBuilder(); + info.append("Traffic Manager Profile: ").append(profile.id()) + .append("\n\tName: ").append(profile.name()) + .append("\n\tResource group: ").append(profile.resourceGroupName()) + .append("\n\tRegion: ").append(profile.regionName()) + .append("\n\tTags: ").append(profile.tags()) + .append("\n\tDNSLabel: ").append(profile.dnsLabel()) + .append("\n\tFQDN: ").append(profile.fqdn()) + .append("\n\tTTL: ").append(profile.ttl()) + .append("\n\tDisabled: ").append(profile.isDisabled()) + .append("\n\tRoutingMethod: ").append(profile.trafficRoutingMethod()) + .append("\n\tMonitor status: ").append(profile.monitorStatus()) + .append("\n\tMonitoring port: ").append(profile.monitoringPort()) + .append("\n\tMonitoring path: ").append(profile.monitoringPath()); + + Map azureEndpoints = profile.azureEndpoints(); + if (!azureEndpoints.isEmpty()) { + info.append("\n\tAzure endpoints:"); + int idx = 1; + for (TrafficManagerAzureEndpoint endpoint : azureEndpoints.values()) { + info.append("\n\t\tAzure endpoint: #").append(idx++) + .append("\n\t\t\tId: ").append(endpoint.id()) + .append("\n\t\t\tType: ").append(endpoint.endpointType()) + .append("\n\t\t\tTarget resourceId: ").append(endpoint.targetAzureResourceId()) + .append("\n\t\t\tTarget resourceType: ").append(endpoint.targetResourceType()) + .append("\n\t\t\tMonitor status: ").append(endpoint.monitorStatus()) + .append("\n\t\t\tDisabled: ").append(endpoint.isDisabled()) + .append("\n\t\t\tRouting priority: ").append(endpoint.routingPriority()) + .append("\n\t\t\tRouting weight: ").append(endpoint.routingWeight()); + } + } + + Map externalEndpoints = profile.externalEndpoints(); + if (!externalEndpoints.isEmpty()) { + info.append("\n\tExternal endpoints:"); + int idx = 1; + for (TrafficManagerExternalEndpoint endpoint : externalEndpoints.values()) { + info.append("\n\t\tExternal endpoint: #").append(idx++) + .append("\n\t\t\tId: ").append(endpoint.id()) + .append("\n\t\t\tType: ").append(endpoint.endpointType()) + .append("\n\t\t\tFQDN: ").append(endpoint.fqdn()) + .append("\n\t\t\tSource Traffic Location: ").append(endpoint.sourceTrafficLocation()) + .append("\n\t\t\tMonitor status: ").append(endpoint.monitorStatus()) + .append("\n\t\t\tDisabled: ").append(endpoint.isDisabled()) + .append("\n\t\t\tRouting priority: ").append(endpoint.routingPriority()) + .append("\n\t\t\tRouting weight: ").append(endpoint.routingWeight()); + } + } + + Map nestedProfileEndpoints = profile.nestedProfileEndpoints(); + if (!nestedProfileEndpoints.isEmpty()) { + info.append("\n\tNested profile endpoints:"); + int idx = 1; + for (TrafficManagerNestedProfileEndpoint endpoint : nestedProfileEndpoints.values()) { + info.append("\n\t\tNested profile endpoint: #").append(idx++) + .append("\n\t\t\tId: ").append(endpoint.id()) + .append("\n\t\t\tType: ").append(endpoint.endpointType()) + .append("\n\t\t\tNested profileId: ").append(endpoint.nestedProfileId()) + .append("\n\t\t\tMinimum child threshold: ").append(endpoint.minChildEndpoints()) + .append("\n\t\t\tSource Traffic Location: ").append(endpoint.sourceTrafficLocation()) + .append("\n\t\t\tMonitor status: ").append(endpoint.monitorStatus()) + .append("\n\t\t\tDisabled: ").append(endpoint.isDisabled()) + .append("\n\t\t\tRouting priority: ").append(endpoint.routingPriority()) + .append("\n\t\t\tRouting weight: ").append(endpoint.routingWeight()); + } + } + System.out.println(info.toString()); + } +} From 04370618120350fd4efd315f53ee0efb937003ba Mon Sep 17 00:00:00 2001 From: anuchan Date: Wed, 12 Oct 2016 16:42:31 -0700 Subject: [PATCH 05/12] Setting endpoint type --- .../implementation/TrafficManagerEndpointImpl.java | 13 ++++++++----- .../implementation/TrafficManagerProfileImpl.java | 1 - .../com/microsoft/azure/management/AzureTests.java | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java index b6e135e878f6f..e0ee6dd4194eb 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java @@ -77,27 +77,30 @@ public TrafficManagerEndpointImpl withMinimumChildEndpoints(int count) { @Override public TrafficManagerEndpointImpl withTargetAzureResourceId(String resourceId) { + this.inner().withType(EndpointType.AZURE.toString()); this.inner().withTargetResourceId(resourceId); return this; } @Override public TrafficManagerEndpointImpl withExternalFqdn(String externalFqdn) { + this.inner().withType(EndpointType.EXTERNAL.toString()); this.inner().withTarget(externalFqdn); return this; } - public TrafficManagerEndpointImpl withSourceTrafficLocation(Region location) { - this.inner().withEndpointLocation(location.toString()); - return this; - } - @Override public TrafficManagerEndpointImpl withNestedProfile(TrafficManagerProfile nestedProfile) { + this.inner().withType(EndpointType.NESTEDPROFILE.toString()); this.inner().withTargetResourceId(nestedProfile.id()); return this; } + public TrafficManagerEndpointImpl withSourceTrafficLocation(Region location) { + this.inner().withEndpointLocation(location.toString()); + return this; + } + @Override public TrafficManagerEndpointImpl withRoutingPriority(int priority) { this.inner().withPriority(new Long(priority)); diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java index 3b89e3164de08..d85e2d2b18662 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java @@ -8,7 +8,6 @@ import com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableResourceImpl; import com.microsoft.azure.management.trafficmanager.TrafficManagerAzureEndpoint; import com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint; -import com.microsoft.azure.management.trafficmanager.MonitorConfig; import com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint; import com.microsoft.azure.management.trafficmanager.TrafficManagerProfile; import com.microsoft.azure.management.trafficmanager.ProfileMonitorStatus; diff --git a/azure/src/test/java/com/microsoft/azure/management/AzureTests.java b/azure/src/test/java/com/microsoft/azure/management/AzureTests.java index 37d440bddc7ab..9de9f8653e4f8 100644 --- a/azure/src/test/java/com/microsoft/azure/management/AzureTests.java +++ b/azure/src/test/java/com/microsoft/azure/management/AzureTests.java @@ -71,7 +71,7 @@ public static void main(String[] args) throws IOException, CloudException { public void setup() throws Exception { // Authenticate based on credentials instance Azure.Authenticated azureAuthed = Azure.configure() - .withLogLevel(Level.NONE) + .withLogLevel(Level.BODY) .withUserAgent("AzureTests") .authenticate(CREDENTIALS); From b49ac7499174b77043e182eee1345e61d7697038 Mon Sep 17 00:00:00 2001 From: anuchan Date: Wed, 12 Oct 2016 19:24:49 -0700 Subject: [PATCH 06/12] use local name for the endpoint type --- .../azure/management/trafficmanager/EndpointType.java | 10 ++++++++++ .../implementation/TrafficManagerEndpointImpl.java | 4 ++-- .../java/com/microsoft/azure/management/Azure.java | 4 +++- .../azure/management/TestTrafficManager.java | 11 +++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointType.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointType.java index 13c48e40a83bf..706e598d237f3 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointType.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointType.java @@ -50,4 +50,14 @@ public static EndpointType fromValue(String value) { public String toString() { return this.value; } + + /** + * @return the local name of the endpoint type + */ + public String localName() { + if (this.value != null) { + return this.value.substring(this.value.lastIndexOf('/') + 1); + } + return null; + } } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java index e0ee6dd4194eb..efcf36d280e59 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java @@ -130,7 +130,7 @@ public Observable createAsync() { final TrafficManagerEndpointImpl self = this; return this.client.createOrUpdateAsync(this.parent().resourceGroupName(), this.parent().name(), - this.endpointType().toString(), + this.endpointType().localName(), this.name(), this.inner()) .map(new Func1() { @@ -151,7 +151,7 @@ public Observable updateAsync() { public Observable deleteAsync() { return this.client.deleteAsync(this.parent().resourceGroupName(), this.parent().name(), - this.endpointType().toString(), + this.endpointType().localName(), this.name()).map(new Func1() { @Override public Void call(Void result) { diff --git a/azure/src/main/java/com/microsoft/azure/management/Azure.java b/azure/src/main/java/com/microsoft/azure/management/Azure.java index 206126becaecb..2fbe66d2249d2 100644 --- a/azure/src/main/java/com/microsoft/azure/management/Azure.java +++ b/azure/src/main/java/com/microsoft/azure/management/Azure.java @@ -400,5 +400,7 @@ public BatchAccounts batchAccounts() { /** * @return entry point to managing traffic manager profiles. */ - public TrafficManagerProfiles trafficManagerProfiles() {return trafficManager.profiles(); } + public TrafficManagerProfiles trafficManagerProfiles() { + return trafficManager.profiles(); + } } diff --git a/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java b/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java index a5a37130e9c42..3b0547c119610 100644 --- a/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java +++ b/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java @@ -33,6 +33,17 @@ public TrafficManagerProfile createResource(TrafficManagerProfiles profiles) thr .withRoutingPriority(1) .withRoutingWeight(1) .attach() + .defineEndpoint("ep2") + .withExternalFqdn("www.yahoo.com") + .withSourceTrafficLocation(Region.EUROPE_NORTH) + .withRoutingPriority(2) + .withRoutingWeight(1) + .attach() + .defineEndpoint("ep3") + .withExternalFqdn("www.linkedin.com") + .withSourceTrafficLocation(Region.US_EAST2) + .withRoutingWeight(1) + .attach() .create(); return profile; } From 3aceed183f05ab41e37ed4102b87e3a17288f961 Mon Sep 17 00:00:00 2001 From: anuchan Date: Thu, 13 Oct 2016 12:57:28 -0700 Subject: [PATCH 07/12] Implementing update and adding unit tests --- .../TrafficManagerExternalEndpoint.java | 4 +- .../TrafficManagerNestedProfileEndpoint.java | 4 +- .../TrafficManagerExternalEndpointImpl.java | 9 +- ...afficManagerNestedProfileEndpointImpl.java | 9 +- .../TrafficManagerProfileImpl.java | 22 ++ .../azure/management/AzureTests.java | 3 +- .../azure/management/TestTemplate.java | 2 +- .../azure/management/TestTrafficManager.java | 228 ++++++++++++++++-- 8 files changed, 258 insertions(+), 23 deletions(-) diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerExternalEndpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerExternalEndpoint.java index 2923cbff513f6..0a782c7dba422 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerExternalEndpoint.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerExternalEndpoint.java @@ -5,6 +5,8 @@ */ package com.microsoft.azure.management.trafficmanager; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; + /** * An immutable client-side representation of an Azure traffic manager profile external endpoint. */ @@ -17,5 +19,5 @@ public interface TrafficManagerExternalEndpoint extends TrafficManagerEndpoint { /** * @return the location of the traffic that the endpoint handles */ - String sourceTrafficLocation(); + Region sourceTrafficLocation(); } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerNestedProfileEndpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerNestedProfileEndpoint.java index e6cad2d0d8fbb..6e1a2e173abf5 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerNestedProfileEndpoint.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerNestedProfileEndpoint.java @@ -5,6 +5,8 @@ */ package com.microsoft.azure.management.trafficmanager; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; + /** * An immutable client-side representation of an Azure traffic manager profile nested profile endpoint. */ @@ -22,5 +24,5 @@ public interface TrafficManagerNestedProfileEndpoint extends TrafficManagerEndpo /** * @return the location of the traffic that the endpoint handles */ - String sourceTrafficLocation(); + Region sourceTrafficLocation(); } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerExternalEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerExternalEndpointImpl.java index 68d43cfbc7d83..0c29228a37673 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerExternalEndpointImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerExternalEndpointImpl.java @@ -5,6 +5,7 @@ */ package com.microsoft.azure.management.trafficmanager.implementation; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; import com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint; /** @@ -25,7 +26,11 @@ public String fqdn() { } @Override - public String sourceTrafficLocation() { - return inner().endpointLocation(); + public Region sourceTrafficLocation() { + Region location = Region.fromLabel((inner().endpointLocation())); + if (location == null) { + return Region.fromName((inner().endpointLocation())); + } + return location; } } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNestedProfileEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNestedProfileEndpointImpl.java index 4d5276d7e3786..54a446f6decee 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNestedProfileEndpointImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNestedProfileEndpointImpl.java @@ -5,6 +5,7 @@ */ package com.microsoft.azure.management.trafficmanager.implementation; +import com.microsoft.azure.management.resources.fluentcore.arm.Region; import com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint; /** @@ -33,7 +34,11 @@ public int minChildEndpoints() { } @Override - public String sourceTrafficLocation() { - return inner().endpointLocation(); + public Region sourceTrafficLocation() { + Region location = Region.fromLabel((inner().endpointLocation())); + if (location == null) { + return Region.fromName((inner().endpointLocation())); + } + return location; } } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java index d85e2d2b18662..390fec2a75aeb 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java @@ -239,6 +239,28 @@ public TrafficManagerProfile call(List endpoints) { }); } + @Override + public Observable updateResourceAsync() { + final TrafficManagerProfileImpl self = this; + // In update we first commit the endpoints then update profile, the reason is through portal and direct API + // call one can create endpoints without properties those are not applicable for the profile's current routing + // method. We cannot update the routing method of the profile until existing endpoints contains the properties + // required for the new routing method. + return self.endpoints.commitAndGetAllAsync() + .flatMap(new Func1, Observable>() { + public Observable call(List endpoints) { + return innerCollection.createOrUpdateAsync(resourceGroupName(), name(), inner()) + .map(new Func1() { + @Override + public TrafficManagerProfile call(ProfileInner profileInner) { + self.setInner(profileInner); + return self; + } + }); + } + }); + } + TrafficManagerProfileImpl withEndpoint(TrafficManagerEndpointImpl endpoint) { this.endpoints.addEndpoint(endpoint); return this; diff --git a/azure/src/test/java/com/microsoft/azure/management/AzureTests.java b/azure/src/test/java/com/microsoft/azure/management/AzureTests.java index 9de9f8653e4f8..caaa685819698 100644 --- a/azure/src/test/java/com/microsoft/azure/management/AzureTests.java +++ b/azure/src/test/java/com/microsoft/azure/management/AzureTests.java @@ -308,6 +308,7 @@ public void testBatchAccount() throws Exception { @Test public void testTrafficManager() throws Exception { - new TestTrafficManager().runTest(azure.trafficManagerProfiles(), azure.resourceGroups()); + new TestTrafficManager(azure.resourceGroups(), azure.publicIpAddresses()) + .runTest(azure.trafficManagerProfiles(), azure.resourceGroups()); } } diff --git a/azure/src/test/java/com/microsoft/azure/management/TestTemplate.java b/azure/src/test/java/com/microsoft/azure/management/TestTemplate.java index 08d05e1c237c2..d8ec6398dd786 100644 --- a/azure/src/test/java/com/microsoft/azure/management/TestTemplate.java +++ b/azure/src/test/java/com/microsoft/azure/management/TestTemplate.java @@ -110,7 +110,7 @@ public void runTest(C collection, ResourceGroups resourceGroups) throws Exceptio print(this.resource); // Verify listing - Assert.assertTrue(verifyListing() - initialCount == 1); + Assert.assertTrue(verifyListing() - initialCount >= 1); // Verify getting this.resource = verifyGetting(); diff --git a/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java b/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java index 3b0547c119610..a6143b7989e53 100644 --- a/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java +++ b/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java @@ -1,12 +1,19 @@ package com.microsoft.azure.management; +import com.microsoft.azure.management.network.PublicIpAddress; +import com.microsoft.azure.management.network.PublicIpAddresses; +import com.microsoft.azure.management.resources.ResourceGroup; +import com.microsoft.azure.management.resources.ResourceGroups; import com.microsoft.azure.management.resources.fluentcore.arm.Region; import com.microsoft.azure.management.resources.fluentcore.utils.ResourceNamer; +import com.microsoft.azure.management.trafficmanager.EndpointType; +import com.microsoft.azure.management.trafficmanager.TargetAzureResourceType; import com.microsoft.azure.management.trafficmanager.TrafficManagerAzureEndpoint; import com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint; import com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint; import com.microsoft.azure.management.trafficmanager.TrafficManagerProfile; import com.microsoft.azure.management.trafficmanager.TrafficManagerProfiles; +import org.junit.Assert; import java.util.Map; @@ -15,41 +22,232 @@ */ public class TestTrafficManager extends TestTemplate { + private final PublicIpAddresses publicIpAddresses; + private final ResourceGroups resourceGroups; + + private final String externalEndpointName21 = "external-ep-1"; + private final String externalEndpointName22 = "external-ep-2"; + private final String externalEndpointName23 = "external-ep-3"; + + private final String externalFqdn21 = "www.azure.microsoft.com"; + private final String externalFqdn22 = "www.bing.com"; + private final String externalFqdn23 = "www.github.com"; + + private final String azureEndpointName = "azure-ep-1"; + private final String nestedProfileEndpointName = "nested-profile-ep-1"; + + public TestTrafficManager(ResourceGroups resourceGroups, PublicIpAddresses publicIpAddresses) { + this.resourceGroups = resourceGroups; + this.publicIpAddresses = publicIpAddresses; + } + @Override public TrafficManagerProfile createResource(TrafficManagerProfiles profiles) throws Exception { - Region region = Region.US_EAST; - String groupName = "rg" + this.testId; + final Region region = Region.US_EAST; + final String groupName = "rg" + this.testId; + + final String pipName = "pip" + this.testId; + final String pipDnsLabel = ResourceNamer.randomResourceName("contoso", 15); + final String tmProfileName = "tm" + this.testId; - final String tmProfileDnsLabel = ResourceNamer.randomResourceName("tmdns", 20); + final String nestedTmProfileName = "nested" + tmProfileName; + + final String tmProfileDnsLabel = ResourceNamer.randomResourceName("tmdns", 15); + final String nestedTmProfileDnsLabel = "nested" + tmProfileDnsLabel; + + ResourceGroup.DefinitionStages.WithCreate rgCreatable = resourceGroups.define(groupName) + .withRegion(region); + // Creates a TM profile that will be used as a nested profile endpoint in parent TM profile + // + TrafficManagerProfile nestedProfile = profiles.define(nestedTmProfileName) + .withNewResourceGroup(rgCreatable) + .withDnsLabel(nestedTmProfileDnsLabel) + .withPriorityBasedRouting() + .withHttpsMonitoring() + .defineEndpoint("external-ep-1") + .withExternalFqdn("www.gitbook.com") + .withSourceTrafficLocation(Region.INDIA_CENTRAL) + .attach() + .withTtl(500) + .create(); + + Assert.assertFalse(nestedProfile.isDisabled()); + Assert.assertNotNull(nestedProfile.monitorStatus()); + Assert.assertEquals(nestedProfile.monitoringPort(), 443); + Assert.assertEquals(nestedProfile.monitoringPath(), "/"); + Assert.assertEquals(nestedProfile.azureEndpoints().size(), 0); + Assert.assertEquals(nestedProfile.nestedProfileEndpoints().size(), 0); + Assert.assertEquals(nestedProfile.externalEndpoints().size(), 1); + Assert.assertEquals(nestedProfile.fqdn(), nestedTmProfileDnsLabel + ".trafficmanager.net"); + Assert.assertEquals(nestedProfile.ttl(), 500); + + // Creates a public ip to be used as an Azure endpoint + // + PublicIpAddress publicIpAddress = this.publicIpAddresses.define(pipName) + .withRegion(region) + .withNewResourceGroup(rgCreatable) + .withLeafDomainLabel(pipDnsLabel) + .create(); + + Assert.assertNotNull(publicIpAddress.fqdn()); + // Creates a TM profile + // TrafficManagerProfile profile = profiles.define(tmProfileName) - .withNewResourceGroup(groupName, region) + .withNewResourceGroup(rgCreatable) .withDnsLabel(tmProfileDnsLabel) - .withPriorityBasedRouting() + .withWeightBasedRouting() .withHttpMonitoring() - .defineEndpoint("ep1") - .withExternalFqdn("www.google.com") - .withSourceTrafficLocation(Region.ASIA_EAST) + .defineEndpoint(externalEndpointName21) + .withExternalFqdn(externalFqdn21) + .withSourceTrafficLocation(Region.US_EAST) .withRoutingPriority(1) .withRoutingWeight(1) .attach() - .defineEndpoint("ep2") - .withExternalFqdn("www.yahoo.com") - .withSourceTrafficLocation(Region.EUROPE_NORTH) + .defineEndpoint(externalEndpointName22) + .withExternalFqdn(externalFqdn22) + .withSourceTrafficLocation(Region.US_EAST2) .withRoutingPriority(2) .withRoutingWeight(1) + .withTrafficDisabled() .attach() - .defineEndpoint("ep3") - .withExternalFqdn("www.linkedin.com") - .withSourceTrafficLocation(Region.US_EAST2) - .withRoutingWeight(1) + .defineEndpoint(azureEndpointName) + .withTargetAzureResourceId(publicIpAddress.id()) + .withRoutingPriority(3) + .attach() + .defineEndpoint(nestedProfileEndpointName) + .withNestedProfile(nestedProfile) + .withMinimumChildEndpoints(1) + .withSourceTrafficLocation(Region.INDIA_CENTRAL) + .withRoutingPriority(4) .attach() .create(); + + Assert.assertFalse(profile.isDisabled()); + Assert.assertNotNull(profile.monitorStatus()); + Assert.assertEquals(profile.monitoringPort(), 80); + Assert.assertEquals(profile.monitoringPath(), "/"); + Assert.assertEquals(profile.azureEndpoints().size(), 1); + Assert.assertEquals(profile.nestedProfileEndpoints().size(), 1); + Assert.assertEquals(profile.externalEndpoints().size(), 2); + Assert.assertEquals(profile.fqdn(), tmProfileDnsLabel + ".trafficmanager.net"); + Assert.assertEquals(profile.ttl(), 300); // Default + + profile = profile.refresh(); + Assert.assertEquals(profile.azureEndpoints().size(), 1); + Assert.assertEquals(profile.nestedProfileEndpoints().size(), 1); + Assert.assertEquals(profile.externalEndpoints().size(), 2); + + int c = 0; + for (TrafficManagerExternalEndpoint endpoint : profile.externalEndpoints().values()) { + Assert.assertEquals(endpoint.endpointType(), EndpointType.EXTERNAL); + if (endpoint.name().equalsIgnoreCase(externalEndpointName21)) { + Assert.assertEquals(endpoint.routingPriority(), 1); + Assert.assertEquals(endpoint.fqdn(), externalFqdn21); + Assert.assertNotNull(endpoint.monitorStatus()); + Assert.assertEquals(endpoint.sourceTrafficLocation(), Region.US_EAST); + c++; + } else if (endpoint.name().equalsIgnoreCase(externalEndpointName22)) { + Assert.assertEquals(endpoint.routingPriority(), 2); + Assert.assertEquals(endpoint.fqdn(), externalFqdn22); + Assert.assertNotNull(endpoint.monitorStatus()); + Assert.assertEquals(endpoint.sourceTrafficLocation(), Region.US_EAST2); + c++; + } + } + Assert.assertEquals(c, 2); + + c = 0; + for (TrafficManagerAzureEndpoint endpoint : profile.azureEndpoints().values()) { + Assert.assertEquals(endpoint.endpointType(), EndpointType.AZURE); + if (endpoint.name().equalsIgnoreCase(azureEndpointName)) { + Assert.assertEquals(endpoint.routingPriority(), 3); + Assert.assertNotNull(endpoint.monitorStatus()); + Assert.assertEquals(endpoint.targetAzureResourceId(), publicIpAddress.id()); + Assert.assertEquals(endpoint.targetResourceType(), TargetAzureResourceType.PUBLICIP); + c++; + } + } + Assert.assertEquals(c, 1); + + c = 0; + for (TrafficManagerNestedProfileEndpoint endpoint : profile.nestedProfileEndpoints().values()) { + Assert.assertEquals(endpoint.endpointType(), EndpointType.NESTEDPROFILE); + if (endpoint.name().equalsIgnoreCase(nestedProfileEndpointName)) { + Assert.assertEquals(endpoint.routingPriority(), 4); + Assert.assertNotNull(endpoint.monitorStatus()); + Assert.assertEquals(endpoint.minChildEndpoints(), 1); + Assert.assertEquals(endpoint.nestedProfileId(), nestedProfile.id()); + Assert.assertEquals(endpoint.sourceTrafficLocation(), Region.INDIA_CENTRAL); + c++; + } + } + Assert.assertEquals(c, 1); return profile; } @Override public TrafficManagerProfile updateResource(TrafficManagerProfile profile) throws Exception { + // Remove an endpoint, update two endpoints and add new one + // + profile.update() + .withTtl(600) + .withHttpMonitoring(8080, "/") + .withPerformanceBasedRouting() + .withoutEndpoint(externalEndpointName21) + .updateAzureEndpoint(azureEndpointName) + .withRoutingPriority(5) + .withRoutingWeight(2) + .parent() + .updateNestedProfileEndpoint(nestedProfileEndpointName) + .withTrafficDisabled() + .parent() + .defineEndpoint(externalEndpointName23) + .withExternalFqdn(externalFqdn23) + .withSourceTrafficLocation(Region.US_CENTRAL) + .withRoutingPriority(6) + .attach() + .apply(); + + Assert.assertEquals(profile.monitoringPort(), 8080); + Assert.assertEquals(profile.monitoringPath(), "/"); + Assert.assertEquals(profile.azureEndpoints().size(), 1); + Assert.assertEquals(profile.nestedProfileEndpoints().size(), 1); + Assert.assertEquals(profile.externalEndpoints().size(), 2); + Assert.assertEquals(profile.ttl(), 600); + + int c = 0; + for (TrafficManagerExternalEndpoint endpoint : profile.externalEndpoints().values()) { + Assert.assertEquals(endpoint.endpointType(), EndpointType.EXTERNAL); + if (endpoint.name().equalsIgnoreCase(externalEndpointName22)) { + Assert.assertEquals(endpoint.routingPriority(), 2); + Assert.assertEquals(endpoint.fqdn(), externalFqdn22); + Assert.assertEquals(endpoint.sourceTrafficLocation(), Region.US_EAST2); + Assert.assertNotNull(endpoint.monitorStatus()); + c++; + } else if (endpoint.name().equalsIgnoreCase(externalEndpointName23)) { + Assert.assertEquals(endpoint.routingPriority(), 6); + Assert.assertEquals(endpoint.fqdn(), externalFqdn23); + Assert.assertNotNull(endpoint.monitorStatus()); + Assert.assertEquals(endpoint.sourceTrafficLocation(), Region.US_CENTRAL); + c++; + } else { + c++; + } + } + Assert.assertEquals(c, 2); + + c = 0; + for (TrafficManagerAzureEndpoint endpoint : profile.azureEndpoints().values()) { + Assert.assertEquals(endpoint.endpointType(), EndpointType.AZURE); + if (endpoint.name().equalsIgnoreCase(azureEndpointName)) { + Assert.assertEquals(endpoint.routingPriority(), 5); + Assert.assertEquals(endpoint.routingWeight(), 2); + Assert.assertEquals(endpoint.targetResourceType(), TargetAzureResourceType.PUBLICIP); + c++; + } + } + Assert.assertEquals(c, 1); return profile; } From 0287b2ab0120d850657ebd5d62739ba988f90ebb Mon Sep 17 00:00:00 2001 From: anuchan Date: Thu, 13 Oct 2016 16:06:36 -0700 Subject: [PATCH 08/12] Adding check dns name availabilty action --- ...CheckProfileDnsNameAvailabilityResult.java | 46 ++++++++++++++++ .../ProfileDnsNameUnavailableReason.java | 55 +++++++++++++++++++ .../TrafficManagerProfiles.java | 8 +++ .../TrafficManagerProfilesImpl.java | 12 ++++ 4 files changed, 121 insertions(+) create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/CheckProfileDnsNameAvailabilityResult.java create mode 100644 azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileDnsNameUnavailableReason.java diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/CheckProfileDnsNameAvailabilityResult.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/CheckProfileDnsNameAvailabilityResult.java new file mode 100644 index 0000000000000..3fd6ca0818b06 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/CheckProfileDnsNameAvailabilityResult.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +import com.microsoft.azure.management.trafficmanager.implementation.TrafficManagerNameAvailabilityInner; + +/** + * The {@link com.microsoft.azure.management.trafficmanager.TrafficManagerProfiles#checkDnsNameAvailability} action result. + */ +public class CheckProfileDnsNameAvailabilityResult { + private TrafficManagerNameAvailabilityInner inner; + + /** + * Creates an instance of CheckProfileDnsNameAvailabilityResult. + * + * @param inner the inner object + */ + public CheckProfileDnsNameAvailabilityResult(TrafficManagerNameAvailabilityInner inner) { + this.inner = inner; + } + + /** + * @return true if the DNS name is available to use, false if the name has already been taken + * or invalid and cannot be used. + */ + public boolean isAvailable() { + return inner.nameAvailable(); + } + + /** + * @return the reason that the DNS name could not be used + */ + public ProfileDnsNameUnavailableReason reason() { + return new ProfileDnsNameUnavailableReason(inner.reason()); + } + + /** + * @return an error message explaining the reason value in more detail + */ + public String message() { + return inner.message(); + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileDnsNameUnavailableReason.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileDnsNameUnavailableReason.java new file mode 100644 index 0000000000000..3486e439fc6e7 --- /dev/null +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileDnsNameUnavailableReason.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + */ +package com.microsoft.azure.management.trafficmanager; + +/** + * The reason for unavailability of traffic manager profile DNS name. + */ +public class ProfileDnsNameUnavailableReason { + /** Static value Invalid for ProfileDnsNameUnavailableReason. */ + public static final ProfileDnsNameUnavailableReason INVALID = new ProfileDnsNameUnavailableReason("Invalid"); + + /** Static value AlreadyExists for ProfileDnsNameUnavailableReason. */ + public static final ProfileDnsNameUnavailableReason ALREADYEXISTS = new ProfileDnsNameUnavailableReason("AlreadyExists"); + + private String value; + + /** + * Creates ProfileDnsNameUnavailableReason. + * + * @param value the reason + */ + public ProfileDnsNameUnavailableReason(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + @Override + public int hashCode() { + return this.value.hashCode(); + } + + @Override + public boolean equals(Object obj) { + String value = this.toString(); + if (!(obj instanceof ProfileDnsNameUnavailableReason)) { + return false; + } + if (obj == this) { + return true; + } + ProfileDnsNameUnavailableReason rhs = (ProfileDnsNameUnavailableReason) obj; + if (value == null) { + return rhs.value == null; + } else { + return value.equals(rhs.value); + } + } +} diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfiles.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfiles.java index bfd6048001927..3e53d21a96b6a 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfiles.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfiles.java @@ -28,4 +28,12 @@ public interface TrafficManagerProfiles extends SupportsDeleting, SupportsDeletingByGroup, SupportsBatchCreation { + + /** + * Checks that the DNS name is valid for traffic manager profile and is not in use. + * + * @param dnsNameLabel the DNS name to check + * @return whether the DNS is available to be used for a traffic manager profile and other info if not + */ + CheckProfileDnsNameAvailabilityResult checkDnsNameAvailability(String dnsNameLabel); } \ No newline at end of file diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java index bfd1768ed4e7b..3959e3d887e58 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java @@ -7,6 +7,7 @@ import com.microsoft.azure.PagedList; import com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl; +import com.microsoft.azure.management.trafficmanager.CheckProfileDnsNameAvailabilityResult; import com.microsoft.azure.management.trafficmanager.DnsConfig; import com.microsoft.azure.management.trafficmanager.MonitorConfig; import com.microsoft.azure.management.trafficmanager.TrafficManagerProfile; @@ -34,6 +35,17 @@ class TrafficManagerProfilesImpl extends GroupableResourcesImpl< this.endpointsClient = trafficManagementClient.endpoints(); } + @Override + public CheckProfileDnsNameAvailabilityResult checkDnsNameAvailability(String dnsNameLabel) { + CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner parameter = + new CheckTrafficManagerRelativeDnsNameAvailabilityParametersInner() + .withName(dnsNameLabel) + .withType("Microsoft.Network/trafficManagerProfiles"); + return new CheckProfileDnsNameAvailabilityResult(this + .innerCollection + .checkTrafficManagerRelativeDnsNameAvailability(parameter)); + } + @Override public PagedList list() { return wrapList(this.innerCollection.listAll()); From 20ed4443016c39e9cbf7b7306a5b6f1d6399f54e Mon Sep 17 00:00:00 2001 From: anuchan Date: Mon, 17 Oct 2016 13:59:20 -0700 Subject: [PATCH 09/12] Addressing review comments --- .../trafficmanager/EndpointMonitorStatus.java | 2 +- .../trafficmanager/EndpointType.java | 2 +- .../trafficmanager/ProfileMonitorStatus.java | 2 +- .../TrafficManagerEndpoint.java | 100 ++++++++++-------- .../TrafficManagerNestedProfileEndpoint.java | 2 +- .../trafficmanager/TrafficManagerProfile.java | 12 +-- .../TrafficManagerEndpointImpl.java | 8 +- .../TrafficManagerEndpointsImpl.java | 10 +- ...afficManagerNestedProfileEndpointImpl.java | 2 +- .../TrafficManagerProfileImpl.java | 8 +- .../TrafficManagerProfilesImpl.java | 2 +- .../azure/management/TestTrafficManager.java | 40 +++---- 12 files changed, 98 insertions(+), 92 deletions(-) diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointMonitorStatus.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointMonitorStatus.java index b5790c3d32c74..416d4c309df07 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointMonitorStatus.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointMonitorStatus.java @@ -22,7 +22,7 @@ public class EndpointMonitorStatus { public static final EndpointMonitorStatus DEGRADED = new EndpointMonitorStatus("Degraded"); /** Static value CheckingEndpoint for EndpointMonitorStatus. */ - public static final EndpointMonitorStatus CHECKINGENDPOINT = new EndpointMonitorStatus("CheckingEndpoint"); + public static final EndpointMonitorStatus CHECKING_ENDPOINT = new EndpointMonitorStatus("CheckingEndpoint"); /** Static value Stopped for EndpointMonitorStatus. */ public static final EndpointMonitorStatus STOPPED = new EndpointMonitorStatus("Stopped"); diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointType.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointType.java index 706e598d237f3..4aa0f709a5e25 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointType.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/EndpointType.java @@ -22,7 +22,7 @@ public enum EndpointType { /** * Enum value Microsoft.Network/trafficManagerProfiles/nestedEndpoints. */ - NESTEDPROFILE("Microsoft.Network/trafficManagerProfiles/nestedEndpoints"); + NESTED_PROFILE("Microsoft.Network/trafficManagerProfiles/nestedEndpoints"); private String value; diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileMonitorStatus.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileMonitorStatus.java index bff04475bb63e..7d4163280255a 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileMonitorStatus.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/ProfileMonitorStatus.java @@ -22,7 +22,7 @@ public class ProfileMonitorStatus { public static final ProfileMonitorStatus DEGRADED = new ProfileMonitorStatus("Degraded"); /** Static value CheckingEndpoint for ProfileMonitorStatus. */ - public static final ProfileMonitorStatus CHECKINGENDPOINT = new ProfileMonitorStatus("CheckingEndpoint"); + public static final ProfileMonitorStatus CHECKING_ENDPOINT = new ProfileMonitorStatus("CheckingEndpoint"); private String value; diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java index 2972700d98219..5916f82ef94f2 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java @@ -31,9 +31,9 @@ public interface TrafficManagerEndpoint extends EndpointMonitorStatus monitorStatus(); /** - * @return true if the endpoint is disabled, false otherwise + * @return true if the endpoint is enabled, false otherwise */ - boolean isDisabled(); + boolean isEnabled(); /** * @return the weight of the endpoint which is used when traffic manager profile is configured with @@ -56,7 +56,7 @@ interface Definition extends DefinitionStages.Blank, DefinitionStages.WithEndpointType, DefinitionStages.WithEndpointThreshold, - DefinitionStages.WithSourceTrafficLocation, + DefinitionStages.WithSourceTrafficRegion, DefinitionStages.WithAttach { } @@ -80,7 +80,9 @@ interface Blank extends WithEndpointType { */ interface WithEndpointType { /** - * Specify that the endpoint is an Azure cloud service, web app or public ip. + * Specifies the resource ID of an Azure resource. + *

+ * supported Azure resources are cloud service, web app or public ip * * @param resourceId the Azure resource id * @return the next stage of the endpoint definition @@ -88,15 +90,15 @@ interface WithEndpointType { WithAttach withTargetAzureResourceId(String resourceId); /** - * Specify that the endpoint is an external endpoint that is not hosted in Azure. + * Specifies an external endpoint that is not hosted in Azure. * * @param externalFqdn the external FQDN * @return the next stage of the endpoint definition */ - WithSourceTrafficLocation withExternalFqdn(String externalFqdn); + WithSourceTrafficRegion withExternalFqdn(String externalFqdn); /** - * Specify that the endpoint is a nested traffic manager profile. + * Specifies a nested traffic manager profile for the endpoint. * * @param nestedProfile the nested traffic manager profile * @return the next stage of the endpoint definition @@ -112,12 +114,12 @@ interface WithEndpointType { */ interface WithEndpointThreshold { /** - * Specifies the child endpoint threshold. + * Specifies the minimum number of endpoints to be online for the nested profile to be considered healthy. * - * @param count the number of child endpoints to be online to consider nested profile as healthy + * @param count the number of endpoints * @return the next stage of the endpoint definition */ - WithSourceTrafficLocation withMinimumChildEndpoints(int count); + WithSourceTrafficRegion withMinimumChildEndpoints(int count); } /** @@ -126,7 +128,7 @@ interface WithEndpointThreshold { * * @param the return type of {@link WithAttach#attach()} */ - interface WithSourceTrafficLocation { + interface WithSourceTrafficRegion { /** * Specifies the location of the endpoint that will be used when the parent profile is configured with * Performance routing method {@link TrafficRoutingMethod#PERFORMANCE}. @@ -134,7 +136,7 @@ interface WithSourceTrafficLocation { * @param location the location * @return the next stage of the endpoint definition */ - WithAttach withSourceTrafficLocation(Region location); + WithAttach withSourceTrafficRegion(Region location); } /** @@ -176,7 +178,7 @@ interface WithRoutingPriority { */ interface WithTrafficDisabled { /** - * Specify that this endpoint should be excluded from receiving traffic. + * Specifies that this endpoint should be excluded from receiving traffic. * * @return the next stage of the endpoint definition */ @@ -206,7 +208,7 @@ interface UpdateDefinition extends UpdateDefinitionStages.Blank, UpdateDefinitionStages.WithEndpointType, UpdateDefinitionStages.WithEndpointThreshold, - UpdateDefinitionStages.WithSourceTrafficLocation, + UpdateDefinitionStages.WithSourceTrafficRegion, UpdateDefinitionStages.WithAttach { } @@ -230,7 +232,9 @@ interface Blank extends WithEndpointType { */ interface WithEndpointType { /** - * Specify that the endpoint is an Azure cloud service, web app or public ip. + * Specifies the resource ID of an Azure resource. + *

+ * supported Azure resources are cloud service, web app or public ip * * @param resourceId the Azure resource id * @return the next stage of the definition @@ -238,15 +242,15 @@ interface WithEndpointType { WithAttach withTargetAzureResourceId(String resourceId); /** - * Specify that the endpoint is an external endpoint that is not hosted in Azure. + * SSpecifies an external endpoint that is not hosted in Azure. * * @param externalFqdn the external FQDN * @return the next stage of the definition */ - WithSourceTrafficLocation withExternalFqdn(String externalFqdn); + WithSourceTrafficRegion withExternalFqdn(String externalFqdn); /** - * Specify that the endpoint is a nested traffic manager profile. + * Specifies a nested traffic manager profile for the endpoint. * * @param nestedProfile the nested traffic manager profile * @return the next stage of the definition @@ -262,12 +266,12 @@ interface WithEndpointType { */ interface WithEndpointThreshold { /** - * Specifies the child endpoint threshold. + * Specifies the minimum number of endpoints to be online for the nested profile to be considered healthy. * - * @param count the number of child endpoints to be online to consider nested profile as healthy + * @param count the number of endpoints * @return the next stage of the definition */ - WithSourceTrafficLocation withMinimumChildEndpoints(int count); + WithSourceTrafficRegion withMinimumChildEndpoints(int count); } /** @@ -276,15 +280,15 @@ interface WithEndpointThreshold { * * @param the return type of {@link WithAttach#attach()} */ - interface WithSourceTrafficLocation { + interface WithSourceTrafficRegion { /** - * Specifies the location of the endpoint that will be used when the parent profile is configured with - * Performance routing method {@link TrafficRoutingMethod#PERFORMANCE}. + * Specifies the region of the endpoint that will be used when the performance-based routing method + * {@link TrafficRoutingMethod#PERFORMANCE} is enabled on the profile. * * @param location the location * @return the next stage of the definition */ - WithAttach withSourceTrafficLocation(Region location); + WithAttach withSourceTrafficRegion(Region location); } /** @@ -294,8 +298,8 @@ interface WithSourceTrafficLocation { */ interface WithRoutingWeight { /** - * Specifies the weight for the endpoint that will be used when the parent profile is configured with - * Weighted routing method {@link TrafficRoutingMethod#WEIGHTED}. + * Specifies the weight for the endpoint that will be used when the weight-based routing method + * {@link TrafficRoutingMethod#WEIGHTED} is enabled on the profile. * * @param weight the endpoint weight * @return the next stage of the definition @@ -310,8 +314,8 @@ interface WithRoutingWeight { */ interface WithRoutingPriority { /** - * Specifies the weight for the endpoint that will be used when the parent profile is configured with - * Priority routing method {@link TrafficRoutingMethod#PRIORITY}. + * Specifies the weight for the endpoint that will be used when priority-based routing method + * is {@link TrafficRoutingMethod#PRIORITY} enabled on the profile. * * @param priority * @return the next stage of the definition @@ -326,7 +330,7 @@ interface WithRoutingPriority { */ interface WithTrafficDisabled { /** - * Specify that this endpoint should be excluded from receiving traffic. + * Specifies that this endpoint should be excluded from receiving traffic. * * @return the next stage of the definition */ @@ -360,7 +364,7 @@ interface UpdateAzureEndpoint extends */ interface UpdateExternalEndpoint extends UpdateStages.WithExternalFqdn, - UpdateStages.WithSourceTrafficLocation, + UpdateStages.WithSourceTrafficRegion, Update { } @@ -369,7 +373,7 @@ interface UpdateExternalEndpoint extends */ interface UpdateNestedProfileEndpoint extends UpdateStages.WithNestedProfileConfig, - UpdateStages.WithSourceTrafficLocation, + UpdateStages.WithSourceTrafficRegion, Update { } @@ -392,7 +396,9 @@ interface UpdateStages { */ interface WithTargetAzureResourceId { /** - * Specify the resource id of target Azure cloud service, web app or public ip. + * Specifies the resource ID of an Azure resource. + *

+ * supported Azure resources are cloud service, web app or public ip * * @param resourceId the Azure resource id * @return the next stage of the endpoint update @@ -405,7 +411,7 @@ interface WithTargetAzureResourceId { */ interface WithExternalFqdn { /** - * Specify the FQDN of an external endpoint that is not hosted in Azure. + * Specifies the FQDN of an external endpoint that is not hosted in Azure. * * @param externalFqdn the external FQDN * @return the next stage of the endpoint update @@ -419,7 +425,7 @@ interface WithExternalFqdn { */ interface WithNestedProfileConfig { /** - * Specify the traffic manager profile to be used as nested profile. + * Specifies a nested traffic manager profile for the endpoint. * * @param nestedProfile the nested traffic manager profile * @return the next stage of the update @@ -427,9 +433,9 @@ interface WithNestedProfileConfig { UpdateNestedProfileEndpoint withNestedProfile(TrafficManagerProfile nestedProfile); /** - * Specifies the child endpoint threshold. + * Specifies the minimum number of endpoints to be online for the nested profile to be considered healthy. * - * @param count the number of child endpoints to be online to consider nested profile as healthy + * @param count number of endpoints * @return the next stage of the endpoint update */ UpdateNestedProfileEndpoint withMinimumChildEndpoints(int count); @@ -439,15 +445,15 @@ interface WithNestedProfileConfig { * The stage of the traffic manager endpoint update allowing to specify the location of the external * or nested profile endpoints. */ - interface WithSourceTrafficLocation { + interface WithSourceTrafficRegion { /** - * Specifies the location of the endpoint that will be used when the parent profile is configured with - * Performance routing method {@link TrafficRoutingMethod#PERFORMANCE}. + * Specifies the region of the endpoint that will be used when the performance-based routing method + * {@link TrafficRoutingMethod#PERFORMANCE} is enabled on the profile. * * @param location the location * @return the next stage of the endpoint update */ - Update withSourceTrafficLocation(Region location); + Update withSourceTrafficRegion(Region location); } /** @@ -455,8 +461,8 @@ interface WithSourceTrafficLocation { */ interface WithRoutingWeight { /** - * Specifies the weight for the endpoint that will be used when the parent profile is configured with - * Weighted routing method {@link TrafficRoutingMethod#WEIGHTED}. + * Specifies the weight for the endpoint that will be used when the weight-based routing method + * {@link TrafficRoutingMethod#WEIGHTED} is enabled on the profile. * * @param weight the endpoint weight * @return the next stage of the update @@ -469,8 +475,8 @@ interface WithRoutingWeight { */ interface WithRoutingPriority { /** - * Specifies the weight for the endpoint that will be used when the parent profile is configured with - * Priority routing method {@link TrafficRoutingMethod#PRIORITY}. + * Specifies the weight for the endpoint that will be used when priority-based routing method + * is {@link TrafficRoutingMethod#PRIORITY} enabled on the profile. * * @param priority the endpoint priority * @return the next stage of the update @@ -483,14 +489,14 @@ interface WithRoutingPriority { */ interface WithTrafficDisabledOrEnabled { /** - * Specify that the endpoint should be excluded from receiving traffic. + * Specifies that the endpoint should be excluded from receiving traffic. * * @return the next stage of the update */ Update withTrafficDisabled(); /** - * Specify that the endpoint should receive the traffic. + * Specifies that the endpoint should receive the traffic. * * @return the next stage of the update */ diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerNestedProfileEndpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerNestedProfileEndpoint.java index 6e1a2e173abf5..9701c66d7ebce 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerNestedProfileEndpoint.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerNestedProfileEndpoint.java @@ -19,7 +19,7 @@ public interface TrafficManagerNestedProfileEndpoint extends TrafficManagerEndpo /** * @return the number of child endpoints to be online to consider nested profile as healthy */ - int minChildEndpoints(); + int minimumChildEndpointCount(); /** * @return the location of the traffic that the endpoint handles diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java index 9e175c1e2e57e..3e96b67c43c43 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java @@ -37,14 +37,14 @@ public interface TrafficManagerProfile extends String fqdn(); /** - * @return the DNS Ttime-To-Live (TTL), in seconds + * @return the DNS Time-To-Live (TTL), in seconds */ - int ttl(); + int timeToLive(); /** - * @return true if the traffic manager profile is disabled, false if enabled + * @return true if the traffic manager profile is enabled, false if enabled */ - boolean isDisabled(); + boolean isEnabled(); /** * @return the routing method used to route traffic to traffic manager profile endpoints @@ -223,7 +223,7 @@ interface WithTtl { * @param ttlInSeconds DNS TTL in seconds * @return the next stage of the traffic manager profile definition */ - WithCreate withTtl(int ttlInSeconds); + WithCreate withTimeToLive(int ttlInSeconds); } /** @@ -393,7 +393,7 @@ interface WithTtl { * @param ttlInSeconds DNS TTL in seconds * @return the next stage of the traffic manager profile update */ - Update withTtl(int ttlInSeconds); + Update withTimeToLive(int ttlInSeconds); } /** diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java index efcf36d280e59..15c4673d79e4f 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java @@ -55,8 +55,8 @@ public EndpointMonitorStatus monitorStatus() { } @Override - public boolean isDisabled() { - return this.inner().endpointStatus().equalsIgnoreCase(this.endpointStatusDisabled); + public boolean isEnabled() { + return this.inner().endpointStatus().equalsIgnoreCase(this.endpointStatusEnabled); } @Override @@ -91,12 +91,12 @@ public TrafficManagerEndpointImpl withExternalFqdn(String externalFqdn) { @Override public TrafficManagerEndpointImpl withNestedProfile(TrafficManagerProfile nestedProfile) { - this.inner().withType(EndpointType.NESTEDPROFILE.toString()); + this.inner().withType(EndpointType.NESTED_PROFILE.toString()); this.inner().withTargetResourceId(nestedProfile.id()); return this; } - public TrafficManagerEndpointImpl withSourceTrafficLocation(Region location) { + public TrafficManagerEndpointImpl withSourceTrafficRegion(Region location) { this.inner().withEndpointLocation(location.toString()); return this; } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java index 8b50a9ec7d5c2..7a02986c8d3d5 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java @@ -45,7 +45,7 @@ class TrafficManagerEndpointsImpl extends /** * @return the azure endpoints as a map indexed by name. */ - public Map azureEndpointsAsMap() { + Map azureEndpointsAsMap() { Map result = new HashMap<>(); for (Map.Entry entry : this.collection().entrySet()) { TrafficManagerEndpointImpl endpoint = entry.getValue(); @@ -63,7 +63,7 @@ public Map azureEndpointsAsMap() { /** * @return the external endpoints as a map indexed by name. */ - public Map externalEndpointsAsMap() { + Map externalEndpointsAsMap() { Map result = new HashMap<>(); for (Map.Entry entry : this.collection().entrySet()) { TrafficManagerEndpointImpl endpoint = entry.getValue(); @@ -81,11 +81,11 @@ public Map externalEndpointsAsMap() { /** * @return the nested profile endpoints as a map indexed by name. */ - public Map nestedProfileEndpointsAsMap() { + Map nestedProfileEndpointsAsMap() { Map result = new HashMap<>(); for (Map.Entry entry : this.collection().entrySet()) { TrafficManagerEndpointImpl endpoint = entry.getValue(); - if (endpoint.endpointType() == EndpointType.NESTEDPROFILE) { + if (endpoint.endpointType() == EndpointType.NESTED_PROFILE) { TrafficManagerNestedProfileEndpoint nestedProfileEndpoint = new TrafficManagerNestedProfileEndpointImpl(entry.getKey(), this.parent(), endpoint.inner(), @@ -142,7 +142,7 @@ public TrafficManagerEndpointImpl updateExternalEndpoint(String name) { */ public TrafficManagerEndpointImpl updateNestedProfileEndpoint(String name) { TrafficManagerEndpointImpl endpoint = this.prepareUpdate(name); - if (endpoint.endpointType() != EndpointType.NESTEDPROFILE) { + if (endpoint.endpointType() != EndpointType.NESTED_PROFILE) { throw new IllegalArgumentException("A nested profile endpoint with name " + name + " not found in the profile"); } return endpoint; diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNestedProfileEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNestedProfileEndpointImpl.java index 54a446f6decee..e959fb8c7f303 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNestedProfileEndpointImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerNestedProfileEndpointImpl.java @@ -26,7 +26,7 @@ public String nestedProfileId() { } @Override - public int minChildEndpoints() { + public int minimumChildEndpointCount() { if (inner().minChildEndpoints() == null) { return 0; } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java index 390fec2a75aeb..3a1f68a78b4ad 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java @@ -59,13 +59,13 @@ public String fqdn() { } @Override - public int ttl() { + public int timeToLive() { return this.inner().dnsConfig().ttl().intValue(); } @Override - public boolean isDisabled() { - return this.inner().profileStatus().equalsIgnoreCase(this.profileStatusDisabled); + public boolean isEnabled() { + return this.inner().profileStatus().equalsIgnoreCase(this.profileStatusEnabled); } @Override @@ -210,7 +210,7 @@ public TrafficManagerProfileImpl withProfileStatusEnabled() { } @Override - public TrafficManagerProfileImpl withTtl(int ttlInSeconds) { + public TrafficManagerProfileImpl withTimeToLive(int ttlInSeconds) { this.inner().dnsConfig().withTtl(new Long(ttlInSeconds)); return this; } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java index 3959e3d887e58..4e7c32c6b6fe6 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java @@ -94,7 +94,7 @@ private TrafficManagerProfileImpl setDefaults(TrafficManagerProfileImpl profile) profile.inner().withMonitorConfig(new MonitorConfig()); // DnsConfig is required profile.inner().withDnsConfig(new DnsConfig()); - profile.withTtl(300); + profile.withTimeToLive(300); // TM location must be 'global' irrespective of region of the resource group it resides. profile.inner().withLocation("global"); // Endpoints are external child resource still initializing it avoid null checks in the model impl. diff --git a/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java b/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java index a6143b7989e53..955478550c4c4 100644 --- a/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java +++ b/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java @@ -67,12 +67,12 @@ public TrafficManagerProfile createResource(TrafficManagerProfiles profiles) thr .withHttpsMonitoring() .defineEndpoint("external-ep-1") .withExternalFqdn("www.gitbook.com") - .withSourceTrafficLocation(Region.INDIA_CENTRAL) + .withSourceTrafficRegion(Region.INDIA_CENTRAL) .attach() - .withTtl(500) + .withTimeToLive(500) .create(); - Assert.assertFalse(nestedProfile.isDisabled()); + Assert.assertTrue(nestedProfile.isEnabled()); Assert.assertNotNull(nestedProfile.monitorStatus()); Assert.assertEquals(nestedProfile.monitoringPort(), 443); Assert.assertEquals(nestedProfile.monitoringPath(), "/"); @@ -80,7 +80,7 @@ public TrafficManagerProfile createResource(TrafficManagerProfiles profiles) thr Assert.assertEquals(nestedProfile.nestedProfileEndpoints().size(), 0); Assert.assertEquals(nestedProfile.externalEndpoints().size(), 1); Assert.assertEquals(nestedProfile.fqdn(), nestedTmProfileDnsLabel + ".trafficmanager.net"); - Assert.assertEquals(nestedProfile.ttl(), 500); + Assert.assertEquals(nestedProfile.timeToLive(), 500); // Creates a public ip to be used as an Azure endpoint // @@ -100,13 +100,13 @@ public TrafficManagerProfile createResource(TrafficManagerProfiles profiles) thr .withHttpMonitoring() .defineEndpoint(externalEndpointName21) .withExternalFqdn(externalFqdn21) - .withSourceTrafficLocation(Region.US_EAST) + .withSourceTrafficRegion(Region.US_EAST) .withRoutingPriority(1) .withRoutingWeight(1) .attach() .defineEndpoint(externalEndpointName22) .withExternalFqdn(externalFqdn22) - .withSourceTrafficLocation(Region.US_EAST2) + .withSourceTrafficRegion(Region.US_EAST2) .withRoutingPriority(2) .withRoutingWeight(1) .withTrafficDisabled() @@ -118,12 +118,12 @@ public TrafficManagerProfile createResource(TrafficManagerProfiles profiles) thr .defineEndpoint(nestedProfileEndpointName) .withNestedProfile(nestedProfile) .withMinimumChildEndpoints(1) - .withSourceTrafficLocation(Region.INDIA_CENTRAL) + .withSourceTrafficRegion(Region.INDIA_CENTRAL) .withRoutingPriority(4) .attach() .create(); - Assert.assertFalse(profile.isDisabled()); + Assert.assertTrue(profile.isEnabled()); Assert.assertNotNull(profile.monitorStatus()); Assert.assertEquals(profile.monitoringPort(), 80); Assert.assertEquals(profile.monitoringPath(), "/"); @@ -131,7 +131,7 @@ public TrafficManagerProfile createResource(TrafficManagerProfiles profiles) thr Assert.assertEquals(profile.nestedProfileEndpoints().size(), 1); Assert.assertEquals(profile.externalEndpoints().size(), 2); Assert.assertEquals(profile.fqdn(), tmProfileDnsLabel + ".trafficmanager.net"); - Assert.assertEquals(profile.ttl(), 300); // Default + Assert.assertEquals(profile.timeToLive(), 300); // Default profile = profile.refresh(); Assert.assertEquals(profile.azureEndpoints().size(), 1); @@ -172,11 +172,11 @@ public TrafficManagerProfile createResource(TrafficManagerProfiles profiles) thr c = 0; for (TrafficManagerNestedProfileEndpoint endpoint : profile.nestedProfileEndpoints().values()) { - Assert.assertEquals(endpoint.endpointType(), EndpointType.NESTEDPROFILE); + Assert.assertEquals(endpoint.endpointType(), EndpointType.NESTED_PROFILE); if (endpoint.name().equalsIgnoreCase(nestedProfileEndpointName)) { Assert.assertEquals(endpoint.routingPriority(), 4); Assert.assertNotNull(endpoint.monitorStatus()); - Assert.assertEquals(endpoint.minChildEndpoints(), 1); + Assert.assertEquals(endpoint.minimumChildEndpointCount(), 1); Assert.assertEquals(endpoint.nestedProfileId(), nestedProfile.id()); Assert.assertEquals(endpoint.sourceTrafficLocation(), Region.INDIA_CENTRAL); c++; @@ -191,7 +191,7 @@ public TrafficManagerProfile updateResource(TrafficManagerProfile profile) throw // Remove an endpoint, update two endpoints and add new one // profile.update() - .withTtl(600) + .withTimeToLive(600) .withHttpMonitoring(8080, "/") .withPerformanceBasedRouting() .withoutEndpoint(externalEndpointName21) @@ -204,7 +204,7 @@ public TrafficManagerProfile updateResource(TrafficManagerProfile profile) throw .parent() .defineEndpoint(externalEndpointName23) .withExternalFqdn(externalFqdn23) - .withSourceTrafficLocation(Region.US_CENTRAL) + .withSourceTrafficRegion(Region.US_CENTRAL) .withRoutingPriority(6) .attach() .apply(); @@ -214,7 +214,7 @@ public TrafficManagerProfile updateResource(TrafficManagerProfile profile) throw Assert.assertEquals(profile.azureEndpoints().size(), 1); Assert.assertEquals(profile.nestedProfileEndpoints().size(), 1); Assert.assertEquals(profile.externalEndpoints().size(), 2); - Assert.assertEquals(profile.ttl(), 600); + Assert.assertEquals(profile.timeToLive(), 600); int c = 0; for (TrafficManagerExternalEndpoint endpoint : profile.externalEndpoints().values()) { @@ -261,8 +261,8 @@ public void print(TrafficManagerProfile profile) { .append("\n\tTags: ").append(profile.tags()) .append("\n\tDNSLabel: ").append(profile.dnsLabel()) .append("\n\tFQDN: ").append(profile.fqdn()) - .append("\n\tTTL: ").append(profile.ttl()) - .append("\n\tDisabled: ").append(profile.isDisabled()) + .append("\n\tTTL: ").append(profile.timeToLive()) + .append("\n\tEnabled: ").append(profile.isEnabled()) .append("\n\tRoutingMethod: ").append(profile.trafficRoutingMethod()) .append("\n\tMonitor status: ").append(profile.monitorStatus()) .append("\n\tMonitoring port: ").append(profile.monitoringPort()) @@ -279,7 +279,7 @@ public void print(TrafficManagerProfile profile) { .append("\n\t\t\tTarget resourceId: ").append(endpoint.targetAzureResourceId()) .append("\n\t\t\tTarget resourceType: ").append(endpoint.targetResourceType()) .append("\n\t\t\tMonitor status: ").append(endpoint.monitorStatus()) - .append("\n\t\t\tDisabled: ").append(endpoint.isDisabled()) + .append("\n\t\t\tEnabled: ").append(endpoint.isEnabled()) .append("\n\t\t\tRouting priority: ").append(endpoint.routingPriority()) .append("\n\t\t\tRouting weight: ").append(endpoint.routingWeight()); } @@ -296,7 +296,7 @@ public void print(TrafficManagerProfile profile) { .append("\n\t\t\tFQDN: ").append(endpoint.fqdn()) .append("\n\t\t\tSource Traffic Location: ").append(endpoint.sourceTrafficLocation()) .append("\n\t\t\tMonitor status: ").append(endpoint.monitorStatus()) - .append("\n\t\t\tDisabled: ").append(endpoint.isDisabled()) + .append("\n\t\t\tEnabled: ").append(endpoint.isEnabled()) .append("\n\t\t\tRouting priority: ").append(endpoint.routingPriority()) .append("\n\t\t\tRouting weight: ").append(endpoint.routingWeight()); } @@ -311,10 +311,10 @@ public void print(TrafficManagerProfile profile) { .append("\n\t\t\tId: ").append(endpoint.id()) .append("\n\t\t\tType: ").append(endpoint.endpointType()) .append("\n\t\t\tNested profileId: ").append(endpoint.nestedProfileId()) - .append("\n\t\t\tMinimum child threshold: ").append(endpoint.minChildEndpoints()) + .append("\n\t\t\tMinimum child threshold: ").append(endpoint.minimumChildEndpointCount()) .append("\n\t\t\tSource Traffic Location: ").append(endpoint.sourceTrafficLocation()) .append("\n\t\t\tMonitor status: ").append(endpoint.monitorStatus()) - .append("\n\t\t\tDisabled: ").append(endpoint.isDisabled()) + .append("\n\t\t\tEnabled: ").append(endpoint.isEnabled()) .append("\n\t\t\tRouting priority: ").append(endpoint.routingPriority()) .append("\n\t\t\tRouting weight: ").append(endpoint.routingWeight()); } From 5422cc7542687d01ae7be199cf2def824ce68dd9 Mon Sep 17 00:00:00 2001 From: anuchan Date: Mon, 17 Oct 2016 14:45:26 -0700 Subject: [PATCH 10/12] (1). Making monitoring config optional [default http] (2). rename withDnsLabel to withLeafDomainLabel (3). use with[Azure|External|Nested]Endpoint in the defineEndpoint chain --- .../TrafficManagerEndpoint.java | 22 ++++---- .../trafficmanager/TrafficManagerProfile.java | 54 ++++++++++--------- .../TrafficManagerEndpointImpl.java | 21 ++++++-- .../TrafficManagerProfileImpl.java | 2 +- .../TrafficManagerProfilesImpl.java | 1 + .../azure/management/TestTrafficManager.java | 20 +++---- 6 files changed, 69 insertions(+), 51 deletions(-) diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java index 5916f82ef94f2..9aeb6dd43d86e 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java @@ -87,7 +87,7 @@ interface WithEndpointType { * @param resourceId the Azure resource id * @return the next stage of the endpoint definition */ - WithAttach withTargetAzureResourceId(String resourceId); + WithAttach withAzureEndpoint(String resourceId); /** * Specifies an external endpoint that is not hosted in Azure. @@ -95,7 +95,7 @@ interface WithEndpointType { * @param externalFqdn the external FQDN * @return the next stage of the endpoint definition */ - WithSourceTrafficRegion withExternalFqdn(String externalFqdn); + WithSourceTrafficRegion withExternalEndpoint(String externalFqdn); /** * Specifies a nested traffic manager profile for the endpoint. @@ -103,7 +103,7 @@ interface WithEndpointType { * @param nestedProfile the nested traffic manager profile * @return the next stage of the endpoint definition */ - WithEndpointThreshold withNestedProfile(TrafficManagerProfile nestedProfile); + WithEndpointThreshold withNestedEndpoint(TrafficManagerProfile nestedProfile); } /** @@ -239,7 +239,7 @@ interface WithEndpointType { * @param resourceId the Azure resource id * @return the next stage of the definition */ - WithAttach withTargetAzureResourceId(String resourceId); + WithAttach withAzureEndpoint(String resourceId); /** * SSpecifies an external endpoint that is not hosted in Azure. @@ -247,7 +247,7 @@ interface WithEndpointType { * @param externalFqdn the external FQDN * @return the next stage of the definition */ - WithSourceTrafficRegion withExternalFqdn(String externalFqdn); + WithSourceTrafficRegion withExternalEndpoint(String externalFqdn); /** * Specifies a nested traffic manager profile for the endpoint. @@ -255,7 +255,7 @@ interface WithEndpointType { * @param nestedProfile the nested traffic manager profile * @return the next stage of the definition */ - WithEndpointThreshold withNestedProfile(TrafficManagerProfile nestedProfile); + WithEndpointThreshold withNestedEndpoint(TrafficManagerProfile nestedProfile); } /** @@ -355,7 +355,7 @@ interface WithAttach extends * The entirety of an Azure endpoint update as a part of parent traffic manager profile profile update. */ interface UpdateAzureEndpoint extends - UpdateStages.WithTargetAzureResourceId, + UpdateStages.WithAzureResource, Update { } @@ -394,7 +394,7 @@ interface UpdateStages { /** * The stage of an Azure endpoint update allowing to specify the target Azure resource. */ - interface WithTargetAzureResourceId { + interface WithAzureResource { /** * Specifies the resource ID of an Azure resource. *

@@ -403,7 +403,7 @@ interface WithTargetAzureResourceId { * @param resourceId the Azure resource id * @return the next stage of the endpoint update */ - Update withTargetAzureResourceId(String resourceId); + Update withAzureResource(String resourceId); } /** @@ -416,7 +416,7 @@ interface WithExternalFqdn { * @param externalFqdn the external FQDN * @return the next stage of the endpoint update */ - UpdateExternalEndpoint withExternalFqdn(String externalFqdn); + UpdateExternalEndpoint withFqdn(String externalFqdn); } /** @@ -430,7 +430,7 @@ interface WithNestedProfileConfig { * @param nestedProfile the nested traffic manager profile * @return the next stage of the update */ - UpdateNestedProfileEndpoint withNestedProfile(TrafficManagerProfile nestedProfile); + UpdateNestedProfileEndpoint withProfile(TrafficManagerProfile nestedProfile); /** * Specifies the minimum number of endpoints to be online for the nested profile to be considered healthy. diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java index 3e96b67c43c43..d6d11124270a4 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java @@ -90,9 +90,8 @@ public interface TrafficManagerProfile extends */ interface Definition extends DefinitionStages.Blank, - DefinitionStages.WithDnsLabel, + DefinitionStages.WithLeafDomainLabel, DefinitionStages.WithTrafficRoutingMethod, - DefinitionStages.WithMonitoringConfiguration, DefinitionStages.WithCreate { } @@ -103,21 +102,23 @@ interface DefinitionStages { /** * The stage of the traffic manager profile definition allowing to specify the resource group. */ - interface Blank extends GroupableResource.DefinitionStages.WithGroupAndRegion { + interface Blank extends GroupableResource.DefinitionStages.WithGroupAndRegion { } /** * The stage of the traffic manager profile definition allowing to specify the relative DNS name. */ - interface WithDnsLabel { + interface WithLeafDomainLabel { /** * Specify the relative DNS name of the profile. *

+ * The fully qualified domain name (FQDN) + * will be constructed automatically by appending the rest of the domain to this label. * * @param dnsLabel the relative DNS name of the profile * @return the next stage of the traffic manager profile definition */ - WithTrafficRoutingMethod withDnsLabel(String dnsLabel); + WithTrafficRoutingMethod withLeafDomainLabel(String dnsLabel); } /** @@ -132,7 +133,7 @@ interface WithTrafficRoutingMethod { * * @return the next stage of the traffic manager profile definition */ - WithMonitoringConfiguration withPriorityBasedRouting(); + WithEndpoint withPriorityBasedRouting(); /** * Specify that end user traffic should be distributed to the endpoints based on the weight assigned @@ -140,7 +141,7 @@ interface WithTrafficRoutingMethod { * * @return the next stage of the traffic manager profile definition */ - WithMonitoringConfiguration withWeightBasedRouting(); + WithEndpoint withWeightBasedRouting(); /** * Specify that end user traffic should be routed based on the geographic location of the endpoint @@ -148,7 +149,7 @@ interface WithTrafficRoutingMethod { * * @return the next stage of the traffic manager profile definition */ - WithMonitoringConfiguration withPerformanceBasedRouting(); + WithEndpoint withPerformanceBasedRouting(); /** * Specify the traffic routing method for the profile. @@ -156,7 +157,20 @@ interface WithTrafficRoutingMethod { * @param routingMethod the traffic routing method for the profile * @return the next stage of the traffic manager profile definition */ - WithMonitoringConfiguration withTrafficRoutingMethod(TrafficRoutingMethod routingMethod); + WithEndpoint withTrafficRoutingMethod(TrafficRoutingMethod routingMethod); + } + + /** + * The stage of the traffic manager profile definition allowing to specify endpoint. + */ + interface WithEndpoint { + /** + * Specifies definition of an endpoint to be attached to the traffic manager profile. + * + * @param name the name for the endpoint + * @return the stage representing configuration for the endpoint + */ + TrafficManagerEndpoint.DefinitionStages.Blank defineEndpoint(String name); } /** @@ -169,7 +183,7 @@ interface WithMonitoringConfiguration { * * @return the next stage of the traffic manager profile definition */ - WithEndpoint withHttpMonitoring(); + WithCreate withHttpMonitoring(); /** * Specify to use HTTPS monitoring for the endpoints that checks for HTTPS 200 response from the path '/' @@ -177,7 +191,7 @@ interface WithMonitoringConfiguration { * * @return the next stage of the traffic manager profile definition */ - WithEndpoint withHttpsMonitoring(); + WithCreate withHttpsMonitoring(); /** * Specify the HTTP monitoring for the endpoints that checks for HTTP 200 response from the specified @@ -187,7 +201,7 @@ interface WithMonitoringConfiguration { * @param path the monitoring path * @return the next stage of the traffic manager profile definition */ - WithEndpoint withHttpMonitoring(int port, String path); + WithCreate withHttpMonitoring(int port, String path); /** * Specify the HTTPS monitoring for the endpoints that checks for HTTPS 200 response from the specified @@ -197,20 +211,7 @@ interface WithMonitoringConfiguration { * @param path the monitoring path * @return the next stage of the traffic manager profile definition */ - WithEndpoint withHttpsMonitoring(int port, String path); - } - - /** - * The stage of the traffic manager profile definition allowing to specify endpoint. - */ - interface WithEndpoint { - /** - * Specifies definition of an endpoint to be attached to the traffic manager profile. - * - * @param name the name for the endpoint - * @return the stage representing configuration for the endpoint - */ - TrafficManagerEndpoint.DefinitionStages.Blank defineEndpoint(String name); + WithCreate withHttpsMonitoring(int port, String path); } /** @@ -247,6 +248,7 @@ interface WithProfileStatus { interface WithCreate extends Creatable, Resource.DefinitionWithTags, + DefinitionStages.WithMonitoringConfiguration, DefinitionStages.WithTtl, DefinitionStages.WithProfileStatus, DefinitionStages.WithEndpoint { diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java index 15c4673d79e4f..4873cef9f1020 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java @@ -76,21 +76,36 @@ public TrafficManagerEndpointImpl withMinimumChildEndpoints(int count) { } @Override - public TrafficManagerEndpointImpl withTargetAzureResourceId(String resourceId) { + public TrafficManagerEndpointImpl withAzureResource(String resourceId) { + return this.withAzureEndpoint(resourceId); + } + + @Override + public TrafficManagerEndpointImpl withFqdn(String externalFqdn) { + return this.withExternalEndpoint(externalFqdn); + } + + @Override + public TrafficManagerEndpointImpl withProfile(TrafficManagerProfile nestedProfile) { + return this.withNestedEndpoint(nestedProfile); + } + + @Override + public TrafficManagerEndpointImpl withAzureEndpoint(String resourceId) { this.inner().withType(EndpointType.AZURE.toString()); this.inner().withTargetResourceId(resourceId); return this; } @Override - public TrafficManagerEndpointImpl withExternalFqdn(String externalFqdn) { + public TrafficManagerEndpointImpl withExternalEndpoint(String externalFqdn) { this.inner().withType(EndpointType.EXTERNAL.toString()); this.inner().withTarget(externalFqdn); return this; } @Override - public TrafficManagerEndpointImpl withNestedProfile(TrafficManagerProfile nestedProfile) { + public TrafficManagerEndpointImpl withNestedEndpoint(TrafficManagerProfile nestedProfile) { this.inner().withType(EndpointType.NESTED_PROFILE.toString()); this.inner().withTargetResourceId(nestedProfile.id()); return this; diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java index 3a1f68a78b4ad..48db6fc804123 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java @@ -114,7 +114,7 @@ public TrafficManagerProfile refresh() { } @Override - public TrafficManagerProfileImpl withDnsLabel(String dnsLabel) { + public TrafficManagerProfileImpl withLeafDomainLabel(String dnsLabel) { this.inner().dnsConfig().withRelativeName(dnsLabel); return this; } diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java index 4e7c32c6b6fe6..4bf38a5ff63a2 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfilesImpl.java @@ -92,6 +92,7 @@ public TrafficManagerProfileImpl define(String name) { private TrafficManagerProfileImpl setDefaults(TrafficManagerProfileImpl profile) { // MonitorConfig is required profile.inner().withMonitorConfig(new MonitorConfig()); + profile.withHttpMonitoring(); // Default to Http monitoring // DnsConfig is required profile.inner().withDnsConfig(new DnsConfig()); profile.withTimeToLive(300); diff --git a/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java b/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java index 955478550c4c4..34b74715570f7 100644 --- a/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java +++ b/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java @@ -62,13 +62,13 @@ public TrafficManagerProfile createResource(TrafficManagerProfiles profiles) thr // TrafficManagerProfile nestedProfile = profiles.define(nestedTmProfileName) .withNewResourceGroup(rgCreatable) - .withDnsLabel(nestedTmProfileDnsLabel) + .withLeafDomainLabel(nestedTmProfileDnsLabel) .withPriorityBasedRouting() - .withHttpsMonitoring() .defineEndpoint("external-ep-1") - .withExternalFqdn("www.gitbook.com") + .withExternalEndpoint("www.gitbook.com") .withSourceTrafficRegion(Region.INDIA_CENTRAL) .attach() + .withHttpsMonitoring() .withTimeToLive(500) .create(); @@ -95,32 +95,32 @@ public TrafficManagerProfile createResource(TrafficManagerProfiles profiles) thr // TrafficManagerProfile profile = profiles.define(tmProfileName) .withNewResourceGroup(rgCreatable) - .withDnsLabel(tmProfileDnsLabel) + .withLeafDomainLabel(tmProfileDnsLabel) .withWeightBasedRouting() - .withHttpMonitoring() .defineEndpoint(externalEndpointName21) - .withExternalFqdn(externalFqdn21) + .withExternalEndpoint(externalFqdn21) .withSourceTrafficRegion(Region.US_EAST) .withRoutingPriority(1) .withRoutingWeight(1) .attach() .defineEndpoint(externalEndpointName22) - .withExternalFqdn(externalFqdn22) + .withExternalEndpoint(externalFqdn22) .withSourceTrafficRegion(Region.US_EAST2) .withRoutingPriority(2) .withRoutingWeight(1) .withTrafficDisabled() .attach() .defineEndpoint(azureEndpointName) - .withTargetAzureResourceId(publicIpAddress.id()) + .withAzureEndpoint(publicIpAddress.id()) .withRoutingPriority(3) .attach() .defineEndpoint(nestedProfileEndpointName) - .withNestedProfile(nestedProfile) + .withNestedEndpoint(nestedProfile) .withMinimumChildEndpoints(1) .withSourceTrafficRegion(Region.INDIA_CENTRAL) .withRoutingPriority(4) .attach() + .withHttpMonitoring() .create(); Assert.assertTrue(profile.isEnabled()); @@ -203,7 +203,7 @@ public TrafficManagerProfile updateResource(TrafficManagerProfile profile) throw .withTrafficDisabled() .parent() .defineEndpoint(externalEndpointName23) - .withExternalFqdn(externalFqdn23) + .withExternalEndpoint(externalFqdn23) .withSourceTrafficRegion(Region.US_CENTRAL) .withRoutingPriority(6) .attach() From caa3569c0451b9e232bb2a3852de7d1221dee2be Mon Sep 17 00:00:00 2001 From: anuchan Date: Mon, 17 Oct 2016 15:56:34 -0700 Subject: [PATCH 11/12] making minimum child threshold optional for nested profile endpoint and defaulting to 1 --- .../TrafficManagerEndpoint.java | 44 +++++++++++++------ .../TrafficManagerEndpointImpl.java | 3 +- .../azure/management/TestTrafficManager.java | 10 ++--- 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java index 9aeb6dd43d86e..75ecd2aa02ffd 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java @@ -56,7 +56,8 @@ interface Definition extends DefinitionStages.Blank, DefinitionStages.WithEndpointType, DefinitionStages.WithEndpointThreshold, - DefinitionStages.WithSourceTrafficRegion, + DefinitionStages.WithEndpointRegion, + DefinitionStages.WithEndpointRegionThenThreshold, DefinitionStages.WithAttach { } @@ -95,7 +96,7 @@ interface WithEndpointType { * @param externalFqdn the external FQDN * @return the next stage of the endpoint definition */ - WithSourceTrafficRegion withExternalEndpoint(String externalFqdn); + WithEndpointRegion withExternalEndpoint(String externalFqdn); /** * Specifies a nested traffic manager profile for the endpoint. @@ -103,7 +104,24 @@ interface WithEndpointType { * @param nestedProfile the nested traffic manager profile * @return the next stage of the endpoint definition */ - WithEndpointThreshold withNestedEndpoint(TrafficManagerProfile nestedProfile); + WithEndpointRegionThenThreshold withNestedEndpoint(TrafficManagerProfile nestedProfile); + } + + /** + * The stage of the traffic manager endpoint definition allowing to specify the location of the external + * endpoint. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithEndpointRegion { + /** + * Specifies the location of the endpoint that will be used when the parent profile is configured with + * Performance routing method {@link TrafficRoutingMethod#PERFORMANCE}. + * + * @param location the location + * @return the next stage of the endpoint definition + */ + WithAttach withEndpointRegion(Region location); } /** @@ -112,23 +130,23 @@ interface WithEndpointType { * * @param the return type of {@link WithAttach#attach()} */ - interface WithEndpointThreshold { + interface WithEndpointThreshold extends WithAttach { /** * Specifies the minimum number of endpoints to be online for the nested profile to be considered healthy. * * @param count the number of endpoints * @return the next stage of the endpoint definition */ - WithSourceTrafficRegion withMinimumChildEndpoints(int count); + WithAttach withMinimumChildEndpoints(int count); } /** - * The stage of the traffic manager endpoint definition allowing to specify the location of the external - * or nested profile endpoints. + * The stage of the traffic manager endpoint definition allowing to specify the location of the nested profile + * endpoint. * * @param the return type of {@link WithAttach#attach()} */ - interface WithSourceTrafficRegion { + interface WithEndpointRegionThenThreshold { /** * Specifies the location of the endpoint that will be used when the parent profile is configured with * Performance routing method {@link TrafficRoutingMethod#PERFORMANCE}. @@ -136,7 +154,7 @@ interface WithSourceTrafficRegion { * @param location the location * @return the next stage of the endpoint definition */ - WithAttach withSourceTrafficRegion(Region location); + WithEndpointThreshold withEndpointRegion(Region location); } /** @@ -364,7 +382,7 @@ interface UpdateAzureEndpoint extends */ interface UpdateExternalEndpoint extends UpdateStages.WithExternalFqdn, - UpdateStages.WithSourceTrafficRegion, + UpdateStages.WithEndpointRegion, Update { } @@ -373,7 +391,7 @@ interface UpdateExternalEndpoint extends */ interface UpdateNestedProfileEndpoint extends UpdateStages.WithNestedProfileConfig, - UpdateStages.WithSourceTrafficRegion, + UpdateStages.WithEndpointRegion, Update { } @@ -445,7 +463,7 @@ interface WithNestedProfileConfig { * The stage of the traffic manager endpoint update allowing to specify the location of the external * or nested profile endpoints. */ - interface WithSourceTrafficRegion { + interface WithEndpointRegion { /** * Specifies the region of the endpoint that will be used when the performance-based routing method * {@link TrafficRoutingMethod#PERFORMANCE} is enabled on the profile. @@ -453,7 +471,7 @@ interface WithSourceTrafficRegion { * @param location the location * @return the next stage of the endpoint update */ - Update withSourceTrafficRegion(Region location); + Update withEndpointRegion(Region location); } /** diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java index 4873cef9f1020..408d7a4ab4f9d 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java @@ -108,10 +108,11 @@ public TrafficManagerEndpointImpl withExternalEndpoint(String externalFqdn) { public TrafficManagerEndpointImpl withNestedEndpoint(TrafficManagerProfile nestedProfile) { this.inner().withType(EndpointType.NESTED_PROFILE.toString()); this.inner().withTargetResourceId(nestedProfile.id()); + this.inner().withMinChildEndpoints(new Long(1)); return this; } - public TrafficManagerEndpointImpl withSourceTrafficRegion(Region location) { + public TrafficManagerEndpointImpl withEndpointRegion(Region location) { this.inner().withEndpointLocation(location.toString()); return this; } diff --git a/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java b/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java index 34b74715570f7..227f948c19e7c 100644 --- a/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java +++ b/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java @@ -66,7 +66,7 @@ public TrafficManagerProfile createResource(TrafficManagerProfiles profiles) thr .withPriorityBasedRouting() .defineEndpoint("external-ep-1") .withExternalEndpoint("www.gitbook.com") - .withSourceTrafficRegion(Region.INDIA_CENTRAL) + .withEndpointRegion(Region.INDIA_CENTRAL) .attach() .withHttpsMonitoring() .withTimeToLive(500) @@ -99,13 +99,13 @@ public TrafficManagerProfile createResource(TrafficManagerProfiles profiles) thr .withWeightBasedRouting() .defineEndpoint(externalEndpointName21) .withExternalEndpoint(externalFqdn21) - .withSourceTrafficRegion(Region.US_EAST) + .withEndpointRegion(Region.US_EAST) .withRoutingPriority(1) .withRoutingWeight(1) .attach() .defineEndpoint(externalEndpointName22) .withExternalEndpoint(externalFqdn22) - .withSourceTrafficRegion(Region.US_EAST2) + .withEndpointRegion(Region.US_EAST2) .withRoutingPriority(2) .withRoutingWeight(1) .withTrafficDisabled() @@ -113,11 +113,11 @@ public TrafficManagerProfile createResource(TrafficManagerProfiles profiles) thr .defineEndpoint(azureEndpointName) .withAzureEndpoint(publicIpAddress.id()) .withRoutingPriority(3) - .attach() + .attach() .defineEndpoint(nestedProfileEndpointName) .withNestedEndpoint(nestedProfile) + .withEndpointRegion(Region.INDIA_CENTRAL) .withMinimumChildEndpoints(1) - .withSourceTrafficRegion(Region.INDIA_CENTRAL) .withRoutingPriority(4) .attach() .withHttpMonitoring() From 723b4fe574a3b89bac9b0d8819fe9faa3d7c729d Mon Sep 17 00:00:00 2001 From: anuchan Date: Mon, 17 Oct 2016 18:12:52 -0700 Subject: [PATCH 12/12] Making endpoint defintion chain more user friendly based on discussion with Martin & Asir --- .../TrafficManagerEndpoint.java | 238 ++++++++++++------ .../trafficmanager/TrafficManagerProfile.java | 46 +++- .../TrafficManagerEndpointImpl.java | 38 +-- .../TrafficManagerEndpointsImpl.java | 32 ++- .../TrafficManagerProfileImpl.java | 20 +- .../azure/management/TestTrafficManager.java | 43 ++-- 6 files changed, 278 insertions(+), 139 deletions(-) diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java index 75ecd2aa02ffd..c6da223646d4d 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerEndpoint.java @@ -53,11 +53,14 @@ public interface TrafficManagerEndpoint extends * @param the return type of the final {@link Attachable#attach()} */ interface Definition extends - DefinitionStages.Blank, - DefinitionStages.WithEndpointType, + DefinitionStages.AzureTargetEndpointBlank, + DefinitionStages.ExternalTargetEndpointBlank, + DefinitionStages.NestedProfileTargetEndpointBlank, + DefinitionStages.WithAzureResource, + DefinitionStages.WithFqdn, + DefinitionStages.WithSourceTrafficRegion, + DefinitionStages.WithSourceTrafficRegionThenThreshold, DefinitionStages.WithEndpointThreshold, - DefinitionStages.WithEndpointRegion, - DefinitionStages.WithEndpointRegionThenThreshold, DefinitionStages.WithAttach { } @@ -67,44 +70,61 @@ interface Definition extends */ interface DefinitionStages { /** - * The first stage of a traffic manager profile endpoint definition. + * The first stage of a traffic manager profile Azure endpoint definition. * * @param the return type of {@link WithAttach#attach()} */ - interface Blank extends WithEndpointType { + interface AzureTargetEndpointBlank extends WithAzureResource { } /** - * The stage of the traffic manager profile endpoint definition allowing to specify the type. + * The first stage of a traffic manager profile external endpoint definition. * * @param the return type of {@link WithAttach#attach()} */ - interface WithEndpointType { + interface ExternalTargetEndpointBlank extends WithFqdn { + } + + /** + * The first stage of a traffic manager profile nested profile endpoint definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface NestedProfileTargetEndpointBlank extends WithNestedProfile { + } + + /** + * The stage of the traffic manager profile Azure endpoint definition allowing to specify the ID + * of the target Azure resource. + * + * @param the return type of {@link UpdateDefinitionStages.WithAttach#attach()} + */ + interface WithAzureResource { /** * Specifies the resource ID of an Azure resource. *

* supported Azure resources are cloud service, web app or public ip * * @param resourceId the Azure resource id - * @return the next stage of the endpoint definition + * @return the next stage of the definition */ - WithAttach withAzureEndpoint(String resourceId); + WithAttach toResourceId(String resourceId); + } + /** + * The stage of the traffic manager profile external endpoint definition allowing to specify + * the FQDN. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithFqdn { /** - * Specifies an external endpoint that is not hosted in Azure. + * Specifies the FQDN of an external endpoint. * * @param externalFqdn the external FQDN * @return the next stage of the endpoint definition */ - WithEndpointRegion withExternalEndpoint(String externalFqdn); - - /** - * Specifies a nested traffic manager profile for the endpoint. - * - * @param nestedProfile the nested traffic manager profile - * @return the next stage of the endpoint definition - */ - WithEndpointRegionThenThreshold withNestedEndpoint(TrafficManagerProfile nestedProfile); + WithSourceTrafficRegion toFqdn(String externalFqdn); } /** @@ -113,48 +133,63 @@ interface WithEndpointType { * * @param the return type of {@link WithAttach#attach()} */ - interface WithEndpointRegion { + interface WithSourceTrafficRegion { /** * Specifies the location of the endpoint that will be used when the parent profile is configured with * Performance routing method {@link TrafficRoutingMethod#PERFORMANCE}. * - * @param location the location + * @param region the location * @return the next stage of the endpoint definition */ - WithAttach withEndpointRegion(Region location); + WithAttach fromRegion(Region region); } /** - * The stage of the nested traffic manager profile endpoint definition allowing to specify the minimum - * endpoints to be online in the nested profile to consider it as not degraded. + * The stage of the traffic manager nested profile endpoint definition allowing to specify the profile. * - * @param the return type of {@link WithAttach#attach()} + * @param the return type of {@link UpdateDefinitionStages.WithAttach#attach()} */ - interface WithEndpointThreshold extends WithAttach { + interface WithNestedProfile { /** - * Specifies the minimum number of endpoints to be online for the nested profile to be considered healthy. + * Specifies a nested traffic manager profile for the endpoint. * - * @param count the number of endpoints - * @return the next stage of the endpoint definition + * @param profile the nested traffic manager profile + * @return the next stage of the definition */ - WithAttach withMinimumChildEndpoints(int count); + WithSourceTrafficRegionThenThreshold toProfile(TrafficManagerProfile profile); } /** - * The stage of the traffic manager endpoint definition allowing to specify the location of the nested profile - * endpoint. + * The stage of the traffic manager endpoint definition allowing to specify the location of the nested + * profile endpoint. * * @param the return type of {@link WithAttach#attach()} */ - interface WithEndpointRegionThenThreshold { + interface WithSourceTrafficRegionThenThreshold { /** * Specifies the location of the endpoint that will be used when the parent profile is configured with * Performance routing method {@link TrafficRoutingMethod#PERFORMANCE}. * - * @param location the location + * @param region the location * @return the next stage of the endpoint definition */ - WithEndpointThreshold withEndpointRegion(Region location); + WithEndpointThreshold fromRegion(Region region); + } + + /** + * The stage of the nested traffic manager profile endpoint definition allowing to specify the minimum + * endpoints to be online in the nested profile to consider it as not degraded. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithEndpointThreshold extends WithAttach { + /** + * Specifies the minimum number of endpoints to be online for the nested profile to be considered healthy. + * + * @param count the number of endpoints + * @return the next stage of the endpoint definition + */ + WithAttach withMinimumEndpointsToEnableTraffic(int count); } /** @@ -223,10 +258,14 @@ interface WithAttach extends * @param the return type of the final {@link Attachable#attach()} */ interface UpdateDefinition extends - UpdateDefinitionStages.Blank, - UpdateDefinitionStages.WithEndpointType, - UpdateDefinitionStages.WithEndpointThreshold, + UpdateDefinitionStages.AzureTargetEndpointBlank, + UpdateDefinitionStages.ExternalTargetEndpointBlank, + UpdateDefinitionStages.NestedProfileTargetEndpointBlank, + UpdateDefinitionStages.WithAzureResource, + UpdateDefinitionStages.WithFqdn, UpdateDefinitionStages.WithSourceTrafficRegion, + UpdateDefinitionStages.WithSourceTrafficRegionThenThreshold, + UpdateDefinitionStages.WithEndpointThreshold, UpdateDefinitionStages.WithAttach { } @@ -236,19 +275,36 @@ interface UpdateDefinition extends */ interface UpdateDefinitionStages { /** - * The first stage of a traffic manager profile endpoint definition. + * The first stage of a traffic manager profile Azure endpoint definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface AzureTargetEndpointBlank extends WithAzureResource { + } + + /** + * The first stage of a traffic manager profile external endpoint definition. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface ExternalTargetEndpointBlank extends WithFqdn { + } + + /** + * The first stage of a traffic manager profile nested profile endpoint definition. * * @param the return type of {@link WithAttach#attach()} */ - interface Blank extends WithEndpointType { + interface NestedProfileTargetEndpointBlank extends WithNestedProfile { } /** - * The stage of the traffic manager profile endpoint definition allowing to specify the type. + * The stage of the traffic manager profile Azure endpoint definition allowing to specify the ID + * of the target Azure resource. * * @param the return type of {@link WithAttach#attach()} */ - interface WithEndpointType { + interface WithAzureResource { /** * Specifies the resource ID of an Azure resource. *

@@ -257,56 +313,88 @@ interface WithEndpointType { * @param resourceId the Azure resource id * @return the next stage of the definition */ - WithAttach withAzureEndpoint(String resourceId); + WithAttach toResourceId(String resourceId); + } + /** + * The stage of the traffic manager profile external endpoint definition allowing to specify + * the FQDN. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithFqdn { /** - * SSpecifies an external endpoint that is not hosted in Azure. + * Specifies the FQDN of an external endpoint. * * @param externalFqdn the external FQDN - * @return the next stage of the definition + * @return the next stage of the endpoint definition + */ + WithSourceTrafficRegion toFqdn(String externalFqdn); + } + + /** + * The stage of the traffic manager endpoint definition allowing to specify the location of the external + * endpoint. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithSourceTrafficRegion { + /** + * Specifies the location of the endpoint that will be used when the parent profile is configured with + * Performance routing method {@link TrafficRoutingMethod#PERFORMANCE}. + * + * @param region the location + * @return the next stage of the endpoint definition */ - WithSourceTrafficRegion withExternalEndpoint(String externalFqdn); + WithAttach fromRegion(Region region); + } + /** + * The stage of the traffic manager nested profile endpoint definition allowing to specify the profile. + * + * @param the return type of {@link WithAttach#attach()} + */ + interface WithNestedProfile { /** * Specifies a nested traffic manager profile for the endpoint. * - * @param nestedProfile the nested traffic manager profile + * @param profile the nested traffic manager profile * @return the next stage of the definition */ - WithEndpointThreshold withNestedEndpoint(TrafficManagerProfile nestedProfile); + WithSourceTrafficRegionThenThreshold toProfile(TrafficManagerProfile profile); } /** - * The stage of the nested traffic manager profile endpoint definition allowing to specify the minimum - * endpoints to be online in the nested profile to consider it as not degraded. + * The stage of the traffic manager endpoint definition allowing to specify the location of the nested + * endpoint. * * @param the return type of {@link WithAttach#attach()} */ - interface WithEndpointThreshold { + interface WithSourceTrafficRegionThenThreshold { /** - * Specifies the minimum number of endpoints to be online for the nested profile to be considered healthy. + * Specifies the location of the endpoint that will be used when the parent profile is configured with + * Performance routing method {@link TrafficRoutingMethod#PERFORMANCE}. * - * @param count the number of endpoints - * @return the next stage of the definition + * @param region the location + * @return the next stage of the endpoint definition */ - WithSourceTrafficRegion withMinimumChildEndpoints(int count); + WithEndpointThreshold fromRegion(Region region); } /** - * The stage of the traffic manager endpoint definition allowing to specify the location of the external - * or nested profile endpoints. + * The stage of the nested traffic manager profile endpoint definition allowing to specify the minimum + * endpoints to be online in the nested profile to consider it as not degraded. * * @param the return type of {@link WithAttach#attach()} */ - interface WithSourceTrafficRegion { + interface WithEndpointThreshold extends WithAttach { /** - * Specifies the region of the endpoint that will be used when the performance-based routing method - * {@link TrafficRoutingMethod#PERFORMANCE} is enabled on the profile. + * Specifies the minimum number of endpoints to be online for the nested profile to be considered healthy. * - * @param location the location - * @return the next stage of the definition + * @param count the number of endpoints + * @return the next stage of the endpoint definition */ - WithAttach withSourceTrafficRegion(Region location); + WithAttach withMinimumEndpointsToEnableTraffic(int count); } /** @@ -381,8 +469,8 @@ interface UpdateAzureEndpoint extends * The entirety of an external endpoint update as a part of parent traffic manager profile profile update. */ interface UpdateExternalEndpoint extends - UpdateStages.WithExternalFqdn, - UpdateStages.WithEndpointRegion, + UpdateStages.WithFqdn, + UpdateStages.WithSourceTrafficRegion, Update { } @@ -391,7 +479,7 @@ interface UpdateExternalEndpoint extends */ interface UpdateNestedProfileEndpoint extends UpdateStages.WithNestedProfileConfig, - UpdateStages.WithEndpointRegion, + UpdateStages.WithSourceTrafficRegion, Update { } @@ -419,22 +507,22 @@ interface WithAzureResource { * supported Azure resources are cloud service, web app or public ip * * @param resourceId the Azure resource id - * @return the next stage of the endpoint update + * @return the next stage of the update */ - Update withAzureResource(String resourceId); + Update toResourceId(String resourceId); } /** * The stage of an external endpoint update allowing to specify the FQDN. */ - interface WithExternalFqdn { + interface WithFqdn { /** * Specifies the FQDN of an external endpoint that is not hosted in Azure. * * @param externalFqdn the external FQDN * @return the next stage of the endpoint update */ - UpdateExternalEndpoint withFqdn(String externalFqdn); + UpdateExternalEndpoint toFqdn(String externalFqdn); } /** @@ -448,7 +536,7 @@ interface WithNestedProfileConfig { * @param nestedProfile the nested traffic manager profile * @return the next stage of the update */ - UpdateNestedProfileEndpoint withProfile(TrafficManagerProfile nestedProfile); + UpdateNestedProfileEndpoint toProfile(TrafficManagerProfile nestedProfile); /** * Specifies the minimum number of endpoints to be online for the nested profile to be considered healthy. @@ -456,14 +544,14 @@ interface WithNestedProfileConfig { * @param count number of endpoints * @return the next stage of the endpoint update */ - UpdateNestedProfileEndpoint withMinimumChildEndpoints(int count); + UpdateNestedProfileEndpoint withMinimumEndpointsToEnableTraffic(int count); } /** * The stage of the traffic manager endpoint update allowing to specify the location of the external * or nested profile endpoints. */ - interface WithEndpointRegion { + interface WithSourceTrafficRegion { /** * Specifies the region of the endpoint that will be used when the performance-based routing method * {@link TrafficRoutingMethod#PERFORMANCE} is enabled on the profile. @@ -471,7 +559,7 @@ interface WithEndpointRegion { * @param location the location * @return the next stage of the endpoint update */ - Update withEndpointRegion(Region location); + Update fromRegion(Region location); } /** diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java index d6d11124270a4..991d2e72e3ded 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/TrafficManagerProfile.java @@ -165,12 +165,28 @@ interface WithTrafficRoutingMethod { */ interface WithEndpoint { /** - * Specifies definition of an endpoint to be attached to the traffic manager profile. + * Specifies definition of an Azure endpoint to be attached to the traffic manager profile. * * @param name the name for the endpoint * @return the stage representing configuration for the endpoint */ - TrafficManagerEndpoint.DefinitionStages.Blank defineEndpoint(String name); + TrafficManagerEndpoint.DefinitionStages.AzureTargetEndpointBlank defineAzureTargetEndpoint(String name); + + /** + * Specifies definition of an external endpoint to be attached to the traffic manager profile. + * + * @param name the name for the endpoint + * @return the stage representing configuration for the endpoint + */ + TrafficManagerEndpoint.DefinitionStages.ExternalTargetEndpointBlank defineExternalTargetEndpoint(String name); + + /** + * Specifies definition of an nested profile endpoint to be attached to the traffic manager profile. + * + * @param name the name for the endpoint + * @return the stage representing configuration for the endpoint + */ + TrafficManagerEndpoint.DefinitionStages.NestedProfileTargetEndpointBlank defineNestedTargetEndpoint(String name); } /** @@ -344,12 +360,28 @@ interface WithMonitoringConfiguration { */ interface WithEndpoint { /** - * Specifies definition of an endpoint to be attached to the traffic manager profile. + * Specifies definition of an Azure endpoint to be attached to the traffic manager profile. + * + * @param name the name for the endpoint + * @return the stage representing configuration for the endpoint + */ + TrafficManagerEndpoint.UpdateDefinitionStages.AzureTargetEndpointBlank defineAzureTargetEndpoint(String name); + + /** + * Specifies definition of an external endpoint to be attached to the traffic manager profile. + * + * @param name the name for the endpoint + * @return the stage representing configuration for the endpoint + */ + TrafficManagerEndpoint.UpdateDefinitionStages.ExternalTargetEndpointBlank defineExternalTargetEndpoint(String name); + + /** + * Specifies definition of an nested profile endpoint to be attached to the traffic manager profile. * * @param name the name for the endpoint * @return the stage representing configuration for the endpoint */ - TrafficManagerEndpoint.UpdateDefinitionStages.Blank defineEndpoint(String name); + TrafficManagerEndpoint.UpdateDefinitionStages.NestedProfileTargetEndpointBlank defineNestedTargetEndpoint(String name); /** * Begins the description of an update of an existing Azure endpoint in this profile. @@ -357,7 +389,7 @@ interface WithEndpoint { * @param name the name of the Azure endpoint * @return the stage representing updating configuration for the Azure endpoint */ - TrafficManagerEndpoint.UpdateAzureEndpoint updateAzureEndpoint(String name); + TrafficManagerEndpoint.UpdateAzureEndpoint updateAzureTargetEndpoint(String name); /** * Begins the description of an update of an existing external endpoint in this profile. @@ -365,7 +397,7 @@ interface WithEndpoint { * @param name the name of the external endpoint * @return the stage representing updating configuration for the external endpoint */ - TrafficManagerEndpoint.UpdateExternalEndpoint updateExternalEndpoint(String name); + TrafficManagerEndpoint.UpdateExternalEndpoint updateExternalTargetEndpoint(String name); /** * Begins the description of an update of an existing nested traffic manager profile endpoint @@ -374,7 +406,7 @@ interface WithEndpoint { * @param name the name of the nested profile endpoint * @return the stage representing updating configuration for the nested traffic manager profile endpoint */ - TrafficManagerEndpoint.UpdateNestedProfileEndpoint updateNestedProfileEndpoint(String name); + TrafficManagerEndpoint.UpdateNestedProfileEndpoint updateNestedProfileTargetEndpoint(String name); /** * Removes an endpoint in the profile. diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java index 408d7a4ab4f9d..b786db08d9688 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointImpl.java @@ -70,53 +70,35 @@ public int routingPriority() { } @Override - public TrafficManagerEndpointImpl withMinimumChildEndpoints(int count) { - this.inner().withMinChildEndpoints(new Long(count)); - return this; - } - - @Override - public TrafficManagerEndpointImpl withAzureResource(String resourceId) { - return this.withAzureEndpoint(resourceId); - } - - @Override - public TrafficManagerEndpointImpl withFqdn(String externalFqdn) { - return this.withExternalEndpoint(externalFqdn); - } - - @Override - public TrafficManagerEndpointImpl withProfile(TrafficManagerProfile nestedProfile) { - return this.withNestedEndpoint(nestedProfile); - } - - @Override - public TrafficManagerEndpointImpl withAzureEndpoint(String resourceId) { - this.inner().withType(EndpointType.AZURE.toString()); + public TrafficManagerEndpointImpl toResourceId(String resourceId) { this.inner().withTargetResourceId(resourceId); return this; } @Override - public TrafficManagerEndpointImpl withExternalEndpoint(String externalFqdn) { - this.inner().withType(EndpointType.EXTERNAL.toString()); + public TrafficManagerEndpointImpl toFqdn(String externalFqdn) { this.inner().withTarget(externalFqdn); return this; } @Override - public TrafficManagerEndpointImpl withNestedEndpoint(TrafficManagerProfile nestedProfile) { - this.inner().withType(EndpointType.NESTED_PROFILE.toString()); + public TrafficManagerEndpointImpl toProfile(TrafficManagerProfile nestedProfile) { this.inner().withTargetResourceId(nestedProfile.id()); this.inner().withMinChildEndpoints(new Long(1)); return this; } - public TrafficManagerEndpointImpl withEndpointRegion(Region location) { + public TrafficManagerEndpointImpl fromRegion(Region location) { this.inner().withEndpointLocation(location.toString()); return this; } + @Override + public TrafficManagerEndpointImpl withMinimumEndpointsToEnableTraffic(int count) { + this.inner().withMinChildEndpoints(new Long(count)); + return this; + } + @Override public TrafficManagerEndpointImpl withRoutingPriority(int priority) { this.inner().withPriority(new Long(priority)); diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java index 7a02986c8d3d5..842479fd1e0b1 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerEndpointsImpl.java @@ -97,13 +97,39 @@ Map nestedProfileEndpointsAsMap() { } /** - * Starts an endpoint definition chain. + * Starts an Azure endpoint definition chain. * * @param name the name of the endpoint to be added * @return the endpoint */ - public TrafficManagerEndpointImpl define(String name) { - return this.prepareDefine(name); + public TrafficManagerEndpointImpl defineAzureTargetEndpoint(String name) { + TrafficManagerEndpointImpl endpoint = this.prepareDefine(name); + endpoint.inner().withType(EndpointType.AZURE.toString()); + return endpoint; + } + + /** + * Starts an external endpoint definition chain. + * + * @param name the name of the endpoint to be added + * @return the endpoint + */ + public TrafficManagerEndpointImpl defineExteralTargetEndpoint(String name) { + TrafficManagerEndpointImpl endpoint = this.prepareDefine(name); + endpoint.inner().withType(EndpointType.EXTERNAL.toString()); + return endpoint; + } + + /** + * Starts an nested profile endpoint definition chain. + * + * @param name the name of the endpoint to be added + * @return the endpoint + */ + public TrafficManagerEndpointImpl defineNestedProfileTargetEndpoint(String name) { + TrafficManagerEndpointImpl endpoint = this.prepareDefine(name); + endpoint.inner().withType(EndpointType.NESTED_PROFILE.toString()); + return endpoint; } /** diff --git a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java index 48db6fc804123..3a4c571d86c58 100644 --- a/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java +++ b/azure-mgmt-trafficmanager/src/main/java/com/microsoft/azure/management/trafficmanager/implementation/TrafficManagerProfileImpl.java @@ -144,22 +144,32 @@ public TrafficManagerProfileImpl withTrafficRoutingMethod(TrafficRoutingMethod r } @Override - public TrafficManagerEndpointImpl defineEndpoint(String name) { - return this.endpoints.define(name); + public TrafficManagerEndpointImpl defineAzureTargetEndpoint(String name) { + return this.endpoints.defineAzureTargetEndpoint(name); } @Override - public TrafficManagerEndpointImpl updateAzureEndpoint(String name) { + public TrafficManagerEndpointImpl defineExternalTargetEndpoint(String name) { + return this.endpoints.defineExteralTargetEndpoint(name); + } + + @Override + public TrafficManagerEndpointImpl defineNestedTargetEndpoint(String name) { + return this.endpoints.defineNestedProfileTargetEndpoint(name); + } + + @Override + public TrafficManagerEndpointImpl updateAzureTargetEndpoint(String name) { return this.endpoints.updateAzureEndpoint(name); } @Override - public TrafficManagerEndpointImpl updateExternalEndpoint(String name) { + public TrafficManagerEndpointImpl updateExternalTargetEndpoint(String name) { return this.endpoints.updateExternalEndpoint(name); } @Override - public TrafficManagerEndpointImpl updateNestedProfileEndpoint(String name) { + public TrafficManagerEndpointImpl updateNestedProfileTargetEndpoint(String name) { return this.endpoints.updateNestedProfileEndpoint(name); } diff --git a/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java b/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java index 227f948c19e7c..2addd76f404cc 100644 --- a/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java +++ b/azure/src/test/java/com/microsoft/azure/management/TestTrafficManager.java @@ -64,9 +64,9 @@ public TrafficManagerProfile createResource(TrafficManagerProfiles profiles) thr .withNewResourceGroup(rgCreatable) .withLeafDomainLabel(nestedTmProfileDnsLabel) .withPriorityBasedRouting() - .defineEndpoint("external-ep-1") - .withExternalEndpoint("www.gitbook.com") - .withEndpointRegion(Region.INDIA_CENTRAL) + .defineExternalTargetEndpoint("external-ep-1") + .toFqdn("www.gitbook.com") + .fromRegion(Region.INDIA_CENTRAL) .attach() .withHttpsMonitoring() .withTimeToLive(500) @@ -93,33 +93,34 @@ public TrafficManagerProfile createResource(TrafficManagerProfiles profiles) thr Assert.assertNotNull(publicIpAddress.fqdn()); // Creates a TM profile // + TrafficManagerProfile profile = profiles.define(tmProfileName) .withNewResourceGroup(rgCreatable) .withLeafDomainLabel(tmProfileDnsLabel) .withWeightBasedRouting() - .defineEndpoint(externalEndpointName21) - .withExternalEndpoint(externalFqdn21) - .withEndpointRegion(Region.US_EAST) + .defineExternalTargetEndpoint(externalEndpointName21) + .toFqdn(externalFqdn21) + .fromRegion(Region.US_EAST) .withRoutingPriority(1) .withRoutingWeight(1) .attach() - .defineEndpoint(externalEndpointName22) - .withExternalEndpoint(externalFqdn22) - .withEndpointRegion(Region.US_EAST2) + .defineExternalTargetEndpoint(externalEndpointName22) + .toFqdn(externalFqdn22) + .fromRegion(Region.US_EAST2) .withRoutingPriority(2) .withRoutingWeight(1) .withTrafficDisabled() .attach() - .defineEndpoint(azureEndpointName) - .withAzureEndpoint(publicIpAddress.id()) + .defineAzureTargetEndpoint(azureEndpointName) + .toResourceId(publicIpAddress.id()) .withRoutingPriority(3) .attach() - .defineEndpoint(nestedProfileEndpointName) - .withNestedEndpoint(nestedProfile) - .withEndpointRegion(Region.INDIA_CENTRAL) - .withMinimumChildEndpoints(1) + .defineNestedTargetEndpoint(nestedProfileEndpointName) + .toProfile(nestedProfile) + .fromRegion(Region.INDIA_CENTRAL) + .withMinimumEndpointsToEnableTraffic(1) .withRoutingPriority(4) - .attach() + .attach() .withHttpMonitoring() .create(); @@ -195,16 +196,16 @@ public TrafficManagerProfile updateResource(TrafficManagerProfile profile) throw .withHttpMonitoring(8080, "/") .withPerformanceBasedRouting() .withoutEndpoint(externalEndpointName21) - .updateAzureEndpoint(azureEndpointName) + .updateAzureTargetEndpoint(azureEndpointName) .withRoutingPriority(5) .withRoutingWeight(2) .parent() - .updateNestedProfileEndpoint(nestedProfileEndpointName) + .updateNestedProfileTargetEndpoint(nestedProfileEndpointName) .withTrafficDisabled() .parent() - .defineEndpoint(externalEndpointName23) - .withExternalEndpoint(externalFqdn23) - .withSourceTrafficRegion(Region.US_CENTRAL) + .defineExternalTargetEndpoint(externalEndpointName23) + .toFqdn(externalFqdn23) + .fromRegion(Region.US_CENTRAL) .withRoutingPriority(6) .attach() .apply();