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
74ffdeb
commit b18f0d1
Showing
16 changed files
with
252 additions
and
86 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
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
17 changes: 16 additions & 1 deletion
17
experiments/Azure.Experiments/Azure.Experiments/IResourceConfig.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 |
---|---|---|
@@ -1,6 +1,21 @@ | ||
namespace Microsoft.Azure.Experiments | ||
{ | ||
public interface IResourceConfigVisitor<Result> | ||
{ | ||
Result Visit<Config>(ResourceConfig<Config> config) | ||
where Config : class; | ||
Result Visit<Config, ParentConfig>(NestedResourceConfig<Config, ParentConfig> config) | ||
where Config : class | ||
where ParentConfig : class; | ||
} | ||
|
||
public interface IResourceConfig | ||
{ | ||
{ | ||
Result Apply<Result>(IResourceConfigVisitor<Result> visitor); | ||
} | ||
|
||
public interface IResourceConfig<Config> : IResourceConfig | ||
where Config : class | ||
{ | ||
} | ||
} |
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 |
---|---|---|
|
@@ -2,5 +2,7 @@ | |
{ | ||
public interface IState | ||
{ | ||
Config Get<Config>(IResourceConfig<Config> config) | ||
where Config : class; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
experiments/Azure.Experiments/Azure.Experiments/NestedResourceConfig.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,21 @@ | ||
namespace Microsoft.Azure.Experiments | ||
{ | ||
public sealed class NestedResourceConfig<Config, ParentConfig> : IResourceConfig<Config> | ||
where Config : class | ||
where ParentConfig : class | ||
{ | ||
public NestedResourcePolicy<Config, ParentConfig> Policy { get; } | ||
|
||
public IResourceConfig<ParentConfig> Parent { get; } | ||
|
||
public NestedResourceConfig( | ||
NestedResourcePolicy<Config, ParentConfig> policy, IResourceConfig<ParentConfig> parent) | ||
{ | ||
Policy = policy; | ||
Parent = parent; | ||
} | ||
|
||
public Result Apply<Result>(IResourceConfigVisitor<Result> visitor) | ||
=> visitor.Visit(this); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
experiments/Azure.Experiments/Azure.Experiments/Network/NetworkInterfacePolicy.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,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 NetworkInterfacePolicy | ||
{ | ||
public static ResourcePolicy<NetworkInterface> Policy { get; } | ||
= NetworkPolicy.Create( | ||
client => client.NetworkInterfaces, | ||
p => p.Operations.GetAsync( | ||
p.ResourceGroupName, p.Name, null, p.CancellationToken), | ||
p => p.Operations.CreateOrUpdateAsync( | ||
p.ResourceGroupName, p.Name, p.Config, p.CancellationToken)); | ||
|
||
public static ResourceConfig<NetworkInterface> CreateNetworkSecurityGroupConfig( | ||
this ResourceConfig<ResourceGroup> resourceGroup, string name) | ||
=> Policy.CreateConfig(resourceGroup, name); | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
experiments/Azure.Experiments/Azure.Experiments/Network/NetworkPolicy.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
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
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
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
Oops, something went wrong.