IOCMProvider.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. * create a new resource to later add it with {@see addResourceType()}
  84. * @return IOCMResource
  85. * @since 28.0.0
  86. */
  87. public function createNewResourceType(): IOCMResource;
  88. /**
  89. * add a single resource to the object
  90. *
  91. * @param IOCMResource $resource
  92. *
  93. * @return $this
  94. * @since 28.0.0
  95. */
  96. public function addResourceType(IOCMResource $resource): static;
  97. /**
  98. * set resources
  99. *
  100. * @param IOCMResource[] $resourceTypes
  101. *
  102. * @return $this
  103. * @since 28.0.0
  104. */
  105. public function setResourceTypes(array $resourceTypes): static;
  106. /**
  107. * get all set resources
  108. *
  109. * @return IOCMResource[]
  110. * @since 28.0.0
  111. */
  112. public function getResourceTypes(): array;
  113. /**
  114. * extract a specific string value from the listing of protocols, based on resource-name and protocol-name
  115. *
  116. * @param string $resourceName
  117. * @param string $protocol
  118. *
  119. * @return string
  120. * @throws OCMArgumentException
  121. * @since 28.0.0
  122. */
  123. public function extractProtocolEntry(string $resourceName, string $protocol): string;
  124. /**
  125. * import data from an array
  126. *
  127. * @param array<string, int|string|bool|array> $data
  128. *
  129. * @return $this
  130. * @throws OCMProviderException in case a descent provider cannot be generated from data
  131. * @since 28.0.0
  132. */
  133. public function import(array $data): static;
  134. /**
  135. * @return array{
  136. * enabled: bool,
  137. * apiVersion: string,
  138. * endPoint: string,
  139. * resourceTypes: array{
  140. * name: string,
  141. * shareTypes: string[],
  142. * protocols: array<string, string>
  143. * }[]
  144. * }
  145. * @since 28.0.0
  146. */
  147. public function jsonSerialize(): array;
  148. }