Skip to content

Commit f242616

Browse files
authored
Addint OData function def support (#433)
Signed-off-by: Tihomir Surdilovic <[email protected]>
1 parent 666150b commit f242616

File tree

4 files changed

+153
-14
lines changed

4 files changed

+153
-14
lines changed

roadmap/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ _Status description:_
3838
| ✔️| Added Workflow Auth definitions | [spec doc](../specification.md) |
3939
| ✔️| Added State execution timeouts | [spec doc](../specification.md) |
4040
| ✔️| Temporarily removed `waitForCompletion` for subflows | [spec doc](../specification.md) |
41+
| ✔️| Added function definition support for OData | [spec doc](../specification.md) |
4142
| ✏️ | AsyncAPI operation support | |
4243
| ✏️ | OData function definition support | |
4344
| ✏️ | Update to retries - state specific rather than error specific | |

schema/functions.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,17 @@
3636
},
3737
"operation": {
3838
"type": "string",
39-
"description": "If type is `rest`, <path_to_openapi_definition>#<operation_id>. If type is `rpc`, <path_to_grpc_proto_file>#<service_name>#<service_method>. If type is `graphql`, <url_to_graphql_endpoint>#<literal \"mutation\" or \"query\">#<query_or_mutation_name>. If type is `expression`, defines the workflow expression.",
39+
"description": "If type is `rest`, <path_to_openapi_definition>#<operation_id>. If type is `rpc`, <path_to_grpc_proto_file>#<service_name>#<service_method>. If type is `graphql`, <url_to_graphql_endpoint>#<literal \\\"mutation\\\" or \\\"query\\\">#<query_or_mutation_name>. If type is `odata`, <URI_to_odata_service>#<Entity_Set_Name>. If type is `expression`, defines the workflow expression.",
4040
"minLength": 1
4141
},
4242
"type": {
4343
"type": "string",
44-
"description": "Defines the function type. Is either `rest`, `rpc`, `graphql` or `expression`. Default is `rest`",
44+
"description": "Defines the function type. Is either `rest`, `rpc`, `graphql`, `odata`, or `expression`. Default is `rest`",
4545
"enum": [
4646
"rest",
4747
"rpc",
4848
"graphql",
49+
"odata",
4950
"expression"
5051
],
5152
"default": "rest"

schema/odata.json

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"$id": "https://serverlessworkflow.io/schemas/0.7/odata.json",
3+
"$schema": "http://json-schema.org/draft-07/schema#",
4+
"description": "Serverless Workflow specification - OData command options schema",
5+
"type": "object",
6+
"key": {
7+
"type": "string",
8+
"description": "The unique identifier of the single entry to query",
9+
"minLength": 1
10+
},
11+
"queryOptions":{
12+
"$ref": "#/definitions/queryoptions"
13+
},
14+
"definitions": {
15+
"queryoptions": {
16+
"type": "object",
17+
"properties": {
18+
"filter": {
19+
"type": "string",
20+
"description": "The $filter system query option allows clients to filter the set of resources that are addressed by a request URL. $filter specifies conditions that MUST be met by a resource for it to be returned in the set of matching resources",
21+
"minLength": 1
22+
},
23+
"expand": {
24+
"type": "string",
25+
"description": "The $expand system query option allows clients to request related resources when a resource that satisfies a particular request is retrieved",
26+
"minLength": 1
27+
},
28+
"select": {
29+
"type": "string",
30+
"description": "The $select system query option allows clients to requests a limited set of information for each entity or complex type identified by the ResourcePath and other System Query Options like $filter, $top, $skip etc. The $select query option is often used in conjunction with the $expand query option, to first increase the scope of the resource graph returned ($expand) and then selectively prune that resource graph ($select)",
31+
"minLength": 1
32+
},
33+
"orderBy": {
34+
"type": "string",
35+
"description": "The $orderby system query option allows clients to request resource in a particular order",
36+
"minLength": 1
37+
},
38+
"top": {
39+
"type": "integer",
40+
"description": "The $top system query option allows clients a required number of resources. Usually used in conjunction with the $skip query options",
41+
"minLength": 1
42+
},
43+
"skip": {
44+
"type": "integer",
45+
"description": "The $skip system query option allows clients to skip a given number of resources. Usually used in conjunction with the $top query options",
46+
"minLength": 1
47+
},
48+
"count": {
49+
"type": "boolean",
50+
"description": "The $count system query option allows clients to request a count of the matching resources included with the resources in the response"
51+
},
52+
"search": {
53+
"type": "string",
54+
"description": "The $search system query option allows clients to request items within a collection matching a free-text search expression",
55+
"minLength": 1
56+
},
57+
"format": {
58+
"type": "string",
59+
"description": "The $format system query option if supported allows clients to request a response in a particular format",
60+
"minLength": 1
61+
},
62+
"compute": {
63+
"type": "string",
64+
"description": "The $compute system query option allows clients to define computed properties that can be used in a $select or within a $filter or $orderby expression.",
65+
"minLength": 1
66+
},
67+
"index": {
68+
"type": "string",
69+
"description": "The $index system query option allows clients to do a positional insert into a collection annotated with using the Core.PositionalInsert term (see http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#VocCore)",
70+
"minLength": 1
71+
},
72+
"schemaVersion": {
73+
"type": "string",
74+
"description": "The $schemaversion system query option allows clients to specify the version of the schema against which the request is made. The semantics of $schemaversion is covered in the OData-Protocol (http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#odata) document.",
75+
"minLength": 1
76+
}
77+
},
78+
"additionalProperties": false
79+
}
80+
}
81+
}

specification.md

Lines changed: 68 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@
2323
+ [Using multiple data filters](#using-multiple-data-filters)
2424
+ [Data Merging](#data-merging)
2525
* [Workflow Functions](#workflow-functions)
26-
+ [Using Functions For RESTful Service Invocations](#using-functions-for-restful-service-invocations)
27-
+ [Using Functions For RPC Service Invocations](#using-functions-for-rpc-service-invocations)
28-
+ [Using Functions For GraphQL Service Invocations](#using-functions-for-graphql-service-invocations)
26+
+ [Using Functions for RESTful Service Invocations](#using-functions-for-restful-service-invocations)
27+
+ [Using Functions for RPC Service Invocations](#using-functions-for-rpc-service-invocations)
28+
+ [Using Functions for GraphQL Service Invocations](#using-functions-for-graphql-service-invocations)
2929
- [Invoking a GraphQL `Query`](#invoking-a-graphql-query)
3030
- [Invoking a GraphQL `Mutation`](#invoking-a-graphql-mutation)
31-
+ [Using Functions For Expression Evaluation](#using-functions-for-expression-evaluation)
31+
+ [Using Functions for OData Service Invocations](#using-functions-for-odata-service-invocations)
32+
- [Creating an OData Function Definition](#creating-an-odata-function-definition)
33+
- [Invoking an OData Function Definition](#invoking-an-odata-function-definition)
34+
+ [Using Functions for Expression Evaluation](#using-functions-for-expression-evaluation)
3235
* [Workflow Expressions](#workflow-expressions)
3336
* [Workflow Definition Structure](#workflow-definition-structure)
3437
+ [Workflow States](#workflow-states)
@@ -1029,7 +1032,7 @@ Reference the following sections to learn more about workflow functions:
10291032
* [Using functions for GraphQL service invocation](#Using-Functions-For-GraphQL-Service-Invocations)
10301033
* [Using functions for expression evaluations](#Using-Functions-For-Expression-Evaluation)
10311034

1032-
#### Using Functions For RESTful Service Invocations
1035+
#### Using Functions for RESTful Service Invocations
10331036

10341037
[Functions](#Function-Definition) can be used to describe services and their operations that need to be invoked during
10351038
workflow execution. They can be referenced by states [action definitions](#Action-Definition) to clearly
@@ -1086,7 +1089,7 @@ Note that the referenced function definition type in this case must be `rest` (d
10861089

10871090
For more information about functions, reference the [Functions definitions](#Function-Definition) section.
10881091

1089-
#### Using Functions For RPC Service Invocations
1092+
#### Using Functions for RPC Service Invocations
10901093

10911094
Similar to defining invocations of operations on RESTful services, you can also use the workflow
10921095
[functions definitions](#Function-Definition) that follow the remote procedure call (RPC) protocol.
@@ -1149,7 +1152,7 @@ Note that the referenced function definition type in this case must be `rpc`.
11491152

11501153
For more information about functions, reference the [Functions definitions](#Function-Definition) section.
11511154

1152-
#### Using Functions For GraphQL Service Invocations
1155+
#### Using Functions for GraphQL Service Invocations
11531156

11541157
If you want to use GraphQL services, you can also invoke them using a similar syntax to the above methods.
11551158

@@ -1294,9 +1297,60 @@ Note that GraphQL Subscriptions are not supported at this time.
12941297

12951298
For more information about functions, reference the [Functions definitions](#Function-Definition) section.
12961299

1297-
#### Using Functions For Expression Evaluation
1300+
#### Using Functions for OData Service Invocations
12981301

1299-
In addition to defining RESTful, RPC and GraphQL services and their operations, workflow [functions definitions](#Function-Definition)
1302+
Similar to defining invocations of operations on GraphQL services, you can also use workflow
1303+
[Functions Definitions](#Function-Definition) to execute complex queries on an [OData](https://www.odata.org/documentation/) service.
1304+
1305+
##### Creating an OData Function Definition
1306+
1307+
We start off by creating a workflow [Functions Definitions](#Function-Definition). For example:
1308+
1309+
1310+
```json
1311+
{
1312+
"functions": [
1313+
{
1314+
"name": "queryPersons",
1315+
"operation": "https://services.odata.org/V3/OData/OData.svc#Persons",
1316+
"type": "odata"
1317+
}
1318+
]
1319+
}
1320+
```
1321+
1322+
Note that the `operation` property must follow the following format:
1323+
1324+
```text
1325+
<URI_to_odata_service>#<Entity_Set_Name>
1326+
```
1327+
1328+
##### Invoking an OData Function Definition
1329+
1330+
In order to invoke the defined [OData](https://www.odata.org/documentation/) function,
1331+
simply reference it in a workflow [Action Definition](#Action-Definition) and set its function arguments. For example:
1332+
1333+
```json
1334+
{
1335+
"refName": "queryPersons",
1336+
"arguments": {
1337+
"queryOptions":{
1338+
"expand": "PersonDetail/Person",
1339+
"select": "Id, PersonDetail/Person/Name",
1340+
"top": 5,
1341+
"orderby": "PersonDetail/Person/Name"
1342+
}
1343+
}
1344+
}
1345+
```
1346+
1347+
In order to ensure compatibility of OData support across runtimes,
1348+
the`arguments` property of an [OData](https://www.odata.org/documentation/) function reference
1349+
should follow the Serverless Workflow [OData Json schema](https://github.com/serverlessworkflow/specification/tree/main/schema/odata.json)
1350+
1351+
#### Using Functions for Expression Evaluation
1352+
1353+
In addition to defining RESTful, RPC, GraphQL and OData services and their operations, workflow [functions definitions](#Function-Definition)
13001354
can also be used to define expressions that should be evaluated during workflow execution.
13011355

13021356
Defining expressions as part of function definitions has the benefit of being able to reference
@@ -2969,8 +3023,8 @@ section.
29693023
| Parameter | Description | Type | Required |
29703024
| --- | --- | --- | --- |
29713025
| name | Unique function name | string | yes |
2972-
| operation | If type is `rest`, <path_to_openapi_definition>#<operation_id>. If type is `rpc`, <path_to_grpc_proto_file>#<service_name>#<service_method>. If type is `graphql`, <url_to_graphql_endpoint>#<literal \"mutation\" or \"query\">#<query_or_mutation_name>. If type is `expression`, defines the workflow expression. | string | no |
2973-
| type | Defines the function type. Is either `rest`, `rpc` or `expression`. Default is `rest` | enum | no |
3026+
| operation | If type is `rest`, <path_to_openapi_definition>#<operation_id>. If type is `rpc`, <path_to_grpc_proto_file>#<service_name>#<service_method>. If type is `graphql`, <url_to_graphql_endpoint>#<literal \"mutation\" or \"query\">#<query_or_mutation_name>. If type is `odata`, <URI_to_odata_service>#<Entity_Set_Name>. If type is `expression`, defines the workflow expression. | string | no |
3027+
| type | Defines the function type. Is either `rest`, `rpc`, `odata` or `expression`. Default is `rest` | enum | no |
29743028
| authRef | References an [auth definition](#Auth-Definition) name to be used to access to resource defined in the operation parameter | string | no |
29753029
| [metadata](#Workflow-Metadata) | Metadata information. Can be used to define custom function information | object | no |
29763030

@@ -3017,7 +3071,9 @@ Depending on the function `type`, the `operation` property can be:
30173071
* If `type` is `rpc`, a combination of the gRPC proto document URI and the particular service name and service method name that needs to be invoked, separated by a '#'.
30183072
For example `file://myuserservice.proto#UserService#ListUsers`.
30193073
* If `type` is `graphql`, a combination of the GraphQL schema definition URI and the particular service name and service method name that needs to be invoked, separated by a '#'.
3020-
For example `file://myuserservice.proto#UserService#ListUsers`.
3074+
For example `file://myuserservice.proto#UserService#ListUsers`.
3075+
* If `type` is `odata`, a combination of the GraphQL schema definition URI and the particular service name and service method name that needs to be invoked, separated by a '#'.
3076+
For example `https://https://services.odata.org/V3/OData/OData.svc#Products`.
30213077
* If `type` is `expression`, defines the expression syntax. Take a look at the [workflow expressions section](#Workflow-Expressions) for more information on this.
30223078

30233079
The `authRef` property references a name of a defined workflow [auth definition](#Auth-Definition).

0 commit comments

Comments
 (0)