Provider.php 3.2 KB

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