diff --git a/appinfo/routes.php b/appinfo/routes.php deleted file mode 100644 index 30daf561f..000000000 --- a/appinfo/routes.php +++ /dev/null @@ -1,93 +0,0 @@ - [ - [ - 'name' => 'Folder#getFolders', - 'url' => '/folders', - 'verb' => 'GET' - ], - [ - 'name' => 'Folder#getFolder', - 'url' => '/folders/{id}', - 'verb' => 'GET' - ], - [ - 'name' => 'Folder#addFolder', - 'url' => '/folders', - 'verb' => 'POST' - ], - [ - 'name' => 'Folder#removeFolder', - 'url' => '/folders/{id}', - 'verb' => 'DELETE' - ], - [ - 'name' => 'Folder#setMountPoint', - 'url' => '/folders/{id}', - 'verb' => 'PUT' - ], - [ - 'name' => 'Folder#addGroup', - 'url' => '/folders/{id}/groups', - 'verb' => 'POST' - ], - [ - 'name' => 'Folder#removeGroup', - 'url' => '/folders/{id}/groups/{group}', - 'verb' => 'DELETE', - 'requirements' => ['group' => '.+'] - ], - [ - 'name' => 'Folder#setPermissions', - 'url' => '/folders/{id}/groups/{group}', - 'verb' => 'POST', - 'requirements' => ['group' => '.+'] - ], - [ - 'name' => 'Folder#setManageACL', - 'url' => '/folders/{id}/manageACL', - 'verb' => 'POST' - ], - [ - 'name' => 'Folder#setQuota', - 'url' => '/folders/{id}/quota', - 'verb' => 'POST' - ], - - [ - 'name' => 'Folder#setACL', - 'url' => '/folders/{id}/acl', - 'verb' => 'POST' - ], - [ - 'name' => 'Folder#renameFolder', - 'url' => '/folders/{id}/mountpoint', - 'verb' => 'POST' - ], - [ - 'name' => 'Folder#aclMappingSearch', - 'url' => '/folders/{id}/search', - 'verb' => 'GET' - ], - [ - 'name' => 'Delegation#getAllGroups', - 'url' => 'delegation/groups', - 'verb' => 'GET' - ], - [ - 'name' => 'Delegation#getAllCircles', - 'url' => 'delegation/circles', - 'verb' => 'GET' - ], - [ - 'name' => 'Delegation#getAuthorizedGroups', - 'url' => '/delegation/authorized-groups', - 'verb' => 'GET', - ], - ]]; diff --git a/lib/Controller/DelegationController.php b/lib/Controller/DelegationController.php index 945c6d9ad..309f3b56d 100644 --- a/lib/Controller/DelegationController.php +++ b/lib/Controller/DelegationController.php @@ -11,6 +11,7 @@ use OCA\GroupFolders\Service\DelegationService; use OCA\Settings\Service\AuthorizedGroupService; use OCP\App\IAppManager; +use OCP\AppFramework\Http\Attribute\ApiRoute; use OCP\AppFramework\Http\Attribute\NoAdminRequired; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCSController; @@ -41,6 +42,7 @@ public function __construct( * @RequireGroupFolderAdmin */ #[NoAdminRequired] + #[ApiRoute(verb: 'GET', url: '/delegation/groups')] public function getAllGroups(): DataResponse { // Get all groups $groups = $this->groupManager->search(''); @@ -63,6 +65,7 @@ public function getAllGroups(): DataResponse { * @RequireGroupFolderAdmin */ #[NoAdminRequired] + #[ApiRoute(verb: 'GET', url: '/delegation/circles')] public function getAllCircles(): DataResponse { $circlesEnabled = $this->appManager->isEnabledForUser('circles'); if (!$circlesEnabled) { @@ -102,6 +105,7 @@ public function getAllCircles(): DataResponse { * @RequireGroupFolderAdmin */ #[NoAdminRequired] + #[ApiRoute(verb: 'GET', url: '/delegation/authorized-groups')] public function getAuthorizedGroups(string $classname = ""): DataResponse { $data = []; $authorizedGroups = $this->authorizedGroupService->findExistingGroupsForClass($classname); diff --git a/lib/Controller/FolderController.php b/lib/Controller/FolderController.php index 45db6e32a..49255a544 100644 --- a/lib/Controller/FolderController.php +++ b/lib/Controller/FolderController.php @@ -14,6 +14,7 @@ use OCA\GroupFolders\Service\FoldersFilter; use OCP\AppFramework\Http; use OCP\AppFramework\Http\Attribute\NoAdminRequired; +use OCP\AppFramework\Http\Attribute\ApiRoute; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCS\OCSNotFoundException; use OCP\AppFramework\OCSController; @@ -89,6 +90,7 @@ private function formatFolder(array $folder): array { } #[NoAdminRequired] + #[ApiRoute(verb: 'GET', url: '/folders')] public function getFolders(bool $applicable = false): DataResponse { $folders = $this->manager->getAllFoldersWithSize($this->getRootFolderStorageId()); $folders = array_map([$this, 'formatFolder'], $folders); @@ -107,6 +109,7 @@ public function getFolders(bool $applicable = false): DataResponse { } #[NoAdminRequired] + #[ApiRoute(verb: 'GET', url: '/folders/{id}')] public function getFolder(int $id): DataResponse { $response = $this->checkFolderExists($id); if ($response) { @@ -145,6 +148,7 @@ private function getRootFolderStorageId(): ?int { * @throws OCSNotFoundException */ #[NoAdminRequired] + #[ApiRoute(verb: 'POST', url: '/folders')] public function addFolder(string $mountpoint): DataResponse { $id = $this->manager->createFolder(trim($mountpoint)); $folder = $this->manager->getFolder($id, $this->rootFolder->getMountPoint()->getNumericStorageId()); @@ -158,6 +162,7 @@ public function addFolder(string $mountpoint): DataResponse { * @RequireGroupFolderAdmin */ #[NoAdminRequired] + #[ApiRoute(verb: 'DELETE', url: '/folders/{id}')] public function removeFolder(int $id): DataResponse { $response = $this->checkFolderExists($id); if ($response) { @@ -173,6 +178,7 @@ public function removeFolder(int $id): DataResponse { * @RequireGroupFolderAdmin */ #[NoAdminRequired] + #[ApiRoute(verb: 'PUT', url: '/folders/{id}')] public function setMountPoint(int $id, string $mountPoint): DataResponse { $this->manager->renameFolder($id, trim($mountPoint)); return new DataResponse(['success' => true]); @@ -182,6 +188,7 @@ public function setMountPoint(int $id, string $mountPoint): DataResponse { * @RequireGroupFolderAdmin */ #[NoAdminRequired] + #[ApiRoute(verb: 'POST', url: '/folders/{id}/groups')] public function addGroup(int $id, string $group): DataResponse { $response = $this->checkFolderExists($id); if ($response) { @@ -195,6 +202,7 @@ public function addGroup(int $id, string $group): DataResponse { * @RequireGroupFolderAdmin */ #[NoAdminRequired] + #[ApiRoute(verb: 'DELETE', url: '/folders/{id}/groups/{group}', requirements: ['group' => '.+'])] public function removeGroup(int $id, string $group): DataResponse { $response = $this->checkFolderExists($id); if ($response) { @@ -208,6 +216,7 @@ public function removeGroup(int $id, string $group): DataResponse { * @RequireGroupFolderAdmin */ #[NoAdminRequired] + #[ApiRoute(verb: 'POST', url: '/folders/{id}/groups/{group}', requirements: ['group' => '.+'])] public function setPermissions(int $id, string $group, int $permissions): DataResponse { $response = $this->checkFolderExists($id); if ($response) { @@ -222,6 +231,7 @@ public function setPermissions(int $id, string $group, int $permissions): DataRe * @throws \OCP\DB\Exception */ #[NoAdminRequired] + #[ApiRoute(verb: 'POST', url: '/folders/{id}/manageACL')] public function setManageACL(int $id, string $mappingType, string $mappingId, bool $manageAcl): DataResponse { $response = $this->checkFolderExists($id); if ($response) { @@ -235,6 +245,7 @@ public function setManageACL(int $id, string $mappingType, string $mappingId, bo * @RequireGroupFolderAdmin */ #[NoAdminRequired] + #[ApiRoute(verb: 'POST', url: '/folders/{id}/quota')] public function setQuota(int $id, int $quota): DataResponse { $response = $this->checkFolderExists($id); if ($response) { @@ -248,6 +259,7 @@ public function setQuota(int $id, int $quota): DataResponse { * @RequireGroupFolderAdmin */ #[NoAdminRequired] + #[ApiRoute(verb: 'POST', url: '/folders/{id}/acl')] public function setACL(int $id, bool $acl): DataResponse { $response = $this->checkFolderExists($id); if ($response) { @@ -261,6 +273,7 @@ public function setACL(int $id, bool $acl): DataResponse { * @RequireGroupFolderAdmin */ #[NoAdminRequired] + #[ApiRoute(verb: 'POST', url: '/folders/{id}/mountpoint')] public function renameFolder(int $id, string $mountpoint): DataResponse { $response = $this->checkFolderExists($id); if ($response) { @@ -308,6 +321,7 @@ private function folderDataForXML(array $data): array { } #[NoAdminRequired] + #[ApiRoute(verb: 'GET', url: '/folders/{id}/search')] public function aclMappingSearch(int $id, ?int $fileId, string $search = ''): DataResponse { $users = []; $groups = [];