我正在尝试在 Trend v12 DSM SAAS 上设置反恶意软件电子邮件自定义,并尝试下面给出的 python 的 API 调用示例。 https://automation.deepsecurity.trendmicro.com/article/dsaas/send-request?platform=dsaas
但是我无法建立连接并且遇到连接问题并出现以下错误。
2019-11-12 10:24:24,653 警告重试(重试(总计=2,连接=无,读取=无,重定向=无,状态=无))连接被“NewConnectionError(”:无法建立新连接:[Errno 11001] getaddrinfo failed')':/api/policies 2019-11-12 10:24:24,655 警告重试(重试(总计=1,连接=无,读取=无,重定向=无,状态=无)) 连接被'NewConnectionError(': 无法建立新连接: [Errno 11001] getaddrinfo failed')': /api/policies 2019-11-12 10:24:24,656 WARNING Retrying (Retry(total=0 , connect=None, read=None, redirect=None, status=None)) 连接被'NewConnectionError(': 无法建立新连接: [Errno 11001] getaddrinfo failed')': /api/policies Traceback (最近一次通话最后):
网址“.trendmicro.com”在我正在使用的代理中列入白名单。r = s.get(' https://app.deepsecurity.trendmicro.com ') 也返回 200 代码。
根据必须通过代理发送流量的网络限制,我无法绕过代理。
import deepsecurity as api
from deepsecurity.rest import ApiException as api_exception
import requests
api.Configuration.verify_ssl = False
s = requests.Session()
s.proxies = {
"http": "http://myproxy:80",
"https": "http://myproxy:80",
}
r = s.get('https://app.deepsecurity.trendmicro.com')
def get_policies_list(api, configuration, api_version, api_exception):
""" Gets a list of policies on the Deep Security Manager
:return: A PoliciesApi object that contains a list of policies.
"""
try:
# Create a PoliciesApi object
policies_api = api.PoliciesApi(api.ApiClient(configuration))
print('getting policy api configuration')
# List policies using version v1 of the API
policies_list = policies_api.list_policies(api_version)
print('getting policy list')
# View the list of policies
return policies_list
except api_exception as e:
return "Exception: " + str(e)
if __name__ == '__main__':
# Add Deep Security Manager host information to the api client configuration
print ('first line')
configuration = api.Configuration()
configuration.host = 'https://app.deepsecurity.trendmicro.com/api'
# Authentication
configuration.api_key['api-secret-key'] = 'mysecretkey'
# Version
api_version = 'v1'
print ('executing the api call')
print(get_policies_list(api, configuration, api_version, api_exception))
我需要做一些其他设置来建立连接吗?请告诉我。