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

Fix for operations bound to directoryObjects/deletedItems #451

Merged
merged 5 commits into from
Oct 5, 2023
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
44 changes: 44 additions & 0 deletions transforms/csdl/preprocess_csdl.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,18 @@
<String>microsoft.graph.device</String>
</Collection>
</Annotation>
<Annotation Term="Org.OData.Core.V1.ExplicitOperationBindings">
<Collection>
<String>microsoft.graph.getByIds</String>
<String>microsoft.graph.getAvailableExtensionProperties</String>
<String>microsoft.graph.validateProperties</String>
<String>microsoft.graph.restore</String>
<String>microsoft.graph.getMemberObjects</String>
<String>microsoft.graph.getMemberGroups</String>
<String>microsoft.graph.checkMemberObjects</String>
<String>microsoft.graph.checkMemberGroups</String>
</Collection>
</Annotation>
</xsl:copy>
</xsl:template>
<xsl:template match="edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='user']/edm:NavigationProperty[@Name='ownedDevices']|
Expand Down Expand Up @@ -426,6 +438,8 @@
<!-- Remove ContainsTarget attribute for both Kiota-based and PowerShell-based CSDL -->
<xsl:template match="edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='group']/edm:NavigationProperty[@Name='acceptedSenders']/@ContainsTarget|
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='group']/edm:NavigationProperty[@Name='rejectedSenders']/@ContainsTarget|
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='connectedOrganization']/edm:NavigationProperty[@Name='externalSponsors']/@ContainsTarget|
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='connectedOrganization']/edm:NavigationProperty[@Name='internalSponsors']/@ContainsTarget|
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='accessPackageCatalog']/edm:NavigationProperty[@Name='accessPackages']/@ContainsTarget">
<xsl:apply-templates select="@* | node()"/>
</xsl:template>
Expand Down Expand Up @@ -541,6 +555,17 @@
<xsl:attribute name="Type">Edm.Stream</xsl:attribute>
</xsl:template>

<!-- Actions/Functions bound to directoryObject should have the 'RequiresExplicitBinding' annotation-->
<xsl:template match="edm:Schema[@Namespace='microsoft.graph']/edm:Action[@IsBound='true'][edm:Parameter[@Type='graph.directoryObject']] |
edm:Schema[@Namespace='microsoft.graph']/edm:Action[@IsBound='true'][edm:Parameter[@Type='Collection(graph.directoryObject)']] |
edm:Schema[@Namespace='microsoft.graph']/edm:Function[@IsBound='true'][edm:Parameter[@Type='graph.directoryObject']] |
edm:Schema[@Namespace='microsoft.graph']/edm:Function[@IsBound='true'][edm:Parameter[@Type='Collection(graph.directoryObject)']]">
<xsl:copy>
<xsl:copy-of select="@* | node()" />
<Annotation Term="Org.OData.Core.V1.RequiresExplicitBinding"/>
</xsl:copy>
</xsl:template>

<!--Replace single-valued with collection-valued return types for complex type appliedConditionalAccessPolicy-->
<xsl:template match="edm:Schema[@Namespace='microsoft.graph']/edm:ComplexType[@Name='appliedConditionalAccessPolicy']/edm:Property[@Name='conditionsNotSatisfied' or @Name='conditionsSatisfied']/@Type">
<xsl:attribute name="Type">Collection(graph.conditionalAccessConditions)</xsl:attribute>
Expand Down Expand Up @@ -1959,6 +1984,25 @@
<!-- Remove directoryObject Capability Annotations -->
<xsl:template match="edm:Schema[starts-with(@Namespace, 'microsoft.graph')]/edm:Annotations[@Target='microsoft.graph.directoryObject']/*[starts-with(@Term, 'Org.OData.Capabilities')]"/>

<xsl:template match="edm:Schema[starts-with(@Namespace, 'microsoft.graph')]/edm:Annotations[@Target='microsoft.graph.directoryObject']">
<xsl:element name="Annotations">
<xsl:attribute name="Target">microsoft.graph.directoryObject</xsl:attribute>
<Annotation Term="Org.OData.Core.V1.ExplicitOperationBindings">
<Collection>
<String>microsoft.graph.getByIds</String>
<String>microsoft.graph.delta</String>
<String>microsoft.graph.getAvailableExtensionProperties</String>
<String>microsoft.graph.validateProperties</String>
<String>microsoft.graph.restore</String>
<String>microsoft.graph.getMemberObjects</String>
<String>microsoft.graph.getMemberGroups</String>
<String>microsoft.graph.checkMemberObjects</String>
<String>microsoft.graph.checkMemberGroups</String>
</Collection>
</Annotation>
</xsl:element>
</xsl:template>

<!-- Add Referenceable Annotations (for /$ref paths) -->
<xsl:template match="edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='connectorGroup']/edm:NavigationProperty[@Name='members']|
edm:Schema[@Namespace='microsoft.graph']/edm:EntityType[@Name='educationClass']/edm:NavigationProperty[@Name='members']|
Expand Down
4 changes: 4 additions & 0 deletions transforms/csdl/preprocess_csdl_test_input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@
<Parameter Name="bindingparameter" Type="Collection(graph.event)" Nullable="false" />
<ReturnType Type="Collection(graph.event)" Nullable="false" />
</Function>
<Function Name="delta" IsBound="true">
<Parameter Name="bindingparameter" Type="Collection(graph.directoryObject)" Nullable="false" />
<ReturnType Type="Collection(graph.directoryObject)" Nullable="false" />
</Function>
<Action Name="accept" IsBound="true">
<Parameter Name="bindingParameter" Type="graph.event" />
<Parameter Name="SendResponse" Type="Edm.Boolean" />
Expand Down
37 changes: 34 additions & 3 deletions transforms/csdl/preprocess_csdl_test_output.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href='preprocess_csdl.xsl'?>
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx">
<edmx:DataServices>
Expand Down Expand Up @@ -358,6 +358,18 @@
<String>microsoft.graph.device</String>
</Collection>
</Annotation>
<Annotation Term="Org.OData.Core.V1.ExplicitOperationBindings" xmlns:edm="http://docs.oasis-open.org/odata/ns/edm">
<Collection>
<String>microsoft.graph.getByIds</String>
<String>microsoft.graph.getAvailableExtensionProperties</String>
<String>microsoft.graph.validateProperties</String>
<String>microsoft.graph.restore</String>
<String>microsoft.graph.getMemberObjects</String>
<String>microsoft.graph.getMemberGroups</String>
<String>microsoft.graph.checkMemberObjects</String>
<String>microsoft.graph.checkMemberGroups</String>
</Collection>
</Annotation>
</NavigationProperty>
</EntityType>
<EntityType Name="accessPackageCatalog" BaseType="graph.entity">
Expand Down Expand Up @@ -629,7 +641,7 @@
</EntityType>
<EntityType Name="connectedOrganization" BaseType="graph.entity">
<Property Name="description" Type="Edm.String" />
<NavigationProperty Name="internalSponsors" Type="Collection(graph.directoryObject)" ContainsTarget="true">
<NavigationProperty Name="internalSponsors" Type="Collection(graph.directoryObject)">
<Annotation Term="Org.OData.Capabilities.V1.NavigationRestrictions">
<Record>
<PropertyValue Property="Referenceable" Bool="true" />
Expand Down Expand Up @@ -905,6 +917,11 @@
</Record>
</Annotation>
</Function>
<Function Name="delta" IsBound="true">
<Parameter Name="bindingparameter" Type="Collection(graph.directoryObject)" Nullable="false" />
<ReturnType Type="Collection(graph.directoryObject)" Nullable="false" />
<Annotation Term="Org.OData.Core.V1.RequiresExplicitBinding" xmlns:edm="http://docs.oasis-open.org/odata/ns/edm" />
</Function>
<Action Name="accept" IsBound="true">
<Parameter Name="bindingParameter" Type="graph.event" />
<Parameter Name="SendResponse" Type="Edm.Boolean" />
Expand Down Expand Up @@ -1220,7 +1237,21 @@
<Property Name="description" Type="Edm.String" />
<Property Name="displayName" Type="Edm.String" Nullable="false" />
</EntityType>
<Annotations Target="microsoft.graph.directoryObject" />
<Annotations Target="microsoft.graph.directoryObject">
<Annotation Term="Org.OData.Core.V1.ExplicitOperationBindings" xmlns:edm="http://docs.oasis-open.org/odata/ns/edm">
<Collection>
<String>microsoft.graph.getByIds</String>
<String>microsoft.graph.delta</String>
<String>microsoft.graph.getAvailableExtensionProperties</String>
<String>microsoft.graph.validateProperties</String>
<String>microsoft.graph.restore</String>
<String>microsoft.graph.getMemberObjects</String>
<String>microsoft.graph.getMemberGroups</String>
<String>microsoft.graph.checkMemberObjects</String>
<String>microsoft.graph.checkMemberGroups</String>
</Collection>
</Annotation>
</Annotations>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
Loading