IOCMProvider.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\OCM;
  8. use JsonSerializable;
  9. use OCP\OCM\Exceptions\OCMArgumentException;
  10. use OCP\OCM\Exceptions\OCMProviderException;
  11. /**
  12. * Model based on the Open Cloud Mesh Discovery API
  13. * @link https://github.com/cs3org/OCM-API/
  14. * @since 28.0.0
  15. */
  16. interface IOCMProvider extends JsonSerializable {
  17. /**
  18. * enable OCM
  19. *
  20. * @param bool $enabled
  21. *
  22. * @return $this
  23. * @since 28.0.0
  24. */
  25. public function setEnabled(bool $enabled): static;
  26. /**
  27. * is set as enabled ?
  28. *
  29. * @return bool
  30. * @since 28.0.0
  31. */
  32. public function isEnabled(): bool;
  33. /**
  34. * get set API Version
  35. *
  36. * @param string $apiVersion
  37. *
  38. * @return $this
  39. * @since 28.0.0
  40. */
  41. public function setApiVersion(string $apiVersion): static;
  42. /**
  43. * returns API version
  44. *
  45. * @return string
  46. * @since 28.0.0
  47. */
  48. public function getApiVersion(): string;
  49. /**
  50. * configure endpoint
  51. *
  52. * @param string $endPoint
  53. *
  54. * @return $this
  55. * @since 28.0.0
  56. */
  57. public function setEndPoint(string $endPoint): static;
  58. /**
  59. * get configured endpoint
  60. *
  61. * @return string
  62. * @since 28.0.0
  63. */
  64. public function getEndPoint(): string;
  65. /**
  66. * create a new resource to later add it with {@see addResourceType()}
  67. * @return IOCMResource
  68. * @since 28.0.0
  69. */
  70. public function createNewResourceType(): IOCMResource;
  71. /**
  72. * add a single resource to the object
  73. *
  74. * @param IOCMResource $resource
  75. *
  76. * @return $this
  77. * @since 28.0.0
  78. */
  79. public function addResourceType(IOCMResource $resource): static;
  80. /**
  81. * set resources
  82. *
  83. * @param IOCMResource[] $resourceTypes
  84. *
  85. * @return $this
  86. * @since 28.0.0
  87. */
  88. public function setResourceTypes(array $resourceTypes): static;
  89. /**
  90. * get all set resources
  91. *
  92. * @return IOCMResource[]
  93. * @since 28.0.0
  94. */
  95. public function getResourceTypes(): array;
  96. /**
  97. * extract a specific string value from the listing of protocols, based on resource-name and protocol-name
  98. *
  99. * @param string $resourceName
  100. * @param string $protocol
  101. *
  102. * @return string
  103. * @throws OCMArgumentException
  104. * @since 28.0.0
  105. */
  106. public function extractProtocolEntry(string $resourceName, string $protocol): string;
  107. /**
  108. * import data from an array
  109. *
  110. * @param array<string, int|string|bool|array> $data
  111. *
  112. * @return $this
  113. * @throws OCMProviderException in case a descent provider cannot be generated from data
  114. * @since 28.0.0
  115. */
  116. public function import(array $data): static;
  117. /**
  118. * @return array{
  119. * enabled: bool,
  120. * apiVersion: string,
  121. * endPoint: string,
  122. * resourceTypes: array{
  123. * name: string,
  124. * shareTypes: string[],
  125. * protocols: array<string, string>
  126. * }[]
  127. * }
  128. * @since 28.0.0
  129. */
  130. public function jsonSerialize(): array;
  131. }