Skip to content

Commit 3a7bbeb

Browse files
junweid62Junwei Daikolchfa-awsnatebower
authored
Add Documentation for wait_for_completion_timeout Parameter (opensearch-project#9138)
* Edit create workflow and provision workflow page , add wait for time completion param description Signed-off-by: Junwei Dai <[email protected]> * Doc review Signed-off-by: Fanit Kolchina <[email protected]> * Apply suggestions from code review Co-authored-by: Nathan Bower <[email protected]> Signed-off-by: kolchfa-aws <[email protected]> --------- Signed-off-by: Junwei Dai <[email protected]> Signed-off-by: Fanit Kolchina <[email protected]> Signed-off-by: kolchfa-aws <[email protected]> Co-authored-by: Junwei Dai <[email protected]> Co-authored-by: Fanit Kolchina <[email protected]> Co-authored-by: kolchfa-aws <[email protected]> Co-authored-by: Nathan Bower <[email protected]>
1 parent 1eb2407 commit 3a7bbeb

File tree

2 files changed

+95
-10
lines changed

2 files changed

+95
-10
lines changed

_automating-configurations/api/create-workflow.md

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,24 @@ PUT /_plugins/_flow_framework/workflow/<workflow_id>?reprovision=true
8484
You can add new steps to the workflow but cannot delete them. Only index setting, search pipeline, and ingest pipeline steps can currently be updated.
8585
{: .note}
8686

87+
To control how long the request waits for the provisioning and reprovisioning process to complete, use the `wait_for_completion_timeout` parameter:
88+
89+
```json
90+
POST /_plugins/_flow_framework/workflow/?provision=true&wait_for_completion_timeout=2s
91+
```
92+
{% include copy-curl.html %}
93+
94+
```json
95+
PUT /_plugins/_flow_framework/workflow/<workflow_id>/?reprovision=true&wait_for_completion_timeout=2s
96+
```
97+
{% include copy-curl.html %}
98+
99+
If the operation does not complete within the specified amount of time, the response returns the current workflow status while execution continues asynchronously.
100+
101+
The `wait_for_completion_timeout` parameter can only be used when either `provision` or `reprovision` is set to `true`
102+
{: .note}
103+
104+
For example, the following request provisions a workflow and waits for up to 2 seconds for completion:
87105
You can create and provision a workflow using a [workflow template]({{site.url}}{{site.baseurl}}/automating-configurations/workflow-templates/) as follows:
88106

89107
```json
@@ -96,14 +114,15 @@ POST /_plugins/_flow_framework/workflow?use_case=<use_case>&provision=true
96114

97115
The following table lists the available query parameters. All query parameters are optional. User-provided parameters are only allowed if the `provision` parameter is set to `true`.
98116

99-
| Parameter | Data type | Description |
100-
| :--- | :--- | :--- |
101-
| `provision` | Boolean | Whether to provision the workflow as part of the request. Default is `false`. |
102-
| `update_fields` | Boolean | Whether to update only the fields included in the request body. Default is `false`. |
103-
| `reprovision` | Boolean | Whether to reprovision the entire template if it has already been provisioned. A complete template must be provided in the request body. Default is `false`. |
104-
| `validation` | String | Whether to validate the workflow. Valid values are `all` (validate the template) and `none` (do not validate the template). Default is `all`. |
105-
| `use_case` | String | The name of the [workflow template]({{site.url}}{{site.baseurl}}/automating-configurations/workflow-templates/#supported-workflow-templates) to use when creating the workflow. |
106-
| User-provided substitution expressions | String | Parameters matching substitution expressions in the template. Only allowed if `provision` is set to `true`. Optional. If `provision` is set to `false`, you can pass these parameters in the [Provision Workflow API query parameters]({{site.url}}{{site.baseurl}}/automating-configurations/api/provision-workflow/#query-parameters). |
117+
| Parameter | Data type | Description |
118+
|:---------------------------------------|:----------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
119+
| `provision` | Boolean | Whether to provision the workflow as part of the request. Default is `false`. |
120+
| `update_fields` | Boolean | Whether to update only the fields included in the request body. Default is `false`. |
121+
| `reprovision` | Boolean | Whether to reprovision the entire template if it has already been provisioned. A complete template must be provided in the request body. Default is `false`. |
122+
| `validation` | String | Whether to validate the workflow. Valid values are `all` (validate the template) and `none` (do not validate the template). Default is `all`. |
123+
| `use_case` | String | The name of the [workflow template]({{site.url}}{{site.baseurl}}/automating-configurations/workflow-templates/#supported-workflow-templates) to use when creating the workflow. |
124+
| `wait_for_completion_timeout` | Time value | Specifies the maximum wait time for synchronous provisioning or reprovisioning. If the timeout is exceeded, the request returns the current workflow status while execution continues asynchronously.|
125+
| User-provided substitution expressions | String | Parameters matching substitution expressions in the template. Only allowed if `provision` is set to `true`. Optional. If `provision` is set to `false`, you can pass these parameters in the [Provision Workflow API query parameters]({{site.url}}{{site.baseurl}}/automating-configurations/api/provision-workflow/#query-parameters). |
107126

108127
## Request body fields
109128

@@ -291,4 +310,33 @@ OpenSearch responds with the `workflow_id`:
291310
}
292311
```
293312

294-
Once you have created a workflow, you can use other workflow APIs with the `workflow_id`.
313+
Once you have created a workflow, you can use other workflow APIs with the `workflow_id`.
314+
315+
#### Example response with wait_for_completion_timeout enabled
316+
317+
```json
318+
{
319+
"workflow_id": "K13IR5QBEpCfUu_-AQdU",
320+
"state": "COMPLETED",
321+
"resources_created": [
322+
{
323+
"workflow_step_name": "create_connector",
324+
"workflow_step_id": "create_connector_1",
325+
"resource_id": "LF3IR5QBEpCfUu_-Awd_",
326+
"resource_type": "connector_id"
327+
},
328+
{
329+
"workflow_step_id": "register_model_2",
330+
"workflow_step_name": "register_remote_model",
331+
"resource_id": "L13IR5QBEpCfUu_-BQdI",
332+
"resource_type": "model_id"
333+
},
334+
{
335+
"workflow_step_name": "deploy_model",
336+
"workflow_step_id": "deploy_model_3",
337+
"resource_id": "L13IR5QBEpCfUu_-BQdI",
338+
"resource_type": "model_id"
339+
}
340+
]
341+
}
342+
```

_automating-configurations/api/provision-workflow.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ POST /_plugins/_flow_framework/workflow/<workflow_id>/_provision?<parameter>=<va
3939
| Parameter | Data type | Description |
4040
| :--- | :--- | :--- |
4141
| User-provided substitution expressions | String | Parameters matching substitution expressions in the template. Optional. |
42+
| `wait_for_completion_timeout` | TimeValue | Specifies the maximum wait time for synchronous provisioning. If the timeout is exceeded, the request returns the current workflow status while execution continues asynchronously.|
4243

4344
#### Example requests
4445

@@ -47,6 +48,13 @@ POST /_plugins/_flow_framework/workflow/8xL8bowB8y25Tqfenm50/_provision
4748
```
4849
{% include copy-curl.html %}
4950

51+
The following request performs a synchronous provisioning call, waiting for up to 2 seconds for completion:
52+
53+
```json
54+
POST /_plugins/_flow_framework/workflow/<workflow_id>/_provision&wait_for_completion_timeout=2s
55+
```
56+
{% include copy-curl.html %}
57+
5058
The following request substitutes the expression {% raw %}`${{ openai_key }}`{% endraw %} with the value "12345" using a query parameter:
5159

5260
```json
@@ -74,4 +82,33 @@ OpenSearch responds with the same `workflow_id` that was used in the request:
7482
}
7583
```
7684

77-
To obtain the provisioning status, query the [Get Workflow State API]({{site.url}}{{site.baseurl}}/automating-configurations/api/get-workflow-status/).
85+
To obtain the provisioning status, call the [Get Workflow State API]({{site.url}}{{site.baseurl}}/automating-configurations/api/get-workflow-status/).
86+
87+
#### Example response with wait_for_completion_timeout enabled
88+
89+
```json
90+
{
91+
"workflow_id": "K13IR5QBEpCfUu_-AQdU",
92+
"state": "COMPLETED",
93+
"resources_created": [
94+
{
95+
"workflow_step_name": "create_connector",
96+
"workflow_step_id": "create_connector_1",
97+
"resource_id": "LF3IR5QBEpCfUu_-Awd_",
98+
"resource_type": "connector_id"
99+
},
100+
{
101+
"workflow_step_id": "register_model_2",
102+
"workflow_step_name": "register_remote_model",
103+
"resource_id": "L13IR5QBEpCfUu_-BQdI",
104+
"resource_type": "model_id"
105+
},
106+
{
107+
"workflow_step_name": "deploy_model",
108+
"workflow_step_id": "deploy_model_3",
109+
"resource_id": "L13IR5QBEpCfUu_-BQdI",
110+
"resource_type": "model_id"
111+
}
112+
]
113+
}
114+
```

0 commit comments

Comments
 (0)