+ All Categories
Home > Documents > CLI Command Reference€¦ · FunctionGraph CLI Command Reference Issue 01 Date 2020-05-13 HUAWEI...

CLI Command Reference€¦ · FunctionGraph CLI Command Reference Issue 01 Date 2020-05-13 HUAWEI...

Date post: 20-Oct-2020
Category:
Upload: others
View: 28 times
Download: 0 times
Share this document with a friend
34
FunctionGraph CLI Command Reference Issue 01 Date 2020-09-28 HUAWEI TECHNOLOGIES CO., LTD.
Transcript
  • FunctionGraph

    CLI Command Reference

    Issue 01

    Date 2020-09-28

    HUAWEI TECHNOLOGIES CO., LTD.

  • Copyright © Huawei Technologies Co., Ltd. 2020. All rights reserved.

    No part of this document may be reproduced or transmitted in any form or by any means without priorwritten consent of Huawei Technologies Co., Ltd. Trademarks and Permissions

    and other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd.All other trademarks and trade names mentioned in this document are the property of their respectiveholders. NoticeThe purchased products, services and features are stipulated by the contract made between Huawei andthe customer. All or part of the products, services and features described in this document may not bewithin the purchase scope or the usage scope. Unless otherwise specified in the contract, all statements,information, and recommendations in this document are provided "AS IS" without warranties, guaranteesor representations of any kind, either express or implied.

    The information in this document is subject to change without notice. Every effort has been made in thepreparation of this document to ensure accuracy of the contents, but all statements, information, andrecommendations in this document do not constitute a warranty of any kind, express or implied.

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. i

  • Contents

    1 Introduction to CLI.................................................................................................................. 1

    2 Function-related Commands................................................................................................ 3

    3 Alias-related Commands..................................................................................................... 12

    4 Trigger-related Commands................................................................................................. 15

    5 Invocation Commands..........................................................................................................20

    6 Interactive Commands......................................................................................................... 22

    7 Function Importing and Exporting Commands..............................................................27

    8 Command Description..........................................................................................................30

    FunctionGraphCLI Command Reference Contents

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. ii

  • 1 Introduction to CLIFunctionGraph provides the command line interface (CLI) for you to managefunctions, triggers, and aliases, and invoke functions.

    CLI Download LinksCLI can run on a 64-bit Linux operating system (OS), 64-bit Windows OS, ormacOS. Table 1-1 provides the download links of CLI.

    Table 1-1 Download links of CLI

    OS Download Link MD5 Verification Code

    Linux CLI for Linux dc2df605fe463d315331ea2e53d9c12d

    Windows CLI for Windows 83647dc5381cd5f891f2444242279974

    macOS CLI for macOS 84b99b9023babe90a355319cdabb9bdc

    Toolkit DescriptionAfter downloading a CLI toolkit, decompress it. Files included in the toolkit arelisted in Table 1-2.

    Table 1-2 File description

    File Description

    config.yaml Configuration file. For details, see CLIConfiguration.

    fgs Executable file.

    README.md Description file.

    FunctionGraphCLI Command Reference 1 Introduction to CLI

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 1

    https://obs.cn-north-1.myhuaweicloud.com/functionstage-cli/fgs-cli-1.0.10_linux-x64.ziphttps://obs.cn-north-1.myhuaweicloud.com/functionstage-cli/fgs-cli-1.0.10_windows-x64.ziphttps://obs.cn-north-1.myhuaweicloud.com/functionstage-cli/fgs-cli-1.0.10_darwin-x64.zip

  • CLI ConfigurationBefore using CLI, configure the user information in the config.yaml file. Table 1-3describes the configuration options contained in this file.

    Table 1-3 Configuration options

    Option Description How to Obtain

    AccessKey Access key ID (AK). For details, see Access Keys.

    SecretKey Secret access key (SK). For details, see Access Keys.

    Timeout Timeout of CLIcommands. The defaultvalue is 30s and themaximum value is 90s.

    Set this parameter as required.

    CurrentRegion Default region of theservice connected to CLI.

    For details, see Availability Zone.

    ProjectName Name of the project towhich the service belongs.

    For details, see API Credentials.

    DomainName Domain name of theservice.

    The default value ismyhuaweicloud.com.

    RegionName Region name of theservice.

    The default value is cn-north-1.

    WARNING

    ● When you access HUAWEI CLOUD through an API, you must undergo AK/SKidentity authentication with the access request encrypted, and ensure that theaccess request is secret, complete, and correct. Properly keep the config.yamlfile to prevent unauthorized use of your access key.

    ● If your access key is used by an unauthorized person (due to a loss or leakage),you can delete the access key or notify the administrator of resetting it andconfigure it again.

    ● A deleted access key cannot be restored. Exercise caution when deleting theaccess key.

    PrecautionsThis document uses Linux as an example to describe all commands.

    FunctionGraphCLI Command Reference 1 Introduction to CLI

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 2

    https://support.huaweicloud.com/en-us/usermanual-ca/en-us_topic_0046606340.htmlhttps://support.huaweicloud.com/en-us/usermanual-ca/en-us_topic_0046606340.htmlhttps://developer.huaweicloud.com/en-us/endpointhttps://support.huaweicloud.com/en-us/usermanual-ca/ca_01_0002.html

  • 2 Function-related CommandsCreating a Function

    Run the create-function command to create a function. This command can betriggered using alias cf. The command syntax is as follows:

    fgs create-function --func-name --code-type --handler --runtime --file [(optional-flags)]

    Table 2-1 lists the options in this command.

    Table 2-1 Options in the command used for creating a function

    Option Abbreviation Description Mandatory

    --func-name value -n value Name of thefunction to becreated.

    Yes

    --code-type value -t value Code entry mode.Options: inline,zip, jar, and obs.

    Yes

    --handler value -p value Handler of thefunction.NOTE

    For a Go function,the initial of thehandler functionname must becapitalized.

    Yes

    FunctionGraphCLI Command Reference 2 Function-related Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 3

  • Option Abbreviation Description Mandatory

    --runtime value -r value Runtime, whichcan be Python 3.6,Python 2.7,Node.js 6.10,Node.js 8.10, Java8, Go 1.8, C# .NETCore 2.0, C# .NETCore 2.1, or PHP7.3.

    Yes

    --file value -f value Name of a codepackage. The sizeof the codepackage cannotexceed 50 MB.

    Yes

    --memory-sizevalue

    -m value Memory. Thedefault value is128 MB.

    No

    --timeout value -to value Timeout forfunctionexecution. Thedefault value is3s.

    No

    --code-url value -l value URL of a codepackage.

    No

    --descriptionvalue

    -d value Functiondescription.

    No

    --user-data value -u value Environmentvariable.

    No

    --xrole value -x value Agency. No

    --publish -pf Creates andpublishes thefunction.

    No

    NO TE

    If the function needs to invoke other cloud services, such as Distributed Message Service(DMS) and Data Ingestion Service (DIS), set the xrole parameter.

    The following is an example of creating a Python function with inline code:

    ./fgs cf -n clitest2 -t inline -c python.handler -r Python2.7 -f python_code.py -x servicestage_admin_trust

    The following in an example of creating a Java function:

    ./fgs cf -n clitest3 -t jar -c index.handler -r Java8 -f java_code.jar -x servicestage_admin_trust

    FunctionGraphCLI Command Reference 2 Function-related Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 4

  • Deleting a FunctionRun the delete function command to delete a function. This command can betriggered using alias df. The command syntax is as follows:

    fgs delete-function --func-urn

    Table 2-2 lists the option in this command.

    Table 2-2 Option in the command used for deleting a function

    Option Abbreviation Description Mandatory

    --func-urn value -fu value URN of thefunction to bedeleted. A URNcan be acombination ofdifferent fields.For details, seeFunction URNDescription.

    Yes

    Example command:

    ./fgs df -fu urn:fss:kweci03rg00fsp:7aad83af3e8d42e99ac194e8419e2c9b:function:default:clitest3

    Querying the Code of a FunctionRun the get-function-code command to query the code of a function. Thiscommand can be triggered using alias gf. The command syntax is as follows:

    fgs get-function-code --func-urn

    Table 2-3 lists the option in this command.

    Table 2-3 Option in the command used for querying function code

    Option Abbreviation Description Mandatory

    --func-urn value --fu value Function URN. Yes

    Example command:

    ./fgs gf --fu urn:fss:kweci03rg00fsp:7aad83af3e8d42e99ac194e8419e2c9b:function:default:clitest1

    Querying the Configurations of a FunctionRun the get-function-config command to query the configurations of a function.This command can be triggered using alias gc. The command syntax is as follows:

    fgs get-function-config --func-urn

    FunctionGraphCLI Command Reference 2 Function-related Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 5

  • Table 2-4 lists the option in this command.

    Table 2-4 Option in the command used for querying function configurations

    Option Abbreviation Description Mandatory

    --func-urn value -fu value Function URN. Yes

    Example command:

    ./fgs gc -fu urn:fss:kweci03rg00fsp:7aad83af3e8d42e99ac194e8419e2c9b:function:default:clitest1

    Querying a Function List

    Run the list-functions command to query a function list. This command can betriggered using alias lf. The command syntax is as follows:

    fgs list-functions [--marker , --max-items ]

    Table 2-5 lists the options in this command.

    Table 2-5 Options in the command used for querying a function list

    Option Abbreviation Description Mandatory

    --marker value -m value Start mark of afunction list. Thedefault value is 1.

    No

    --max-items value -c value Number offunctions in thefunction list. Thedefault value is10.

    No

    Example command:

    ./fgs lf -m 11 -c 3

    Querying Function Versions

    Run the list-function-versions command to query the versions of a function. Thiscommand can be triggered using alias lv. The command syntax is as follows:

    fgs list-function-versions --func-urn [--marker ,--max-items ]

    Table 2-6 lists the options in this command.

    FunctionGraphCLI Command Reference 2 Function-related Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 6

  • Table 2-6 Options in the command used for querying function versions

    Option Abbreviation Description Mandatory

    --func-urn value -fu value Function URN. Yes

    --marker value -m value Start mark of afunction list. Thedefault value is 1.

    No

    --max-items value -c value Number offunctions in thefunction list. Thedefault value is10.

    No

    Example command:

    ./fgs lv -fu urn:fss:kweci03rg00fsp:7aad83af3e8d42e99ac194e8419e2c9b:function:default:clitest1

    Publishing a Version

    Run the publish-version command to publish a function version. This commandcan be triggered using alias pv. The command syntax is as follows:

    fgs publish-version --func-urn [--code-digest --description ]

    Table 2-7 lists the options in this command.

    Table 2-7 Options in the command used for publishing a function version

    Option Abbreviation Description Mandatory

    --func-urn value -fu value Function URN. Yes

    --descriptionvalue

    -d value Description of thefunction version.

    No

    --version-namevalue

    - pv value Function version. Yes

    Example command:

    ./fgs pv -fu urn:fss:southchina:c0a7aaa6ff164697a58c76b4c4dea08f:function:default:function1:latest -pv test --d First version

    Creating an Event Template

    Run the create-functionEvent command to create an event template. Thiscommand can be triggered using alias fe. The command syntax is as follows:

    FunctionGraphCLI Command Reference 2 Function-related Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 7

  • --func-urn --trigger-type-code --event-file-name

    Table 2-8 lists the options in this command.

    Table 2-8 Options in the command used for creating an event template

    Option Abbreviation Description Mandatory

    -- trigger-type-code

    --tt value Select a template.Options: apig,dms, dis, smn,obs, timer, porn,voice, image, lts,and cts

    Yes

    event-file-name --fn value Name of theevent template tobe created.

    Yes

    After the command is executed successfully, an event template with the specifiedname is saved locally with JSON data. You can modify the data as necessary.

    Example command:

    fe --tt apig --fn testApig

    For details on how to use the event template, see Invoking a FunctionAsynchronously.

    Modifying Function CodeRun the update-function-code command to update the code of a function. Thiscommand can be triggered using alias uf. The command syntax is as follows:

    fgs update-function-code --func-urn --code-type --handler --runtime [--file or --code-url --publish]

    Table 2-9 lists the options in this command.

    Table 2-9 Options in the command used for modifying function code

    Option Abbreviation Description Mandatory

    --func-urn value -fu value Function URN. Yes

    --code-type value -t value Code entry mode.Options: inline,zip, jar, and obs.

    Yes

    FunctionGraphCLI Command Reference 2 Function-related Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 8

  • Option Abbreviation Description Mandatory

    --file value -f value Name of a codepackage. The sizeof the codepackage cannotexceed 50 MB.

    Yes

    --code-url value -l value URL of a codepackage.

    No

    --publish -pf Creates andpublishes thefunction.

    No

    --code-url value -l value URL of a codepackage.

    No

    --publish --pf Creates andpublishes thefunction.

    No

    Example command:

    ./fgs uf -fu urn:fss:kweci03rg00fsp:7aad83af3e8d42e99ac194e8419e2c9b:function:default:clitest1 -t inline -f python_code2.py

    Modifying Function ConfigurationsRun the update-function-config command to modify the configurations of afunction. This command can be triggered using alias uc. The command syntax isas follows:

    fgs update-function-config --func-urn [--memory-size --timeout --user-data --xrole --description ]

    Table 2-10 lists the options in this command.

    Table 2-10 Options in the command used for modifying the configurations of afunction

    Option Abbreviation Description Mandatory

    --func-urn value -fu value Function URN. Yes

    --memory-sizevalue

    -m value Memory. Thedefault value is128 MB.

    No

    FunctionGraphCLI Command Reference 2 Function-related Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 9

  • Option Abbreviation Description Mandatory

    --timeout value -to value Timeout forfunctionexecution. Thedefault value is3s.

    No

    --handler value -p value Handler of thefunction.NOTE

    For a Go function,the initial of thehandler functionname must becapitalized.

    No

    --user-data value -u value Environmentvariable.

    No

    --xrole value -x value Agency. No

    --descriptionvalue--concurrencyvalue

    -d value-c value

    Functiondescription.Indicates whetherto disable thefunction. Options:0: disable-1: enable

    NoNo

    Example command:

    ./fgs uc -fu urn:fss:kweci03rg00fsp:7aad83af3e8d42e99ac194e8419e2c9b:function:default:clitest1 -r python2.7 -ha python.handler

    Example command for disabling a function:

    ./fgs uc -fu urn:fss:kweci03rg00fsp:7aad83af3e8d42e99ac194e8419e2c9b:function:default:clitest1 -c 0

    Publishing a Function VersionRun the publish-version command to publish a function version. This commandcan be triggered using alias pv. The command syntax is as follows:

    fgs publish-version --func-urn [--code-digest --description ]

    Table 2-11 lists the options in this command.

    FunctionGraphCLI Command Reference 2 Function-related Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 10

  • Table 2-11 Options in the command used for publishing a function version

    Option Abbreviation Description Mandatory

    --func-urn value -fu value Function URN. Yes

    --code-digestvalue

    -pc value Code digest of thefunction versionto be published.

    Yes

    --descriptionvalue

    -d value Description of thefunction version.

    No

    Example command:

    ./fgs pv -fu urn:fss:kweci03rg00fsp:7aad83af3e8d42e99ac194e8419e2c9b:function:default:clitest1

    FunctionGraphCLI Command Reference 2 Function-related Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 11

  • 3 Alias-related CommandsCreating an Alias

    Run the create-alias command to create an alias for a function. This commandcan be triggered using alias ca. The command syntax is as follows:

    fgs create-alias --func-urn --name --version [--description ]

    Table 3-1 lists the options in this command.

    Table 3-1 Options in the command used for creating an alias

    Option Abbreviation Description Mandatory

    --func-urn value -fu value Function URN. Yes

    --name value -an value Alias. Yes

    --version value -fv value Function version. Yes

    --descriptionvalue

    -ad value Alias description. No

    Example command:

    ./fgs ca -fu urn:fss:kweci03rg00fsp:7aad83af3e8d42e99ac194e8419e2c9b:function:default:clitest1 -an clitestalias1 -fv latest

    Deleting an Alias

    Run the delete-alias command to delete an alias of a function. This commandcan be triggered using alias da. The command syntax is as follows:

    fgs delete-alias --func-urn --name

    Table 3-2 lists the options in this command.

    FunctionGraphCLI Command Reference 3 Alias-related Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 12

  • Table 3-2 Options in the command used for deleting an alias

    Option Abbreviation Description Mandatory

    --func-urn value -fu value Function URN. Yes

    --name value -an value Alias. Yes

    Example command:

    ./fgs da -fu urn:fss:kweci03rg00fsp:7aad83af3e8d42e99ac194e8419e2c9b:function:default:clitest1 -an clitestalias2

    Querying an AliasRun the get-alias command to query an alias of a function. This command can betriggered using alias ga. The command syntax is as follows:

    fgs get-alias --func-urn --name

    Table 3-3 lists the options in this command.

    Table 3-3 Options in the command used for querying a function alias

    Option Abbreviation Description Mandatory

    --func-urn value -fu value Function URN. Yes

    --name value -an value Alias. Yes

    Example command:

    ./fgs ga -fu urn:fss:kweci03rg00fsp:7aad83af3e8d42e99ac194e8419e2c9b:function:default:clitest1 -an clitestalias1

    Querying Aliases of a FunctionRun the list-aliases command to query the aliases of a function. This commandcan be triggered using alias la. The command syntax is as follows:

    fgs list-aliases --func-urn

    Table 3-4 lists the option in this command.

    Table 3-4 Option in the command used for querying the aliases of a function

    Option Abbreviation Description Mandatory

    --func-urn value -fu value Function URN. Yes

    Example command:

    FunctionGraphCLI Command Reference 3 Alias-related Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 13

  • ./fgs la -fu urn:fss:kweci03rg00fsp:7aad83af3e8d42e99ac194e8419e2c9b:function:default:clitest1

    Modifying an AliasRun the update-alias command to modify an alias of a function. This commandcan be triggered using alias ua. The command syntax is as follows:

    fgs update-alias --func-urn --name --version [--description ]

    Table 3-5 lists the options in this command.

    Table 3-5 Options in the command used for modifying an alias

    Option Abbreviation Description Mandatory

    --func-urn value -fu value Function URN. Yes

    --name value -an value Alias. Yes

    --version value -fv value Function version. Yes

    --descriptionvalue

    -ad value Alias description. No

    Example command:

    ./fgs ua -fu urn:fss:kweci03rg00fsp:7aad83af3e8d42e99ac194e8419e2c9b:function:default:clitest1 -an clitestalias1 -fv latest

    FunctionGraphCLI Command Reference 3 Alias-related Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 14

  • 4 Trigger-related CommandsCreating a Trigger

    Run the create-trigger command to create a trigger for a function. This commandcan be triggered using alias ct. The command syntax is as follows:

    fgs create-trigger --func-urn --trigger-type-code --event-type-code --event-data

    Table 4-1 lists the options in this command.

    Table 4-1 Options in the command used for creating a trigger

    Option Abbreviation Description Mandatory

    --func-urn value -fu value URN of thefunction for whichyou will create atrigger.

    Yes

    --trigger-type-code value

    -tt value Trigger type.Options: SMN,DMS, OBS, DIS,APIG, LTS, CTS,and TIMER.

    Yes

    --event-type-codevalue

    -te value Event type of thetrigger. Thedefault value isMessageCreated.

    Yes

    --event-datavalue

    -td value Triggerconfiguration,which must be inJSON format.

    Yes

    Format of a DIS trigger:

    FunctionGraphCLI Command Reference 4 Trigger-related Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 15

  • '{"stream_name":"","shard_iterator_type":"","batch_size":0,"polling_interval":0}'

    Options of shard_iterator_type: LATEST and TRIM_HORIZON

    Options of auth_provider: Huawei cloud platform and Huawei IAMauthentication

    Example command for creating a DMS trigger:

    ./fgs -fu testCLI -tt DMS -te "MessageCreated" -td {"queue_id":"95a8c840-e0f6-4a6f-b4f3-7ce35578388c","consumer_group_id":"g-0ab7ee83-fcaf-4284-be2c-92d1108cbf3f","polling_interval":22}

    Example command for creating an SMN trigger:

    ./fgs ct -fu urn:fss:southchina:c0a7aaa6ff164697a58c76b4c4dea08f:function:default:function1:latest -tt SMN -te "MessageCreated" -td {"topic_urn":"urn:smn:southchina:c0a7aaa6ff164697a58c76b4c4dea08f:smn","endpoint":"urn:fss:southchina:c0a7aaa6ff164697a58c76b4c4dea08f:function:default:function1:latest"}

    Table 4-2 Description of event-data value for creating an SMN trigger

    Parameter Type Description Mandatory

    topic_urn String Topic ID. Yes

    endpoint String Endpoint forreceiving messages.

    Yes

    Example command for creating an APIG trigger:

    ./fgs ct -fu urn:fss:southchina:c0a7aaa6ff164697a58c76b4c4dea08f:function:default:function1 -tt APIG -te "MessageCreated" -td {"group_id":"e94533a9aa4e44e3a6b6e8f6d7b6036d","env_id":"DEFAULT_ENVIRONMENT_RELEASE_ID","env_name":"RELEASE","protocol":"HTTPS","name":"function1","path":"/function1","sl_domain":"37b89db9b14e4b44b7bd537d29e70bbd.apigw.southchina.huaweicloud.com"}

    Table 4-3 Description of event-data value for creating an APIG trigger

    Parameter Type Description Mandatory

    group_id String ID of the API groupto which the APIwill belong.

    Yes

    name String Function name. Yes

    protocol String Options:● HTTP● HTTPS

    Yes

    FunctionGraphCLI Command Reference 4 Trigger-related Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 16

  • Parameter Type Description Mandatory

    env_name String Name of theenvironment inwhich the API willbe published.

    Yes

    auth String Authenticationmode. Options:IAM, APP, andNONE

    Yes

    Example command for creating a timer trigger:

    ./fgs ct -fu urn:fss:southchina:c0a7aaa6ff164697a58c76b4c4dea08f:function:default:function1 -tt TIMER -te "MessageCreated" -td {"schedule":"3m","schedule_type":"Rate"}

    Table 4-4 Description of event-data value for creating a timer trigger

    Parameter Type Description Mandatory

    schedule_type String Triggering rule,which can be Rateor Cron.

    Yes

    schedule string Rate: fixed rate ofminutes (m), hours(h), or days (d). Forexample, 3m.Cron: For example,0*/3 ***?.

    Yes

    Example command for creating an LTS trigger:

    ./fgs ct -fu urn:fss:southchina:c0a7aaa6ff164697a58c76b4c4dea08f:function:default:function1 -tt LTS -te "MessageCreated" -td {"log_group_id":"1deea159-946b-11e8-8824-286ed488ce70","log_group_name":"lts1","log_topic_id":"2616c6aa-946b-11e8-aaf3-286ed488ce71","log_topic_name":"lts-topic-1"}

    Table 4-5 Description of event-data value for creating an LTS trigger

    Parameter Type Description Mandatory

    log_group_id String Log group ID. Yes

    log_group_name String Log group name. Yes

    log_topic_id string Log topic ID. Yes

    log_topic_name string Log topic name. No

    FunctionGraphCLI Command Reference 4 Trigger-related Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 17

  • Example command for creating a CTS trigger:

    ./fgs ct -fu urn:fss:southchina:c0a7aaa6ff164697a58c76b4c4dea08f:function:default:function1 -tt CTS -te "MessageCreated" -td {"name":"eqwrwe","operations":["AAD:addprotocolrule:addProtocolRule","BCS:baas-apiserver:scalePeers","ARS:ars:setConfigArs"]}

    Table 4-6 Description of event-data value for creating a CTS trigger

    Parameter Type Description Mandatory

    name String Trigger name. Yes

    operations String Custom operations.For example,"operations":["AAD:addprotocolrule:addProtocolRule","BCS:baas-apiserver:scalePeers","ARS:ars:setConfigArs"].

    Yes

    Deleting a TriggerRun the delete-trigger command to delete a trigger of a function. This commandcan be triggered using alias dt. The command syntax is as follows:

    fgs delete-trigger --func-urn --trigger-type-code --trigger-id

    Table 4-7 lists the options in this command.

    Table 4-7 Options in the command used for deleting a trigger

    Option Abbreviation Description Mandatory

    --func-urn value -fu value URN of thefunction of whichyou will delete atrigger.

    Yes

    --trigger-type-code value

    -tt value Trigger type.Options: SMN,DMS, OBS, DIS,APIG, LTS, CTS,and TIMER.

    Yes

    --trigger-id value -ti value Trigger ID. Yes

    Example command for deleting a DMS trigger:

    ./fgs dt -fu testCLI -tt DMS -ti 720e27a9-4152-4c5f-973e-f19c1b620f66

    FunctionGraphCLI Command Reference 4 Trigger-related Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 18

  • Querying a TriggerRun the get-trigger command to query the details about a trigger of a function.This command can be triggered using alias gt. The command syntax is as follows:

    fgs get-trigger --func-urn --trigger-type-code --trigger-id

    Table 4-8 lists the options in this command.

    Table 4-8 Options in the command used for querying a trigger

    Option Abbreviation Description Mandatory

    --func-urn value -fu value Function URN. Yes

    --trigger-type-code value

    -tt value Trigger type.Options: SMN,DMS, OBS, DIS,APIG, LTS, CTS,and TIMER.

    Yes

    --trigger-id value -ti value Trigger ID. Yes

    Example command for querying a trigger:

    ./fgs gt -fu testCLI -tt DMS -ti 720e27a9-4152-4c5f-973e-f19c1b620f66

    Querying Triggers of a FunctionRun the list-triggers command to query all the triggers of a function. Thiscommand can be triggered using alias lt. The command syntax is as follows:

    fgs list-triggers --func-urn

    Table 4-9 lists the option in this command.

    Table 4-9 Option in the command used for querying triggers of a function

    Option Abbreviation Description Mandatory

    --func-urn value -fu value Function URN. Yes

    Example command:

    ./fgs lt -fu urn:fss:kweci03rg00fsp:7aad83af3e8d42e99ac194e8419e2c9b:function:default:clitest1

    FunctionGraphCLI Command Reference 4 Trigger-related Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 19

  • 5 Invocation CommandsThe rules of CLI commands are consistent in different OSs, but the format of JSONparameters entered in CLI varies depending on the OS. This section describes thecommand operations in Linux OS. For command operations in other OSs, seeCommand Description.

    Invoking a Function Synchronously

    Run the invoke command to invoke a function synchronously. This command canbe triggered using alias if. The command syntax is as follows:

    fgs invoke --func-urn --event-data

    Table 5-1 lists the options in this command.

    Table 5-1 Options in the command used for invoking a function synchronously

    Option Abbreviation Description Mandatory

    --func-urn value -fu value URN of thefunction to beinvoked.

    Yes

    --event-datavalue

    -ed value Event parameterto be passedwhen a function isinvoked.

    Yes

    Example command:

    ./fgs if -fu urn:fss:kweci03rg00fsp:7aad83af3e8d42e99ac194e8419e2c9b:function:default:clitest1 -ed '{"Name":"sererless"}'

    Invoking a Function Asynchronously

    Run the invoke-async command to invoke a function asynchronously. Thiscommand can be triggered using alias ia. The command syntax is as follows:

    FunctionGraphCLI Command Reference 5 Invocation Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 20

  • fgs invoke-async --func-urn --event-data

    Table 5-2 lists the options in this command.

    Table 5-2 Options in the command used for invoking a function asynchronously

    Option Abbreviation Description Mandatory

    --func-urn value -fu value Function URN. Yes

    --event-datavalue

    -ed value Event parameterto be passedwhen a function isinvoked.

    Yes

    Example command:

    ./fgs ia -fu urn:fss:kweci03rg00fsp:7aad83af3e8d42e99ac194e8419e2c9b:function:default:clitest1 -ed '{"Name":"sererless"}'

    FunctionGraphCLI Command Reference 5 Invocation Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 21

  • 6 Interactive CommandsFunctionGraph supports interactive operations, which can be implemented usingthe commands listed in the following table.

    Table 6-1 Interactive commands

    Option Description

    cd Navigates to a specified directory.

    ls Lists the files under the current directory.

    pwd Queries the current directory.

    info Queries the detailed information about resources.

    rm Deletes resources, such as functions and triggers.

    help Displays help information.

    clear Clears the screen display.

    ctrl+c/quit/exit Exits the current program.

    update-config Modifies service configurations.

    switch Changes the region.

    Navigating to a DirectoryRun the cd command to go to a function directory. The command syntax is asfollows:

    fgs cd

    Example command:

    fgs cd function

    FunctionGraphCLI Command Reference 6 Interactive Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 22

  • Listing Files in the Current DirectoryRun the ls command to list all files under the current directory. The commandsyntax is as follows:

    fgs ls

    You can run the ls command to query all functions under a region directory. Afterrunning the cd command to navigate to a function directory using the cdcommand, you can also run the ls command to query all triggers of the function.

    An example command and command output are as follows:

    $ fgs>cd function$ fgs>lsTriggerId[d884e794-9c46-11e8-a13d-067b7e4b660c] TriggerTypeCode[CTS]TriggerId[IJO4Z2ZG2OFC8BF1000001651E78198A860BA7136943E42D] TriggerTypeCode[OBS]

    Querying the Current DirectoryRun the pwd command to query the current directory. The command syntax is asfollows:

    fgs pwd

    An example command and command output are as follows:

    $ fgs>pwd/southchina/function

    Querying Resource DetailsRun the info command to query the detailed information about the currentconfigurations. The command syntax is as follows:

    fgs info

    An example command and command output are as follows:

    $ fgs>infoRegionName:cn-north-1ProjectName:cn-north-1ProjectId:c3b2459a6d5e4b548e6777e57852692dEndpoint:https://functiongraph.cn-north-1.myhuaweicloud.comIAMAddress:https://iam.cn-north-1.myhuaweicloud.comSMNAddress:https://smn.cn-north-1.myhuaweicloud.comAPIGAddress:https://apig.cn-north-1.myhuaweicloud.comOBSEndpoint:https://obs.cn-north-1.myhuaweicloud.comTimeout:30ProxyServerAddress:ProxyUserName:

    Deleting ResourcesRun the rm command to delete resources, such as functions and triggers. Thecommand syntax is as follows:

    fgs rm

    Query the trigger ID and trigger type code by running the ls command.

    FunctionGraphCLI Command Reference 6 Interactive Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 23

  • Example command:

    fgs rm urn:smn:southchina:c0a7aaa6ff164697a58c76b4c4dea08f:Function:d2142df049694c8bab1f7d476ed597b2 SMN

    Displaying Help InformationRun the help command to query all commands. The command syntax is asfollows:

    fgs help

    An example command and command output are as follows:

    $ fgs>helpNAME: fgs - Huawei FunctionGraph CLI application version: 1.0.9 Built Time: 2019-06-19 21:46:50 +0800 CSTUSAGE: fgs [global options] command [command options]COMMANDS: help Shows a list of commands or help for one command Function Alias related: create-alias, ca Create Function Alias for Function delete-alias, da Delete Function Alias of Function get-alias, ga Get Function Alias of Function list-aliases, la List Function Aliases of Function update-alias, ua Update Function Alias of Function Function Event related: create-functionEvent, fe create function event Function Execution related: invoke, if Invoke FunctionGraph function synchronously invoke-async, ia Invoke FunctionGraph function asynchronously Function Trigger related: create-trigger, ct Creates a trigger which maps a particular function delete-trigger, dt delete a trigger which maps a particular function get-trigger, gt Describe Trigger list-triggers, lt List of Function Triggers Function related: create-function, cf Create FunctionGraph function list-functions, lf List FunctionGraph functions get-function-code, gf Get code of FunctionGraph function update-function-code, uf Update FunctionGraph function code delete-function, df Delete FunctionGraph function get-function-config, gc Get config of FunctionGraph function update-function-config, uc Update FunctionGraph function config publish-version, pv Publish FunctionGraph function list-function-versions, lv List FunctionGraph function versions export, ex Export FunctionGraph functions import, im Import FunctionGraph functions Region Config: update-config, ucr Update Config RegionGLOBAL OPTIONS: --endpoint-url value, -e value FunctionGraph open API access point URL --profile value, -p value Configuration file path. Default is ./config.json --project value, -i value Tenant Project ID --timeout value, -t value Specifies timeout duration in seconds. The maximum value is 60s (default: 0) --iam-url value, --iam value IAM URL for Authorization --version, -v print the version

    FunctionGraphCLI Command Reference 6 Interactive Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 24

  • Clearing the Screen DisplayRun the clear command to clear the screen display. The command syntax is asfollows:

    fgs clear

    Example command:

    fgs clear

    Exiting the Current ProgramTo exit the current program, run the quit or exit command or press Ctrl+c. Thecommand syntax is as follows:

    fgs quit / fgs exit

    Example command:

    fgs quitfgs exit

    Modifying the Configuration FileRun the update-config command to modify the configuration information in theconfig.yaml file. The command syntax is as follows:

    ucr --rn --

    RegionName indicates the name of a region, and ID indicates the abbreviatedname of a configuration option in the config.yaml file.

    Example command:

    ucr --rn southchina --ct 15

    Run the preceding command to change the timeout into 15s in the config.yamlfile.

    Table 6-2 lists the configuration items.

    Table 6-2 Configuration options

    Option Description How to Obtain Abbreviation

    AccessKey AK. For details, see Access Keys. ak

    SecretKey SK. For details, see Access Keys. sk

    RegionName

    Region in whichFunctionGraphresides.

    For details, see AvailabilityZone.

    rn

    ProjectName

    Name of the projectto whichFunctionGraphbelongs.

    For details, see API Credentials. pn

    FunctionGraphCLI Command Reference 6 Interactive Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 25

    https://support.huaweicloud.com/en-us/usermanual-ca/en-us_topic_0046606340.htmlhttps://support.huaweicloud.com/en-us/usermanual-ca/en-us_topic_0046606340.htmlhttps://developer.huaweicloud.com/en-us/endpointhttps://developer.huaweicloud.com/en-us/endpointhttps://support.huaweicloud.com/en-us/usermanual-ca/en-us_topic_0046606344.html

  • Option Description How to Obtain Abbreviation

    ProjectId ID of the project towhich FunctionGraphbelongs.

    For details, see API Credentials. pi

    Timeout Timeout of CLIcommands. Thedefault value is 30sand the maximumvalue is 90s.

    Set this parameter as required. ct

    Endpoint Access address of theFunctionGraphbackend service.

    An example endpoint ofFunctionGraph isfunctiongraph.xx-xxx-x.xxx.com.

    ce

    IAMAddress

    IAM address. For details, see Regions andEndpoints.

    ci

    Viewing Current ConfigurationsRun the info command to view the current configurations. The command syntax is as follows:info

    Changing the RegionRun the switch command to change the region. The command syntax is asfollows:

    fgs switch

    RegionName indicates the name of the region after the change.

    Example command:

    fgs switch southchina

    FunctionGraphCLI Command Reference 6 Interactive Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 26

    https://support.huaweicloud.com/en-us/usermanual-ca/en-us_topic_0046606344.htmlhttps://developer.huaweicloud.com/en-us/endpointhttps://developer.huaweicloud.com/en-us/endpoint

  • 7 Function Importing and ExportingCommands

    Exporting a FunctionRun the export command to export a FunctionGraph function. The commandsyntax is as follows:

    fgs export --func-urn -fu , --application -a ,--path –p

    Table 7-1 lists the options in this command.

    Table 7-1 Options in the command

    Option Abbreviation Description Mandatory

    --func-urn value -fu value Function URN. Yes

    --applicationvalue

    -a value Name of the appto which thefunction belongs.

    No

    --path value -p value Path for storingthe exportedfunction. Thedefault path is thecurrent workingpath.

    No

    -f value Indicates whetherto ignore allinteractions andprompts.

    No

    Example command for exporting a single function:

    ./fgs export -fu urn:fss:cn-north-7:xxx:function:default:testFunction:latest -p D:\ -f

    Example command for exporting multiple functions:

    FunctionGraphCLI Command Reference 7 Function Importing and Exporting Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 27

  • ./fgs export -fu func1,func2:func3

    Importing a FunctionRun the import command to import a FunctionGraph function. The commandsyntax is as follows:

    fgs import --application -a ,--path –p

    Table 7-2 lists the options in this command.

    Table 7-2 Options in the command

    Option Abbreviation Description Mandatory

    --applicationvalue

    -a value Name of the appto which thefunction to beimported belongs.The default valueis default.

    No

    --path value -p value Path where thefunction to beimported isstored.

    Yes

    -f value Indicates whetherto ignore allinteractions andprompts.

    No

    Example command:

    ./fgs import -p C:\Users\Downloads\xxx.zip -f

    Example command for importing a function from OBS:

    ./fgs import -p /tmp/default.yaml

    Descriptions about the command:

    ● The resource package to be imported must be a ZIP package that contains aYAML configuration file and code file, as shown in Figure 7-1. The packagecannot exceed 50 MB.

    Figure 7-1 Resource package

    FunctionGraphCLI Command Reference 7 Function Importing and Exporting Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 28

  • ● The resource package must contain only one YAML configuration file.● Fields in the YAML file must meet the same requirements as those configured

    when you create a function.● The code file is located through the codeFilename field in the YAML file.● The Resource field in the YAML file must specify only one function.● When a dependency package is used, if the code in this package is pulled

    from OBS, the importing is successful. Otherwise, the importing fails.● You can import an exported resource package again, but must specify a

    unique function name. The version of the imported function is LATEST bydefault.

    Parameter Description

    HcCrmTemplateVer-sion

    The value is fixed at v1.

    Resources Function details.

    Type The value is fixed at HC::Serverless::Function.

    Properties Function properties.

    Handler Handler of the function.

    Runtime Running environment.

    CodeType Code entry mode, which can be jar, zip, or inline.

    CodeFileName Code file name.

    DependencyPkg Dependency address.

    Description Function description.

    MemorySize Memory size.

    Timeout Timeout duration.

    Version Function version.

    Environment Environment variables.

    FunctionGraphCLI Command Reference 7 Function Importing and Exporting Commands

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 29

  • 8 Command DescriptionIn addition to the preceding command rules, pay attention to the descriptions inthis section when using CLI.

    Function URN Description

    When using CLI, you must enter the URN of a function in most cases. The formatof a function URN is as follows:

    urn:fss:::function::[:|:!]

    NO TE

    A function URN is divided into eight fields by colons. The value of region_id (you can setthis parameter in accordance with that in the backend) is included in the systemconfigurations. The content in the brackets ([]) is a function version or alias. If you enter analias, add an exclamation mark (!) in front of it for easy identification.

    Instead of providing a complete command, you can enter a command with onlythe required fields as follows:

    ● 1 field: . project_id is obtained from a token, package isdefault, and version is latest.

    ● 2 fields: :. project_id is obtained from a token,and version is latest.

    ● 3 fields: ::. version is latest.● 4 fields: :::.● 7 fields:

    urn:fss:::function::.version is latest.

    ● 8 fields:urn:fss:::function:::.

    Use of JSON Strings

    The format of JSON parameters entered in CLI varies depending on the OS. EnterJSON parameters in different OSs as follows:

    FunctionGraphCLI Command Reference 8 Command Description

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 30

  • ● Linux: JSON structure in single quotation marks (' '). For example:./fgs if --fu urn:fss:kweci03rg00fsp:7aad83af3e8d42e99ac194e8419e2c9b:function:default:clitest1 --ed '{"Name":"sererless"}'

    ● Windows: JSON structure in quotation marks (" "). Each quotation mark inthe JSON structure must follow a backslash (\). For example:./fgs if --fu urn:fss:kweci03rg00fsp:7aad83af3e8d42e99ac194e8419e2c9b:function:default:clitest1 --ed {\"Name\":\"serverless\"}

    ● Windows PowerShell: JSON structure in single quotation marks (' '). Eachquotation mark in the JSON structure must follow a backslash (\). Forexample:./fgs if --fu urn:fss:kweci03rg00fsp:7aad83af3e8d42e99ac194e8419e2c9b:function:default:clitest1 --ed '{\"Name\":\"serverless\"}'

    FunctionGraphCLI Command Reference 8 Command Description

    Issue 01 (2020-09-28) Copyright © Huawei Technologies Co., Ltd. 31

    Contents1 Introduction to CLI2 Function-related Commands3 Alias-related Commands4 Trigger-related Commands5 Invocation Commands6 Interactive Commands7 Function Importing and Exporting Commands8 Command Description


Recommended