我相信您正在寻找的答案在 API 文档的Create a Syslog Configuration部分。
截至今天,Python SDK 中不存在此方法,因此必须手动调用。
像下面这样的东西——它使用了requests
Python 模块——可能对你有用:
import requests
# define credentials
API_KEY = "<YOUR_API_KEY>"
MANAGER_ADDRESS = "<C1WS_OR_DS_ENDPOINT>"
# init required headers
headers = {
# for Cloud One Workload Security
"Authorization": f"ApiKey {API_KEY}",
# for DS:
"api-secret-key": API_KEY,
"api-version": "v1",
"Content-Type": "application/json",
}
# define syslog configuration
payload = {
# main options
"name": "<YOUR_SYSLOG_NAME>",
"description": "<YOUR_SYSLOG_DESCRIPTION>",
"hostName": "<YOUR_SYSLOG_ENDPOINT>",
"port": 514,
"transport": "tcp|udp",
"facility": "kernel|user|mail|daemon|authorization|syslog|printer|news|uucp|clock|authpriv|ftp|ntp|log-audit|log-alert|cron|local0|local1|local2|local3|local4|local5|local6|local7",
"eventFormat": "standard|cef|leef",
# additional options
"agentDirectForwarding": True | False,
"includeTimezone": True | False,
"privateKey": "<string>",
"certificateChain": ["<string>"],
"sourceIdentifier": "<string>",
}
# make post request to manager
response = requests.request(
method="POST",
url=MANAGER_ADDRESS,
headers=headers,
data=payload,
# for DS:
verify=False,
)