java调用Seafile的部分接口
由于Seafile的接口全部是英文,本人十分不适应,使用的时候做了一份记录。Seafile Web API一、APIBasics(api基础)http://192.168.62.128:8000/ 服务器地址1、All API calls must beauthenticated with a valid Seafile API key.所有的API调用必须验证有效
由于Seafile的接口全部是英文,本人十分不适应,使用的时候做了一份记录。
Seafile Web API
一、APIBasics(api基础)
http://192.168.62.128:8000/ 服务器地址
1、All API calls must beauthenticated with a valid Seafile API key.
所有的API调用必须验证有效的seafile API密钥。
curl -H'Authorization: Token 24fd3c026886e3121b2ca630805ed425c272cb96' http://192.168.62.128:8000/api2/auth/ping/
2、 The api key can be retrieved by theobtain auth api. See the Quick Start for details.
API密钥可以通过获得认证API检索。查看详细信息的快速启动。
3、For each API, we provide curl
examples to illustrate the usage. We also provide python
and javascript
examples, please refer to
https://github.com/haiwen/webapi-examples for details.
对于每个API,我们提供curl示例来说明用法。我们还提供了Python和JavaScript的例子,请参阅https://github.com/haiwen/webapi-examples详情。
Status Code 状态码
· 200: OK 正常
· 201: CREATED 创建
· 202: ACCEPTED 接受
· 301: MOVED_PERMANENTLY 永久移动
· 400: BAD_REQUEST 请求失败
· 403: FORBIDDEN 被禁止的
· 404: NOT_FOUND 没有发现
· 409: CONFLICT 冲突
· 429: TOO_MANY_REQUESTS 请求太多
· 440: REPO_PASSWD_REQUIRED repossessed重新请求密码
· 441: REPO_PASSWD_MAGIC_REQUIRED 重新请求密码的图示仪
· 500: INTERNAL_SERVER_ERROR 内部服务器错误
· 520: OPERATION_FAILED 操作失败
二、Quick Start 快速开始
1、ping
Get请求
curl http://192.168.62.128:8000/api2/ping/
"pong"
示例:
2、obtain auth token
获得认证令牌 post请求
curl -d"username=895890836@qq.com&password=123456"http://192.168.62.128:8000/api2/auth-token/
{"token":"68a6088912e4a5de709a5d73e61d0f8561e58d74"}
Ps: youshould use --data-urlencode if you want to process some special charactersproperly.
你应该采用< url编码编码>如果你想处理一些特殊字符正确。
curl--data-urlencode username=895890836@qq.com -d password=123456 http://192.168.62.128:8000/api2/auth-token/
{"token":"68a6088912e4a5de709a5d73e61d0f8561e58d74"}
3、auth ping
认证 指定请求头参数 get
curl -H'Authorization: Token9027d7b880f7e7c3f6bddeae33b0062e500994d5'http://192.168.62.129:8001/api2/auth/ping/
"pong"
三、Account 账号
1、ListAccounts账户列表
GET http://192.168.62.128:8000/api2/accounts/
Request parameters 请求参数
start (default to 0) 开始默认0
limit (default to 100) 分页100条
scope (default None, accepted values: 'LDAP' or'DB')
作用域(默认没有,接受值:“LDAP”或“DB”)
To retrieve all users,just set both start
and limit
to -1
若要检索所有用户,只需将起始和限值设置为- 1。
If scope parameter is passed then accountswill be searched inside the specific scope, otherwise it will be used the oldapproach: first LDAP and, if no account is found, DB.
如果传递范围参数,那么帐户将在特定范围内搜索,否则将使用旧方法:第一LDAP,如果未找到帐户,则db。
Sample request
请求示例
curl -H"Authorization: Token 68a6088912e4a5de709a5d73e61d0f8561e58d74" -H'Accept: application/json; indent=4' http://192.168.62.128:8000/api2/accounts/
Sample response
[
{
"source": "DB",
"email":"895890836@qq.com"
}
]
Errors
403 Permission error, only administrator canperform this action
403权限错误,只有管理员才能执行此操作
2、Get Account Info 获取账号信息
GET http://192.168.62.128:8000/api2/accounts/{email}/
Request parameters
email 邮箱
Sample request
curl -v -H"Authorization: Token 68a6088912e4a5de709a5d73e61d0f8561e58d74" -H'Accept: application/json; indent=4' http://192.168.62.128:8000/api2/accounts/895890836@qq.com/
Sample response
{
"is_staff":false,
"is_active":true,
"id":2,
"create_time":1356061187741686,
"usage":651463187,
"total":107374182400,
"email":"user@mail.com"
}
3、Check Account Info检查账号信息
GET http://192.168.62.128:8000/api2/account/info/
Sample request
curl -H "Authorization: Token
68a6088912e4a5de709a5d73e61d0f8561e58d74" -H 'Accept: application/json; indent=4' http://192.168.62.128:8000/api2/account/info/
Sample response
{
"usage": 26038531,
"total": 104857600,
"email": "user@example.com"
}
4、Create Account 创建账户
PUT http://192.168.62.128:8000/api2/accounts/{email}/
Request parameters
password
is_staff (defaults to False)
is_active (defaults to True)
Sample request
curl -v -X PUT -d "password=123456&name=lili&login_id=3333" -H "Authorization: Token
9027d7b880f7e7c3f6bddeae33b0062e500994d5" -H 'Accept: application/json; indent=4' http://192.168.62.129:8001/api2/accounts/414370178@qq.com/
Sample response
...
< HTTP/1.0 201 CREATED
< Location: http://192.168.62.128:8000/api2/accounts/newaccount@gmail.com/
...
"success"
Success
Response code 201(Created) is returned and the Location header provides shared link.
Errors
400 Bad Request, keyword password isrequired
403 Permission error, only administratorcan perform this action
400错误的请求,关键字密码是必需的。
403权限错误,只有管理员才能执行此操作
4、Update Account
PUT http://192.168.62.128:8000/api2/accounts/{email}/
Request parameters
At least one of followings:
password
is_staff 是否是职员
is_active 是否是激活的
name
note
storage 存储
Sample request
curl -v -X PUT -d "password=654321&is_staff=true&storage=1073741824" -H "Authorization: Token
68a6088912e4a5de709a5d73e61d0f8561e58d74" -H 'Accept: application/json; indent=4' http://192.168.62.128:8000/api2/accounts/414370178@qq.com/
Sample response
...
< HTTP/1.0 200 OK
...
"success"
Success
Response code 200(OK) is returned.
Errors
400 Bad Request, keyword password isrequired
403 Permission error, only administratorcan perform this action
400错误的请求,关键字密码是必需的。
403权限错误,只有管理员才能执行此操作
5、Migrate Account移动用户(不知道具体作用)
POST http://192.168.62.128:8000/api2/accounts/{email}/
Request parameters
op
to_user this user must exist 这个用户是必须存在的
Sample request
curl -v -d "op=migrate&to_user=7788@qq.com" -H "Authorization: Token
68a6088912e4a5de709a5d73e61d0f8561e58d74" -H 'Accept: application/json; indent=4' http://192.168.62.128:8000/api2/accounts/414370178@qq.com/
Sample response
...
< HTTP/1.0 200 OK
...
"success"
Success
Response code 200(OK) is returned.
Errors
400 Bad Request, arguments are missing or invalid
403 Permission error, only administrator can perform this action
6、Delete Account 删除用户
DELETE http://192.168.62.128:8000/api2/accounts/{email}/
Sample request
curl -v -X DELETE -H "Authorization: Token
68a6088912e4a5de709a5d73e61d0f8561e58d74" -H 'Accept: application/json; indent=4' http://192.168.62.128:8000/api2/accounts/newaccount@qq.com/
Sample response
"success"
Errors
403 Permission error, only administrator can perform this action
403权限错误,只有管理员才能执行此操作
更多推荐
所有评论(0)