IOCMProvider.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. // * store signatory (public/private key pair) to sign outgoing/incoming request
  109. // *
  110. // * @param Signatory $signatory
  111. // * @experimental 31.0.0
  112. // */
  113. // public function setSignatory(Signatory $signatory): void;
  114. // /**
  115. // * signatory (public/private key pair) used to sign outgoing/incoming request
  116. // *
  117. // * @return Signatory|null returns null if no Signatory available
  118. // * @experimental 31.0.0
  119. // */
  120. // public function getSignatory(): ?Signatory;
  121. /**
  122. * import data from an array
  123. *
  124. * @param array<string, int|string|bool|array> $data
  125. *
  126. * @return $this
  127. * @throws OCMProviderException in case a descent provider cannot be generated from data
  128. * @since 28.0.0
  129. */
  130. public function import(array $data): static;
  131. /**
  132. * @return array{
  133. * enabled: bool,
  134. * apiVersion: '1.0-proposal1',
  135. * endPoint: string,
  136. * publicKey: array{
  137. * keyId: string,
  138. * publicKeyPem: string
  139. * },
  140. * resourceTypes: list<array{
  141. * name: string,
  142. * shareTypes: list<string>,
  143. * protocols: array<string, string>
  144. * }>,
  145. * version: string
  146. * }
  147. * @since 28.0.0
  148. */
  149. public function jsonSerialize(): array;
  150. }