first push

This commit is contained in:
Maff 2019-05-08 00:18:11 +01:00
commit 61c8d5f620
2 changed files with 349 additions and 0 deletions

249
.gitignore vendored Normal file
View File

@ -0,0 +1,249 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that dont work, or not
# install all needed dependencies.
#Pipfile.lock
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that dont work, or not
# install all needed dependencies.
#Pipfile.lock
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
.vscode/
test.py

100
py3cx.py Normal file
View File

@ -0,0 +1,100 @@
class Py3CX:
class _ApiCallBuilder:
apibase='api'
uri='{}/{}/{}'
# TODO: check login URI component
login={
'uri':'',
'method':'POST',
'expect':200
}
# Returns current username, displayed initial(s), 3CX phone system version, current roles, email addresses and information about privileges and enabled features
CurrentUser={
'uri':'CurrentUser',
'method':'GET',
'expepct':200
}
# Returns a list of current calls, including active trunk where available
ActiveCalls={
'uri':'activeCalls',
'method':'GET',
'expepct':200
}
SystemStatus={
'uri':'SystemStatus',
'method':'GET',
'expepct':200
}
# Returns event log entries; optional ?count=INT argument to retrieve specific number of events
EventLog={
'uri':'{}/getEventLog'.format(SystemStatus['uri']),
'method':'GET',
'expect':200
}
# Returns bytes of recording space used and allocated by quota, also returns recording states.
SystemStatusAdditional={
'uri':'{}/AdditionalStatus'.format(SystemStatus['uri']),
'method':'GET',
'expect':200
}
# Returns state of system health (whether firewall, configured trunks and phones meet 3CX support baselines)
SystemStatusHealth={
'uri':'{}/GetSingleStatus'.format(SystemStatus['uri']),
'method':'GET',
'expect':200
}
# TODO: API call 'SystemStatus/getDbInformation'
# TODO: API call 'TrunkList'
# TODO: API call 'InboundRulesList'
# TODO: API call 'OutboundRuleList'
# TODO: API call 'ActivityLog'
# TODO: API call 'ActivityLog/getKeepDays'
# TODO: API call 'ActivityLog/getKeepLogs'
# TODO: API call 'ActivityLog/getLogLevel'
# TODO: API call 'BackupAndRestoreList'
# TODO: API call 'CallLog'
# TODO: API call 'capture/getInterfaces'
# TODO: API call 'CustomParametersList'
# TODO: API call 'ExtensionList'
# TODO: API call 'GroupList'
# TODO: API call 'IpBlackList'
# TODO: API call 'IVRList'
# TODO: API call 'License'
# TODO: API call 'NumberBlackList'
# TODO: API call 'NumberBlackList/new' POST (followed by calls to 'edit/update' and 'edit/save')
# TODO: API call 'NumberBlackList/delete' POST {Ids: ["(number)"]}
# TODO: API call 'PhoneList'
# TODO: API call 'QueueList'
# TODO: API call 'RecordingList'
# TODO: API call 'RingGroupList'
# TODO: API call 'SystemPromptList'
# TODO: API call 'SystemPromptList/promptSets'
# TODO: API call 'SystemPromptList/promptSetUpdates'
# TODO: API call 'UpdateChecker/GetFromParams'
# TODO: API call 'updateChecker/check' POST
# TODO: API call 'updateChecker/isDebian8'
# TODO: API call 'crm/serverCrmUpdates'
# TODO: API call 'crm/clientCrmUpdates'
# TODO: API call 'CrmList/CrmSettings' POST
def __init__(self, uri=None, account=None):
from os import getenv
if uri==None:
uri=getenv('TCX_URI', None)
if account==None:
account={
"username": getenv('TCX_USERNAME', None),
"password": getenv('TCX_PASSWORD', None)
}
assert (len(account['username']>1)), "py3cx was initialised without account information, and TCX_USERNAME does not contain a valid username."
assert (len(account['password']>5)), "py3cx was initialised without account information, and TCX_PASSWORD does not contain a valid password."
#Validation for initialisation parameters
assert (len(uri)>0), "uri must be a full URI to your target 3CX server"
assert (uri.startswith('http')), "uri must be a valid HTTP or HTTPS URI"
assert ('username' in account), "account object must contain username property"
assert ('password' in account), "account object must contain password property"
assert (len(account['username'])>1), "account object must contain a valid username"
assert (len(account['password'])>5), "account object must contain a valid password"
self._base=uri
self._account=account