1
0

Provider.php 3.3 KB

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