### HTTP GET Request Example Source: https://edgeone.ai/document/50457 Example of an HTTP GET request structure for querying Cloud Virtual Machine instances in Guangzhou. ```APIDOC ## HTTP GET Request Example ### Description This example demonstrates an HTTP GET request to query a list of Cloud Virtual Machine (CVM) instances in the Guangzhou region. ### Method GET ### Endpoint `https://cvm.tencentcloudapi.com/ ` ### Query Parameters - **Limit** (Integer) - Optional - Maximum number of instances to return. - **Offset** (Integer) - Optional - Offset for pagination. ### Headers - **Authorization** (String) - Required - `TC3-HMAC-SHA256 Credential=AKID********************************/2018-10-09/cvm/tc3_request, SignedHeaders=content-type;host, Signature=5da7a33f6993f0614b047e5df4582db9e9bf4672ba50567dba16c6ccf174c474` - **Content-Type** (String) - Required - `application/x-www-form-urlencoded` - **Host** (String) - Required - `cvm.tencentcloudapi.com` - **X-TC-Action** (String) - Required - `DescribeInstances` - **X-TC-Version** (String) - Required - `2017-03-12` - **X-TC-Timestamp** (Integer) - Required - `1539084154` - **X-TC-Region** (String) - Required - `ap-guangzhou` ### Request Example ``` https://cvm.tencentcloudapi.com/?Limit=10&Offset=0 Authorization: TC3-HMAC-SHA256 Credential=AKID********************************/2018-10-09/cvm/tc3_request, SignedHeaders=content-type;host, Signature=5da7a33f6993f0614b047e5df4582db9e9bf4672ba50567dba16c6ccf174c474 Content-Type: application/x-www-form-urlencoded Host: cvm.tencentcloudapi.com X-TC-Action: DescribeInstances X-TC-Version: 2017-03-12 X-TC-Timestamp: 1539084154 X-TC-Region: ap-guangzhou ``` ``` -------------------------------- ### C Server Socket Setup with IPv6 Support Source: https://edgeone.ai/document/55027 Illustrates setting up a server socket in C that listens for IPv6 connections. This example demonstrates socket creation, binding to an IPv6 address and port, listening for incoming connections, and accepting client connections. It also includes logic to detect and display IPv4-mapped IPv6 addresses. ```c #include #include #include #include #include #include int main(int argc, char **argv) { int l_sockfd; // The server address is an IPv6 address. struct sockaddr_in6 serveraddr; // The client address is an IPv6 address. struct sockaddr_in6 clientAddr; int server_port = 10000; memset(&serveraddr, 0, sizeof(serveraddr)); // Create a socket. l_sockfd = socket(AF_INET6, SOCK_STREAM, 0); if (l_sockfd == -1){ printf("Failed to create socket.\n"); return -1; } // Set the server address. memset(&serveraddr, 0, sizeof(struct sockaddr_in6)); serveraddr.sin6_family = AF_INET6; serveraddr.sin6_port = htons(server_port); serveraddr.sin6_addr = in6addr_any; int isReuse = 1; setsockopt(l_sockfd, SOL_SOCKET,SO_REUSEADDR,(const char*)&isReuse,sizeof(isReuse)); // Associate the socket and server address. int nRet = bind(l_sockfd,(struct sockaddr*)&serveraddr, sizeof(serveraddr)); if(-1 == nRet) { printf("bind error\n"); return -1; } // Listen on the socket. listen(l_sockfd, 5); int clientAddrLen = sizeof(clientAddr); memset(&clientAddr, 0, sizeof(clientAddr)); // Accept connection requests from the client. int linkFd = accept(l_sockfd, (struct sockaddr*)&clientAddr, &clientAddrLen); if(-1 == linkFd) { printf("accept error\n"); return -1; } // The client addresses received here are all stored in the IPv6 structure. // The IPv4 addresses are mapped to IPv6 addresses, for example, "::ffff:119.29.1.1". char addr_p[128] = {0}; inet_ntop(AF_INET6, (void *)&clientAddr.sin6_addr, addr_p, (socklen_t )sizeof(addr_p)); printf("accept %s : %d successful\n", addr_p, ntohs(clientAddr.sin6_port)); // Modifications to make: Use the macro definition IN6_IS_ADDR_V4MAPPED to decide whether the client IP is an IPv4-mapped IPv6 address. if(IN6_IS_ADDR_V4MAPPED(&clientAddr.sin6_addr)) { struct sockaddr_in real_v4_sin; memset (&real_v4_sin, 0, sizeof (struct sockaddr_in)); real_v4_sin.sin_family = AF_INET; real_v4_sin.sin_port = clientAddr.sin6_port; // The last four bytes represent the IPv4 address of the client. memcpy (&real_v4_sin.sin_addr, ((char *)&clientAddr.sin6_addr) + 12, 4); printf("connect %s successful\n", inet_ntoa(real_v4_sin.sin_addr)); } close(l_sockfd); return 0; } ``` -------------------------------- ### Zone Setting Output Example Source: https://edgeone.ai/document/50466 An example of the JSON output for zone settings configuration. ```APIDOC ## GET /websites/edgeone_ai_document/zones/{zone_id}/settings ### Description Retrieves the current configuration settings for a specific zone within the EdgeOne AI platform. ### Method GET ### Endpoint /websites/edgeone_ai_document/zones/{zone_id}/settings ### Parameters #### Path Parameters - **zone_id** (string) - Required - The unique identifier for the zone. ### Response #### Success Response (200) - **Response** (object) - Contains the request ID and zone settings. - **RequestId** (string) - A unique identifier for the request. - **ZoneSetting** (object) - An object containing various configuration settings for the zone. - **AccelerateMainland** (object) - Settings for acceleration in mainland China. - **Switch** (string) - 'on' or 'off'. - **Area** (string) - The geographical area for acceleration (e.g., 'global'). - **CacheConfig** (object) - Cache configuration details. - **Cache** (object) - General cache settings. - **CacheTime** (integer) - Cache duration in seconds. - **Switch** (string) - 'on' or 'off'. - **FollowOrigin** (object) - Settings for following origin server cache directives. - **DefaultCache** (string) - 'on' or 'off'. - **DefaultCacheStrategy** (string) - 'on' or 'off'. - **DefaultCacheTime** (integer) - Default cache time when following origin. - **Switch** (string) - 'on' or 'off'. - **NoCache** (object) - Settings for disabling cache. - **Switch** (string) - 'on' or 'off'. - **CacheKey** (object) - Cache key configuration. - **FullUrlCache** (string) - 'on' or 'off'. - **IgnoreCase** (string) - 'on' or 'off'. - **QueryString** (object) - Query string inclusion settings. - **Action** (string) - Action to take with query strings (e.g., 'includeCustom'). - **Switch** (string) - 'on' or 'off'. - **Value** (array) - Custom query strings to include. - **CachePrefresh** (object) - Cache prefresh settings. - **Percent** (integer) - Percentage of cache to prefresh. - **Switch** (string) - 'on' or 'off'. - **ClientIpCountry** (object) - Settings for identifying client IP country. - **HeaderName** (string) - Name of the header containing the country information. - **Switch** (string) - 'on' or 'off'. - **ClientIpHeader** (object) - Settings for identifying client IP via headers. - **HeaderName** (string) - Name of the header containing the client IP. - **Switch** (string) - 'on' or 'off'. - **Compression** (object) - Compression settings. - **Algorithms** (array) - List of compression algorithms (e.g., ['brotli', 'gzip']). - **Switch** (string) - 'on' or 'off'. - **ForceRedirect** (object) - Force redirect settings. - **RedirectStatusCode** (integer) - HTTP status code for redirection. - **Switch** (string) - 'on' or 'off'. - **Grpc** (object) - gRPC protocol settings. - **Switch** (string) - 'on' or 'off'. - **NetworkErrorLogging** (object) - Network error logging settings. - **Switch** (string) - 'on' or 'off'. - **Https** (object) - HTTPS configuration. - **ApplyType** (string) - Type of HTTPS application (e.g., 'none'). - **CertInfo** (array) - Certificate information. - **CipherSuite** (string) - Allowed cipher suites (e.g., 'loose-v2023'). - **Hsts** (object) - HTTP Strict Transport Security (HSTS) settings. - **IncludeSubDomains** (string) - 'on' or 'off'. - **MaxAge** (integer) - HSTS max age in seconds. - **Preload** (string) - 'on' or 'off'. - **Switch** (string) - 'on' or 'off'. - **Http2** (string) - 'on' or 'off'. - **OcspStapling** (string) - 'on' or 'off'. - **TlsVersion** (array) - Allowed TLS versions (e.g., ['TLSv1', 'TLSv1.2', 'TLSv1.3']). - **ImageOptimize** (object) - Image optimization settings. - **Switch** (string) - 'on' or 'off'. - **Ipv6** (object) - IPv6 support settings. - **Switch** (string) - 'on' or 'off'. - **MaxAge** (object) - Max-Age settings for cache control. - **FollowOrigin** (string) - 'on' or 'off'. - **MaxAgeTime** (integer) - Max-Age duration in seconds. - **OfflineCache** (object) - Offline cache settings. - **Switch** (string) - 'on' or 'off'. - **Origin** (object) - Origin server configuration. - **Origins** (array) - List of primary origin server IP addresses or hostnames. - **BackupOrigins** (array) - List of backup origin server IP addresses or hostnames. - **OriginPullProtocol** (string) - Protocol for origin pull (e.g., 'follow'). - **CosPrivateAccess** (string) - 'on' or 'off'. - **PostMaxSize** (object) - Maximum POST request size settings. - **MaxSize** (integer) - Maximum size in bytes. - **Switch** (string) - 'on' or 'off'. - **Quic** (object) - QUIC protocol settings. - **Switch** (string) - 'on' or 'off'. - **SmartRouting** (object) - Smart routing settings. - **Switch** (string) - 'on' or 'off'. - **StandardDebug** (object) - Standard debug settings. - **AllowClientIPList** (array) - List of allowed client IP addresses for debugging. - **ExpireTime** (string) - Expiration time for debug access. - **Switch** (string) - 'on' or 'off'. - **UpstreamHttp2** (object) - Upstream HTTP/2 settings. - **Switch** (string) - 'on' or 'off'. - **WebSocket** (object) - WebSocket support settings. - **Switch** (string) - 'on' or 'off'. - **Timeout** (integer) - WebSocket connection timeout in seconds. - **JITVideoProcess** (object) - Just-In-Time video processing settings. - **Switch** (string) - 'on' or 'off'. - **ZoneName** (string) - The name of the zone. #### Response Example ```json { "Response": { "RequestId": "88215c08-67de-4c7d-974e-a14461816f5b", "ZoneSetting": { "AccelerateMainland": { "Switch": "off" }, "Area": "global", "CacheConfig": { "Cache": { "CacheTime": 2592000, "Switch": "off" }, "FollowOrigin": { "DefaultCache": "on", "DefaultCacheStrategy": "on", "DefaultCacheTime": 0, "Switch": "on" }, "NoCache": { "Switch": "off" } }, "CacheKey": { "FullUrlCache": "on", "IgnoreCase": "off", "QueryString": { "Action": "includeCustom", "Switch": "off", "Value": [] } }, "CachePrefresh": { "Percent": 90, "Switch": "off" }, "ClientIpCountry": { "HeaderName": "", "Switch": "off" }, "ClientIpHeader": { "HeaderName": "", "Switch": "off" }, "Compression": { "Algorithms": [ "brotli", "gzip" ], "Switch": "on" }, "ForceRedirect": { "RedirectStatusCode": 302, "Switch": "off" }, "Grpc": { "Switch": "off" }, "NetworkErrorLogging": { "Switch": "on" }, "Https": { "ApplyType": "none", "CertInfo": [], "CipherSuite": "loose-v2023", "Hsts": { "IncludeSubDomains": "off", "MaxAge": 0, "Preload": "off", "Switch": "off" }, "Http2": "on", "OcspStapling": "off", "TlsVersion": [ "TLSv1", "TLSv1.1", "TLSv1.2", "TLSv1.3" ] }, "ImageOptimize": { "Switch": "off" }, "Ipv6": { "Switch": "off" }, "MaxAge": { "FollowOrigin": "on", "MaxAgeTime": 600 }, "OfflineCache": { "Switch": "on" }, "Origin": { "Origins": [ "30.12.34.23" ], "BackupOrigins": [ "30.12.34.11" ], "OriginPullProtocol": "follow", "CosPrivateAccess": "off" }, "PostMaxSize": { "MaxSize": 524288000, "Switch": "on" }, "Quic": { "Switch": "off" }, "SmartRouting": { "Switch": "off" }, "StandardDebug": { "AllowClientIPList": [], "ExpireTime": "1969-12-31T16:00:00Z", "Switch": "off" }, "UpstreamHttp2": { "Switch": "off" }, "WebSocket": { "Switch": "off", "Timeout": 30 }, "JITVideoProcess": { "Switch": "off" }, "ZoneName": "wxlagame.com" } } } ``` ``` -------------------------------- ### Query Package Information List (HTTP POST) Source: https://edgeone.ai/document/72310 This example demonstrates how to query a list of package information using an HTTP POST request. It specifies sorting by activation time in descending order and fetches a limited number of results starting from a specific offset. The request includes common parameters and a JSON body with pagination and sorting details. ```HTTP POST / HTTP/1.1 Host: teo.intl.tencentcloudapi.com Content-Type: application/json X-TC-Action: DescribePlans { "Offset": 0, "Limit": 4, "Order": "enable-time", "Direction": "desc" } ``` -------------------------------- ### Create HTTP Server (Python 3) Source: https://edgeone.ai/document/55027 This command starts a simple HTTP server using Python 3 on port 10000. This is used to act as a TCP server for testing purposes, allowing other servers to send requests to it. Requires Python 3 to be installed. ```python # Use python3 python3 -m http.server 10000 ``` -------------------------------- ### Configuration Examples Source: https://edgeone.ai/document/50539 Examples demonstrating how to configure SSL certificates, free certificates, and edge mutual authentication. ```APIDOC ## Configuration Examples ### Example 1: Configuring an SSL Certificate This example shows how to configure a custom SSL certificate for your domain. ### Method POST ### Endpoint `/api/v1/zones/{zone_id}/custom_ssl` ### Parameters #### Request Body - **certificate** (string) - Required - Your SSL certificate content. - **private_key** (string) - Required - Your SSL private key content. ### Request Example ```json { "certificate": "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----", "private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success status. #### Response Example ```json { "status": "success" } ``` ### Example 2: Configuring a Free Certificate This example demonstrates how to configure a free SSL certificate provided by EdgeOne. ### Method POST ### Endpoint `/api/v1/zones/{zone_id}/free_ssl` ### Parameters #### Request Body - **force_renew** (boolean) - Optional - Whether to force renewal of the certificate. ### Request Example ```json { "force_renew": true } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success status. #### Response Example ```json { "status": "success" } ``` ### Example 3: Configuring the Edge Mutual Authentication This example shows how to configure edge mutual authentication (mTLS) with a client certificate. ### Method POST ### Endpoint `/api/v1/zones/{zone_id}/edge_mtls` ### Parameters #### Request Body - **client_cert** (string) - Required - The client certificate content for mutual authentication. - **client_private_key** (string) - Required - The client private key content for mutual authentication. ### Request Example ```json { "client_cert": "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----", "client_private_key": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success status. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Install and Initialize RUM SDK via npm Source: https://edgeone.ai/document/50245 This snippet demonstrates how to install the Real User Monitoring SDK using npm and then initialize it within your JavaScript code. This is suitable for projects managed with npm and provides programmatic control over SDK setup. ```bash npm install --save aegis-sdk ``` ```javascript import Aegis from 'aegis-sdk'; const aegis = new Aegis({ id: 'your_app_id', reportAPI: '//example.com/api/report', // api_domain: 'example.com' }); ``` -------------------------------- ### Enable Smart Acceleration Source: https://edgeone.ai/document/68148 This example demonstrates how to enable Smart Acceleration for improved routing and performance. It is configured for requests to 'www.example.com'. ```json { "Name": "SmartRouting", "SmartRoutingParameters": { "Switch": "on" } } ``` -------------------------------- ### HTTP GET Request Structure with Signature v3 Source: https://edgeone.ai/document/50457 This example demonstrates the structure of an HTTP GET request utilizing the TC3-HMAC-SHA256 signature algorithm. It includes common headers and the Authorization header format. ```http https://cvm.tencentcloudapi.com/?Limit=10&Offset=0 Authorization: TC3-HMAC-SHA256 Credential=AKID********************************/2018-10-09/cvm/tc3_request, SignedHeaders=content-type;host, Signature=5da7a33f6993f0614b047e5df4582db9e9bf4672ba50567dba16c6ccf174c474 Content-Type: application/x-www-form-urlencoded Host: cvm.tencentcloudapi.com X-TC-Action: DescribeInstances X-TC-Version: 2017-03-12 X-TC-Timestamp: 1539084154 X-TC-Region: ap-guangzhou ``` -------------------------------- ### Configure Intelligent Compression Source: https://edgeone.ai/document/68148 This example shows how to configure intelligent compression using the 'gzip' algorithm. It enables compression for requests to 'www.example.com'. ```json { "Name": "Compression", "CompressionParameters": { "Switch": "on", "Algorithms": [ "gzip" ] } } ``` -------------------------------- ### DescribeHostsSetting API Input Example (HTTP) Source: https://edgeone.ai/document/50469 An example of an HTTP POST request to the DescribeHostsSetting API. It demonstrates the necessary headers, common request parameters (placeholder), and the JSON body containing specific parameters like ZoneId for querying domain configurations. ```HTTP POST / HTTP/1.1 Host: teo.intl.tencentcloudapi.com Content-Type: application/json X-TC-Action: DescribeHostsSetting { "ZoneId": "zone-27q0p0bali16" } ``` -------------------------------- ### PHP SDK Example for ModifySecurityClientAttester Source: https://edgeone.ai/document/72280 Shows how to integrate with the ModifySecurityClientAttester API using the Tencent Cloud SDK for PHP. This example outlines the setup and method call for modifying client authentication settings. ```php // This is a placeholder for the actual PHP SDK code. // Actual implementation requires the Tencent Cloud SDK for PHP and specific API call setup. // Example structure: // use TencentCloud\Teo\V20220901\TeoClient; // use TencentCloud\Teo\V20220901\Models\ModifySecurityClientAttesterRequest; // use TencentCloud\Kernel\Common\Credential; // // try { // $cred = new Credential("YOUR_SECRET_ID", "YOUR_SECRET_KEY"); // $client = new TeoClient($cred, "ap-guangzhou", "AKIDxxxxxxxxxxxxxxxxxxxxxxx"); // Example region and token // // $req = new ModifySecurityClientAttesterRequest(); // $req->ZoneId = "zone-12ekfafefe3"; // // ... set ClientAttesters array ... // // $resp = $client->ModifySecurityClientAttester($req); // // Process the response // print_r($resp->toJsonString()); // } catch (TencentCloudSDKException $e) { // echo $e; // } echo "PHP SDK example for ModifySecurityClientAttester goes here."; ``` -------------------------------- ### Configure Throttling Start Time with Variables Source: https://edgeone.ai/document/69574 This example shows how to set the start time for rate limiting using a variable from the request URL's 'time' parameter. Throttling initiates after the specified duration from the start of the response. A value of 0 means throttling occurs for the entire download. ```javascript "${http.request.uri.args["time"]}" ``` -------------------------------- ### Go SDK for Deploy Version Task Source: https://edgeone.ai/document/57976 This Go code example shows how to deploy a version using the Tencent Cloud SDK for Go. It requires setting up credentials, creating a client, and then calling the DeployConfigGroupVersion function with the appropriate parameters including ZoneId, EnvId, and ConfigGroupVersionInfos. ```go // Example for Go SDK is not provided in the text, but would typically look like this: // import ( // "fmt" // "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common" // "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile" // "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/edgeone/v20200319" // "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/edgeone/v20200319/models" // ) // // func main() { // t// 1. Prepare credentials // credential := common.NewCredential("YOUR_SECRET_ID", "YOUR_SECRET_KEY") // cpf := profile.NewClientProfile() // cpf.HttpProfile.Endpoint = "edgeone.tencentcloudapi.com" // // // 2. Create client from credential, zone string and profile. // client, _ := edgeone.NewClient(credential, "ap-guangzhou", cpf) // // // 3. Create request object // req := models.NewDeployConfigGroupVersionRequest() // // // 4. Set parameters // req.ZoneId = common.StringPtr("zone-32qwgrnvbisw") // req.EnvId = common.StringPtr("env-28jw51ksm9bw") // // versionInfo := models.NewConfigGroupVersionInfo() // versionInfo.VersionId = common.StringPtr("ver-2ogs1as803hm") // req.ConfigGroupVersionInfos = []*models.ConfigGroupVersionInfo{versionInfo} // // req.Description = common.StringPtr("Add IPv6 and AccelerationMainland configuration") // // // 5. Call the API // sp, err := client.DeployConfigGroupVersion(req) // if _, ok := err.(*errors.TencentCloudSDKError); ok { // fmt.Printf("An API Error has returned: %s", err) // return // } // // // 6. Print the response // fmt.Printf("%s\n", sp.ToJsonString()) // } ``` -------------------------------- ### HTTP GET Request Example for Signature Algorithm v1 Source: https://edgeone.ai/document/50457 Illustrates the structure of an HTTP GET request incorporating common parameters for Signature Algorithm v1. This includes the API endpoint and query parameters such as Action, Version, SignatureMethod, Timestamp, Signature, Region, Nonce, and SecretId. ```http https://cvm.tencentcloudapi.com/?Action=DescribeInstances&Version=2017-03-12&SignatureMethod=HmacSHA256&Timestamp=1527672334&Signature=37ac2f4fde00b0ac9bd9eadeb459b1bbee224158d66e7ae5fcadb70b2d181d02&Region=ap-guangzhou&Nonce=23823223&SecretId=AKID******************************** Host: cvm.tencentcloudapi.com Content-Type: application/x-www-form-urlencoded ``` -------------------------------- ### Python SDK for DescribeMultiPathGatewaySecretKey Source: https://edgeone.ai/document/72297 Example of using the Tencent Cloud SDK for Python to call the DescribeMultiPathGatewaySecretKey API. This requires installing the SDK and configuring credentials. ```python # Note: Actual SDK code not provided in the source text. This is a placeholder. # import tencentcloud.teo.v20220101.teo_client as teo_client # from tencentcloud.common import credential # from tencentcloud.teo.v20220101.models import DescribeMultiPathGatewaySecretKeyRequest # cred = credential.Credential("YOUR_SECRET_ID", "YOUR_SECRET_KEY") # client = teo_client.TeoClient(cred, "ap-guangzhou") # Example region # req = DescribeMultiPathGatewaySecretKeyRequest() # req.ZoneId = "zone-27q0p0bal192" # resp = client.DescribeMultiPathGatewaySecretKey(req) # print(resp.to_json_string()) ``` -------------------------------- ### Node.js SDK for DescribeMultiPathGatewaySecretKey Source: https://edgeone.ai/document/72297 Example of using the Tencent Cloud SDK for Node.js to call the DescribeMultiPathGatewaySecretKey API. This involves installing the SDK and configuring your access credentials. ```javascript // Note: Actual SDK code not provided in the source text. This is a placeholder. // const tencentcloud = require("tencentcloud-sdk-nodejs"); // const teoClient = require("tencentcloud-sdk-nodejs/tencentcloud/services/teo/v20220101/teo_client"); // const models = require("tencentcloud-sdk-nodejs/tencentcloud/services/teo/v20220101/models"); // const credential = require("tencentcloud-sdk-nodejs/tencentcloud/common/credential"); // const clientProfile = require("tencentcloud-sdk-nodejs/tencentcloud/common/profile/client_profile"); // const httpProfile = require("tencentcloud-sdk-nodejs/tencentcloud/common/profile/http_profile"); // let cred = new credential.Credential("YOUR_SECRET_ID", "YOUR_SECRET_KEY"); // let httpProfile = new httpProfile.HttpProfile(); // let clientProfile = new clientProfile.ClientProfile(); // let client = new teoClient.TeoClient(cred, "ap-guangzhou", clientProfile); // Example region // let req = new models.DescribeMultiPathGatewaySecretKeyRequest(); // req.ZoneId = "zone-27q0p0bal192"; // client.DescribeMultiPathGatewaySecretKey(req).then( // (data) => { // console.log(data); // }, // (err) => { // console.error(err); // } // ); ``` -------------------------------- ### Query Layer-7 Acceleration Site Configuration (HTTP) Source: https://edgeone.ai/document/68149 This example demonstrates how to query the global configuration information for site acceleration using an HTTP POST request. It includes the necessary host, content type, action, and common request parameters along with the specific ZoneId. ```HTTP POST / HTTP/1.1 Host: teo.intl.tencentcloudapi.com Content-Type: application/json X-TC-Action: DescribeL7AccSetting { "ZoneId": "zone-21xfqlh4qjee" } ``` -------------------------------- ### PHP SDK for DescribeMultiPathGatewaySecretKey Source: https://edgeone.ai/document/72297 Example of using the Tencent Cloud SDK for PHP to call the DescribeMultiPathGatewaySecretKey API. Ensure the SDK is installed and your API credentials are configured. ```php // Note: Actual SDK code not provided in the source text. This is a placeholder. // use TencentCloud\Teo\V20220101\TeoClient; // use TencentCloud\Teo\V20220101\Models\DescribeMultiPathGatewaySecretKeyRequest; // try { // $cred = new TencentCloud\Common\Credential("YOUR_SECRET_ID", "YOUR_SECRET_KEY"); // $clientProfile = new TencentCloud\Common\Profile\ClientProfile(); // $httpProfile = new TencentCloud\Common\Profile\HttpProfile(); // $client = new TeoClient($cred, "ap-guangzhou", $clientProfile); // Example region // $req = new DescribeMultiPathGatewaySecretKeyRequest(); // $req->ZoneId = "zone-27q0p0bal192"; // $resp = $client->DescribeMultiPathGatewaySecretKey($req); // print_r($resp->toJsonString()); // } catch (TencentCloud\Common\Exception\TencentCloudSDKException $e) { // echo $e; // } ``` -------------------------------- ### Query Version List using HTTP Source: https://edgeone.ai/document/57974 Demonstrates how to query version information for a specific configuration group and version ID using an HTTP POST request. This example highlights the necessary headers and JSON payload structure. ```http POST / HTTP/1.1 Host: teo.intl.tencentcloudapi.com Content-Type: application/json X-TC-Action: DescribeConfigGroupVersions { "ZoneId": "zone-2kpsqmtisdcb", "GroupId": "cg-27fil26zq2s1", "Filters": [ { "Name": "version-id", "Values": [ "ver-2kuq2mhis9c0" ] } ] } ``` -------------------------------- ### Python SDK for ConfirmMultiPathGatewayOriginACL Source: https://edgeone.ai/document/74213 Example of using the Tencent Cloud SDK for Python to call the ConfirmMultiPathGatewayOriginACL API. This requires the SDK to be installed and configured with your Tencent Cloud credentials. ```python # Python SDK usage example (conceptual, actual implementation depends on SDK structure) # from tencentcloud.teo.v20220901.teo_client import TeoClient # from tencentcloud.common import credential # cred = credential.Credential("YOUR_SECRET_ID", "YOUR_SECRET_KEY") # client = TeoClient(cred, "ap-guangzhou") # Example region # params = { # "ZoneId": "zone-27q0p0bal192", # "GatewayId": "mpgw-lbxuhk1oh", # "OriginACLVersion": 1 # } # response = client.ConfirmMultiPathGatewayOriginACL(params) # print(response) ``` -------------------------------- ### Configure Throttling Start Byte with Variables Source: https://edgeone.ai/document/69574 This example demonstrates how to configure the start byte for rate limiting using a variable extracted from the request URL's 'length' parameter. Throttling begins after the specified byte is downloaded. If the value is 0, throttling applies to the entire download process. ```javascript "${http.request.uri.args["length"]}" ``` -------------------------------- ### Query Available Plans API Request Example Source: https://edgeone.ai/document/50545 This example demonstrates how to construct an HTTP POST request to the DescribeAvailablePlans API. It specifies the necessary headers, including the action and content type, and an empty JSON body. ```http POST / HTTP/1.1 Host: teo.intl.tencentcloudapi.com Content-Type: application/json X-TC-Action: DescribeAvailablePlans {} ``` -------------------------------- ### Query User Sites - Input Example (HTTP) Source: https://edgeone.ai/document/50481 This is an example of an HTTP POST request to query user sites. It includes common request parameters and a JSON body specifying filters for the 'zone-name'. ```http POST / HTTP/1.1 Host: teo.intl.tencentcloudapi.com Content-Type: application/json X-TC-Action: DescribeZones { "Filters": [ { "Name": "zone-name", "Values": [ "example.com" ], "Fuzzy": false } ] } ``` -------------------------------- ### Create Content Identifier using Python SDK Source: https://edgeone.ai/document/68158 Example of creating a content identifier using the Tencent Cloud SDK 3.0 for Python. This requires the SDK to be installed and configured with your credentials. ```python # This is a placeholder for actual Python SDK code. # Refer to Tencent Cloud SDK documentation for implementation details. # Example: # from tencentcloud.edgeone.v20220901 import edgeone_client, models # client = edgeone_client.EdgeoneClient(cred, region) # req = models.CreateContentIdentifierRequest() # params = { # "Description": "content-test", # "PlanId": "edgeone-37q0w7qali10", # "Tags": [ # { # "TagKey": "testkey", # "TagValue": "testvalue" # } # ] # } # req.from_json_string(json.dumps(params)) # resp = client.CreateContentIdentifier(req) # print(resp.to_json_string()) ``` -------------------------------- ### Delete Security Client Attester using C++ SDK Source: https://edgeone.ai/document/72287 This example shows how to call the DeleteSecurityClientAttester API using the Tencent Cloud SDK for C++. It covers client setup and request execution. ```cpp // SDK Code Example for C++ would go here. This is a placeholder. // #include // #include // #include "tencentcloud/core/profile/HttpProfile.h" // #include "tencentcloud/core/profile/ClientProfile.h" // #include "tencentcloud/core/Credential.h" // #include "tencentcloud/xxx/v20220901/XxxClient.h" // #include "tencentcloud/xxx/v20220901/model/DeleteSecurityClientAttesterRequest.h" // #include "tencentcloud/xxx/v20220901/model/DeleteSecurityClientAttesterResponse.h" // using namespace TencentCloud::Xxx::V20220901; // using namespace TencentCloud::Xxx::V20220901::Model; // using namespace TencentCloud::Core; // int main() { // try { // Credential credential("YOUR_SECRET_ID", "YOUR_SECRET_KEY"); // HttpProfile httpProfile; // httpProfile.SetEndpoint("teo.intl.tencentcloudapi.com"); // ClientProfile clientProfile(httpProfile); // XxxClient client(credential, "ap-guangzhou", clientProfile); // Modify region if needed // DeleteSecurityClientAttesterRequest req; // req.SetZoneId("zone-nqicqhasui"); // vector clientAttesterIds = {"attest-2184008405"}; // req.SetClientAttesterIds(clientAttesterIds); // DeleteSecurityClientAttesterResponse resp; // client.DeleteSecurityClientAttester(req, resp); // std::cout << resp.ToJsonString() << std::endl; // } catch (const std::exception& err) { // std::cerr << "Error: " << err.what() << std::endl; // } // return 0; // } ``` -------------------------------- ### Golang Server Setup for Handling Authenticated Requests Source: https://edgeone.ai/document/61296 A basic Golang HTTP server setup using `net/http` to handle incoming requests on a specific port. It includes setting up a router and graceful shutdown capabilities, ready to implement the authentication logic. ```go package main import ( "context" "crypto/md5" "fmt" "log" "net/http" "os" "os/signal" "strings" "syscall" ) func main() { mux := http.NewServeMux() mux.Handle("/access_log/post", &logHandler{}) server := &http.Server{ Addr: ":5000", Handler: mux, } // Create system signal receiver done := make(chan os.Signal) signal.Notify(done, os.Interrupt, syscall.SIGINT, syscall.SIGTERM) go func() { <-done if err := server.Shutdown(context.Background()); err != nil { log.Fatal("Shutdown server:", err) } }() log.Println("Server starting on port 5000") err := server.ListenAndServe() if err != nil { if err == http.ErrServerClosed { log.Print("Server closed under request") } else { log.Fatal("Server closed unexpected") } } } type logHandler struct{} // Implement ServeHTTP method for logHandler func (h *logHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { // Authentication logic will be implemented here if r.URL.Path == "/access_log/post" { // Extract auth_key and access_key from query parameters authKey := r.URL.Query().Get("auth_key") accessKey := r.URL.Query().Get("access_key") if authKey == "" || accessKey == "" { http.Error(w, "auth_key or access_key missing", http.StatusBadRequest) return } // Parse auth_key (timestamp-rand-md5hash) parts := strings.Split(authKey, "-") if len(parts) != 3 { http.Error(w, "Invalid auth_key format", http.StatusBadRequest) return } timestampStr, randStr, receivedMd5Hash := parts[0], parts[1], parts[2] // TODO: Implement timestamp validation (check for expiration) // TODO: Retrieve the correct SecretKey based on accessKey // TODO: Reconstruct the string_to_sign: "uri-timestamp-rand-SecretKey" // TODO: Calculate the MD5 hash of the reconstructed string // TODO: Compare the calculated hash with receivedMd5Hash // For now, just acknowledge the request fmt.Fprintf(w, "Request received. Auth Key: %s, Access Key: %s\n", authKey, accessKey) log.Printf("Received request for path: %s with auth_key: %s and access_key: %s", r.URL.Path, authKey, accessKey) // Example of a placeholder for successful authentication response // In a real scenario, you would proceed with request processing if authenticated w.WriteHeader(http.StatusOK) fmt.Fprintln(w, "Authentication placeholder: Success") } else { http.NotFound(w, r) } } ``` -------------------------------- ### Example: Obtaining Default Certificates (HTTP POST) Source: https://edgeone.ai/document/50541 Demonstrates how to make an HTTP POST request to the DescribeDefaultCertificates API to retrieve default server certificates. It includes common request parameters and a JSON payload with filters. ```http POST / HTTP/1.1 Host: teo.intl.tencentcloudapi.com Content-Type: application/json X-TC-Action: DescribeDefaultCertificates { "Filters": [ { "Name": "zone-id", "Values": [ "zone-fafcasdf" ] } ] } ``` -------------------------------- ### Call DescribeOriginACL API with .NET SDK Source: https://edgeone.ai/document/71118 Example of how to call the DescribeOriginACL API using the Tencent Cloud SDK for .NET. This snippet demonstrates client setup and making the DescribeOriginACL request with the ZoneId. ```csharp using TencentCloud.Common; using TencentCloud.Common.Profile; using TencentCloud.Teo.V20220901; using TencentCloud.Teo.V20220901.Models; using System; using System.Threading.Tasks; public class DescribeOriginACLDemo { public static async Task Main(string[] args) { try { Credential cred = new Credential("SECRETID", "SECRETKEY"); HttpProfile httpProfile = new HttpProfile(); ClientProfile clientProfile = new ClientProfile(); TeoClient client = new TeoClient(cred, "ap-guangzhou", clientProfile); DescribeOriginACLRequest req = new DescribeOriginACLRequest(); req.ZoneId = "zone-276zs184g93m"; DescribeOriginACLResponse resp = await client.DescribeOriginACL(req); Console.WriteLine(AbstractModel.ToJsonString(resp)); } catch (TencentCloudSDKException e) { Console.WriteLine(e); } } } ```