Modifying Metadata of a Flow Instance
Function
This API is used to modify the instance metadata of a flow.
Calling Method
For details, see Calling APIs.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions. For details about the required permissions, see Permissions Policies and Supported Actions.
URI
PUT /v2/{project_id}/fgs/workflows/{workflow_id}
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Definition Project ID. For details, see Obtaining a Project ID. Constraints N/A. Range The value contains 32 characters. Only letters and digits are allowed. Default Value N/A. |
| workflow_id | Yes | String | Definition Flow ID. Constraints N/A. Range 1 to 512 characters Default Value N/A. |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | Yes | String | Definition Name of a flow. Constraints ^([_a-zA-Z0-9().-]|[\u4e00-\u9fa5]){1,64}$ Range 1 to 64 characters Default Value N/A. |
| description | No | String | Definition Flow description. Constraints ^([_a-zA-Z0-9().-]|[\u4e00-\u9fa5]){1,512}$ Range 1 to 512 characters Default Value N/A. |
| start | Yes | String | Definition ID of the start node in a flow. Constraints N/A. Range 1 to 256 characters Default Value N/A. |
| triggers | No | Array of Trigger objects | Definition List of triggers in a flow. Constraints N/A. Range 0 to 200 triggers Default Value N/A. |
| functions | Yes | Array of Function objects | Definition List of functions in a flow. Constraints N/A. Range 0 to 100 functions Default Value N/A. |
| states | Yes | Array of OperationState objects | Definition List of nodes in a flow. Constraints N/A. Range 1 to 100 nodes Default Value N/A. |
| constants | Yes | Object | Definition Flow constant. Constraints N/A. Range N/A. Default Value N/A. |
| retries | Yes | Array of Retry objects | Definition List of retry policies for a flow. Constraints N/A. Range 0 to 200 policies Default Value N/A. |
| mode | No | String | Definition Flow mode. The default mode is NORMAL. Constraints N/A. Range Default Value NORMAL |
| express_config | No | ExpressConfig object | Definition Express flow configuration. This parameter is required when mode is set to EXPRESS. |
| enterprise_project_id | No | String | Definition Enterprise project of a flow. Constraints N/A. Range 0 to 64 characters Default Value N/A. |
| enable_stream_response | No | Boolean | Definition Whether streaming response is supported. Constraints N/A. Range N/A. Default Value false |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| trigger_name | Yes | String | Definition Trigger name. Range N/A. |
| trigger_type | Yes | String | Definition Trigger type. Range |
| enabled | No | Boolean | Definition Whether to enable the trigger. Range N/A. |
| trigger_config | No | OBSTriggerConfig object | Definition OBS trigger configuration. Range N/A. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| bucket | Yes | String | Definition OBS bucket name. Range N/A. |
| events | Yes | Array of strings | Definition OBS event list. Range N/A. |
| prefix | Yes | String | Definition OBS object name prefix. Range N/A. |
| suffix | Yes | String | Definition OBS object name suffix. Range N/A. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | Yes | String | Definition Function name, which must be unique in a flow. Range N/A. |
| operation | Yes | String | Definition Function URN. Range N/A. |
| metadata | No | Object | Definition Extended information about the function, which is customized by users. Range N/A. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| action_mode | No | String | Definition Node execution mode. Range |
| actions | Yes | Array of Action objects | Definition Node execution actions. Range N/A. |
| on_errors | No | Array of OnError objects | Definition List of node execution error handling policies. Range N/A. |
| id | Yes | String | Definition Node ID, which is unique in a flow. Range N/A. |
| name | Yes | String | Definition Node name. Range N/A. |
| type | Yes | String | Definition Node type list. Range |
| end | Yes | Boolean | Definition Whether the node is an end node. Range N/A. |
| transition | Yes | String | Definition ID of the next node. Range N/A. |
| state_data_filter | No | StateDataFilter object | Definition Filter expression. Range N/A. |
| duration | No | Long | Definition Waiting time, in seconds. This parameter is mandatory and valid only when the node type is Sleep. Range N/A. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| function_ref | No | FunctionRef object | Definition Function invocation information. Range N/A. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| ref_name | Yes | String | Definition Function reference name, which must be the same as the name in the outer functions. Range N/A. |
| invoke_mode | No | String | Definition Function invocation mode. Currently, only synchronous invocation is supported. Range |
| arguments | Yes | Object | Definition Input parameter for function execution. Constants in constants can be referenced. Definition format: parameter path | constant value/constant path Parameter path: The JsonPath of the input parameter, for example, $.a.b[0].c. The constant value can be of the numeric, string (enclosed in single quotation marks), or Boolean type. The constant path is the JsonPath path of the constant, but the root node must be represented by $CONST, for example, $CONST.a.b. Range N/A. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| error | No | String | Definition Error matching expression, which is used to filter exceptions. Range N/A. |
| transition | No | String | Definition ID of the next node. Range N/A. |
| retry_ref | No | String | Definition Retry policy name. Range N/A. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| input | No | String | Definition Input filter expression (JSONPath). Range N/A. |
| output | No | String | Definition Output filter expression (JSONPath). Range N/A. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | Yes | String | Definition Retry policy name, which must be unique in a flow. Range N/A. |
| delay | No | Long | Definition Retry interval, in seconds. If the parameter is not set, the value is 1 by default. Range N/A. |
| max_attempts | No | Long | Definition Maximum number of retry times. If this parameter is not set, the default value 3 is used. Range N/A. |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| id | String | Definition Flow ID. Range N/A. |
| workflow_urn | String | Definition Flow URN. The format is as follows: urn:fss:<region_id>:<project_id>:workflow:<package>:<workflow_name>:<version> Notes: Currently, only default is supported for package. Currently, only latest is supported for version. Range N/A. |
| name | String | Definition Flow name. Range N/A. |
| description | String | Definition Flow description. Range N/A. |
| created_time | String | Definition Flow creation time. Range Format: yyyy-MM-ddTHH:mm:ssZ (UTC time) |
| updated_time | String | Definition Flow modification time. Range Format: yyyy-MM-ddTHH:mm:ssZ (UTC time) |
| created_by | String | Definition Flow creator Range N/A. |
| enable_stream_response | Boolean | Definition Whether the flow supports streaming response. Range N/A. |
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Error code. |
| error_msg | String | Error description. |
| request_id | String | Request ID. |
Status code: 500
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Error code. |
| error_msg | String | Error description. |
| request_id | String | Request ID. |
Example Requests
Modify the metadata of function flow {workflow_id}.
PUT /v2/{project_id}/fgs/workflows/{workflow_id}
{
"name" : "workflow_test",
"start" : "test",
"functions" : [ {
"name" : "test",
"operation" : "urn:fss:{region}:c53626012ba84727b938ca8bf03108ef:test:latest"
} ],
"constants" : { },
"states" : [ {
"id" : "test",
"name" : "test",
"type" : "Operation",
"end" : false,
"transition" : "end",
"actions" : [ {
"function_ref" : {
"ref_name" : "test",
"arguments" : {
"execution_name" : "$.test"
}
}
} ]
}, {
"id" : "end",
"name" : "end",
"type" : "End",
"end" : true,
"transition" : "",
"state_data_filter" : {
"input" : "",
"output" : ""
},
"actions" : [ ]
} ],
"retries" : [ {
"name" : "test"
} ]
} Example Responses
Status code: 200
{
"id" : "48aff955-ea10-4ffd-b426-190bc192dc14",
"workflow_urn" : "urn:fss:cn-north-7:73d69ae0cfcf460190522d060f05ad:workflow:default:testflow:latest",
"name" : "test-flow",
"description" : "desc",
"created_time" : "2021-01-01T00:00:00Z",
"updated_time" : "2021-01-01T00:00:00Z",
"created_by" : "admin"
} SDK Sample Code
The SDK sample code is as follows.
Java
Modify the metadata of function flow {workflow_id}.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.functiongraph.v2.region.FunctionGraphRegion; import com.huaweicloud.sdk.functiongraph.v2.*; import com.huaweicloud.sdk.functiongraph.v2.model.*; import java.util.List; import java.util.ArrayList; public class UpdateWorkFlowSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); FunctionGraphClient client = FunctionGraphClient.newBuilder() .withCredential(auth) .withRegion(FunctionGraphRegion.valueOf("<YOUR REGION>")) .build(); UpdateWorkFlowRequest request = new UpdateWorkFlowRequest(); request.withWorkflowId("{workflow_id}"); WorkflowCreateBody body = new WorkflowCreateBody(); List<Retry> listbodyRetries = new ArrayList<>(); listbodyRetries.add( new Retry() .withName("test") ); StateDataFilter stateDataFilterStates = new StateDataFilter(); stateDataFilterStates.withInput("") .withOutput(""); FunctionRef functionRefActions = new FunctionRef(); functionRefActions.withRefName("test") .withArguments("{\"execution_name\":\"$.test\"}"); List<Action> listStatesActions = new ArrayList<>(); listStatesActions.add( new Action() .withFunctionRef(functionRefActions) ); List<OperationState> listbodyStates = new ArrayList<>(); listbodyStates.add( new OperationState() .withActions(listStatesActions) .withId("test") .withName("test") .withType(OperationState.TypeEnum.fromValue("Operation")) .withEnd(false) .withTransition("end") ); listbodyStates.add( new OperationState() .withActions() .withId("end") .withName("end") .withType(OperationState.TypeEnum.fromValue("End")) .withEnd(true) .withTransition("") .withStateDataFilter(stateDataFilterStates) ); List<Function> listbodyFunctions = new ArrayList<>(); listbodyFunctions.add( new Function() .withName("test") .withOperation("urn:fss:{region}:c53626012ba84727b938ca8bf03108ef:test:latest") ); body.withRetries(listbodyRetries); body.withConstants(new Object()); body.withStates(listbodyStates); body.withFunctions(listbodyFunctions); body.withStart("test"); body.withName("workflow_test"); request.withBody(body); try { UpdateWorkFlowResponse response = client.updateWorkFlow(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
Python
Modify the metadata of function flow {workflow_id}.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | # coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkfunctiongraph.v2.region.functiongraph_region import FunctionGraphRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkfunctiongraph.v2 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = FunctionGraphClient.new_builder() \ .with_credentials(credentials) \ .with_region(FunctionGraphRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateWorkFlowRequest() request.workflow_id = "{workflow_id}" listRetriesbody = [ Retry( name="test" ) ] stateDataFilterStates = StateDataFilter( input="", output="" ) functionRefActions = FunctionRef( ref_name="test", arguments="{\"execution_name\":\"$.test\"}" ) listActionsStates = [ Action( function_ref=functionRefActions ) ] listStatesbody = [ OperationState( actions=listActionsStates, id="test", name="test", type="Operation", end=False, transition="end" ), OperationState( id="end", name="end", type="End", end=True, transition="", state_data_filter=stateDataFilterStates ) ] listFunctionsbody = [ Function( name="test", operation="urn:fss:{region}:c53626012ba84727b938ca8bf03108ef:test:latest" ) ] request.body = WorkflowCreateBody( retries=listRetriesbody, constants={}, states=listStatesbody, functions=listFunctionsbody, start="test", name="workflow_test" ) response = client.update_work_flow(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
Go
Modify the metadata of function flow {workflow_id}.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" functiongraph "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/functiongraph/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/functiongraph/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/functiongraph/v2/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth, err := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). SafeBuild() if err != nil { fmt.Println(err) return } hcClient, err := functiongraph.FunctionGraphClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). SafeBuild() if err != nil { fmt.Println(err) return } client := functiongraph.NewFunctionGraphClient(hcClient) request := &model.UpdateWorkFlowRequest{} request.WorkflowId = "{workflow_id}" var listRetriesbody = []model.Retry{ { Name: "test", }, } inputStateDataFilter:= "" outputStateDataFilter:= "" stateDataFilterStates := &model.StateDataFilter{ Input: &inputStateDataFilter, Output: &outputStateDataFilter, } var argumentsFunctionRef interface{} = "{\"execution_name\":\"$.test\"}" functionRefActions := &model.FunctionRef{ RefName: "test", Arguments: &argumentsFunctionRef, } var listActionsStates = []model.Action{ { FunctionRef: functionRefActions, }, } var listStatesbody = []model.OperationState{ { Actions: listActionsStates, Id: "test", Name: "test", Type: model.GetOperationStateTypeEnum().OPERATION, End: false, Transition: "end", }, { Id: "end", Name: "end", Type: model.GetOperationStateTypeEnum().END, End: true, Transition: "", StateDataFilter: stateDataFilterStates, }, } var listFunctionsbody = []model.Function{ { Name: "test", Operation: "urn:fss:{region}:c53626012ba84727b938ca8bf03108ef:test:latest", }, } var constantsWorkflowCreateBody interface{} = make(map[string]string) request.Body = &model.WorkflowCreateBody{ Retries: listRetriesbody, Constants: &constantsWorkflowCreateBody, States: listStatesbody, Functions: listFunctionsbody, Start: "test", Name: "workflow_test", } response, err := client.UpdateWorkFlow(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
More
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
Status Codes
| Status Code | Description |
|---|---|
| 200 | Success |
| 400 | Bad Request |
| 500 | Internal Server Error |
Error Codes
See Error Codes.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot