You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Provider.php 3.3KB

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