Search in sources :

Example 1 with SubResource

use of com.microsoft.azure.SubResource in project azure-sdk-for-java by Azure.

the class LoadBalancerImpl method beforeCreating.

@Override
protected void beforeCreating() {
    // Account for the newly created public IPs
    for (Entry<String, String> pipFrontendAssociation : this.creatablePIPKeys.entrySet()) {
        PublicIPAddress pip = (PublicIPAddress) this.createdResource(pipFrontendAssociation.getKey());
        if (pip != null) {
            withExistingPublicIPAddress(pip.id(), pipFrontendAssociation.getValue());
        }
    }
    this.creatablePIPKeys.clear();
    // Reset and update probes
    List<ProbeInner> innerProbes = innersFromWrappers(this.httpProbes.values());
    innerProbes = innersFromWrappers(this.tcpProbes.values(), innerProbes);
    if (innerProbes == null) {
        innerProbes = new ArrayList<>();
    }
    this.inner().withProbes(innerProbes);
    // Reset and update backends
    List<BackendAddressPoolInner> innerBackends = innersFromWrappers(this.backends.values());
    if (null == innerBackends) {
        innerBackends = new ArrayList<>();
    }
    this.inner().withBackendAddressPools(innerBackends);
    // Reset and update frontends
    List<FrontendIPConfigurationInner> innerFrontends = innersFromWrappers(this.frontends.values());
    if (null == innerFrontends) {
        innerFrontends = new ArrayList<>();
    }
    this.inner().withFrontendIPConfigurations(innerFrontends);
    // Reset and update inbound NAT rules
    List<InboundNatRuleInner> innerNatRules = innersFromWrappers(this.inboundNatRules.values());
    if (null == innerNatRules) {
        innerNatRules = new ArrayList<>();
    }
    this.inner().withInboundNatRules(innerNatRules);
    for (LoadBalancerInboundNatRule natRule : this.inboundNatRules.values()) {
        // Clear deleted frontend references
        SubResource ref = natRule.inner().frontendIPConfiguration();
        if (ref != null && !this.frontends().containsKey(ResourceUtils.nameFromResourceId(ref.id()))) {
            natRule.inner().withFrontendIPConfiguration(null);
        }
    }
    // Reset and update inbound NAT pools
    List<InboundNatPoolInner> innerNatPools = innersFromWrappers(this.inboundNatPools.values());
    if (null == innerNatPools) {
        innerNatPools = new ArrayList<>();
    }
    this.inner().withInboundNatPools(innerNatPools);
    for (LoadBalancerInboundNatPool natPool : this.inboundNatPools.values()) {
        // Clear deleted frontend references
        SubResource ref = natPool.inner().frontendIPConfiguration();
        if (ref != null && !this.frontends().containsKey(ResourceUtils.nameFromResourceId(ref.id()))) {
            natPool.inner().withFrontendIPConfiguration(null);
        }
    }
    // Reset and update load balancing rules
    List<LoadBalancingRuleInner> innerRules = innersFromWrappers(this.loadBalancingRules.values());
    if (innerRules == null) {
        innerRules = new ArrayList<>();
    }
    this.inner().withLoadBalancingRules(innerRules);
    for (LoadBalancingRule lbRule : this.loadBalancingRules.values()) {
        SubResource ref;
        // Clear deleted frontend references
        ref = lbRule.inner().frontendIPConfiguration();
        if (ref != null && !this.frontends().containsKey(ResourceUtils.nameFromResourceId(ref.id()))) {
            lbRule.inner().withFrontendIPConfiguration(null);
        }
        // Clear deleted backend references
        ref = lbRule.inner().backendAddressPool();
        if (ref != null && !this.backends().containsKey(ResourceUtils.nameFromResourceId(ref.id()))) {
            lbRule.inner().withBackendAddressPool(null);
        }
        // Clear deleted probe references
        ref = lbRule.inner().probe();
        if (ref != null && !this.httpProbes().containsKey(ResourceUtils.nameFromResourceId(ref.id())) && !this.tcpProbes().containsKey(ResourceUtils.nameFromResourceId(ref.id()))) {
            lbRule.inner().withProbe(null);
        }
    }
}
Also used : SubResource(com.microsoft.azure.SubResource) LoadBalancingRule(com.microsoft.azure.management.network.LoadBalancingRule) PublicIPAddress(com.microsoft.azure.management.network.PublicIPAddress) LoadBalancerInboundNatPool(com.microsoft.azure.management.network.LoadBalancerInboundNatPool) LoadBalancerInboundNatRule(com.microsoft.azure.management.network.LoadBalancerInboundNatRule)

Example 2 with SubResource

use of com.microsoft.azure.SubResource in project azure-sdk-for-java by Azure.

the class LoadBalancerInboundNatPoolImpl method withFrontend.

@Override
public LoadBalancerInboundNatPoolImpl withFrontend(String frontendName) {
    SubResource frontendRef = new SubResource().withId(this.parent().futureResourceId() + "/frontendIPConfigurations/" + frontendName);
    this.inner().withFrontendIPConfiguration(frontendRef);
    return this;
}
Also used : SubResource(com.microsoft.azure.SubResource)

Example 3 with SubResource

use of com.microsoft.azure.SubResource in project azure-sdk-for-java by Azure.

the class LoadBalancerFrontendImpl method inboundNatPools.

@Override
public Map<String, LoadBalancerInboundNatPool> inboundNatPools() {
    final Map<String, LoadBalancerInboundNatPool> pools = new TreeMap<>();
    if (this.inner().inboundNatPools() != null) {
        for (SubResource innerRef : this.inner().inboundNatPools()) {
            String name = ResourceUtils.nameFromResourceId(innerRef.id());
            LoadBalancerInboundNatPool pool = this.parent().inboundNatPools().get(name);
            if (pool != null) {
                pools.put(name, pool);
            }
        }
    }
    return Collections.unmodifiableMap(pools);
}
Also used : SubResource(com.microsoft.azure.SubResource) TreeMap(java.util.TreeMap) LoadBalancerInboundNatPool(com.microsoft.azure.management.network.LoadBalancerInboundNatPool)

Example 4 with SubResource

use of com.microsoft.azure.SubResource in project azure-sdk-for-java by Azure.

the class ApplicationGatewayListenerImpl method withSslCertificate.

@Override
public ApplicationGatewayListenerImpl withSslCertificate(String name) {
    SubResource certRef = new SubResource().withId(this.parent().futureResourceId() + "/sslCertificates/" + name);
    this.inner().withSslCertificate(certRef);
    return this;
}
Also used : SubResource(com.microsoft.azure.SubResource)

Example 5 with SubResource

use of com.microsoft.azure.SubResource in project azure-sdk-for-java by Azure.

the class ApplicationGatewayListenerImpl method withFrontendPort.

// Withers
@Override
public ApplicationGatewayListenerImpl withFrontendPort(String name) {
    SubResource portRef = new SubResource().withId(this.parent().futureResourceId() + "/frontendPorts/" + name);
    this.inner().withFrontendPort(portRef);
    return this;
}
Also used : SubResource(com.microsoft.azure.SubResource)

Aggregations

SubResource (com.microsoft.azure.SubResource)38 ArrayList (java.util.ArrayList)5 TreeMap (java.util.TreeMap)5 LoadBalancingRule (com.microsoft.azure.management.network.LoadBalancingRule)4 LoadBalancerInboundNatPool (com.microsoft.azure.management.network.LoadBalancerInboundNatPool)3 HashMap (java.util.HashMap)3 IPAllocationMethod (com.microsoft.azure.management.network.IPAllocationMethod)2 PublicIPAddressInner (com.microsoft.azure.management.network.implementation.PublicIPAddressInner)2 SubnetInner (com.microsoft.azure.management.network.implementation.SubnetInner)2 CloudError (com.microsoft.azure.CloudError)1 CloudException (com.microsoft.azure.CloudException)1 ApplicationTokenCredentials (com.microsoft.azure.credentials.ApplicationTokenCredentials)1 AvailabilitySet (com.microsoft.azure.management.compute.AvailabilitySet)1 AvailabilitySetSkuTypes (com.microsoft.azure.management.compute.AvailabilitySetSkuTypes)1 CachingTypes (com.microsoft.azure.management.compute.CachingTypes)1 DataDisk (com.microsoft.azure.management.compute.DataDisk)1 Disk (com.microsoft.azure.management.compute.Disk)1 DiskCreateOptionTypes (com.microsoft.azure.management.compute.DiskCreateOptionTypes)1 HardwareProfile (com.microsoft.azure.management.compute.HardwareProfile)1 NetworkProfile (com.microsoft.azure.management.compute.NetworkProfile)1