Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds permissions type #2681

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Authentication/Authentication/Models/GraphCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,10 @@ public class GraphPermission
/// Least privilege flag shows whether the permission is the least privilege.
/// </summary>
public bool IsLeastPrivilege { get; set; }

/// <summary>
/// Permission scope type. It can either be delegated or application scope.
/// </summary>
public string PermissionType { get; set; }
}
}
19 changes: 9 additions & 10 deletions tools/PostGeneration/NewCommandMetadata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading