Provider.php 3.3 KB

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