Add FilterRestrictions annotation transform to managedDevice entity type - #1194
Open
Egor Sidorenko (esidorenko-sl) wants to merge 1 commit into
Conversation
The entity description says filtering is only supported on a subset of properties, but there was no FilterRestrictions annotation, so the metadata advertised the whole collection as filterable. Lists the 35 properties that are not filterable in either v1.0 or beta. The two that are filterable in beta only, deviceType and ownerType, are left out so the same annotation stays correct for both versions.
Author
|
@microsoft-github-policy-service agree |
managedDevice entity type
Author
|
I got access to a tenant with Intune and checked what the service actually does. It rejects the undocumented properties outright rather than ignoring them, which lines up with the annotation being the missing piece. Requests against
So the service knows exactly which properties can be filtered and says so at request parse time, before it looks at any data. The tenant I used has no enrolled devices, which does not matter for the 400 cases since the query never gets that far. This is the same behaviour that #225 described for |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1193
microsoft.graph.managedDevicecarries a description saying that$filteris only supported on some of its properties, but it has noFilterRestrictionsannotation. With the annotation missing,Filterabledefaults to true and the metadata tells every generated client that the whole collection can be filtered.This adds the annotation, following the same approach as #227 for
directorySetting.What the change does
transforms/csdl/preprocess_csdl.xslgets a new named templateManagedDeviceFilterRestrictionsTemplatethat emitsFilterabletrue plus aNonFilterablePropertiescollection, and two call sites mirroring thedirectorySettingones. One handles the case whereAnnotations Target="microsoft.graph.managedDevice"already exists, which is what happens in both v1.0 and beta today, and the other creates the element if it is ever absent.I did not reuse the existing
FilterRestrictionsTemplatebecause it only emits theFilterableflag and there is no way to pass it a property list.How the property list was built
I took the list from the metadata itself rather than from the API docs. A property counts as filterable if its own
Core.V1.Descriptionmentions$filter, which is exactly the rule the entity description states.v1.0 has 55 properties, 20 of them filterable. Beta has 83 properties, 22 filterable, the two extra ones being
deviceTypeandownerType. The 35 properties listed inNonFilterablePropertiesare the ones that are not filterable in either version, so the same annotation is correct for v1.0 and beta.deviceTypeandownerTypeare deliberately left out for that reason.For reference, the 20 properties documented as filterable in v1.0 are
azureADDeviceId,complianceGracePeriodExpirationDateTime,complianceState,deviceCategoryDisplayName,deviceName,emailAddress,enrolledDateTime,exchangeAccessState,imei,jailBroken,lastSyncDateTime,managementAgent,managementState,manufacturer,model,operatingSystem,osVersion,phoneNumber,serialNumberanduserPrincipalName.Testing
I added a type level
Annotationselement formanagedDevicetopreprocess_csdl_test_input.xmlso the test exercises the same path that runs against the real schema, then regeneratedpreprocess_csdl_test_output.xmlwithtransform.ps1. The output keeps the existing description and appends the new annotation with all 35 property paths. No other part of the output changed.One note on the
directorySettingtemplate I copied from: it sets an attribute after copying child nodes, which XSLT ignores at that point. I left that out of the new template since@*|node()already copies the target attribute.Happy to adjust the property list, or to redo this through
additions/main.tspinstead if you would rather have new capability annotations go that route.