Help Center> FunctionGraph> CLI Reference> Invoking a Function
Updated on 2023-06-25 GMT+08:00

Invoking a Function

Before invoking a function, obtain the URN, as shown in Figure 1.

Figure 1 Obtaining a function URN

Synchronous Invocation

The following is an example command for synchronous invocation. For details about the parameters, see Table 1.

hcloud FunctionGraph InvokeFunction --cli-region="ap-southeast-1" --X-Cff-Log-Type="tail" --X-CFF-Request-Version="v1" --function_urn="urn:fss:cn-east-3:******:function:default:hcloud-invoke:latest" --project_id="******" --key="value"
Table 1 Parameter description

Parameter

Mandatory

Description

--cli-region

Yes

Region where the target function is located.

--function_urn

Yes

Function URN.

--project_id

Yes

Project ID.

--X-Cff-Log-Type

No

Options: tail (4 KB logs will be returned in the header) and null (no logs will be returned).

X-CFF-Request-Version

No

Response body format. Options:

  • v0: text format.
  • v1: JSON format. Use this format when using an SDK.

Body

Yes

Request body in --key="value" format. The JSON structure is {"key":"value"}.

Figure 2 shows the output result. For details about the response parameters, see Table 2.

Figure 2 Output result
Table 2 Response parameters

Parameter

Type

Description

request_id

String

Request ID.

result

String

Execution result.

log

String

Execution log.

status

Integer

Execution status.

error_code

String

Error code.

Asynchronous Invocation

The following is an example command for asynchronous invocation. For details about the parameters, see Table 3.

hcloud FunctionGraph AsyncInvokeFunction --cli-region="cn-east-3" --function_urn="urn:fss:cn-east-3:******:function:default:hcloud-invoke:latest" --project_id="******" --key="value"
Table 3 Parameter description

Parameter

Mandatory

Description

--cli-region

Yes

Region where the target function is located.

--function_urn

Yes

Function URN.

--project_id

Yes

Project ID.

Body

Yes

Request body in --key="value" format. The JSON structure is { "key":"value"}.

Figure 3 shows the output result. For details about the response parameters, see Table 2.

Figure 3 Output result
Table 4 Response parameters

Parameter

Type

Description

request_id

String

Request ID.