Permalink
Browse files

Api updates

  • Loading branch information...
1 parent 2d8fdc4 commit 9d8753c56d50a7304fa160e89354c082c81f6916 @cdujeu cdujeu committed May 18, 2016
@@ -149,6 +149,14 @@
"description": "If it's a move/rename, will remove original after copy operation",
"required": false,
"type": "boolean"
+ },
+ {
+ "name": "override",
+ "in": "query",
+ "description": "Ignore existing resource and override it",
+ "required": false,
+ "type": "boolean",
+ "default": false
}
],
"produces": [
@@ -170,7 +178,7 @@
"patch": {
"x-pydio-plugin": "access.fs",
"x-pydio-action": "fs_update_metadata",
- "description": "Update existing resources metadata (see I/O for content modification). Basic metadata is provided\nby core plugins, but they can be extended by other plugins.\nFor example :\n`{\"core\": {\"chmod\": 777}}, {\"user_meta\":[{\"metaName\":\"metaValue\"}]}`\n`{\"bookmarks\":{\"bookmarked\": true}, \"locks\":{\"locked\":true}, \"meta.watch\":{\"watch\":true}}`\netc...\n",
+ "description": "Update existing resources metadata (see I/O for content modification). Basic metadata is provided by core plugins, but they can be extended by other plugins.\nFor example :\n`{\"core\": {\"chmod\": 777}}, {\"user_meta\":[{\"metaName\":\"metaValue\"}]}`\n`{\"bookmarks\":{\"bookmarked\": true}, \"locks\":{\"locked\":true}, \"meta.watch\":{\"watch\":true}}`\netc...\n",
"operationId": "updateNode",
"parameters": [
{
@@ -231,7 +239,7 @@
"get": {
"x-pydio-plugin": "access.fs",
"x-pydio-action": "download",
- "description": "Get resource content. Depending on the attachment parameter, will try to either trigger a download,\nor send binary stream with appropriate headers.\nDepending on the active plugins, may be able to serve:\n+ Plain text\n+ MP3/Wav Stream\n+ MP4 Stream\n+ On-the-fly generated images\n+ On-the-fly generated thumbnails for images or pdf\n",
+ "description": "Get resource content. Depending on the attachment parameter, will try to either trigger a download, or send binary stream with appropriate headers. Depending on the active plugins, may be able to serve: + Plain text + MP3/Wav Stream + MP4 Stream + On-the-fly generated images + On-the-fly generated thumbnails for images or pdf\n",
"operationId": "download",
"parameters": [
{
@@ -247,7 +255,7 @@
{
"name": "additional_parameters",
"in": "query",
- "description": "some plugin can take more parameters to send various contents derived from main resource. For example, for images, you can pass get_thumb & dimension",
+ "description": "some plugin can take more parameters to send various contents\nderived from main resource. For example, for images, you can pass\nget_thumb & dimension\n",
"type": "string",
"required": false
}
@@ -311,7 +319,7 @@
"$ref": "#/parameters/pathParameter"
},
{
- "name": "file",
+ "name": "userfile_0",
"in": "formData",
"description": "File to upload",
"required": true,
@@ -351,7 +359,7 @@
"type": "boolean"
},
{
- "name": "file",
+ "name": "userfile_0",
"in": "formData",
"description": "File to upload",
"required": true,
@@ -375,8 +383,17 @@
"get": {
"description": "List tasks currently running on the server (and visible to the current user).\n",
"operationId": "listTasks",
+ "x-pydio-plugin": "core.tasks",
+ "x-pydio-action": "tasks_list",
"parameters": [
{
+ "name": "filter",
+ "in": "formData",
+ "description": "additional filters for task listing (JSON serialized)",
+ "type": "string",
+ "required": false
+ },
+ {
"$ref": "#/parameters/workspaceIdFormParameter"
},
{
@@ -387,7 +404,38 @@
"200": {
"description": "Successful Response",
"schema": {
- "$ref": "#/definitions/PydioResponse"
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/Task"
+ }
+ }
+ }
+ },
+ "tags": [
+ "Task"
+ ]
+ }
+ },
+ "/tasks/{taskId}": {
+ "get": {
+ "description": "Get information about a currently running task Id\n",
+ "operationId": "getTaskInfo",
+ "x-pydio-plugin": "core.tasks",
+ "x-pydio-action": "task_info",
+ "parameters": [
+ {
+ "name": "taskId",
+ "in": "path",
+ "description": "Task to monitor on the server",
+ "type": "string",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "schema": {
+ "$ref": "#/definitions/Task"
}
}
},
@@ -398,26 +446,23 @@
"post": {
"description": "Create a task on the server. This will generally trigger a server-side background \"Task\", which ID will be returned in the PydioResponse['tasks'] array\n",
"operationId": "createTask",
+ "x-pydio-plugin": "core.tasks",
+ "x-pydio-action": "task_create",
"parameters": [
{
- "name": "taskName",
- "in": "query",
+ "name": "taskId",
+ "in": "path",
"description": "Task to launch on the server",
"type": "string",
- "enum": [
- "index",
- "purge",
- "restore",
- "mkdir",
- "resync"
- ],
"required": true
},
{
- "$ref": "#/parameters/workspaceIdFormParameter"
- },
- {
- "$ref": "#/parameters/nodeSelectionParameter"
+ "name": "task",
+ "in": "body",
+ "description": "JSON Task object",
+ "schema": {
+ "$ref": "#/definitions/Task"
+ }
}
],
"responses": {
@@ -431,25 +476,53 @@
"tags": [
"Task"
]
- }
- },
- "/tasks/{taskId}": {
- "get": {
- "description": "Get information about a currently running task Id\n",
- "operationId": "getTaskInfo",
+ },
+ "patch": {
+ "description": "Update a task on the server.\n",
+ "operationId": "updateTask",
+ "x-pydio-plugin": "core.tasks",
+ "x-pydio-action": "task_update",
"parameters": [
{
"name": "taskId",
"in": "path",
- "description": "Task to monitor on the server",
+ "description": "Task to update on the server",
"type": "string",
"required": true
},
{
- "$ref": "#/parameters/workspaceIdFormParameter"
- },
+ "name": "task",
+ "in": "body",
+ "description": "JSON Task object",
+ "schema": {
+ "$ref": "#/definitions/Task"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "schema": {
+ "$ref": "#/definitions/Task"
+ }
+ }
+ },
+ "tags": [
+ "Task"
+ ]
+ },
+ "delete": {
+ "description": "Update a task on the server.\n",
+ "operationId": "deleteTask",
+ "x-pydio-plugin": "core.tasks",
+ "x-pydio-action": "task_delete",
+ "parameters": [
{
- "$ref": "#/parameters/nodeSelectionParameter"
+ "name": "taskId",
+ "in": "path",
+ "description": "Task to delete on the server",
+ "type": "string",
+ "required": true
}
],
"responses": {
@@ -657,6 +730,29 @@
},
"description": {
"type": "string"
+ },
+ "userId": {
+ "type": "string"
+ },
+ "wsId": {
+ "type": "string"
+ },
+ "actionName": {
+ "type": "string"
+ },
+ "schedule": {
+ "type": "object",
+ "properties": {
+ "scheduleType": {
+ "type": "string"
+ },
+ "scheduleValue": {
+ "type": "string"
+ }
+ }
+ },
+ "parameters": {
+ "type": "object"
}
}
},
@@ -37,11 +37,6 @@ class ApiRouter
* "cacheOptions" => ["cacheFile" => "path", "cacheDisabled" => true],
*/
private $cacheOptions;
- /**
- * @var object Will be used as '$this' for triggering the callbacks
- */
- private $callbacksContext;
-
private $v2Base = "/api/v2";
private $v1Base = "/api";
@@ -43,6 +43,14 @@ public static function handleRequest(ServerRequestInterface $request, ResponseIn
}
$request = $request->withParsedBody($params);
+ if(in_array("application/json", $request->getHeader("Content-Type"))){
+ $body = "".$request->getBody();
+ $body = json_decode($body, true);
+ if(is_array($body)){
+ $request = $request->withParsedBody(array_merge($request->getParsedBody(), ["request_body" => $body]));
+ }
+ }
+
$serverData = $request->getServerParams();
if(Server::$mode == Server::MODE_REST){
@@ -192,19 +192,31 @@ public static function cast($destination, $sourceObject)
if (is_string($destination)) {
$destination = new $destination();
}
- $sourceReflection = new \ReflectionObject($sourceObject);
$destinationReflection = new \ReflectionObject($destination);
- $sourceProperties = $sourceReflection->getProperties();
- foreach ($sourceProperties as $sourceProperty) {
- $sourceProperty->setAccessible(true);
- $name = $sourceProperty->getName();
- $value = $sourceProperty->getValue($sourceObject);
- if ($destinationReflection->hasProperty($name)) {
- $propDest = $destinationReflection->getProperty($name);
- $propDest->setAccessible(true);
- $propDest->setValue($destination,$value);
- } else {
- $destination->$name = $value;
+ if(is_object($sourceObject)){
+ $sourceReflection = new \ReflectionObject($sourceObject);
+ $sourceProperties = $sourceReflection->getProperties();
+ foreach ($sourceProperties as $sourceProperty) {
+ $sourceProperty->setAccessible(true);
+ $name = $sourceProperty->getName();
+ $value = $sourceProperty->getValue($sourceObject);
+ if ($destinationReflection->hasProperty($name)) {
+ $propDest = $destinationReflection->getProperty($name);
+ $propDest->setAccessible(true);
+ $propDest->setValue($destination,$value);
+ } else {
+ $destination->$name = $value;
+ }
+ }
+ }else{
+ foreach($sourceObject as $name => $value){
+ if ($destinationReflection->hasProperty($name)) {
+ $propDest = $destinationReflection->getProperty($name);
+ $propDest->setAccessible(true);
+ $propDest->setValue($destination,$value);
+ } else {
+ $destination->$name = $value;
+ }
}
}
return $destination;

0 comments on commit 9d8753c

Please sign in to comment.