Skip to content

Commit

Permalink
No delete function
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-shandar committed Oct 18, 2017
1 parent fb1539a commit db9488e
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public async Task VmObject()
var pia = new PublicIpAddressObject("MyVM", rg);
var nsg = new NetworkSecurityGroupObject("MyVM", rg);
var ni = new NetworkInterfaceObject("MyVM", rg, subnet, pia, nsg);
var vm = new VmObject("MyVM", rg, ni, "MyVMUser", "@3as54dDd");
var vm = new VmObject(c, "MyVM", rg, ni, "MyVMUser", "@3as54dDd");
var info = await vm.GetOrCreateAsync(c);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ public async Task<T> GetOrCreateAsync(Context c)
return Info;
}

public Task DeleteAsync(Context c)
=> DeleteAsync(CreateClient(c));

public override Task CheckOrCreateAsync(Context c)
=> GetOrCreateAsync(c);

Expand All @@ -84,8 +81,6 @@ protected AzureObject(string name, IEnumerable<AzureObject> dependencies)

protected abstract Task<T> CreateAsync(C c);

protected abstract Task DeleteAsync(C c);

private bool IsGetCalled;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ protected override async Task<NetworkInterface> CreateAsync(
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ protected override Task<PublicIPAddress> CreateAsync(IPublicIPAddressesOperation
protected override IPublicIPAddressesOperations CreateClient(Context c)
=> c.CreateNetwork().PublicIPAddresses;

protected override Task DeleteAsync(IPublicIPAddressesOperations c)
=> c.DeleteAsync(ResourceGroupName, Name);

protected override Task<PublicIPAddress> GetOrThrowAsync(IPublicIPAddressesOperations c)
=> c.GetAsync(ResourceGroupName, Name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,5 @@ protected override Task<ResourceGroup> CreateAsync(IResourceGroupsOperations c)

protected override Task<ResourceGroup> GetOrThrowAsync(IResourceGroupsOperations c)
=> c.GetAsync(Name);

protected override Task DeleteAsync(IResourceGroupsOperations c)
=> c.DeleteAsync(Name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ protected override async Task<Subnet> CreateAsync(IVirtualNetworksOperations c)
protected override IVirtualNetworksOperations CreateClient(Context c)
=> c.CreateNetwork().VirtualNetworks;

protected override Task DeleteAsync(IVirtualNetworksOperations c)
{
throw new NotImplementedException();
}

protected override async Task<Subnet> GetOrThrowAsync(IVirtualNetworksOperations c)
=> GetSubnet(await Vn.GetOrNullAsync(c));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ protected override Task<VirtualNetwork> CreateAsync(IVirtualNetworksOperations c
protected override IVirtualNetworksOperations CreateClient(Context c)
=> c.CreateNetwork().VirtualNetworks;

protected override Task DeleteAsync(IVirtualNetworksOperations c)
=> c.DeleteAsync(ResourceGroupName, Name);

protected override Task<VirtualNetwork> GetOrThrowAsync(
IVirtualNetworksOperations c)
=> c.GetAsync(ResourceGroupName, Name);
Expand Down
21 changes: 12 additions & 9 deletions experiments/Azure.Experiments/Azure.Experiments/VmObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,27 @@ public sealed class VmObject
: ResourceObject<VirtualMachine, IVirtualMachinesOperations>
{
public VmObject(
Context c,
string name,
ResourceGroupObject rg,
NetworkInterfaceObject ni,
string adminUsername,
string adminPassword)
: base(name, rg, new[] { ni })
{
Client = new ComputeManagementClient(c.Credentials)
{
SubscriptionId = c.SubscriptionId
}
.VirtualMachines;
AdminUsername = adminUsername;
AdminPassword = adminPassword;
Ni = ni;
}

protected override Task<VirtualMachine> CreateAsync(
IVirtualMachinesOperations c)
=> c.CreateOrUpdateAsync(
IVirtualMachinesOperations _)
=> Client.CreateOrUpdateAsync(
ResourceGroupName,
Name,
new VirtualMachine
Expand Down Expand Up @@ -67,18 +73,15 @@ protected override IVirtualMachinesOperations CreateClient(Context c)
}
.VirtualMachines;

protected override Task DeleteAsync(IVirtualMachinesOperations c)
{
throw new System.NotImplementedException();
}

protected override Task<VirtualMachine> GetOrThrowAsync(IVirtualMachinesOperations c)
=> c.GetAsync(ResourceGroupName, Name);
protected override Task<VirtualMachine> GetOrThrowAsync(IVirtualMachinesOperations _)
=> Client.GetAsync(ResourceGroupName, Name);

private string AdminUsername { get; }

private string AdminPassword { get; }

private NetworkInterfaceObject Ni { get; }

private IVirtualMachinesOperations Client { get; }
}
}

0 comments on commit db9488e

Please sign in to comment.