provider.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * @author Lukas Reschke <lukas@owncloud.com>
  4. *
  5. * @copyright Copyright (c) 2015, ownCloud, Inc.
  6. * @license AGPL-3.0
  7. *
  8. * This code is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License, version 3,
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License, version 3,
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>
  19. *
  20. */
  21. class Provider extends \OCP\AppFramework\Controller {
  22. /** @var \OCP\App\IAppManager */
  23. private $appManager;
  24. /**
  25. * @param string $appName
  26. * @param \OCP\IRequest $request
  27. * @param \OCP\App\IAppManager $appManager
  28. */
  29. public function __construct($appName,
  30. \OCP\IRequest $request,
  31. \OCP\App\IAppManager $appManager) {
  32. parent::__construct($appName, $request);
  33. $this->appManager = $appManager;
  34. }
  35. /**
  36. * @return \OCP\AppFramework\Http\JSONResponse
  37. */
  38. public function buildProviderList() {
  39. $services = [
  40. 'PRIVATE_DATA' => [
  41. 'version' => 1,
  42. 'endpoints' => [
  43. 'store' => '/ocs/v2.php/privatedata/setattribute',
  44. 'read' => '/ocs/v2.php/privatedata/getattribute',
  45. 'delete' => '/ocs/v2.php/privatedata/deleteattribute',
  46. ],
  47. ],
  48. ];
  49. if($this->appManager->isEnabledForUser('files_sharing')) {
  50. $services['SHARING'] = [
  51. 'version' => 1,
  52. 'endpoints' => [
  53. 'share' => '/ocs/v2.php/apps/files_sharing/api/v1/shares',
  54. ],
  55. ];
  56. $services['FEDERATED_SHARING'] = [
  57. 'version' => 1,
  58. 'endpoints' => [
  59. 'share' => '/ocs/v2.php/cloud/shares',
  60. 'webdav' => '/public.php/webdav/',
  61. ],
  62. ];
  63. }
  64. if($this->appManager->isEnabledForUser('activity')) {
  65. $services['ACTIVITY'] = [
  66. 'version' => 1,
  67. 'endpoints' => [
  68. 'list' => '/ocs/v2.php/cloud/activity',
  69. ],
  70. ];
  71. }
  72. if($this->appManager->isEnabledForUser('provisioning_api')) {
  73. $services['PROVISIONING'] = [
  74. 'version' => 1,
  75. 'endpoints' => [
  76. 'user' => '/ocs/v2.php/cloud/users',
  77. 'groups' => '/ocs/v2.php/cloud/groups',
  78. 'apps' => '/ocs/v2.php/cloud/apps',
  79. ],
  80. ];
  81. }
  82. return new \OCP\AppFramework\Http\JSONResponse([
  83. 'version' => 2,
  84. 'services' => $services,
  85. ]);
  86. }
  87. }