IOCMProvider.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2023 Maxence Lange <maxence@artificial-owl.com>
  5. *
  6. * @author Maxence Lange <maxence@artificial-owl.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\OCM;
  25. use JsonSerializable;
  26. use OCP\OCM\Exceptions\OCMArgumentException;
  27. use OCP\OCM\Exceptions\OCMProviderException;
  28. /**
  29. * Model based on the Open Cloud Mesh Discovery API
  30. * @link https://github.com/cs3org/OCM-API/
  31. * @since 28.0.0
  32. */
  33. interface IOCMProvider extends JsonSerializable {
  34. /**
  35. * enable OCM
  36. *
  37. * @param bool $enabled
  38. *
  39. * @return $this
  40. * @since 28.0.0
  41. */
  42. public function setEnabled(bool $enabled): static;
  43. /**
  44. * is set as enabled ?
  45. *
  46. * @return bool
  47. * @since 28.0.0
  48. */
  49. public function isEnabled(): bool;
  50. /**
  51. * get set API Version
  52. *
  53. * @param string $apiVersion
  54. *
  55. * @return $this
  56. * @since 28.0.0
  57. */
  58. public function setApiVersion(string $apiVersion): static;
  59. /**
  60. * returns API version
  61. *
  62. * @return string
  63. * @since 28.0.0
  64. */
  65. public function getApiVersion(): string;
  66. /**
  67. * configure endpoint
  68. *
  69. * @param string $endPoint
  70. *
  71. * @return $this
  72. * @since 28.0.0
  73. */
  74. public function setEndPoint(string $endPoint): static;
  75. /**
  76. * get configured endpoint
  77. *
  78. * @return string
  79. * @since 28.0.0
  80. */
  81. public function getEndPoint(): string;
  82. /**
  83. * add a single resource to the object
  84. *
  85. * @param IOCMResource $resource
  86. *
  87. * @return $this
  88. * @since 28.0.0
  89. */
  90. public function addResourceType(IOCMResource $resource): static;
  91. /**
  92. * set resources
  93. *
  94. * @param IOCMResource[] $resourceTypes
  95. *
  96. * @return $this
  97. * @since 28.0.0
  98. */
  99. public function setResourceTypes(array $resourceTypes): static;
  100. /**
  101. * get all set resources
  102. *
  103. * @return IOCMResource[]
  104. * @since 28.0.0
  105. */
  106. public function getResourceTypes(): array;
  107. /**
  108. * extract a specific string value from the listing of protocols, based on resource-name and protocol-name
  109. *
  110. * @param string $resourceName
  111. * @param string $protocol
  112. *
  113. * @return string
  114. * @throws OCMArgumentException
  115. * @since 28.0.0
  116. */
  117. public function extractProtocolEntry(string $resourceName, string $protocol): string;
  118. /**
  119. * import data from an array
  120. *
  121. * @param array<string, int|string|bool|array> $data
  122. *
  123. * @return $this
  124. * @throws OCMProviderException in case a descent provider cannot be generated from data
  125. * @since 28.0.0
  126. */
  127. public function import(array $data): static;
  128. /**
  129. * @return array{
  130. * enabled: bool,
  131. * apiVersion: string,
  132. * endPoint: string,
  133. * resourceTypes: array{
  134. * name: string,
  135. * shareTypes: string[],
  136. * protocols: array<string, string>
  137. * }[]
  138. * }
  139. * @since 28.0.0
  140. */
  141. public function jsonSerialize(): array;
  142. }