1.12.0 • Published 1 year ago

@hw-agconnect/agc-cli v1.12.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

AppGalleryConnectCliTool

Table Of Contents

Overview

AppGalleryConnectCliTool (AGCLI for short), is a command line tool which helps you to operate and manage your application services on AppGalleryConnect, The AGCLI provides;

  • Development and maintenance services for developers through command lines.
  • Basic capabilities such as developer login and logout, team switchover, and selecting project.
  • Ease of use and accessibility to AGC App Services such as Cloud Function, Cloud Storage, Cloud Cache and more to reduce the operations that you would need to complete on AGC Web Portal.

Prerequisites

Ensure that:

Installation

Go to the compilation platform and run the following command to download and install AGCLI:

npm install -g @hw-agconnect/agc-cli

Run the following command to install autocompletion for your shell. You need to reload your shell after the installation. (If autocomplete with the TAB key on the keyboard does not work.)

agcli install-completion

Usage

Run the following command to log in to AGCLI:

 agcli login

Run the following command to select a team: After entering the command, press arrow keys to select a team.

agcli team select

Run the following command to select a project: After entering agcli project select, press arrow keys to select a project.

agcli project select

Documentation

You can find the usage documentation in this section.

Cloud Functions

The commands for operating Cloud Functions is described in the following table. For more information please check the Service Introduction in the Huawei Developers Website.

Cloud Function

The commands for operating Cloud Function is described in the following table.

ResourceCommandDescription
Create Functionagcli func create-function --name a1 --code-path ./function.zipCreates cloud functions.
Invoke Functionagcli func invoke --name a1 --payload "{\"request\": \"world\"}"Calls cloud functions.
List of Functionsagcli func list-function-versions --name a1Queries a cloud function list by running list-functions.
Publish Functionagcli func publish-function --name a1 --version-description "publish function description"Publishes a cloud function by running publish-function.
Query Version of Functionagcli func query-function-version --name a1 --function-version $latestQueries the list of all versions for a function by running list-function-versions.
Update and Publish Functionagcli func update-and-publish-function --name a1 --version-description "version description is necessary" --code-path ./function.zipUpdates and publishes cloud functions.
Update Code of Functionagcli func update-function-code --name a1 --code-path ./function.zipUpdates cloud function code.
Update Config of Functionagcli func update-function-config --name a1 --timeout 63Updates cloud function configurations.

Cloud Function Layer

The commands for operating Cloud Function Layer is described in the following table.

ResourceCommandDescription
Create Layeragcli func create-layer --name test-layer --compatible-runtimes nodejs14.x --code-path ./layer.zip --shared-scope businessCreates a layer.
Create Version of Layeragcli func create-layer-version --name test-layer --compatible-runtimes nodejs14.x --code-path ./layer.zip --shared-scope businessCreates a layer version.
List Versions of Layersagcli func list-layers --compatible-runtime nodejs14.xQueries all layers.
List Versions of Layeragcli func list-layer-versions --name test-layerQueries all versions of a layer.
Query Version of Layeragcli func query-layer-version --name test-layer --version 1Queries a layer version.

Cloud Function Trigger

The commands for operating Cloud Function Trigger is described in the following table.

ResourceCommandDescription
Create Cron Triggeragcli func create-cron-trigger --function-name a1 --function-version $latest --schedule "@every 10h" --payload "{\"request\":\"good\"}" --trigger-mode ASyncCreates a CRON trigger by running create-cron-trigger.↵
Create Http Triggeragcli func create-http-trigger --function-name a1 --function-version $latest --auth-type apiqw-client --enable-url-decode trueCreates an HTTP trigger by running create-http-trigger.↵
Export Triggersagcli func export-triggers --function-name a1 --function-version $latestExport trigger from cloud db Service.
Import Triggersagcli func import-triggers --function-name a1 --source string path --function-version $latestImport trigger to cloud db Service.
Update Cron Triggeragcli func update-cron-trigger --trigger-id xxx --trigger-switch trueUpdates a CRON trigger.
List of Triggersagcli func list-triggers --function-name a1 --function-verison $latestQueries a trigger list of a function by running list-triggers.
Query Triggeragcli func query-trigger --trigger-id xxxxQueries a trigger by running query-trigger.

Cloud Function Alias

The commands for operating Cloud Function Alias is described in the following table. | Resource | Command | Description | |-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------| | Create Alias | agcli func create-alias --name test --function-name a1 --function-version $latest --description "this is test alias" --routing-config "{\"$latest\":80, \"2\":20}" | Creates an alias of a function by running create-alias. | | Update Alias | agcli func update-alias --name test --function-name a1 --description "this is test" --routing-config "{\"$latest\":90,\"2\":10}" | Updates the alias of a function by running update-alias. | | List of Alias | agcli func list-aliases --function-name a1 --function-version $latest | Queries an alias list of a function by running list-aliases. | | Query Alias | agcli func query-alias --name test --function-name a1 | Queries an alias of a function. |


Cloud Storage

The commands for operating Cloud Storage is described in the following table. For more information please check the Service Introduction in the Huawei Developers Website.

ResourceCommandDescription
Enableagcli storage enableEnable Cloud Storage.
Documentagcli storage docLink to document.
Create Bucketagcli storage create-bucket --name bucketNameCreate a new bucket.
Select Bucketagcli storage selectBucket switchover.
Delete Bucketagcli storage delete-bucketDelete specified bucket.
Add CORSagcli storage add-cors --methods GET, POST --origins https://localhost:443List all cross-origin policies.
Clear CORSagcli storage clear-corsClear Cross-Origin Resource Sharing rules.
Delete CORSagcli storage delete-cors --index 1Delete Cross-Origin Resource Sharing rule.
List CORSagcli storage list-corsList Cross-Origin Resource Sharing rules
Upload Fileagcli storage upload --file /local/imagePath/demo.jpg --destination images/demo.jpgCommand for uploading file to cloud storage.
List Fileagcli storage list --prefix images/ --delimiter /Listing files with specified prefix.
Download Fileagcli storage download --file images/demo.jpg --destination /local/imagePath/demo.jpgCommand for downloading file from cloud storage.
Delete Fileagcli storage delete --file images/demo.jpgDeleting file at specified destination.
File Detailsagcli storage file-details --file images/demo.jpgView file at specified destination.

Cloud DB

The commands for operating Cloud DB is described in the following table. For more information please check the Service Introduction in the Huawei Developers Website.

ResourceCommandDescription
Enableagcli db enableEnable the Cloud DB Service.
Documentagcli db docOpen document of cloud DB.
Informationagcli db infoView data usage info from Cloud DB.
Update Objectagcli agcli db update-object --object personUpdate database object to Cloud DB.
Update Dataagcli db update-data --zone zoneName --object person --data \'{"name": "john doe", "age": 21}\''Update data by query.
View Dataagcli db view-data --zone zoneName --object objectName --primary-key primary-key --primary-value primaryValue'View single data entry from Cloud DB.
View Objectagcli db view-object --name nameView information of Cloud DB object.
View Ruleagcli db view-ruleView security rules of Cloud DB.
Publish Ruleagcli db publish-rule --rule rulePublish security rules of Cloud DB.
List Zoneagcli db list-zoneList zone(s) from Cloud DB.
List Objectagcli db list-object --version version --name nameList objects from Cloud DB.
Import Objectagcli db import-object --source filepathImport data object to Cloud DB.
Import Dataagcli db import-data --zone zoneName --object objectName --source source --path pathImport data object to Cloud DB.
Export Objectagcli db export-object --type type --java-type javaType --js-type jsType --package-name pkgNameExport data object from Cloud DB.
Export Dataagcli db export-data --target target --zone zone --object objectTypeName --offset offset --number number --path pathExport data object from Cloud DB.
Delete Zoneagcli db delete-zone --name nameDelete a zone from Cloud DB.
Delete Ruleagcli db delete-rule --timestamp timestampDelete security rule from Cloud DB.
Delete Dataagcli db delete-data --zone zoneName --object person --data \'{"name": "john doe", "age": 21}\'Delete database object from Cloud DB.
Create zoneagcli db create-zone --name nameCreate a zone in Cloud DB.
Create Objectagcli db create-object --object personCreate a database object to Cloud DB.
Clear Dataagcli db clear-data --zone zoneName --object objectNameClear data from Cloud DB.
Queryagcli db query --zone zoneName --object objectName -eq \'name: John\' -eq \'lastName: Doe\' -gte \'age: 18\'Clear data from Cloud DB.
Add Dataagcli db add-data --zone zoneName --object person --data \'{"name": "john doe", "age": 21}\'Add data in database.

Cloud Cache

The commands for operating Cloud Cache is described in the following table. For more information please check the Service Introduction in the Huawei Developers Website.

Note: This service is currently only available in China region.

ResourceCommandDescription
Docagcli cache docOpen document of Cloud Cache.
Enableagcli cache enable --password Testpassword123*Enable the Cloud Cache Service.
Change Passwordagcli cache change-password --password Testpassword123*Change password of the Cloud Cache Service.
Commandagcli cache exec --command "SET key value" --raw trueExecute command in the Cloud Cache Service.
Infoagcli cache info --start-time 1692859729 --end-time 1692859729View usage statistics of the Cloud Cache Service.

Auth Service

The commands for operating Auth Service is described in the following table. For more information please check the Service Introduction in the Huawei Developers Website.

ResourceCommandDescription
Enableagcli auth enableEnable the Auth service.
Documentagcli auth docOpen document of cloud storage.
Importagcli auth import --source Import user data to Auth Service.
Exportagcli auth export --destination Export user data from Auth Service.

CloudDev

The commands for operating CloudDev Service is described in the following table.

ResourceCommandDescription
Initagcli clouddev initInitialize a CloudDev project.
Buildagcli clouddev buildBuild CloudDev project.
Localagcli clouddev local --function-name hello-worldTest CloudDev projects locally.
Cleanagcli clouddev clean --forceClean .build folder in CloudDev project
Deployagcli clouddev deployDeploy the CloudDev project

CloudDev Functions

The commands for operating CloudDev Functions is described in the following table.

ResourceCommandDescription
Createagcli clouddev create --function-name hello-world --runtime nodejs14.x --memory 500 --timeout 60 --instance-concurrency 100 --handler handler.myHandler --environment '{"envKey":"envValue"}'Creating a Cloud Function in the CloudDev Project.
Create Triggeragcli clouddev create-trigger --type httpCreate a Cloud Function Trigger
Create Aliasagcli clouddev create-alias --name hello --function-name hello-worldCreate an Alias for Cloud Function.

CloudDev Storage

The commands for operating CloudDev Storage is described in the following table.

ResourceCommandDescription
Storage Createagcli clouddev storage create -–bucket lll-6o83aCreate a Cloud Storage bucket in the CloudDev Project.
Storage Addagcli clouddev storage add --file C:\Users\Desktop\images.png --destination clouddev\demo.png --bucket lll-6o83aAdd a file to your Cloud Storage Bucket.

CloudDev Hosting

The commands for operating CloudDev Hosting is described in the following table.

ResourceCommandDescription
Hosting Createagcli clouddev hosting create --domain huawei.comCreate a Cloud Hosting in the CloudDev Project.

Hosting Service

The commands for operating Hosting Service is described in the following table. For more information please check the Service Introduction in the Huawei Developers Website.

ResourceCommandDescription
Enableagcli hosting enableEnable the Cloud Hosting Service.
Documentagcli hosting docOpen document of Cloud Hosting Service.
Infoagcli hosting info --start-time timestamp --end-time timestampShow info of usage statistics of Cloud Hosting Service.
New Websiteagcli hosting new-website --domain domain --type customCreate a website hosting domain.
Modify Websiteagcli hosting modify-website --domain domain --desc desc --clean-url falseModify the website hosting domain.
List of Websitesagcli hosting list-website --page 0List existing website(s).
Delete Websiteagcli hosting delete-website --siteName siteNameDelete website hosting domain.
Deploy Websiteagcli hosting deploy --file ./test.zip --siteName testDeploy a website.
New Storage Accelerationagcli hosting new-storage-acceleration --domain domain --type customCreate a storage acceleration domain.
List of Storage Accelerationsagcli hosting list-storage-acceleration --page 0List the Cloud Hosting Storage Service Acceleration.
Delete Storage Accelerationagcli hosting delete-storage-acceleration --domain domainDelete the Cloud Hosting Storage Service Acceleration.
Associate Storage Accelerationagcli hosting storage-acceleration-associateAssociate bucket the Cloud Hosting Storage Service Acceleration.

License

Huawei AppGalleryConnectCliTool is licensed under the "ISC".