Search in sources :

Example 1 with TrafficManagerNestedProfileEndpoint

use of com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint in project azure-sdk-for-java by Azure.

the class TestTrafficManager method createResource.

@Override
public TrafficManagerProfile createResource(TrafficManagerProfiles profiles) throws Exception {
    final Region region = Region.US_EAST;
    final String groupName = "rg" + this.testId;
    final String pipName = "pip" + this.testId;
    final String pipDnsLabel = SdkContext.randomResourceName("contoso", 15);
    final String tmProfileName = "tm" + this.testId;
    final String nestedTmProfileName = "nested" + tmProfileName;
    final String tmProfileDnsLabel = SdkContext.randomResourceName("tmdns", 15);
    final String nestedTmProfileDnsLabel = "nested" + tmProfileDnsLabel;
    ResourceGroup.DefinitionStages.WithCreate rgCreatable = profiles.manager().resourceManager().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).withLeafDomainLabel(nestedTmProfileDnsLabel).withPriorityBasedRouting().defineExternalTargetEndpoint("external-ep-1").toFqdn("www.gitbook.com").fromRegion(Region.INDIA_CENTRAL).attach().withHttpsMonitoring().withTimeToLive(500).create();
    Assert.assertTrue(nestedProfile.isEnabled());
    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.timeToLive(), 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(rgCreatable).withLeafDomainLabel(tmProfileDnsLabel).withWeightBasedRouting().defineExternalTargetEndpoint(externalEndpointName21).toFqdn(externalFqdn21).fromRegion(Region.US_EAST).withRoutingPriority(1).withRoutingWeight(1).attach().defineExternalTargetEndpoint(externalEndpointName22).toFqdn(externalFqdn22).fromRegion(Region.US_EAST2).withRoutingPriority(2).withRoutingWeight(1).withTrafficDisabled().attach().defineAzureTargetEndpoint(azureEndpointName).toResourceId(publicIPAddress.id()).withRoutingPriority(3).attach().defineNestedTargetEndpoint(nestedProfileEndpointName).toProfile(nestedProfile).fromRegion(Region.INDIA_CENTRAL).withMinimumEndpointsToEnableTraffic(1).withRoutingPriority(4).attach().withHttpMonitoring().create();
    Assert.assertTrue(profile.isEnabled());
    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");
    // Default
    Assert.assertEquals(profile.timeToLive(), 300);
    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.NESTED_PROFILE);
        if (endpoint.name().equalsIgnoreCase(nestedProfileEndpointName)) {
            Assert.assertEquals(endpoint.routingPriority(), 4);
            Assert.assertNotNull(endpoint.monitorStatus());
            Assert.assertEquals(endpoint.minimumChildEndpointCount(), 1);
            Assert.assertEquals(endpoint.nestedProfileId(), nestedProfile.id());
            Assert.assertEquals(endpoint.sourceTrafficLocation(), Region.INDIA_CENTRAL);
            c++;
        }
    }
    Assert.assertEquals(c, 1);
    return profile;
}
Also used : TrafficManagerExternalEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint) TrafficManagerNestedProfileEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint) TrafficManagerAzureEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerAzureEndpoint) TrafficManagerProfile(com.microsoft.azure.management.trafficmanager.TrafficManagerProfile) Region(com.microsoft.azure.management.resources.fluentcore.arm.Region) PublicIPAddress(com.microsoft.azure.management.network.PublicIPAddress) TrafficManagerExternalEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint) TrafficManagerAzureEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerAzureEndpoint) TrafficManagerNestedProfileEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint)

Example 2 with TrafficManagerNestedProfileEndpoint

use of com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint in project azure-sdk-for-java by Azure.

the class TrafficManagerEndpointsImpl method nestedProfileEndpointsAsMap.

/**
     * @return the nested profile endpoints as a map indexed by name.
     */
Map<String, TrafficManagerNestedProfileEndpoint> nestedProfileEndpointsAsMap() {
    Map<String, TrafficManagerNestedProfileEndpoint> result = new HashMap<>();
    for (Map.Entry<String, TrafficManagerEndpointImpl> entry : this.collection().entrySet()) {
        TrafficManagerEndpointImpl endpoint = entry.getValue();
        if (endpoint.endpointType() == EndpointType.NESTED_PROFILE) {
            TrafficManagerNestedProfileEndpoint nestedProfileEndpoint = new TrafficManagerNestedProfileEndpointImpl(entry.getKey(), this.parent(), endpoint.inner(), this.client);
            result.put(entry.getKey(), nestedProfileEndpoint);
        }
    }
    return Collections.unmodifiableMap(result);
}
Also used : TrafficManagerNestedProfileEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with TrafficManagerNestedProfileEndpoint

use of com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint in project azure-sdk-for-java by Azure.

the class Utils method print.

/**
     * Print a traffic manager profile.
     * @param profile a traffic manager profile
     */
public static 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.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()).append("\n\tMonitoring path: ").append(profile.monitoringPath());
    Map<String, TrafficManagerAzureEndpoint> 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\tEnabled: ").append(endpoint.isEnabled()).append("\n\t\t\tRouting priority: ").append(endpoint.routingPriority()).append("\n\t\t\tRouting weight: ").append(endpoint.routingWeight());
        }
    }
    Map<String, TrafficManagerExternalEndpoint> 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\tEnabled: ").append(endpoint.isEnabled()).append("\n\t\t\tRouting priority: ").append(endpoint.routingPriority()).append("\n\t\t\tRouting weight: ").append(endpoint.routingWeight());
        }
    }
    Map<String, TrafficManagerNestedProfileEndpoint> 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.minimumChildEndpointCount()).append("\n\t\t\tSource Traffic Location: ").append(endpoint.sourceTrafficLocation()).append("\n\t\t\tMonitor status: ").append(endpoint.monitorStatus()).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());
        }
    }
    System.out.println(info.toString());
}
Also used : TrafficManagerExternalEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint) TrafficManagerNestedProfileEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint) TrafficManagerAzureEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerAzureEndpoint) ConnectionString(com.microsoft.azure.management.appservice.ConnectionString) TrafficManagerExternalEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint) TrafficManagerNestedProfileEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint) TrafficManagerAzureEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerAzureEndpoint)

Example 4 with TrafficManagerNestedProfileEndpoint

use of com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint in project azure-sdk-for-java by Azure.

the class TestTrafficManager method print.

@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.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()).append("\n\tMonitoring path: ").append(profile.monitoringPath());
    Map<String, TrafficManagerAzureEndpoint> 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\tEnabled: ").append(endpoint.isEnabled()).append("\n\t\t\tRouting priority: ").append(endpoint.routingPriority()).append("\n\t\t\tRouting weight: ").append(endpoint.routingWeight());
        }
    }
    Map<String, TrafficManagerExternalEndpoint> 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\tEnabled: ").append(endpoint.isEnabled()).append("\n\t\t\tRouting priority: ").append(endpoint.routingPriority()).append("\n\t\t\tRouting weight: ").append(endpoint.routingWeight());
        }
    }
    Map<String, TrafficManagerNestedProfileEndpoint> 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.minimumChildEndpointCount()).append("\n\t\t\tSource Traffic Location: ").append(endpoint.sourceTrafficLocation()).append("\n\t\t\tMonitor status: ").append(endpoint.monitorStatus()).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());
        }
    }
    System.out.println(info.toString());
}
Also used : TrafficManagerExternalEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint) TrafficManagerNestedProfileEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint) TrafficManagerAzureEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerAzureEndpoint) TrafficManagerExternalEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint) TrafficManagerAzureEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerAzureEndpoint) TrafficManagerNestedProfileEndpoint(com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint)

Aggregations

TrafficManagerNestedProfileEndpoint (com.microsoft.azure.management.trafficmanager.TrafficManagerNestedProfileEndpoint)4 TrafficManagerAzureEndpoint (com.microsoft.azure.management.trafficmanager.TrafficManagerAzureEndpoint)3 TrafficManagerExternalEndpoint (com.microsoft.azure.management.trafficmanager.TrafficManagerExternalEndpoint)3 ConnectionString (com.microsoft.azure.management.appservice.ConnectionString)1 PublicIPAddress (com.microsoft.azure.management.network.PublicIPAddress)1 Region (com.microsoft.azure.management.resources.fluentcore.arm.Region)1 TrafficManagerProfile (com.microsoft.azure.management.trafficmanager.TrafficManagerProfile)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1