Tutorials
1 Using of CLI Tools
1.1 Command structure
Input format
pgos_cli [help] [command] [help] [options]
Options
--v / --verbose
Open verbose logs.
Syntax:
--v --cli-load-json 'xxx'
// or
--verbose --cli-load-json 'xxx'
--set-config-file
Specify the current configuration file for current command.
Configuration file format:
{"secret-key": "your-secret-key", "title-region": "your-title-region-id", "title-id": "yourer-title-id"}
Syntax:
- Win DOS(CMD)
- Win Powershell
- Linux Shell
pgos_cli help --set-config-file --cli-load-json "{\"option1\":\"param1\",\"option2\":\"param2\"}"
pgos_cli help --set-config-file --cli-load-json '{\"option1\":\"param1\",\"option2\":\"param2\"}'
pgos_cli help --set-config-file --cli-load-json "{\"option1\":\"param1\",\"option2\":\"param2\"}"
--cli-load-json
PGOS CLI loads all parameters in batches from a JSON file or JSON string.
Syntax:
- Win DOS(CMD)
- Win Powershell
- Linux Shell
// JSON string
--cli-load-json "{\"option1\":\"param1\",\"option2\":\"param2\"}"
// JSON file
--cli-load-json 'c:\\res\\options.json'
// JSON string
--cli-load-json '{\"option1\":\"param1\",\"option2\":\"param2\"}'
// JSON file
--cli-load-json 'c:\\res\\options.json'
// JSON string
--cli-load-json "{\"option1\":\"param1\",\"option2\":\"param2\"}"
// JSON file
--cli-load-json 'c:\\res\\options.json'
--cli-upload-files
(list)
A array JSON string lists resource files to be uploaded, like game build, virtual server script package, and so on.
(array)
(object)
label (string)
A descriptive label that is associated with a file. Label must be unique in the list.
For most commands, the label parameter value is preset by PGOS, please read the [Command Reference](#Command Reference) throughly.
path (string)
The absolute path of the file to be uploaded.
Syntax:
- Win DOS(CMD)
- Win Powershell
- Linux Shell
// JSON string
--cli-upload-files "[{\"label\":\"BucketKey\", \"path\":\"c:\\res\\build_v1.zip\", \"region\":\"ap-guangzhou\"},{\"label\":\"BucketKey\", \"path\":\"c:\\res\\build_v2.zip\", \"region\":\"ap-guangzhou\"}]"
// JSOn file
--cli-upload-files 'c:\\res\\files_to_upload.json'
// JSON string
--cli-upload-files '[{\"label\":\"BucketKey\", \"path\":\"c:\\res\\build_v1.zip\", \"region\":\"ap-guangzhou\"},{\"label\":\"BucketKey\", \"path\":\"c:\\res\\build_v2.zip\", \"region\":\"ap-guangzhou\"}]'
// JSOn file
--cli-upload-files 'c:\\res\\files_to_upload.json'
// JSON string
--cli-upload-files "[{\"label\":\"BucketKey\", \"path\":\"c:\\res\\build_v1.zip\", \"region\":\"ap-guangzhou\"},{\"label\":\"BucketKey\", \"path\":\"c:\\res\\build_v2.zip\", \"region\":\"ap-guangzhou\"}]"
// JSOn file
--cli-upload-files 'c:\\res\\files_to_upload.json'
1.2 Set Authentication Configurations
Use command set-title-region
to set title region ID.
Use command set-secret-key
to set secret key.
Use command config
to check current configurations.
1.3 Getting Help
Help for pgos_cli
Help for pgos_cli will show the available commands name.
pgos_cli.exe help
Help for Commands
Help for command will show the input params
and output params
of the specified command.
pgos_cli.exe list-build help
1.4 Executing Commands
Execute list-build
by loading params from JSON file.
pgos_cli.exe list-build --cli-load-json 'G:\\test\\pgos_cli\\jsons\\list-build.json'
2 Using of PGOS CLI python SDK
|-demo
|-json_params_demo [json files contain all command's params, just for reference]
|-test.py [a demo script shows that simple use of python sdk]
|-deps
|-pgos_cli
|-pgos_cli_executable
|-scripts
|-README.md [readme file]
|-setup.py [setup script of the python package]
2.1 Install PGOS CLI python SDK
Dependencies
- Python3.8 or higher versions is required.
- boto3 higher than 1.19.4 is required.
- cos-python-sdk-v5 higher than 1.9.0 is required.
Install with PIP
Use pip to install and upgrade pgos_cli python SDK.
python -m pip install --upgrade pgos-cli-python-sdk-v1
All dependent python modules will be installed after the command completed.
Using source code
Also you could visit https://pgos.intlgame.com/#/index/download and download the source code of PGOS CLI python SDK, but all dependent python modules should be installed manually. The following commands are for your reference:
python -m pip install boto3
python -m pip install cos-python-sdk-v5
2.2 Set Authentication Configurations
Example
# import PgosCliClient
from pgos_cli import PgosCliClient
import os
# get a instance for PgosCliClient
pgos_cli_client = PgosCliClient()
# set secret key
pgos_cli_client.SetSecretKey('XXXX-XXXX-XXXX-XXXX-XXXX')
# set title region ID
pgos_cli_client.SetTitleRegion('xxx')
# set title id
pgos_cli_client.SetTitleID("xxx")
2.3 Get Help information of CLI or Commands
Example
# import PgosCliClient
from pgos_cli import PgosCliClient
import os
# get a instance for PgosCliClient
pgos_cli_client = PgosCliClient()
# help for pgos_cli
pgos_cli_client.Help()
# help for command
pgos_cli_client.Help('list-build')
2.4 Execute Commands
Consistent with CLI Tools , the python SDK supports to load all parameters in batches from a JSON file or JSON string.
# import PgosCliClient
from pgos_cli import PgosCliClient
# get a instance for PgosCliClient
pgos_cli_client = PgosCliClient()
# load all params from a JSON string
pgos_cli_client.ExecuteCommand(command_name, json_str)
# load all params from a JSON file
pgos_cli_client.ExecuteCommand(command_name, json_file_path)
The result is presented in JSON form, the structure is as follows:
{
"errno": number,
"errmsg": string,
"data":{
// View structure of 'data' through the Help command
}
}
Example
# import PgosCliClient
from pgos_cli import PgosCliClient
import os
# get a instance for PgosCliClient
pgos_cli_client = PgosCliClient()
# set secret key
pgos_cli_client.SetSecretKey('XXXX-XXXX-XXXX-XXXX-XXXX')
# set title region id
pgos_cli_client.SetTitleRegion('dev_AAA_123456')
# generate full path of params JSON
def GenParamsJsonPath(command_name):
params_file_name = command_name + '.json'
root = os.path.dirname(os.path.abspath(__file__))
path = os.path.join(root, 'json_params_demo')
path = os.path.join(path, params_file_name)
return path
# generate full path of load file JSON
def GenUploadFilesJsonPath():
root = os.path.dirname(os.path.abspath(__file__))
upload_file_params_path = os.path.join(os.path.join(root, 'json_params_demo'), 'upload-files.json')
return upload_file_params_path
# execute a command, and load params from local JSON file
def TestCommand(command_name, upload_files = False):
if upload_files:
ret = pgos_cli_client.ExecuteCommand(
command_name,
GenParamsJsonPath(command_name),
GenUploadFilesJsonPath())
if 'data' in ret:
print(json.dumps(ret['data'], indent=4))
else:
ret = pgos_cli_client.ExecuteCommand(
command_name,
GenParamsJsonPath(command_name))
if 'data' in ret:
print(json.dumps(ret['data'], indent=4))
# execute command: list-build
TestCommand('list-build')
2.5 Usage example
We provide a complete usage example for PGOS CLI python SDK. Including:
- example for params:
.\demo\json_params_demo\*.json
- example for Api calling:
\demo\json_params_demo\test.py