Skip to content

Commit

Permalink
Merge pull request #2875 from microsoftgraph/2867-find-mggraphcommand…
Browse files Browse the repository at this point in the history
…-returns-incorrect-api-reference-link-for-mguser-commands

Removes ``ApiReferenceLink`` values that point to intune API reference docs and adds AutoREST directive to remove ``Get-MgUserMailFolderMessageContent``
  • Loading branch information
timayabi2020 authored Aug 1, 2024
2 parents 804fd63 + e329857 commit 9558be0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Mail/Mail.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@ require:
``` yaml
# Directives go here!
directive:
# Remove cmdlets.
- where:
verb: Get
subject: ^UserMailFolderMessageContent$
remove: true
```
25 changes: 24 additions & 1 deletion tools/PostGeneration/NewCommandMetadata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,29 @@ $ApiVersion | ForEach-Object {
if(-not($CommandAliasValue.Contains("-Mg"))) {
$CommandAliasValue = $null
}
$ExternalDocsUrl = ($RawFileContent -match $ExternalDocsPattern) ? $Matches.0 : $null
if(-not($Null -eq $ExternalDocsUrl)) {
$ExternalDocsUrl = $ExternalDocsUrl.Replace("intune-onboarding-", "")
$ExternalDocsUrl = $ExternalDocsUrl.Replace("intune-mam-", "")

try {
$HTTP_Request = [System.Net.WebRequest]::Create($ExternalDocsUrl)

# We then get a response from the site.
$HTTP_Response = $HTTP_Request.GetResponse()

# We then get the HTTP code as an integer.
$HTTP_Status = [int]$HTTP_Response.StatusCode

If (-not($HTTP_Status-eq 200)) {
$ExternalDocsUrl = $Null
}
If ($HTTP_Response -ne $null) { $HTTP_Response.Close() }
}
catch {
$ExternalDocsUrl = $Null
}
}
$MappingValue = @{
Command = $CommandName
Variants = [System.Collections.ArrayList]@($VariantName)
Expand All @@ -89,7 +112,7 @@ $ApiVersion | ForEach-Object {
ApiVersion = $CurrentApiVersion
OutputType = ($RawFileContent -match $OutputTypePattern) ? $Matches.1 : $null
Module = $ModuleName
ApiReferenceLink = ($RawFileContent -match $ExternalDocsPattern) ? $Matches.0 : $null
ApiReferenceLink = $ExternalDocsUrl
CommandAlias = $CommandAliasValue
Permissions = @()
}
Expand Down

0 comments on commit 9558be0

Please sign in to comment.