Skip to content

Commit cc429b7

Browse files
No interfaces.
1 parent ed16283 commit cc429b7

31 files changed

+417
-455
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.Azure.Management.Compute;
2+
using Microsoft.Azure.Management.Compute.Models;
3+
using Microsoft.Azure.Management.Network.Models;
4+
using Microsoft.Azure.Management.ResourceManager.Models;
5+
6+
namespace Microsoft.Azure.Experiments.Compute
7+
{
8+
public static class VirtualMachineConfig
9+
{
10+
public static ResourceConfig<VirtualMachine> Create(
11+
string name,
12+
ResourceConfig<ResourceGroup> resourceGroup,
13+
ResourceConfig<NetworkInterface> networkInterface)
14+
=> ManagedResourceConfig.Create(
15+
resourceGroup,
16+
name,
17+
new[] { networkInterface },
18+
c => c
19+
.CreateComputeManagementClient()
20+
.VirtualMachines
21+
.GetAsync(resourceGroup.Name, name),
22+
c => c.Location);
23+
}
24+
}

experiments/Azure.Experiments/Azure.Experiments/Compute/VirtualMachineParameters.cs

Lines changed: 0 additions & 38 deletions
This file was deleted.

experiments/Azure.Experiments/Azure.Experiments/CreateInfo.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

experiments/Azure.Experiments/Azure.Experiments/DependencyLocation.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

experiments/Azure.Experiments/Azure.Experiments/DependencyLocationExtensions.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

experiments/Azure.Experiments/Azure.Experiments/GetInfoContext.cs

Lines changed: 0 additions & 27 deletions
This file was deleted.

experiments/Azure.Experiments/Azure.Experiments/ICreateContext.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Threading.Tasks;
4+
5+
namespace Microsoft.Azure.Experiments
6+
{
7+
public interface ICreateOperation
8+
{
9+
IEnumerable<ICreateOperation> Dependencies { get; }
10+
11+
Task<object> Create(Context context);
12+
}
13+
14+
public sealed class CreateOperation<I> : ICreateOperation
15+
{
16+
public IEnumerable<ICreateOperation> Dependencies { get; }
17+
18+
public async Task<object> Create(Context context) => await CreateFunc(context);
19+
20+
public CreateOperation(
21+
IEnumerable<ICreateOperation> dependencies, Func<Context, Task<I>> createFunc)
22+
{
23+
Dependencies = dependencies;
24+
CreateFunc = createFunc;
25+
}
26+
27+
private Func<Context, Task<I>> CreateFunc { get; }
28+
}
29+
}

experiments/Azure.Experiments/Azure.Experiments/IGetInfoContext.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Microsoft.Azure.Experiments
2+
{
3+
public interface IStateMap
4+
{
5+
I Get<I>(ResourceConfig<I> config)
6+
where I : class;
7+
}
8+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace Microsoft.Azure.Experiments
2+
{
3+
/// <summary>
4+
/// null is no prefered location
5+
/// { IsCommon = ...; Name = null } is a location conflict.
6+
/// </summary>
7+
public sealed class Location
8+
{
9+
public bool IsCommon { get; }
10+
11+
public string Name { get; }
12+
13+
public Location(bool isCommon, string name)
14+
{
15+
IsCommon = isCommon;
16+
Name = name;
17+
}
18+
}
19+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace Microsoft.Azure.Experiments
2+
{
3+
public static class LocationExtensions
4+
{
5+
public static Location Merge(this Location a, Location b)
6+
{
7+
if (a == null)
8+
{
9+
return b;
10+
}
11+
if (b == null)
12+
{
13+
return a;
14+
}
15+
16+
if (a.IsCommon != b.IsCommon)
17+
{
18+
return a.IsCommon ? b : a;
19+
}
20+
21+
return a.Name == b.Name ? a : new Location(a.IsCommon, null);
22+
}
23+
}
24+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Microsoft.Azure.Management.ResourceManager.Models;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
7+
namespace Microsoft.Azure.Experiments
8+
{
9+
public static class ManagedResourceConfig
10+
{
11+
public static ResourceConfig<I> Create<I>(
12+
ResourceConfig<ResourceGroup> resourceGroup,
13+
string name,
14+
IEnumerable<IResourceConfig> dependencies,
15+
Func<Context, Task<I>> getAsync,
16+
Func<I, string> getLocation)
17+
where I : class
18+
=> ResourceConfig.Create(
19+
name,
20+
dependencies.Concat(new[] { resourceGroup }),
21+
getAsync,
22+
i => new Location(true, getLocation(i)),
23+
(map, config) => map.Get(config));
24+
}
25+
}

experiments/Azure.Experiments/Azure.Experiments/ManagedResourceParameters.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Microsoft.Azure.Management.Network;
2+
using Microsoft.Azure.Management.Network.Models;
3+
using Microsoft.Azure.Management.ResourceManager.Models;
4+
5+
namespace Microsoft.Azure.Experiments.Network
6+
{
7+
public static class NetworkInterfaceConfig
8+
{
9+
public static ResourceConfig<NetworkInterface> Create(
10+
ResourceConfig<ResourceGroup> resourceGroup,
11+
string name,
12+
ResourceConfig<Subnet> subnet,
13+
ResourceConfig<PublicIPAddress> publicIpAddress,
14+
ResourceConfig<NetworkSecurityGroup> networkSecurityGroup)
15+
=> NetworkResourceConfig.Create(
16+
resourceGroup,
17+
name,
18+
new IResourceConfig[] { subnet, publicIpAddress, networkSecurityGroup },
19+
c => c.NetworkInterfaces.GetAsync(resourceGroup.Name, name));
20+
}
21+
}

experiments/Azure.Experiments/Azure.Experiments/Network/NetworkInterfaceParameters.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)