ICloudFederationProviderManager.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2018 Bjoern Schiessle <bjoern@schiessle.org>
  4. *
  5. * @author Bjoern Schiessle <bjoern@schiessle.org>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. *
  8. * @license GNU AGPL version 3 or any later version
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License as
  12. * published by the Free Software Foundation, either version 3 of the
  13. * License, or (at your option) any later version.
  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
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. */
  24. namespace OCP\Federation;
  25. use OCP\Http\Client\IResponse;
  26. use OCP\OCM\Exceptions\OCMProviderException;
  27. /**
  28. * Class ICloudFederationProviderManager
  29. *
  30. * Manage cloud federation providers
  31. *
  32. * @since 14.0.0
  33. *
  34. */
  35. interface ICloudFederationProviderManager {
  36. /**
  37. * Registers an callback function which must return an cloud federation provider
  38. *
  39. * @param string $resourceType which resource type does the provider handles
  40. * @param string $displayName user facing name of the federated share provider
  41. * @param callable $callback
  42. * @throws Exceptions\ProviderAlreadyExistsException
  43. *
  44. * @since 14.0.0
  45. */
  46. public function addCloudFederationProvider($resourceType, $displayName, callable $callback);
  47. /**
  48. * remove cloud federation provider
  49. *
  50. * @param string $resourceType
  51. *
  52. * @since 14.0.0
  53. */
  54. public function removeCloudFederationProvider($resourceType);
  55. /**
  56. * get a list of all cloudFederationProviders
  57. *
  58. * @return array [resourceType => ['resourceType' => $resourceType, 'displayName' => $displayName, 'callback' => callback]]
  59. *
  60. * @since 14.0.0
  61. */
  62. public function getAllCloudFederationProviders();
  63. /**
  64. * get a specific cloud federation provider
  65. *
  66. * @param string $resourceType
  67. * @return ICloudFederationProvider
  68. * @throws Exceptions\ProviderDoesNotExistsException
  69. *
  70. * @since 14.0.0
  71. */
  72. public function getCloudFederationProvider($resourceType);
  73. /**
  74. * send federated share
  75. *
  76. * @param ICloudFederationShare $share
  77. * @return mixed
  78. *
  79. * @since 14.0.0
  80. * @deprecated 29.0.0 - Use {@see sendCloudShare()} instead and handle errors manually
  81. */
  82. public function sendShare(ICloudFederationShare $share);
  83. /**
  84. * @param ICloudFederationShare $share
  85. * @return IResponse
  86. * @throws OCMProviderException
  87. * @since 29.0.0
  88. */
  89. public function sendCloudShare(ICloudFederationShare $share): IResponse;
  90. /**
  91. * send notification about existing share
  92. *
  93. * @param string $url
  94. * @param ICloudFederationNotification $notification
  95. * @return array|false
  96. *
  97. * @since 14.0.0
  98. * @deprecated 29.0.0 - Use {@see sendCloudNotification()} instead and handle errors manually
  99. */
  100. public function sendNotification($url, ICloudFederationNotification $notification);
  101. /**
  102. * @param string $url
  103. * @param ICloudFederationNotification $notification
  104. * @return IResponse
  105. * @throws OCMProviderException
  106. * @since 29.0.0
  107. */
  108. public function sendCloudNotification(string $url, ICloudFederationNotification $notification): IResponse;
  109. /**
  110. * check if the new cloud federation API is ready to be used
  111. *
  112. * @return bool
  113. *
  114. * @since 14.0.0
  115. */
  116. public function isReady();
  117. }