Skip to content

Commit 471eb08

Browse files
committed
update on hybrid
1 parent 3c3458b commit 471eb08

File tree

4 files changed

+73
-40
lines changed

4 files changed

+73
-40
lines changed

graph/GuidelinesGraph.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Table of contents
1212
- [Uniform Resource Locators (URLs)](#uniform-resource-locators-urls)
1313
- [Query support](#query-support)
1414
- [Resource modeling patterns](#resource-modeling-patterns)
15+
- [Pros and cons](#pros-and-cons)
1516
- [Behavior modeling](#behavior-modeling)
1617
- [Error handling](#error-handling)
1718
- [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,
215216

216217
- **[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.
217218

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.
219220

220221
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.
221222

222223
| API qualities\patterns | Properties and behavior described in metadata | Supports combinations of properties and behaviors | Simple query construction |
223224
|-------------------------|-----------------------------------------------|---------------------------------------------------|---------------------------|
224225
| Type hierarchy | yes | no | no |
225226
| Facets | partially | yes | yes |
226-
| Flat | no | no | yes |
227+
| Flat bag | no | no | yes |
227228

228229
#### Pros and cons
229230

@@ -235,11 +236,11 @@ Following are a few pros and cons to decide which pattern to use:
235236

236237
- 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.
237238

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.
239240

240241
- **facets** has the potential to model what is typically associated with multiple inheritance.
241242

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.
243244

244245
- **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.
245246

@@ -379,6 +380,7 @@ The guidelines in previous sections are intentionally brief and provide a jump s
379380
| [Dictionary](./patterns/dictionary.md) | Clients can provide an unknown quantity of data elements of the same type. |
380381
| [Evolvable enums](./patterns/evolvable-enums.md) | Extend enumerated types without breaking changes. |
381382
| [Facets](./patterns/facets.md) | Model parent-child relationships. |
383+
| [Flat bag](./patterns/flat-bag.md) | Model variants of the same type. |
382384
| [Modeling subsets](./patterns/subsets.md) | Model collection subsets for All, None, Included, or Excluded criteria. |
383385
| [Namespace](./patterns/namespace.md) | Organize resource definitions into a logical set. |
384386
| [Type hierarchy](./patterns/subtypes.md) | Model `is-a` relationships using subtypes. |

graph/patterns/change-notification.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Change notification
2+
3+
Microsoft Graph API Design Pattern
4+
5+
*Provide a short description of the pattern.*
6+
7+
8+
## Problem
9+
10+
*Describe the business context relevant for the pattern.*
11+
12+
*Provide a short description of the problem.*
13+
14+
## Solution
15+
16+
*Describe how to implement the solution to solve the problem.*
17+
18+
*Describe related patterns.*
19+
20+
## When to use this pattern
21+
22+
*Describe when and why the solution is applicable and when it might not be.*
23+
24+
## Issues and considerations
25+
26+
*Describe tradeoffs of the solution.*
27+
28+
## Example
29+
30+
*Provide a short example from real life.*

graph/patterns/flat-bag.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Flat Bag Pattern
1+
# Flat Bag of properties Pattern
22

33
Microsoft Graph API Design Pattern
44

@@ -15,19 +15,19 @@ The API designer creates one entity type with all the potential properties plus
1515

1616
## When to use this pattern
1717

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.
1919
The pattern also makes it syntactically easier to query resources by using OData $filter expression because it doesn't require casting.
2020

2121
## Issues and considerations
2222

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.
2424
The pattern is not recommended for large number of variants and properties because the payload becomes sparsely populated.
2525

2626
You can consider related patterns such as Type hierarchy and Flat bag of properties.
2727

2828
## Example
2929

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).
3131

3232
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`).
3333

graph/patterns/operations.md

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,31 @@
22

33
Microsoft Graph API Design Pattern
44

5-
 
5+
*Operations pattern provides an ability to model a change which impacts multiple resources and can't be effectively modeled using HTTP methods*
66

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>
107

118
## 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.
149

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.
1611

1712
## Solution
18-
--------
1913

2014
To address these use cases an API designers may use operational resources such as functions or actions.
2115
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.
2216
otherwise the designer can model operation as an action.
2317

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
2423

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).
2625

2726

28-
## Issues and Considerations
29-
---
27+
## Issues and considerations
3028

31-
- MS Graph does NOT support unbound actions or functions.
29+
- MS Graph does NOT support unbound actions or functions.
3230

3331
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.
3432

@@ -44,27 +42,30 @@ Bound actions and functions are invoked on resources matching the type of the bi
4442

4543
- API designer **MUST** use POST to call operations on resources.
4644
|
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 []().
6046

6147
## Example
62-
-------
63-
64-
*Provide a short example from real life*
65-
66-
* * 
67-
68-
6948

49+
```
50+
<Action Name="createUploadSession" IsBound="true" ags:EnabledForPassthrough="true" ags:OwnerService="Microsoft.Exchange">
51+
<Parameter Name="bindingParameter" Type="Collection(graph.attachment)" />
52+
<Parameter Name="AttachmentItem" Type="graph.attachmentItem" Nullable="false" />
53+
<ReturnType Type="graph.uploadSession" />
54+
</Action>
55+
```
56+
<Action Name="deprovision" IsBound="true" ags:OwnerService="Microsoft.Intune.Devices">
57+
<Parameter Name="bindingParameter" Type="graph.managedDevice" />
58+
<Parameter Name="deprovisionReason" Type="Edm.String" Nullable="false" Unicode="false" />
59+
</Action>
60+
61+
<Function Name="additionalAccess" IsBound="true" ags:OwnerService="Microsoft.IGAELM">
62+
<Parameter Name="bindingParameter" Type="Collection(graph.accessPackageAssignment)" />
63+
<ReturnType Type="Collection(graph.accessPackageAssignment)" />
64+
</Function>
65+
66+
<Function Name="compare" IsBound="true" ags:OwnerService="Microsoft.Intune.DeviceIntent">
67+
<Parameter Name="bindingParameter" Type="graph.deviceManagementIntent" />
68+
<Parameter Name="templateId" Type="Edm.String" Unicode="false" />
69+
<ReturnType Type="Collection(graph.deviceManagementSettingComparison)" />
70+
</Function>
7071

0 commit comments

Comments
 (0)