Search in sources :

Example 21 with SubResource

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

the class VirtualMachineScaleSetImpl method associateBackEndsToIpConfiguration.

private static void associateBackEndsToIpConfiguration(String loadBalancerId, VirtualMachineScaleSetIPConfigurationInner ipConfig, String... backendNames) {
    List<SubResource> backendSubResourcesToAssociate = new ArrayList<>();
    for (String backendName : backendNames) {
        String backendPoolId = mergePath(loadBalancerId, "backendAddressPools", backendName);
        boolean found = false;
        for (SubResource subResource : ipConfig.loadBalancerBackendAddressPools()) {
            if (subResource.id().equalsIgnoreCase(backendPoolId)) {
                found = true;
                break;
            }
        }
        if (!found) {
            backendSubResourcesToAssociate.add(new SubResource().withId(backendPoolId));
        }
    }
    for (SubResource backendSubResource : backendSubResourcesToAssociate) {
        ipConfig.loadBalancerBackendAddressPools().add(backendSubResource);
    }
}
Also used : SubResource(com.microsoft.azure.SubResource) ArrayList(java.util.ArrayList)

Example 22 with SubResource

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

the class ApplicationGatewayIPConfigurationImpl method withExistingSubnet.

@Override
public ApplicationGatewayIPConfigurationImpl withExistingSubnet(String networkId, String subnetName) {
    SubResource subnetRef = new SubResource().withId(networkId + "/subnets/" + subnetName);
    this.inner().withSubnet(subnetRef);
    return this;
}
Also used : SubResource(com.microsoft.azure.SubResource)

Example 23 with SubResource

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

the class ApplicationGatewayImpl method beforeCreating.

@Override
protected void beforeCreating() {
    // Process created PIPs
    for (Entry<String, String> frontendPipPair : this.creatablePipsByFrontend.entrySet()) {
        Resource createdPip = this.createdResource(frontendPipPair.getValue());
        this.updateFrontend(frontendPipPair.getKey()).withExistingPublicIPAddress(createdPip.id());
    }
    this.creatablePipsByFrontend.clear();
    // Reset and update IP configs
    ensureDefaultIPConfig();
    this.inner().withGatewayIPConfigurations(innersFromWrappers(this.ipConfigs.values()));
    // Reset and update frontends
    this.inner().withFrontendIPConfigurations(innersFromWrappers(this.frontends.values()));
    // Reset and update probes
    this.inner().withProbes(innersFromWrappers(this.probes.values()));
    // Reset and update backends
    this.inner().withBackendAddressPools(innersFromWrappers(this.backends.values()));
    // Reset and update backend HTTP settings configs
    this.inner().withBackendHttpSettingsCollection(innersFromWrappers(this.backendHttpConfigs.values()));
    for (ApplicationGatewayBackendHttpConfiguration config : this.backendHttpConfigs.values()) {
        SubResource ref;
        // Clear deleted probe references
        ref = config.inner().probe();
        if (ref != null && !this.probes().containsKey(ResourceUtils.nameFromResourceId(ref.id()))) {
            config.inner().withProbe(null);
        }
    }
    // Reset and update HTTP listeners
    this.inner().withHttpListeners(innersFromWrappers(this.listeners.values()));
    for (ApplicationGatewayListener listener : this.listeners.values()) {
        SubResource ref;
        // Clear deleted frontend references
        ref = listener.inner().frontendIPConfiguration();
        if (ref != null && !this.frontends().containsKey(ResourceUtils.nameFromResourceId(ref.id()))) {
            listener.inner().withFrontendIPConfiguration(null);
        }
        // Clear deleted frontend port references
        ref = listener.inner().frontendPort();
        if (ref != null && !this.frontendPorts().containsKey(ResourceUtils.nameFromResourceId(ref.id()))) {
            listener.inner().withFrontendPort(null);
        }
        // Clear deleted SSL certificate references
        ref = listener.inner().sslCertificate();
        if (ref != null && !this.sslCertificates().containsKey(ResourceUtils.nameFromResourceId(ref.id()))) {
            listener.inner().withSslCertificate(null);
        }
    }
    // Reset and update request routing rules
    this.inner().withRequestRoutingRules(innersFromWrappers(this.rules.values()));
    for (ApplicationGatewayRequestRoutingRule rule : this.rules.values()) {
        SubResource ref;
        // Clear deleted backends
        ref = rule.inner().backendAddressPool();
        if (ref != null && !this.backends().containsKey(ResourceUtils.nameFromResourceId(ref.id()))) {
            rule.inner().withBackendAddressPool(null);
        }
        // Clear deleted backend HTTP configs
        ref = rule.inner().backendHttpSettings();
        if (ref != null && !this.backendHttpConfigurations().containsKey(ResourceUtils.nameFromResourceId(ref.id()))) {
            rule.inner().withBackendHttpSettings(null);
        }
        // Clear deleted frontend HTTP listeners
        ref = rule.inner().httpListener();
        if (ref != null && !this.listeners().containsKey(ResourceUtils.nameFromResourceId(ref.id()))) {
            rule.inner().withHttpListener(null);
        }
    }
    // Reset and update SSL certs
    this.inner().withSslCertificates(innersFromWrappers(this.sslCerts.values()));
}
Also used : SubResource(com.microsoft.azure.SubResource) SubResource(com.microsoft.azure.SubResource) Resource(com.microsoft.azure.management.resources.fluentcore.arm.models.Resource) ApplicationGatewayRequestRoutingRule(com.microsoft.azure.management.network.ApplicationGatewayRequestRoutingRule) ApplicationGatewayBackendHttpConfiguration(com.microsoft.azure.management.network.ApplicationGatewayBackendHttpConfiguration) ApplicationGatewayListener(com.microsoft.azure.management.network.ApplicationGatewayListener)

Example 24 with SubResource

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

the class ApplicationGatewayListenerImpl method withFrontend.

// Helpers
private ApplicationGatewayListenerImpl withFrontend(String name) {
    SubResource frontendRef = new SubResource().withId(this.parent().futureResourceId() + "/frontendIPConfigurations/" + name);
    this.inner().withFrontendIPConfiguration(frontendRef);
    return this;
}
Also used : SubResource(com.microsoft.azure.SubResource)

Example 25 with SubResource

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

the class LoadBalancerProbeImpl method loadBalancingRules.

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

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