routes.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bjoern Schiessle <bjoern@schiessle.org>
  6. * @author Björn Schießle <bjoern@schiessle.org>
  7. * @author Christopher Schäpers <kondou@ts.unde.re>
  8. * @author Joas Schilling <coding@schilljs.com>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Robin McCorkell <robin@mccorkell.me.uk>
  11. * @author Thomas Müller <thomas.mueller@tmit.eu>
  12. * @author Tom Needham <tom@owncloud.com>
  13. *
  14. * @license AGPL-3.0
  15. *
  16. * This code is free software: you can redistribute it and/or modify
  17. * it under the terms of the GNU Affero General Public License, version 3,
  18. * as published by the Free Software Foundation.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU Affero General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU Affero General Public License, version 3,
  26. * along with this program. If not, see <http://www.gnu.org/licenses/>
  27. *
  28. */
  29. use OCP\API;
  30. // Config
  31. API::register(
  32. 'get',
  33. '/config',
  34. array('OC_OCS_Config', 'apiConfig'),
  35. 'core',
  36. API::GUEST_AUTH
  37. );
  38. // Person
  39. API::register(
  40. 'post',
  41. '/person/check',
  42. array('OC_OCS_Person', 'check'),
  43. 'core',
  44. API::GUEST_AUTH
  45. );
  46. // Privatedata
  47. API::register(
  48. 'get',
  49. '/privatedata/getattribute',
  50. array('OC_OCS_Privatedata', 'get'),
  51. 'core',
  52. API::USER_AUTH,
  53. array('app' => '', 'key' => '')
  54. );
  55. API::register(
  56. 'get',
  57. '/privatedata/getattribute/{app}',
  58. array('OC_OCS_Privatedata', 'get'),
  59. 'core',
  60. API::USER_AUTH,
  61. array('key' => '')
  62. );
  63. API::register(
  64. 'get',
  65. '/privatedata/getattribute/{app}/{key}',
  66. array('OC_OCS_Privatedata', 'get'),
  67. 'core',
  68. API::USER_AUTH
  69. );
  70. API::register(
  71. 'post',
  72. '/privatedata/setattribute/{app}/{key}',
  73. array('OC_OCS_Privatedata', 'set'),
  74. 'core',
  75. API::USER_AUTH
  76. );
  77. API::register(
  78. 'post',
  79. '/privatedata/deleteattribute/{app}/{key}',
  80. array('OC_OCS_Privatedata', 'delete'),
  81. 'core',
  82. API::USER_AUTH
  83. );
  84. // cloud
  85. API::register(
  86. 'get',
  87. '/cloud/capabilities',
  88. array('OC_OCS_Cloud', 'getCapabilities'),
  89. 'core',
  90. API::USER_AUTH
  91. );
  92. API::register(
  93. 'get',
  94. '/cloud/user',
  95. array('OC_OCS_Cloud', 'getCurrentUser'),
  96. 'core',
  97. API::USER_AUTH
  98. );
  99. // Server-to-Server Sharing
  100. if (\OC::$server->getAppManager()->isEnabledForUser('files_sharing')) {
  101. $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application();
  102. $addressHandler = new \OCA\FederatedFileSharing\AddressHandler(
  103. \OC::$server->getURLGenerator(),
  104. \OC::$server->getL10N('federatedfilesharing')
  105. );
  106. $notification = new \OCA\FederatedFileSharing\Notifications(
  107. $addressHandler,
  108. \OC::$server->getHTTPClientService(),
  109. new \OCA\FederatedFileSharing\DiscoveryManager(\OC::$server->getMemCacheFactory(), \OC::$server->getHTTPClientService()),
  110. \OC::$server->getJobList()
  111. );
  112. $s2s = new OCA\FederatedFileSharing\RequestHandler(
  113. $federatedSharingApp->getFederatedShareProvider(),
  114. \OC::$server->getDatabaseConnection(),
  115. \OC::$server->getShareManager(),
  116. \OC::$server->getRequest(),
  117. $notification,
  118. $addressHandler,
  119. \OC::$server->getUserManager()
  120. );
  121. API::register('post',
  122. '/cloud/shares',
  123. array($s2s, 'createShare'),
  124. 'files_sharing',
  125. API::GUEST_AUTH
  126. );
  127. API::register('post',
  128. '/cloud/shares/{id}/reshare',
  129. array($s2s, 'reShare'),
  130. 'files_sharing',
  131. API::GUEST_AUTH
  132. );
  133. API::register('post',
  134. '/cloud/shares/{id}/permissions',
  135. array($s2s, 'updatePermissions'),
  136. 'files_sharing',
  137. API::GUEST_AUTH
  138. );
  139. API::register('post',
  140. '/cloud/shares/{id}/accept',
  141. array($s2s, 'acceptShare'),
  142. 'files_sharing',
  143. API::GUEST_AUTH
  144. );
  145. API::register('post',
  146. '/cloud/shares/{id}/decline',
  147. array($s2s, 'declineShare'),
  148. 'files_sharing',
  149. API::GUEST_AUTH
  150. );
  151. API::register('post',
  152. '/cloud/shares/{id}/unshare',
  153. array($s2s, 'unshare'),
  154. 'files_sharing',
  155. API::GUEST_AUTH
  156. );
  157. API::register('post',
  158. '/cloud/shares/{id}/revoke',
  159. array($s2s, 'revoke'),
  160. 'files_sharing',
  161. API::GUEST_AUTH
  162. );
  163. }