Skip to content

Commit

Permalink
No interfaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-shandar committed Nov 3, 2017
1 parent ed16283 commit cc429b7
Show file tree
Hide file tree
Showing 31 changed files with 417 additions and 455 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.Azure.Management.Compute;
using Microsoft.Azure.Management.Compute.Models;
using Microsoft.Azure.Management.Network.Models;
using Microsoft.Azure.Management.ResourceManager.Models;

namespace Microsoft.Azure.Experiments.Compute
{
public static class VirtualMachineConfig
{
public static ResourceConfig<VirtualMachine> Create(
string name,
ResourceConfig<ResourceGroup> resourceGroup,
ResourceConfig<NetworkInterface> networkInterface)
=> ManagedResourceConfig.Create(
resourceGroup,
name,
new[] { networkInterface },
c => c
.CreateComputeManagementClient()
.VirtualMachines
.GetAsync(resourceGroup.Name, name),
c => c.Location);
}
}

This file was deleted.

12 changes: 0 additions & 12 deletions experiments/Azure.Experiments/Azure.Experiments/CreateInfo.cs

This file was deleted.

This file was deleted.

This file was deleted.

27 changes: 0 additions & 27 deletions experiments/Azure.Experiments/Azure.Experiments/GetInfoContext.cs

This file was deleted.

12 changes: 0 additions & 12 deletions experiments/Azure.Experiments/Azure.Experiments/ICreateContext.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Microsoft.Azure.Experiments
{
public interface ICreateOperation
{
IEnumerable<ICreateOperation> Dependencies { get; }

Task<object> Create(Context context);
}

public sealed class CreateOperation<I> : ICreateOperation
{
public IEnumerable<ICreateOperation> Dependencies { get; }

public async Task<object> Create(Context context) => await CreateFunc(context);

public CreateOperation(
IEnumerable<ICreateOperation> dependencies, Func<Context, Task<I>> createFunc)
{
Dependencies = dependencies;
CreateFunc = createFunc;
}

private Func<Context, Task<I>> CreateFunc { get; }
}
}
13 changes: 0 additions & 13 deletions experiments/Azure.Experiments/Azure.Experiments/IGetInfoContext.cs

This file was deleted.

8 changes: 8 additions & 0 deletions experiments/Azure.Experiments/Azure.Experiments/IStateMap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Microsoft.Azure.Experiments
{
public interface IStateMap
{
I Get<I>(ResourceConfig<I> config)
where I : class;
}
}
19 changes: 19 additions & 0 deletions experiments/Azure.Experiments/Azure.Experiments/Location.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Microsoft.Azure.Experiments
{
/// <summary>
/// null is no prefered location
/// { IsCommon = ...; Name = null } is a location conflict.
/// </summary>
public sealed class Location
{
public bool IsCommon { get; }

public string Name { get; }

public Location(bool isCommon, string name)
{
IsCommon = isCommon;
Name = name;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace Microsoft.Azure.Experiments
{
public static class LocationExtensions
{
public static Location Merge(this Location a, Location b)
{
if (a == null)
{
return b;
}
if (b == null)
{
return a;
}

if (a.IsCommon != b.IsCommon)
{
return a.IsCommon ? b : a;
}

return a.Name == b.Name ? a : new Location(a.IsCommon, null);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Microsoft.Azure.Management.ResourceManager.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Microsoft.Azure.Experiments
{
public static class ManagedResourceConfig
{
public static ResourceConfig<I> Create<I>(
ResourceConfig<ResourceGroup> resourceGroup,
string name,
IEnumerable<IResourceConfig> dependencies,
Func<Context, Task<I>> getAsync,
Func<I, string> getLocation)
where I : class
=> ResourceConfig.Create(
name,
dependencies.Concat(new[] { resourceGroup }),
getAsync,
i => new Location(true, getLocation(i)),
(map, config) => map.Get(config));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.Azure.Management.Network;
using Microsoft.Azure.Management.Network.Models;
using Microsoft.Azure.Management.ResourceManager.Models;

namespace Microsoft.Azure.Experiments.Network
{
public static class NetworkInterfaceConfig
{
public static ResourceConfig<NetworkInterface> Create(
ResourceConfig<ResourceGroup> resourceGroup,
string name,
ResourceConfig<Subnet> subnet,
ResourceConfig<PublicIPAddress> publicIpAddress,
ResourceConfig<NetworkSecurityGroup> networkSecurityGroup)
=> NetworkResourceConfig.Create(
resourceGroup,
name,
new IResourceConfig[] { subnet, publicIpAddress, networkSecurityGroup },
c => c.NetworkInterfaces.GetAsync(resourceGroup.Name, name));
}
}

This file was deleted.

Loading

0 comments on commit cc429b7

Please sign in to comment.