api.php 2.2 KB

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