api.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * @author Bart Visscher <bartv@thisnet.nl>
  4. * @author Joas Schilling <nickvergessen@owncloud.com>
  5. * @author Morris Jobke <hey@morrisjobke.de>
  6. * @author Tom Needham <tom@owncloud.com>
  7. *
  8. * @copyright Copyright (c) 2015, ownCloud, Inc.
  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. /**
  25. * Public interface of ownCloud for apps to use.
  26. * API Class
  27. *
  28. */
  29. // use OCP namespace for all classes that are considered public.
  30. // This means that they should be used by apps instead of the internal ownCloud classes
  31. namespace OCP;
  32. /**
  33. * This class provides functions to manage apps in ownCloud
  34. * @since 5.0.0
  35. */
  36. class API {
  37. /**
  38. * API authentication levels
  39. * @since 8.1.0
  40. */
  41. const GUEST_AUTH = 0;
  42. const USER_AUTH = 1;
  43. const SUBADMIN_AUTH = 2;
  44. const ADMIN_AUTH = 3;
  45. /**
  46. * API Response Codes
  47. * @since 8.1.0
  48. */
  49. const RESPOND_UNAUTHORISED = 997;
  50. const RESPOND_SERVER_ERROR = 996;
  51. const RESPOND_NOT_FOUND = 998;
  52. const RESPOND_UNKNOWN_ERROR = 999;
  53. /**
  54. * registers an api call
  55. * @param string $method the http method
  56. * @param string $url the url to match
  57. * @param callable $action the function to run
  58. * @param string $app the id of the app registering the call
  59. * @param int $authLevel the level of authentication required for the call (See `self::*_AUTH` constants)
  60. * @param array $defaults
  61. * @param array $requirements
  62. * @since 5.0.0
  63. */
  64. public static function register($method, $url, $action, $app, $authLevel = self::USER_AUTH,
  65. $defaults = array(), $requirements = array()){
  66. \OC_API::register($method, $url, $action, $app, $authLevel, $defaults, $requirements);
  67. }
  68. }