Skip to content

Commit

Permalink
Broken but it's ok ;-)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-shandar committed Oct 26, 2017
1 parent d6db1f6 commit 4a41002
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Microsoft.Azure.Management.Compute.Models;
using Microsoft.Azure.Experiments.Network;
using System.Threading.Tasks;
using Microsoft.Azure.Management.Compute;

namespace Microsoft.Azure.Experiments.Compute
{
public sealed class VirtualMachineParameters : ResourceParameters<VirtualMachine>
{
public NetworkInterfaceParameters Ni { get; }

public VirtualMachineParameters(
string name,
ResourceGroupParameters resourceGroup,
NetworkInterfaceParameters ni)
: base(name, resourceGroup, new[] { ni })
{
Ni = ni;
}

public override Task<VirtualMachine> GetAsync(Context context)
=> context
.CreateCompute()
.VirtualMachines
.GetAsync(ResourceGroup.Name, Name);
}
}
32 changes: 32 additions & 0 deletions experiments/Azure.Experiments/Azure.Experiments/Context.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Microsoft.Azure.Management.Compute;
using Microsoft.Azure.Management.Network;
using Microsoft.Rest;

namespace Microsoft.Azure.Experiments
{
public sealed class Context
{
public Context(
ServiceClientCredentials credentials, string subscriptionId)
{
Credentials = credentials;
SubscriptionId = subscriptionId;
}

public ServiceClientCredentials Credentials { get; }

public string SubscriptionId { get; }

public NetworkManagementClient CreateNetwork()
=> new NetworkManagementClient(Credentials)
{
SubscriptionId = SubscriptionId
};

public ComputeManagementClient CreateCompute()
=> new ComputeManagementClient(Credentials)
{
SubscriptionId = SubscriptionId
};
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Azure.Management.Network.Models;
using Microsoft.Azure.Management.Network;

namespace Microsoft.Azure.Experiments.Network
{
Expand All @@ -24,5 +26,11 @@ public NetworkInterfaceParameters(
Nsg = nsg;
Pia = pia;
}

public override Task<NetworkInterface> GetAsync(Context context)
=> context
.CreateNetwork()
.NetworkInterfaces
.GetAsync(ResourceGroup.Name, Name);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Microsoft.Azure.Management.Network.Models;
using System.Threading.Tasks;
using Microsoft.Azure.Management.Network.Models;
using Microsoft.Azure.Management.Network;

namespace Microsoft.Azure.Experiments.Network
{
Expand All @@ -10,5 +12,11 @@ public NetworkSecurityGroupParameters(
: base(name, resourceGroup, NoDependencies)
{
}

public override Task<NetworkSecurityGroup> GetAsync(Context context)
=> context
.CreateNetwork()
.NetworkSecurityGroups
.GetAsync(ResourceGroup.Name, Name);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Azure.Management.Network.Models;
using Microsoft.Azure.Management.Network;

namespace Microsoft.Azure.Experiments.Network
{
Expand All @@ -11,5 +13,11 @@ public PublicIpAddressParameters(
: base(name, resourceGroup, NoDependencies)
{
}

public override Task<PublicIPAddress> GetAsync(Context context)
=> context
.CreateNetwork()
.PublicIPAddresses
.GetAsync(ResourceGroup.Name, Name);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Azure.Management.Network.Models;
using System.Threading.Tasks;
using Microsoft.Azure.Management.Network.Models;

namespace Microsoft.Azure.Experiments.Network
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Microsoft.Azure.Management.Network.Models;
using System.Threading.Tasks;
using Microsoft.Azure.Management.Network.Models;
using Microsoft.Azure.Management.Network;

namespace Microsoft.Azure.Experiments.Network
{
Expand All @@ -10,5 +12,11 @@ public VirtualNetworkParameters(
: base(name, resourceGroup, NoDependencies)
{
}

public override Task<VirtualNetwork> GetAsync(Context context)
=> context
.CreateNetwork()
.VirtualNetworks
.GetAsync(ResourceGroup.Name, Name);
}
}
3 changes: 3 additions & 0 deletions experiments/Azure.Experiments/Azure.Experiments/Parameters.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Microsoft.Azure.Experiments
{
Expand All @@ -25,5 +26,7 @@ protected Parameters(string name, IEnumerable<Parameters> parameters)
: base(name, parameters)
{
}

public abstract Task<T> GetAsync(Context context);
}
}

0 comments on commit 4a41002

Please sign in to comment.