feat(OCM): Add a way for apps to create a new IOCMResource

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/40885/head
Joas Schilling 2 years ago
parent b246d51cbc
commit fc445a2eaa
No known key found for this signature in database
GPG Key ID: 74434EFE0D2E2205
  1. 6
      apps/cloud_federation_api/lib/Capabilities.php
  2. 8
      lib/private/OCM/Model/OCMProvider.php
  3. 7
      lib/public/OCM/IOCMProvider.php

@ -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…
Cancel
Save