-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
ee8b1d3
commit b58aed2
Showing
4 changed files
with
118 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Management.Automation; | ||
using Microsoft.Azure.Commands.Compute.Automation.Models; | ||
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; | ||
using Microsoft.Azure.Management.Compute; | ||
using Microsoft.Azure.Management.Compute.Models; | ||
using Microsoft.WindowsAzure.Commands.Utilities.Common; | ||
namespace Microsoft.Azure.Commands.Compute.Automation | ||
{ | ||
[Cmdlet(VerbsCommon.Get, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "DiskAccess", DefaultParameterSetName = DefaultParameterSet)] | ||
[OutputType(typeof(PSDiskAccess))] | ||
public partial class GetAzureDiskAccess : ComputeAutomationBaseCmdlet | ||
{ | ||
private const string DefaultParameterSet = "DefaultParameterSet"; | ||
private const string InputObjectParameterSet = "InputObjectParameterSet"; | ||
private const string ResourceIDParameterSet = "ResourceIDParameterSet"; | ||
[Parameter( | ||
ParameterSetName = DefaultParameterSet, | ||
Position = 0, | ||
ValueFromPipelineByPropertyName = true)] | ||
[ResourceGroupCompleter] | ||
[SupportsWildcards] | ||
public string ResourceGroupName { get; set; } | ||
[Parameter( | ||
ParameterSetName = DefaultParameterSet, | ||
Position = 1, | ||
ValueFromPipelineByPropertyName = true)] | ||
[ResourceNameCompleter("Microsoft.Compute/diskAccesses", "ResourceGroupName")] | ||
[SupportsWildcards] | ||
[Alias("diskAccessName")] | ||
public string Name { get; set; } | ||
[Parameter( | ||
Mandatory = true, | ||
Position = 0, | ||
ParameterSetName = ResourceIDParameterSet, | ||
ValueFromPipelineByPropertyName = true, | ||
HelpMessage = "Resource ID for your disk access.")] | ||
[ResourceIdCompleter("Microsoft.Compute/diskAccesses")] | ||
public string ResourceId { get; set; } | ||
public override void ExecuteCmdlet() | ||
{ | ||
base.ExecuteCmdlet(); | ||
ExecuteClientAction(() => | ||
{ | ||
string resourceGroupName = this.ResourceGroupName; | ||
string diskName = this.DiskName; | ||
if (ShouldGetByName(resourceGroupName, diskName)) | ||
{ | ||
var result = DisksClient.Get(resourceGroupName, diskName); | ||
var psObject = new PSDisk(); | ||
ComputeAutomationAutoMapperProfile.Mapper.Map<Disk, PSDisk>(result, psObject); | ||
WriteObject(psObject); | ||
} | ||
else if (ShouldListByResourceGroup(resourceGroupName, diskName)) | ||
{ | ||
var result = DisksClient.ListByResourceGroup(resourceGroupName); | ||
var resultList = result.ToList(); | ||
var nextPageLink = result.NextPageLink; | ||
while (!string.IsNullOrEmpty(nextPageLink)) | ||
{ | ||
var pageResult = DisksClient.ListByResourceGroupNext(nextPageLink); | ||
foreach (var pageItem in pageResult) | ||
{ | ||
resultList.Add(pageItem); | ||
} | ||
nextPageLink = pageResult.NextPageLink; | ||
} | ||
var psObject = new List<PSDiskList>(); | ||
foreach (var r in resultList) | ||
{ | ||
psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map<Disk, PSDiskList>(r)); | ||
} | ||
WriteObject(TopLevelWildcardFilter(resourceGroupName, diskName, psObject), true); | ||
} | ||
else | ||
{ | ||
var result = DisksClient.List(); | ||
var resultList = result.ToList(); | ||
var nextPageLink = result.NextPageLink; | ||
while (!string.IsNullOrEmpty(nextPageLink)) | ||
{ | ||
var pageResult = DisksClient.ListNext(nextPageLink); | ||
foreach (var pageItem in pageResult) | ||
{ | ||
resultList.Add(pageItem); | ||
} | ||
nextPageLink = pageResult.NextPageLink; | ||
} | ||
var psObject = new List<PSDiskList>(); | ||
foreach (var r in resultList) | ||
{ | ||
psObject.Add(ComputeAutomationAutoMapperProfile.Mapper.Map<Disk, PSDiskList>(r)); | ||
} | ||
WriteObject(TopLevelWildcardFilter(resourceGroupName, diskName, psObject), true); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
*/ |
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