Skip to content

Commit f371ea5

Browse files
authored
Merge pull request #2681 from microsoftgraph/1781-find-mggraphcommand-differentiate-delegated-vs-app-permissions
Adds permissions type
2 parents 69515a2 + 20d3ad9 commit f371ea5

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/Authentication/Authentication/Models/GraphCommand.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,10 @@ public class GraphPermission
107107
/// Least privilege flag shows whether the permission is the least privilege.
108108
/// </summary>
109109
public bool IsLeastPrivilege { get; set; }
110+
111+
/// <summary>
112+
/// Permission scope type. It can either be delegated or application scope.
113+
/// </summary>
114+
public string PermissionType { get; set; }
110115
}
111116
}

tools/PostGeneration/NewCommandMetadata.ps1

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ $ApiVersion | ForEach-Object {
4848
$SplitFileName = $_.BaseName.Split("_")
4949
$CommandName = (New-Object regex -ArgumentList "Mg").Replace($SplitFileName[0], "-Mg", 1)
5050
$VariantName = $SplitFileName[1]
51-
5251
if ($_.DirectoryName -match "\\src\\(.*?.)\\") {
5352
$ModuleName = ($CurrentApiVersion -eq "beta") ? "Beta.$($Matches.1)" : $Matches.1
5453
}
@@ -64,12 +63,12 @@ $ApiVersion | ForEach-Object {
6463
$SegmentBuilder = ""
6564
# Trim nested namespace segments.
6665
$NestedNamespaceSegments = $Matches.1 -split "/"
67-
foreach($Segment in $NestedNamespaceSegments){
66+
foreach ($Segment in $NestedNamespaceSegments) {
6867
# Remove microsoft.graph prefix and trailing '()' from functions.
69-
$Segment = $segment.Replace("microsoft.graph.","").Replace("()", "")
68+
$Segment = $segment.Replace("microsoft.graph.", "").Replace("()", "")
7069
# Get resource object name from segment if it exists. e.g get 'updateAudience' from windowsUpdates.updateAudience
7170
$ResourceObj = $Segment.Split(".")
72-
$Segment = $ResourceObj[$ResourceObj.Count-1]
71+
$Segment = $ResourceObj[$ResourceObj.Count - 1]
7372
$SegmentBuilder += "/$Segment"
7473
}
7574
$Uri = $Uri -replace [Regex]::Escape($MatchedUriSegment), $SegmentBuilder
@@ -98,16 +97,16 @@ $ApiVersion | ForEach-Object {
9897
$PermissionsResponse = Invoke-RestMethod -Uri "$($PermissionsUrl)?requesturl=$($MappingValue.Uri)&method=$($MappingValue.Method)" -ErrorAction SilentlyContinue
9998
$PermissionsResponse | ForEach-Object {
10099
$Permissions += [PSCustomObject]@{
101-
Name = $_.value
102-
Description = $_.consentDisplayName
103-
FullDescription = $_.consentDescription
104-
IsAdmin = $_.IsAdmin
105-
ScopeType = $_.ScopeType
100+
Name = $_.value
101+
Description = $_.consentDisplayName
102+
FullDescription = $_.consentDescription
103+
IsAdmin = $_.IsAdmin
104+
PermissionType = $_.ScopeType
106105
IsLeastPrivilege = $_.isLeastPrivilege
107106
}
108107
}
109108
$Permissions = $Permissions | Sort-Object -Property Name -Unique
110-
$Permissions = $Permissions | Sort-Object -Property ScopeType
109+
$Permissions = $Permissions | Sort-Object -Property PermissionType
111110
$Permissions = $Permissions | Sort-Object -Property IsLeastPrivilege
112111
[array]::Reverse($Permissions)
113112
$MappingValue.Permissions = $Permissions

0 commit comments

Comments
 (0)