Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
import java.util.Set;

import com.microsoft.azure.management.apigeneration.Fluent;
import com.microsoft.azure.management.apigeneration.LangMethodDefinition;
import com.microsoft.azure.management.apigeneration.LangMethodDefinition.LangMethodType;
import com.microsoft.azure.management.apigeneration.Method;
import com.microsoft.azure.management.network.implementation.BackendAddressPoolInner;
import com.microsoft.azure.management.network.model.HasLoadBalancingRules;
import com.microsoft.azure.management.resources.fluentcore.arm.models.ChildResource;
Expand All @@ -36,7 +35,7 @@ public interface Backend extends
/**
* @return a list of the resource IDs of the virtual machines associated with this backend
*/
@LangMethodDefinition(AsType = LangMethodType.Method)
@Method
Set<String> getVirtualMachineIds();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
package com.microsoft.azure.management.network;

import com.microsoft.azure.management.apigeneration.Fluent;
import com.microsoft.azure.management.apigeneration.LangMethodDefinition;
import com.microsoft.azure.management.apigeneration.LangMethodDefinition.LangMethodType;
import com.microsoft.azure.management.apigeneration.Method;
import com.microsoft.azure.management.network.implementation.NetworkInterfaceInner;
import com.microsoft.azure.management.resources.fluentcore.arm.models.GroupableResource;
import com.microsoft.azure.management.resources.fluentcore.arm.models.Resource;
Expand Down Expand Up @@ -109,7 +108,7 @@ public interface NetworkInterface extends
*
* @return the network security group associated with this network interface.
*/
@LangMethodDefinition(AsType = LangMethodType.Method)
@Method
NetworkSecurityGroup getNetworkSecurityGroup();

/**
Expand All @@ -135,6 +134,27 @@ interface Definition extends
* Grouping of network interface definition stages.
*/
interface DefinitionStages {
/**
* The stage of the network interface definition allowing to associate it with a load balancer.
*/
interface WithLoadBalancer {
/**
* Associates the network interface's primary IP configuration with a backend of an existing load balancer.
* @param loadBalancer an existing load balancer
* @param backendName the name of an existing backend on that load balancer
* @return the next stage of the definition
*/
WithCreate withExistingLoadBalancerBackend(LoadBalancer loadBalancer, String backendName);

/**
* Associates the network interface's primary IP configuration with an inbound NAT rule of an existing load balancer.
* @param loadBalancer an existing load balancer
* @param inboundNatRuleName the name of an existing inbound NAT rule on the selected load balancer
* @return the next stage of the definition
*/
WithCreate withExistingLoadBalancerInboundNatRule(LoadBalancer loadBalancer, String inboundNatRuleName);
}

/**
* The first stage of the network interface.
*/
Expand Down Expand Up @@ -322,7 +342,8 @@ interface WithCreate extends
Resource.DefinitionWithTags<WithCreate>,
WithPrimaryPublicIpAddress,
WithNetworkSecurityGroup,
WithSecondaryIpConfiguration {
WithSecondaryIpConfiguration,
WithLoadBalancer {
/**
* Enable IP forwarding in the network interface.
*
Expand Down Expand Up @@ -549,6 +570,39 @@ interface WithIpConfiguration {
*/
NicIpConfiguration.Update updateIpConfiguration(String name);
}

/**
* The stage of the network interface update allowing to associate it with a load balancer.
*/
interface WithLoadBalancer {
/**
* Associates the network interface's primary IP configuration with a backend of an existing load balancer.
* @param loadBalancer an existing load balancer
* @param backendName the name of an existing backend on that load balancer
* @return the next stage of the update
*/
Update withExistingLoadBalancerBackend(LoadBalancer loadBalancer, String backendName);

/**
* Associates the network interface's primary IP configuration with an inbound NAT rule of an existing load balancer.
* @param loadBalancer an existing load balancer
* @param inboundNatRuleName the name of an existing inbound NAT rule on the selected load balancer
* @return the next stage of the update
*/
Update withExistingLoadBalancerInboundNatRule(LoadBalancer loadBalancer, String inboundNatRuleName);

/**
* Removes all the existing associations with any load balancer backends.
* @return the next stage of the update
*/
Update withoutLoadBalancerBackends();

/**
* Removes all the existing associations with any load balancer inbound NAT rules.
* @return the next stage of the update
*/
Update withoutLoadBalancerInboundNatRules();
}
}

/**
Expand All @@ -566,6 +620,7 @@ interface Update extends
UpdateStages.WithNetworkSecurityGroup,
UpdateStages.WithIpForwarding,
UpdateStages.WithDnsServer,
UpdateStages.WithIpConfiguration {
UpdateStages.WithIpConfiguration,
UpdateStages.WithLoadBalancer {
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.microsoft.azure.management.network;

import java.util.List;

import com.microsoft.azure.management.apigeneration.Fluent;
import com.microsoft.azure.management.apigeneration.LangMethodDefinition;
import com.microsoft.azure.management.apigeneration.LangMethodDefinition.LangMethodType;
import com.microsoft.azure.management.apigeneration.Method;
import com.microsoft.azure.management.network.implementation.NetworkInterfaceIPConfigurationInner;
import com.microsoft.azure.management.network.model.HasPrivateIpAddress;
import com.microsoft.azure.management.network.model.HasPublicIpAddress;
Expand All @@ -28,14 +29,24 @@ public interface NicIpConfiguration extends
/**
* @return the virtual network associated with this IP configuration
*/
@LangMethodDefinition(AsType = LangMethodType.Method)
@Method
Network getNetwork();

/**
* @return private IP address version
*/
IPVersion privateIpAddressVersion();

/**
* @return the load balancer backends associated with this network interface IP configuration
*/
List<Backend> listAssociatedLoadBalancerBackends();

/**
* @return the load balancer inbound NAT rules associated with this network interface IP configuration
*/
List<InboundNatRule> listAssociatedLoadBalancerInboundNatRules();

// Setters (fluent)

/**
Expand Down Expand Up @@ -151,6 +162,30 @@ interface WithSubnet<ParentT> {
interface WithPublicIpAddress<ParentT> extends HasPublicIpAddress.DefinitionStages.WithPublicIpAddress<WithAttach<ParentT>> {
}

/**
* The stage of the network interface IP configuration definition allowing to specify the load balancer
* to associate this IP configuration with.
*
* @param <ParentT> the return type of the final {@link Attachable#attach()}
*/
interface WithLoadBalancer<ParentT> {
/**
* Specifies the load balancer backend to associate this IP configuration with.
* @param loadBalancer an existing load balancer
* @param backendName the name of an existing backend on that load balancer
* @return the next stage of the update
*/
WithAttach<ParentT> withExistingLoadBalancerBackend(LoadBalancer loadBalancer, String backendName);

/**
* Specifies the load balancer inbound NAT rule to associate this IP configuration with.
* @param loadBalancer an existing load balancer
* @param inboundNatRuleName the name of an existing inbound NAT rule on the selected load balancer
* @return the next stage of the update
*/
WithAttach<ParentT> withExistingLoadBalancerInboundNatRule(LoadBalancer loadBalancer, String inboundNatRuleName);
}

/**
* The final stage of network interface IP configuration.
* <p>
Expand All @@ -162,7 +197,8 @@ interface WithPublicIpAddress<ParentT> extends HasPublicIpAddress.DefinitionStag
interface WithAttach<ParentT>
extends
Attachable.InDefinition<ParentT>,
WithPublicIpAddress<ParentT> {
WithPublicIpAddress<ParentT>,
WithLoadBalancer<ParentT> {
}
}

Expand Down Expand Up @@ -278,6 +314,30 @@ interface WithSubnet<ParentT> {
interface WithPublicIpAddress<ParentT> extends HasPublicIpAddress.UpdateDefinitionStages.WithPublicIpAddress<WithAttach<ParentT>> {
}

/**
* The stage of the network interface IP configuration definition allowing to specify the load balancer
* to associate this IP configuration with.
*
* @param <ParentT> the return type of the final {@link Attachable#attach()}
*/
interface WithLoadBalancer<ParentT> {
/**
* Specifies the load balancer to associate this IP configuration with.
* @param loadBalancer an existing load balancer
* @param backendName the name of an existing backend on that load balancer
* @return the next stage of the update
*/
WithAttach<ParentT> withExistingLoadBalancerBackend(LoadBalancer loadBalancer, String backendName);

/**
* Specifies the load balancer inbound NAT rule to associate this IP configuration with.
* @param loadBalancer an existing load balancer
* @param inboundNatRuleName the name of an existing inbound NAT rule on the selected load balancer
* @return the next stage of the update
*/
WithAttach<ParentT> withExistingLoadBalancerInboundNatRule(LoadBalancer loadBalancer, String inboundNatRuleName);
}

/**
* The final stage of network interface IP configuration.
* <p>
Expand All @@ -301,8 +361,7 @@ interface Update extends
UpdateStages.WithSubnet,
UpdateStages.WithPrivateIp,
UpdateStages.WithPublicIpAddress,
UpdateStages.WithLoadBalancer,
UpdateStages.WithBackendAddressPool {
UpdateStages.WithLoadBalancer {
}

/**
Expand Down Expand Up @@ -340,20 +399,6 @@ interface WithPrivateIp extends HasPrivateIpAddress.UpdateStages.WithPrivateIpAd
interface WithPublicIpAddress extends HasPublicIpAddress.UpdateStages.WithPublicIpAddress<Update> {
}

/**
* The stage of the network interface IP configuration update allowing to specify the load balancer
* back end address pool to add it to.
*/
interface WithBackendAddressPool {
/**
* Adds this network interface's IP configuration to the provided back end address pool of
* the specified load balancer.
* @param name the name of an existing load balancer back end address pool
* @return the next stage of the update
*/
Update withBackendAddressPool(String name);
}

/**
* The stage of the network interface's IP configuration allowing to specify the load balancer
* to associate this IP configuration with.
Expand All @@ -362,9 +407,30 @@ interface WithLoadBalancer {
/**
* Specifies the load balancer to associate this IP configuration with.
* @param loadBalancer an existing load balancer
* @param backendName the name of an existing backend on that load balancer
* @return the next stage of the update
*/
Update withExistingLoadBalancerBackend(LoadBalancer loadBalancer, String backendName);

/**
* Specifies the load balancer inbound NAT rule to associate this IP configuration with.
* @param loadBalancer an existing load balancer
* @param inboundNatRuleName the name of an existing inbound NAT rule on the selected load balancer
* @return the next stage of the update
*/
Update withExistingLoadBalancerInboundNatRule(LoadBalancer loadBalancer, String inboundNatRuleName);

/**
* Removes all the existing associations with load balancer backends.
* @return the next stage of the update
*/
Update withoutLoadBalancerBackends();

/**
* Removes all the existing associations with load balancer inbound NAT rules.
* @return the next stage of the update
*/
WithBackendAddressPool withExistingLoadBalancer(LoadBalancer loadBalancer);
Update withoutLoadBalancerInboundNatRules();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ protected void afterCreating() {
NicIpConfiguration nicIp = nic.primaryIpConfiguration();
nic.update()
.updateIpConfiguration(nicIp.name())
.withExistingLoadBalancer(this)
.withBackendAddressPool(backendName)
.withExistingLoadBalancerBackend(this, backendName)
.parent()
.apply();
this.nicsInBackends.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.microsoft.azure.SubResource;
import com.microsoft.azure.management.apigeneration.LangDefinition;
import com.microsoft.azure.management.network.IPAllocationMethod;
import com.microsoft.azure.management.network.LoadBalancer;
import com.microsoft.azure.management.network.Network;
import com.microsoft.azure.management.network.NetworkInterface;
import com.microsoft.azure.management.network.NetworkSecurityGroup;
Expand Down Expand Up @@ -128,6 +129,36 @@ public NetworkInterfaceImpl withNewPrimaryPublicIpAddress(String leafDnsLabel) {
return this;
}

@Override
public NetworkInterfaceImpl withExistingLoadBalancerBackend(LoadBalancer loadBalancer, String backendName) {
this.primaryIpConfiguration().withExistingLoadBalancerBackend(loadBalancer, backendName);
return this;
}

@Override
public NetworkInterfaceImpl withExistingLoadBalancerInboundNatRule(LoadBalancer loadBalancer, String inboundNatRuleName) {
this.primaryIpConfiguration().withExistingLoadBalancerInboundNatRule(loadBalancer, inboundNatRuleName);
return this;
}

@Override
public Update withoutLoadBalancerBackends() {
for (NicIpConfiguration ipConfig : this.ipConfigurations().values()) {
this.updateIpConfiguration(ipConfig.name())
.withoutLoadBalancerBackends();
}
return this;
}

@Override
public Update withoutLoadBalancerInboundNatRules() {
for (NicIpConfiguration ipConfig : this.ipConfigurations().values()) {
this.updateIpConfiguration(ipConfig.name())
.withoutLoadBalancerInboundNatRules();
}
return this;
}

@Override
public NetworkInterfaceImpl withoutPrimaryPublicIpAddress() {
this.primaryIpConfiguration().withoutPublicIpAddress();
Expand Down Expand Up @@ -404,6 +435,10 @@ protected void afterCreating() {
clearCachedRelatedResources();
}

NetworkManager manager() {
return this.myManager;
}

@Override
protected void beforeCreating() {
NetworkSecurityGroup networkSecurityGroup = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public List<Subnet> listAssociatedSubnets() {
}
}

return subnets;
return Collections.unmodifiableList(subnets);
}

// Setters (fluent)
Expand Down
Loading