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
-[API contract and non-backward compatible changes](#api-contract-and-non-backward-compatible-changes)
@@ -215,15 +216,15 @@ The three most often used patterns in Microsoft Graph today are type hierarchy,
215
216
216
217
-**[Facets](./patterns/facets.md)** are represented by a single entity type with common properties and one facet property (of complex type) per variant. The facet properties only have a value when the object represents that variant.
217
218
218
-
-**Flat bag of properties** is represented by one entity type with all the potential properties plus an additional property to distinguish the variants, often called type. The type property describes the variant and also defines properties that are required or meaningful for the variant given by the type property.
219
+
-**[Flat bag of properties]/(./patterns/flat-bag.md)** is represented by one entity type with all the potential properties plus an additional property to distinguish the variants, often called type. The type property describes the variant and also defines properties that are required or meaningful for the variant given by the type property.
219
220
220
221
The following table shows a summary of the main qualities for each pattern and can help you select a pattern fit for your use case.
221
222
222
223
| API qualities\patterns | Properties and behavior described in metadata | Supports combinations of properties and behaviors | Simple query construction |
@@ -235,11 +236,11 @@ Following are a few pros and cons to decide which pattern to use:
235
236
236
237
- Introducing new cases/variants in **[facets](./patterns/facets.md)** is straightforward. You need to be careful because it can introduce situations where previously only one of the facets was non-null and now all the old ones are null. This is not unlike adding new subtypes in the **hierarchy** pattern or adding a new type value in the **flat** pattern.
237
238
238
-
-**hierarchy** and **facets** (to a slightly lesser degree) are well-suited for strongly typed client programming languages, whereas **flat** is more familiar to developers of less strongly typed languages.
239
+
-**hierarchy** and **facets** (to a slightly lesser degree) are well-suited for strongly typed client programming languages, whereas **flat bag** is more familiar to developers of less strongly typed languages.
239
240
240
241
-**facets** has the potential to model what is typically associated with multiple inheritance.
241
242
242
-
-**facets** and **flat** lend to syntactically simpler filter query expression. **hierarchy** is more explicit but requires the cast segments in the filter query.
243
+
-**facets** and **flat bag** lend to syntactically simpler filter query expression. **hierarchy** is more explicit but requires the cast segments in the filter query.
243
244
244
245
-**hierarchy** can be refined by annotating the collections with OData derived type constraints; see [validation vocabulary](https://github.com/oasis-tcs/odata-vocabularies/blob/main/vocabularies/Org.OData.Validation.V1.md). This annotation restricts the values to certain sub-trees of an inheritance **hierarchy**. It makes it very explicit that the collection only contains elements of some of the subtypes and helps to not return objects of a type that are semantically not suitable.
245
246
@@ -379,6 +380,7 @@ The guidelines in previous sections are intentionally brief and provide a jump s
379
380
|[Dictionary](./patterns/dictionary.md)| Clients can provide an unknown quantity of data elements of the same type. |
380
381
|[Evolvable enums](./patterns/evolvable-enums.md)| Extend enumerated types without breaking changes. |
381
382
|[Facets](./patterns/facets.md)| Model parent-child relationships. |
383
+
|[Flat bag](./patterns/flat-bag.md)| Model variants of the same type. |
382
384
|[Modeling subsets](./patterns/subsets.md)| Model collection subsets for All, None, Included, or Excluded criteria. |
383
385
|[Namespace](./patterns/namespace.md)| Organize resource definitions into a logical set. |
384
386
|[Type hierarchy](./patterns/subtypes.md)| Model `is-a` relationships using subtypes. |
Copy file name to clipboardExpand all lines: graph/patterns/flat-bag.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Flat Bag Pattern
1
+
# Flat Bag of properties Pattern
2
2
3
3
Microsoft Graph API Design Pattern
4
4
@@ -15,19 +15,19 @@ The API designer creates one entity type with all the potential properties plus
15
15
16
16
## When to use this pattern
17
17
18
-
The flat-bag pattern is useful when there is a small number of variants with similar behavior and variants are queried for mostly read-only operations.
18
+
The Flat bag pattern is useful when there is a small number of variants with similar behavior and variants are queried for mostly read-only operations.
19
19
The pattern also makes it syntactically easier to query resources by using OData $filter expression because it doesn't require casting.
20
20
21
21
## Issues and considerations
22
22
23
-
In general the flat-bag pattern is the least recommended modeling choice because it is weakly typed and it is difficult to semantically verify targeted resource modifications. But there are circumstances when query simplicity and limited number of properties may overweight considerations of more strongly typed approach.
23
+
In general the Flat bag pattern is the least recommended modeling choice because it is weakly typed and it is difficult to semantically verify targeted resource modifications. But there are circumstances when query simplicity and limited number of properties may overweight considerations of more strongly typed approach.
24
24
The pattern is not recommended for large number of variants and properties because the payload becomes sparsely populated.
25
25
26
26
You can consider related patterns such as Type hierarchy and Flat bag of properties.
27
27
28
28
## Example
29
29
30
-
A good example for flat-bag implementation is the recurrencePattern and recurrenceRange types on [patternedRecurrence](https://docs.microsoft.com/graph/api/resources/patternedrecurrence).
30
+
A good example for Flat bag implementation is the recurrencePattern type on [recurrencePattern](https://docs.microsoft.com/en-us/graph/api/resources/recurrencepattern?view=graph-rest-1.0).
31
31
32
32
The recurrencePattern has six variants expressed as six different values of the `type` property (for example: daily, weekly, ...). The key here is that for each of these values, some properties are meaningful and others are ignored (for example: `daysOfWeek` is relevant when `type` is `weekly` but not when it is `daily`).
Copy file name to clipboardExpand all lines: graph/patterns/operations.md
+33-32Lines changed: 33 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,33 +2,31 @@
2
2
3
3
Microsoft Graph API Design Pattern
4
4
5
-
5
+
*Operations pattern provides an ability to model a change which impacts multiple resources and can't be effectively modeled using HTTP methods*
6
6
7
-
### *Operations pattern provides an ability to model a change which impacts multiple resources and can't be effectively modeled using HTTP methods*
8
-
9
-
<BR>
10
7
11
8
## Problem
12
-
---
13
-
Sometimes when modeling a complex business domain API designers need to model a business operation which effects multiple resources and needs to be performed as a single unit. Modeling the operation via HTTP methods on each individual resource may be either ineffective or doesn't reflect how it's proccessed by the backend service. In addition the operation may produce an observable side effects.
14
9
15
-
**
10
+
Sometimes when modeling a complex business domain API designers need to model a business operation which effects multiple resources and needs to be performed as a single unit. Modeling the operation via HTTP methods on each individual resource may be either ineffective or doesn't reflect how it's processed by the backend service. In addition the operation may produce an observable side effects.
16
11
17
12
## Solution
18
-
--------
19
13
20
14
To address these use cases an API designers may use operational resources such as functions or actions.
21
15
If the operation doesn't have any side effects and MUST return a single instance of a type or collection of instances then the designer SHOULD use OData function.
22
16
otherwise the designer can model operation as an action.
23
17
18
+
## When to use this pattern
19
+
20
+
The operation pattern is well suited to use cases which cannot be modeled as a single HTTP method on a resource and require either multiple round trips to complete a single logical operation or produce one or multiple side effects.
21
+
22
+
There are related patterns to consider such as
24
23
25
-
**
24
+
[Long running operation](https://github.com/microsoft/api-guidelines/tree/graph/graph) and [Change Tracking](https://github.com/microsoft/api-guidelines/tree/graph/graph).
26
25
27
26
28
-
## Issues and Considerations
29
-
---
27
+
## Issues and considerations
30
28
31
-
- MS Graph does NOT support unbound actions or functions.
29
+
- MS Graph does NOT support unbound actions or functions.
32
30
33
31
Bound actions and functions are invoked on resources matching the type of the binding parameter. The binding parameter can be of any type, and it MAY be Nullable. For MS Graph, actions and functions must have the `isBound="true"` attribute. The first parameter is the binding parameter.
34
32
@@ -44,27 +42,30 @@ Bound actions and functions are invoked on resources matching the type of the bi
44
42
45
43
- API designer **MUST** use POST to call operations on resources.
46
44
|
47
-
- Addition of a new mandatory not nullable parameter to an existing action or function is a breaking change and is not allowed without proper versioning []().
48
-
49
-
50
-
## When to Use this Pattern
51
-
52
-
The operation pattern is well suited to use cases which cannot be modeled as a single HTTP method on a resource and require either multiple round trips to complete a single logical operation or produce one or multiple side effects.
53
-
54
-
There are related patterns to consider such as
55
-
56
-
[Long running operation](https://github.com/microsoft/api-guidelines/tree/graph/graph) and [Change Tracking](https://github.com/microsoft/api-guidelines/tree/graph/graph).
57
-
58
-
59
-
**
45
+
- Addition of a new mandatory not nullable parameter to an existing action or function is a breaking change and is not allowed without proper versioning []().
0 commit comments