mirror of
https://github.com/nextcloud/server.git
synced 2026-02-19 02:38:40 -05:00
feat(OCM): Add a way for apps to create a new IOCMResource
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
b246d51cbc
commit
fc445a2eaa
3 changed files with 17 additions and 4 deletions
|
|
@ -28,14 +28,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\CloudFederationAPI;
|
||||
|
||||
use OC\OCM\Model\OCMResource;
|
||||
use OCP\Capabilities\ICapability;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\OCM\Exceptions\OCMArgumentException;
|
||||
use OCP\OCM\IOCMProvider;
|
||||
|
||||
class Capabilities implements ICapability {
|
||||
|
||||
public const API_VERSION = '1.0-proposal1';
|
||||
|
||||
public function __construct(
|
||||
|
|
@ -74,12 +72,12 @@ class Capabilities implements ICapability {
|
|||
|
||||
$this->provider->setEndPoint(substr($url, 0, $pos));
|
||||
|
||||
$resource = new OCMResource();
|
||||
$resource = $this->provider->createNewResourceType();
|
||||
$resource->setName('file')
|
||||
->setShareTypes(['user', 'group'])
|
||||
->setProtocols(['webdav' => '/public.php/webdav/']);
|
||||
|
||||
$this->provider->setResourceTypes([$resource]);
|
||||
$this->provider->addResourceType($resource);
|
||||
|
||||
return ['ocm' => $this->provider->jsonSerialize()];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,6 +95,14 @@ class OCMProvider implements IOCMProvider {
|
|||
return $this->endPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* create a new resource to later add it with {@see IOCMProvider::addResourceType()}
|
||||
* @return IOCMResource
|
||||
*/
|
||||
public function createNewResourceType(): IOCMResource {
|
||||
return new OCMResource();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOCMResource $resource
|
||||
*
|
||||
|
|
|
|||
|
|
@ -90,6 +90,13 @@ interface IOCMProvider extends JsonSerializable {
|
|||
*/
|
||||
public function getEndPoint(): string;
|
||||
|
||||
/**
|
||||
* create a new resource to later add it with {@see addResourceType()}
|
||||
* @return IOCMResource
|
||||
* @since 28.0.0
|
||||
*/
|
||||
public function createNewResourceType(): IOCMResource;
|
||||
|
||||
/**
|
||||
* add a single resource to the object
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue