2014-12-22 13:54:50 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 14:49:16 +00:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2016-05-26 17:56:05 +00:00
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
2015-10-26 12:54:55 +00:00
|
|
|
* @author michag86 <micha_g@arcor.de>
|
2015-03-26 10:44:34 +00:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2016-07-21 14:49:16 +00:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2016-05-26 17:56:05 +00:00
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
2015-03-26 10:44:34 +00:00
|
|
|
* @author Tom Needham <tom@owncloud.com>
|
2014-12-22 13:54:50 +00:00
|
|
|
*
|
2015-03-26 10:44:34 +00:00
|
|
|
* @license AGPL-3.0
|
2014-12-22 13:54:50 +00:00
|
|
|
*
|
2015-03-26 10:44:34 +00:00
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
2015-02-26 10:37:37 +00:00
|
|
|
*
|
2015-03-26 10:44:34 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2014-12-22 13:54:50 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2015-03-26 10:44:34 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
2014-12-22 13:54:50 +00:00
|
|
|
*
|
2015-03-26 10:44:34 +00:00
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2014-12-22 13:54:50 +00:00
|
|
|
*
|
|
|
|
*/
|
2015-02-26 10:37:37 +00:00
|
|
|
|
2016-04-07 15:22:21 +00:00
|
|
|
use OCA\Provisioning_API\Apps;
|
|
|
|
use OCA\Provisioning_API\Users;
|
2015-04-18 08:30:02 +00:00
|
|
|
use OCP\API;
|
|
|
|
|
2016-08-11 07:46:25 +00:00
|
|
|
$app = new \OCA\Provisioning_API\AppInfo\Application();
|
|
|
|
$app->registerRoutes($this, [
|
|
|
|
'ocs' => [
|
|
|
|
// Groups
|
|
|
|
['root' => '/cloud', 'name' => 'Groups#getGroups', 'url' => '/groups', 'verb' => 'GET'],
|
|
|
|
['root' => '/cloud', 'name' => 'Groups#getGroup', 'url' => '/groups/{groupId}', 'verb' => 'GET'],
|
|
|
|
['root' => '/cloud', 'name' => 'Groups#addGroup', 'url' => '/groups', 'verb' => 'POST'],
|
|
|
|
['root' => '/cloud', 'name' => 'Groups#deleteGroup', 'url' => '/groups/{groupId}', 'verb' => 'DELETE'],
|
|
|
|
['root' => '/cloud', 'name' => 'Groups#getSubAdminsOfGroup', 'url' => '/groups/{groupId}/subadmins', 'verb' => 'GET'],
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
|
2015-07-25 10:46:39 +00:00
|
|
|
// Users
|
2016-04-07 15:22:21 +00:00
|
|
|
$users = new Users(
|
2015-07-25 10:46:39 +00:00
|
|
|
\OC::$server->getUserManager(),
|
|
|
|
\OC::$server->getConfig(),
|
2015-07-25 13:01:31 +00:00
|
|
|
\OC::$server->getGroupManager(),
|
2015-10-27 13:09:45 +00:00
|
|
|
\OC::$server->getUserSession(),
|
|
|
|
\OC::$server->getLogger()
|
2015-07-25 10:46:39 +00:00
|
|
|
);
|
2015-08-18 15:43:16 +00:00
|
|
|
API::register('get', '/cloud/users', [$users, 'getUsers'], 'provisioning_api', API::SUBADMIN_AUTH);
|
2015-08-27 16:29:28 +00:00
|
|
|
API::register('post', '/cloud/users', [$users, 'addUser'], 'provisioning_api', API::SUBADMIN_AUTH);
|
2015-07-25 10:46:39 +00:00
|
|
|
API::register('get', '/cloud/users/{userid}', [$users, 'getUser'], 'provisioning_api', API::USER_AUTH);
|
|
|
|
API::register('put', '/cloud/users/{userid}', [$users, 'editUser'], 'provisioning_api', API::USER_AUTH);
|
|
|
|
API::register('delete', '/cloud/users/{userid}', [$users, 'deleteUser'], 'provisioning_api', API::SUBADMIN_AUTH);
|
2016-04-07 15:22:21 +00:00
|
|
|
API::register('put', '/cloud/users/{userid}/enable', [$users, 'enableUser'], 'provisioning_api', API::SUBADMIN_AUTH);
|
|
|
|
API::register('put', '/cloud/users/{userid}/disable', [$users, 'disableUser'], 'provisioning_api', API::SUBADMIN_AUTH);
|
2015-07-25 10:46:39 +00:00
|
|
|
API::register('get', '/cloud/users/{userid}/groups', [$users, 'getUsersGroups'], 'provisioning_api', API::USER_AUTH);
|
|
|
|
API::register('post', '/cloud/users/{userid}/groups', [$users, 'addToGroup'], 'provisioning_api', API::SUBADMIN_AUTH);
|
|
|
|
API::register('delete', '/cloud/users/{userid}/groups', [$users, 'removeFromGroup'], 'provisioning_api', API::SUBADMIN_AUTH);
|
|
|
|
API::register('post', '/cloud/users/{userid}/subadmins', [$users, 'addSubAdmin'], 'provisioning_api', API::ADMIN_AUTH);
|
|
|
|
API::register('delete', '/cloud/users/{userid}/subadmins', [$users, 'removeSubAdmin'], 'provisioning_api', API::ADMIN_AUTH);
|
|
|
|
API::register('get', '/cloud/users/{userid}/subadmins', [$users, 'getUserSubAdminGroups'], 'provisioning_api', API::ADMIN_AUTH);
|
2014-12-22 13:54:50 +00:00
|
|
|
|
|
|
|
// Apps
|
2016-04-07 15:22:21 +00:00
|
|
|
$apps = new Apps(
|
2016-01-05 23:03:08 +00:00
|
|
|
\OC::$server->getAppManager(),
|
|
|
|
\OC::$server->getOcsClient()
|
2015-07-25 19:14:43 +00:00
|
|
|
);
|
2015-07-25 10:46:39 +00:00
|
|
|
API::register('get', '/cloud/apps', [$apps, 'getApps'], 'provisioning_api', API::ADMIN_AUTH);
|
|
|
|
API::register('get', '/cloud/apps/{appid}', [$apps, 'getAppInfo'], 'provisioning_api', API::ADMIN_AUTH);
|
|
|
|
API::register('post', '/cloud/apps/{appid}', [$apps, 'enable'], 'provisioning_api', API::ADMIN_AUTH);
|
|
|
|
API::register('delete', '/cloud/apps/{appid}', [$apps, 'disable'], 'provisioning_api', API::ADMIN_AUTH);
|