### StartCompShareInstance API Request Source: https://www.compshare.cn/docs/gpus/instance/startcompshareinstance Example of a GET request to start a GPU instance. Ensure all required parameters are correctly provided. ```http https://api.compshare.cn/?Action=StartCompShareInstance &Region=cn-zj &Zone=cn-zj-01 &ProjectId=cEMGtAkM &UHostId=NHNZFdXi &WithoutGpu=false ``` -------------------------------- ### Start OpenClaw Onboarding Wizard Source: https://www.compshare.cn/docs/modelverse/best_practice/openclaw Run this command in your terminal to start the OpenClaw configuration wizard. Follow the prompts to select QuickStart and Custom Provider. ```bash openclaw onboard ``` -------------------------------- ### Install and Start Clawdbot Gateway (Local systemd) Source: https://www.compshare.cn/docs/operation/bestpractices/feishu For local environments with systemd, install the Clawdbot gateway service and then start it. ```bash clawdbot gateway install clawdbot gateway start ``` -------------------------------- ### Get Instance Monitoring Data (Go SDK) Source: https://www.compshare.cn/docs/gpus/instance/getcompshareinstancemonitor This Go SDK example demonstrates how to retrieve monitoring data for compute sharing instances. Make sure to install the ucloud-sdk-go and replace the placeholder public and private keys with your credentials. ```go package main import ( "fmt" "github.com/ucloud/ucloud-sdk-go/services/ucompshare" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) func main() { cfg := ucloud.NewConfig() cfg.Region = "cn-wlcb" cfg.BaseUrl = "https://api.compshare.cn" credential := auth.NewCredential() credential.PublicKey = "my_public_key" // 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取 credential.PrivateKey = "my_private_key" // 替换为你的私钥 client := ucompshare.NewClient(&cfg, &credential) req := client.NewGetCompShareInstanceMonitorRequest() req.UHostIds = []string{"uhost-xxxx"} resp, err := client.GetCompShareInstanceMonitor(req) if err != nil { fmt.Printf("查询失败: %s\n", err) return } fmt.Printf("监控数据: %+v\n", resp.Data) } ``` -------------------------------- ### Create Team using Go SDK Source: https://www.compshare.cn/docs/gpus/team/createcompshareteam This Go SDK example demonstrates how to create a team. Remember to install the necessary dependency and replace the placeholder keys with your credentials. The Name and Description are optional but recommended for clarity. ```go package main import ( "fmt" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" "github.com/ucloud/ucloud-sdk-go/ucloud/request" "github.com/ucloud/ucloud-sdk-go/ucloud/response" ) type CreateCompShareTeamRequest struct { request.CommonBase Name *string Description *string `required:"false"` } type CreateCompShareTeamResponse struct { response.CommonBase } func main() { cfg := ucloud.NewConfig() cfg.Region = "cn-wlcb" cfg.BaseUrl = "https://api.compshare.cn" credential := auth.NewCredential() credential.PublicKey = "my_public_key" // 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取 credential.PrivateKey = "my_private_key" // 替换为你的私钥 client := ucloud.NewClient(&cfg, &credential) req := &CreateCompShareTeamRequest{ Name: ucloud.String("my-team"), Description: ucloud.String("AI研发团队"), } req.SetRegion("cn-wlcb") resp := &CreateCompShareTeamResponse{} if err := client.InvokeAction("CreateCompShareTeam", req, resp); err != nil { fmt.Printf("调用失败: RetCode=%d Msg=%s err=%v\n", resp.RetCode, resp.Message, err) return } fmt.Println("创建成功") } ``` -------------------------------- ### Get Supported Availability Zones (Go SDK) Source: https://www.compshare.cn/docs/gpus/instance/describecompsharesupportzone This Go SDK example demonstrates how to fetch supported availability zones. Remember to substitute the placeholder public and private keys with your credentials. The output displays the Zone and its description. ```go package main import ( "fmt" "github.com/ucloud/ucloud-sdk-go/services/ucompshare" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) func main() { cfg := ucloud.NewConfig() cfg.Region = "cn-wlcb" cfg.BaseUrl = "https://api.compshare.cn" credential := auth.NewCredential() credential.PublicKey = "my_public_key" // 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取 credential.PrivateKey = "my_private_key" // 替换为你的私钥 client := ucompshare.NewClient(&cfg, &credential) req := client.NewDescribeCompShareSupportZoneRequest() resp, err := client.DescribeCompShareSupportZone(req) if err != nil { fmt.Printf("查询失败: %s\n", err) return } for _, zone := range resp.ZoneInfo { fmt.Printf(" %s - %s\n", zone.Zone, zone.Describe) } } ``` -------------------------------- ### StartCompShareInstance API Response Source: https://www.compshare.cn/docs/gpus/instance/startcompshareinstance Example JSON response after successfully starting a GPU instance. A RetCode of 0 indicates success. ```json { "Action": "StartCompShareInstanceResponse", "UHostId": "jkHGryKM", "RetCode": 0 } ``` -------------------------------- ### Get Instance Monitoring Data (Python SDK) Source: https://www.compshare.cn/docs/gpus/instance/getcompshareinstancemonitor Use this Python SDK example to fetch monitoring data for compute sharing instances. Ensure you have installed the ucloud-sdk-python3. Replace placeholder keys with your actual credentials. ```python from ucloud.core import exc from ucloud.client import Client def main(): client = Client({ "region": "cn-wlcb", "public_key": "my_public_key", # 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取 "private_key": "my_private_key", # 替换为你的私钥 "base_url": "https://api.compshare.cn", }) try: resp = client.ucompshare().get_comp_share_instance_monitor({ "UHostIds": ["uhost-xxxx"], }) for inst in resp.get("Data", {}).get("List", []): print(f"实例 {inst['UHostId']}:") for metric in inst.get("Metrics", []): print(f" {metric['MetricKey']}: {metric.get('Results', [])}") except exc.UCloudException as e: print(e) if __name__ == "__main__": main() ``` -------------------------------- ### Create Custom Image using Go SDK Source: https://www.compshare.cn/docs/gpus/image/createcompsharecustomimage This Go SDK example demonstrates how to create a custom image from a CompShare instance. Remember to install the necessary SDK dependency and replace placeholder credentials and instance IDs. The source instance remains usable during the image creation process. ```go package main import ( "fmt" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" "github.com/ucloud/ucloud-sdk-go/ucloud/request" "github.com/ucloud/ucloud-sdk-go/ucloud/response" ) type CreateCompShareCustomImageRequest struct { request.CommonBase UHostId *string Name *string Description *string `required:"false"` } type CreateCompShareCustomImageResponse struct { response.CommonBase CompShareImageId string `json:"CompShareImageId"` } func main() { cfg := ucloud.NewConfig() cfg.Region = "cn-wlcb" cfg.BaseUrl = "https://api.compshare.cn" credential := auth.NewCredential() credential.PublicKey = "my_public_key" // 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取 credential.PrivateKey = "my_private_key" // 替换为你的私钥 client := ucloud.NewClient(&cfg, &credential) req := &CreateCompShareCustomImageRequest{ UHostId: ucloud.String("uhost-xxxx"), // 实例 ID,通过 DescribeCompShareInstance 获取 Name: ucloud.String("my-custom-env"), Description: ucloud.String("预装了PyTorch 2.1和CUDA 12.1"), } req.SetRegion("cn-wlcb") req.SetZone("cn-wlcb-01") sp := &CreateCompShareCustomImageResponse{} if err := client.InvokeAction("CreateCompShareCustomImage", req, resp); err != nil { fmt.Printf("调用失败: RetCode=%d Msg=%s err=%v\n", resp.RetCode, resp.Message, err) return } fmt.Printf("镜像创建中,CompShareImageId: %s\n", resp.CompShareImageId) } ``` -------------------------------- ### Install Remote GUI and Desktop Environment Source: https://www.compshare.cn/docs/operation/bestpractices/createVNC Installs necessary packages for a remote graphical interface and a lightweight desktop environment. This installation can take 5-10 minutes. ```bash apt install -y dbus-x11 xorg openbox xfce4 xfce4-goodies tightvncserver ``` -------------------------------- ### Get Available GPU Instance Types (Go) Source: https://www.compshare.cn/docs/gpus/instance/describeavailablecompshareinstancetypes This Go SDK example demonstrates how to retrieve available GPU instance types and their status within a specified region and zone. Remember to replace placeholder API credentials with your actual keys. ```go package main import ( "fmt" "github.com/ucloud/ucloud-sdk-go/services/ucompshare" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) func main() { cfg := ucloud.NewConfig() cfg.Region = "cn-wlcb" cfg.Zone = "cn-wlcb-01" cfg.BaseUrl = "https://api.compshare.cn" credential := auth.NewCredential() credential.PublicKey = "my_public_key" // 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取 credential.PrivateKey = "my_private_key" // 替换为你的私钥 client := ucompshare.NewClient(&cfg, &credential) req := client.NewDescribeAvailableCompShareInstanceTypesRequest() resp, err := client.DescribeAvailableCompShareInstanceTypes(req) if err != nil { fmt.Printf("查询失败: %s\n", err) return } for _, t := range resp.AvailableInstanceTypes { fmt.Printf(" %s - %s\n", t.Name, t.Status) } } ``` -------------------------------- ### Install OpenAI SDK Source: https://www.compshare.cn/docs/modelverse/models/text_api/embeddings Install the necessary SDK for interacting with the API. ```bash pip install openai ``` -------------------------------- ### Get Image Tags List (Go SDK) Source: https://www.compshare.cn/docs/gpus/image/describecompshareimagetags This Go code example demonstrates how to fetch image tags using the UCloud Go SDK. Remember to substitute the placeholder public and private keys with your valid credentials. ```go package main import ( "fmt" "github.com/ucloud/ucloud-sdk-go/services/ucompshare" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) func main() { cfg := ucloud.NewConfig() cfg.Region = "cn-wlcb" cfg.BaseUrl = "https://api.compshare.cn" credential := auth.NewCredential() credential.PublicKey = "my_public_key" // 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取 credential.PrivateKey = "my_private_key" // 替换为你的私钥 client := ucompshare.NewClient(&cfg, &credential) req := client.NewDescribeCompShareImageTagsRequest() resp, err := client.DescribeCompShareImageTags(req) if err != nil { fmt.Printf("查询失败: %s\n", err) return } fmt.Printf("标签: %v\n", resp.Tags) } ``` -------------------------------- ### Create and Attach Compshare Disk (Go) Source: https://www.compshare.cn/docs/gpus/data/createandattachcompsharedisk This Go SDK example demonstrates how to create a cloud disk and attach it to a compute sharing instance. The instance must be in a 'Running' or 'Stopped' state. Remember to replace the placeholder public and private keys with your actual credentials. ```go package main import ( "fmt" "github.com/ucloud/ucloud-sdk-go/services/ucompshare" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) func main() { cfg := ucloud.NewConfig() cfg.Region = "cn-wlcb" cfg.Zone = "cn-wlcb-01" cfg.BaseUrl = "https://api.compshare.cn" credential := auth.NewCredential() credential.PublicKey = "my_public_key" // 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取 credential.PrivateKey = "my_private_key" // 替换为你的私钥 client := ucompshare.NewClient(&cfg, &credential) req := client.NewCreateAndAttachCompshareDiskRequest() req.UHostId = ucloud.String("uhost-xxxx") // 实例 ID,通过 DescribeCompShareInstance 获取 req.Size = ucloud.Int(100) req.DiskType = ucloud.String("CLOUD_SSD") req.Name = ucloud.String("my-data-disk") resp, err := client.CreateAndAttachCompshareDisk(req) if err != nil { fmt.Printf("创建失败: %s\n", err) return } fmt.Printf("创建并挂载成功,UDiskId: %s\n", resp.UDiskId) } ``` -------------------------------- ### Query Instance Upgrade Price in Go Source: https://www.compshare.cn/docs/gpus/instance/getcompshareinstanceupgradeprice This Go SDK example demonstrates how to query the price difference for upgrading a shared instance. Remember to substitute your public and private keys and the correct instance ID. Memory is provided in MB. ```go package main import ( "fmt" "github.com/ucloud/ucloud-sdk-go/services/ucompshare" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) func main() { cfg := ucloud.NewConfig() cfg.Region = "cn-wlcb" cfg.Zone = "cn-wlcb-01" cfg.BaseUrl = "https://api.compshare.cn" credential := auth.NewCredential() credential.PublicKey = "my_public_key" // 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取 credential.PrivateKey = "my_private_key" // 替换为你的私钥 client := ucompshare.NewClient(&cfg, &credential) req := client.NewGetCompShareInstanceUpgradePriceRequest() req.UHostId = ucloud.String("uhost-xxxx") // 实例 ID,通过 DescribeCompShareInstance 获取 req.CPU = ucloud.Int(32) req.Memory = ucloud.Int(128 * 1024) req.GPU = ucloud.Int(2) resp, err := client.GetCompShareInstanceUpgradePrice(req) if err != nil { fmt.Printf("查询失败: %s\n", err) return } fmt.Printf("升配差价: %.2f 元\n", resp.Price) } ``` -------------------------------- ### Verify Node.js Installation Source: https://www.compshare.cn/docs/modelverse/best_practice/claudecode Check if Node.js version 18 or higher is installed. Ensure Node.js is installed before proceeding with CLI setup. ```bash node --version npm --version ``` -------------------------------- ### Run Clawdbot Onboarding Wizard Source: https://www.compshare.cn/docs/operation/bestpractices/telegram Execute this command to start the Clawdbot configuration wizard if no configuration file is found. Follow the on-screen prompts to set up your bot. ```bash clawdbot onboard ``` -------------------------------- ### Launch D-Bus Source: https://www.compshare.cn/docs/operation/bestpractices/createVNC Starts the D-Bus system message bus. Ensure dbus-x11 is installed; if not, reinstall it. ```bash dbus-launch ``` -------------------------------- ### Query Image Creation Progress (Go) Source: https://www.compshare.cn/docs/gpus/image/getcompshareimagecreateprogress This Go SDK example demonstrates how to query the creation progress of a self-built image. Remember to substitute your public and private keys, and the image ID. The output will show the completion percentage and estimated time remaining. ```go package main import ( "fmt" "github.com/ucloud/ucloud-sdk-go/services/ucompshare" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) func main() { cfg := ucloud.NewConfig() cfg.Region = "cn-wlcb" cfg.Zone = "cn-wlcb-01" cfg.BaseUrl = "https://api.compshare.cn" credential := auth.NewCredential() credential.PublicKey = "my_public_key" // 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取 credential.PrivateKey = "my_private_key" // 替换为你的私钥 client := ucompshare.NewClient(&cfg, &credential) req := client.NewGetCompShareImageCreateProgressRequest() req.CompShareImageId = ucloud.String("compshareImage-xxxx") // 镜像 ID,通过 DescribeCompShareImages 获取 resp, err := client.GetCompShareImageCreateProgress(req) if err != nil { fmt.Printf("查询失败: %s\n", err) return } fmt.Printf("进度: %.1f%%\n", *resp.Process) } ``` -------------------------------- ### Stop CompShare Instance Request Example Source: https://www.compshare.cn/docs/gpus/instance/stopcompshareinstance This is an example of an HTTP GET request to stop a CompShare GPU instance. Ensure all required parameters like Region, Zone, and UHostId are correctly provided. ```http https://api.compshare.cn/?Action=StopCompShareInstance &Region=cn-zj &Zone=cn-zj-01 &ProjectId=xEOkvEBT &UHostId=UpMrYJEe ``` -------------------------------- ### Start noVNC Proxy Source: https://www.compshare.cn/docs/operation/bestpractices/createVNC Starts the noVNC proxy service in the background, which forwards VNC connections to the specified port (defaulting to 5901) and listens on port 6080 for web access. Includes example log output. ```bash # 启动代理服务,并后台运⾏ /usr/lib/noVNC/utils/novnc_proxy --vnc localhost:5901 & # 打印⽇志如下,端⼝号默认监听:6080 Using installed websockify at /root/miniconda3/bin/websockify Starting webserver and WebSockets proxy on port 6080 WebSocket server settings: - Listen on :6080 - Web server. Web root: /usr/lib/noVNC - No SSL/TLS support (no cert file) - proxying from :6080 to localhost:5901 Navigate to this URL: http://b9732a281594:6080/vnc.html?host=b9732a281594&port=6080 Press Ctrl-C to exit ``` -------------------------------- ### Reinstall GPU Instance Request Example Source: https://www.compshare.cn/docs/gpus/instance/reinstallcompshareinstance This example demonstrates how to construct a request to reinstall a GPU instance. Ensure all required parameters like Region, Zone, UHostId, and CompShareImageId are provided. ```HTTP https://api.compshare.cn/?Action=ReinstallCompShareInstance &Region=cn-zj &Zone=cn-zj-01 &ProjectId=vQBurWEY &UHostId=YNAiIZEC &CompShareImageId=lXjZDcTq &Password=FtKctudQ ``` -------------------------------- ### Activate Conda Virtual Environment Source: https://www.compshare.cn/docs/operation/gpu/community Activate the previously created virtual environment to start using its isolated Python installation and packages. ```bash conda activate my-env ``` -------------------------------- ### Configure VNC Startup Source: https://www.compshare.cn/docs/operation/bestpractices/createVNC Appends the command to start the XFCE desktop environment to the VNC startup script and makes the script executable. ```bash echo "startxfce4 &" >> ~/.vnc/xstartup chmod +x ~/.vnc/xstartup ``` -------------------------------- ### Go SDK Example for SetCompShareTeamRelation Source: https://www.compshare.cn/docs/gpus/team/setcompshareteamrelation This Go SDK example demonstrates how to modify a team member's role or status, or remove a member using the SetCompShareTeamRelation API. Make sure to install the ucloud-sdk-go and replace the placeholder public and private keys with your credentials. ```go package main import ( "fmt" "github.com/ucloud/ucloud-sdk-go/services/ucompshare" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) func main() { cfg := ucloud.NewConfig() cfg.Region = "cn-wlcb" cfg.BaseUrl = "https://api.compshare.cn" credential := auth.NewCredential() credential.PublicKey = "my_public_key" // 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取 credential.PrivateKey = "my_private_key" // 替换为你的私钥 client := ucompshare.NewClient(&cfg, &credential) req := client.NewSetCompShareTeamRelationRequest() req.TeamId = ucloud.Uint(1001) req.Status = ucloud.String("Cancel") req.UserCompanyId = ucloud.Uint(50002) _, err := client.SetCompShareTeamRelation(req) if err != nil { fmt.Printf("操作失败: %s\n", err) return } fmt.Println("操作成功") } ``` -------------------------------- ### StartCompShareInstance Source: https://www.compshare.cn/docs/gpus/instance/startcompshareinstance Starts a GPU instance on the Youyun Zhisuan platform. ```APIDOC ## StartCompShareInstance ### Description Starts a GPU instance on the Youyun Zhisuan platform. ### Method GET ### Endpoint / ### Parameters #### Query Parameters - **Action** (string) - Required - The action to perform, which is "StartCompShareInstance". - **Region** (string) - Required - The region of the instance. Example: cn-wlcb. - **Zone** (string) - Required - The availability zone of the instance. Example: cn-wlcb-01. - **ProjectId** (string) - Optional - The project ID. If not provided, the default project is used. Sub-accounts must provide this. Refer to GetProjectList. - **UHostId** (string) - Required - The instance ID. - **WithoutGpu** (bool) - Optional - Whether to start the instance without a GPU. ### Request Example ``` https://api.compshare.cn/?Action=StartCompShareInstance &Region=cn-zj &Zone=cn-zj-01 &ProjectId=cEMGtAkM &UHostId=NHNZFdXi &WithoutGpu=false ``` ### Response #### Success Response (200) - **RetCode** (int) - The return code. - **Action** (string) - The operation name. - **UHostId** (string) - The instance ID. #### Response Example ```json { "Action": "StartCompShareInstanceResponse", "UHostId": "jkHGryKM", "RetCode": 0 } ``` ``` -------------------------------- ### Get Project ID using Python SDK Source: https://www.compshare.cn/docs/gpus/instance/deletecompsharestopscheduler Use this Python code to retrieve the Project ID required for API requests. Ensure you have the UCloud SDK installed. ```python resp = client.invoke("GetProjectList") project_id = resp["ProjectSet"][0]["ProjectId"] # 例如 "org-cwy2qk" ``` -------------------------------- ### Query Team Member Unpaid Orders (Go) Source: https://www.compshare.cn/docs/gpus/team/describeteammemberunpaidorder This Go SDK example demonstrates how to query unpaid orders for a team member. Make sure to install the SDK and provide your API keys. ```go package main import ( "fmt" "github.com/ucloud/ucloud-sdk-go/services/ucompshare" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) func main() { cfg := ucloud.NewConfig() cfg.Region = "cn-wlcb" cfg.BaseUrl = "https://api.compshare.cn" credential := auth.NewCredential() credential.PublicKey = "my_public_key" // 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取 credential.PrivateKey = "my_private_key" // 替换为你的私钥 client := ucompshare.NewClient(&cfg, &credential) req := client.NewDescribeTeamMemberUnpaidOrderRequest() req.TeamId = ucloud.Uint32(100001) req.VirtualCompanyId = ucloud.Uint32(300001) req.Limit = ucloud.Int(25) req.Offset = ucloud.Int(0) resp, err := client.DescribeTeamMemberUnpaidOrder(req) if err != nil { fmt.Printf("查询失败: %s\n", err) return } for _, order := range resp.OrderInfos { fmt.Printf("订单号: %s, 金额: %s, 资源: %s\n", order.OrderNo, order.Amount, order.ResourceId) } } ``` -------------------------------- ### Backup VNC Startup File Source: https://www.compshare.cn/docs/operation/bestpractices/createVNC Creates a backup of the VNC startup script before modifying it. ```bash cp ~/.vnc/xstartup ~/.vnc/xstartup.bak ``` -------------------------------- ### Install UV and SQLITE on Windows Source: https://www.compshare.cn/docs/modelverse/best_practice/mcp/MCPServer Use winget to install the UV package manager and SQLite on Windows systems. ```bash winget install --id=astral-sh.uv -e winget install sqlite.sqlite ``` -------------------------------- ### Terminate GPU Instance (Go SDK) Source: https://www.compshare.cn/docs/gpus/instance/terminatecompshareinstance This Go SDK example demonstrates how to terminate a GPU compute sharing instance. You need to install the ucloud-sdk-go and replace the placeholder credentials and instance ID. ```go package main import ( "fmt" "github.com/ucloud/ucloud-sdk-go/services/ucompshare" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) func main() { cfg := ucloud.NewConfig() cfg.Region = "cn-wlcb" cfg.Zone = "cn-wlcb-01" cfg.BaseUrl = "https://api.compshare.cn" credential := auth.NewCredential() credential.PublicKey = "my_public_key" // 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取 credential.PrivateKey = "my_private_key" // 替换为你的私钥 client := ucompshare.NewClient(&cfg, &credential) req := client.NewTerminateCompShareInstanceRequest() req.UHostId = ucloud.String("uhost-xxxx") // 实例 ID,通过 DescribeCompShareInstance 获取 resp, err := client.TerminateCompShareInstance(req) if err != nil { fmt.Printf("删除失败: %s\n", err) return } fmt.Printf("删除成功: %s\n", resp.UHostId) } ``` -------------------------------- ### Call Chat Completions API using LangChain Source: https://www.compshare.cn/docs/modelverse/models/quick-start Integrate with LangChain for building complex AI applications. This example demonstrates a basic chat chain setup. Ensure you replace `{model_name}` and `{api_key}`. ```python from langchain_openai import ChatOpenAI from langchain import LLMChain from langchain.prompts import ChatPromptTemplate llm = ChatOpenAI( model_name="{model_name}", openai_api_key="{api_key}", openai_api_base="https://api.modelverse.cn/v1/", ) prompt = ChatPromptTemplate.from_template( """ {input} """ ) chain = LLMChain(llm=llm, prompt=prompt) print(chain.run("一句话描述UCloud这家公司。")) ``` -------------------------------- ### Go SDK Example for DescribeTeamMemberOrderCount Source: https://www.compshare.cn/docs/gpus/team/describeteammemberordercount This Go code snippet demonstrates how to fetch team member order counts using the UCloud Go SDK. Remember to install the SDK and substitute your API keys. ```go package main import ( "fmt" "github.com/ucloud/ucloud-sdk-go/services/ucompshare" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) func main() { cfg := ucloud.NewConfig() cfg.Region = "cn-wlcb" cfg.BaseUrl = "https://api.compshare.cn" credential := auth.NewCredential() credential.PublicKey = "my_public_key" // 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取 credential.PrivateKey = "my_private_key" // 替换为你的私钥 client := ucompshare.NewClient(&cfg, &credential) req := client.NewDescribeTeamMemberOrderCountRequest() req.TeamId = ucloud.Uint32(100001) req.VirtualCompanyId = ucloud.Uint32(300001) req.BeginTime = ucloud.Uint64(1700000000) req.EndTime = ucloud.Uint64(1700086400) resp, err := client.DescribeTeamMemberOrderCount(req) if err != nil { fmt.Printf("查询失败: %s\n", err) return } fmt.Printf("订单总数: %d\n", resp.TotalCount) fmt.Printf("总金额: %s, 实付: %s, 免费额度: %s, 优惠券: %s\n", resp.Amount, resp.AmountReal, resp.AmountFree, resp.AmountCoupon) } ``` -------------------------------- ### Python SDK Example for DescribeTeamMemberOrderCount Source: https://www.compshare.cn/docs/gpus/team/describeteammemberordercount Use this snippet to query team member order counts using the UCloud Python SDK. Ensure the SDK is installed and replace placeholder keys with your actual credentials. ```python from ucloud.core import exc from ucloud.client import Client def main(): client = Client({ "region": "cn-wlcb", "public_key": "my_public_key", # 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取 "private_key": "my_private_key", # 替换为你的私钥 "base_url": "https://api.compshare.cn", }) try: resp = client.ucompshare().describe_team_member_order_count({ "TeamId": 100001, "VirtualCompanyId": 300001, "BeginTime": 1700000000, "EndTime": 1700086400, }) print(f"订单总数: {resp['TotalCount']}") print(f"总金额: {resp['Amount']}") print(f"实付金额: {resp['AmountReal']}") print(f"免费额度: {resp['AmountFree']}") print(f"优惠券: {resp['AmountCoupon']}") except exc.UCloudException as e: print(e) if __name__ == "__main__": main() ``` -------------------------------- ### Create GPU Instance using Python SDK Source: https://www.compshare.cn/docs/gpus/instance/createcompshareinstance Use this Python SDK example to create a GPU instance. Ensure you replace placeholder values for region, public/private keys, and image ID with your actual credentials and resource identifiers. The example demonstrates setting instance specifications, disk configuration, and charge type. ```python from ucloud.core import exc from ucloud.client import Client def main(): client = Client({ "region": "cn-wlcb", "public_key": "my_public_key", # 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取 "private_key": "my_private_key", # 替换为你的私钥 "base_url": "https://api.compshare.cn", }) try: resp = client.ucompshare().invoke("CreateCompShareInstance", { "Region": "cn-wlcb", "Zone": "cn-wlcb-01", "MachineType": "G", "CompShareImageId": "compshareImage-xxxx", # 替换为实际的镜像 ID "GPU": 1, "GpuType": "4090", "CPU": 16, "Memory": 64 * 1024, # 单位 MB,64 * 1024 = 64GB "ChargeType": "Dynamic", "Name": "my-instance", "Disks": [ { "IsBoot": "true", "Size": 200, # 系统盘大小,单位 GB "Type": "CLOUD_SSD", } ], }) print("实例创建成功,UHostIds:", resp.get("UHostIds")) except exc.UCloudException as e: print(e) if __name__ == "__main__": main() ``` -------------------------------- ### Get Team Details with Go SDK Source: https://www.compshare.cn/docs/gpus/team/getcompshareteaminfo This Go code snippet demonstrates how to retrieve team and member information using the UCloud Go SDK. Install the SDK and configure your credentials and base URL. ```go package main import ( "fmt" "github.com/ucloud/ucloud-sdk-go/services/ucompshare" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) func main() { cfg := ucloud.NewConfig() cfg.Region = "cn-wlcb" cfg.BaseUrl = "https://api.compshare.cn" credential := auth.NewCredential() credential.PublicKey = "my_public_key" # 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取 credential.PrivateKey = "my_private_key" # 替换为你的私钥 client := ucompshare.NewClient(&cfg, &credential) req := client.NewGetCompShareTeamInfoRequest() req.TeamId = ucloud.Uint(1001) resp, err := client.GetCompShareTeamInfo(req) if err != nil { fmt.Printf("查询失败: %s\n", err) return } fmt.Printf("团队: %s (ID: %d)\n", resp.Team.Name, resp.Team.Id) for _, member := range resp.TeamRelation { fmt.Printf(" 成员: %s (状态: %s, 可用额度: %d)\n", member.RemarkName, member.Status, member.AvailableAmount) } } ``` -------------------------------- ### Set Team Member Quota - Python SDK Source: https://www.compshare.cn/docs/gpus/team/setcompshareteamamount Use this Python SDK example to set or withdraw quotas for team members. Ensure the UCloud SDK is installed and replace placeholder keys with your actual credentials. ```python from ucloud.core import exc from ucloud.client import Client def main(): client = Client({ "region": "cn-wlcb", "public_key": "my_public_key", # 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取 "private_key": "my_private_key", # 替换为你的私钥 "base_url": "https://api.compshare.cn", }) try: resp = client.ucompshare().set_comp_share_team_amount({ "TeamId": 1001, "VirtualCompanyId": [60001, 60002], "Amount": 100000, "OperateType": "AllocateAmount", }) failed = resp.get("FailedMembers", {}) if failed: for vid, info in failed.items(): print(f"设置失败 - 成员 {vid}: {info['Message']}") else: print("全部设置成功") except exc.UCloudException as e: print(e) if __name__ == "__main__": main() ``` -------------------------------- ### Create CompShare Instance with Go SDK Source: https://www.compshare.cn/docs/gpus/instance/createcompshareinstance Use this Go code to create a CompShare instance. Configure machine type, image ID, GPU details, CPU, memory, and disk parameters. Ensure your API keys and region are correctly set. ```go package main import ( "fmt" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" "github.com/ucloud/ucloud-sdk-go/ucloud/request" "github.com/ucloud/ucloud-sdk-go/ucloud/response" ) type DiskParam struct { IsBoot string // "true" = 系统盘, "false" = 数据盘 Type string // CLOUD_SSD / CLOUD_RSSD / CLOUD_NORMAL Size *int // 磁盘大小 (GB) } type CreateCompShareInstanceRequest struct { request.CommonBase MachineType *string CompShareImageId *string GpuType *string GPU *int CPU *int Memory *int // 单位 MB ChargeType *string `required:"false"` Name *string `required:"false"` Quantity *int `required:"false"` Disks []DiskParam } type CreateCompShareInstanceResponse struct { response.CommonBase UHostIds []string `json:"UHostIds"` // 创建成功的实例 ID 列表 } func main() { cfg := ucloud.NewConfig() cfg.Region = "cn-wlcb" cfg.BaseUrl = "https://api.compshare.cn" credential := auth.NewCredential() credential.PublicKey = "my_public_key" // 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取 credential.PrivateKey = "my_private_key" // 替换为你的私钥 client := ucloud.NewClient(&cfg, &credential) req := &CreateCompShareInstanceRequest{ MachineType: ucloud.String("G"), CompShareImageId: ucloud.String("compshareImage-xxxx"), // 替换为实际的镜像 ID GpuType: ucloud.String("4090"), GPU: ucloud.Int(1), CPU: ucloud.Int(16), Memory: ucloud.Int(64 * 1024), // 单位 MB,64 * 1024 = 64 GB ChargeType: ucloud.String("Dynamic"), Name: ucloud.String("my-instance"), Disks: []DiskParam{ {IsBoot: "true", Type: "CLOUD_SSD", Size: ucloud.Int(200)}, }, } req.SetRegion("cn-wlcb") req.SetZone("cn-wlcb-01") resp := &CreateCompShareInstanceResponse{} if err := client.InvokeAction("CreateCompShareInstance", req, resp); err != nil { fmt.Printf("调用失败: RetCode=%d Msg=%s err=%v\n", resp.RetCode, resp.Message, err) return } fmt.Printf("实例创建成功,UHostIds: %v\n", resp.UHostIds) } ``` -------------------------------- ### Resize Cloud Disk with Go SDK Source: https://www.compshare.cn/docs/gpus/data/resizecompsharedisk This Go SDK example demonstrates how to resize a cloud disk. The cloud disk's associated instance must be in a 'Stopped' state, and the new size must be greater than the current capacity. Remember to replace placeholder credentials. ```go package main import ( "fmt" "github.com/ucloud/ucloud-sdk-go/services/ucompshare" "github.com/ucloud/ucloud-sdk-go/ucloud" "github.com/ucloud/ucloud-sdk-go/ucloud/auth" ) func main() { cfg := ucloud.NewConfig() cfg.Region = "cn-wlcb" cfg.Zone = "cn-wlcb-01" cfg.BaseUrl = "https://api.compshare.cn" credential := auth.NewCredential() credential.PublicKey = "my_public_key" // 替换为你的公钥,从 https://console.compshare.cn/uaccount/api_manage 获取 credential.PrivateKey = "my_private_key" // 替换为你的私钥 client := ucompshare.NewClient(&cfg, &credential) req := client.NewResizeCompShareDiskRequest() req.UDiskId = ucloud.String("udisk-xxxx") // 云盘 ID,通过 DescribeCompShareInstance 的 DiskSet 获取 req.Size = ucloud.Int(200) resp, err := client.ResizeCompShareDisk(req) if err != nil { fmt.Printf("扩容失败: %s\n", err) return } fmt.Printf("扩容成功: %s\n", resp.UDiskId) } ```