Updated on 2024-03-14 GMT+08:00

Querying Function Templates

Function

This API is used to query function templates.

URI

GET /v2/{project_id}/fgs/templates

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details, see Obtaining a Project ID.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

marker

No

String

Start position of the current query. The default value is 0.

Default: 0

Minimum: 1

Maximum: 64

maxitems

No

String

Maximum number of templates obtained in each query.

ispublic

No

String

Indicates whether the template is public.

runtime

No

String

Runtime template.

scene

No

String

Scenario template.

service

No

String

Cloud service template.

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Content-Type

Yes

String

Message body type (format).

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

func_templates

Array of ShowFunctionTemplateResponseBody objects

Function templates.

next_marker

Integer

Next read location.

Table 5 ShowFunctionTemplateResponseBody

Parameter

Type

Description

id

String

Template ID.

type

Integer

Template type.

title

String

Template title.

template_name

String

Template name.

description

String

Template description.

runtime

String

Template runtime.

handler

String

Template handler.

code_type

String

Code type.

code

String

Code file.

timeout

Integer

Maximum duration the function can be executed. Value range: 3s–259,200s.

memory_size

Integer

Memory size.

trigger_metadata_list

Array of TriggerMetadataList objects

Trigger information.

temp_detail

TempDetail object

user_data

String

User data.

encrypted_user_data

String

Encrypted user data.

dependencies

Array of strings

Dependencies required by the template.

scene

String

Template application scenarios.

service

String

Cloud service associated with the template.

Table 6 TriggerMetadataList

Parameter

Type

Description

trigger_name

String

Trigger name.

trigger_type

String

Trigger type.

event_type

String

Event type.

event_data

String

Event data.

Table 7 TempDetail

Parameter

Type

Description

input

String

Template input.

output

String

Template output.

warning

String

Warning.

Status code: 400

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 401

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 403

Table 10 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 500

Table 11 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Requests

Query 500 public function templates.

GET /v2/{project_id}/fgs/templates?marker=0&maxitems=500&ispublic=true

Example Responses

Status code: 200

OK

{
  "func_templates" : [ {
    "id" : "d3aa6e4c-xxxx-xxxx-9c09-5c50c4xxxxxx",
    "type" : 1,
    "title" : "access-service-with-http",
    "template_name" : "access-service-with-http-php",
    "description" : "access service with http.",
    "runtime" : "PHP7.3",
    "handler" : "index.handler",
    "code_type" : "inline",
    "code" : "xxxxx",
    "timeout" : 30,
    "memory_size" : 256,
    "trigger_metadata_list" : [ ],
    "temp_detail" : {
      "input" : "None",
      "output" : "execution succeed: Return to access service information through http/https,",
      "warning" : "1. configure the serveraddress environment variables."
    },
    "user_data" : "",
    "encrypted_user_data" : "",
    "dependencies" : [ ],
    "scene" : "basic_function_usage",
    "service" : "FunctionGraph"
  } ],
  "next_marker" : 1
}

Status Codes

Status Code

Description

200

OK

400

Bad request.

401

Unauthorized.

403

Forbidden.

500

Internal server error.

Error Codes

See Error Codes.