Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* example支持cls产品 Co-authored-by: samlyang <samlyang@tencent.com>
- Loading branch information
Showing
8 changed files
with
471 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
syntax = "proto2"; | ||
|
||
package cls; | ||
|
||
message Log | ||
{ | ||
required int64 time = 1; | ||
message Content | ||
{ | ||
required string key = 1; | ||
required string value = 2; | ||
} | ||
repeated Content contents= 2; | ||
} | ||
|
||
message LogTag | ||
{ | ||
required string key = 1; | ||
required string value = 2; | ||
} | ||
|
||
message LogGroup | ||
{ | ||
repeated Log logs= 1; | ||
optional string contextFlow= 2; | ||
optional string filename = 3; | ||
optional string source = 4; | ||
repeated LogTag logTags = 5; | ||
} | ||
|
||
message LogGroupList | ||
{ | ||
repeated LogGroup logGroupList = 1; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- coding: utf-8 -*- | ||
import os | ||
|
||
from tencentcloud.common import credential | ||
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException | ||
# 导入对应产品模块的client models。 | ||
from tencentcloud.cls.v20201016 import cls_client | ||
from tencentcloud.cls.v20201016 import models | ||
from tencentcloud.common.profile.client_profile import ClientProfile | ||
from tencentcloud.common.profile.http_profile import HttpProfile | ||
|
||
try: | ||
# 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey | ||
cred = credential.Credential( | ||
os.environ.get("TENCENTCLOUD_SECRET_ID"), | ||
os.environ.get("TENCENTCLOUD_SECRET_KEY")) | ||
|
||
# 实例化一个http选项,可选的,没有特殊需求可以跳过。 | ||
httpProfile = HttpProfile() | ||
httpProfile.reqMethod = "POST" # post请求(默认为post请求) | ||
httpProfile.reqTimeout = 30 # 请求超时时间,单位为秒(默认60秒) | ||
httpProfile.endpoint = "cls.tencentcloudapi.com" # 指定接入地域域名(默认就近接入) | ||
httpProfile.keepAlive = True | ||
|
||
# 实例化一个client选项,可选的,没有特殊需求可以跳过。 | ||
clientProfile = ClientProfile() | ||
clientProfile.signMethod = "TC3-HMAC-SHA256" # 指定签名算法(默认为HmacSHA256) | ||
clientProfile.httpProfile = httpProfile | ||
|
||
client = cls_client.ClsClient(cred, "ap-guangzhou", clientProfile) | ||
req = models.CreateTopicRequest() | ||
req.LogsetId = "xxx" | ||
req.TopicName = "xxx" | ||
resp = client.CreateTopic(req) | ||
|
||
# 输出json格式的字符串回包 | ||
print("%s" % resp.to_json_string()) | ||
|
||
except TencentCloudSDKException as err: | ||
print("%s" % err) |
Oops, something went wrong.