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);
}
}
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;
}
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()));
}
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;
}
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);
}
Aggregations