Skip to content

Commit 5936a33

Browse files
committed
Edited Olga's latest updates
1 parent 14c8147 commit 5936a33

File tree

8 files changed

+72
-87
lines changed

8 files changed

+72
-87
lines changed

graph/GuidelinesGraph.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ The three most often used patterns in Microsoft Graph today are type hierarchy,
216216

217217
- **[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.
218218

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+
- **[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.
220220

221221
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.
222222

@@ -234,7 +234,7 @@ Following are a few pros and cons to decide which pattern to use:
234234

235235
- Introducing new cases in **hierarchy** is relatively isolated (which is why it is so familiar to OOP) and is considered backwards compatible (at least syntactically).
236236

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+
- 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 bag](./patterns/flat-bag.md)** pattern.
238238

239239
- **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.
240240

@@ -380,8 +380,8 @@ The guidelines in previous sections are intentionally brief and provide a jump s
380380
| [Dictionary](./patterns/dictionary.md) | Clients can provide an unknown quantity of data elements of the same type. |
381381
| [Evolvable enums](./patterns/evolvable-enums.md) | Extend enumerated types without breaking changes. |
382382
| [Facets](./patterns/facets.md) | Model parent-child relationships. |
383-
| [Flat bag](./patterns/flat-bag.md) | Model variants of the same type. |
384-
| [Long running operations](./patterns/longRunningOperations.md)| Model operations where processing a client request takes a long time. |
383+
| [Flat bag](./patterns/flat-bag.md) | Model variants of the same type. |
384+
| [Long running operations](./patterns/longRunningOperations.md)| Model operations where processing a client request takes a long time. |
385385
| [Modeling subsets](./patterns/subsets.md) | Model collection subsets for All, None, Included, or Excluded criteria. |
386386
| [Namespace](./patterns/namespace.md) | Organize resource definitions into a logical set. |
387387
| [Type hierarchy](./patterns/subtypes.md) | Model `is-a` relationships using subtypes. |

graph/patterns/alternate-key.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ Declare `mail` and `ssn` as alternate keys on an entity:
153153
}
154154
```
155155
156-
4. Request a resource where the alternate key property does not exist on any resource in the colleciton:
156+
4. Request a resource where the alternate key property does not exist on any resource in the collection:
157157
158158
```http
159159
GET https://graph.microsoft.com/v1.0/users(email='[email protected]')

graph/patterns/evolvable-enums.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Microsoft Graph API Design Pattern
44

5-
*The evolvable enum pattern allows API producers to extend enumerated types with new members without breaking API consumers.*
5+
*The evolvable enums pattern allows API producers to extend enumerated types with new members without breaking API consumers.*
66

77
## Problem
88

graph/patterns/facets.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ In this solution, a child variant is identified by the presence of one or more f
1919

2020
The facet pattern is useful when there is a number of variants and they are not mutually exclusive. It also makes it syntactically easier to query resources by using OData $filter expression because it doesn't require casting.
2121

22-
You can consider related patterns such as [Type hierarchy](./subtypes.md) and Flat bag of properties.
22+
You can consider related patterns such as [type hierarchy](./subtypes.md) and [flat bag of properties](./flat-bag.md).
2323

2424
## Issues and considerations
2525

graph/patterns/flat-bag.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
1-
# Flat Bag of properties Pattern
1+
# Flat bag of properties
22

33
Microsoft Graph API Design Pattern
44

55
*A known pattern in Microsoft Graph is to model multiple variants of a common concept as a single entity type with all potential properties plus an additional property to distinguish the variants.*
66

7-
87
## Problem
98

10-
API designers need to model a small and limited number of variants of a common concept with a concise list of non-overlapping properties and consistent behavior across variant. The designer also wants to simplify query construction.
9+
API designers need to model a small and limited number of variants of a common concept with a concise list of non-overlapping properties and consistent behavior across variants. The designer also wants to simplify query construction.
1110

1211
## Solution
1312

14-
The API designer creates one entity type with all the potential properties plus an additional property to distinguish the variants, often called `variantType`. For each value of `variantType` some properties are meaningful and others are ignored.
13+
The API designer creates one entity type with all the potential properties plus an additional property to distinguish the variants, often called `variantType`. For each value of `variantType`, some properties are meaningful and others are ignored.
1514

1615
## When to use this pattern
1716

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

2119
## Issues and considerations
2220

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-
The pattern is not recommended for large number of variants and properties because the payload becomes sparsely populated.
21+
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. However, there are circumstances when query simplicity and a limited number of properties might overweight considerations of a more strongly typed approach.
22+
The pattern is not recommended for a large number of variants and properties because the payload becomes sparsely populated.
2523

26-
You can consider related patterns such as Type hierarchy and Flat bag of properties.
24+
You can consider related patterns such as [type hierarchy](./subtypes.md) and [facets](./facets.md).
2725

2826
## Example
2927

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).
28+
A good example for flat bag implementation is the recurrencePattern type on [recurrencePattern](https://docs.microsoft.com/graph/api/resources/recurrencepattern).
3129

3230
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`).
3331

graph/patterns/longRunningOperations.md renamed to graph/patterns/long-running-operations.md

Lines changed: 39 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22

33
Microsoft Graph API Design Pattern
44

5-
__*The long running operations (LRO) pattern provides the ability to model operations where processing a client request takes a long time, but the client isn't blocked and can do some other work until operation completion.*__
5+
*The long running operations (LRO) pattern provides the ability to model operations where processing a client request takes a long time, but the client isn't blocked and can do some other work until operation completion.*
66

77
## Problem
88

99
The API design requires modeling operations on resources, which takes a long time
1010
to complete so that API clients don't need to wait and can continue doing other
1111
work while waiting for the final operation results. The client should be able to
1212
monitor the progress of the operation and have an ability to cancel it if
13-
needed. The API needs to provide a mechanism to track the work
13+
needed.
14+
15+
The API needs to provide a mechanism to track the work
1416
being done in the background. The mechanism needs to be expressed in the same
1517
web style as other interactive APIs. It also needs to support checking on the status and/or
1618
being notified asynchronously of the results.
@@ -24,18 +26,15 @@ operation.
2426
There are two flavors of this solution:
2527

2628
- The returned resource is the targeted resource and includes the status of
27-
the operation. This pattern is often called RELO (resource-based
28-
long running operation).
29+
the operation. This pattern is often called RELO (resource-based long running operation).
2930

3031
<!-- markdownlint-disable MD033 -->
3132
<p align="center">
3233
<img src="RELO.gif" alt="The status monitor LRO flow"/>
3334
</p>
3435
<!-- markdownlint-enable MD033 -->
3536

36-
- The returned resource is a new API resource called 'Stepwise Operation' and
37-
is created to track the status. This LRO solution is similar to the concept
38-
of Promises or Futures in other programming languages.
37+
- The returned resource is a new API resource called *stepwise operation* and is created to track the status. This LRO solution is similar to the concept of Promises or Futures in other programming languages.
3938

4039
<!-- markdownlint-disable MD033 -->
4140
<p align="center">
@@ -47,32 +46,28 @@ The RELO pattern is the preferred pattern for long running operations and should
4746
used wherever possible. The pattern avoids complexity, and consistent resource
4847
presentation makes things simpler for our users and tooling chain.
4948

50-
In general, Microsoft Graph API guidelines for LRO follow [Microsoft REST API
49+
In general, Microsoft Graph API guidelines for long running operations follow [Microsoft REST API
5150
Guidelines](https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#13-long-running-operations).
5251

5352
There are some deviations from the base guidelines where Microsoft Graph API standards require that you do one of the following:
5453

55-
- For RELO pattern you should return the Location header that indicates the location of the resource.
54+
- For the RELO pattern, you should return the Location header that indicates the location of the resource.
5655
- The API response says the targeted resource is being created by returning a 201 status code and the resource URI is provided in the Location header, but the response indicates that the request is not completed by including "Provisioning" status.
5756

58-
- For LRO pattern you should return the Location header that indicates the location of a new stepwise operation resource.
57+
- For the LRO pattern, you should return the Location header that indicates the location of a new stepwise operation resource.
5958
- The API response says the operation resource is being created at the URL provided in the Location header and indicates that the request is not completed by including a 202 status code.
60-
- Microsoft Graph doesn’t allow tenant wide operation resources therefore stepwise operations is often modeled as a navigation property on the target resource.
59+
- Microsoft Graph doesn’t allow tenant-wide operation resources; therefore, stepwise operations are often modeled as a navigation property on the target resource.
6160

6261
## When to use this pattern
6362

64-
Any API call that is expected to take longer than 1 second in the 99th percentile should use the long running operations pattern.
63+
Any API call that is expected to take longer than one second in the 99th percentile should use the long running operations pattern.
6564

66-
How do you select which flavor of LRO pattern to use? An API designer can follow these
67-
heuristics:
65+
How do you select which flavor of LRO pattern to use? An API designer can follow these heuristics:
6866

69-
1. If a service can create a resource with a minimal latency and continue
70-
updating its status according to the well-defined and stable state
71-
transition model until completion, then the RELO model is the best choice.
67+
1. If a service can create a resource with a minimal latency and continue updating its status according to the well-defined and stable state transition model until completion, then the RELO model is the best choice.
7268

73-
2. Otherwise, a service should follow the Stepwise Operation pattern.
69+
2. Otherwise, a service should follow the stepwise operation pattern.
7470

75-
7671
## Issues and considerations
7772

7873
- One or more API consumers MUST be able to monitor and operate on the same resource at the same time.
@@ -82,32 +77,28 @@ heuristics:
8277
resource is no longer active. Clients MAY issue a GET on some resource to
8378
determine the state of a long running operation.
8479

85-
- The long running operations pattern SHOULD work for clients looking to "fire and forget"
80+
- The long running operations pattern SHOULD work for clients looking to "fire and forget"
8681
and for clients looking to actively monitor and act upon results.
8782

88-
- The long running operations pattern might be supplemented by the [change notification
89-
pattern](change-notification.md).
83+
- The long running operations pattern might be supplemented by the [change notification pattern](./change-notification.md).
9084

91-
- Cancellation of a long running operation does not explicitly mean a rollback. On a per API-defined case, it
92-
might mean a rollback, or compensation, or completion, or partial completion,
85+
- Cancellation of a long running operation does not explicitly mean a rollback. On a per API-defined case, it
86+
might mean a rollback or compensation or completion or partial completion,
9387
etc. Following a canceled operation, the API should return a consistent state that allows
9488
continued service.
9589

96-
- A recommended minimum retention time for a stepwise operation is 24 hours.
90+
- A recommended minimum retention time for a stepwise operation is 24 hours.
9791
Operations SHOULD transition to "tombstone" for an additional period of time
9892
prior to being purged from the system.
9993

100-
- Services that provides a new operation resource MUST support GET semantics on the operation.
101-
- Services that returns a new operation MUST always return an LRO (even if the LRO is created in the completed state) that way API consumers don't have to deal with two different shapes of response.
102-
103-
94+
- Services that provide a new operation resource MUST support GET semantics on the operation.
95+
- Services that return a new operation MUST always return an LRO (even if the LRO is created in the completed state); that way API consumers don't have to deal with two different shapes of response.
10496

10597
## Examples
10698

99+
### Create a new resource using RELO
107100

108-
### Create a new resource using RELO
109-
110-
A client wants to provision a new database
101+
A client wants to provision a new database:
111102

112103
```
113104
POST https://graph.microsoft.com/v1.0/storage/databases/
@@ -119,7 +110,7 @@ POST https://graph.microsoft.com/v1.0/storage/databases/
119110

120111
The API responds synchronously that the database has been created and indicates
121112
that the provisioning operation is not fully completed by including the
122-
Content-Location header and status property in the response payload.
113+
Content-Location header and status property in the response payload:
123114

124115
```
125116
HTTP/1.1 201 Created
@@ -132,7 +123,8 @@ Location: https://graph.microsoft.com/v1.0/storage/databases/db1
132123
[ … other fields for "database" …]
133124
}
134125
```
135-
The client waits for a period of time then invokes another request to try to get the database status.
126+
127+
The client waits for a period of time, and then invokes another request to try to get the database status:
136128

137129
```
138130
GET https://graph.microsoft.com/v1.0/storage/databases/db1
@@ -146,10 +138,9 @@ HTTP/1.1 200 Ok
146138
}
147139
```
148140

141+
### Cancel RELO operation
149142

150-
### Cancel RELO operation
151-
152-
A client wants to cancel provisioning of a new database
143+
A client wants to cancel provisioning of a new database:
153144

154145
```
155146
DELETE https://graph.microsoft.com/v1.0/storage/databases/db1
@@ -159,7 +150,7 @@ DELETE https://graph.microsoft.com/v1.0/storage/databases/db1
159150
The API responds synchronously that the database is being deleted and indicates
160151
that the operation is accepted and is not fully completed by including the
161152
status property in the response payload. The API might provide a
162-
recommendation to wait for 30 seconds.
153+
recommendation to wait for 30 seconds:
163154

164155
```
165156
HTTP/1.1 202 Accepted
@@ -172,14 +163,15 @@ Retry-After: 30
172163
[ … other fields for "database" …]
173164
}
174165
```
175-
The client waits for a period of time then invokes another request to try to get the deletion status.
166+
167+
The client waits for a period of time, and then invokes another request to try to get the deletion status:
176168

177169
```
178170
GET https://graph.microsoft.com/v1.0/storage/databases/db1
179171
180172
HTTP/1.1 404 Not Found
181173
```
182-
### Create a new resource using the Stepwise Operation
174+
### Create a new resource using the stepwise operation
183175

184176
```
185177
POST https://graph.microsoft.com/v1.0/storage/archives/
@@ -191,7 +183,7 @@ POST https://graph.microsoft.com/v1.0/storage/archives/
191183
```
192184

193185
The API responds synchronously that the request has been accepted and includes
194-
the Location header with an operation resource for further polling.
186+
the Location header with an operation resource for further polling:
195187

196188
```
197189
HTTP/1.1 202 Accepted
@@ -200,15 +192,15 @@ Location: https://graph.microsoft.com/v1.0/storage/operations/123
200192
201193
```
202194

203-
### Poll on a Stepwise Operation
195+
### Poll on a stepwise operation
204196

205197
```
206198
207199
GET https://graph.microsoft.com/v1.0/storage/operations/123
208200
```
209201

210202
The server responds that results are still not ready and optionally provides a
211-
recommendation to wait 30 seconds.
203+
recommendation to wait 30 seconds:
212204

213205
```
214206
HTTP/1.1 200 OK
@@ -220,6 +212,7 @@ Retry-After: 30
220212
"status": "running"
221213
}
222214
```
215+
223216
The client waits the recommended 30 seconds and then invokes another request to get
224217
the results of the operation.
225218

@@ -241,7 +234,8 @@ HTTP/1.1 200 OK
241234
"resourceLocation": "https://graph.microsoft.com/v1.0/storage/archives/987"
242235
}
243236
```
244-
### Trigger a long running action using the Stepwise Operation
237+
238+
### Trigger a long running action using the stepwise operation
245239

246240
```
247241
POST https://graph.microsoft.com/v1.0/storage/copyArchive
@@ -254,7 +248,7 @@ POST https://graph.microsoft.com/v1.0/storage/copyArchive
254248
```
255249

256250
The API responds synchronously that the request has been accepted and includes
257-
the Location header with an operation resource for further polling.
251+
the Location header with an operation resource for further polling:
258252

259253
```
260254
HTTP/1.1 202 Accepted

0 commit comments

Comments
 (0)