Provider.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OC\OCS;
  8. use OCP\App\IAppManager;
  9. use OCP\AppFramework\Controller;
  10. use OCP\AppFramework\Http\JSONResponse;
  11. use OCP\IRequest;
  12. class Provider extends Controller {
  13. /**
  14. * @param string $appName
  15. * @param IRequest $request
  16. * @param IAppManager $appManager
  17. */
  18. public function __construct($appName,
  19. \OCP\IRequest $request,
  20. private \OCP\App\IAppManager $appManager) {
  21. parent::__construct($appName, $request);
  22. }
  23. /**
  24. * @return JSONResponse
  25. */
  26. public function buildProviderList(): JSONResponse {
  27. $services = [
  28. 'PRIVATE_DATA' => [
  29. 'version' => 1,
  30. 'endpoints' => [
  31. 'store' => '/ocs/v2.php/privatedata/setattribute',
  32. 'read' => '/ocs/v2.php/privatedata/getattribute',
  33. 'delete' => '/ocs/v2.php/privatedata/deleteattribute',
  34. ],
  35. ],
  36. ];
  37. if ($this->appManager->isEnabledForUser('files_sharing')) {
  38. $services['SHARING'] = [
  39. 'version' => 1,
  40. 'endpoints' => [
  41. 'share' => '/ocs/v2.php/apps/files_sharing/api/v1/shares',
  42. ],
  43. ];
  44. $services['FEDERATED_SHARING'] = [
  45. 'version' => 1,
  46. 'endpoints' => [
  47. 'share' => '/ocs/v2.php/cloud/shares',
  48. 'webdav' => '/public.php/webdav/',
  49. ],
  50. ];
  51. }
  52. if ($this->appManager->isEnabledForUser('federation')) {
  53. if (isset($services['FEDERATED_SHARING'])) {
  54. $services['FEDERATED_SHARING']['endpoints']['shared-secret'] = '/ocs/v2.php/cloud/shared-secret';
  55. $services['FEDERATED_SHARING']['endpoints']['system-address-book'] = '/remote.php/dav/addressbooks/system/system/system';
  56. $services['FEDERATED_SHARING']['endpoints']['carddav-user'] = 'system';
  57. } else {
  58. $services['FEDERATED_SHARING'] = [
  59. 'version' => 1,
  60. 'endpoints' => [
  61. 'shared-secret' => '/ocs/v2.php/cloud/shared-secret',
  62. 'system-address-book' => '/remote.php/dav/addressbooks/system/system/system',
  63. 'carddav-user' => 'system'
  64. ],
  65. ];
  66. }
  67. }
  68. if ($this->appManager->isEnabledForUser('activity')) {
  69. $services['ACTIVITY'] = [
  70. 'version' => 1,
  71. 'endpoints' => [
  72. 'list' => '/ocs/v2.php/cloud/activity',
  73. ],
  74. ];
  75. }
  76. if ($this->appManager->isEnabledForUser('provisioning_api')) {
  77. $services['PROVISIONING'] = [
  78. 'version' => 1,
  79. 'endpoints' => [
  80. 'user' => '/ocs/v2.php/cloud/users',
  81. 'groups' => '/ocs/v2.php/cloud/groups',
  82. 'apps' => '/ocs/v2.php/cloud/apps',
  83. ],
  84. ];
  85. }
  86. return new JSONResponse([
  87. 'version' => 2,
  88. 'services' => $services,
  89. ]);
  90. }
  91. }