provider.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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/v1.php/privatedata/setattribute',
  45. 'read' => '/ocs/v1.php/privatedata/getattribute',
  46. 'delete' => '/ocs/v1.php/privatedata/deleteattribute',
  47. ],
  48. ],
  49. ];
  50. if($this->appManager->isEnabledForUser('files_sharing')) {
  51. $services['SHARING'] = [
  52. 'version' => 1,
  53. 'endpoints' => [
  54. 'share' => '/ocs/v1.php/apps/files_sharing/api/v1/shares',
  55. ],
  56. ];
  57. $services['FEDERATED_SHARING'] = [
  58. 'version' => 1,
  59. 'endpoints' => [
  60. 'share' => '/ocs/v1.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/v1.php/cloud/activity',
  70. ],
  71. ];
  72. }
  73. if($this->appManager->isEnabledForUser('provisioning_api')) {
  74. $services['PROVISIONING'] = [
  75. 'version' => 1,
  76. 'endpoints' => [
  77. 'user' => '/ocs/v1.php/cloud/users',
  78. 'groups' => '/ocs/v1.php/cloud/groups',
  79. 'apps' => '/ocs/v1.php/cloud/apps',
  80. ],
  81. ];
  82. }
  83. return new \OCP\AppFramework\Http\JSONResponse($services);
  84. }
  85. }