mirror of
https://github.com/N4S4/synology-api.git
synced 2025-07-30 12:59:07 +00:00
update v.0.4.0
see release notes for more informations
This commit is contained in:
101
README.md
101
README.md
@ -390,7 +390,6 @@ DS info with below functions:
|
||||
| network_pppoe() |
|
||||
| network_ipv6tunnel() |
|
||||
| network_vpn_pptp() |
|
||||
| network_openvpn_with_conf() |
|
||||
| network_openvpn() |
|
||||
| network_vpn_l2tp() |
|
||||
| domain_schedule() |
|
||||
@ -413,6 +412,41 @@ DS info with below functions:
|
||||
| process() |
|
||||
| utilisation() |
|
||||
| storage() |
|
||||
| external_device_storage_usb() ||
|
||||
| external_device_storage_esata() |
|
||||
| file_index_resource() |
|
||||
| cms_info() |
|
||||
| port_forwarding_rules() |
|
||||
| port_forwarding_router_conf |
|
||||
| disk_list |
|
||||
| ddns_provider_info |
|
||||
| ddns_record_info |
|
||||
| ddns_external_ip |
|
||||
| ddns_synology |
|
||||
| iscsi_lun_info |
|
||||
| hddman |
|
||||
|ftp_security_info|
|
||||
|bandwidth_control_info|
|
||||
|directory_domain_info|
|
||||
|ws_transfer_info|
|
||||
|ref_link_copy_info|
|
||||
|bonjour_service_info|
|
||||
|users_info|
|
||||
|password_policy|
|
||||
|password_expiry|
|
||||
|personal_photo_enable|
|
||||
|ftp_chroot_user|
|
||||
|server_pair|
|
||||
|groups_info|
|
||||
|ldap_info|
|
||||
|sso_iwa_info|
|
||||
|sso_info|
|
||||
|network_interface_info|
|
||||
|proxy_info|
|
||||
|gateway_list|
|
||||
|firewall_info|
|
||||
|auto_upgrade_status|
|
||||
|upgrade_server_check|
|
||||
|
||||
### Virtualization
|
||||
|
||||
@ -465,10 +499,73 @@ DS info with below functions:
|
||||
| set_default_cert() | set default certificate |
|
||||
| upload_cert() | upload a certificate |
|
||||
|
||||
### vpn
|
||||
| Functions |
|
||||
| --- |
|
||||
|settings_list()|
|
||||
|active_connections_list()|
|
||||
|log_list()|
|
||||
|network_interface_setting()|
|
||||
|security_autoblock_setting()|
|
||||
|permission_setting()|
|
||||
|pptp_settings_info()|
|
||||
|openvpn_settings_info()|
|
||||
|l2tp_settings_info()|
|
||||
|
||||
### oauth
|
||||
| Functions |
|
||||
| --- |
|
||||
|clients()|
|
||||
|tokens()|
|
||||
|logs()|
|
||||
|
||||
|
||||
### security_advisor
|
||||
| Functions |
|
||||
| --- |
|
||||
|general_info()|
|
||||
|security_scan()|
|
||||
|checklist()|
|
||||
|login_activity()|
|
||||
|advisor_config()|
|
||||
|scan_config()|
|
||||
|
||||
|
||||
### dhcp_server
|
||||
| Functions |
|
||||
| --- |
|
||||
|general_info()|
|
||||
|vendor()|
|
||||
|pxe()|
|
||||
|tftp()|
|
||||
|network_bond()|
|
||||
|network_ethernet()|
|
||||
|
||||
|
||||
### usb_copy
|
||||
| Functions |
|
||||
| --- |
|
||||
|usb_copy_info()|
|
||||
|toggle_usb_copy()|
|
||||
|logs()|
|
||||
|global_settings()|
|
||||
|
||||
### log_center
|
||||
| Functions |
|
||||
| --- |
|
||||
|logcenter()|
|
||||
|client_status_cnt()|
|
||||
|client_status_eps()|
|
||||
|remote_log_archives()|
|
||||
|display_logs()|
|
||||
|setting_storage_list()|
|
||||
|registry_send_list()|
|
||||
|history()|
|
||||
|
||||
|
||||
#### What's still missing
|
||||
|
||||
There is still few missing function which is a work in progress:
|
||||
There is still few missing function for the api supplied from Synology which is a work in progress:
|
||||
|
||||
| Missing in FileStation |
|
||||
|----------------------|
|
||||
|
2
setup.py
2
setup.py
@ -8,7 +8,7 @@ with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
|
||||
|
||||
setup(
|
||||
name='synology-api',
|
||||
version='0.3.0',
|
||||
version='0.4.0',
|
||||
packages=find_packages(exclude=['tests*']),
|
||||
license='MIT',
|
||||
description='Python Synology API Wrapper',
|
||||
|
@ -3,12 +3,21 @@ from . import \
|
||||
auth,\
|
||||
base_api_core,\
|
||||
directory_server,\
|
||||
docker,\
|
||||
drive_admin_console,\
|
||||
core_active_backup,\
|
||||
core_backup,\
|
||||
core_certificate,\
|
||||
core_sys_info,\
|
||||
downloadstation,\
|
||||
log_center,\
|
||||
vpn,\
|
||||
oauth,\
|
||||
security_advisor,\
|
||||
dhcp_server,\
|
||||
notestation,\
|
||||
filestation,\
|
||||
photos,\
|
||||
usb_copy,\
|
||||
virtualization
|
||||
|
||||
|
@ -4,7 +4,7 @@ import time
|
||||
|
||||
|
||||
class ActiveBackupBusiness(base_api_core.Core):
|
||||
def __init__(self, ip_address, port, username, password, secure=False, cert_verify=False, dsm_version=2, debug=True):
|
||||
def __init__(self, ip_address, port, username, password, secure=False, cert_verify=False, dsm_version=7, debug=True):
|
||||
super(ActiveBackupBusiness, self).__init__(ip_address, port, username, password, secure, cert_verify, dsm_version, debug)
|
||||
|
||||
def list_vm_hypervisor(self):
|
||||
|
@ -2,7 +2,7 @@ from . import base_api_core
|
||||
|
||||
|
||||
class Backup(base_api_core.Core):
|
||||
def __init__(self, ip_address, port, username, password, secure=False, cert_verify=False, dsm_version=2, debug=True):
|
||||
def __init__(self, ip_address, port, username, password, secure=False, cert_verify=False, dsm_version=7, debug=True):
|
||||
super(Backup, self).__init__(ip_address, port, username, password, secure, cert_verify, dsm_version, debug)
|
||||
|
||||
def backup_repository_get(self):
|
||||
|
@ -7,8 +7,10 @@ import json
|
||||
|
||||
class Certificate(base_api_core.Core):
|
||||
def __init__(self, ip_address, port, username, password, secure=False, cert_verify=False, dsm_version=2, debug=True):
|
||||
def __init__(self, ip_address, port, username, password, secure=False, cert_verify=False, dsm_version=7, debug=True):
|
||||
super(Certificate, self).__init__(ip_address, port, username, password, secure, cert_verify, dsm_version, debug)
|
||||
self._debug = debug
|
||||
|
||||
def _base_certificate_methods(self, method, cert_id=None, ids=None):
|
||||
available_method = ['list', 'set', 'delete']
|
||||
if method not in available_method:
|
||||
|
@ -2,7 +2,7 @@ from . import base_api_core
|
||||
|
||||
|
||||
class SysInfo(base_api_core.Core):
|
||||
def __init__(self, ip_address, port, username, password, secure=False, cert_verify=False, dsm_version=2, debug=True):
|
||||
def __init__(self, ip_address, port, username, password, secure=False, cert_verify=False, dsm_version=7, debug=True):
|
||||
super(SysInfo, self).__init__(ip_address, port, username, password, secure, cert_verify, dsm_version, debug)
|
||||
|
||||
def fileserv_smb(self):
|
||||
@ -278,14 +278,6 @@ class SysInfo(base_api_core.Core):
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def network_openvpn_with_conf(self):
|
||||
api_name = 'SYNO.Core.Network.VPN.OpenVPNWithConf'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def network_openvpn(self):
|
||||
api_name = 'SYNO.Core.Network.VPN.OpenVPN'
|
||||
info = self.core_list[api_name]
|
||||
@ -461,3 +453,323 @@ class SysInfo(base_api_core.Core):
|
||||
req_param = {'version': info['maxVersion'], 'method': 'load_info'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def external_device_storage_usb(self):
|
||||
api_name = 'SYNO.Core.ExternalDevice.Storage.USB'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list',
|
||||
'additional': ['dev_type', 'product', 'status', 'partitions']}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def external_device_storage_esata(self):
|
||||
api_name = 'SYNO.Core.ExternalDevice.Storage.eSATA'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list', 'additional': ['dev_type', 'status']}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def file_index_resource(self):
|
||||
api_name = 'SYNO.Finder.FileIndexing.Status'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def cms_info(self):
|
||||
api_name = 'SYNO.Core.CMS.Info'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
# TODO {'error': {'code': 2502}, 'success': False}
|
||||
'''def service_port_info(self):
|
||||
api_name = 'SYNO.Core.Service.PortInfo'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'load', 'target': ['port_forward']}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)'''
|
||||
|
||||
def port_forwarding_rules(self):
|
||||
api_name = 'SYNO.Core.PortForwarding.Rules'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'load'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def port_forwarding_router_conf(self):
|
||||
api_name = 'SYNO.Core.PortForwarding.RouterConf'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def disk_list(self):
|
||||
api_name = 'SYNO.Core.Polling.Data'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def ddns_provider_info(self):
|
||||
api_name = 'SYNO.Core.DDNS.Provider'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def ddns_record_info(self):
|
||||
api_name = 'SYNO.Core.DDNS.Record'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def ddns_external_ip(self):
|
||||
api_name = 'SYNO.Core.DDNS.ExtIP'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list', 'retry': 'true'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def ddns_synology(self):
|
||||
api_name = 'SYNO.Core.DDNS.Synology'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get_myds_account'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def iscsi_lun_info(self):
|
||||
api_name = 'SYNO.Core.ISCSI.LUN'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def hddman(self):
|
||||
api_name = 'SYNO.Storage.CGI.HddMan'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def ftp_security_info(self):
|
||||
api_name = 'SYNO.Core.FileServ.FTP.Security'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def bandwidth_control_info(self):
|
||||
api_name = 'SYNO.Core.BandwidthControl.Protocol'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get', 'protocol': 'FTP'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def directory_domain_info(self): # TODO to test
|
||||
api_name = 'SYNO.Core.Directory.Domain'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def ws_transfer_info(self): # TODO to test
|
||||
api_name = 'SYNO.Core.FileServ.ServiceDiscovery.WSTransfer'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def ref_link_copy_info(self):
|
||||
api_name = 'SYNO.Core.FileServ.ReflinkCopy'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def bonjour_service_info(self):
|
||||
api_name = 'SYNO.Core.ExternalDevice.Printer.BonjourSharing'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def users_info(self, offset=0, limit=-1):
|
||||
api_name = 'SYNO.Core.User'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list', 'type': 'local', 'offset': offset, 'limit': limit}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def password_policy(self):
|
||||
api_name = 'SYNO.Core.User.PasswordPolicy'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def password_expiry(self):
|
||||
api_name = 'SYNO.Core.User.PasswordExpiry'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def personal_photo_enable(self):
|
||||
api_name = 'SYNO.Core.User.Home'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def ftp_chroot_user(self):
|
||||
api_name = 'SYNO.Core.FileServ.FTP.ChrootUser'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'load'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def server_pair(self):
|
||||
api_name = 'SYNO.S2S.Server.Pair'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list', 'additional': ['sync_shares']}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def groups_info(self, offset=0, limit=-1, name_only=False):
|
||||
api_name = 'SYNO.Core.Group'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
|
||||
if name_only:
|
||||
name_only = 'true'
|
||||
elif not name_only:
|
||||
name_only = 'false'
|
||||
else:
|
||||
return 'name_only must be True or False'
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list', 'offset': offset, 'limit': limit,
|
||||
'name_only': name_only, 'type': 'local'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def ldap_info(self):
|
||||
api_name = 'SYNO.Core.Directory.LDAP'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
# TODO {'error': {'code': 103}, 'success': False}
|
||||
'''def domain_info(self):
|
||||
api_name = 'SYNO.Core.Directory.Domain'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get', 'get': {'additional': 'true'}}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)'''
|
||||
|
||||
def sso_iwa_info(self):
|
||||
api_name = 'SYNO.Core.Directory.SSO.IWA'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def sso_info(self):
|
||||
api_name = 'SYNO.Core.Directory.SSO'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def network_interface_info(self):
|
||||
api_name = 'SYNO.Core.Network.Interface'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def proxy_info(self):
|
||||
api_name = 'SYNO.Core.Network.Proxy'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def gateway_list(self, ip_type='ipv4', type='wan'):
|
||||
api_name = 'SYNO.Core.Network.Router.Gateway.List'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get', 'iptype': ip_type, 'type': type}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def firewall_info(self):
|
||||
api_name = 'SYNO.Core.Security.Firewall.Profile'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
# TODO {'error': {'code': 101}, 'success': False}
|
||||
'''def upgrade_schedule_set(self, week_day=4, hour=4, minute=10):
|
||||
api_name = 'SYNO.Core.Upgrade.Setting'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
|
||||
schedule = {'week_day': '4', 'hour': 4, 'minute': 10}
|
||||
req_param = {'version': info['maxVersion'], 'method': 'set', 'autoupdate_type': 'hotfix-security',
|
||||
'schedule': schedule}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)'''
|
||||
|
||||
def auto_upgrade_status(self):
|
||||
api_name = 'SYNO.Core.Upgrade.AutoUpgrade'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'status'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def upgrade_server_check(self):
|
||||
api_name = 'SYNO.Core.Upgrade.Server'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'check', 'user_reading': 'true',
|
||||
'need_auto_smallupdate': 'true', 'need_promotion': 'true'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
54
synology_api/dhcp_server.py
Normal file
54
synology_api/dhcp_server.py
Normal file
@ -0,0 +1,54 @@
|
||||
from . import base_api_core
|
||||
|
||||
|
||||
class dhcp_server(base_api_core.Core):
|
||||
def __init__(self, ip_address, port, username, password, secure=False, cert_verify=False, dsm_version=7, debug=True):
|
||||
super(dhcp_server, self).__init__(ip_address, port, username, password, secure, cert_verify, dsm_version, debug)
|
||||
|
||||
def general_info(self):
|
||||
api_name = 'SYNO.Network.DHCPServer'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get', 'ifname': 'ovs_eth0'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def vendor(self):
|
||||
api_name = 'SYNO.Network.DHCPServer.Vendor'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def pxe(self):
|
||||
api_name = 'SYNO.Network.DHCPServer.PXE'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def tftp(self):
|
||||
api_name = 'SYNO.Core.TFTP'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def network_bond(self):
|
||||
api_name = 'SYNO.Core.Network.Bond'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def network_ethernet(self):
|
||||
api_name = 'SYNO.Core.Network.Ethernet'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
56
synology_api/docker.py
Normal file
56
synology_api/docker.py
Normal file
@ -0,0 +1,56 @@
|
||||
from . import base_api_core
|
||||
|
||||
|
||||
class Docker(base_api_core.Core):
|
||||
def __init__(self, ip_address, port, username, password, secure=False, cert_verify=False, dsm_version=7,
|
||||
debug=True):
|
||||
super(Docker, self).__init__(ip_address, port, username, password, secure, cert_verify, dsm_version, debug)
|
||||
|
||||
def containers(self):
|
||||
api_name = 'SYNO.Docker.Container'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list', 'limit': '-1', 'offset': '0', 'type': 'all'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def container_resources(self):
|
||||
api_name = 'SYNO.Docker.Container.Resource'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def system_resources(self):
|
||||
api_name = 'SYNO.Core.System.Utilization'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def downloaded_images(self):
|
||||
api_name = 'SYNO.Docker.Image'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list', 'limit': '-1', 'offset': '0',
|
||||
"show_dsm": 'false'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def images_registry_resources(self):
|
||||
api_name = 'SYNO.Docker.Registry'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def network(self):
|
||||
api_name = 'SYNO.Docker.Network'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
130
synology_api/drive_admin_console.py
Normal file
130
synology_api/drive_admin_console.py
Normal file
@ -0,0 +1,130 @@
|
||||
from . import base_api_core
|
||||
|
||||
|
||||
class admin_console(base_api_core.Core):
|
||||
def __init__(self, ip_address, port, username, password, secure=False, cert_verify=False, dsm_version=7,
|
||||
debug=True):
|
||||
super(admin_console, self).__init__(ip_address, port, username, password, secure, cert_verify, dsm_version, debug)
|
||||
|
||||
def status_info(self):
|
||||
api_name = 'SYNO.SynologyDrive'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get_status'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def config_info(self):
|
||||
api_name = 'SYNO.SynologyDrive.Config'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def connections(self):
|
||||
api_name = 'SYNO.SynologyDrive.Connection'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'summary'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def drive_check_user(self):
|
||||
api_name = 'SYNO.SynologyDrive'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'check_user'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def active_connections(self):
|
||||
api_name = 'SYNO.SynologyDrive.Connection'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def active_sync_connections(self):
|
||||
api_name = 'SYNO.SynologyDriveShareSync.Connection'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def share_active_list(self):
|
||||
api_name = 'SYNO.SynologyDrive.Share'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list_active'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def log(self, share_type='all', get_all=False, limit=1000, keyword='', date_from=0, date_to=0, username='',
|
||||
target='user'):
|
||||
api_name = 'SYNO.SynologyDrive.Log'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
|
||||
if get_all:
|
||||
get_all = 'true'
|
||||
elif not get_all:
|
||||
get_all = 'false'
|
||||
else:
|
||||
return 'get_all must be True or False'
|
||||
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list', 'share_type': share_type, 'get_all': get_all,
|
||||
'limit': limit, 'keyword': keyword, 'datefrom': date_from, 'dateto': date_to, 'username': username,
|
||||
'target': target}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def c2fs_share(self):
|
||||
api_name = 'SYNO.C2FS.Share'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def settings(self):
|
||||
api_name = 'SYNO.SynologyDrive.Settings'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def db_usage(self):
|
||||
api_name = 'SYNO.SynologyDrive.DBUsage'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def delete_status(self):
|
||||
api_name = 'SYNO.SynologyDrive.Node.Delete'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'status'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def file_property_transfer_status(self):
|
||||
api_name = 'SYNO.SynologyDrive.Migration.UserHome'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'status'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def user_sync_profile(self, user='', start=0, limit='null'):
|
||||
api_name = 'SYNO.SynologyDrive.Profiles'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list', 'start': start, 'limit': limit, 'user': user}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
71
synology_api/log_center.py
Normal file
71
synology_api/log_center.py
Normal file
@ -0,0 +1,71 @@
|
||||
from . import base_api_core
|
||||
|
||||
|
||||
class LogCenter(base_api_core.Core):
|
||||
def __init__(self, ip_address, port, username, password, secure=False, cert_verify=False, dsm_version=7,
|
||||
debug=True):
|
||||
super(LogCenter, self).__init__(ip_address, port, username, password, secure, cert_verify, dsm_version, debug)
|
||||
|
||||
def logcenter(self):
|
||||
api_name = 'SYNO.LogCenter.RecvRule'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def client_status_cnt(self):
|
||||
api_name = 'SYNO.Core.SyslogClient.Status'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'cnt_get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def client_status_eps(self):
|
||||
api_name = 'SYNO.Core.SyslogClient.Status'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'eps_get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def remote_log_archives(self):
|
||||
api_name = 'SYNO.LogCenter.Log'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get_remotearch_subfolder'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def display_logs(self):
|
||||
api_name = 'SYNO.Core.SyslogClient.Log'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def setting_storage_list(self):
|
||||
api_name = 'SYNO.LogCenter.Setting.Storage'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def registry_send_list(self):
|
||||
api_name = 'SYNO.LogCenter.Client'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def history(self):
|
||||
api_name = 'SYNO.LogCenter.History'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
101
synology_api/notestation.py
Normal file
101
synology_api/notestation.py
Normal file
@ -0,0 +1,101 @@
|
||||
from . import base_api_core
|
||||
|
||||
|
||||
class NoteStation(base_api_core.Core):
|
||||
def __init__(self, ip_address, port, username, password, secure=False, cert_verify=False, dsm_version=7,
|
||||
debug=True):
|
||||
super(NoteStation, self).__init__(ip_address, port, username, password, secure, cert_verify, dsm_version, debug)
|
||||
|
||||
def settings_info(self):
|
||||
api_name = 'SYNO.NoteStation.Setting'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
# TODO success response but need more info about it
|
||||
'''def notestation_settings_init(self):
|
||||
api_name = 'SYNO.NoteStation.Setting'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'init'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)'''
|
||||
|
||||
def info(self):
|
||||
api_name = 'SYNO.NoteStation.Info'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def notebooks_info(self):
|
||||
api_name = 'SYNO.NoteStation.Notebook'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def tags_info(self):
|
||||
api_name = 'SYNO.NoteStation.Tag'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def shortcuts(self):
|
||||
api_name = 'SYNO.NoteStation.Shortcut'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def todo(self):
|
||||
api_name = 'SYNO.NoteStation.Todo'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def smart(self): # TODO need to investigate for additional params
|
||||
api_name = 'SYNO.NoteStation.Smart'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def note_list(self):
|
||||
api_name = 'SYNO.NoteStation.Note'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def specific_note_id(self, note_id):
|
||||
api_name = 'SYNO.NoteStation.Note'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
|
||||
if note_id is None:
|
||||
return 'note_id must be specify, run note_list() and copy object_id that you need'
|
||||
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get', 'object_id': note_id}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
# TODO success response but need additional data
|
||||
'''def note_idle(self):
|
||||
api_name = 'SYNO.NoteStation.Note'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'idle'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)'''
|
30
synology_api/oauth.py
Normal file
30
synology_api/oauth.py
Normal file
@ -0,0 +1,30 @@
|
||||
from . import base_api_core
|
||||
|
||||
|
||||
class OAuth(base_api_core.Core):
|
||||
def __init__(self, ip_address, port, username, password, secure=False, cert_verify=False, dsm_version=7, debug=True):
|
||||
super(OAuth, self).__init__(ip_address, port, username, password, secure, cert_verify, dsm_version, debug)
|
||||
|
||||
def clients(self, offset=0, limit=20):
|
||||
api_name = 'SYNO.OAUTH.Client'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list', 'offset': offset, 'limit': limit}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def tokens(self, offset=0, limit=20):
|
||||
api_name = 'SYNO.OAUTH.Token'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list', 'offset': offset, 'limit': limit}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def logs(self, offset=0, limit=20):
|
||||
api_name = 'SYNO.OAUTH.Log'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list', 'action': 'list', 'offset': offset, 'limit': limit}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
54
synology_api/security_advisor.py
Normal file
54
synology_api/security_advisor.py
Normal file
@ -0,0 +1,54 @@
|
||||
from . import base_api_core
|
||||
|
||||
|
||||
class SecurityAdvisor(base_api_core.Core):
|
||||
def __init__(self, ip_address, port, username, password, secure=False, cert_verify=False, dsm_version=7, debug=True):
|
||||
super(SecurityAdvisor, self).__init__(ip_address, port, username, password, secure, cert_verify, dsm_version, debug)
|
||||
|
||||
def general_info(self):
|
||||
api_name = 'SYNO.SecurityAdvisor.Conf.Location'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def security_scan(self):
|
||||
api_name = 'SYNO.Core.SecurityScan.Conf'
|
||||
info = self.core_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def checklist(self):
|
||||
api_name = 'SYNO.SecurityAdvisor.Conf.Checklist'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list', 'group': 'home'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def login_activity(self, offset=0, limit=20):
|
||||
api_name = 'SYNO.SecurityAdvisor.LoginActivity'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'list', 'offser': offset, 'limit': limit}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def advisor_config(self):
|
||||
api_name = 'SYNO.SecurityAdvisor.Conf'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def scan_config(self):
|
||||
api_name = 'SYNO.Core.SecurityScan.Conf'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'group_enum', 'argGroup': 'custom'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
47
synology_api/usb_copy.py
Normal file
47
synology_api/usb_copy.py
Normal file
@ -0,0 +1,47 @@
|
||||
from . import base_api_core
|
||||
|
||||
|
||||
class USB_Copy(base_api_core.Core):
|
||||
def __init__(self, ip_address, port, username, password, secure=False, cert_verify=False, dsm_version=7, debug=True):
|
||||
super(USB_Copy, self).__init__(ip_address, port, username, password, secure, cert_verify, dsm_version, debug)
|
||||
|
||||
def usb_copy_info(self, id=1):
|
||||
api_name = 'SYNO.USBCopy'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get', 'id': id}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def toggle_usb_copy(self, enable=True, id=1):
|
||||
api_name = 'SYNO.USBCopy'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
|
||||
if enable:
|
||||
enable = 'enable'
|
||||
elif not enable:
|
||||
enable = 'disable'
|
||||
else:
|
||||
return 'enable must be True or False'
|
||||
|
||||
req_param = {'version': info['maxVersion'], 'method': enable, 'id': id}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def logs(self, offset=0, limit=200):
|
||||
api_name = 'SYNO.USBCopy'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get_log_list', 'offset': offset, 'limit': limit,
|
||||
'log_filter': '{"log_desc_id_list":[0,1,2,3,10,11,100,101,102,103,104,105,1000]}'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def global_settings(self):
|
||||
api_name = 'SYNO.USBCopy'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get_global_setting'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
@ -3,7 +3,7 @@ from . import auth as syn
|
||||
|
||||
class Virtualization:
|
||||
|
||||
def __init__(self, ip_address, port, username, password, secure=False, cert_verify=False, dsm_version=2, debug=True):
|
||||
def __init__(self, ip_address, port, username, password, secure=False, cert_verify=False, dsm_version=7, debug=True):
|
||||
|
||||
self.session = syn.Authentication(ip_address, port, username, password, secure, cert_verify, dsm_version, debug)
|
||||
|
||||
|
215
synology_api/vpn.py
Normal file
215
synology_api/vpn.py
Normal file
@ -0,0 +1,215 @@
|
||||
from . import base_api_core
|
||||
|
||||
|
||||
class VPN(base_api_core.Core):
|
||||
def __init__(self, ip_address, port, username, password, secure=False, cert_verify=False, dsm_version=7,
|
||||
debug=True):
|
||||
super(VPN, self).__init__(ip_address, port, username, password, secure, cert_verify, dsm_version, debug)
|
||||
|
||||
def settings_list(self):
|
||||
api_name = 'SYNO.VPNServer.Settings.Config'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'status_load'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def active_connections_list(self, sort='login_time', dir='DESC', start=0, limit=100):
|
||||
api_name = 'SYNO.VPNServer.Management.Connection'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'enum', 'sort': sort, 'dir': dir, 'start': start,
|
||||
'limit': limit}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def log_list(self, start=0, limit=50, prtltype=0):
|
||||
api_name = 'SYNO.VPNServer.Management.Log'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'load', 'start': start, 'limit': limit,
|
||||
'prtltype': prtltype}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def network_interface_setting(self):
|
||||
api_name = 'SYNO.VPNServer.Management.Interface'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'load'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def security_autoblock_setting(self):
|
||||
api_name = 'SYNO.Core.Security.AutoBlock'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'get'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def permission_setting(self, start=0, limit=100):
|
||||
api_name = 'SYNO.VPNServer.Management.Account'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'load', 'action': 'enum', 'start': str(start),
|
||||
'limit': str(limit)}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def pptp_settings_info(self):
|
||||
api_name = 'SYNO.VPNServer.Settings.Config'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'load', 'serv_type': 'pptp'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def openvpn_settings_info(self):
|
||||
api_name = 'SYNO.VPNServer.Settings.Config'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'load', 'serv_type': 'openvpn'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
def l2tp_settings_info(self):
|
||||
api_name = 'SYNO.VPNServer.Settings.Config'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
req_param = {'version': info['maxVersion'], 'method': 'load', 'serv_type': 'l2tp'}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)
|
||||
|
||||
# TODO not working {'error': {'code': 600}, 'success': False} response
|
||||
'''def pptp_settings_setup(self, serv_type='pptp', serv_enable=True, serv_ip='10.0.0.0', serv_range=5, auth_type=2,
|
||||
auth_conn=3, mppe_type=1, mtu=1400, dns_check=False, dns='192.168.1.1'):
|
||||
api_name = 'SYNO.VPNServer.Settings.Config'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
|
||||
if serv_enable:
|
||||
serv_enable = 'true'
|
||||
elif not serv_enable:
|
||||
serv_enable = 'false'
|
||||
else:
|
||||
return 'serv_enable must be True or False'
|
||||
|
||||
if dns_check:
|
||||
dns_check = 'true'
|
||||
elif not dns_check:
|
||||
dns_check = 'false'
|
||||
else:
|
||||
return 'dns_check must be True or False'
|
||||
|
||||
req_param = {'version': info['maxVersion'], 'method': 'apply', 'serv_type': serv_type,
|
||||
'serv_enable': serv_enable, 'serv_ip': serv_ip, 'serv_range': serv_range,
|
||||
'auth_type': auth_type, 'auth_conn': auth_conn, 'mppe_type': mppe_type, 'mtu': mtu,
|
||||
'dns_check': dns_check, 'dns': dns}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)'''
|
||||
|
||||
# TODO not working {'error': {'code': 600}, 'success': False} response
|
||||
'''def openvpn_settings_setup(self, serv_type='openvpn', serv_enable=True, serv_ip='10.8.0.0', serv_range=5,
|
||||
comp_enable=True, push_route_enable=False, tls_auth_key=False, verify_server_cn=False,
|
||||
auth_conn=3, port=1194, protocol='udp', encryption='AES-256-CBC', authentication= 'SHA512',
|
||||
enable_ipv6_server=False, ipv6_prefix='', mssfix_value=1450):
|
||||
api_name = 'SYNO.VPNServer.Settings.Config'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
|
||||
if serv_enable:
|
||||
serv_enable = 'true'
|
||||
elif not serv_enable:
|
||||
serv_enable = 'false'
|
||||
else:
|
||||
return 'serv_enable must be True or False'
|
||||
|
||||
if comp_enable:
|
||||
comp_enable = 'true'
|
||||
elif not comp_enable:
|
||||
comp_enable = 'false'
|
||||
else:
|
||||
return 'comp_enable must be True or False'
|
||||
|
||||
if push_route_enable:
|
||||
push_route_enable = 'true'
|
||||
elif not push_route_enable:
|
||||
push_route_enable = 'false'
|
||||
else:
|
||||
return 'push_route_enable must be True or False'
|
||||
|
||||
if tls_auth_key:
|
||||
tls_auth_key = 'true'
|
||||
elif not tls_auth_key:
|
||||
tls_auth_key = 'false'
|
||||
else:
|
||||
return 'tls_auth_key must be True or False'
|
||||
|
||||
if verify_server_cn:
|
||||
verify_server_cn = 'true'
|
||||
elif not verify_server_cn:
|
||||
verify_server_cn = 'false'
|
||||
else:
|
||||
return 'verify_server_cn must be True or False'
|
||||
|
||||
if enable_ipv6_server:
|
||||
enable_ipv6_server = 'true'
|
||||
elif not enable_ipv6_server:
|
||||
enable_ipv6_server = 'false'
|
||||
else:
|
||||
return 'enable_ipv6_server must be True or False'
|
||||
|
||||
req_param = {'version': info['maxVersion'], 'method': 'apply', 'serv_type': serv_type,
|
||||
'serv_enable': serv_enable, 'serv_ip': serv_ip, 'serv_range': serv_range,
|
||||
'comp_enable': comp_enable, 'push_route_enable': push_route_enable, 'tls_auth_key': tls_auth_key,
|
||||
'verify_server_cn': verify_server_cn, 'auth_conn': auth_conn, 'port': port, 'protocol': protocol,
|
||||
'encryption': encryption, 'authentication': authentication,
|
||||
'enable_ipv6_server': enable_ipv6_server, 'ipv6_prefix': ipv6_prefix, 'mssfix_value': mssfix_value}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)'''
|
||||
|
||||
# TODO not working {'error': {'code': 600}, 'success': False} response
|
||||
'''def l2tp_settings_setup(self, serv_type='l2tp', serv_enable=True, serv_ip='10.2.0.0', serv_range=5,
|
||||
auth_type=2, auth_conn=3, mtu=1400, dns_check=False, dns='192.168.1.1', preshared_key='',
|
||||
preshared_key_confirm='', sha2_truncbug=True, kernel_mode=True):
|
||||
api_name = 'SYNO.VPNServer.Settings.Config'
|
||||
info = self.gen_list[api_name]
|
||||
api_path = info['path']
|
||||
|
||||
if serv_enable:
|
||||
serv_enable = 'true'
|
||||
elif not serv_enable:
|
||||
serv_enable = 'false'
|
||||
else:
|
||||
return 'serv_enable must be True or False'
|
||||
|
||||
if dns_check:
|
||||
dns_check = 'true'
|
||||
elif not dns_check:
|
||||
dns_check = 'false'
|
||||
else:
|
||||
return 'dns_check must be True or False'
|
||||
|
||||
if sha2_truncbug:
|
||||
sha2_truncbug = 'true'
|
||||
elif not sha2_truncbug:
|
||||
sha2_truncbug = 'false'
|
||||
else:
|
||||
return 'sha2_truncbug must be True or False'
|
||||
|
||||
if kernel_mode:
|
||||
kernel_mode = 'true'
|
||||
elif not kernel_mode:
|
||||
kernel_mode = 'false'
|
||||
else:
|
||||
return 'kernel_mode must be True or False'
|
||||
|
||||
req_param = {'version': info['maxVersion'], 'method': 'apply', 'serv_type': serv_type,
|
||||
'serv_enable': serv_enable, 'serv_ip': serv_ip, 'serv_range': serv_range,
|
||||
'auth_type': auth_type, 'auth_conn': auth_conn, 'mtu': mtu, 'dns_check': dns_check, 'dns': dns,
|
||||
'preshared_key': preshared_key, 'preshared_key_confirm': preshared_key_confirm,
|
||||
'sha2_truncbug': sha2_truncbug, 'kernel_mode': kernel_mode}
|
||||
|
||||
return self.request_data(api_name, api_path, req_param)'''
|
||||
|
Reference in New Issue
Block a user