forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2be7c9c
commit 83d0145
Showing
5 changed files
with
119 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
experiments/Azure.Experiments/Azure.Experiments/NetworkInterfaceObject.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Microsoft.Azure.Management.Network; | ||
using Microsoft.Azure.Management.Network.Models; | ||
using System.Threading.Tasks; | ||
|
||
namespace Azure.Experiments | ||
{ | ||
class NetworkInterfaceObject | ||
: ResourceObject<NetworkInterface, INetworkInterfacesOperations> | ||
{ | ||
protected NetworkInterfaceObject( | ||
string name, | ||
ResourceGroupObject rg, | ||
VirtualNetworkObject vn, | ||
PublicIpAddressObject pia, | ||
NetworkSecurityGroupObject nsg) | ||
: base(name, rg, new AzureObject[] { vn, pia, nsg }) | ||
{ | ||
} | ||
|
||
protected override Task<NetworkInterface> CreateAsync( | ||
INetworkInterfacesOperations c) | ||
=> c.CreateOrUpdateAsync( | ||
ResourceGroupName, Name, new NetworkInterface()); | ||
|
||
protected override INetworkInterfacesOperations CreateClient(Context c) | ||
=> c.CreateNetwork().NetworkInterfaces; | ||
|
||
protected override Task DeleteAsync(INetworkInterfacesOperations c) | ||
=> c.DeleteAsync(ResourceGroupName, Name); | ||
|
||
protected override Task<NetworkInterface> GetOrThrowAsync( | ||
INetworkInterfacesOperations c) | ||
=> c.GetAsync(ResourceGroupName, Name); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
experiments/Azure.Experiments/Azure.Experiments/NetworkSecurityGroup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Microsoft.Azure.Management.Network; | ||
using Microsoft.Azure.Management.Network.Models; | ||
using System.Threading.Tasks; | ||
|
||
namespace Azure.Experiments | ||
{ | ||
public sealed class NetworkSecurityGroupObject | ||
: ResourceObject<NetworkSecurityGroup, INetworkSecurityGroupsOperations> | ||
{ | ||
public NetworkSecurityGroupObject( | ||
string name, ResourceGroupObject rg) | ||
: base(name, rg) | ||
{ | ||
} | ||
|
||
protected override Task<NetworkSecurityGroup> CreateAsync( | ||
INetworkSecurityGroupsOperations c) | ||
=> c.CreateOrUpdateAsync( | ||
ResourceGroupName, | ||
Name, | ||
new NetworkSecurityGroup { Location = "eastus" }); | ||
|
||
protected override INetworkSecurityGroupsOperations CreateClient( | ||
Context c) | ||
=> c.CreateNetwork().NetworkSecurityGroups; | ||
|
||
protected override Task DeleteAsync(INetworkSecurityGroupsOperations c) | ||
=> c.DeleteAsync(ResourceGroupName, Name); | ||
|
||
protected override Task<NetworkSecurityGroup> GetOrThrowAsync( | ||
INetworkSecurityGroupsOperations c) | ||
=> c.GetAsync(ResourceGroupName, Name); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
experiments/Azure.Experiments/Azure.Experiments/SubnetObject.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Microsoft.Azure.Management.Network; | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Azure.Experiments | ||
{ | ||
sealed class SubnetObject : AzureObject<object, IVirtualNetworksOperations> | ||
{ | ||
public SubnetObject(string name, VirtualNetworkObject vn) | ||
: base(name, new[] { vn }) | ||
{ | ||
Vn = vn; | ||
} | ||
|
||
protected override Task<object> CreateAsync(IVirtualNetworksOperations c) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
protected override IVirtualNetworksOperations CreateClient(Context c) | ||
=> c.CreateNetwork().VirtualNetworks; | ||
|
||
protected override Task DeleteAsync(IVirtualNetworksOperations c) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
protected override async Task<object> GetOrThrowAsync(IVirtualNetworksOperations c) | ||
=> (await Vn.GetOrNullAsync(c)) | ||
?.Subnets | ||
.FirstOrDefault(s => s.Name == Name); | ||
|
||
private VirtualNetworkObject Vn { get; } | ||
} | ||
} |