Provider.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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(
  19. $appName,
  20. \OCP\IRequest $request,
  21. private \OCP\App\IAppManager $appManager,
  22. ) {
  23. parent::__construct($appName, $request);
  24. }
  25. /**
  26. * @return JSONResponse
  27. */
  28. public function buildProviderList(): JSONResponse {
  29. $services = [
  30. 'PRIVATE_DATA' => [
  31. 'version' => 1,
  32. 'endpoints' => [
  33. 'store' => '/ocs/v2.php/privatedata/setattribute',
  34. 'read' => '/ocs/v2.php/privatedata/getattribute',
  35. 'delete' => '/ocs/v2.php/privatedata/deleteattribute',
  36. ],
  37. ],
  38. ];
  39. if ($this->appManager->isEnabledForUser('files_sharing')) {
  40. $services['SHARING'] = [
  41. 'version' => 1,
  42. 'endpoints' => [
  43. 'share' => '/ocs/v2.php/apps/files_sharing/api/v1/shares',
  44. ],
  45. ];
  46. $services['FEDERATED_SHARING'] = [
  47. 'version' => 1,
  48. 'endpoints' => [
  49. 'share' => '/ocs/v2.php/cloud/shares',
  50. 'webdav' => '/public.php/webdav/',
  51. ],
  52. ];
  53. }
  54. if ($this->appManager->isEnabledForUser('federation')) {
  55. if (isset($services['FEDERATED_SHARING'])) {
  56. $services['FEDERATED_SHARING']['endpoints']['shared-secret'] = '/ocs/v2.php/cloud/shared-secret';
  57. $services['FEDERATED_SHARING']['endpoints']['system-address-book'] = '/remote.php/dav/addressbooks/system/system/system';
  58. $services['FEDERATED_SHARING']['endpoints']['carddav-user'] = 'system';
  59. } else {
  60. $services['FEDERATED_SHARING'] = [
  61. 'version' => 1,
  62. 'endpoints' => [
  63. 'shared-secret' => '/ocs/v2.php/cloud/shared-secret',
  64. 'system-address-book' => '/remote.php/dav/addressbooks/system/system/system',
  65. 'carddav-user' => 'system'
  66. ],
  67. ];
  68. }
  69. }
  70. if ($this->appManager->isEnabledForUser('activity')) {
  71. $services['ACTIVITY'] = [
  72. 'version' => 1,
  73. 'endpoints' => [
  74. 'list' => '/ocs/v2.php/cloud/activity',
  75. ],
  76. ];
  77. }
  78. if ($this->appManager->isEnabledForUser('provisioning_api')) {
  79. $services['PROVISIONING'] = [
  80. 'version' => 1,
  81. 'endpoints' => [
  82. 'user' => '/ocs/v2.php/cloud/users',
  83. 'groups' => '/ocs/v2.php/cloud/groups',
  84. 'apps' => '/ocs/v2.php/cloud/apps',
  85. ],
  86. ];
  87. }
  88. return new JSONResponse([
  89. 'version' => 2,
  90. 'services' => $services,
  91. ]);
  92. }
  93. }