diff --git a/src/Authentication/Authentication/Models/GraphCommand.cs b/src/Authentication/Authentication/Models/GraphCommand.cs index 159d0a9b693..4dd5147f902 100644 --- a/src/Authentication/Authentication/Models/GraphCommand.cs +++ b/src/Authentication/Authentication/Models/GraphCommand.cs @@ -107,5 +107,10 @@ public class GraphPermission /// Least privilege flag shows whether the permission is the least privilege. /// public bool IsLeastPrivilege { get; set; } + + /// + /// Permission scope type. It can either be delegated or application scope. + /// + public string PermissionType { get; set; } } } diff --git a/tools/PostGeneration/NewCommandMetadata.ps1 b/tools/PostGeneration/NewCommandMetadata.ps1 index f5b9ef5eb07..2e558cd6b72 100644 --- a/tools/PostGeneration/NewCommandMetadata.ps1 +++ b/tools/PostGeneration/NewCommandMetadata.ps1 @@ -48,7 +48,6 @@ $ApiVersion | ForEach-Object { $SplitFileName = $_.BaseName.Split("_") $CommandName = (New-Object regex -ArgumentList "Mg").Replace($SplitFileName[0], "-Mg", 1) $VariantName = $SplitFileName[1] - if ($_.DirectoryName -match "\\src\\(.*?.)\\") { $ModuleName = ($CurrentApiVersion -eq "beta") ? "Beta.$($Matches.1)" : $Matches.1 } @@ -64,12 +63,12 @@ $ApiVersion | ForEach-Object { $SegmentBuilder = "" # Trim nested namespace segments. $NestedNamespaceSegments = $Matches.1 -split "/" - foreach($Segment in $NestedNamespaceSegments){ + foreach ($Segment in $NestedNamespaceSegments) { # Remove microsoft.graph prefix and trailing '()' from functions. - $Segment = $segment.Replace("microsoft.graph.","").Replace("()", "") + $Segment = $segment.Replace("microsoft.graph.", "").Replace("()", "") # Get resource object name from segment if it exists. e.g get 'updateAudience' from windowsUpdates.updateAudience $ResourceObj = $Segment.Split(".") - $Segment = $ResourceObj[$ResourceObj.Count-1] + $Segment = $ResourceObj[$ResourceObj.Count - 1] $SegmentBuilder += "/$Segment" } $Uri = $Uri -replace [Regex]::Escape($MatchedUriSegment), $SegmentBuilder @@ -98,16 +97,16 @@ $ApiVersion | ForEach-Object { $PermissionsResponse = Invoke-RestMethod -Uri "$($PermissionsUrl)?requesturl=$($MappingValue.Uri)&method=$($MappingValue.Method)" -ErrorAction SilentlyContinue $PermissionsResponse | ForEach-Object { $Permissions += [PSCustomObject]@{ - Name = $_.value - Description = $_.consentDisplayName - FullDescription = $_.consentDescription - IsAdmin = $_.IsAdmin - ScopeType = $_.ScopeType + Name = $_.value + Description = $_.consentDisplayName + FullDescription = $_.consentDescription + IsAdmin = $_.IsAdmin + PermissionType = $_.ScopeType IsLeastPrivilege = $_.isLeastPrivilege } } $Permissions = $Permissions | Sort-Object -Property Name -Unique - $Permissions = $Permissions | Sort-Object -Property ScopeType + $Permissions = $Permissions | Sort-Object -Property PermissionType $Permissions = $Permissions | Sort-Object -Property IsLeastPrivilege [array]::Reverse($Permissions) $MappingValue.Permissions = $Permissions