Add public api for remote api
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
74b5ce8fd4
commit
5133a31d3c
20 changed files with 623 additions and 9 deletions
|
@ -246,6 +246,14 @@ return array(
|
|||
'OCP\\OCS\\IDiscoveryService' => $baseDir . '/lib/public/OCS/IDiscoveryService.php',
|
||||
'OCP\\PreConditionNotMetException' => $baseDir . '/lib/public/PreConditionNotMetException.php',
|
||||
'OCP\\Preview\\IProvider' => $baseDir . '/lib/public/Preview/IProvider.php',
|
||||
'OCP\\Remote\\Api\\IApiCollection' => $baseDir . '/lib/public/Remote/Api/IApiCollection.php',
|
||||
'OCP\\Remote\\Api\\IApiFactory' => $baseDir . '/lib/public/Remote/Api/IApiFactory.php',
|
||||
'OCP\\Remote\\Api\\ICapabilitiesApi' => $baseDir . '/lib/public/Remote/Api/ICapabilitiesApi.php',
|
||||
'OCP\\Remote\\Api\\IUserApi' => $baseDir . '/lib/public/Remote/Api/IUserApi.php',
|
||||
'OCP\\Remote\\ICredentials' => $baseDir . '/lib/public/Remote/ICredentials.php',
|
||||
'OCP\\Remote\\IInstance' => $baseDir . '/lib/public/Remote/IInstance.php',
|
||||
'OCP\\Remote\\IInstanceFactory' => $baseDir . '/lib/public/Remote/IInstanceFactory.php',
|
||||
'OCP\\Remote\\IUser' => $baseDir . '/lib/public/Remote/IUser.php',
|
||||
'OCP\\Response' => $baseDir . '/lib/public/Response.php',
|
||||
'OCP\\RichObjectStrings\\Definitions' => $baseDir . '/lib/public/RichObjectStrings/Definitions.php',
|
||||
'OCP\\RichObjectStrings\\IValidator' => $baseDir . '/lib/public/RichObjectStrings/IValidator.php',
|
||||
|
@ -780,10 +788,13 @@ return array(
|
|||
'OC\\Preview\\XBitmap' => $baseDir . '/lib/private/Preview/XBitmap.php',
|
||||
'OC\\RedisFactory' => $baseDir . '/lib/private/RedisFactory.php',
|
||||
'OC\\Remote\\Api\\ApiBase' => $baseDir . '/lib/private/Remote/Api/ApiBase.php',
|
||||
'OC\\Remote\\Api\\ApiCollection' => $baseDir . '/lib/private/Remote/Api/ApiCollection.php',
|
||||
'OC\\Remote\\Api\\ApiFactory' => $baseDir . '/lib/private/Remote/Api/ApiFactory.php',
|
||||
'OC\\Remote\\Api\\NotFoundException' => $baseDir . '/lib/private/Remote/Api/NotFoundException.php',
|
||||
'OC\\Remote\\Api\\OCS' => $baseDir . '/lib/private/Remote/Api/OCS.php',
|
||||
'OC\\Remote\\Credentials' => $baseDir . '/lib/private/Remote/Credentials.php',
|
||||
'OC\\Remote\\Instance' => $baseDir . '/lib/private/Remote/Instance.php',
|
||||
'OC\\Remote\\InstanceFactory' => $baseDir . '/lib/private/Remote/InstanceFactory.php',
|
||||
'OC\\Remote\\User' => $baseDir . '/lib/private/Remote/User.php',
|
||||
'OC\\Repair' => $baseDir . '/lib/private/Repair.php',
|
||||
'OC\\RepairException' => $baseDir . '/lib/private/RepairException.php',
|
||||
|
|
|
@ -276,6 +276,14 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
|
|||
'OCP\\OCS\\IDiscoveryService' => __DIR__ . '/../../..' . '/lib/public/OCS/IDiscoveryService.php',
|
||||
'OCP\\PreConditionNotMetException' => __DIR__ . '/../../..' . '/lib/public/PreConditionNotMetException.php',
|
||||
'OCP\\Preview\\IProvider' => __DIR__ . '/../../..' . '/lib/public/Preview/IProvider.php',
|
||||
'OCP\\Remote\\Api\\IApiCollection' => __DIR__ . '/../../..' . '/lib/public/Remote/Api/IApiCollection.php',
|
||||
'OCP\\Remote\\Api\\IApiFactory' => __DIR__ . '/../../..' . '/lib/public/Remote/Api/IApiFactory.php',
|
||||
'OCP\\Remote\\Api\\ICapabilitiesApi' => __DIR__ . '/../../..' . '/lib/public/Remote/Api/ICapabilitiesApi.php',
|
||||
'OCP\\Remote\\Api\\IUserApi' => __DIR__ . '/../../..' . '/lib/public/Remote/Api/IUserApi.php',
|
||||
'OCP\\Remote\\ICredentials' => __DIR__ . '/../../..' . '/lib/public/Remote/ICredentials.php',
|
||||
'OCP\\Remote\\IInstance' => __DIR__ . '/../../..' . '/lib/public/Remote/IInstance.php',
|
||||
'OCP\\Remote\\IInstanceFactory' => __DIR__ . '/../../..' . '/lib/public/Remote/IInstanceFactory.php',
|
||||
'OCP\\Remote\\IUser' => __DIR__ . '/../../..' . '/lib/public/Remote/IUser.php',
|
||||
'OCP\\Response' => __DIR__ . '/../../..' . '/lib/public/Response.php',
|
||||
'OCP\\RichObjectStrings\\Definitions' => __DIR__ . '/../../..' . '/lib/public/RichObjectStrings/Definitions.php',
|
||||
'OCP\\RichObjectStrings\\IValidator' => __DIR__ . '/../../..' . '/lib/public/RichObjectStrings/IValidator.php',
|
||||
|
@ -810,10 +818,13 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
|
|||
'OC\\Preview\\XBitmap' => __DIR__ . '/../../..' . '/lib/private/Preview/XBitmap.php',
|
||||
'OC\\RedisFactory' => __DIR__ . '/../../..' . '/lib/private/RedisFactory.php',
|
||||
'OC\\Remote\\Api\\ApiBase' => __DIR__ . '/../../..' . '/lib/private/Remote/Api/ApiBase.php',
|
||||
'OC\\Remote\\Api\\ApiCollection' => __DIR__ . '/../../..' . '/lib/private/Remote/Api/ApiCollection.php',
|
||||
'OC\\Remote\\Api\\ApiFactory' => __DIR__ . '/../../..' . '/lib/private/Remote/Api/ApiFactory.php',
|
||||
'OC\\Remote\\Api\\NotFoundException' => __DIR__ . '/../../..' . '/lib/private/Remote/Api/NotFoundException.php',
|
||||
'OC\\Remote\\Api\\OCS' => __DIR__ . '/../../..' . '/lib/private/Remote/Api/OCS.php',
|
||||
'OC\\Remote\\Credentials' => __DIR__ . '/../../..' . '/lib/private/Remote/Credentials.php',
|
||||
'OC\\Remote\\Instance' => __DIR__ . '/../../..' . '/lib/private/Remote/Instance.php',
|
||||
'OC\\Remote\\InstanceFactory' => __DIR__ . '/../../..' . '/lib/private/Remote/InstanceFactory.php',
|
||||
'OC\\Remote\\User' => __DIR__ . '/../../..' . '/lib/private/Remote/User.php',
|
||||
'OC\\Repair' => __DIR__ . '/../../..' . '/lib/private/Repair.php',
|
||||
'OC\\RepairException' => __DIR__ . '/../../..' . '/lib/private/RepairException.php',
|
||||
|
|
|
@ -21,19 +21,19 @@
|
|||
|
||||
namespace OC\Remote\Api;
|
||||
|
||||
use OC\Remote\Credentials;
|
||||
use OC\Remote\Instance;
|
||||
use OCP\Http\Client\IClientService;
|
||||
use OCP\Remote\ICredentials;
|
||||
use OCP\Remote\IInstance;
|
||||
|
||||
class ApiBase {
|
||||
/** @var Instance */
|
||||
/** @var IInstance */
|
||||
private $instance;
|
||||
/** @var Credentials */
|
||||
/** @var ICredentials */
|
||||
private $credentials;
|
||||
/** @var IClientService */
|
||||
private $clientService;
|
||||
|
||||
public function __construct(Instance $instance, Credentials $credentials, IClientService $clientService) {
|
||||
public function __construct(IInstance $instance, ICredentials $credentials, IClientService $clientService) {
|
||||
$this->instance = $instance;
|
||||
$this->credentials = $credentials;
|
||||
$this->clientService = $clientService;
|
||||
|
|
48
lib/private/Remote/Api/ApiCollection.php
Normal file
48
lib/private/Remote/Api/ApiCollection.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\Remote\Api;
|
||||
|
||||
|
||||
use OCP\Http\Client\IClientService;
|
||||
use OCP\Remote\Api\IApiCollection;
|
||||
use OCP\Remote\ICredentials;
|
||||
use OCP\Remote\IInstance;
|
||||
|
||||
class ApiCollection implements IApiCollection {
|
||||
private $instance;
|
||||
private $credentials;
|
||||
private $clientService;
|
||||
|
||||
public function __construct(IInstance $instance, ICredentials $credentials, IClientService $clientService) {
|
||||
$this->instance = $instance;
|
||||
$this->credentials = $credentials;
|
||||
$this->clientService = $clientService;
|
||||
}
|
||||
|
||||
public function getCapabilitiesApi() {
|
||||
return new OCS($this->instance, $this->credentials, $this->clientService);
|
||||
}
|
||||
|
||||
public function getUserApi() {
|
||||
return new OCS($this->instance, $this->credentials, $this->clientService);
|
||||
}
|
||||
}
|
40
lib/private/Remote/Api/ApiFactory.php
Normal file
40
lib/private/Remote/Api/ApiFactory.php
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\Remote\Api;
|
||||
|
||||
|
||||
use OCP\Http\Client\IClientService;
|
||||
use OCP\Remote\Api\IApiFactory;
|
||||
use OCP\Remote\ICredentials;
|
||||
use OCP\Remote\IInstance;
|
||||
|
||||
class ApiFactory implements IApiFactory {
|
||||
private $clientService;
|
||||
|
||||
public function __construct(IClientService $clientService) {
|
||||
$this->clientService = $clientService;
|
||||
}
|
||||
|
||||
public function getApiCollection(IInstance $instance, ICredentials $credentials) {
|
||||
return new ApiCollection($instance, $credentials, $this->clientService);
|
||||
}
|
||||
}
|
|
@ -26,8 +26,10 @@ use GuzzleHttp\Exception\ClientException;
|
|||
use OC\ForbiddenException;
|
||||
use OC\Remote\User;
|
||||
use OCP\API;
|
||||
use OCP\Remote\Api\ICapabilitiesApi;
|
||||
use OCP\Remote\Api\IUserApi;
|
||||
|
||||
class OCS extends ApiBase {
|
||||
class OCS extends ApiBase implements ICapabilitiesApi, IUserApi {
|
||||
/**
|
||||
* @param string $method
|
||||
* @param string $url
|
||||
|
|
|
@ -22,7 +22,9 @@
|
|||
namespace OC\Remote;
|
||||
|
||||
|
||||
class Credentials {
|
||||
use OCP\Remote\ICredentials;
|
||||
|
||||
class Credentials implements ICredentials {
|
||||
/** @var string */
|
||||
private $user;
|
||||
/** @var string */
|
||||
|
|
|
@ -24,11 +24,12 @@ namespace OC\Remote;
|
|||
use OC\Remote\Api\NotFoundException;
|
||||
use OCP\Http\Client\IClientService;
|
||||
use OCP\ICache;
|
||||
use OCP\Remote\IInstance;
|
||||
|
||||
/**
|
||||
* Provides some basic info about a remote Nextcloud instance
|
||||
*/
|
||||
class Instance {
|
||||
class Instance implements IInstance {
|
||||
/** @var string */
|
||||
private $url;
|
||||
|
||||
|
|
41
lib/private/Remote/InstanceFactory.php
Normal file
41
lib/private/Remote/InstanceFactory.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\Remote;
|
||||
|
||||
|
||||
use OCP\Http\Client\IClientService;
|
||||
use OCP\ICache;
|
||||
use OCP\Remote\IInstanceFactory;
|
||||
|
||||
class InstanceFactory implements IInstanceFactory {
|
||||
private $cache;
|
||||
private $clientService;
|
||||
|
||||
public function __construct(ICache $cache, IClientService $clientService) {
|
||||
$this->cache = $cache;
|
||||
$this->clientService = $clientService;
|
||||
}
|
||||
|
||||
public function getInstance($url) {
|
||||
return new Instance($url, $this->cache, $this->clientService);
|
||||
}
|
||||
}
|
|
@ -22,7 +22,9 @@
|
|||
namespace OC\Remote;
|
||||
|
||||
|
||||
class User {
|
||||
use OCP\Remote\IUser;
|
||||
|
||||
class User implements IUser {
|
||||
/** @var array */
|
||||
private $data;
|
||||
|
||||
|
|
|
@ -89,6 +89,8 @@ use OC\Memcache\ArrayCache;
|
|||
use OC\Memcache\Factory;
|
||||
use OC\Notification\Manager;
|
||||
use OC\OCS\DiscoveryService;
|
||||
use OC\Remote\Api\ApiFactory;
|
||||
use OC\Remote\InstanceFactory;
|
||||
use OC\Repair\NC11\CleanPreviewsBackgroundJob;
|
||||
use OC\RichObjectStrings\Validator;
|
||||
use OC\Security\Bruteforce\Throttler;
|
||||
|
@ -123,6 +125,8 @@ use OCP\IServerContainer;
|
|||
use OCP\ITempManager;
|
||||
use OCP\Contacts\ContactsMenu\IActionFactory;
|
||||
use OCP\Lock\ILockingProvider;
|
||||
use OCP\Remote\Api\IApiFactory;
|
||||
use OCP\Remote\IInstanceFactory;
|
||||
use OCP\RichObjectStrings\IValidator;
|
||||
use OCP\Security\IContentSecurityPolicyManager;
|
||||
use OCP\Share;
|
||||
|
@ -1109,6 +1113,15 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
$c->getConfig()
|
||||
);
|
||||
});
|
||||
|
||||
$this->registerService(IApiFactory::class, function(Server $c) {
|
||||
return new ApiFactory($c->getHTTPClientService());
|
||||
});
|
||||
|
||||
$this->registerService(IInstanceFactory::class, function(Server $c) {
|
||||
$memcacheFactory = $c->getMemCacheFactory();
|
||||
return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->getHTTPClientService());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1878,4 +1891,18 @@ class Server extends ServerContainer implements IServerContainer {
|
|||
public function getCloudIdManager() {
|
||||
return $this->query(ICloudIdManager::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \OCP\Remote\Api\IApiFactory
|
||||
*/
|
||||
public function getRemoteApiFactory() {
|
||||
return $this->query(IApiFactory::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \OCP\Remote\IInstanceFactory
|
||||
*/
|
||||
public function getRemoteInstanceFactory() {
|
||||
return $this->query(IInstanceFactory::class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -541,4 +541,16 @@ interface IServerContainer extends IContainer {
|
|||
* @since 12.0.0
|
||||
*/
|
||||
public function getCloudIdManager();
|
||||
|
||||
/**
|
||||
* @return \OCP\Remote\Api\IApiFactory
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getRemoteApiFactory();
|
||||
|
||||
/**
|
||||
* @return \OCP\Remote\IInstanceFactory
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getRemoteInstanceFactory();
|
||||
}
|
||||
|
|
43
lib/public/Remote/Api/IApiCollection.php
Normal file
43
lib/public/Remote/Api/IApiCollection.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCP\Remote\Api;
|
||||
|
||||
/**
|
||||
* Provides access to the various apis of a remote instance
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
interface IApiCollection {
|
||||
/**
|
||||
* @return IUserApi
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getUserApi();
|
||||
|
||||
/**
|
||||
* @return ICapabilitiesApi
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getCapabilitiesApi();
|
||||
}
|
39
lib/public/Remote/Api/IApiFactory.php
Normal file
39
lib/public/Remote/Api/IApiFactory.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCP\Remote\Api;
|
||||
|
||||
use OCP\Remote\ICredentials;
|
||||
use OCP\Remote\IInstance;
|
||||
|
||||
/**
|
||||
* @since 13.0.0
|
||||
*/
|
||||
interface IApiFactory {
|
||||
/**
|
||||
* @param IInstance $instance
|
||||
* @param ICredentials $credentials
|
||||
* @return IApiCollection
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getApiCollection(IInstance $instance, ICredentials $credentials);
|
||||
}
|
34
lib/public/Remote/Api/ICapabilitiesApi.php
Normal file
34
lib/public/Remote/Api/ICapabilitiesApi.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCP\Remote\Api;
|
||||
|
||||
/**
|
||||
* @since 13.0.0
|
||||
*/
|
||||
interface ICapabilitiesApi {
|
||||
/**
|
||||
* @return array The capabilities in the form of [$appId => [$capability => $value]]
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getCapabilities();
|
||||
}
|
37
lib/public/Remote/Api/IUserApi.php
Normal file
37
lib/public/Remote/Api/IUserApi.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCP\Remote\Api;
|
||||
|
||||
use OCP\Remote\IUser;
|
||||
|
||||
/**
|
||||
* @since 13.0.0
|
||||
*/
|
||||
interface IUserApi {
|
||||
/**
|
||||
* @param string $userId
|
||||
* @return IUser
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getUser($userId);
|
||||
}
|
43
lib/public/Remote/ICredentials.php
Normal file
43
lib/public/Remote/ICredentials.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCP\Remote;
|
||||
|
||||
/**
|
||||
* The credentials for a remote user
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
interface ICredentials {
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getUsername();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getPassword();
|
||||
}
|
66
lib/public/Remote/IInstance.php
Normal file
66
lib/public/Remote/IInstance.php
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCP\Remote;
|
||||
|
||||
/**
|
||||
* Provides some basic info about a remote Nextcloud instance
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
interface IInstance {
|
||||
/**
|
||||
* @return string The url of the remote server without protocol
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getUrl();
|
||||
|
||||
/**
|
||||
* @return string The of of the remote server with protocol
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getFullUrl();
|
||||
|
||||
/**
|
||||
* @return string The full version string in '13.1.2.3' format
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getVersion();
|
||||
|
||||
/**
|
||||
* @return string 'http' or 'https'
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getProtocol();
|
||||
|
||||
/**
|
||||
* Check that the remote server is installed and not in maintenance mode
|
||||
*
|
||||
* @since 13.0.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isActive();
|
||||
}
|
35
lib/public/Remote/IInstanceFactory.php
Normal file
35
lib/public/Remote/IInstanceFactory.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCP\Remote;
|
||||
|
||||
/**
|
||||
* @since 13.0.0
|
||||
*/
|
||||
interface IInstanceFactory {
|
||||
/**
|
||||
* @param $url
|
||||
* @return IInstance
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getInstance($url);
|
||||
}
|
120
lib/public/Remote/IUser.php
Normal file
120
lib/public/Remote/IUser.php
Normal file
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCP\Remote;
|
||||
|
||||
/**
|
||||
* User info for a remote user
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
interface IUser {
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getUserId();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getEmail();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getDisplayName();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getPhone();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getAddress();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getWebsite();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getTwitter();
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getGroups();
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getLanguage();
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getUsedSpace();
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getFreeSpace();
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getTotalSpace();
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*
|
||||
* @since 13.0.0
|
||||
*/
|
||||
public function getQuota();
|
||||
}
|
Loading…
Reference in a new issue