Skip to content

Commit 40abe33

Browse files
committed
added hybrid mode
1 parent 2043c42 commit 40abe33

File tree

2 files changed

+137
-0
lines changed

2 files changed

+137
-0
lines changed

graph/patterns/longRunningOperations.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,3 +241,70 @@ HTTP/1.1 200 OK
241241
"resourceLocation": "https://graph.microsoft.com/v1.0/storage/archives/987"
242242
}
243243
```
244+
### Trigger a long running action using the Stepwise Operation
245+
246+
```
247+
POST https://graph.microsoft.com/v1.0/storage/copyArchive
248+
249+
{
250+
"displayName": "Image Archive",
251+
"destination": "Second-tier storage"
252+
...
253+
}
254+
```
255+
256+
The API responds synchronously that the request has been accepted and includes
257+
the Location header with an operation resource for further polling.
258+
259+
```
260+
HTTP/1.1 202 Accepted
261+
262+
Location: https://graph.microsoft.com/v1.0/storage/operations/123
263+
264+
```
265+
### Trigger a long running action using the Stepwise Operation in hybrid model
266+
267+
The server responds synchronously to POST requests to collections that create a resource even if the resources aren't fully created when the response is generated. The response includes a representation of the incomplete resource that will eventually exist at the URL in the Content-Location header and the Location header with an operation resource for further polling.
268+
269+
```
270+
POST https://graph.microsoft.com/v1.0/storage/databases/
271+
272+
{
273+
"displayName": "Retail DB",
274+
}
275+
```
276+
277+
The API responds synchronously that the database has been created and indicates
278+
that the provisioning operation is not fully completed by including the
279+
Content-Location header and status property in the response payload.
280+
281+
```
282+
HTTP/1.1 202 Accepted
283+
Content-Location: https://graph.microsoft.com/v1.0/storage/databases/db1
284+
Location: https://graph.microsoft.com/v1.0/storage/operations/123
285+
{
286+
"id": "db1",
287+
"displayName": "Retail DB",
288+
"status": "provisioning",
289+
[ … other fields for "database" …]
290+
}
291+
```
292+
The client waits for a period of time then invokes another request to try to get the database status.
293+
294+
```
295+
296+
GET https://graph.microsoft.com/v1.0/storage/operations/123
297+
```
298+
If resource creation is successful then the server responds with a "status:succeeded" and the resource
299+
location.
300+
301+
```
302+
HTTP/1.1 200 OK
303+
304+
{
305+
"createdDateTime": "2015-06-19T12-01-03.45Z",
306+
"lastActionDateTime": "2015-06-19T12-06-03.0024Z",
307+
"status": "succeeded",
308+
"resourceLocation": "https://graph.microsoft.com/v1.0/storage/databases/db1"
309+
}
310+
```

graph/patterns/operations.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Operations pattern
2+
3+
Microsoft Graph API Design Pattern
4+
5+
 
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+
11+
## 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+
15+
* *
16+
17+
## Solution
18+
--------
19+
20+
To address these use cases an API designers may use operational resources such as functions or actions.
21+
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+
otherwise the designer can model operation as an action.
23+
24+
25+
* *
26+
27+
28+
## Issues and Considerations
29+
---
30+
31+
- MS Graph does NOT support unbound actions or functions.
32+
33+
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+
35+
- Both actions and functions support overloading, meaning a schema may contain multiple actions or functions with the same name.The overload rules as per the OData [standard](http://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/odata-csdl-xml-v4.01.html#sec_FunctionOverloads) apply when adding parameters to actions and functions.
36+
37+
- As Graph only supports bound actions and functions, all must have at least one parameter where the first is the binding parameter. The MUSTS of parameters:
38+
39+
- Each parameter must have a simple identifier name.
40+
- The parameter name must be unique within the overload.
41+
- The parameter must specify a type.
42+
43+
- Graph supports the use of optional parameters. The optional parameter annotation can be used instead of creating function or action overloads when unnecessary.
44+
45+
- API designer **MUST** use POST to call operations on resources.
46+
|
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+
* *
60+
61+
## Example
62+
-------
63+
64+
*Provide a short example from real life*
65+
66+
* * 
67+
68+
69+
70+

0 commit comments

Comments
 (0)