python serverdensity.com API包装
py-serverdensit的Python项目详细描述
py server density 1.x
==
about py serverdensity关于py serverdensity
——
``py serverdensity``是一个面向对象的轻量级python库,用于'server density api<;https://github.com/serverdensity.com/sd-api docs`.
该库提供对sd-api中所有get和post方法的访问,负责身份验证,允许您将值作为dict中的项发布,从服务响应返回本机python对象,并引发服务错误的异常。
installation
----
可以使用“pip”从pypi安装库:
pip install py serverdensity
`使用“git”:
git clone git://github.com/1stvamp/py serverdensity.git
cd py serverdensity
python setup.py install
用法
----
安装后,只需从“serverdensity.api”模块导入类“sdapi”,使用服务器密度帐户详细信息实例化该处理程序(记住要为正在使用的帐户打开API访问,请参阅“文档”https://github.com/server density/sd API docs authentication>;`,然后可以作为API处理程序的属性访问每个部分上的方法::
from serverdensity.api import sdapi,sdservicererror
api=sdapi(
account='foo.serverdensity.com',
username='bar',
password='baz'
)
api.alerts.getlast()
尝试:
api.devices.getbyhostname({'hostname':'myserver.somedomain.com'})
api.devices.getbyid({},{'device id':'device\'id'})
除了sdservicererror,e:
打印“错误:”,e
打印“响应:”,e.response
==
about py serverdensity关于py serverdensity
——
``py serverdensity``是一个面向对象的轻量级python库,用于'server density api<;https://github.com/serverdensity.com/sd-api docs`.
该库提供对sd-api中所有get和post方法的访问,负责身份验证,允许您将值作为dict中的项发布,从服务响应返回本机python对象,并引发服务错误的异常。
installation
----
可以使用“pip”从pypi安装库:
pip install py serverdensity
`使用“git”:
git clone git://github.com/1stvamp/py serverdensity.git
cd py serverdensity
python setup.py install
用法
----
安装后,只需从“serverdensity.api”模块导入类“sdapi”,使用服务器密度帐户详细信息实例化该处理程序(记住要为正在使用的帐户打开API访问,请参阅“文档”https://github.com/server density/sd API docs authentication>;`,然后可以作为API处理程序的属性访问每个部分上的方法::
from serverdensity.api import sdapi,sdservicererror
api=sdapi(
account='foo.serverdensity.com',
username='bar',
password='baz'
)
api.alerts.getlast()
尝试:
api.devices.getbyhostname({'hostname':'myserver.somedomain.com'})
api.devices.getbyid({},{'device id':'device\'id'})
除了sdservicererror,e:
打印“错误:”,e
打印“响应:”,e.response