provider.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. 'version' => 2,
  41. 'PRIVATE_DATA' => [
  42. 'version' => 1,
  43. 'endpoints' => [
  44. 'store' => '/ocs/v2.php/privatedata/setattribute',
  45. 'read' => '/ocs/v2.php/privatedata/getattribute',
  46. 'delete' => '/ocs/v2.php/privatedata/deleteattribute',
  47. ],
  48. ],
  49. ];
  50. if($this->appManager->isEnabledForUser('files_sharing')) {
  51. $services['SHARING'] = [
  52. 'version' => 1,
  53. 'endpoints' => [
  54. 'share' => '/ocs/v2.php/apps/files_sharing/api/v1/shares',
  55. ],
  56. ];
  57. $services['FEDERATED_SHARING'] = [
  58. 'version' => 1,
  59. 'endpoints' => [
  60. 'share' => '/ocs/v2.php/cloud/shares',
  61. 'webdav' => '/public.php/webdav/',
  62. ],
  63. ];
  64. }
  65. if($this->appManager->isEnabledForUser('activity')) {
  66. $services['ACTIVITY'] = [
  67. 'version' => 1,
  68. 'endpoints' => [
  69. 'list' => '/ocs/v2.php/cloud/activity',
  70. ],
  71. ];
  72. }
  73. if($this->appManager->isEnabledForUser('provisioning_api')) {
  74. $services['PROVISIONING'] = [
  75. 'version' => 1,
  76. 'endpoints' => [
  77. 'user' => '/ocs/v2.php/cloud/users',
  78. 'groups' => '/ocs/v2.php/cloud/groups',
  79. 'apps' => '/ocs/v2.php/cloud/apps',
  80. ],
  81. ];
  82. }
  83. return new \OCP\AppFramework\Http\JSONResponse($services);
  84. }
  85. }