You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: graph/patterns/subsets.md
+14-18Lines changed: 14 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,27 +2,23 @@
2
2
3
3
Microsoft Graph API Design Pattern
4
4
5
-
The modeling collection subsets pattern is the modeling state associated to a collection that may include all instances, an included subset, an excluded subset, no instances, or any combinations of the preceding items.
5
+
*The modeling collection subsets pattern is the modeling state associated to a collection that may include all instances, an included subset, an excluded subset, no instances, or any combinations of the preceding items.*
6
+
7
+
## Problem
6
8
7
9
A common pattern is to apply a policy or state to a collection of objects. With this, there also comes the question of how to model cases where we want to apply to 'all' or 'none' without having to special case these values within the collection set or introduce cross-property dependencies. Likewise, we'd like to model it in a way where it is easy to understand and interpret usage from just looking at the schema.
8
10
9
11
An example is where you have a policy that you need to be able to apply to users in an organization. You might want to support the default **None**, enablement for **All**, or enablement for **Select** users where you only grant it to a few users.
10
12
11
-
## Problem
12
-
13
-
--------
14
-
15
13
Existing patterns for this either have special-cased 'strings' or have tightly coupled dependencies between two independent properties. Neither is intuitive, both require reading documentation, and neither can be inferred from the schema or within client libraries.
16
14
17
15
## Solution
18
16
19
-
--------
20
-
21
17
Have an abstract base class where all 'variants' of the subset are derived types from the base subset. For more information, see the [general subtyping guidance](https://github.com/microsoft/api-guidelines/blob/graph/graph/patterns/subtypes.md).
22
18
23
19
The abstract base class should also hold an enum for all possible variants. The purpose of including this is to allow for easier ways to do query and filter operations on variants like 'all' and 'none' without relying on `isof` functions.
@@ -75,8 +71,6 @@ Be aware that the name values and types in the preceding examples are just examp
75
71
76
72
## When to use this pattern
77
73
78
-
--------
79
-
80
74
Use this pattern when supporting two or more collection states of the following, where at least one of the states is a subset variant:
81
75
82
76
- All targets
@@ -88,17 +82,15 @@ If you only ever need to support two states—All or None—without usin
88
82
89
83
## Issues and considerations
90
84
91
-
--------
92
-
93
85
Given that we are using an overarching subtype model, subtyping model limitations apply here as well; for more details, see the [subtyping documentation](https://github.com/microsoft/api-guidelines/blob/graph/graph/Modelling%20with%20Subtypes%20Pattern.md).
94
86
95
87
## Example
96
88
97
-
--------
98
-
89
+
```http
99
90
GET https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies/
91
+
```
100
92
101
-
_Note: unrelated properties on entities are omitted for easier readability_
93
+
_Note: Unrelated properties on entities are omitted for easier readability._
102
94
103
95
```json
104
96
{
@@ -135,9 +127,11 @@ _Note: unrelated properties on entities are omitted for easier readability_
135
127
}
136
128
```
137
129
130
+
```http
138
131
POST https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies/
132
+
```
139
133
140
-
_Note: unrelated properties on entities are omitted for easier readability_
134
+
_Note: Unrelated properties on entities are omitted for easier readability._
141
135
142
136
```json
143
137
{
@@ -156,9 +150,11 @@ _Note: unrelated properties on entities are omitted for easier readability_
156
150
157
151
or
158
152
153
+
```http
159
154
POST https://graph.microsoft.com/v1.0/identity/conditionalAccess/policies/
155
+
```
160
156
161
-
_Note: unrelated properties on entities are omitted for easier readability_
157
+
_Note: Unrelated properties on entities are omitted for easier readability._
0 commit comments