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
Copy file name to clipboardExpand all lines: roadmap/README.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -35,8 +35,8 @@ _Status description:_
35
35
| ✔️| Apply fixes to auth spec schema [workflow schema](https://github.com/serverlessworkflow/specification/tree/main/schema)|
36
36
| ✔️| Update the `dataInputSchema` top-level property by supporting the assignment of a JSON schema object [workflow schema](https://github.com/serverlessworkflow/specification/tree/main/specification.md#workflow-definition-structure)|
37
37
| ✔️| Add the new `WORKFLOW` reserved keyword to workflow expressions |
38
+
| ✔️| Add the new `http` function type [spec doc](https://github.com/serverlessworkflow/specification/tree/main/specification.md#using-functions-for-http-service-invocations)|
Copy file name to clipboardExpand all lines: schema/functions.json
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -36,14 +36,15 @@
36
36
},
37
37
"operation": {
38
38
"type": "string",
39
-
"description": "If type is `rest`, <path_to_openapi_definition>#<operation_id>. If type is `asyncapi`, <path_to_asyncapi_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.",
39
+
"description": "If type is `rest`, <path_to_openapi_definition>#<operation_id>. If type is `asyncapi`, <path_to_asyncapi_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. If type is `http`, <HTTP_method>#<request_target>",
40
40
"minLength": 1
41
41
},
42
42
"type": {
43
43
"type": "string",
44
-
"description": "Defines the function type. Is either `rest`, `asyncapi, `rpc`, `graphql`, `odata`, `expression`, or `custom`. Default is `rest`",
44
+
"description": "Defines the function type. Is either `rest`, `http`,`asyncapi, `rpc`, `graphql`, `odata`, `expression`, or `custom`. Default is `rest`",
+[Using multiple data filters](#using-multiple-data-filters)
24
24
+[Data Merging](#data-merging)
25
25
*[Workflow Functions](#workflow-functions)
26
-
+[Using Functions for RESTful Service Invocations](#using-functions-for-restful-service-invocations)
26
+
+[Using Functions for OpenAPI RESTFul Service Invocations](#using-functions-for-openapi-restful-service-invocations)
27
+
+[Using Functions for HTTP Service Invocations](#using-functions-for-http-service-invocations)
27
28
+[Using Functions for Async API Service Invocations](#using-functions-for-async-api-service-invocations)
28
-
+[Using Functions for RPC Service Invocations](#using-functions-for-rpc-service-invocations)
29
+
+[Using Functions for gRPC Service Invocations](#using-functions-for-grpc-service-invocations)
29
30
+[Using Functions for GraphQL Service Invocations](#using-functions-for-graphql-service-invocations)
30
31
-[Invoking a GraphQL `Query`](#invoking-a-graphql-query)
31
32
-[Invoking a GraphQL `Mutation`](#invoking-a-graphql-mutation)
@@ -991,8 +992,9 @@ They can be referenced by their domain-specific names inside workflow [states](#
991
992
992
993
Reference the following sections to learn more about workflow functions:
993
994
994
-
* [Using functions for RESTful service invocations](#Using-Functions-for-RESTful-Service-Invocations)
995
-
* [Using Functions for Async API Service Invocations](#Using-Functions-for-Async-API-Service-Invocations)
995
+
* [Using functions for OpenAPI RESTful service invocations](#using-functions-for-openapi-restful-service-invocations)
996
+
+ [Using functions for HTTP Service Invocations](#using-functions-for-http-service-invocations)
997
+
* [Using functions for Async API Service Invocations](#Using-Functions-for-Async-API-Service-Invocations)
996
998
* [Using functions for gRPC service invocation](#Using-Functions-For-RPC-Service-Invocations)
997
999
* [Using functions for GraphQL service invocation](#Using-Functions-For-GraphQL-Service-Invocations)
998
1000
* [Using Functions for OData Service Invocations](#Using-Functions-for-OData-Service-Invocations)
@@ -1002,7 +1004,7 @@ Reference the following sections to learn more about workflow functions:
1002
1004
We can define if functions are invoked sync or async. Reference
1003
1005
the [functionRef](#FunctionRef-Definition) to learn more on how to do this.
1004
1006
1005
-
#### Using Functions for RESTful Service Invocations
1007
+
#### Using Functions for OpenAPI RESTful Service Invocations
1006
1008
1007
1009
[Functions](#Function-Definition) can be used to describe services and their operations that need to be invoked during
1008
1010
workflow execution. They can be referenced by states [action definitions](#Action-Definition) to clearly
@@ -1059,6 +1061,162 @@ Note that the referenced function definition type in this case must be `rest` (d
1059
1061
1060
1062
For more information about functions, reference the [Functions definitions](#Function-Definition) section.
1061
1063
1064
+
#### Using functions for HTTP Service Invocations
1065
+
1066
+
The specification supports describing HTTP invocations via a simplified interface in the [functions definition](#Function-Definition).
1067
+
1068
+
Here is an example function definition for HTTP requests with method `GET` and request target corresponding with [URI Template](https://www.rfc-editor.org/rfc/rfc6570.html) `/users/{id}`:
1069
+
1070
+
```json
1071
+
{
1072
+
"functions":[
1073
+
{
1074
+
"name":"queryUserById",
1075
+
"operation":"GET#/users/{id}",
1076
+
"type":"http"
1077
+
}
1078
+
]
1079
+
}
1080
+
```
1081
+
1082
+
Note that the [Function Definition](#Function-Definition)'s `operation` property must have the following format:
1083
+
1084
+
```text
1085
+
<HTTP_method>#<request_target>
1086
+
```
1087
+
1088
+
* The HTTP method used by the HTTP invocation. Can be any [valid HTTP method](https://www.rfc-editor.org/rfc/rfc9110.html#name-method-definitions) such as `GET`, `POST`, `PUT`, etc.
1089
+
* The endpoint **location path** or the service full URL. Runtimes implementations are **discouraged** to expect the full URL in this field since this is a matter of infrastructure configuration.
1090
+
1091
+
The list below describes the HTTP function parameters in the `operation` attribute:
1092
+
1093
+
* Path parameters must be enclosed with braces (`{}`) as defined by [URI Templates](https://www.rfc-editor.org/rfc/rfc6570.html). The parameter name can be later referenced by the workflow states. For example: `/user/{id}`
1094
+
* [Query parameters](https://www.rfc-editor.org/rfc/rfc9110.html#section-4.2.2) must be enclosed with braces (`{}`) as defined by [URI Templates](https://www.rfc-editor.org/rfc/rfc6570.html). The parameter name can be later referenced by the workflow states. For example: `/user?status={status}`.
1095
+
1096
+
<!-- TODO: refine how we are going to describe http headers parameters -->
1097
+
Additional HTTP header fields can be passed via the `metadata` function definition. For example:
1098
+
1099
+
```json
1100
+
{
1101
+
"functions":[
1102
+
{
1103
+
"name":"queryUserById",
1104
+
"operation":"GET#/users/{id}",
1105
+
"type":"http",
1106
+
"metadata":{
1107
+
"x-custom-header":"the-value"
1108
+
}
1109
+
}
1110
+
]
1111
+
}
1112
+
```
1113
+
1114
+
> Since the data manipulated in the Serverless Workflow specification is primarly JSON, runtimes are encouraged to support at least `Content-Type: application/json` header field for HTTP requests.
1115
+
1116
+
Avoid passing sensitive information in headers such as authentication tokens. See the [auth definition](#auth-definition) for more information.
1117
+
1118
+
HTTP request content doesn't need to be described in the function definition. **All the data within the state** should be passed to the HTTP request. See the [action data filter](#action-data-filters) if you need to limit the amount of data passed to a given action.
1119
+
1120
+
The function can be referenced during workflow execution when the invocation of the HTTP service is desired. For example:
1121
+
1122
+
```json
1123
+
{
1124
+
"states":[
1125
+
{
1126
+
"name":"QueryUserInfo",
1127
+
"type":"operation",
1128
+
"actions":[
1129
+
{
1130
+
"functionRef":"queryUserById",
1131
+
"arguments":{
1132
+
"id":"${ .user.id }"
1133
+
}
1134
+
}
1135
+
],
1136
+
"end":true
1137
+
}
1138
+
]
1139
+
}
1140
+
```
1141
+
1142
+
Example of the `POST` request sending the state data as part of the body:
1143
+
1144
+
```json
1145
+
{
1146
+
"functions":[
1147
+
{
1148
+
"name":"createUser",
1149
+
"operation":"POST#/users",
1150
+
"type":"http"
1151
+
}
1152
+
]
1153
+
}
1154
+
```
1155
+
1156
+
Then you can reference the `createUser` function and filter the input data to invoke it.
In this case, only the contents of the `user` attribute will be passed to the function. The user ID returned by the HTTP request body will then be added to the state data:
#### Using Functions for Async API Service Invocations
1063
1221
1064
1222
[Functions](#Function-Definition) can be used to invoke PUBLISH and SUBSCRIBE operations on a message broker documented by the [Async API Specification](https://www.asyncapi.com/docs/specifications/v2.1.0).
@@ -1148,7 +1306,7 @@ Our defined function definition can then we referenced in a workflow [action](#A
1148
1306
}
1149
1307
```
1150
1308
1151
-
#### Using Functions for RPC Service Invocations
1309
+
#### Using Functions for gRPC Service Invocations
1152
1310
1153
1311
Similar to defining invocations of operations on RESTful services, you can also use the workflow
1154
1312
[functions definitions](#Function-Definition) that follow the remote procedure call (RPC) protocol.
@@ -1157,7 +1315,7 @@ a widely used RPC system.
1157
1315
gRPC uses [Protocol Buffers](https://developers.google.com/protocol-buffers/docs/overview) to define messages, services,
1158
1316
and the methods on those services that can be invoked.
1159
1317
1160
-
Let's look at an example of invoking a service method using RPC. For this example let's say we have the following
1318
+
Let's look at an example of invoking a service method using gRPC. For this example let's say we have the following
1161
1319
gRPC protocol buffer definition in a myuserservice.proto file:
1162
1320
1163
1321
```text
@@ -1409,7 +1567,7 @@ should follow the Serverless Workflow [OData Json schema](https://github.com/ser
1409
1567
1410
1568
#### Using Functions for Expression Evaluation
1411
1569
1412
-
In addition to defining RESTful, AsyncAPI, RPC, GraphQL and OData services and their operations, workflow [functions definitions](#Function-Definition)
1570
+
In addition to defining RESTful, AsyncAPI, gRPC, GraphQL and OData services and their operations, workflow [functions definitions](#Function-Definition)
1413
1571
can also be used to define expressions that should be evaluated during workflow execution.
1414
1572
1415
1573
Defining expressions as part of function definitions has the benefit of being able to reference
@@ -3189,11 +3347,24 @@ Note that `transition` and `end` properties are mutually exclusive, meaning that
3189
3347
| Parameter | Description | Type | Required |
3190
3348
| --- | --- | --- | --- |
3191
3349
| name | Unique function name | string | yes |
3192
-
| operation | If type is `rest`, <path_to_openapi_definition>#<operation_id>. If type is `asyncapi`, <path_to_asyncapi_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 | yes |
3193
-
| type | Defines the function type. Can be either `rest`, `asyncapi`, `rpc`, `graphql`, `odata`, `expression`, or [`custom`](#defining-custom-function-types). Default is `rest` | enum | no |
3350
+
| operation | See the table "Function Operation description by type" below. | string | yes |
3351
+
| type | Defines the function type. Can be either `rest`, `http`, `asyncapi`, `rpc`, `graphql`, `odata`, `expression`, or [`custom`](#defining-custom-function-types). Default is `rest` | enum | no |
3194
3352
| authRef | References an [auth definition](#Auth-Definition) name to be used to access to resource defined in the operation parameter | string | no |
3195
3353
| [metadata](#Workflow-Metadata) | Metadata information. Can be used to define custom function information | object | no |
0 commit comments