-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39223 from nextcloud/feature/openapi/provisioning…
…_api provisioning_api: Add OpenAPI spec
- Loading branch information
Showing
15 changed files
with
559 additions
and
350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
* @copyright Copyright (c) 2021 Vincent Petry <[email protected]> | ||
* | ||
* @author Vincent Petry <[email protected]> | ||
* @author Kate Döen <[email protected]> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
|
@@ -37,6 +38,15 @@ public function __construct(IAppManager $appManager) { | |
|
||
/** | ||
* Function an app uses to return the capabilities | ||
* | ||
* @return array{ | ||
* provisioning_api: array{ | ||
* version: string, | ||
* AccountPropertyScopesVersion: int, | ||
* AccountPropertyScopesFederatedEnabled: bool, | ||
* AccountPropertyScopesPublishedEnabled: bool, | ||
* }, | ||
* } | ||
*/ | ||
public function getCapabilities() { | ||
$federatedScopeEnabled = $this->appManager->isEnabledForUser('federation'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
* | ||
* @author Joas Schilling <[email protected]> | ||
* @author Roeland Jago Douma <[email protected]> | ||
* @author Kate Döen <[email protected]> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
|
@@ -84,7 +85,9 @@ public function __construct(string $appName, | |
} | ||
|
||
/** | ||
* @return DataResponse | ||
* Get a list of apps | ||
* | ||
* @return DataResponse<Http::STATUS_OK, array{data: string[]}, array{}> | ||
*/ | ||
public function getApps(): DataResponse { | ||
return new DataResponse([ | ||
|
@@ -93,8 +96,13 @@ public function getApps(): DataResponse { | |
} | ||
|
||
/** | ||
* @param string $app | ||
* @return DataResponse | ||
* Get the config keys of an app | ||
* | ||
* @param string $app ID of the app | ||
* @return DataResponse<Http::STATUS_OK, array{data: string[]}, array{}>|DataResponse<Http::STATUS_FORBIDDEN, array{data: array{message: string}}, array{}> | ||
* | ||
* 200: Keys returned | ||
* 403: App is not allowed | ||
*/ | ||
public function getKeys(string $app): DataResponse { | ||
try { | ||
|
@@ -108,10 +116,15 @@ public function getKeys(string $app): DataResponse { | |
} | ||
|
||
/** | ||
* @param string $app | ||
* @param string $key | ||
* @param string $defaultValue | ||
* @return DataResponse | ||
* Get a the config value of an app | ||
* | ||
* @param string $app ID of the app | ||
* @param string $key Key | ||
* @param string $defaultValue Default returned value if the value is empty | ||
* @return DataResponse<Http::STATUS_OK, array{data: string}, array{}>|DataResponse<Http::STATUS_FORBIDDEN, array{data: array{message: string}}, array{}> | ||
* | ||
* 200: Value returned | ||
* 403: App is not allowed | ||
*/ | ||
public function getValue(string $app, string $key, string $defaultValue = ''): DataResponse { | ||
try { | ||
|
@@ -128,10 +141,16 @@ public function getValue(string $app, string $key, string $defaultValue = ''): D | |
* @PasswordConfirmationRequired | ||
* @NoSubAdminRequired | ||
* @NoAdminRequired | ||
* @param string $app | ||
* @param string $key | ||
* @param string $value | ||
* @return DataResponse | ||
* | ||
* Update the config value of an app | ||
* | ||
* @param string $app ID of the app | ||
* @param string $key Key to update | ||
* @param string $value New value for the key | ||
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>|DataResponse<Http::STATUS_FORBIDDEN, array{data: array{message: string}}, array{}> | ||
* | ||
* 200: Value updated successfully | ||
* 403: App or key is not allowed | ||
*/ | ||
public function setValue(string $app, string $key, string $value): DataResponse { | ||
$user = $this->userSession->getUser(); | ||
|
@@ -156,9 +175,15 @@ public function setValue(string $app, string $key, string $value): DataResponse | |
|
||
/** | ||
* @PasswordConfirmationRequired | ||
* @param string $app | ||
* @param string $key | ||
* @return DataResponse | ||
* | ||
* Delete a config key of an app | ||
* | ||
* @param string $app ID of the app | ||
* @param string $key Key to delete | ||
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>|DataResponse<Http::STATUS_FORBIDDEN, array{data: array{message: string}}, array{}> | ||
* | ||
* 200: Key deleted successfully | ||
* 403: App or key is not allowed | ||
*/ | ||
public function deleteKey(string $app, string $key): DataResponse { | ||
try { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
* @author Lukas Reschke <[email protected]> | ||
* @author Roeland Jago Douma <[email protected]> | ||
* @author Tom Needham <[email protected]> | ||
* @author Kate Döen <[email protected]> | ||
* | ||
* @license AGPL-3.0 | ||
* | ||
|
@@ -29,13 +30,18 @@ | |
namespace OCA\Provisioning_API\Controller; | ||
|
||
use OC_App; | ||
use OCA\Provisioning_API\ResponseDefinitions; | ||
use OCP\App\AppPathNotFoundException; | ||
use OCP\App\IAppManager; | ||
use OCP\AppFramework\Http; | ||
use OCP\AppFramework\Http\DataResponse; | ||
use OCP\AppFramework\OCS\OCSException; | ||
use OCP\AppFramework\OCSController; | ||
use OCP\IRequest; | ||
|
||
/** | ||
* @psalm-import-type ProvisioningApiAppInfo from ResponseDefinitions | ||
*/ | ||
class AppsController extends OCSController { | ||
/** @var IAppManager */ | ||
private $appManager; | ||
|
@@ -51,16 +57,19 @@ public function __construct( | |
} | ||
|
||
/** | ||
* @param string|null $filter | ||
* @return DataResponse | ||
* Get a list of installed apps | ||
* | ||
* @param ?string $filter Filter for enabled or disabled apps | ||
* @return DataResponse<Http::STATUS_OK, array{apps: string[]}, array{}> | ||
* @throws OCSException | ||
*/ | ||
public function getApps(string $filter = null): DataResponse { | ||
public function getApps(?string $filter = null): DataResponse { | ||
$apps = (new OC_App())->listAllApps(); | ||
$list = []; | ||
foreach ($apps as $app) { | ||
$list[] = $app['id']; | ||
} | ||
/** @var string[] $list */ | ||
if ($filter) { | ||
switch ($filter) { | ||
case 'enabled': | ||
|
@@ -80,8 +89,10 @@ public function getApps(string $filter = null): DataResponse { | |
} | ||
|
||
/** | ||
* @param string $app | ||
* @return DataResponse | ||
* Get the app info for an app | ||
* | ||
* @param string $app ID of the app | ||
* @return DataResponse<Http::STATUS_OK, ProvisioningApiAppInfo, array{}> | ||
* @throws OCSException | ||
*/ | ||
public function getAppInfo(string $app): DataResponse { | ||
|
@@ -95,8 +106,11 @@ public function getAppInfo(string $app): DataResponse { | |
|
||
/** | ||
* @PasswordConfirmationRequired | ||
* @param string $app | ||
* @return DataResponse | ||
* | ||
* Enable an app | ||
* | ||
* @param string $app ID of the app | ||
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}> | ||
* @throws OCSException | ||
*/ | ||
public function enable(string $app): DataResponse { | ||
|
@@ -110,8 +124,11 @@ public function enable(string $app): DataResponse { | |
|
||
/** | ||
* @PasswordConfirmationRequired | ||
* @param string $app | ||
* @return DataResponse | ||
* | ||
* Disable an app | ||
* | ||
* @param string $app ID of the app | ||
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}> | ||
*/ | ||
public function disable(string $app): DataResponse { | ||
$this->appManager->disableApp($app); | ||
|
Oops, something went wrong.